-
Notifications
You must be signed in to change notification settings - Fork 0
/
phre.py
30 lines (25 loc) · 676 Bytes
/
phre.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Read Quality Distribution
# https://rosalind.info/problems/phre/
from Bio import SeqIO
import io
fasta_str = """@Rosalind_0041
GGCCGGTCTATTTACGTTCTCACCCGACGTGACGTACGGTCC
+
6.3536354;.151<211/0?::6/-2051)-*"40/.,+%)
@Rosalind_0041
TCGTATGCGTAGCACTTGGTACAGGAAGTGAACATCCAGGAT
+
AH@FGGGJ<GB<<9:GD=D@GG9=?A@DC=;:?>839/4856
@Rosalind_0041
ATTCGGTAATTGGCGTGAATCTGTTCTGACTGATAGAGACAA
+
@DJEJEA?JHJ@8?F?IA3=;8@C95=;=?;>D/:;74792.
"""
records = list(SeqIO.parse(io.StringIO(fasta_str), "fastq"))
count = 0
threshold = 28
for record in records:
quality = record.letter_annotations["phred_quality"]
if sum(quality)/len(quality) < threshold:
count += 1
print(count)