pal.substmodel
Class AbstractRateMatrix

java.lang.Object
  |
  +--pal.substmodel.AbstractRateMatrix
All Implemented Interfaces:
java.lang.Cloneable, NamedParameterized, Parameterized, RateMatrix, Report, java.io.Serializable
Direct Known Subclasses:
AminoAcidModel, CodonModel, NucleotideModel, TwoStateModel

public abstract class AbstractRateMatrix
extends java.lang.Object
implements RateMatrix

abstract base class for all rate matrices

See Also:
Serialized Form

Field Summary
 DataType dataType
          data type
 int dimension
          dimension
protected  FormattedOutput format
           
 double[] frequency
          stationary frequencies (sum = 1.0)
 double[][] rate
          rate matrix (transition: from 1st index to 2nd index)
 
Constructor Summary
protected AbstractRateMatrix(int dim)
           
 
Method Summary
 void addPalObjectListener(PalObjectListener pol)
          Add a PalObjectListener to be notified of changes to the model.
 java.lang.Object clone()
           
protected  void fireParametersChangedEvent()
           
protected  void fireParametersChangedEvent(PalObjectEvent pe)
           
protected  void fromQToR()
          Computes normalized rate matrix from Q matrix (general reversible model) - Q_ii = 0 - Q_ij = Q_ji - Q_ij is stored in R_ij (rate) - only upper triangular is used Also updates related MatrixExponential
 DataType getDataType()
          Get the data type of this rate matrix
 int getDimension()
           
 double[] getEquilibriumFrequencies()
           
 double getEquilibriumFrequency(int i)
           
abstract  int getModelID()
          get numerical code describing the model type
 double[][] getRelativeRates()
           
 void getTransitionProbabilities(double[][] probabilityStore)
          A utility method for speed, transfers trans prob information quickly into store
 double getTransitionProbability(int fromState, int toState)
          Returns the probability of going from one state to another given the current distance
 int getTypeID()
          get numerical code describing the data type
protected  void printFrequencies(java.io.PrintWriter out)
           
 void removePalObjectListener(PalObjectListener pol)
           
 void setDistance(double distance)
          Sets the distance (such as time/branch length) used when calculating the probabilities.
protected  void setFrequencies(double[] f)
           
protected  void updateMatrixExp()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface pal.substmodel.RateMatrix
getUniqueName
 
Methods inherited from interface pal.misc.NamedParameterized
getParameterName
 
Methods inherited from interface pal.misc.Parameterized
getDefaultValue, getLowerLimit, getNumParameters, getParameter, getUpperLimit, setParameter, setParameterSE
 
Methods inherited from interface pal.misc.Report
report
 

Field Detail

dimension

public int dimension
dimension

frequency

public double[] frequency
stationary frequencies (sum = 1.0)

rate

public double[][] rate
rate matrix (transition: from 1st index to 2nd index)

dataType

public DataType dataType
data type

format

protected FormattedOutput format
Constructor Detail

AbstractRateMatrix

protected AbstractRateMatrix(int dim)
Method Detail

getTypeID

public int getTypeID()
get numerical code describing the data type
Specified by:
getTypeID in interface RateMatrix
Returns:
integer code identifying a data type

getModelID

public abstract int getModelID()
get numerical code describing the model type
Specified by:
getModelID in interface RateMatrix
Returns:
integer code identifying a substitution model

getDimension

public int getDimension()
Specified by:
getDimension in interface RateMatrix
Following copied from interface: pal.substmodel.RateMatrix
Returns:
the dimension of this rate matrix.

getEquilibriumFrequencies

public double[] getEquilibriumFrequencies()
Specified by:
getEquilibriumFrequencies in interface RateMatrix
Returns:
stationary frequencies (sum = 1.0)

getEquilibriumFrequency

public double getEquilibriumFrequency(int i)
Specified by:
getEquilibriumFrequency in interface RateMatrix
Returns:
stationary frequencie (sum = 1.0) for ith state

getDataType

public DataType getDataType()
Description copied from interface: RateMatrix
Get the data type of this rate matrix
Specified by:
getDataType in interface RateMatrix

getRelativeRates

public double[][] getRelativeRates()
Specified by:
getRelativeRates in interface RateMatrix
Returns:
rate matrix (transition: from 1st index to 2nd index)

getTransitionProbability

public double getTransitionProbability(int fromState,
                                       int toState)
Returns the probability of going from one state to another given the current distance
Specified by:
getTransitionProbability in interface RateMatrix
Parameters:
fromState - The state from which we are starting
toState - The resulting state

setDistance

public final void setDistance(double distance)
Sets the distance (such as time/branch length) used when calculating the probabilities. This method may well take the most time!
Specified by:
setDistance in interface RateMatrix

getTransitionProbabilities

public final void getTransitionProbabilities(double[][] probabilityStore)
A utility method for speed, transfers trans prob information quickly into store
Specified by:
getTransitionProbabilities in interface RateMatrix

printFrequencies

protected void printFrequencies(java.io.PrintWriter out)

setFrequencies

protected void setFrequencies(double[] f)

fromQToR

protected void fromQToR()
Computes normalized rate matrix from Q matrix (general reversible model) - Q_ii = 0 - Q_ij = Q_ji - Q_ij is stored in R_ij (rate) - only upper triangular is used Also updates related MatrixExponential

addPalObjectListener

public void addPalObjectListener(PalObjectListener pol)
Description copied from interface: RateMatrix
Add a PalObjectListener to be notified of changes to the model. Only the parametersChanged method will generally be called
Specified by:
addPalObjectListener in interface RateMatrix

removePalObjectListener

public void removePalObjectListener(PalObjectListener pol)
Specified by:
removePalObjectListener in interface RateMatrix

fireParametersChangedEvent

protected void fireParametersChangedEvent()

fireParametersChangedEvent

protected void fireParametersChangedEvent(PalObjectEvent pe)

updateMatrixExp

protected void updateMatrixExp()

clone

public java.lang.Object clone()
Specified by:
clone in interface RateMatrix
Overrides:
clone in class java.lang.Object