我尝试导入一个替换矩阵,以基于给定的输入在Python中实现Needleman-Wunsch算法。 如果我想选择一个矩阵,我可以这样做:
from Bio.SubsMat import MatrixInfo as matlist
scoring_mat = matlist.blosum62
如果我想导入任何基于输入的矩阵,我该怎么办?我现在有这个:
def blosum(name):
index = str(name)
x= "blosum"+index
return x
a= blosum(62)
scoring_mat = matlist.a
不幸的是,它给了我以下错误:
AttributeError: module 'Bio.SubsMat.MatrixInfo' has no attribute 'a'
我要怎么做才能让它工作?你知道吗
提前谢谢!你知道吗
试试
scoring_mat = getattr(matlist,a)
。它对我有用。你知道吗相关问题 更多 >
编程相关推荐