Module: BioDSL::Digest
- Included in:
- Seq
- Defined in:
- lib/BioDSL/seq/digest.rb
Overview
Namespace for Digest.
Instance Method Summary collapse
-
#each_digest(pattern, cut_pos) {|subseq| ... } ⇒ Object
Method to get the next digestion product from a sequence.
Instance Method Details
#each_digest(pattern, cut_pos) {|subseq| ... } ⇒ Object
Method to get the next digestion product from a sequence.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/BioDSL/seq/digest.rb', line 36 def each_digest(pattern, cut_pos) return to_enum(:each_digest, pattern, cut_pos) unless block_given? pattern = disambiguate(pattern) offset = 0 seq.upcase.scan pattern do pos = $`.length + cut_pos if pos >= 0 && pos < length - 2 subseq = self[offset...pos] subseq.seq_name = "#{seq_name}[#{offset}-#{pos - offset - 1}]" yield subseq end offset = pos end offset = 0 if offset < 0 || offset > length subseq = self[offset..-1] subseq.seq_name = "#{seq_name}[#{offset}-#{length - 1}]" yield subseq end |