Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts

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

    Leave a comment:


  • wolma
    replied
    @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)

    Leave a comment:


  • Brian Bushnell
    replied
    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.

    Leave a comment:


  • dpryan
    replied
    @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)

    Leave a comment:


  • Desai
    replied
    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,

    Leave a comment:


  • wolma
    replied
    Programming Language

    great, this forum removes significant whitespace

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

    Leave a comment:


  • wolma
    replied
    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

    Leave a comment:


  • omerfaruk
    replied
    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

    Leave a comment:


  • Desai
    replied
    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

    Leave a comment:


  • SNPsaurus
    replied
    at a unix command line:
    awk '/^>/ {printf("\n%s\n",$0);next; } { printf("%s",$0);} END {printf("\n");}' < test.txt

    Leave a comment:


  • Desai
    replied
    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?

    Leave a comment:


  • omerfaruk
    replied
    you can use string replace in python

    Leave a comment:


  • Desai
    started a topic Programming Language

    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

Latest Articles

Collapse

  • SEQadmin2
    The Factors Reshaping Genome Assembly
    by SEQadmin2



    When the Human Genome Project declared the human genome finished in 2003, portions of the sequence were still missing, including many of its most repetitive and structurally complex regions.1 Still, for the next two decades, researchers analyzed their sequencing data against the single linear reference that came out of this effort. Released in 2013 as GRCh38, that reference has powered countless discoveries, but it has gaps and cannot capture the genetic diversity of the world’s...
    11-24-2026, 07:04 AM

ad_right_rmr

Collapse

News

Collapse

Topics Statistics Last Post
Started by SEQadmin2, Today, 11:10 AM
0 responses
11 views
0 reactions
Last Post SEQadmin2  
Started by SEQadmin2, Yesterday, 11:06 AM
0 responses
20 views
0 reactions
Last Post SEQadmin2  
Started by SEQadmin2, 11-23-2026, 11:11 AM
0 responses
58 views
0 reactions
Last Post SEQadmin2  
Started by SEQadmin2, 11-17-2026, 06:27 AM
0 responses
55 views
0 reactions
Last Post SEQadmin2  
Working...