Class: Bio::BioAlignment::Sequence
- Inherits:
-
Object
- Object
- Bio::BioAlignment::Sequence
- Includes:
- State, Enumerable
- Defined in:
- lib/bio-alignment/sequence.rb
Overview
A Sequence is a simple and efficient container for String sequences. To add state to elements unpack it into an Elements object with to_elements.
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#seq ⇒ Object
readonly
Returns the value of attribute seq.
Attributes included from State
Instance Method Summary collapse
- #<<(element) ⇒ Object
- #[](index) ⇒ Object
- #clone ⇒ Object
-
#each ⇒ Object
Return each element in the Sequence as an Element opbject, so it can be queried for gap? and undefined?.
- #empty_copy ⇒ Object
-
#initialize(id, seq) ⇒ Sequence
constructor
A new instance of Sequence.
- #length ⇒ Object
-
#to_elements ⇒ Object
Return Sequence (string) as an Elements object.
- #to_s ⇒ Object
Constructor Details
#initialize(id, seq) ⇒ Sequence
Returns a new instance of Sequence.
12 13 14 15 |
# File 'lib/bio-alignment/sequence.rb', line 12 def initialize id, seq @id = id @seq = seq end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
11 12 13 |
# File 'lib/bio-alignment/sequence.rb', line 11 def id @id end |
#seq ⇒ Object (readonly)
Returns the value of attribute seq.
11 12 13 |
# File 'lib/bio-alignment/sequence.rb', line 11 def seq @seq end |
Instance Method Details
#<<(element) ⇒ Object
35 36 37 |
# File 'lib/bio-alignment/sequence.rb', line 35 def << element @seq += element.to_s end |
#[](index) ⇒ Object
17 18 19 |
# File 'lib/bio-alignment/sequence.rb', line 17 def [] index @seq[index] end |
#clone ⇒ Object
43 44 45 |
# File 'lib/bio-alignment/sequence.rb', line 43 def clone Sequence.new(@id,@seq.clone) end |
#each ⇒ Object
Return each element in the Sequence as an Element opbject, so it can be queried for gap? and undefined?
27 28 29 |
# File 'lib/bio-alignment/sequence.rb', line 27 def each @seq.each_char { | c | yield Element.new(c) } end |
#empty_copy ⇒ Object
39 40 41 |
# File 'lib/bio-alignment/sequence.rb', line 39 def empty_copy Sequence.new(@id,"") end |
#length ⇒ Object
21 22 23 |
# File 'lib/bio-alignment/sequence.rb', line 21 def length @seq.length end |
#to_elements ⇒ Object
Return Sequence (string) as an Elements object
48 49 50 |
# File 'lib/bio-alignment/sequence.rb', line 48 def to_elements Elements.new(@id,@seq) end |
#to_s ⇒ Object
31 32 33 |
# File 'lib/bio-alignment/sequence.rb', line 31 def to_s @seq.to_s end |