我有这样的输入文件
@a
CTCTCTTTAGAACAATCATCACATACCCCTGGTT
+
1>1A>FDF3113B11BB1BAED1D11BAEE0ABG
@b
CAATGCAGCGAACAATGTTCTGGTGGTTGAATTT
+
111>1@11C?1AE?BFDGGGGGBGCCGGGGHHHH
....
我计算了此文件中的平均质量分数,但在计算标准时需要帮助 该分数的偏差
这里我做了什么
import sys,csv
import numpy as np
import math
r = open(sys.argv[1],"r")
length =200
a = np.zeros(length)
b = np.zeros(length)
av = np.zeros(length)
while True:
id = reads.readline().rstrip()
if id == "":
break
seq= r.readline().rstrip()
p = r.readline().rstrip()
qua = r.readline().rstrip()
l= len(qua)
q = [ord(character) - 33 for character in qua]
for i in range(l):
a[i] += q[i]
b[i] += 1
for j in range(length):
av[j] = float(a[j]) / b[j]
s2 = sum((x - av[j])**2 for x in q[i])/b[j] # error in this
standard_deviation = s2**0.5
print standard_deviation
答案 0 :(得分:0)
这个怎么样?
import sys,csv
import numpy as np
import math
r = open(sys.argv[1],"r")
while True:
id = reads.readline().rstrip()
if id == "":
break
seq= r.readline().rstrip()
p = r.readline().rstrip()
qua = r.readline().rstrip()
q = [ord(character) - 33 for character in qua]
mean = np.mean(q)
standard_deviation = np.std(q)