class Bio::BioAlignment::CodonSequence
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.
Attributes
id[R]
seq[R]
Public Class Methods
new(id, seq, options = { :codon_table => 1 })
click to toggle source
# File lib/bio-alignment/codonsequence.rb, line 75 def initialize id, seq, options = { :codon_table => 1 } @id = id @seq = [] @codon_table = options[:codon_table] seq.scan(/\S\S\S/).each do | codon | @seq << Codon.new(codon, @codon_table) end @id.freeze @codon_table.freeze # @seq is not immutable, as we can add new codes to the list end
Public Instance Methods
<<(codon)
click to toggle source
# File lib/bio-alignment/codonsequence.rb, line 118 def << codon @seq << codon end
[](index)
click to toggle source
# File lib/bio-alignment/codonsequence.rb, line 87 def [] index @seq[index] end
each() { |codon| ... }
click to toggle source
# File lib/bio-alignment/codonsequence.rb, line 95 def each @seq.each { | codon | yield codon } end
empty_copy()
click to toggle source
# File lib/bio-alignment/codonsequence.rb, line 114 def empty_copy CodonSequence.new(@id,"") end
length()
click to toggle source
# File lib/bio-alignment/codonsequence.rb, line 91 def length @seq.length end
to_aa()
click to toggle source
# File lib/bio-alignment/codonsequence.rb, line 110 def to_aa @seq.map { |codon| codon.to_aa }.join('') end
to_elements()
click to toggle source
to_nt()
click to toggle source
extra methods
# File lib/bio-alignment/codonsequence.rb, line 106 def to_nt @seq.map { |codon| codon.to_s }.join('') end
to_s()
click to toggle source
Output codon style
# File lib/bio-alignment/codonsequence.rb, line 100 def to_s @seq.map { |codon| codon.to_s }.join(' ') end