I am not aware of an official fasta format description. The only constraint that I know of is that there should not be any whitespace after >
The only constraint that I know of is that there should not be any whitespace after . Apart from that particular position, whitespaces are allowed in the header line.>
So, regarding your particular example, both are valid fasta sequences. When in doubt, you can use SeqIO
from Biopython
, if you can parse your file with the following code, it is should be a valid fasta file.
from Bio import SeqIO
with open("example.fasta") as handle:
for record in SeqIO.parse(handle, "fasta"):
print(record.id)
Edit per @Chris_Rands' comment
The code below does the same as above, meaning that SeqIO.parse()
takes care of opening and closing the file.
from Bio import SeqIO
for record in SeqIO.parse("example.fasta", "fasta"):
print(record.id)