os.subprocess モジュールを使用していくつかの外部コマンドを実行する Python スクリプトがあります。しかし、これらのステップの 1 つは非常に時間がかかるため、個別に実行したいと考えています。それらを起動し、それらが終了したことを確認してから、並列ではない次のコマンドを実行する必要があります。私のコードは次のようなものです:
nproc = 24
for i in xrange(nproc):
#Run program in parallel
#Combine files generated by the parallel step
for i in xrange(nproc):
handle = open('Niben_%s_structures' % (zfile_name), 'w')
for i in xrange(nproc):
for zline in open('Niben_%s_file%d_structures' % (zfile_name,i)):handle.write(zline)
handle.close()
#Run next step
cmd = 'bowtie-build -f Niben_%s_precursors.fa bowtie-index/Niben_%s_precursors' % (zfile_name,zfile_name)