This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Empty fasta headers

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

1 answer

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

Thanks Frederic!

Log in to answer this question.