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
- #<<(codon) ⇒ Object
- #[](index) ⇒ Object
- #each ⇒ Object
- #empty_copy ⇒ Object
-
#initialize(id, seq, options = { :codon_table => 1 }) ⇒ CodonSequence
constructor
A new instance of CodonSequence.
- #length ⇒ Object
- #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.
68 69 70 71 72 73 74 75 |
# File 'lib/bio-alignment/codonsequence.rb', line 68 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.
67 68 69 |
# File 'lib/bio-alignment/codonsequence.rb', line 67 def id @id end |
#seq ⇒ Object (readonly)
Returns the value of attribute seq.
67 68 69 |
# File 'lib/bio-alignment/codonsequence.rb', line 67 def seq @seq end |
Instance Method Details
#<<(codon) ⇒ Object
107 108 109 |
# File 'lib/bio-alignment/codonsequence.rb', line 107 def << codon @seq << codon end |
#[](index) ⇒ Object
77 78 79 |
# File 'lib/bio-alignment/codonsequence.rb', line 77 def [] index @seq[index] end |
#each ⇒ Object
85 86 87 |
# File 'lib/bio-alignment/codonsequence.rb', line 85 def each @seq.each { | codon | yield codon } end |
#empty_copy ⇒ Object
103 104 105 |
# File 'lib/bio-alignment/codonsequence.rb', line 103 def empty_copy CodonSequence.new(@id,"") end |
#length ⇒ Object
81 82 83 |
# File 'lib/bio-alignment/codonsequence.rb', line 81 def length @seq.length end |
#to_aa ⇒ Object
99 100 101 |
# File 'lib/bio-alignment/codonsequence.rb', line 99 def to_aa @seq.map { |codon| codon.to_aa }.join('') end |
#to_nt ⇒ Object
extra methods
95 96 97 |
# File 'lib/bio-alignment/codonsequence.rb', line 95 def to_nt @seq.map { |codon| codon.to_s }.join('') end |
#to_s ⇒ Object
89 90 91 |
# File 'lib/bio-alignment/codonsequence.rb', line 89 def to_s @seq.map { |codon| codon.to_s }.join(' ') end |