R
- The return type from the calculationpublic abstract class Calculator<R extends Likelihood> extends java.lang.Object implements Optimizable<R>
Modifier and Type | Class and Description |
---|---|
static class |
Calculator.CalculatorException
Exception thrown when there is a problem with the calculation
|
class |
Calculator.SiteCalculator
Calculates the likelihood of a single site.
|
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<java.lang.String,Model> |
m
The model to do the calculation on.
|
protected java.util.HashMap<Site,java.util.Map<java.lang.String,SiteLikelihood.NodeLikelihood>> |
snl
The site node likelihoods.
|
protected java.util.Map<java.lang.String,Tree> |
t
The tree to do the calculation on.
|
Modifier | Constructor and Description |
---|---|
protected |
Calculator(java.util.Map<java.lang.String,Model> m,
java.util.Map<java.lang.String,Tree> t,
java.util.HashMap<Site,java.util.Map<java.lang.String,SiteLikelihood.NodeLikelihood>> snl)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
R |
calculate(Parameters p)
Abstract method for actually calculating the likelihood
|
abstract SiteLikelihood |
calculateSite(Site s,
Tree t,
Parameters p,
Probabilities tp,
java.util.Map<java.lang.String,SiteLikelihood.NodeLikelihood> nl)
Calculate the likelihood for a single site.
|
abstract R |
combineSites(java.util.Map<Site,SiteLikelihood> sites,
Parameters p)
Combines the likelihood from each site into a alignment likelihood
|
abstract int |
getAlignmentLength()
Get the length of the alignment the calculator is using
|
static void |
setNoThreads(int number)
Set the number of threads to be used during the calculations
|
void |
setThread(boolean thread)
Set whether threaded calculations should be performed
|
protected java.util.Map<Site,SiteLikelihood> |
siteCalculate(Parameters p)
Calculates the likelihood for each site
|
protected java.util.HashMap<Site,java.util.Map<java.lang.String,SiteLikelihood.NodeLikelihood>> snl
protected java.util.Map<java.lang.String,Tree> t
protected java.util.Map<java.lang.String,Model> m
protected Calculator(java.util.Map<java.lang.String,Model> m, java.util.Map<java.lang.String,Tree> t, java.util.HashMap<Site,java.util.Map<java.lang.String,SiteLikelihood.NodeLikelihood>> snl)
m
- The modelt
- The treesnl
- The site node likelihoods. That is the initial likelihood values
for each state at each node for each site. Will usually be 1.0 if that state at that
node of that site is possible, else 0.0.public R calculate(Parameters p) throws TreeException, RateCategory.RateException, Model.ModelException, Parameters.ParameterException, Calculator.CalculatorException
calculate
in interface Optimizable<R extends Likelihood>
p
- The parameters to be used in the calculationTreeException
- Thrown if there is a problem with the Tree (e.g. if
there is a branch with no length given in parameters)RateCategory.RateException
- Thrown if there is an issue with
a rate category in the model (e.g. a badly formatted rate).Model.ModelException
- Thrown if there is a problem with the
model (e.g. the rate categories differ in their states)Parameters.ParameterException
- Thrown if there is a problem
with the parameters (e.g. a required parameter is not present)Calculator.CalculatorException
- If an unexpected (i.e. positive
or NaN) log likelihood is calculatedpublic abstract R combineSites(java.util.Map<Site,SiteLikelihood> sites, Parameters p) throws Calculator.CalculatorException, TreeException, Parameters.ParameterException, RateCategory.RateException, Model.ModelException
sites
- A map from sites to the likelihood of those sites.p
- The parameters to use in the calculationTreeException
- Thrown if there is a problem with the Tree (e.g. if
there is a branch with no length given in parameters)RateCategory.RateException
- Thrown if there is an issue with
a rate category in the model (e.g. a badly formatted rate).Model.ModelException
- Thrown if there is a problem with the
model (e.g. the rate categories differ in their states)Parameters.ParameterException
- Thrown if there is a problem
with the parameters (e.g. a required parameter is not present)Calculator.CalculatorException
- If an unexpected (i.e. positive
or NaN) log likelihood is calculatedpublic abstract SiteLikelihood calculateSite(Site s, Tree t, Parameters p, Probabilities tp, java.util.Map<java.lang.String,SiteLikelihood.NodeLikelihood> nl) throws Parameters.ParameterException
s
- The site to calculate the likelihood fort
- The tree to use in calculating the likelihoodp
- The parameters to use in calculating the likelihoodtp
- Pre-calculated transition probabilities to be used in the
calculation (passed in as they don't need to be calculated separately for
each site). See Probabilities
for more informationnl
- The starting node-likelihoods are passed here as it is much
quicker to clone them for each calculation than re-create themSiteLikelihood
given the likelihood and
any other informationParameters.ParameterException
- Thrown if there is a
problem with a passed parameterprotected java.util.Map<Site,SiteLikelihood> siteCalculate(Parameters p) throws TreeException, RateCategory.RateException, Model.ModelException, Parameters.ParameterException, Calculator.CalculatorException
p
- The parameters to be used in the calculationTreeException
- Thrown if there is a problem with the Tree (e.g. if
there is a branch with no length given in parameters)RateCategory.RateException
- Thrown if there is an issue with
a rate category in the model (e.g. a badly formatted rate).Model.ModelException
- Thrown if there is a problem with the
model (e.g. the rate categories differ in their states)Parameters.ParameterException
- Thrown if there is a problem
with the parameters (e.g. a required parameter is not present)Calculator.CalculatorException
- If an unexpected (i.e. positive
or NaN) log likelihood is calculatedpublic void setThread(boolean thread)
thread
- Whether to perform threaded calculationspublic abstract int getAlignmentLength()
public static void setNoThreads(int number)
number
- Number of threads