我想为大约100个文件(subset_1到subset_100)运行此命令以进行主题分析并存储其各自的输出。我试图通过最初使用子进程来创建一个列表。建议我如何运行100个文件。
命令:
meme subset_*.fas -text -dna -mod anr -nmotifs 10 -w 8 -revcomp -maxsites 100 -bfile seqs.MEMEbkgr > subset_*.MEME
这是我正在尝试的python脚本:
import subprocess
m = ['meme', 'subset_%s.fas', '-text', '-dna', '-mod', 'anr', '-nmotifs',
'1', '-w', '8', '-revcomp' '-maxsites' '100' '-bfile' 'seqs.MEMEbkgr'
'>' 'subset_%s.MEME']
for i in range(2):
finder_out = open("subset_%s", "w")
finder_out.close()
subprocess.call('m')
答案 0 :(得分:2)
#as example to be short enough
command = "meme subset_{filenum}.fas > subset_{filenum}.MEME"
for i in range(100):
param={"filenum":i} #this is used to replace {filenum} with i in comnmand
#param is dict with string as key
command_t=command.format(**param)
print command_t
subprocess.call(command_t,shell=True)