]> git.donarmstrong.com Git - biopieces.git/commitdiff
added multithreading to find_adaptor
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Sat, 28 May 2011 21:24:18 +0000 (21:24 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Sat, 28 May 2011 21:24:18 +0000 (21:24 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@1438 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/find_adaptor

index 78e633a34ca0365694022bdf310ed1ef354871f3..85377e4f86e93b150a699f809c117c8e744ed242 100755 (executable)
@@ -37,10 +37,9 @@ require 'maasha/fasta'
 class PatScanError < StandardError; end;
 
 class PatScan
-  def initialize(options, tmpdir, file_pattern, file_patscan, cpus)
+  def initialize(options, tmpdir, file_pattern, cpus)
     @options      = options
     @file_pattern = file_pattern
-    @file_patscan = file_patscan
     @cpus         = cpus
     @files_fasta  = Dir.glob(File.join(tmpdir, "*.fna"))
 
@@ -110,17 +109,21 @@ class PatScan
   end
 
   def parse_results
+    files_result = Dir.glob(File.join(tmpdir, "*.out"))
+
     matches = {}
 
-    Fasta.open(@file_patscan, mode='r') do |ios|
-      ios.each do |entry|
-        if entry.seq_name =~ /^(\d+):\[(\d+),(\d+)\]$/
-          name  = $1.to_i
-          start = $2.to_i - 1
-          stop  = $3.to_i - 1
-          matches[name] = [start, stop - start + 1] unless matches.has_key? name
-        else
-          raise "Failed to parse sequence name: #{entry.seq_name}"
+    files_result.each do |file|
+      Fasta.open(file, mode='r') do |ios|
+        ios.each do |entry|
+          if entry.seq_name =~ /^(\d+):\[(\d+),(\d+)\]$/
+            name  = $1.to_i
+            start = $2.to_i - 1
+            stop  = $3.to_i - 1
+            matches[name] = [start, stop - start + 1] unless matches.has_key? name
+          else
+            raise "Failed to parse sequence name: #{entry.seq_name}"
+          end
         end
       end
     end
@@ -217,7 +220,6 @@ options = Biopieces.options_parse(ARGV, casts)
 tmpdir       = "Tyt" # DEBUG TODO
 file_records = File.join(tmpdir, "data.stream")
 file_pattern = File.join(tmpdir, "pattern.txt")
-file_patscan = File.join(tmpdir, "patscan.out")
 
 number_file = 0
 number_seq  = 0
@@ -250,9 +252,8 @@ Biopieces.open(options[:stream_in], file_records) do |input, output|
   out_fa.close if out_fa.respond_to? :close
 end
 
-patscan = PatScan.new(options, tmpdir, file_pattern, file_patscan, options[:cpus])
+patscan = PatScan.new(options, tmpdir, file_pattern, options[:cpus])
 patscan.run
-exit
 matches = patscan.parse_results
 
 number_seq = 0