【问题标题】:Running BLAST in Python with Biopython for SARS Virus. My output is simply not showing up! Someone check my code?使用 Biopython 为 SARS 病毒在 Python 中运行 BLAST。我的输出根本没有出现!有人检查我的代码吗?
【发布时间】:2020-05-01 20:02:35
【问题描述】:

这是我的代码:

from Bio.Blast import NCBIWWW          
result = NCBIWWW.qblast("blastn","nt",r"C:\Users\video\Documents\sars.fasta")  
save_file = open("blast4.xml", "w")
save_file.write(result.read())
save_file.close()
result.close()
result = open("blast4.xml")
from Bio.Blast import NCBIXML
records = NCBIXML.parse(result)
blast_record = records.__next__()
# Up till here there are no problems 

for alignment in blast_record.alignments:
    for hsp in alignment.hsps:
        if hsp.expect <0.01:
            print('****Alignment****') 
            print('sequence:', alignment.title) 
            print('length:', alignment.length) 
            print('score:', hsp.score) 
            print('gaps:', hsp.gaps) 
            print('e value:', hsp.expect) 
            print(hsp.query[0.90] + '...') 
            print(hsp.match[0.90] + '...') 
            print(hsp.sbjct[0.90] + '...')

代码似乎可以运行,但没有输出!没有桌子或任何东西。代码只是运行,什么也没有。有什么问题?

【问题讨论】:

    标签: xml bioinformatics biopython blast sparse-file


    【解决方案1】:

    len(blast_record.alignments) 的值是多少?我不知道您使用的是哪个 sars.fasta 文件,但如果我使用 this sars fasta file 尝试您的代码,则 len(blast_record.alignments) 的值是 0

    所以我假设您的爆炸结果不包含任何对齐,因此不会打印对齐信息。

    【讨论】:

      猜你喜欢
      • 2023-04-10
      • 1970-01-01
      • 2021-02-16
      • 1970-01-01
      • 2023-01-17
      • 1970-01-01
      • 2021-12-08
      • 2014-09-11
      • 2018-06-15
      相关资源
      最近更新 更多