我是python的新手,并且被要求编写一个代码,我输入特定的DNA序列并获得该序列的各种值作为回报。我制作了一本字典,但是我很难让代码重新调用字典中的值。代码如下:
import math
def dnaTM(seqobj):
if isinstance(seqobj,SeqRecord):
seq = seqobj.seq.tostring().upper()
elif isinstance(seqobj,Seq):
seq = seqobj.tostring().upper()
elif isinstance(seqobj,str):
seq = seqobj.upper()
C_primer = .000001
C_Monovalent = 1
percentage_annealed = 50
percentage_annealed = percentage_annealed/100.0
R = 1.987
deltaH = dict()
deltaS = dict()
deltaH = { 'AA/TT': -7.9, 'AT/TA': -7.2, 'TA/AT': -7.2, 'CA/GT': -8.5,
'GT/CA': -8.4, 'CT/GA': -7.8, 'GA/CT': -8.2, 'CG/GC': -10.6,
'GC/CG': -9.8, 'GG/CC': -8.0, 'GC_init': 0.1, 'AT_init': 2.3}
deltaS = { 'AA/TT': -22.2, 'AT/TA': -20.4, 'TA/AT': -21.3, 'CA/GT': -22.7,
'GT/CA': -22.4, 'CT/GA': -21.0, 'GA/CT': -22.2, 'CG/GC': -27.2,
'GC/CG': -24.4, 'GG/CC': -19.9, 'GC_init': -2.8, 'AT_init': 4.1,
'sym': -1.4}
seqLength = len(seq)
dH = 0.2 + deltaH[str(seq[0])] + deltaH[str(seq[len(seq)-1])]
dS = -5.7 + deltaS[seq[0]] + deltaS[seq[len(seq)-1]]
for i in range(0, seqLength - 1):
dH += deltaH[str(seq[i:i+2])]
dS += deltaS[seq[i:i+2]]
dS = dS + 0.368 * seqLength * math.log(1)
Tm =(dH * 1000) / (dS + R * (math.log(C_primer*(1- percentage_annealed)/percenta\
ge_annealed)-21.4164))
return Tm