-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphred_scale.py
executable file
·35 lines (25 loc) · 935 Bytes
/
phred_scale.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
31
32
33
34
35
#!/usr/bin/env python
import sys
import os
import string
import re
from optparse import OptionParser
import math
""" just a simple script to help convert phred scaled probablity and error probablilty """
def main():
usage = "usage: %prog [options] number"
parser = OptionParser(usage)
parser.add_option("--Q", action="store_true", dest="qscore", help="report the phred scaled quality")
parser.add_option("--P", action="store_true", dest="pscore", help="report the error probability ")
(options, args)=parser.parse_args()
number=args[0]
number=float(number)
if options.pscore==True:
print "error probability: ", pow(10,(-number/10))
elif options.qscore==True:
print "phred-scaled probablity: ", -10 * math.log10(number)
else:
sys.stderr.write("did you forget to specity --Q or --P option?\n")
exit(1)
if __name__ == "__main__":
main()