我试图用DNA序列做一些基本的python,但现在我遇到了一个小问题。
这是我的初始代码:
def positie(enzyme):
pos = sequentie.find(enzyme.lower())
print (pos)
def searchopdracht(enzyme):
if enzyme.lower() in sequentie:
print(enzyme, " does cut, at location:")
positie(enzyme)
print(" ")
else:
print(enzyme, "does not cut")
print(" ")
for enzyme in [DdeI, BspMII, EcoRI, HindIII, TaqI]:
searchopdracht(enzyme)
其中输出以下内容:
CTGAG does cut, at location: 1022
TCCGGA does not cut
GAATTC does cut, at location: 1449
AAGCTT does cut, at location: 77
TCGA does cut, at location: 171
一切都很好并且有效,但是我想要显示酶的名称而不是序列,例如,不是" CTGAG确实切割,位置:1022"但是" DdeI确实在地点:1022"
这是我尝试的(但没有提供任何输出),但随意提出其他建议:
def positie( enzyme ):
pos = sequentie.find(enzyme.lower())
print (pos)
def searchopdracht(enzyme, enzyme_name):
if enzyme.lower() in sequentie:
print(enzyme_name," does cut, at location:")
positie(enzyme)
print(" ")
else:
print(enzyme_name, "does not cut")
print(" ")
list1 = [DdeI, BspMII, EcoRI, HindIII, TaqI]
list2 = ["DdeI", "BspMII", "EcoRI", "HindIII", "TaqI"]
for (enzyme, enzyme_name) in (list1, list2):
searchopdracht(enzyme)
答案 0 :(得分:0)
您需要将enzyme_name
作为参数传递给searchopdracht()
,并使用zip
创建输入的元组对:
for enzyme, enzyme_name in zip(list1, list2):
searchopdracht(enzyme, enzyme_name) # added argument