Originally posted by wolma
View Post
Unconfigured Ad
Collapse
X
-
@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:
-
Or a language where indent level is not syntactically relevant *cough*Originally posted by dpryan View Post@wolma: You need to just use the "code" tags:
Just kidding, I think Python is a good choice in this case.
Leave a comment:
-
@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:
-
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:
-
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:
-
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:
-
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:
-
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.Originally posted by SNPsaurus View Postat a unix command line:
awk '/^>/ {printf("\n%s\n",$0);next; } { printf("%s",$0);} END {printf("\n");}' < test.txt
Thanks again for your help.Attached Files
Leave a comment:
-
at a unix command line:
awk '/^>/ {printf("\n%s\n",$0);next; } { printf("%s",$0);} END {printf("\n");}' < test.txt
Leave a comment:
-
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 aheadAttached FilesTags: None
Latest Articles
Collapse
-
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...-
Channel: Articles
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
by SEQadmin2
Today, 11:10 AM
|
||
|
Single-Nucleus Sequencing Links Type 2 Diabetes Risk Variants to Specific Muscle Cell Types
by SEQadmin2
Started by SEQadmin2, Yesterday, 11:06 AM
|
0 responses
20 views
0 reactions
|
Last Post
by SEQadmin2
Yesterday, 11:06 AM
|
||
|
Started by SEQadmin2, 11-23-2026, 11:11 AM
|
0 responses
58 views
0 reactions
|
Last Post
by SEQadmin2
11-23-2026, 11:11 AM
|
||
|
Started by SEQadmin2, 11-17-2026, 06:27 AM
|
0 responses
55 views
0 reactions
|
Last Post
by SEQadmin2
11-17-2026, 06:27 AM
|
Leave a comment: