我正在尝试自动从目录中的多个文件进行爆炸输出。这里的变量是硬编码的,但稍后将由用户定义。我的内文件将通过循环更改,但我在 python 内的文件上运行 NcbiblastpCommandline 时遇到问题。旨在使用多批较大的 fasta 文件的输入在本地运行blast,因此blast将按顺序运行每个批处理文件,输出到tsv中,我在tsv中解析数据并传递给clustalw本地对齐。
Input_file="minifasta.fasta"
data="uniprot_database"
E_Value_Thresh=1e-10
counter=1
Filename2= 'Batch'+str(counter)
from Bio.Blast.Applications import NcbiblastpCommandline
blast_output_file='blastout.tsv'
NcbiblastpCommandline.outfile=Filename2
from Bio.Blast.Applications import NcbiblastpCommandline
cline = NcbiblastpCommandline(query=Input_file, db=data,outfmt=6,
out=blast_output_file, evalue= E_Value_Thresh)
print(cline)
stdt, stdr= cline()
我不断收到错误消息“NcbiblastpCommandline”对象不可迭代。我被定向到 stdt、stdr 行,但没有 stdt、stdr 时会出现另一个错误,指出该命令无法识别,并且错误消息定向到 stdout_str、stderr_str。我找不到 Python 3 中 NcbiblastpCommandline 用法的最新示例来指导我。
我收到的完整错误是:
ApplicationError: Non-zero return code 127 from 'blastp -out blastout.tsv -outfmt 6 -query minifasta.fasta -db uniprot_database -evalue 1e-10', message '/bin/sh: blastp: command not found'.
File "/Users/me/anaconda3/lib/python3.6/site-packages/Bio/Application/__init__.py", line 523, in __call__
stdout_str, stderr_str)
最佳答案
首先运行 whichblastp
以查找 blastp
的完整路径,并将其作为参数提供给 NcbiblastpCommandline
。
from Bio.Blast.Applications import NcbiblastpCommandline
blastp_path = '/path/to/blastp'
cline = NcbiblastpCommandline(cmd=blastp_path, query=Input_file, db=data,outfmt=6,
out=blast_output_file, evalue= E_Value_Thresh)
如果您现在执行print(cline)
,它应该打印出将要运行的完整命令。通过复制/粘贴此输出并从命令行运行它来仔细检查这是否有效。
关于python - NCBIblastP 命令行错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50059372/