Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Desai
    Member
    • Dec 2013
    • 18

    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
  • omerfaruk
    Member
    • Apr 2013
    • 19

    #2
    you can use string replace in python

    Comment

    • Desai
      Member
      • Dec 2013
      • 18

      #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

      • SNPsaurus
        Registered Vendor
        • May 2013
        • 525

        #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

        • Desai
          Member
          • Dec 2013
          • 18

          #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

          • omerfaruk
            Member
            • Apr 2013
            • 19

            #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

            • wolma
              Member
              • May 2014
              • 23

              #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

              • wolma
                Member
                • May 2014
                • 23

                #8
                Programming Language

                great, this forum removes significant whitespace

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

                Comment

                • Desai
                  Member
                  • Dec 2013
                  • 18

                  #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

                  • dpryan
                    Devon Ryan
                    • Jul 2011
                    • 3478

                    #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

                    • Brian Bushnell
                      Super Moderator
                      • Jan 2014
                      • 2709

                      #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

                      • wolma
                        Member
                        • May 2014
                        • 23

                        #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

                        • westerman
                          Rick Westerman
                          • Jun 2008
                          • 1104

                          #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

                          • SEQadmin2
                            From Collection to Sequencing: Why Sample Preparation and Preservation Define Sequencing Data
                            by SEQadmin2


                            Data variability is still an issue in sequencing technologies despite the advances in reproducibility and accuracy of these platforms. But the problem does not originate in the sequencing itself, but in the previous steps, before the sample reaches the sequencer.


                            The first step is collection, followed by preservation and sample preparation for analysis. Most scientists overlook those steps, but not being careful might just be skewing the experiment’s results.
                            ...
                            06-02-2026, 10:05 AM
                          • SEQadmin2
                            Single-Cell Sequencing at an Inflection Point: Early Impacts of New Platforms and Emerging Trends
                            by SEQadmin2


                            With the launch of new single-cell sequencing platforms in 2026, the field stands at an exciting inflection point. This article surveys the most impactful advances in the field and discusses how they’re reshaping research in cancer, immunology, and beyond.


                            Introduction

                            Single-cell sequencing technologies have undergone remarkable advances over the past decade, transitioning from low-throughput experimental approaches to highly scalable platforms capable of...
                            05-22-2026, 06:42 AM
                          • SEQadmin2
                            Environmental Genomics in the Age of NGS: From Microbes to Conservation Strategies
                            by SEQadmin2

                            Studying ecosystems means dealing with complex, multi-species communities that are hard to observe at scale. This complexity, however, hides many important questions to be answered, from how biogeochemical cycles work and how climate change can affect species distribution to how conservation strategies can work best.


                            Genomics, particularly since the expansion of NGS, has transformed ecosystem ecology. By sequencing environmental DNA, we can now assess biodiversity without direct...
                            05-06-2026, 09:04 AM

                          ad_right_rmr

                          Collapse

                          News

                          Collapse

                          Topics Statistics Last Post
                          Started by SEQadmin2, Today, 08:59 AM
                          0 responses
                          11 views
                          0 reactions
                          Last Post SEQadmin2  
                          Started by SEQadmin2, 06-02-2026, 12:03 PM
                          0 responses
                          21 views
                          0 reactions
                          Last Post SEQadmin2  
                          Started by SEQadmin2, 06-02-2026, 11:40 AM
                          0 responses
                          17 views
                          0 reactions
                          Last Post SEQadmin2  
                          Started by SEQadmin2, 05-28-2026, 11:40 AM
                          0 responses
                          31 views
                          0 reactions
                          Last Post SEQadmin2  
                          Working...