public class Model extends java.lang.Object implements java.lang.Iterable<RateCategory>
RateCategory
.Parameter
) be assigned a fixed value or optimised.
They may also contain numbers and mathematical operations. See
FunctionParser
for more on how these rates are evaluated.Modifier and Type | Class and Description |
---|---|
static class |
Model.ModelException
Exception thrown when there is a problem with the model
|
Constructor and Description |
---|
Model(java.util.Map<RateCategory,java.lang.String> freq)
Creates a new model with multiple rate classes
|
Model(RateCategory r)
Creates a new model with a single rate class
|
Modifier and Type | Method and Description |
---|---|
static Model |
fromFile(java.io.File f)
Creates a new model from a file.
|
static Model |
gammaRates(RateCategory r,
java.lang.String gamma,
int cats)
Creates a new model with multiple rate classes distributed by a gamma
distribution (see Yang 1993) based on a single rate class
|
double |
getFreq(RateCategory r)
Gets the frquency of a rate class
|
java.util.Map<java.lang.String,java.lang.Integer> |
getMap()
Gets a map from the rate name to its index in the rate matrix
|
int |
getNumberStates()
Get the number of states represented in the model
|
java.util.Set<RateCategory> |
getRates()
Gets a set of rate classes in the model
|
double |
getScale()
Gets the scale - the value the rate matrices need to be multiplied by
to ensure an average rate of 1.
|
java.util.Set<java.lang.String> |
getStates()
Gets the set of all states in the model
|
boolean |
hasSingleRate()
Tests whether the model has a single rate class.
|
java.util.Iterator<RateCategory> |
iterator() |
void |
setParameters(Parameters p)
Sets the parameters of a model to the values contained in the
Parameters data structure. |
void |
setRescale(boolean rescale)
Sets whether the matrix should be rescaled so the average rate of change
is one.
|
public Model(RateCategory r)
r
- The single rate classpublic Model(java.util.Map<RateCategory,java.lang.String> freq) throws Model.ModelException
freq
- A map from the rate classes in the model to the frequency of
the rate class (as a String - see the introduction to this class).
Frequencies need not sum to one as they are rescaled to do so.Model.ModelException
- If the states in each of the rate classes are not
identical.public int getNumberStates()
public java.util.Map<java.lang.String,java.lang.Integer> getMap()
public java.util.Set<java.lang.String> getStates()
public double getFreq(RateCategory r)
r
- The rate class to get the frquency forpublic void setParameters(Parameters p) throws RateCategory.RateException, Model.ModelException, Parameters.ParameterException
Parameters
data structure.p
- The parameter valuesRateCategory.RateException
- If there is an error while setting the parameter
values for one of the rate classes.Model.ModelException
- If there is an error while setting the parameter
values for the frequency of the rate classes.Parameters.ParameterException
- If a parameter that needs to be set for this
model has not been passedpublic double getScale()
public boolean hasSingleRate()
public java.util.Iterator<RateCategory> iterator()
iterator
in interface java.lang.Iterable<RateCategory>
public java.util.Set<RateCategory> getRates()
public void setRescale(boolean rescale)
rescale
- Whether to rescalepublic static Model gammaRates(RateCategory r, java.lang.String gamma, int cats)
r
- The rate class to base the model ongamma
- The value of gamma as a string (as it will be evaluated)cats
- The number of categories, or rate classes, in the new modelpublic static Model fromFile(java.io.File f) throws InputException, Model.ModelException, RateCategory.RateException
MathsParse
for the format of this
equation) followed by a tab followed by a file path to a RateCategoy file.
f
- The input fileInputException
- If there is an exception reading a fileModel.ModelException
- If there is a problem initialising the modelRateCategory.RateException
- If there is a problem with one of
the Rate Categories in the model