module Bio::Sequence::SequenceMasker
Bio::Sequence::SequenceMasker is a mix-in module to provide helpful methods for masking a sequence.
It is only expected to be included in Bio::Sequence. In the future, methods in this module might be moved to Bio::Sequence or other module and this module might be removed. Please do not depend on this module.
Public Instance Methods
Masks the sequence with each value in the enum. The enum<em> should be an array or enumerator. A block must be given. When the block returns true, the sequence is masked with <em>mask_char.
Arguments:
-
(required) enum : Enumerator
-
(required) mask_char : (String) character used for masking
- Returns
-
Bio::Sequence object
# File lib/bio/sequence/sequence_masker.rb, line 42 def mask_with_enumerator(enum, mask_char) offset = 0 unit = mask_char.length - 1 s = self.seq.class.new(self.seq) j = 0 enum.each_with_index do |item, index| if yield item then j = index + offset if j < s.length then s[j, 1] = mask_char offset += unit end end end newseq = self.dup newseq.seq = s newseq end
Masks high error-probability sequence regions. For each sequence position, if the error probability is larger than the threshold, the sequence in the position is replaced with mask_char.
Arguments:
-
(required) threshold : (Numeric) threshold
-
(required) mask_char : (String) character used for masking
- Returns
-
Bio::Sequence object
# File lib/bio/sequence/sequence_masker.rb, line 89 def mask_with_error_probability(threshold, mask_char) values = self.error_probabilities || [] mask_with_enumerator(values, mask_char) do |item| item > threshold end end
Masks low quality sequence regions. For each sequence position, if the quality score is smaller than the threshold, the sequence in the position is replaced with mask_char.
Note: This method does not care quality_score_type.
Arguments:
-
(required) threshold : (Numeric) threshold
-
(required) mask_char : (String) character used for masking
- Returns
-
Bio::Sequence object
# File lib/bio/sequence/sequence_masker.rb, line 72 def mask_with_quality_score(threshold, mask_char) scores = self.quality_scores || [] mask_with_enumerator(scores, mask_char) do |item| item < threshold end end