我无法通过Python调用名为sixpack的EMBOSS程序(通过命令行运行)。
我通过Windows 7,Python版本3.23,Biopython版本1.59,EMBOSS版本6.4.0.4运行Python。 Sixpack用于翻译所有六个阅读框中的DNA序列,并创建两个文件作为输出;标识ORF的序列文件和含有蛋白质序列的文件。
我可以从命令行成功调用三个必需参数:(-sequence [input file]
,-outseq [output sequence file]
,-outfile [protein sequence file]
)。我一直在使用子进程模块代替os.system,因为我已经读过它更强大和多功能。
以下是我的python代码,它运行时没有错误,但不会生成所需的输出文件。
from Bio import SeqIO
import re
import os
import subprocess
infile = input('Full path to EXISTING .fasta file would you like to open: ')
outdir = input('NEW Directory to write outfiles to: ')
os.mkdir(outdir)
for record in SeqIO.parse(infile, "fasta"):
print("Translating (6-Frame): " + record.id)
ident=re.sub("\|", "-", record.id)
print (infile)
print ("Old record ID: " + record.id)
print ("New record ID: " + ident)
subprocess.call (['C:\memboss\sixpack.exe', '-sequence ' + infile, '-outseq ' + outdir + ident + '.sixpack', '-outfile ' + outdir + ident + '.format'])
print ("Translation of: " + infile + "\nWritten to: " + outdir + ident)
答案 0 :(得分:2)
找到答案..我使用错误的语法来调用子进程。这是正确的语法:
subprocess.call (['C:\memboss\sixpack.exe', '-sequence', infile, '-outseq', outdir + ident + '.sixpack', '-outfile', outdir + ident + '.format'])