Search in sources :

Example 1 with GaussianProcessMultilocusSkytrackLikelihood

use of dr.evomodel.coalescent.GaussianProcessMultilocusSkytrackLikelihood in project beast-mcmc by beast-dev.

the class GaussianProcessSkytrackLikelihoodParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    XMLObject cxo = xo.getChild(POPULATION_PARAMETER);
    Parameter popParameter = (Parameter) cxo.getChild(Parameter.class);
    cxo = xo.getChild(PRECISION_PARAMETER);
    Parameter precParameter = (Parameter) cxo.getChild(Parameter.class);
    //        cxo = xo.getChild(LAMBDA_BOUND_PARAMETER);
    //        Parameter lambda_bound = (Parameter) cxo.getChild(Parameter.class);
    //
    //        cxo = xo.getChild(LAMBDA_PARAMETER);
    //        Parameter lambda_parameter = (Parameter) cxo.getChild(Parameter.class);
    cxo = xo.getChild(POPULATION_TREE);
    List<Tree> treeList = new ArrayList<Tree>();
    for (int i = 0; i < cxo.getChildCount(); i++) {
        Object testObject = cxo.getChild(i);
        if (testObject instanceof Tree) {
            treeList.add((TreeModel) testObject);
        }
    }
    //        TreeModel treeModel = (TreeModel) cxo.getChild(TreeModel.class);
    //        cxo = xo.getChild(GROUP_SIZES);
    //        Parameter groupParameter = null;
    //        if (cxo != null) {
    //            groupParameter = (Parameter) cxo.getChild(Parameter.class);
    //
    //            if (popParameter.getDimension() != groupParameter.getDimension())
    //                throw new XMLParseException("Population and group size parameters must have the same length");
    //        }
    Parameter lambda_parameter;
    if (xo.getChild(LAMBDA_PARAMETER) != null) {
        cxo = xo.getChild(LAMBDA_PARAMETER);
        lambda_parameter = (Parameter) cxo.getChild(Parameter.class);
    } else {
        lambda_parameter = new Parameter.Default(1.0);
    }
    Parameter GPtype;
    if (xo.getChild(GPTYPE) != null) {
        cxo = xo.getChild(GPTYPE);
        GPtype = (Parameter) cxo.getChild(Parameter.class);
    } else {
        GPtype = new Parameter.Default(1.0);
    }
    Parameter Tmrca;
    if (xo.getChild(TMRCA) != null) {
        cxo = xo.getChild(TMRCA);
        Tmrca = (Parameter) cxo.getChild(Parameter.class);
    } else {
        Tmrca = new Parameter.Default(1.0);
    }
    Parameter numPoints;
    if (xo.getChild(NUMBER_POINTS) != null) {
        cxo = xo.getChild(NUMBER_POINTS);
        numPoints = (Parameter) cxo.getChild(Parameter.class);
    } else {
        numPoints = new Parameter.Default(1.0);
    }
    Parameter CoalCounts;
    if (xo.getChild(COALCOUNT) != null) {
        cxo = xo.getChild(COALCOUNT);
        CoalCounts = (Parameter) cxo.getChild(Parameter.class);
    } else {
        CoalCounts = new Parameter.Default(1.0);
    }
    Parameter GPcounts;
    if (xo.getChild(GPCOUNTS) != null) {
        cxo = xo.getChild(GPCOUNTS);
        GPcounts = (Parameter) cxo.getChild(Parameter.class);
    } else {
        GPcounts = new Parameter.Default(1.0);
    }
    Parameter coalfactor;
    if (xo.getChild(COALFACTOR) != null) {
        cxo = xo.getChild(COALFACTOR);
        coalfactor = (Parameter) cxo.getChild(Parameter.class);
    } else {
        coalfactor = new Parameter.Default(1.0);
    }
    Parameter lambda_bound;
    if (xo.getChild(LAMBDA_BOUND_PARAMETER) != null) {
        cxo = xo.getChild(LAMBDA_BOUND_PARAMETER);
        lambda_bound = (Parameter) cxo.getChild(Parameter.class);
    } else {
        lambda_bound = new Parameter.Default(1.0);
    }
    Parameter alpha_parameter;
    if (xo.getChild(ALPHA_PARAMETER) != null) {
        cxo = xo.getChild(ALPHA_PARAMETER);
        alpha_parameter = (Parameter) cxo.getChild(Parameter.class);
    } else {
        alpha_parameter = new Parameter.Default(0.001);
    }
    Parameter beta_parameter;
    if (xo.getChild(BETA_PARAMETER) != null) {
        cxo = xo.getChild(BETA_PARAMETER);
        beta_parameter = (Parameter) cxo.getChild(Parameter.class);
    } else {
        beta_parameter = new Parameter.Default(0.001);
    }
    Parameter change_points;
    if (xo.getChild(CHANGE_POINTS) != null) {
        cxo = xo.getChild(CHANGE_POINTS);
        change_points = (Parameter) cxo.getChild(Parameter.class);
    } else {
        change_points = new Parameter.Default(0, 1);
    }
    if (xo.getAttribute(RANDOMIZE_TREE, false)) {
        for (Tree tree : treeList) {
            if (tree instanceof TreeModel) {
                GaussianProcessSkytrackLikelihood.checkTree((TreeModel) tree);
            } else {
                throw new XMLParseException("Can not randomize a fixed tree");
            }
        }
    }
    //        XMLObject latentChild = xo.getChild(LATENT_PARAMETER);
    //        Parameter latentPoints = (Parameter) latentChild.getChild(Parameter.class);
    boolean rescaleByRootHeight = xo.getAttribute(RESCALE_BY_ROOT_ISSUE, true);
    if (treeList.size() == 1) {
        return new GaussianProcessSkytrackLikelihood(treeList, precParameter, rescaleByRootHeight, lambda_bound, lambda_parameter, popParameter, alpha_parameter, beta_parameter, change_points, GPtype, GPcounts, coalfactor, CoalCounts, numPoints, Tmrca);
    } else {
        return new GaussianProcessMultilocusSkytrackLikelihood(treeList, precParameter, rescaleByRootHeight, lambda_bound, lambda_parameter, popParameter, alpha_parameter, beta_parameter, change_points, GPtype, GPcounts, coalfactor, CoalCounts, numPoints, Tmrca);
    }
}
Also used : ArrayList(java.util.ArrayList) GaussianProcessMultilocusSkytrackLikelihood(dr.evomodel.coalescent.GaussianProcessMultilocusSkytrackLikelihood) TreeModel(dr.evomodel.tree.TreeModel) GaussianProcessSkytrackLikelihood(dr.evomodel.coalescent.GaussianProcessSkytrackLikelihood) Parameter(dr.inference.model.Parameter) Tree(dr.evolution.tree.Tree)

Aggregations

Tree (dr.evolution.tree.Tree)1 GaussianProcessMultilocusSkytrackLikelihood (dr.evomodel.coalescent.GaussianProcessMultilocusSkytrackLikelihood)1 GaussianProcessSkytrackLikelihood (dr.evomodel.coalescent.GaussianProcessSkytrackLikelihood)1 TreeModel (dr.evomodel.tree.TreeModel)1 Parameter (dr.inference.model.Parameter)1 ArrayList (java.util.ArrayList)1