我试图从Python脚本运行一个外部程序。在
在搜索和阅读了这里的多个帖子后,我找到了似乎是解决办法。在
首先,我使用subprocess.call功能。在
如果我这样构建命令:
hmmer1=subprocess.call("D:\Python_Scripts\HMMer3\hmmsearch.exe --tblout hmmTestTab.out SDHA.hmm Test.fasta")
外部程序D:\Python_Scripts\HMMer3\hmmsearch.exe正在跑步hmmTestTab.out文件名SDHA。嗯和测试.fasta作为输入文件。在
不过,如果我试图用变量outfile、hmmprofile和fastafile(我打算接收这些变量作为Python脚本的参数,并使用它们来构建外部程序调用)
^{pr2}$Python打印一个关于无法打开输入文件的错误。在
我还使用了“Popen”函数,得到了类似的结果:
这个电话有效
hmmer3=Popen(['D:\Python_Scripts\HMMer3\hmmsearch.exe', '--tblout','hmmTestTab.out', 'SDHA.hmm','Test.fasta'])
但这个没有
hmmer4=Popen(['D:\Python_Scripts\HMMer3\hmmsearch.exe', '--tblout','outfile', 'hmmprofile','fastafile'])
因此,我想我需要了解将变量插值到调用中要遵循的过程,因为问题似乎就在那里。在
你们谁能帮我解决这个问题吗?在
提前谢谢
尝试改变这一点:
到
^{pr2}$编辑
你有:
但这不是传递变量
outfile
。它传递一个字符串,'outfile'
。在你想要:
^{pr2}$另一个答案是正确的,尽管它解决了一个不同的问题;您应该将反斜杠加倍,或者使用
r''
原始字符串。在相关问题 更多 >
编程相关推荐