]> git.donarmstrong.com Git - biopieces.git/blobdiff - bp_bin/remove_primers
removed debug message
[biopieces.git] / bp_bin / remove_primers
index 5f26eb6051a3bc2092c5c6a1dc882be7dd2f1efc..6544afce3087b02dd53f83f8202e7f7c647c4aa5 100755 (executable)
@@ -32,6 +32,7 @@
 require 'pp'
 require 'maasha/biopieces'
 require 'maasha/seq'
+require 'maasha/seq/backtrack'
 
 include BackTrack
 
@@ -46,32 +47,38 @@ options = Biopieces.options_parse(ARGV, casts)
 
 Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
   input.each do |record|
-    if record.has_key? :SEQ
+    if record[:SEQ]
       forward = false
       reverse = false
-      seq = Seq.new_bp(record)
+      entry = Seq.new_bp(record)
 
-      seq.patscan(options[:forward].to_s, 0, options[:mismatches], options[:insertions], options[:deletions]) do |match|
+      entry.patscan(options[:forward].to_s,
+                  max_mismatches: options[:mismatches],
+                  max_insertions: options[:insertions],
+                  max_deletions:  options[:deletions]) do |match|
         record[:FORWARD_POS] = match.pos
         record[:FORWARD_LEN] = match.length
         pos = match.pos + match.length
-        len = seq.length - pos
-        seq.subseq!(pos, len) if len > 0
+        len = entry.length - pos
+        entry = entry[pos ... pos + len] if len > 0
         forward = true
         break
       end
 
-      seq.patscan(options[:reverse].to_s, 0, options[:mismatches], options[:insertions], options[:deletions]) do |match|
+      entry.patscan(options[:reverse].to_s,
+                  max_mismatches: options[:mismatches],
+                  max_insertions: options[:insertions],
+                  max_deletions:  options[:deletions]) do |match|
         record[:REVERSE_POS] = match.pos
         record[:REVERSE_LEN] = match.length
         pos = 0
         len = match.pos
 
         if len == 0
-          seq.seq  = ""
-          seq.qual = "" if seq.qual
+          entry.seq  = ""
+          entry.qual = "" if entry.qual
         else
-          seq.subseq!(pos, len)
+          entry = entry[pos ... pos + len]
         end 
 
         reverse = true
@@ -79,7 +86,7 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
       end
 
       if forward or reverse
-        record.merge!(seq.to_bp)
+        record.merge!(entry.to_bp)
       end
 
       output.puts record