2013-12-16 19 views
1

我想運行此命令大約100個文件(subset_1到subset_100)進行motif分析並存儲其各自的輸出。我試圖通過創建一個列表來初步使用子進程。建議我如何運行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

你想要的所有100個文件追加到subset_.MEME文件? – Back2Basics

+0

沒有。我需要在一個單獨的文件中的每個子集 – user2985098

+0

這是我正在嘗試的一個python腳本。導入子過程 m = ['meme','subset_%s.fas','-text','-dna','-mod','anr','-nmotifs','1','-w' (2): finder_out = open(),'8' (「subset_%s」,「w」) finder_out.close() subprocess.call('m') – user2985098

回答

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) 
相關問題