+# Copyright (C) 2007-2013 Martin A. Hansen.
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
require 'inline'
+# Error class for all exceptions to do with Trim.
class TrimError < StandardError; end
# Module containing methods for end trimming sequences with suboptimal quality
def quality_trim_right(min_qual, min_len = 1)
check_trim_args(min_qual)
- pos = trim_right_pos_c(self.qual, self.length, min_qual, min_len, SCORE_BASE)
+ pos = trim_right_pos_c(self.qual, self.length, min_qual, min_len, Seq::SCORE_BASE)
self.subseq(0, pos)
end
def quality_trim_right!(min_qual, min_len = 1)
check_trim_args(min_qual)
- pos = trim_right_pos_c(self.qual, self.length, min_qual, min_len, SCORE_BASE)
+ pos = trim_right_pos_c(self.qual, self.length, min_qual, min_len, Seq::SCORE_BASE)
self.subseq!(0, pos)
end
def quality_trim_left(min_qual, min_len = 1)
check_trim_args(min_qual)
- pos = trim_left_pos_c(self.qual, self.length, min_qual, min_len, SCORE_BASE)
+ pos = trim_left_pos_c(self.qual, self.length, min_qual, min_len, Seq::SCORE_BASE)
self.subseq(pos)
end
def quality_trim_left!(min_qual, min_len = 1)
check_trim_args(min_qual)
- pos = trim_left_pos_c(self.qual, self.length, min_qual, min_len, SCORE_BASE)
+ pos = trim_left_pos_c(self.qual, self.length, min_qual, min_len, Seq::SCORE_BASE)
self.subseq!(pos)
end
def quality_trim(min_qual, min_len = 1)
check_trim_args(min_qual)
- pos_right = trim_right_pos_c(self.qual, self.length, min_qual, min_len, SCORE_BASE)
- pos_left = trim_left_pos_c(self.qual, self.length, min_qual, min_len, SCORE_BASE)
+ pos_right = trim_right_pos_c(self.qual, self.length, min_qual, min_len, Seq::SCORE_BASE)
+ pos_left = trim_left_pos_c(self.qual, self.length, min_qual, min_len, Seq::SCORE_BASE)
pos_left = pos_right if pos_left > pos_right
def quality_trim!(min_qual, min_len = 1)
check_trim_args(min_qual)
- pos_right = trim_right_pos_c(self.qual, self.length, min_qual, min_len, SCORE_BASE)
- pos_left = trim_left_pos_c(self.qual, self.length, min_qual, min_len, SCORE_BASE)
+ pos_right = trim_right_pos_c(self.qual, self.length, min_qual, min_len, Seq::SCORE_BASE)
+ pos_left = trim_left_pos_c(self.qual, self.length, min_qual, min_len, Seq::SCORE_BASE)
pos_left = pos_right if pos_left > pos_right
def check_trim_args(min_qual)
raise TrimError, "no sequence" if self.seq.nil?
raise TrimError, "no quality score" if self.qual.nil?
- unless (SCORE_MIN .. SCORE_MAX).include? min_qual
- raise TrimError, "minimum quality value: #{min_qual} out of range #{SCORE_MIN} .. #{SCORE_MAX}"
+ unless (Seq::SCORE_MIN .. Seq::SCORE_MAX).include? min_qual
+ raise TrimError, "minimum quality value: #{min_qual} out of range #{Seq::SCORE_MIN} .. #{Seq::SCORE_MAX}"
end
end
{
c = 0;
- while ((c < min_len) && ((c + i) < len) && (qual[len - (c + i) - 1] - score_base > min_qual))
+ while ((c < min_len) && ((c + i) < len) && (qual[len - (c + i) - 1] - score_base >= min_qual))
c++;
if (c == min_len)
{
c = 0;
- while ((c < min_len) && ((c + i) < len) && (qual[c + i] - score_base > min_qual))
+ while ((c < min_len) && ((c + i) < len) && (qual[c + i] - score_base >= min_qual))
c++;
if (c == min_len)