From: martinahansen Date: Tue, 8 Mar 2011 11:21:41 +0000 (+0000) Subject: updated remove_illumina_adaptor X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=6f35a1f2f4f8973565e93e348e72d567ca2e6835;p=biopieces.git updated remove_illumina_adaptor git-svn-id: http://biopieces.googlecode.com/svn/trunk@1286 74ccb610-7750-0410-82ae-013aeee3265d --- diff --git a/bp_bin/remove_illumina_adaptor b/bp_bin/remove_illumina_adaptor index cb81799..7f74c8a 100755 --- a/bp_bin/remove_illumina_adaptor +++ b/bp_bin/remove_illumina_adaptor @@ -33,6 +33,7 @@ require 'biopieces' require 'seq' casts = [] +casts << {:long=>'min', :short=>'m', :type=>'uint', :mandatory=>false, :default=>0, :allowed=>nil, :disallowed=>nil} casts << {:long=>'right_adaptor', :short=>'r', :type=>'string', :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil} casts << {:long=>'left_adaptor', :short=>'l', :type=>'string', :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil} casts << {:long=>'right_hamming_dist', :short=>'R', :type=>'uint', :mandatory=>false, :default=>25, :allowed=>nil, :disallowed=>nil} @@ -48,7 +49,7 @@ bp.each_record do |record| if options[:right_adaptor] pos_right = entry.adaptor_locate_right(options[:right_adaptor], options[:right_hamming_dist]) - entry.subseq!(0, pos_right) if pos_right >= 0 + entry.subseq!(0, pos_right) if pos_right >= 0 and entry.length - pos_right >= options[:min] record[:CLIP_ADAPTOR_RIGHT] = pos_right else record[:CLIP_ADAPTOR_RIGHT] = -1 @@ -56,7 +57,7 @@ bp.each_record do |record| if options[:left_adaptor] pos_left = entry.adaptor_locate_left(options[:left_adaptor], options[:left_hamming_dist]) - entry.subseq!(pos_left + 1) if pos_left >= 0 + entry.subseq!(pos_left + 1) if pos_left >= options[:min] record[:CLIP_ADAPTOR_LEFT] = pos_left else record[:CLIP_ADAPTOR_LEFT] = -1 diff --git a/code_ruby/Maasha/lib/seq.rb b/code_ruby/Maasha/lib/seq.rb index 1a7d698..6d739b9 100644 --- a/code_ruby/Maasha/lib/seq.rb +++ b/code_ruby/Maasha/lib/seq.rb @@ -22,7 +22,7 @@ # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -require 'bits' +require 'amatch' # Residue alphabets DNA = %w[a t c g] @@ -38,6 +38,8 @@ SCORE_ILLUMINA = 64 class SeqError < StandardError; end class Seq + include Amatch + attr_accessor :seq_name, :seq, :type, :qual # Method that generates all possible oligos of a specifed length and type. @@ -318,8 +320,9 @@ class Seq len = self.length - pos subseq = self.seq[pos ... pos + len].upcase subadaptor = adaptor[0 ... len].upcase + m = Hamming.new(subseq) + hamming_dist = m.match(subadaptor) hamming_max = (len * hd_percent * 0.01).round - hamming_dist = String.hamming_dist(subseq, subadaptor) return pos if hamming_dist <= hamming_max pos += 1 @@ -341,8 +344,9 @@ class Seq len = pos subseq = self.seq[0 ... len].upcase subadaptor = adaptor[adaptor.length - len ... adaptor.length].upcase + m = Hamming.new(subseq) + hamming_dist = m.match(subadaptor) hamming_max = (len * hd_percent * 0.01).round - hamming_dist = String.hamming_dist(subseq, subadaptor) pos -= 1