From: martinahansen Date: Sun, 29 May 2011 08:17:01 +0000 (+0000) Subject: squashing bugs in find_adaptor X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=865d594187da7c11491a58c3a27f1828e54f474b;p=biopieces.git squashing bugs in find_adaptor git-svn-id: http://biopieces.googlecode.com/svn/trunk@1440 74ccb610-7750-0410-82ae-013aeee3265d --- diff --git a/bp_bin/find_adaptor b/bp_bin/find_adaptor index cd103f4..be8a0c2 100755 --- a/bp_bin/find_adaptor +++ b/bp_bin/find_adaptor @@ -63,42 +63,42 @@ class PatScan # end # end - def run - child_count = 0 - - @files_fasta.each do |file| - Thread.pass while child_count >= @cpus - child_count += 1 - - Thread.new do - command = command_compile(file) - system(command) - raise PatScanError, "Command failed: #{command}" unless $?.success? - child_count -= 1 - end - end - end - # def run # child_count = 0 -# ch_mutex = Mutex.new -# threads = [] # # @files_fasta.each do |file| # Thread.pass while child_count >= @cpus -# ch_mutex.synchronize { child_count += 1 } +# child_count += 1 # -# threads << Thread.new do +# Thread.new do # command = command_compile(file) # system(command) # raise PatScanError, "Command failed: #{command}" unless $?.success? -# ch_mutex.synchronize { child_count -= 1 } +# child_count -= 1 # end # end -# -# threads.each { |t| t.join } # end + def run + child_count = 0 + ch_mutex = Mutex.new + threads = [] + + @files_fasta.each do |file| + Thread.pass while child_count >= @cpus + ch_mutex.synchronize { child_count += 1 } + + threads << Thread.new do + command = command_compile(file) + system(command) + raise PatScanError, "Command failed: #{command}" unless $?.success? + ch_mutex.synchronize { child_count -= 1 } + end + end + + threads.each { |t| t.join } + end + def command_compile(file) commands = [] commands << "nice -n 19" @@ -217,8 +217,7 @@ BASE_PER_FILE = 10_000_000 options = Biopieces.options_parse(ARGV, casts) -#tmpdir = Biopieces.mktmpdir -tmpdir = "/home/maasha/Tyt" +tmpdir = Biopieces.mktmpdir file_records = File.join(tmpdir, "data.stream") file_pattern = File.join(tmpdir, "pattern.txt")