pal.substmodel
Class CachedRateMatrix

java.lang.Object
  |
  +--pal.substmodel.CachedRateMatrix
All Implemented Interfaces:
java.lang.Cloneable, NamedParameterized, PalObjectListener, Parameterized, RateMatrix, Report, java.io.Serializable

public class CachedRateMatrix
extends java.lang.Object
implements RateMatrix, PalObjectListener

a cached rate matrix. This model caches transition probabilities by distance in order to increase speed of likelihood calculations for repeated calls with same/similar branch lengths.

See Also:
Serialized Form

Constructor Summary
CachedRateMatrix(CachedRateMatrix cachedRateMatrix)
           
CachedRateMatrix(RateMatrix rateMatrix, DoubleKeyCache cache)
           
CachedRateMatrix(RateMatrix rateMatrix, int maxCacheSize)
           
 
Method Summary
 void addPalObjectListener(PalObjectListener pol)
          Add a PalObjectListener to be notified of changes to the model.
 java.lang.Object clone()
          A non shallow implementation of clone()
 DataType getDataType()
          Get the data type of this rate matrix
 double getDefaultValue(int n)
          get default value of parameter
 int getDimension()
           
 double[] getEquilibriumFrequencies()
           
 double getEquilibriumFrequency(int i)
           
 double getLowerLimit(int n)
          get lower parameter limit
 int getModelID()
          get numerical code describing the model type
 int getNumParameters()
          get number of parameters
 double getParameter(int n)
          get model parameter
 java.lang.String getParameterName(int i)
           
 double[][] getRelativeRates()
           
 void getTransitionProbabilities(double[][] probs)
          A utility method for speed, transfers trans prob information quickly into store
 double getTransitionProbability(int i, int j)
          get transition probability for the preselected model and the previously specified distance
 int getTypeID()
          get numerical code describing the data type
 java.lang.String getUniqueName()
           
 double getUpperLimit(int n)
          get upper parameter limit
 void parametersChanged(PalObjectEvent pe)
          Signifies that parametric valued governing the state of this Object have changed.
 void removePalObjectListener(PalObjectListener pol)
           
 void report(java.io.PrintWriter out)
          print human readable report (e.g., on parameters and associated model)
 void setDistance(double k)
          set distance and corresponding computation transition probabilities
 void setParameter(double param, int n)
          set model parameter
 void setParameterSE(double paramSE, int n)
          set standard errors for model parameter
 void structureChanged(PalObjectEvent pe)
          Signifies that the structure of the object has changed (for example in trees to topology has changed)
 java.lang.String toString()
          Return string representation of substitution model.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CachedRateMatrix

public CachedRateMatrix(RateMatrix rateMatrix,
                        DoubleKeyCache cache)
Parameters:
model - the underlying substitution model
cache - the caching method used

CachedRateMatrix

public CachedRateMatrix(RateMatrix rateMatrix,
                        int maxCacheSize)
Parameters:
model - the underlying substitution model

CachedRateMatrix

public CachedRateMatrix(CachedRateMatrix cachedRateMatrix)
Parameters:
model - the previous cached model.
Method Detail

report

public final void report(java.io.PrintWriter out)
Description copied from interface: Report
print human readable report (e.g., on parameters and associated model)
Specified by:
report in interface Report
Following copied from interface: pal.misc.Report
Parameters:
out - output stream

getTypeID

public final int getTypeID()
Description copied from interface: RateMatrix
get numerical code describing the data type
Specified by:
getTypeID in interface RateMatrix
Following copied from interface: pal.substmodel.RateMatrix
Returns:
integer code identifying a data type

getModelID

public final int getModelID()
Description copied from interface: RateMatrix
get numerical code describing the model type
Specified by:
getModelID in interface RateMatrix
Following copied from interface: pal.substmodel.RateMatrix
Returns:
integer code identifying a substitution model

getDimension

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

getEquilibriumFrequencies

public final double[] getEquilibriumFrequencies()
Specified by:
getEquilibriumFrequencies in interface RateMatrix
Following copied from interface: pal.substmodel.RateMatrix
Returns:
stationary frequencies (sum = 1.0)

getEquilibriumFrequency

public final double getEquilibriumFrequency(int i)
Specified by:
getEquilibriumFrequency in interface RateMatrix
Following copied from interface: pal.substmodel.RateMatrix
Returns:
stationary frequency (sum = 1.0) for ith state Preferred method for infrequent use.

getRelativeRates

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

toString

public java.lang.String toString()
Return string representation of substitution model.
Overrides:
toString in class java.lang.Object

getNumParameters

public final int getNumParameters()
Description copied from interface: Parameterized
get number of parameters
Specified by:
getNumParameters in interface Parameterized
Following copied from interface: pal.misc.Parameterized
Returns:
number of parameters

setParameter

public final void setParameter(double param,
                               int n)
Description copied from interface: Parameterized
set model parameter
Specified by:
setParameter in interface Parameterized
Following copied from interface: pal.misc.Parameterized
Parameters:
param - parameter value
n - parameter number

getParameter

public final double getParameter(int n)
Description copied from interface: Parameterized
get model parameter
Specified by:
getParameter in interface Parameterized
Following copied from interface: pal.misc.Parameterized
Parameters:
n - parameter number
Returns:
parameter value

setParameterSE

public final void setParameterSE(double paramSE,
                                 int n)
Description copied from interface: Parameterized
set standard errors for model parameter
Specified by:
setParameterSE in interface Parameterized
Following copied from interface: pal.misc.Parameterized
Parameters:
paramSE - standard error of parameter value
n - parameter number

getLowerLimit

public final double getLowerLimit(int n)
Description copied from interface: Parameterized
get lower parameter limit
Specified by:
getLowerLimit in interface Parameterized
Following copied from interface: pal.misc.Parameterized
Parameters:
n - parameter number
Returns:
lower bound

getUpperLimit

public final double getUpperLimit(int n)
Description copied from interface: Parameterized
get upper parameter limit
Specified by:
getUpperLimit in interface Parameterized
Following copied from interface: pal.misc.Parameterized
Parameters:
n - parameter number
Returns:
upper bound

getDefaultValue

public final double getDefaultValue(int n)
Description copied from interface: Parameterized
get default value of parameter
Specified by:
getDefaultValue in interface Parameterized
Following copied from interface: pal.misc.Parameterized
Parameters:
n - parameter number
Returns:
default value

getParameterName

public final java.lang.String getParameterName(int i)
Specified by:
getParameterName in interface NamedParameterized
Following copied from interface: pal.misc.NamedParameterized
Returns:
a short identifier for this parameter type. Should be the same for all instances of a given class!

setDistance

public final void setDistance(double k)
set distance and corresponding computation transition probabilities
Specified by:
setDistance in interface RateMatrix
Parameters:
k - distance

getTransitionProbability

public final double getTransitionProbability(int i,
                                             int j)
get transition probability for the preselected model and the previously specified distance
Specified by:
getTransitionProbability in interface RateMatrix
Parameters:
i - start state
j - end state
Returns:
transition probability

getTransitionProbabilities

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

clone

public final java.lang.Object clone()
A non shallow implementation of clone()
Specified by:
clone in interface RateMatrix
Overrides:
clone in class java.lang.Object

getDataType

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

getUniqueName

public final java.lang.String getUniqueName()
Specified by:
getUniqueName in interface RateMatrix
Following copied from interface: pal.substmodel.RateMatrix
Returns:
a short unique human-readable identifier for this rate matrix.

structureChanged

public void structureChanged(PalObjectEvent pe)
Description copied from interface: PalObjectListener
Signifies that the structure of the object has changed (for example in trees to topology has changed)
Specified by:
structureChanged in interface PalObjectListener

parametersChanged

public void parametersChanged(PalObjectEvent pe)
Description copied from interface: PalObjectListener
Signifies that parametric valued governing the state of this Object have changed. Parameters don't have to be visible ones For example, in trees the branch lengths have changed.
Specified by:
parametersChanged in interface PalObjectListener

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