This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Import the quality scores from a FASTQ file in Python 3 Biopython

Hi,

I would like to import the FASTQ scores in Python. I have figured the 'seq' attribute from the records in a FASTQ object but does anybody know how to extract the quality score as well, please?

from Bio import SeqIO
records = SeqIO.parse("assembly.fastq", "fastq")
for i, record in enumerate(records):
    if i == 1:
        print(record.seq)
        break

Thanks.

Best, C.

python3 fastq biopython quality fasta

1 answer

Try this:

from Bio import SeqIO
for record in SeqIO.parse(input_file, "fastq"):
    score=record.letter_annotations["phred_quality"]

Log in to answer this question.