This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Parsing fasta file using seqIO

How to check if a multiple sequence file is in fasta format while parsing using seqIO

sequence biopython fasta parsing

Hello

I have a multiple sequence file in fasta format.I am trying to parse sequences in python. All I need to check is the presence of '>' before every sequence. While this can be easily executed otherwise, I was hoping there would be a simpler option using SeqIO.parse. For now, if the sequences are not preceded by '>', I do not get any parsed output. thanks!

Please use ADD COMMENT or ADD REPLY to answer to previous reactions, as such this thread remains logically structured and easy to follow. I have now moved your post but as you can see it's not optimal. Adding an answer should only be used for providing a solution to the question asked.

BioPerl's SeqIO? Biopython's SeqIO? Some other seqIO? (Only clear from the tags you've added)

2 answers

You can’t really use SeqIO to check if the sequences are in fasta format, since SeqIO requires you to tell it that information when you read a file in (other than assuming its a FASTA, and waiting for it to fail if it isn’t).

It looks like this question has been asked before. Here's a response in Perl A: Check If A File Is In Fasta Format

Log in to answer this question.