Likelihood
Class Calculator

java.lang.Object
  extended by Likelihood.Calculator

public class Calculator
extends java.lang.Object

Calculates the likelihood for different parameter values. Succesive calls to an instance of this class are used to maximise the parameters values for one case. Uses the pruning technique of Felenstein 1981 and can account for unobserved states using Felsenstein 1992.

Version:
1.2

Nested Class Summary
static class Calculator.SiteCalculator
          Calculates the likelihood of a single site.
 
Constructor Summary
Calculator(java.util.Map<java.lang.String,Model> m, Alignment a, Tree t)
          Creates a class to calculate the likelihood for a given set of models, an alignment, and a tree.
Calculator(java.util.Map<java.lang.String,Model> m, Alignment a, Tree t, Alignment unobserved)
          Creates a class to calculate the likelihood for a given set of models, an alignment, a tree, and unobserved data.
Calculator(java.util.Map<java.lang.String,Model> m, Alignment a, Tree t, Alignment unobserved, java.util.Map<java.lang.String,Constrainer> con)
          Creates a class to calculate the likelihood for a given set of models, an alignment, a tree, unobserved data and a set of constraints.
Calculator(java.util.Map<java.lang.String,Model> m, Alignment a, Tree t, java.util.Map<java.lang.String,Constrainer> con)
          Creates a class to calculate the likelihood for a given set of models, an alignment, a tree and a set of constraints.
Calculator(Model m, Alignment a, Tree t)
          Creates an object to calculate the likelihood for a given model, alignment, tree.
Calculator(Model m, Alignment a, Tree t, Alignment unobserved)
          Creates a class to calculate the likelihood for a given model, alignment, tree, missing data and constraints
Calculator(Model m, Alignment a, Tree t, Alignment unobserved, Constrainer con)
          Creates a class to calculate the likelihood for a given model, alignment, tree, unobserved data and constraints
Calculator(Model m, Alignment a, Tree t, Constrainer con)
          Creates a class to calculate the likelihood for a given model, alignment, tree and constraints
 
Method Summary
 Likelihood calculate(Parameters p)
          Calculates the likelihood for a given set of parameters
static void setNoThreads(int number)
          Set the number of threads to be used during the calculations
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Calculator

public Calculator(Model m,
                  Alignment a,
                  Tree t)
           throws TreeException
Creates an object to calculate the likelihood for a given model, alignment, tree. Has no unobserved data or constraints

Parameters:
m - The model
a - The alignment
t - The tree
Throws:
TreeException - If there is a problem with the tree

Calculator

public Calculator(Model m,
                  Alignment a,
                  Tree t,
                  Alignment unobserved)
           throws TreeException
Creates a class to calculate the likelihood for a given model, alignment, tree, missing data and constraints

Parameters:
m - The model
a - The alignment
t - The tree
unobserved - Unobserved data given as another alignment
Throws:
TreeException - If there is a problem with the tree

Calculator

public Calculator(Model m,
                  Alignment a,
                  Tree t,
                  Constrainer con)
           throws TreeException
Creates a class to calculate the likelihood for a given model, alignment, tree and constraints

Parameters:
m - The model
a - The alignment
t - The tree
con - Any constraints
Throws:
TreeException - If there is a problem with the tree

Calculator

public Calculator(Model m,
                  Alignment a,
                  Tree t,
                  Alignment unobserved,
                  Constrainer con)
           throws TreeException
Creates a class to calculate the likelihood for a given model, alignment, tree, unobserved data and constraints

Parameters:
m - The model
a - The alignment
t - The tree
unobserved - Unobserved data given as another alignment
con - Any constraints
Throws:
TreeException - If there is a problem with the tree

Calculator

public Calculator(java.util.Map<java.lang.String,Model> m,
                  Alignment a,
                  Tree t)
           throws AlignmentException,
                  TreeException
Creates a class to calculate the likelihood for a given set of models, an alignment, and a tree. There should be one model per site class in the alignment

Parameters:
m - Map from site class to model
a - The alignment
t - The tree
Throws:
AlignmentException - Thrown if a model isn't given for each site class in the alignment
TreeException - If there is a problem with the tree

Calculator

public Calculator(java.util.Map<java.lang.String,Model> m,
                  Alignment a,
                  Tree t,
                  Alignment unobserved)
           throws AlignmentException,
                  TreeException
Creates a class to calculate the likelihood for a given set of models, an alignment, a tree, and unobserved data. There should be one model per site class in the alignment

Parameters:
m - Map from site class to model
a - The alignment
t - The tree
unobserved - Unobserved data given as another alignment
Throws:
AlignmentException - Thrown if a model isn't given for each site class in the alignment
TreeException - If there is a problem with the tree

Calculator

public Calculator(java.util.Map<java.lang.String,Model> m,
                  Alignment a,
                  Tree t,
                  java.util.Map<java.lang.String,Constrainer> con)
           throws AlignmentException,
                  TreeException
Creates a class to calculate the likelihood for a given set of models, an alignment, a tree and a set of constraints. There should be one model and one constrainer per site class in the alignment

Parameters:
m - Map from site class to model
a - The alignment
t - The tree
con - Map from site class to constrainer
Throws:
AlignmentException - Thrown if a model and constrainer isn't given for each site class in the alignment
TreeException - If there is a problem with the tree

Calculator

public Calculator(java.util.Map<java.lang.String,Model> m,
                  Alignment a,
                  Tree t,
                  Alignment unobserved,
                  java.util.Map<java.lang.String,Constrainer> con)
           throws AlignmentException,
                  TreeException
Creates a class to calculate the likelihood for a given set of models, an alignment, a tree, unobserved data and a set of constraints. There should be one model and one constrainer per site class in the alignment

Parameters:
m - Map from site class to model
a - The alignment
t - The tree
unobserved - Unobserved data given as another alignment
con - Map from site class to constrainer
Throws:
AlignmentException - Thrown if a model and constrainer isn't given for each site class in the alignment
TreeException - If there is a problem with the tree
Method Detail

calculate

public Likelihood calculate(Parameters p)
                     throws TreeException,
                            RateCategory.RateException,
                            Model.ModelException,
                            Parameters.ParameterException
Calculates the likelihood for a given set of parameters

Parameters:
p - The parameters to be used in the calculation
Returns:
A Likelihood object which contains the likelihood as well as likelihoods for each site.
Throws:
TreeException - 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 requied parameter is not present)

setNoThreads

public static void setNoThreads(int number)
Set the number of threads to be used during the calculations

Parameters:
number - Number of threads