我必须实现以下算法:equation其中“I”包含R、K、H和Nterm,“j”包含D、E、C、Y和返回净电荷的正字符m。这种方法被另一种方法用来计算pI,它基本上是产生最低电荷的pH值。在
以下是我目前所掌握的情况:class ProteinParam :
aa2mw = {
'A': 89.093, 'G': 75.067, 'M': 149.211, 'S': 105.093, 'C': 121.158,
'H': 155.155, 'N': 132.118, 'T': 119.119, 'D': 133.103, 'I': 131.173,
'P': 115.131, 'V': 117.146, 'E': 147.129, 'K': 146.188, 'Q': 146.145,
'W': 204.225, 'F': 165.189, 'L': 131.173, 'R': 174.201, 'Y': 181.189
}
mwH2O = 18.015
aa2abs280= {'Y':1490, 'W': 5500, 'C': 125}
aacomp = {}
aa2chargePos = {'K': 10.5, 'R':12.4, 'H':6}
aa2chargeNeg = {'D': 3.86, 'E': 4.25, 'C': 8.33, 'Y': 10}
aaNterm = 9.69
aaCterm = 2.34
def __init__ (self, protein):
l = ''.join(protein).split()
l = ''.join(l).upper()
clean_prot = ""
for aa in l:
if aa in ProteinParam.aa2mw:
clean_prot += aa
else:
pass
self.protString = clean_prot
for i in ProteinParam.aa2mw:
ProteinParam.aacomp[i] = 0
for aa in self.protString:
if aa in ProteinParam.aacomp:
ProteinParam.aacomp[aa] += 1
def aaCount (self):
return(len(self.protString))
def pI (self):
best_charge = 100000000
for test_pH in range (14000):
test_pH += 1
test_pH = (test_pH / 100)
new_charge = self.charge(test_pH)
if new_charge < best_charge:
best_charge = new_charge
return best_charge
def aaComposition (self) :
return ProteinParam.aacomp
def charge (self, pH):
self.pH = pH
negative = 0
positive = 0
for pos in ['R', 'K', 'H']:
positive += ((ProteinParam.aacomp[pos]) * ((10 ** ProteinParam.aa2chargePos[pos]) / (((10 ** ProteinParam.aa2chargePos[pos])) + (10 ** self.pH))))
positive += ProteinParam.aaNterm
for neg in ['D', 'E', 'C', 'Y']:
negative += ((ProteinParam.aacomp[neg]) * ((10 ** self.pH) / (((10 ** ProteinParam.aa2chargeNeg[neg])) + (10 ** self.pH))))
negative += ProteinParam.aaCterm
total = positive - negative
return total
prot_in = input("Enter a protein: ")
prot_obj = ProteinParam(prot_in)
x = prot_obj.pI()
print(x)
问题是,无论我输入什么,当我调用pI()时,我总是返回6.35,我不知道问题出在哪里。我怀疑它在charge()方法中,因为我不知道它在哪里,而且缺少错误并不能缩小它的范围。输入“vlspaktnvkaaw”应给出9.88的pI。有什么想法吗?在