This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Check whether a fasta header has sequence underneath it

Hello

I have a .ffn file having 1000 sequences. I wanted to check whether all the fasta headers have sequence underneath them, and it would be great if I also get to know about the fasta headers which do not have sequences underneath them.

Thanks

sequencing sequence

1 answer

BioPython is ideal for this.

from Bio import SeqIO

records=list(SeqIO.parse("your_file.fasta","fasta"))
for record in records:
    if len(record.seq)==0:
        printrecord.id)

This will give you ids of headers without any sequences.

The key message here is that most commonly-used languages have libraries to parse fasta; then it's just a case of applying the appropriate methods (string length in this case).

Log in to answer this question.