Empty fasta headers
1
0
Entering edit mode
10.5 years ago
GP ▴ 10

Hi All,

I want to remove empty fasta headers from the fasta file. I used the commands from this biostar post but they seems to work only for nt sequence file (strange!) and I have file with short aa sequnces, would be helpful if anyone help me with one liner perl or awk or similar. Thanks for any help.

infile.fasta

>Seq_1
CMRPQWSIGSN
>Seq_2
>Seq_3
WSIGSNCMRPQWCMRPQ

Output I want:

>Seq_1
CMRPQWSIGSN
>Seq_3
WSIGSNCMRPQWCMRPQ
sequence • 3.5k views
ADD COMMENT
2
Entering edit mode
10.5 years ago

The biostar post you linked gives a awk command that does the job, even for amino acid sequences:

awk 'BEGIN {RS = ">" ; FS = "\n" ; ORS = ""} $2 {print ">"$0}' input.fas > output.fas
ADD COMMENT
0
Entering edit mode

Thanks Frederic!

ADD REPLY

Login before adding your answer.

Traffic: 2518 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6