Skip to content

Commit b96851b

Browse files
committed
add except
1 parent 3d275d5 commit b96851b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

phred_per_read.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@ def phred_to_number(fastqfile):
3434
for n in range(0, count):
3535
name = fastq[4 * n]
3636
qualityscore = fastq[4 * n + 3]
37-
score_one=[phred[i] for i in qualityscore]
37+
score_one=[]
38+
for i in qualityscore:
39+
try:
40+
score_one.append(phred[i])
41+
except KeyError as e:
42+
logging.warnings("score char not in sanger 0-45 range", e)
43+
3844
score_one_mean=mean(score_one)
3945
# Note the last word in qyalityscore is "\n"
4046
print("{}\t{}".format(name, score_one_mean))

0 commit comments

Comments
 (0)