Class CodonSequence

java.lang.Object
jebl.evolution.sequences.CodonSequence
All Implemented Interfaces:
Comparable, Sequence, Attributable

public class CodonSequence extends Object implements Sequence
A codon implementation of the Sequence interface.
Version:
$Id: BasicSequence.java 1042 2009-12-08 00:14:20Z amyzeta $
Author:
Andrew Rambaut, Alexei Drummond
  • Constructor Details

    • CodonSequence

      public CodonSequence(Taxon taxon, State[] states)
      Creates a sequence with a name corresponding to the taxon name
      Parameters:
      taxon -
      states -
  • Method Details

    • getSequenceType

      public SequenceType getSequenceType()
      Specified by:
      getSequenceType in interface Sequence
      Returns:
      the type of symbols that this sequence is made up of.
    • getString

      public String getString()
      Specified by:
      getString in interface Sequence
      Returns:
      a string representing the sequence of symbols.
    • getCleanString

      public String getCleanString()
    • getStates

      public State[] getStates()
      Specified by:
      getStates in interface Sequence
      Returns:
      an array of state objects.
    • getStateIndices

      public byte[] getStateIndices()
      Specified by:
      getStateIndices in interface Sequence
      Returns:
      an array of state indices.
    • getSequenceCharacters

      public byte[] getSequenceCharacters()
      Get the sequence characters representing the sequence. This return is a byte[] rather than a char[] to avoid using twice as much memory as necessary. The individual elements of the returned array can be cast to chars.
      Returns:
      the sequence characters as an array of characters.
    • getState

      public State getState(int site)
      Specified by:
      getState in interface Sequence
      Returns:
      the state at site.
    • getLength

      public int getLength()
      Returns the length of the sequence
      Specified by:
      getLength in interface Sequence
      Returns:
      the length
    • getTaxon

      public Taxon getTaxon()
      Specified by:
      getTaxon in interface Sequence
      Returns:
      that taxon that this sequence represents (primarily used to match sequences with tree nodes)
    • compareTo

      public int compareTo(Object o)
      Sequences are compared by their taxa
      Specified by:
      compareTo in interface Comparable
      Parameters:
      o - another sequence
      Returns:
      an integer
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setAttribute

      public void setAttribute(String name, Object value)
      Description copied from interface: Attributable
      Sets an named attribute for this object.
      Specified by:
      setAttribute in interface Attributable
      Parameters:
      name - the name of the attribute.
      value - the new value of the attribute.
    • getAttribute

      public Object getAttribute(String name)
      Specified by:
      getAttribute in interface Attributable
      Parameters:
      name - the name of the attribute of interest, or null if the attribute doesn't exist.
      Returns:
      an object representing the named attributed for this object.
    • removeAttribute

      public void removeAttribute(String name)
      Specified by:
      removeAttribute in interface Attributable
      Parameters:
      name - name of attribute to remove
    • getAttributeNames

      public Set<String> getAttributeNames()
      Specified by:
      getAttributeNames in interface Attributable
      Returns:
      an array of the attributeNames that this object has.
    • getAttributeMap

      public Map<String,Object> getAttributeMap()
      Description copied from interface: Attributable
      Gets the entire attribute map.
      Specified by:
      getAttributeMap in interface Attributable
      Returns:
      an unmodifiable map
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object