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
                            Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
                            by SEQadmin2



                            Genomics studies in neuroscience face a special challenge due to the brain’s complexity and scarcity of samples. Mapping changes in cell type and state using conventional next-generation sequencing methods remains challenging. Advances in technologies like single-cell sequencing, spatial transcriptomics, and long-read sequencing have opened the door to deeper studies of the brain and diseases like Alzheimer’s, amyotrophic lateral sclerosis (ALS), and schizophrenia.
                            ...
                            07-09-2026, 11:10 AM
                          • SEQadmin2
                            Cancer Drug Resistance: The Lingering Barrier to Rising Survival
                            by SEQadmin2



                            Cancer survival rates have significantly increased in the last few decades in the United States, reaching a combined 70% 5-year survival rate by 2021. Behind this number, there are years of research to find new therapies, drug targets, and early detection methods. But there is one core challenge that keeps slowing down these advances, and it’s about drug resistance.

                            There is no single reason why many patients don’t respond to treatment as expected. Cancer is...
                            07-08-2026, 05:17 AM
                          • GATTACAT
                            Reply to Nine Things a Sample Prep Scientist Thinks About Before Sequencing
                            by GATTACAT
                            Love this - good data definitely starts from good input, and poor input can only give relatively poor data. I particularly like the mention of Nanodrop/absorbance based methods for quantification. It's such a toss up if you'll get an accurate reading or what amounts to a randomly generated number, and a lot of library/sequencing related issues can be traced back to poor quant.
                            07-01-2026, 11:43 AM

                          ad_right_rmr

                          Collapse

                          News

                          Collapse

                          Topics Statistics Last Post
                          Started by SEQadmin2, Today, 10:26 AM
                          0 responses
                          9 views
                          0 reactions
                          Last Post SEQadmin2  
                          Started by SEQadmin2, 07-09-2026, 10:04 AM
                          0 responses
                          24 views
                          0 reactions
                          Last Post SEQadmin2  
                          Started by SEQadmin2, 07-08-2026, 10:08 AM
                          0 responses
                          16 views
                          0 reactions
                          Last Post SEQadmin2  
                          Started by SEQadmin2, 07-07-2026, 11:05 AM
                          0 responses
                          33 views
                          0 reactions
                          Last Post SEQadmin2  
                          Working...