Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Programming Language

    Dear Friends,

    I am newbie in Biology field, I dont know how to use progrmming language. My query is I have one file which I want to convert in simple file which should be without white space, line breaker and without any space, e.g I have attached my file with this query. I need some script or some command.

    Thank you for viewing replying in advance,
    Have great day ahead
    Attached Files

  • #2
    you can use string replace in python

    Comment


    • #3
      Originally posted by omerfaruk View Post
      you can use string replace in python
      Hey, thanks for your help but as I said I dont know how to use python. Could you do it for me? Thank you for giving your time?

      Comment


      • #4
        at a unix command line:
        awk '/^>/ {printf("\n%s\n",$0);next; } { printf("%s",$0);} END {printf("\n");}' < test.txt
        Providing nextRAD genotyping and PacBio sequencing services. http://snpsaurus.com

        Comment


        • #5
          Originally posted by SNPsaurus View Post
          at a unix command line:
          awk '/^>/ {printf("\n%s\n",$0);next; } { printf("%s",$0);} END {printf("\n");}' < test.txt
          Hey friend Thank you for reply. However still it dosent working for me, the script which you had send that was just for the that test.txt file not working with my original problem file . I am here attaching second file which is exact format that I want. Please help me, Its very urgent. I have to analysis thousands files so I can not waste time behind erasing every space.

          Thanks again for your help.
          Attached Files

          Comment


          • #6
            make eol_format.py executable with chmod a+x eol_format.py

            run as:

            python eol_format.py test.txt (put a space after .py and write file path/name)

            this will write you a file with test.txt.edit.txt.

            Code is pretty straightforward, you can read what it does and change by checking syntax by googling.
            Attached Files

            Comment


            • #7
              omerfaruk's script works though it doesn't really show the beauty of the python language, so here is a more elegant version of it:

              import sys

              with open(sys.argv[1], 'r') as infile:
              with open(sys.argv[2], 'w') as outfile:
              for line in infile:
              if line[0] != '>':
              line = line.strip()
              outfile.write(line)

              copy this exactly as it is formatted to a text editor, save it under whatevername.py, then from the command line run it like this:

              python nameofscript input_file output_file

              Recommendation: if you consider learning one programming language, choose python.

              Cheers,
              Wolfgang

              Comment


              • #8
                Programming Language

                great, this forum removes significant whitespace

                so here's the script again as an attachment with correct formatting.
                Attached Files

                Comment


                • #9
                  Thank you Reply

                  Tons of thank you omerfaruk and wolma. It really helped me. I did know about python much but now I would like to learn because of beauty of python, thanks again wolma and omerfaruk.

                  Have great time ahead,

                  Comment


                  • #10
                    @wolma: You need to just use the "code" tags:

                    Code:
                    import sys
                    
                    with open(sys.argv[1], 'r') as infile:
                    with open(sys.argv[2], 'w') as outfile:
                    for line in infile:
                        if line[0] != '>':
                            line = line.strip()
                        outfile.write(line)

                    Comment


                    • #11
                      Originally posted by dpryan View Post
                      @wolma: You need to just use the "code" tags:
                      Or a language where indent level is not syntactically relevant *cough*

                      Just kidding, I think Python is a good choice in this case.

                      Comment


                      • #12
                        @dpryan: Thanks for the hint (should have read the FAQ before complaining) !

                        I'll give it a try with a slightly enhanced version of my previous suggestion. This one will work correctly with multisequence fasta files (my first version would not put a line break between the end of the previous sequence and a new title line):

                        Code:
                        import sys
                        
                        record_sep = ''
                        with open(sys.argv[1], 'r') as infile:
                            with open(sys.argv[2], 'w') as outfile:
                                for line in infile:
                                    if line[0] == '>':
                                        outfile.write(record_sep)
                                        record_sep = '\n'
                                    else:
                                        line = line.strip()
                                    outfile.write(line)

                        Comment


                        • #13
                          Originally posted by wolma View Post
                          great, this forum removes significant whitespace
                          Only if you consider whitespace to be significant. :-)

                          Comment

                          Latest Articles

                          Collapse

                          • seqadmin
                            Strategies for Sequencing Challenging Samples
                            by seqadmin


                            Despite advancements in sequencing platforms and related sample preparation technologies, certain sample types continue to present significant challenges that can compromise sequencing results. Pedro Echave, Senior Manager of the Global Business Segment at Revvity, explained that the success of a sequencing experiment ultimately depends on the amount and integrity of the nucleic acid template (RNA or DNA) obtained from a sample. “The better the quality of the nucleic acid isolated...
                            03-22-2024, 06:39 AM
                          • seqadmin
                            Techniques and Challenges in Conservation Genomics
                            by seqadmin



                            The field of conservation genomics centers on applying genomics technologies in support of conservation efforts and the preservation of biodiversity. This article features interviews with two researchers who showcase their innovative work and highlight the current state and future of conservation genomics.

                            Avian Conservation
                            Matthew DeSaix, a recent doctoral graduate from Kristen Ruegg’s lab at The University of Colorado, shared that most of his research...
                            03-08-2024, 10:41 AM

                          ad_right_rmr

                          Collapse

                          News

                          Collapse

                          Topics Statistics Last Post
                          Started by seqadmin, Yesterday, 06:37 PM
                          0 responses
                          8 views
                          0 likes
                          Last Post seqadmin  
                          Started by seqadmin, Yesterday, 06:07 PM
                          0 responses
                          8 views
                          0 likes
                          Last Post seqadmin  
                          Started by seqadmin, 03-22-2024, 10:03 AM
                          0 responses
                          49 views
                          0 likes
                          Last Post seqadmin  
                          Started by seqadmin, 03-21-2024, 07:32 AM
                          0 responses
                          67 views
                          0 likes
                          Last Post seqadmin  
                          Working...
                          X