Simulations
Class Simulate

java.lang.Object
  extended by Simulations.Simulate

public class Simulate
extends java.lang.Object

Class for constructing simulated data

Version:
1.2

Nested Class Summary
 class Simulate.SimulationException
          Exception for when there is a problem with the simulation
 
Constructor Summary
Simulate(java.util.Map<java.lang.String,Model> m, Tree t, Parameters p)
          Creates an object to simulate data for a given set of models, a tree and parameters.
Simulate(java.util.Map<java.lang.String,Model> m, Tree t, Parameters p, Alignment unobserved)
          Creates an object to simulate data for a given set of models, a tree, parameters and unobserved sattes.
Simulate(java.util.Map<java.lang.String,Model> m, Tree t, Parameters p, Alignment unobserved, java.util.Map<java.lang.String,Constrainer> con)
          Creates an object to simulate data for a given set of models, a tree, parameters, unobserved states and constrainers.
Simulate(Model m, Tree t, Parameters p)
          Creates an object to simulate data for a given model, tree and parameters.
Simulate(Model m, Tree t, Parameters p, Alignment unobserved)
          Creates an object to simulate data for a given model, tree, parameters and unobserved states.
Simulate(Model m, Tree t, Parameters p, Alignment unobserved, Constrainer con)
          Creates an object to simulate data for a given model, tree, parameters, unobserved states and constraints.
 
Method Summary
 Alignment getAlignment(int length)
          Gets a simulated alignment, not returing the state of internal nodes
 Alignment getAlignment(int length, boolean internal)
          Gets a simulated alignment
 Alignment getAlignment(int length, boolean internal, java.util.Map<java.lang.String,java.lang.String> recode)
          Gets a simulated alignment.
 Alignment getAlignment(int length, java.util.Map<java.lang.String,java.lang.String> recode)
          Gets a simulated alignment, not returing the state of internal nodes.
 Alignment getAlignment(java.util.List<java.lang.String> siteClasses)
          Gets a simulated alignment, not returning the state of the internal nodes.
 Alignment getAlignment(java.util.List<java.lang.String> siteClasses, boolean internal)
          Gets a simulated alignment.
 Alignment getAlignment(java.util.List<java.lang.String> siteClasses, boolean internal, java.util.Map<java.lang.String,java.lang.String> recode)
          Gets a simulated alignment.
 Alignment getAlignment(java.util.List<java.lang.String> siteClasses, java.util.Map<java.lang.String,java.lang.String> recode)
          Gets a simulated alignment, not returning the state of the internal nodes.
 Site getSite()
          Gets a simulated site without returning the state of the internal nodes
 Site getSite(boolean internal)
          Gets a simulated site
 Site getSite(boolean internal, java.util.Map<java.lang.String,java.lang.String> recode)
          Gets a simulated site.
 Site getSite(boolean internal, java.util.Map<java.lang.String,java.lang.String> recode, java.lang.String siteClass)
          Gets a simulated site.
 Site getSite(boolean internal, java.lang.String siteClass)
          Gets a simulated site
 Site getSite(java.util.Map<java.lang.String,java.lang.String> recode)
          Gets a simulated site without returning the state of the internal nodes.
 Site getSite(java.util.Map<java.lang.String,java.lang.String> recode, java.lang.String siteClass)
          Gets a simulated site without returning the state of the internal nodes.
 Site getSite(java.lang.String siteClass)
          Gets a simulated site without returning the state of the internal nodes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Simulate

public Simulate(Model m,
                Tree t,
                Parameters p)
         throws RateCategory.RateException,
                Model.ModelException,
                TreeException,
                Parameters.ParameterException
Creates an object to simulate data for a given model, tree and parameters. Has no unobserved states or constraints.

Parameters:
m - The model
t - The tree
p - The parameters
Throws:
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)
TreeException - Thrown if there is a problem with the tree.
Parameters.ParameterException - Thrown if there is a problem with the parameters (e.g. a requied parameter is not present)

Simulate

public Simulate(Model m,
                Tree t,
                Parameters p,
                Alignment unobserved)
         throws RateCategory.RateException,
                Model.ModelException,
                TreeException,
                Parameters.ParameterException
Creates an object to simulate data for a given model, tree, parameters and unobserved states. Has no constraints.

Parameters:
m - The model
t - The tree
p - The parameters
unobserved - The unobserved states
Throws:
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)
TreeException - Thrown if there is a problem with the tree.
Parameters.ParameterException - Thrown if there is a problem with the parameters (e.g. a requied parameter is not present)

Simulate

public Simulate(Model m,
                Tree t,
                Parameters p,
                Alignment unobserved,
                Constrainer con)
         throws RateCategory.RateException,
                Model.ModelException,
                TreeException,
                Parameters.ParameterException
Creates an object to simulate data for a given model, tree, parameters, unobserved states and constraints. If a site is generated that does not meet the constraints then it is discarded and a new site generated.

Parameters:
m - The model
t - The tree
p - The parameters
unobserved - The unobserved states
con - The constraints
Throws:
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)
TreeException - Thrown if there is a problem with the tree.
Parameters.ParameterException - Thrown if there is a problem with the parameters (e.g. a requied parameter is not present)

Simulate

public Simulate(java.util.Map<java.lang.String,Model> m,
                Tree t,
                Parameters p)
         throws RateCategory.RateException,
                Model.ModelException,
                TreeException,
                Parameters.ParameterException
Creates an object to simulate data for a given set of models, a tree and parameters. Has no unobserved states or constraints. A different model can be given for each rate class.

Parameters:
m - Map from site class to model
t - The tree
p - The parameters
Throws:
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)
TreeException - Thrown if there is a problem with the tree.
Parameters.ParameterException - Thrown if there is a problem with the parameters (e.g. a requied parameter is not present)

Simulate

public Simulate(java.util.Map<java.lang.String,Model> m,
                Tree t,
                Parameters p,
                Alignment unobserved)
         throws RateCategory.RateException,
                Model.ModelException,
                TreeException,
                Parameters.ParameterException
Creates an object to simulate data for a given set of models, a tree, parameters and unobserved sattes. Has no constraints. A different model can be given for each rate class.

Parameters:
m - Map from site class to model
t - The tree
p - The parameters
unobserved - The unobserved states
Throws:
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)
TreeException - Thrown if there is a problem with the tree.
Parameters.ParameterException - Thrown if there is a problem with the parameters (e.g. a requied parameter is not present)

Simulate

public Simulate(java.util.Map<java.lang.String,Model> m,
                Tree t,
                Parameters p,
                Alignment unobserved,
                java.util.Map<java.lang.String,Constrainer> con)
         throws RateCategory.RateException,
                Model.ModelException,
                TreeException,
                Parameters.ParameterException
Creates an object to simulate data for a given set of models, a tree, parameters, unobserved states and constrainers. A different model and constrainer can be given for each rate class.

Parameters:
m - Map from site class to model
t - The tree
p - The parameters
con - Map from rate site class to constrainer
unobserved - The unobserved states
Throws:
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)
TreeException - Thrown if there is a problem with the tree.
Parameters.ParameterException - Thrown if there is a problem with the parameters (e.g. a requied parameter is not present)
Method Detail

getSite

public Site getSite()
             throws TreeException,
                    Simulate.SimulationException
Gets a simulated site without returning the state of the internal nodes

Returns:
The simulated site
Throws:
TreeException - Thrown if the constrainer has a problem with the tree
Simulate.SimulationException - Thrown if there is a problem with the simulation (currently only if attempting to simulate for a site class we don't have a model and / or constraints for)

getSite

public Site getSite(java.lang.String siteClass)
             throws TreeException,
                    Simulate.SimulationException
Gets a simulated site without returning the state of the internal nodes

Parameters:
siteClass - The site class to simulate for
Returns:
The simulated site
Throws:
TreeException - Thrown if the constrainer has a problem with the tree
Simulate.SimulationException - Thrown if there is a problem with the simulation (currently only if attempting to simulate for a site class we don't have a model and / or constraints for)

getSite

public Site getSite(java.util.Map<java.lang.String,java.lang.String> recode)
             throws TreeException,
                    Simulate.SimulationException
Gets a simulated site without returning the state of the internal nodes. Recodes the simulated data before returning. For example if both "A" and "B" are unobserved states representing an observed state of "0" then this can be used to change "A" and "B" to zero. This is neccessay as the simulator generates unobserved states by default. The returned site will have ambiguous data set as appropiate.

Parameters:
recode - Map of recodings
Returns:
The simulated site
Throws:
TreeException - Thrown if the constrainer has a problem with the tree
Simulate.SimulationException - Thrown if there is a problem with the simulation (currently only if attempting to simulate for a site class we don't have a model and / or constraints for)

getSite

public Site getSite(java.util.Map<java.lang.String,java.lang.String> recode,
                    java.lang.String siteClass)
             throws TreeException,
                    Simulate.SimulationException
Gets a simulated site without returning the state of the internal nodes. Recodes the simulated data before returning. For example if both "A" and "B" are unobserved states representing an observed state of "0" then this can be used to change "A" and "B" to zero. This is neccessay as the simulator generates unobserved states by default. The returned site will have ambiguous data set as appropiate.

Parameters:
recode - Map of recodings
siteClass - The site class to simulate for
Returns:
The simulated site
Throws:
TreeException - Thrown if the constrainer has a problem with the tree
Simulate.SimulationException - Thrown if there is a problem with the simulation (currently only if attempting to simulate for a site class we don't have a model and / or constraints for)

getSite

public Site getSite(boolean internal)
             throws TreeException,
                    Simulate.SimulationException
Gets a simulated site

Parameters:
internal - Whether to return the state of the internal nodes
Returns:
The simulated site
Throws:
TreeException - Thrown if the constrainer has a problem with the tree
Simulate.SimulationException - Thrown if there is a problem with the simulation (currently only if attempting to simulate for a site class we don't have a model and / or constraints for)

getSite

public Site getSite(boolean internal,
                    java.lang.String siteClass)
             throws TreeException,
                    Simulate.SimulationException
Gets a simulated site

Parameters:
internal - Whether to return the state of the internal nodes
siteClass - The site class to simulate for
Returns:
The simulated site
Throws:
TreeException - Thrown if the constrainer has a problem with the tree
Simulate.SimulationException - Thrown if there is a problem with the simulation (currently only if attempting to simulate for a site class we don't have a model and / or constraints for)

getSite

public Site getSite(boolean internal,
                    java.util.Map<java.lang.String,java.lang.String> recode)
             throws TreeException,
                    Simulate.SimulationException
Gets a simulated site. Recodes the simulated data before returning. For example if both "A" and "B" are unobserved states representing an observed state of "0" then this can be used to change "A" and "B" to zero. This is neccessay as the simulator generates unobserved states by default. The returned site will have ambiguous data set as appropiate.

Parameters:
recode - Map of recodings
internal - Whether to return the state of the internal nodes
Returns:
The simulated site
Throws:
TreeException - Thrown if the constrainer has a problem with the tree
Simulate.SimulationException - Thrown if there is a problem with the simulation (currently only if attempting to simulate for a site class we don't have a model and / or constraints for)

getSite

public Site getSite(boolean internal,
                    java.util.Map<java.lang.String,java.lang.String> recode,
                    java.lang.String siteClass)
             throws TreeException,
                    Simulate.SimulationException
Gets a simulated site. Recodes the simulated data before returning. For example if both "A" and "B" are unobserved states representing an observed state of "0" then this can be used to change "A" and "B" to zero. This is neccessay as the simulator generates unobserved states by default. The returned site will have ambiguous data set as appropiate.

Parameters:
recode - Map of recodings
internal - Whether to return the state of the internal nodes
siteClass - The site class to simulate for
Returns:
The simulated site
Throws:
TreeException - Thrown if the constrainer has a problem with the tree
Simulate.SimulationException - Thrown if there is a problem with the simulation (currently only if attempting to simulate for a site class we don't have a model and / or constraints for)

getAlignment

public Alignment getAlignment(int length)
                       throws AlignmentException,
                              TreeException,
                              Simulate.SimulationException
Gets a simulated alignment, not returing the state of internal nodes

Parameters:
length - The length of the alignment
Returns:
The simulated alignment
Throws:
AlignmentException - Thrown if there is a problem with the alignment
TreeException - Thrown if the constrainer has a problem with the tree
Simulate.SimulationException - Thrown if there is a problem with the simulation (currently only if attempting to simulate for a site class we don't have a model and / or constraints for)

getAlignment

public Alignment getAlignment(int length,
                              boolean internal)
                       throws AlignmentException,
                              TreeException,
                              Simulate.SimulationException
Gets a simulated alignment

Parameters:
length - The length of the alignment
internal - Whether to return the state of the internal nodes
Returns:
The simulated alignment
Throws:
AlignmentException - Thrown if there is a problem with the alignment
TreeException - Thrown if the constrainer has a problem with the tree
Simulate.SimulationException - Thrown if there is a problem with the simulation (currently only if attempting to simulate for a site class we don't have a model and / or constraints for)

getAlignment

public Alignment getAlignment(int length,
                              java.util.Map<java.lang.String,java.lang.String> recode)
                       throws AlignmentException,
                              TreeException,
                              Simulate.SimulationException
Gets a simulated alignment, not returing the state of internal nodes. Recodes the simulated data before returning. For example if both "A" and "B" are unobserved states representing an observed state of "0" then this can be used to change "A" and "B" to zero. This is neccessay as the simulator generates unobserved states by default. The returned site will have ambiguous data set as appropiate.

Parameters:
length - The length of the alignment
recode - Map of recodings
Returns:
The simulated alignment
Throws:
AlignmentException - Thrown if there is a problem with the alignment
TreeException - Thrown if the constrainer has a problem with the tree
Simulate.SimulationException - Thrown if there is a problem with the simulation (currently only if attempting to simulate for a site class we don't have a model and / or constraints for)

getAlignment

public Alignment getAlignment(int length,
                              boolean internal,
                              java.util.Map<java.lang.String,java.lang.String> recode)
                       throws AlignmentException,
                              TreeException,
                              Simulate.SimulationException
Gets a simulated alignment. Recodes the simulated data before returning. For example if both "A" and "B" are unobserved states representing an observed state of "0" then this can be used to change "A" and "B" to zero. This is neccessay as the simulator generates unobserved states by default. The returned site will have ambiguous data set as appropiate.

Parameters:
length - The length of the alignment
internal - Whether to return the state of the internal nodes
recode - Map of recodings
Returns:
The simulated alignment
Throws:
AlignmentException - Thrown if there is a problem with the alignment
TreeException - Thrown if the constrainer has a problem with the tree
Simulate.SimulationException - Thrown if there is a problem with the simulation (currently only if attempting to simulate for a site class we don't have a model and / or constraints for)

getAlignment

public Alignment getAlignment(java.util.List<java.lang.String> siteClasses)
                       throws AlignmentException,
                              TreeException,
                              Simulate.SimulationException
Gets a simulated alignment, not returning the state of the internal nodes. The simulated alignment will be the same length as siteClasses and each site will have been simulated according to the corresponding class in siteClasses.

Parameters:
siteClasses - List of site classes used to generate the alignment
Returns:
The simulated alignment
Throws:
AlignmentException - Thrown if there is a problem with the alignment
TreeException - Thrown if the constrainer has a problem with the tree
Simulate.SimulationException - Thrown if there is a problem with the simulation (currently only if attempting to simulate for a site class we don't have a model and / or constraints for)

getAlignment

public Alignment getAlignment(java.util.List<java.lang.String> siteClasses,
                              boolean internal)
                       throws AlignmentException,
                              TreeException,
                              Simulate.SimulationException
Gets a simulated alignment. The simulated alignment will be the same length as siteClasses and each site will have been simulated according to the corresponding class in siteClasses.

Parameters:
siteClasses - List of site classes used to generate the alignment
internal - Whether to return the state of the internal nodes
Returns:
The simulated alignment
Throws:
AlignmentException - Thrown if there is a problem with the alignment
TreeException - Thrown if the constrainer has a problem with the tree
Simulate.SimulationException - Thrown if there is a problem with the simulation (currently only if attempting to simulate for a site class we don't have a model and / or constraints for)

getAlignment

public Alignment getAlignment(java.util.List<java.lang.String> siteClasses,
                              java.util.Map<java.lang.String,java.lang.String> recode)
                       throws AlignmentException,
                              TreeException,
                              Simulate.SimulationException
Gets a simulated alignment, not returning the state of the internal nodes. The simulated alignment will be the same length as siteClasses and each site will have been simulated according to the corresponding class in siteClasses. Recodes the simulated data before returning. For example if both "A" and "B" are unobserved states representing an observed state of "0" then this can be used to change "A" and "B" to zero. This is neccessay as the simulator generates unobserved states by default. The returned site will have ambiguous data set as appropiate.

Parameters:
siteClasses - List of site classes used to generate the alignment
recode - Map of recodings
Returns:
The simulated alignment
Throws:
AlignmentException - Thrown if there is a problem with the alignment
TreeException - Thrown if the constrainer has a problem with the tree
Simulate.SimulationException - Thrown if there is a problem with the simulation (currently only if attempting to simulate for a site class we don't have a model and / or constraints for)

getAlignment

public Alignment getAlignment(java.util.List<java.lang.String> siteClasses,
                              boolean internal,
                              java.util.Map<java.lang.String,java.lang.String> recode)
                       throws AlignmentException,
                              TreeException,
                              Simulate.SimulationException
Gets a simulated alignment. The simulated alignment will be the same length as siteClasses and each site will have been simulated according to the corresponding class in siteClasses. Recodes the simulated data before returning. For example if both "A" and "B" are unobserved states representing an observed state of "0" then this can be used to change "A" and "B" to zero. This is neccessay as the simulator generates unobserved states by default. The returned site will have ambiguous data set as appropiate.

Parameters:
siteClasses - List of site classes used to generate the alignment
internal - Whether to return the state of the internal nodes
recode - Map of recodings
Returns:
The simulated alignment
Throws:
AlignmentException - Thrown if there is a problem with the alignment
TreeException - Thrown if the constrainer has a problem with the tree
Simulate.SimulationException - Thrown if there is a problem with the simulation (currently only if attempting to simulate for a site class we don't have a model and / or constraints for)