Module: Wrnap::Global::Extensions::ClassMethods
- Defined in:
- lib/wrnap/global/rna/extensions.rb
Instance Method Summary collapse
- #generate_sequence(sequence_length) ⇒ Object
- #shuffle(sequence, token_length = 2) ⇒ Object
- #structure_from_bp_list(length, base_pairs) ⇒ Object
Instance Method Details
#generate_sequence(sequence_length) ⇒ Object
28 29 30 31 |
# File 'lib/wrnap/global/rna/extensions.rb', line 28 def generate_sequence(sequence_length) # 0th order Markov chain w/ uniform probability distribution Rna.init_from_string(sequence_length.times.inject("") { |string, _| string + %w[A U C G][rand(4)] }) end |
#shuffle(sequence, token_length = 2) ⇒ Object
33 34 35 |
# File 'lib/wrnap/global/rna/extensions.rb', line 33 def shuffle(sequence, token_length = 2) Shuffle.new(sequence).shuffle(token_length) end |
#structure_from_bp_list(length, base_pairs) ⇒ Object
37 38 39 |
# File 'lib/wrnap/global/rna/extensions.rb', line 37 def structure_from_bp_list(length, base_pairs) base_pairs.to_a.map(&:to_a).map(&:sort).inject("." * length) { |structure, (i, j)| structure.tap { structure[i] = ?(; structure[j] = ?) } } end |