Module 11
Reading FASTA
Parsing FASTA with SeqIO.
Easy FASTA parsing
SeqIO.parse() reads a FASTA file and yields SeqRecord objects. Each record has an id and a sequence.
from Bio import SeqIO
from io import StringIO
fasta_data = ">Tv01\nATGC\n>Tv02\nGGGG"
handle = StringIO(fasta_data)
for record in SeqIO.parse(handle, "fasta"):
print(record.id, len(record))Your task
Read FASTA with SeqIO
- Parse a FASTA string and print each record's id and length.