Module 9

Reading one FASTA record

Parsing a single record.

Parsing a record

To parse a FASTA record, you split it into lines, take the first line as the header, and join the rest as the sequence.

Python
fasta = ">Tv01\nATGCGT\nAATGC"
lines = fasta.split("\n")
header = lines[0]
sequence = "".join(lines[1:])
print(header)
print(sequence)
>Tv01 ATGCGTAATGC
Your task

Parse a FASTA record

  • Parse a FASTA string and print header and sequence.