Search in sources :

Example 1 with MutationDeathModel

use of dr.oldevomodel.substmodel.MutationDeathModel in project beast-mcmc by beast-dev.

the class ALSTreeLikelihoodParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    boolean useAmbiguities = false;
    boolean storePartials = true;
    if (xo.hasAttribute(TreeLikelihoodParser.USE_AMBIGUITIES)) {
        useAmbiguities = xo.getBooleanAttribute(TreeLikelihoodParser.USE_AMBIGUITIES);
    }
    if (xo.hasAttribute(TreeLikelihoodParser.STORE_PARTIALS)) {
        storePartials = xo.getBooleanAttribute(TreeLikelihoodParser.STORE_PARTIALS);
    }
    boolean integrateGainRate = xo.getBooleanAttribute(INTEGRATE_GAIN_RATE);
    //AbstractObservationProcess observationProcess = (AbstractObservationProcess) xo.getChild(AbstractObservationProcess.class);
    PatternList patternList = (PatternList) xo.getChild(PatternList.class);
    TreeModel treeModel = (TreeModel) xo.getChild(TreeModel.class);
    SiteModel siteModel = (SiteModel) xo.getChild(SiteModel.class);
    BranchRateModel branchRateModel = (BranchRateModel) xo.getChild(BranchRateModel.class);
    Parameter mu = ((MutationDeathModel) siteModel.getSubstitutionModel()).getDeathParameter();
    Parameter lam;
    if (!integrateGainRate) {
        lam = (Parameter) xo.getElementFirstChild(IMMIGRATION_RATE);
    } else {
        lam = new Parameter.Default("gainRate", 1.0, 0.001, 1.999);
    }
    AbstractObservationProcess observationProcess = null;
    Logger.getLogger("dr.evolution").info("\n ---------------------------------\nCreating ALSTreeLikelihood model.");
    for (int i = 0; i < xo.getChildCount(); ++i) {
        Object cxo = xo.getChild(i);
        if (cxo instanceof XMLObject && ((XMLObject) cxo).getName().equals(OBSERVATION_PROCESS)) {
            if (((XMLObject) cxo).getStringAttribute(OBSERVATION_TYPE).equals("singleTip")) {
                String taxonName = ((XMLObject) cxo).getStringAttribute(OBSERVATION_TAXON);
                Taxon taxon = treeModel.getTaxon(treeModel.getTaxonIndex(taxonName));
                observationProcess = new SingleTipObservationProcess(treeModel, patternList, siteModel, branchRateModel, mu, lam, taxon);
                Logger.getLogger("dr.evolution").info("All traits are assumed extant in " + taxonName);
            } else {
                // "anyTip" observation process
                observationProcess = new AnyTipObservationProcess(ANY_TIP, treeModel, patternList, siteModel, branchRateModel, mu, lam);
                Logger.getLogger("dr.evolution").info("Observed traits are assumed to be extant in at least one tip node.");
            }
            observationProcess.setIntegrateGainRate(integrateGainRate);
        }
    }
    Logger.getLogger("dr.evolution").info("\tIf you publish results using Acquisition-Loss-Mutation (ALS) Model likelihood, please reference Alekseyenko, Lee and Suchard (2008) Syst. Biol 57: 772-784.\n---------------------------------\n");
    boolean forceRescaling = xo.getAttribute(FORCE_RESCALING, false);
    return new ALSTreeLikelihood(observationProcess, patternList, treeModel, siteModel, branchRateModel, useAmbiguities, storePartials, forceRescaling);
}
Also used : Taxon(dr.evolution.util.Taxon) AnyTipObservationProcess(dr.oldevomodel.MSSD.AnyTipObservationProcess) PatternList(dr.evolution.alignment.PatternList) MutationDeathModel(dr.oldevomodel.substmodel.MutationDeathModel) SiteModel(dr.oldevomodel.sitemodel.SiteModel) ALSTreeLikelihood(dr.oldevomodel.MSSD.ALSTreeLikelihood) TreeModel(dr.evomodel.tree.TreeModel) SingleTipObservationProcess(dr.oldevomodel.MSSD.SingleTipObservationProcess) BranchRateModel(dr.evomodel.branchratemodel.BranchRateModel) AbstractObservationProcess(dr.oldevomodel.MSSD.AbstractObservationProcess) Parameter(dr.inference.model.Parameter)

Example 2 with MutationDeathModel

use of dr.oldevomodel.substmodel.MutationDeathModel in project beast-mcmc by beast-dev.

the class ALSTreeLikelihoodParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    boolean useAmbiguities = false;
    boolean storePartials = true;
    if (xo.hasAttribute(TreeLikelihoodParser.USE_AMBIGUITIES)) {
        useAmbiguities = xo.getBooleanAttribute(TreeLikelihoodParser.USE_AMBIGUITIES);
    }
    if (xo.hasAttribute(TreeLikelihoodParser.STORE_PARTIALS)) {
        storePartials = xo.getBooleanAttribute(TreeLikelihoodParser.STORE_PARTIALS);
    }
    boolean integrateGainRate = xo.getBooleanAttribute(INTEGRATE_GAIN_RATE);
    //AbstractObservationProcess observationProcess = (AbstractObservationProcess) xo.getChild(AbstractObservationProcess.class);
    PatternList patternList = (PatternList) xo.getChild(PatternList.class);
    TreeModel treeModel = (TreeModel) xo.getChild(TreeModel.class);
    SiteModel siteModel = (SiteModel) xo.getChild(SiteModel.class);
    BranchRateModel branchRateModel = (BranchRateModel) xo.getChild(BranchRateModel.class);
    Parameter mu = ((MutationDeathModel) siteModel.getSubstitutionModel()).getDeathParameter();
    Parameter lam;
    if (!integrateGainRate) {
        lam = (Parameter) xo.getElementFirstChild(IMMIGRATION_RATE);
    } else {
        lam = new Parameter.Default("gainRate", 1.0, 0.001, 1.999);
    }
    AbstractObservationProcess observationProcess = null;
    Logger.getLogger("dr.evolution").info("\n ---------------------------------\nCreating ALSTreeLikelihood model.");
    for (int i = 0; i < xo.getChildCount(); ++i) {
        Object cxo = xo.getChild(i);
        if (cxo instanceof XMLObject && ((XMLObject) cxo).getName().equals(OBSERVATION_PROCESS)) {
            if (((XMLObject) cxo).getStringAttribute(OBSERVATION_TYPE).equals("singleTip")) {
                String taxonName = ((XMLObject) cxo).getStringAttribute(OBSERVATION_TAXON);
                Taxon taxon = treeModel.getTaxon(treeModel.getTaxonIndex(taxonName));
                observationProcess = new SingleTipObservationProcess(treeModel, patternList, siteModel, branchRateModel, mu, lam, taxon);
                Logger.getLogger("dr.evolution").info("All traits are assumed extant in " + taxonName);
            } else {
                // "anyTip" observation process
                observationProcess = new AnyTipObservationProcess(ANY_TIP, treeModel, patternList, siteModel, branchRateModel, mu, lam);
                Logger.getLogger("dr.evolution").info("Observed traits are assumed to be extant in at least one tip node.");
            }
            observationProcess.setIntegrateGainRate(integrateGainRate);
        }
    }
    Logger.getLogger("dr.evolution").info("\tIf you publish results using Acquisition-Loss-Mutation (ALS) Model likelihood, please reference Alekseyenko, Lee and Suchard (2008) Syst. Biol 57: 772-784.\n---------------------------------\n");
    boolean forceRescaling = xo.getAttribute(FORCE_RESCALING, false);
    return new ALSTreeLikelihood(observationProcess, patternList, treeModel, siteModel, branchRateModel, useAmbiguities, storePartials, forceRescaling);
}
Also used : Taxon(dr.evolution.util.Taxon) AnyTipObservationProcess(dr.oldevomodel.MSSD.AnyTipObservationProcess) PatternList(dr.evolution.alignment.PatternList) MutationDeathModel(dr.oldevomodel.substmodel.MutationDeathModel) SiteModel(dr.oldevomodel.sitemodel.SiteModel) ALSTreeLikelihood(dr.oldevomodel.MSSD.ALSTreeLikelihood) TreeModel(dr.evomodel.tree.TreeModel) SingleTipObservationProcess(dr.oldevomodel.MSSD.SingleTipObservationProcess) BranchRateModel(dr.evomodel.branchratemodel.BranchRateModel) AbstractObservationProcess(dr.oldevomodel.MSSD.AbstractObservationProcess) Parameter(dr.inference.model.Parameter)

Example 3 with MutationDeathModel

use of dr.oldevomodel.substmodel.MutationDeathModel in project beast-mcmc by beast-dev.

the class MutationDeathModelParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    Parameter dummyFreqParameter;
    Parameter delParam = (Parameter) xo.getChild(Parameter.class);
    Logger.getLogger("dr.evomodel").info("Creating MutationDeath substitution model.\n\tInitial death rate is " + delParam.getParameterValue(0));
    MutationDeathType dT = (MutationDeathType) xo.getChild(MutationDeathType.class);
    AbstractSubstitutionModel evoModel = (AbstractSubstitutionModel) xo.getChild(AbstractSubstitutionModel.class);
    if (evoModel == null) {
        // Assuming pure survival model
        Logger.getLogger("dr.evomodel").info("\tSubstitutionModel not provided assuming pure death/survival model.");
        dummyFreqParameter = new Parameter.Default(new double[] { 1.0, 0.0 });
    } else {
        dummyFreqParameter = new Parameter.Default(dT.getStateCount());
        double[] freqs = evoModel.getFrequencyModel().getFrequencies();
        for (int i = 0; i < freqs.length; ++i) {
            dummyFreqParameter.setParameterValueQuietly(i, freqs[i]);
        }
        dummyFreqParameter.setParameterValueQuietly(dT.getStateCount() - 1, 0.0);
    }
    FrequencyModel dummyFrequencies = new FrequencyModel(dT, dummyFreqParameter);
    Parameter mutationRate;
    if (xo.hasChildNamed(MUTATION_RATE)) {
        mutationRate = (Parameter) xo.getElementFirstChild(MUTATION_RATE);
    } else {
        mutationRate = new Parameter.Default(new double[] { 1.0 });
    }
    Logger.getLogger("dr.evomodel").info("\tInitial mutation rate is " + mutationRate.getParameterValue(0));
    return new MutationDeathModel(delParam, dT, evoModel, dummyFrequencies, mutationRate);
}
Also used : FrequencyModel(dr.oldevomodel.substmodel.FrequencyModel) AbstractSubstitutionModel(dr.oldevomodel.substmodel.AbstractSubstitutionModel) Parameter(dr.inference.model.Parameter) MutationDeathModel(dr.oldevomodel.substmodel.MutationDeathModel) MutationDeathType(dr.evolution.datatype.MutationDeathType)

Aggregations

Parameter (dr.inference.model.Parameter)3 MutationDeathModel (dr.oldevomodel.substmodel.MutationDeathModel)3 PatternList (dr.evolution.alignment.PatternList)2 Taxon (dr.evolution.util.Taxon)2 BranchRateModel (dr.evomodel.branchratemodel.BranchRateModel)2 TreeModel (dr.evomodel.tree.TreeModel)2 ALSTreeLikelihood (dr.oldevomodel.MSSD.ALSTreeLikelihood)2 AbstractObservationProcess (dr.oldevomodel.MSSD.AbstractObservationProcess)2 AnyTipObservationProcess (dr.oldevomodel.MSSD.AnyTipObservationProcess)2 SingleTipObservationProcess (dr.oldevomodel.MSSD.SingleTipObservationProcess)2 SiteModel (dr.oldevomodel.sitemodel.SiteModel)2 MutationDeathType (dr.evolution.datatype.MutationDeathType)1 AbstractSubstitutionModel (dr.oldevomodel.substmodel.AbstractSubstitutionModel)1 FrequencyModel (dr.oldevomodel.substmodel.FrequencyModel)1