]> git.donarmstrong.com Git - biopieces.git/blobdiff - bp_bin/remove_primers
fixed encoding bug in read_454
[biopieces.git] / bp_bin / remove_primers
index 720d943ee6db515b49980342afb96a8717a0fa22..88c1a81c3351df23fca647bec6d131d5b64e9dd9 100755 (executable)
@@ -32,6 +32,9 @@
 require 'pp'
 require 'maasha/biopieces'
 require 'maasha/seq'
+require 'maasha/seq/backtrack'
+
+include BackTrack
 
 casts = []
 casts << {:long=>'forward',    :short=>'f', :type=>'string', :mandatory=>true,  :default=>nil, :allowed=>nil, :disallowed=>nil}
@@ -44,12 +47,15 @@ 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)
 
-      seq.patscan(options[:forward].to_s, 0, options[:mismatches], options[:insertions], options[:deletions]) do |match|
+      seq.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
@@ -59,7 +65,10 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
         break
       end
 
-      seq.patscan(options[:reverse].to_s, 0, options[:mismatches], options[:insertions], options[:deletions]) do |match|
+      seq.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