我要和Stepic一起去上课。我认为两个字符串之间的一个简单断言失败了。不然我怎么才能检查平等呢?谢谢,吉姆
def weights_to_letters(peptide):
'''
take a list of weights and convert to a string of aa letters
'''
from Bio.Data.IUPACData import protein_weights
ret_string = ''
for weight in peptide:
for key in protein_weights.keys():
if weight == round(protein_weights[key] - 18): # -18 for weight of extra water molecule
ret_string += str(key)
break
return ret_string
def test_weights_to_letters():
print(type('WDG') , 'WDG', type(weights_to_letters([186,128,113])), weights_to_letters([186,115,57]))
assert weights_to_letters([186,128,113]) == 'WDG'这就是最后的结果:
<class 'str'> WDG <class 'str'> WDG
Traceback (most recent call last):
File "C:\Users\Jim\My Documents\GitHub\Stepic-Rosalind\BioAlgWeek2.py", line 238, in <module>
testcode()
File "C:\Users\Jim\My Documents\GitHub\Stepic-Rosalind\BioAlgWeek2.py", line 228, in testcode
test_weights_to_letters()
File "C:\Users\Jim\My Documents\GitHub\Stepic-Rosalind\BioAlgWeek2.py", line 209, in test_weights_to_letters
assert weights_to_letters([186,128,113]) == 'WDG'
AssertionError发布于 2014-10-30 16:43:50
您似乎在test_weights_to_letters()的第一行中有一个错误。您正在向weights_to_letters传递186,115,57,但您正在断言weights_to_letters(186,128,113)。
https://stackoverflow.com/questions/26658507
复制相似问题