我正在尝试创建一个简单的脚本来一个接一个地运行不同的任务,但我不知道如何通过python脚本运行该程序!我知道这应该很简单!但是我到处都找不到它。我的例子是:
samtools merge filename.bam file1.sorted.bam file2.sorted.bam file3.sorted.bam file4.sorted.bam
samtools index filename.bam
samtools idxstats filename.bam > filename.txt
samtools pileup -vcf path/filename.fa filename_sorted.bam我希望python运行第一个命令,并在它完成后转到下一个命令!重要的是要等到它完成!
发布于 2011-08-17 23:51:50
from subprocess import call # call runs an external program and waits for it to quit
for command in ("samtools merge filename.bam file1.sorted.bam file2.sorted.bam file3.sorted.bam file4.sorted.bam",
"samtools index filename.bam",
"samtools idxstats filename.bam > filename.txt",
"samtools pileup -vcf path/filename.fa filename_sorted.bam"):
# shell=True is so you can handle redirects like in the 3rd command
call(command, shell=True) 发布于 2011-08-17 23:51:16
使用subprocess module。在页面的底部有很多例子。
https://stackoverflow.com/questions/7095734
复制相似问题