public class RateCategory
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Class and Description |
---|---|
static class |
RateCategory.FrequencyType
Enumeration of the different ways of defining the root frequency
|
static class |
RateCategory.RateException
Exception thrown if there is a problem within a RateClass
|
Constructor and Description |
---|
RateCategory(java.lang.String[][] rates,
RateCategory.FrequencyType freqType,
java.util.HashMap<java.lang.String,java.lang.Integer> map)
Constructor for when the root distribution is defined as the stationary
or quasi-stationary distribution.
|
RateCategory(java.lang.String[][] rates,
java.lang.String[] freq,
java.util.Map<java.lang.String,java.lang.Integer> map)
Constructor for when the root distribution is defined.
|
Modifier and Type | Method and Description |
---|---|
static RateCategory |
fromFile(java.io.File mfile)
Creates an instance from the information in a file.
|
java.util.Map<java.lang.String,java.lang.Integer> |
getArrayMap()
Gets the map that maps state to position in matrix
Called this as
getMap() is kept for comptability |
double[] |
getFreq()
Gets the root frequencies
|
java.util.Map<java.lang.String,java.lang.Integer> |
getMap()
Gets the map that maps state to position in matrix
|
java.lang.String |
getName()
Get the name of the rate category
|
int |
getNumberStates()
Gets the number of states in the rate class
|
SquareMatrix |
getP(double length)
Gets the P-matrix for a given length
|
Root |
getRoot()
Get a root object that can be used to calculate the total likelihood
from the root node likelihoods or provide the frequencies of the various
states at the root
|
SquareMatrix |
getScaledMatrix()
Gets the scaled rate matrix
|
double |
getTotalRate()
Gets the total rate of the rate class.
|
RateCategory |
multiplyBy(java.lang.String mult)
Returns a new RateCategory where every position in the rate matrix is multiplied
by a given value
|
void |
setName(java.lang.String name)
Sets the name of the rate category.
|
void |
setParameters(Parameters p)
Updates the parameters in the RateCategory and recalculates matrices /
frequencies if necessary.
|
java.lang.String |
toString() |
public RateCategory(java.lang.String[][] rates, RateCategory.FrequencyType freqType, java.util.HashMap<java.lang.String,java.lang.Integer> map) throws RateCategory.RateException
rates
- Array representing the rate matrixfreqType
- How the root frequency is calculatedmap
- Map from State to position in matrix (0-index). For example
map would contain A -> 0 if state A was in the first position (column and
row of the matrix.RateCategory.RateException
- If the rate matrix is not squarepublic RateCategory(java.lang.String[][] rates, java.lang.String[] freq, java.util.Map<java.lang.String,java.lang.Integer> map) throws RateCategory.RateException
_StateName
, for example if there is a state A,
the parameter _A
can be used to represent the frquency of A.rates
- Array representing the rate matrixfreq
- Root frequency.map
- Map from State to position in matrix (0-index) or root frequency.
For example map would contain A -> 0 if state A was in the first position
(column and row) of the matrix and in the first position of the root frequency
array.RateCategory.RateException
- If the rate matrix is not square
or the frequency array is not the same length as the rate matrix.public void setParameters(Parameters p) throws RateCategory.RateException, Parameters.ParameterException
p
- The new parametersRateCategory.RateException
- If the parameters passed does not
include all the parameters in the model.Parameters.ParameterException
- If a parameter that needs to be set for this
rate category has not been passedpublic double getTotalRate()
public double[] getFreq()
getMap()
and which was passed to the constuctor.public Root getRoot()
public int getNumberStates()
public java.util.Map<java.lang.String,java.lang.Integer> getArrayMap()
getMap()
is kept for comptabilitypublic java.util.Map<java.lang.String,java.lang.Integer> getMap()
public RateCategory multiplyBy(java.lang.String mult) throws RateCategory.RateException
mult
- Value to be multiplied (as a string as it will be evaluated as
a equation)RateCategory.RateException
- If the equation to multiply the
rates by is invalid.public SquareMatrix getP(double length) throws RateCategory.RateException
length
- The lengthgetMap()
and which was passed to the constructor.RateCategory.RateException
- Thrown if the matrix cannot be
calculated.public SquareMatrix getScaledMatrix()
public void setName(java.lang.String name)
name
- The rate category's namepublic java.lang.String getName()
public java.lang.String toString()
toString
in class java.lang.Object
public static RateCategory fromFile(java.io.File mfile) throws InputException, RateCategory.RateException
MathsParse
for a description of the format of the equations that can be in the rate
matrix and root distribution.
File format is as follows:
mfile
- The input fileInputException
- If there is a problem with the input fileRateCategory.RateException
- If the RateCategory can not be created