Thank you so much!!!!
Hi!
I need help with solving the following question with Python3:
Write a Python program that reads a fastq file and calculate how many bases have Phred base read quality of zero, between 1 and 10 (inclusive), 11 and 20, 21 and 30, 31 and 40, and above 40.
The final results should be like:
Base quality zero: XXX bases
Base quality 1-10: YYY bases
Base quality 11-20: ZZZ bases
Base quality 21-30: QQQ bases
Base quality 31-40: RRR bases
Base quality above 40: SSS bases
I don't know where to start. Any help will be greatly appreciated!
1 answer
To decode a base quality of say character I can use the formula ord("I") - 33
qual = ord("I") - 33
print (qual)
prints the Phred quality for character I as
40
to apply this to multiple codes, put it into a function:
def decode(c):
return ord(c) - 33
letters = "II93882$%@%%@"
values = map(decode, letters)
values = list(values)
print (values)
prints:
[40, 40, 24, 18, 23, 23, 17, 3, 4, 31, 4, 4, 31]
this should be sufficient to get your started
Log in to answer this question.
And I know the post Python 3: Only Look at Quality Line. Still having difficulties.
No one wants to write your program for you. If you really want help, post your code, and people will probably be be to see why it's not working.