Module | Bio::Sequence::SequenceMasker |
In: |
lib/bio/sequence/sequence_masker.rb
|
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.
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:
Returns: | Bio::Sequence object |
# File lib/bio/sequence/sequence_masker.rb, line 39 39: def mask_with_enumerator(enum, mask_char) 40: offset = 0 41: unit = mask_char.length - 1 42: s = self.seq.class.new(self.seq) 43: j = 0 44: enum.each_with_index do |item, index| 45: if yield item then 46: j = index + offset 47: if j < s.length then 48: s[j, 1] = mask_char 49: offset += unit 50: end 51: end 52: end 53: newseq = self.dup 54: newseq.seq = s 55: newseq 56: 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:
Returns: | Bio::Sequence object |
# File lib/bio/sequence/sequence_masker.rb, line 86 86: def mask_with_error_probability(threshold, mask_char) 87: values = self.error_probabilities || [] 88: mask_with_enumerator(values, mask_char) do |item| 89: item > threshold 90: end 91: 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:
Returns: | Bio::Sequence object |
# File lib/bio/sequence/sequence_masker.rb, line 69 69: def mask_with_quality_score(threshold, mask_char) 70: scores = self.quality_scores || [] 71: mask_with_enumerator(scores, mask_char) do |item| 72: item < threshold 73: end 74: end