]> git.donarmstrong.com Git - biopieces.git/commitdiff
squashing bugs in find_adaptor
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Sun, 29 May 2011 08:17:01 +0000 (08:17 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Sun, 29 May 2011 08:17:01 +0000 (08:17 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@1440 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/find_adaptor

index cd103f446f0780499fe0e310cd38ea43905c7f0d..be8a0c297bac85384fd7f60a9581d661404e6d77 100755 (executable)
@@ -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")