Class: Wrnap::Rna::Helix
- Inherits:
-
Object
- Object
- Wrnap::Rna::Helix
- Defined in:
- lib/wrnap/rna/motifs.rb
Instance Attribute Summary collapse
-
#i ⇒ Object
readonly
Returns the value of attribute i.
-
#j ⇒ Object
readonly
Returns the value of attribute j.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
Instance Method Summary collapse
- #apply!(structure) ⇒ Object
- #in(sequence) ⇒ Object
-
#initialize(i, j, length) ⇒ Helix
constructor
A new instance of Helix.
- #inspect ⇒ Object
- #k ⇒ Object
- #l ⇒ Object
- #merge!(helix) ⇒ Object
- #name ⇒ Object
- #reindex!(rna) ⇒ Object
- #to_loops ⇒ Object
Constructor Details
#initialize(i, j, length) ⇒ Helix
Returns a new instance of Helix.
6 7 8 |
# File 'lib/wrnap/rna/motifs.rb', line 6 def initialize(i, j, length) @i, @j, @length = i, j, length end |
Instance Attribute Details
#i ⇒ Object (readonly)
Returns the value of attribute i.
4 5 6 |
# File 'lib/wrnap/rna/motifs.rb', line 4 def i @i end |
#j ⇒ Object (readonly)
Returns the value of attribute j.
4 5 6 |
# File 'lib/wrnap/rna/motifs.rb', line 4 def j @j end |
#length ⇒ Object (readonly)
Returns the value of attribute length.
4 5 6 |
# File 'lib/wrnap/rna/motifs.rb', line 4 def length @length end |
Instance Method Details
#apply!(structure) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/wrnap/rna/motifs.rb', line 23 def apply!(structure) structure.tap do structure[i, length] = ?( * length structure[l, length] = ?) * length end end |
#in(sequence) ⇒ Object
13 14 15 16 17 |
# File 'lib/wrnap/rna/motifs.rb', line 13 def in(sequence) (0...length).map do |stem_position| [sequence[i + stem_position], sequence[j - stem_position]] end end |
#inspect ⇒ Object
50 51 52 |
# File 'lib/wrnap/rna/motifs.rb', line 50 def inspect "#<Helix: %s>" % name end |
#k ⇒ Object
10 |
# File 'lib/wrnap/rna/motifs.rb', line 10 def k; i + length - 1; end |
#l ⇒ Object
11 |
# File 'lib/wrnap/rna/motifs.rb', line 11 def l; j - length + 1; end |
#merge!(helix) ⇒ Object
30 31 32 |
# File 'lib/wrnap/rna/motifs.rb', line 30 def merge!(helix) @length = helix.k - i + 1 end |
#name ⇒ Object
46 47 48 |
# File 'lib/wrnap/rna/motifs.rb', line 46 def name "(%d..%d, %d..%d [%d])" % [i, k, l, j, length] end |
#reindex!(rna) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/wrnap/rna/motifs.rb', line 34 def reindex!(rna) tap do if i < 0 && j < 0 @i = rna.len + i @j = rna.len + j else @i = i - rna.len @j = j - rna.len end end end |