Python 3.x 如何使用Python3中的biopython文库从TB测序fasta文件中找到反向导向基因(如pncA)的突变?
为了找到类似S104R的突变(吡喃甲酰胺从2288681到2289241),我们必须首先删除“-”(如果fasta文件中存在任何插入/删除片段),然后对其进行反向补码,然后查找指定有密码子编号的特定突变(这里是104)。我用基本的字符串函数找到了答案,但如果可能的话,我希望biopython库更简洁明了。所以下面的代码对我来说很好:Python 3.x 如何使用Python3中的biopython文库从TB测序fasta文件中找到反向导向基因(如pncA)的突变?,python-3.x,bioinformatics,biopython,dna-sequence,sequencing,Python 3.x,Bioinformatics,Biopython,Dna Sequence,Sequencing,为了找到类似S104R的突变(吡喃甲酰胺从2288681到2289241),我们必须首先删除“-”(如果fasta文件中存在任何插入/删除片段),然后对其进行反向补码,然后查找指定有密码子编号的特定突变(这里是104)。我用基本的字符串函数找到了答案,但如果可能的话,我希望biopython库更简洁明了。所以下面的代码对我来说很好: from Bio import SeqIO sample_file=SeqIO.parse('fasta_file_location', 'fasta') // t
from Bio import SeqIO
sample_file=SeqIO.parse('fasta_file_location', 'fasta') // there are two items in sample_file(reference and patient sequence)
ref=str(sample_file[0].seq).replace('-','')[2288681:2289241].replace('A', 't').replace('T', 'a').replace('C', 'g').replace('G', 'c')[::-1].upper()[(104-1)*3:(104-1)*3+3]
pat=str(sample_file[1].seq).replace('-','')[2288681:2289241].replace('A', 't').replace('T', 'a').replace('C', 'g').replace('G', 'c')[::-1].upper()[(104-1)*3:(104-1)*3+3]
print("ref: ",ref, "pat: ", pat) // output-> ref: AGC, pat: CGG
但以下代码不适用于我:
ref=sample_file[0].seq.strip("-")[2288681:2289241].reverse_complement()[(104-1)*3:(104-1)*3+3]
pat=sample_file[1].seq.strip("-")[2288681:2289241].reverse_complement()[(104-1)*3:(104-1)*3+3]
有更方便的方法很好,因为后者使用biopython函数,所以如果您知道如何使其更好,请提供帮助。不与我们共享输入fasta fil有什么意义,这样我们就可以使用它了(很抱歉,rant)sample_文件是一个迭代器,不确定您是否可以使用sample_文件[0]先把它放到一个列表里。sample_file_list=[]for i in SeqIO.parse('fasta_file_location','fasta'):sample_file_list.append(i)您可以使用ref=sample_file_list[0]或[1],尝试并告诉我们,没有您的输入,我无法尝试