pal.datatype
Class GeneralizedCodons

java.lang.Object
  |
  +--pal.datatype.SimpleDataType
        |
        +--pal.datatype.GeneralizedCodons
All Implemented Interfaces:
DataType, java.io.Serializable

public class GeneralizedCodons
extends SimpleDataType
implements java.io.Serializable

Used for mapping an exact codon to an exact state, and vice versa Can also be used as a DataType (exactly as for Codons, but more versatile).

See Also:
Serialized Form

Field Summary
static GeneralizedCodons DEFAULT_INSTANCE
          An instance for Nucleotides because what is the point of reconstructing this class
 
Fields inherited from interface pal.datatype.DataType
AMINO_ACID_DESCRIPTION, AMINOACIDS, CODON_DESCRIPTION, CODONS, GENERALIZED_CODONS_DESCRIPTION, GENERALIZEDCODONS, IUPAC_NUCELOTIDES_DESCRIPTION, IUPACNUCLEOTIDES, NUCLEOTIDE_DESCRIPTION, NUCLEOTIDES, TWO_STATE_DESCRIPTION, TWOSTATES, UNKNOWN_CHARACTER
 
Constructor Summary
GeneralizedCodons()
          The Biologists, what else do we need, constructor (nucleode character types, codon length 3)
GeneralizedCodons(DataType characterType, int codonLength)
          The Computer Scientist's want of abstraction consturctor
 
Method Summary
 char[] convertNucleotideToCodon(char[] nucleotideSequence, int startingPosition, int length, boolean reverse)
          Translates a Nucleotide sequence into a Codon sequence
 java.lang.String convertNucleotideToCodon(java.lang.String nucleotideSequence, int startingPosition, int length, boolean reverse)
          Translates a Nucleotide sequence into a Codon sequence
 int[] getBaseStatesFromCodonState(int codonState)
          Translates an index into a codon
 char getChar(int state)
          Get character corresponding to a given state
 char getCodonCharFromCodon(char[] codon)
          Returns a unique ascii character for any given codon
 char getCodonCharFromCodonIndex(int index)
          Returns a unique ascii character for any given codon index
 char getCodonCharFromCodonStates(int[] codon)
          Returns a unique ascii character for any given codon
 double[] getCodonFrequencies(double[] residueFrequencies)
           
 char[] getCodonFromCodonChar(char codonChar)
          Translates an index into a codon
 char[] getCodonFromCodonIndex(int index)
          Translates an index into a codon
 int getCodonIndexFromCodon(char[] codon)
          Returns -1 if the codon has unknowns, or gaps in it, or is less than length length!
 int getCodonIndexFromCodonChar(char c)
          Returns a unique ascii character for any given codon index
 int getCodonIndexFromCodonStates(int[] codon)
          Returns -1 if the codon has unknowns, or gaps in it, or is less than length length!
 java.lang.String getDescription()
          String describing the data type
 double[] getNucleotideFrequencies(double[] codonFrequencies)
           
 int getNumStates()
          get number of unique states
 int getState(char c)
          get state corresponding to a character
 int getTypeID()
          Get numerical code describing the data type
 boolean isUnknownState(int state)
           
 
Methods inherited from class pal.datatype.SimpleDataType
getNumSimpleStates, getSimpleStates, isAmbiguousState, isGapChar, isUnknownChar
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_INSTANCE

public static final GeneralizedCodons DEFAULT_INSTANCE
An instance for Nucleotides because what is the point of reconstructing this class
Constructor Detail

GeneralizedCodons

public GeneralizedCodons()
The Biologists, what else do we need, constructor (nucleode character types, codon length 3)

GeneralizedCodons

public GeneralizedCodons(DataType characterType,
                         int codonLength)
The Computer Scientist's want of abstraction consturctor
Method Detail

getCodonIndexFromCodon

public final int getCodonIndexFromCodon(char[] codon)
Returns -1 if the codon has unknowns, or gaps in it, or is less than length length!

getCodonIndexFromCodonStates

public final int getCodonIndexFromCodonStates(int[] codon)
Returns -1 if the codon has unknowns, or gaps in it, or is less than length length!

getCodonFromCodonIndex

public final char[] getCodonFromCodonIndex(int index)
Translates an index into a codon

getCodonFromCodonChar

public final char[] getCodonFromCodonChar(char codonChar)
Translates an index into a codon

getBaseStatesFromCodonState

public final int[] getBaseStatesFromCodonState(int codonState)
Translates an index into a codon

getCodonCharFromCodonIndex

public final char getCodonCharFromCodonIndex(int index)
Returns a unique ascii character for any given codon index

getCodonIndexFromCodonChar

public final int getCodonIndexFromCodonChar(char c)
Returns a unique ascii character for any given codon index

getCodonCharFromCodon

public final char getCodonCharFromCodon(char[] codon)
Returns a unique ascii character for any given codon

getCodonCharFromCodonStates

public final char getCodonCharFromCodonStates(int[] codon)
Returns a unique ascii character for any given codon

convertNucleotideToCodon

public final java.lang.String convertNucleotideToCodon(java.lang.String nucleotideSequence,
                                                       int startingPosition,
                                                       int length,
                                                       boolean reverse)
Translates a Nucleotide sequence into a Codon sequence

convertNucleotideToCodon

public final char[] convertNucleotideToCodon(char[] nucleotideSequence,
                                             int startingPosition,
                                             int length,
                                             boolean reverse)
Translates a Nucleotide sequence into a Codon sequence
Parameters:
nucleotideSequence - - the base nucleotide sequence as a char array
starting - position - the starting position to begin reading from
length - - the length of the reading frame (in nucleotide units - should be a multiple of 3, if not remainder is truncated!)
reverse - - if true works backwards with codon at starting position being last in translation (codon read in reverse as well). Else reads forwards.
translator - - the nucleotide translator to use for translation nucleotides into amino acids.

getNumStates

public int getNumStates()
get number of unique states
Returns:
number of unique states

getState

public int getState(char c)
get state corresponding to a character
Parameters:
c - character
Returns:
state

getChar

public char getChar(int state)
Get character corresponding to a given state
Following copied from interface: pal.datatype.DataType
Parameters:
state - state return corresponding character

getDescription

public java.lang.String getDescription()
String describing the data type
Following copied from interface: pal.datatype.DataType
Returns:
string describing the data type

isUnknownState

public boolean isUnknownState(int state)
Overrides:
isUnknownState in class SimpleDataType
Returns:
true if this state is an unknown state

getTypeID

public int getTypeID()
Get numerical code describing the data type
Following copied from interface: pal.datatype.DataType
Returns:
numerical code

getCodonFrequencies

public double[] getCodonFrequencies(double[] residueFrequencies)

getNucleotideFrequencies

public final double[] getNucleotideFrequencies(double[] codonFrequencies)