Class: Bio::BioAlignment::Codon
- Inherits:
-
Object
- Object
- Bio::BioAlignment::Codon
- Includes:
- State
- Defined in:
- lib/bio-alignment/codonsequence.rb
Overview
Codon element for the matrix, used by CodonSequence.
Constant Summary collapse
- GAP =
'---'
- UNDEFINED =
'XXX'
Instance Attribute Summary collapse
-
#codon_table ⇒ Object
readonly
Returns the value of attribute codon_table.
Attributes included from State
Instance Method Summary collapse
- #==(other) ⇒ Object
- #gap? ⇒ Boolean
-
#initialize(codon, codon_table = 1) ⇒ Codon
constructor
A new instance of Codon.
-
#to_aa ⇒ Object
lazily convert to Amino acid (once only).
- #to_s ⇒ Object
- #undefined? ⇒ Boolean
Constructor Details
#initialize(codon, codon_table = 1) ⇒ Codon
Returns a new instance of Codon.
15 16 17 18 19 20 |
# File 'lib/bio-alignment/codonsequence.rb', line 15 def initialize codon, codon_table = 1 @codon = codon @codon_table = codon_table @codon.freeze @codon_table.freeze end |
Instance Attribute Details
#codon_table ⇒ Object (readonly)
Returns the value of attribute codon_table.
12 13 14 |
# File 'lib/bio-alignment/codonsequence.rb', line 12 def codon_table @codon_table end |
Instance Method Details
#==(other) ⇒ Object
38 39 40 |
# File 'lib/bio-alignment/codonsequence.rb', line 38 def == other @codon == other.to_s end |
#gap? ⇒ Boolean
22 23 24 |
# File 'lib/bio-alignment/codonsequence.rb', line 22 def gap? @codon == GAP end |
#to_aa ⇒ Object
lazily convert to Amino acid (once only)
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/bio-alignment/codonsequence.rb', line 43 def to_aa aa = translate if not aa if gap? return '-' elsif undefined? return UNDEFINED else raise 'What?' end end aa end |
#to_s ⇒ Object
34 35 36 |
# File 'lib/bio-alignment/codonsequence.rb', line 34 def to_s @codon end |
#undefined? ⇒ Boolean
26 27 28 29 30 31 32 |
# File 'lib/bio-alignment/codonsequence.rb', line 26 def undefined? aa = translate if aa == nil and not gap? return true end false end |