用肌肉打电话或在管道中呼叫mafft时,子进程popen功能会锁定
我正在尝试使用肌肉或MAFFT进行序列对齐,具体取决于用户在管道中。 为此,我正在使用subprocess
软件包,但是有时,子过程永远不会终止,我的脚本不会继续。这是我调用子过程的方式:
child = subprocess.Popen(str(muscle_cline), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
child.wait()
命令muscle_cline
看起来像这样:
./tools/muscle/muscle5.1.win64.exe -align C:\Users\alexis\Desktop\git-repo\MitoSplitter\results\genes-fasta\12S_tmp.fasta -output C:\Users\alexis\Desktop\git-repo\MitoSplitter\results\alignement\12S_tmp_muscle_align.fasta
我在一个函数中调用此行,该函数仅创建命令行并调用子过程,并转换输出。
然后,我在循环的中调用此功能。
for file in getFastaFile(my_dir):
alignSequenceWithMuscle(file)
问题是,出于未知原因,子过程永远不会完成并锁定...
我试图检查孩子的返回代码,或打印东西以查看它被锁定的位置,当我调用子过程时,它被锁定了。
有什么想法吗?
I'm trying to include sequence alignment using muscle or mafft, depending of the user in a pipeline.
To do so, i'm using the subprocess
package, but sometimes, the subprocess never terminates and my script doesn't continue. Here is how I call the subprocess:
child = subprocess.Popen(str(muscle_cline), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
child.wait()
The command muscle_cline
looks like this:
./tools/muscle/muscle5.1.win64.exe -align C:\Users\alexis\Desktop\git-repo\MitoSplitter\results\genes-fasta\12S_tmp.fasta -output C:\Users\alexis\Desktop\git-repo\MitoSplitter\results\alignement\12S_tmp_muscle_align.fasta
I'm calling this line in a function that just creates the command line and calls the subprocess, and converts the output.
I'm then calling this function in a for
loop
for file in getFastaFile(my_dir):
alignSequenceWithMuscle(file)
The issue is that sometimes, for unknown reasons, the subprocess never finishes and get locked...
I tried to check the returncode of the child, or print stuff to see where it gets locked, and it's getting locked when I'm calling the subprocess.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您通常希望避免
popen
,尤其是如果您对其要求没有很好的了解。这就是为什么Python为您提供subprocess.check_output
和其他高级功能的原因,这些功能负责管理管理子过程的挑剔。还要注意RAW字符串
r“ ...”
避免必须加倍反弹,而text = true
关键字参数指示python隐式解释字节
您从子过程中收到。You generally want to avoid bare
Popen
, especially if you don't have a good understanding of its requirements. This is precisely why Python offers yousubprocess.check_output
and other higher-level functions which take care of the nitty-gritty of managing a subprocess.Notice also the raw strings
r"..."
to avoid having to double the backslashes, and thetext=True
keyword argument to instruct Python to implicitly decode thebytes
you receive from the subprocess.