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 42 def mask_with_enumerator(enum, mask_char) 43 offset = 0 44 unit = mask_char.length - 1 45 s = self.seq.class.new(self.seq) 46 j = 0 47 enum.each_with_index do |item, index| 48 if yield item then 49 j = index + offset 50 if j < s.length then 51 s[j, 1] = mask_char 52 offset += unit 53 end 54 end 55 end 56 newseq = self.dup 57 newseq.seq = s 58 newseq 59 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 89 def mask_with_error_probability(threshold, mask_char) 90 values = self.error_probabilities || [] 91 mask_with_enumerator(values, mask_char) do |item| 92 item > threshold 93 end 94 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 72 def mask_with_quality_score(threshold, mask_char) 73 scores = self.quality_scores || [] 74 mask_with_enumerator(scores, mask_char) do |item| 75 item < threshold 76 end 77 end