]> git.donarmstrong.com Git - biopieces.git/blobdiff - bp_bin/find_adaptor
removed debug message
[biopieces.git] / bp_bin / find_adaptor
index 5b2c96b76403428a3ae776d81cbbdda87587e046..2fd757aa09dfcf39e02be9037e5b9b1f372c6b6b 100755 (executable)
@@ -53,11 +53,11 @@ casts << {:long=>'deletions',   :short=>'d', :type=>'uint',   :mandatory=>false,
 options = Biopieces.options_parse(ARGV, casts)
 
 if options[:forward_rc]
-  options[:forward] = Seq.new("test", options[:forward_rc], 'dna').revcomp.seq
+  options[:forward] = Seq.new(seq: options[:forward_rc], type: :dna).reverse.complement.seq
 end
 
 if options[:reverse_rc]
-  options[:reverse] = Seq.new("test", options[:reverse_rc], 'dna').revcomp.seq
+  options[:reverse] = Seq.new(seq: options[:reverse_rc], type: :dna).reverse.complement.seq
 end
 
 raise ArgumentError, "no adaptor specified" unless options[:forward] or options[:reverse]
@@ -88,11 +88,11 @@ end
 
 Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
   input.each do |record|
-    if record[:SEQ] and record[:SEQ].length > 0
+    if record[:SEQ]
       entry = Seq.new_bp(record)
 
-      if options[:forward]
-        if m = entry.patmatch(options[:forward], 0, fmis, fins, fdel)
+      if options[:forward] and record[:SEQ].length >= options[:forward].length
+        if m = entry.patmatch(options[:forward], max_mismatches: fmis, max_insertions: fins, max_deletions: fdel)
           record[:ADAPTOR_POS_LEFT] = m.pos
           record[:ADAPTOR_LEN_LEFT] = m.length
           record[:ADAPTOR_PAT_LEFT] = m.match
@@ -106,9 +106,8 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
             fdel = percent2real(len, options[:deletions])
 
             pat = pat[1 ... pat.length]
-$stderr.puts pat
-$stderr.puts entry.seq[0 ... len]
-            if m = entry.patmatch(pat, [0, len], fmis, fins, fdel)
+
+            if m = entry.patmatch(pat, start: 0, stop: len, max_mismatches: fmis, max_insertions: fins, max_deletions: fdel)
               record[:ADAPTOR_POS_LEFT] = m.pos
               record[:ADAPTOR_LEN_LEFT] = m.length
               record[:ADAPTOR_PAT_LEFT] = m.match
@@ -121,8 +120,8 @@ $stderr.puts entry.seq[0 ... len]
         end
       end
 
-      if options[:reverse]
-        if m = entry.patmatch(options[:reverse], 0, rmis, rins, rdel)
+      if options[:reverse] and record[:SEQ].length >= options[:reverse].length
+        if m = entry.patmatch(options[:reverse], max_mismatches: rmis, max_insertions: rins, max_deletions: rdel)
           record[:ADAPTOR_POS_RIGHT] = m.pos
           record[:ADAPTOR_LEN_RIGHT] = m.length
           record[:ADAPTOR_PAT_RIGHT] = m.match
@@ -137,7 +136,7 @@ $stderr.puts entry.seq[0 ... len]
 
             pat = pat[0 ... pat.length - 1]
 
-            if m = entry.patmatch(pat, entry.length - len, rmis, rins, rdel)
+            if m = entry.patmatch(pat, start: entry.length - len, max_mismatches: rmis, max_insertions: rins, max_deletions: rdel)
               record[:ADAPTOR_POS_RIGHT] = m.pos
               record[:ADAPTOR_LEN_RIGHT] = m.length
               record[:ADAPTOR_PAT_RIGHT] = m.match