Class: Bio::BioAlignment::CodonSequence
- Inherits:
-
Object
- Object
- Bio::BioAlignment::CodonSequence
- Includes:
- Enumerable
- Defined in:
- lib/bio-alignment/codonsequence.rb
Overview
A CodonSequence supports the concept of codons (triple nucleotides) for an alignment. A codon table number can be passed in for translation of nucleotide sequences. This is the same table used in BioRuby.
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#seq ⇒ Object
readonly
Returns the value of attribute seq.
Instance Method Summary collapse
- #[](index) ⇒ Object
- #each ⇒ Object
-
#initialize(id, seq, options = { :codon_table => 1 }) ⇒ CodonSequence
constructor
A new instance of CodonSequence.
- #to_aa ⇒ Object
-
#to_nt ⇒ Object
extra methods.
- #to_s ⇒ Object
Constructor Details
#initialize(id, seq, options = { :codon_table => 1 }) ⇒ CodonSequence
Returns a new instance of CodonSequence.
64 65 66 67 68 69 70 71 |
# File 'lib/bio-alignment/codonsequence.rb', line 64 def initialize id, seq, = { :codon_table => 1 } @id = id @seq = [] @codon_table = [:codon_table] seq.scan(/\S\S\S/).each do | codon | @seq << Codon.new(codon, @codon_table) end end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
63 64 65 |
# File 'lib/bio-alignment/codonsequence.rb', line 63 def id @id end |
#seq ⇒ Object (readonly)
Returns the value of attribute seq.
63 64 65 |
# File 'lib/bio-alignment/codonsequence.rb', line 63 def seq @seq end |
Instance Method Details
#[](index) ⇒ Object
73 74 75 |
# File 'lib/bio-alignment/codonsequence.rb', line 73 def [] index @seq[index] end |
#each ⇒ Object
77 78 79 |
# File 'lib/bio-alignment/codonsequence.rb', line 77 def each @seq.each { | codon | yield codon } end |
#to_aa ⇒ Object
91 92 93 |
# File 'lib/bio-alignment/codonsequence.rb', line 91 def to_aa @seq.map { |codon| codon.to_aa }.join('') end |
#to_nt ⇒ Object
extra methods
87 88 89 |
# File 'lib/bio-alignment/codonsequence.rb', line 87 def to_nt @seq.map { |codon| codon.to_s }.join('') end |
#to_s ⇒ Object
81 82 83 |
# File 'lib/bio-alignment/codonsequence.rb', line 81 def to_s @seq.map { |codon| codon.to_s }.join(' ') end |