/** * Creates an object to simulate data for a given set of models, a tree, parameters and unobserved * states. A different model can be given for each rate class. * * @param m Map from site class to model * @param t The tree * @param p The parameters * @param unobserved The unobserved states * @throws Models.RateCategory.RateException Thrown if there is an issue with a rate category in * the model (e.g. a badly formatted rate). * @throws Models.Model.ModelException Thrown if there is a problem with the model (e.g. the rate * categories differ in their states) * @throws TreeException Thrown if there is a problem with the tree. * @throws Parameters.Parameters.ParameterException Thrown if there is a problem with the * parameters (e.g. a required parameter is not present) */ public Simulate(Map<String, Model> m, Tree t, Parameters p, Alignment unobserved) throws RateException, ModelException, TreeException, ParameterException { P = new HashMap<>(); for (Entry<String, Model> e : m.entrySet()) { P.put(e.getKey(), new Probabilities(e.getValue(), t, p)); } this.missing = unobserved; this.t = new HashMap<>(); for (String s : m.keySet()) { this.t.put(s, t); } random = new Random(); // If the parameters setting doesn't include branch lengths parameters then // add them from the tree. The paramter / branch length interaction is a // bit counter-inutative and probably needs changing but in the mean time // this is here to make errors less likely. for (Branch b : t) { if (!p.hasParam(b.getChild())) { p.addParameter(Parameter.newFixedParameter(b.getChild(), b.getLength())); } } }