基于字符串输入Python的变量替换矩阵导入

2024-05-29 10:53:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试导入一个替换矩阵,以基于给定的输入在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'

我要怎么做才能让它工作?你知道吗

提前谢谢!你知道吗


Tags: namefromimport算法index矩阵bioscoring

热门问题