Search in sources :

Example 16 with Taxa

use of dr.evolution.util.Taxa in project beast-mcmc by beast-dev.

the class ClockModelGenerator method writeBranchRatesModel.

/**
 * Write the relaxed clock branch rates block.
 *
 * @param clockModel  PartitionClockModel
 * @param writer the writer
 */
public void writeBranchRatesModel(PartitionClockModel clockModel, XMLWriter writer) {
    Attribute[] attributes;
    PartitionTreeModel treeModel = clockModel.getPartitionTreeModel();
    String treePrefix = treeModel.getPrefix();
    String prefix = clockModel.getPrefix();
    String tag;
    switch(clockModel.getClockType()) {
        case STRICT_CLOCK:
            tag = StrictClockBranchRatesParser.STRICT_CLOCK_BRANCH_RATES;
            writer.writeComment("The strict clock (Uniform rates across branches)");
            writer.writeOpenTag(tag, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, prefix + BranchRateModel.BRANCH_RATES) });
            writeParameter("rate", "clock.rate", clockModel, writer);
            writer.writeCloseTag(tag);
            writeMeanRateStatistic(writer, tag, prefix, treePrefix);
            break;
        case UNCORRELATED:
            if (clockModel.performModelAveraging()) {
                tag = MixtureModelBranchRatesParser.MIXTURE_MODEL_BRANCH_RATES;
                writer.writeComment("Bayesian Model Averaging (BMA) of the available relaxed clock models as described by" + " Li & Drummond (2012) MBE 29:751-61.");
                // Bayesian Model Averaging uses the continuous quantile implementation by default
                writer.writeComment("  Continuous quantile implementation (Li & Drummond (2012) Mol Biol Evol 29:751-61)");
                attributes = new Attribute[] { new Attribute.Default<String>(XMLParser.ID, prefix + BranchRateModel.BRANCH_RATES) };
                writer.writeOpenTag(tag, attributes);
                // tree
                writer.writeIDref(DefaultTreeModel.TREE_MODEL, treePrefix + DefaultTreeModel.TREE_MODEL);
                writer.writeOpenTag("distribution");
                writer.writeOpenTag(LogNormalDistributionModelParser.LOGNORMAL_DISTRIBUTION_MODEL, new Attribute.Default<String>(LogNormalDistributionModelParser.MEAN_IN_REAL_SPACE, "true"));
                writeParameter("mean", ClockType.UCLD_MEAN, clockModel, writer);
                writeParameter("stdev", ClockType.UCLD_STDEV, clockModel, writer);
                writer.writeCloseTag(LogNormalDistributionModelParser.LOGNORMAL_DISTRIBUTION_MODEL);
                writer.writeCloseTag("distribution");
                writer.writeOpenTag("distribution");
                writer.writeOpenTag(GammaDistributionModel.GAMMA_DISTRIBUTION_MODEL);
                writeParameter("mean", ClockType.UCGD_MEAN, clockModel, writer);
                writeParameter("shape", ClockType.UCGD_SHAPE, clockModel, writer);
                writer.writeCloseTag(GammaDistributionModel.GAMMA_DISTRIBUTION_MODEL);
                writer.writeCloseTag("distribution");
                writer.writeOpenTag("distribution");
                writer.writeOpenTag(ExponentialDistributionModel.EXPONENTIAL_DISTRIBUTION_MODEL);
                writeParameter("mean", ClockType.UCED_MEAN, clockModel, writer);
                writer.writeCloseTag(ExponentialDistributionModel.EXPONENTIAL_DISTRIBUTION_MODEL);
                writer.writeCloseTag("distribution");
                writer.writeOpenTag(MixtureModelBranchRatesParser.DISTRIBUTION_INDEX);
                writeParameter(clockModel.getParameter("branchRates.distributionIndex"), -1, writer);
                writer.writeCloseTag(MixtureModelBranchRatesParser.DISTRIBUTION_INDEX);
                writer.writeOpenTag(MixtureModelBranchRatesParser.RATE_CATEGORY_QUANTILES);
                writeParameter(clockModel.getParameter("branchRates.quantiles"), -1, writer);
                writer.writeCloseTag(MixtureModelBranchRatesParser.RATE_CATEGORY_QUANTILES);
                writer.writeCloseTag(tag);
                writeMeanRateStatistic(writer, tag, prefix, treePrefix);
                writeCoefficientOfVariationStatistic(writer, tag, prefix, treePrefix);
                writeCovarianceStatistic(writer, tag, prefix, treePrefix);
            } else {
                tag = DiscretizedBranchRatesParser.DISCRETIZED_BRANCH_RATES;
                writer.writeComment("The uncorrelated relaxed clock (Drummond, Ho, Phillips & Rambaut (2006) PLoS Biology 4, e88 )");
                if (clockModel.isContinuousQuantile()) {
                    writer.writeComment("  Continuous quantile implementation (Li & Drummond (2012) Mol Biol Evol 29:751-61)");
                    tag = ContinuousBranchRatesParser.CONTINUOUS_BRANCH_RATES;
                }
                attributes = new Attribute[] { new Attribute.Default<String>(XMLParser.ID, prefix + BranchRateModel.BRANCH_RATES) };
                writer.writeOpenTag(tag, attributes);
                // tree
                writer.writeIDref(DefaultTreeModel.TREE_MODEL, treePrefix + DefaultTreeModel.TREE_MODEL);
                writer.writeOpenTag("distribution");
                switch(clockModel.getClockDistributionType()) {
                    case LOGNORMAL:
                        writer.writeOpenTag(LogNormalDistributionModelParser.LOGNORMAL_DISTRIBUTION_MODEL, new Attribute.Default<String>(LogNormalDistributionModelParser.MEAN_IN_REAL_SPACE, "true"));
                        writeParameter("mean", ClockType.UCLD_MEAN, clockModel, writer);
                        writeParameter("stdev", ClockType.UCLD_STDEV, clockModel, writer);
                        writer.writeCloseTag(LogNormalDistributionModelParser.LOGNORMAL_DISTRIBUTION_MODEL);
                        break;
                    case GAMMA:
                        writer.writeOpenTag(GammaDistributionModel.GAMMA_DISTRIBUTION_MODEL);
                        writeParameter("mean", ClockType.UCGD_MEAN, clockModel, writer);
                        writeParameter("shape", ClockType.UCGD_SHAPE, clockModel, writer);
                        writer.writeCloseTag(GammaDistributionModel.GAMMA_DISTRIBUTION_MODEL);
                        break;
                    case CAUCHY:
                        throw new UnsupportedOperationException("Uncorrelated Cauchy model not implemented yet");
                    // break;
                    case EXPONENTIAL:
                        writer.writeOpenTag(ExponentialDistributionModel.EXPONENTIAL_DISTRIBUTION_MODEL);
                        writeParameter("mean", ClockType.UCED_MEAN, clockModel, writer);
                        writer.writeCloseTag(ExponentialDistributionModel.EXPONENTIAL_DISTRIBUTION_MODEL);
                        break;
                }
                writer.writeCloseTag("distribution");
                if (clockModel.isContinuousQuantile()) {
                    writer.writeOpenTag(ContinuousBranchRatesParser.RATE_QUANTILES);
                    writeParameter(clockModel.getParameter("branchRates.quantiles"), -1, writer);
                    writer.writeCloseTag(ContinuousBranchRatesParser.RATE_QUANTILES);
                    writer.writeCloseTag(tag);
                } else {
                    writer.writeOpenTag(DiscretizedBranchRatesParser.RATE_CATEGORIES);
                    writeParameter(clockModel.getParameter("branchRates.categories"), -1, writer);
                    writer.writeCloseTag(DiscretizedBranchRatesParser.RATE_CATEGORIES);
                    writer.writeCloseTag(tag);
                }
                writeMeanRateStatistic(writer, tag, prefix, treePrefix);
                writeCoefficientOfVariationStatistic(writer, tag, prefix, treePrefix);
                writeCovarianceStatistic(writer, tag, prefix, treePrefix);
            }
            break;
        case AUTOCORRELATED:
            writer.writeComment("The autocorrelated relaxed clock (Rannala & Yang, 2007)");
            tag = ACLikelihoodParser.AC_LIKELIHOOD;
            attributes = new Attribute[] { new Attribute.Default<String>(XMLParser.ID, prefix + BranchRateModel.BRANCH_RATES), new Attribute.Default<String>("episodic", "false"), new Attribute.Default<String>("logspace", "true") };
            writer.writeOpenTag(tag, attributes);
            writer.writeIDref(DefaultTreeModel.TREE_MODEL, treePrefix + DefaultTreeModel.TREE_MODEL);
            // if (!model.isEstimatedRate()) { //TODO move to options or panel select method
            // Parameter parameter = tree.getParameter(DefaultTreeModel.TREE_MODEL + "." + RateEvolutionLikelihood.ROOTRATE);//"treeModel.rootRate"
            // parameter.isFixed = true;
            // parameter.initial = model.getRate();
            // }
            writer.writeOpenTag(RateEvolutionLikelihood.RATES, new Attribute[] { new Attribute.Default<String>(TreeModelParser.ROOT_NODE, "false"), new Attribute.Default<String>(TreeModelParser.INTERNAL_NODES, "true"), new Attribute.Default<String>(TreeModelParser.LEAF_NODES, "true") });
            writer.writeTag(ParameterParser.PARAMETER, new Attribute.Default<String>(XMLParser.ID, treePrefix + DefaultTreeModel.TREE_MODEL + "." + TreeModelParser.NODE_RATES), true);
            writer.writeCloseTag(RateEvolutionLikelihood.RATES);
            writer.writeOpenTag(RateEvolutionLikelihood.ROOTRATE, new Attribute[] { new Attribute.Default<String>(TreeModelParser.ROOT_NODE, "true"), new Attribute.Default<String>(TreeModelParser.INTERNAL_NODES, "false"), new Attribute.Default<String>(TreeModelParser.LEAF_NODES, "false") });
            writer.writeTag(ParameterParser.PARAMETER, new Attribute.Default<String>(XMLParser.ID, treePrefix + DefaultTreeModel.TREE_MODEL + "." + RateEvolutionLikelihood.ROOTRATE), true);
            writer.writeCloseTag(RateEvolutionLikelihood.ROOTRATE);
            // writeParameterRef("rates", treePrefix + "treeModel.nodeRates", writer);
            // writeParameterRef(RateEvolutionLikelihood.ROOTRATE, treePrefix + "treeModel.rootRate", writer);
            writeParameter("variance", "branchRates.var", treeModel, writer);
            writer.writeCloseTag(tag);
            // if (model.isEstimatedRate()) {//TODO
            writer.writeText("");
            writer.writeOpenTag(CompoundParameterParser.COMPOUND_PARAMETER, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, treePrefix + DefaultTreeModel.TREE_MODEL + "." + "allRates") });
            writer.writeIDref(ParameterParser.PARAMETER, treePrefix + DefaultTreeModel.TREE_MODEL + "." + TreeModelParser.NODE_RATES);
            writer.writeIDref(ParameterParser.PARAMETER, treePrefix + DefaultTreeModel.TREE_MODEL + "." + RateEvolutionLikelihood.ROOTRATE);
            writer.writeCloseTag(CompoundParameterParser.COMPOUND_PARAMETER);
            // }
            writeMeanRateStatistic(writer, tag, prefix, treePrefix);
            writeCoefficientOfVariationStatistic(writer, tag, prefix, treePrefix);
            writeCovarianceStatistic(writer, tag, prefix, treePrefix);
        case // 1 random local clock CANNOT have different tree models
        RANDOM_LOCAL_CLOCK:
            writer.writeComment("The random local clock model (Drummond & Suchard, 2010)");
            tag = RandomLocalClockModelParser.LOCAL_BRANCH_RATES;
            writer.writeOpenTag(tag, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, prefix + BranchRateModel.BRANCH_RATES), new Attribute.Default<String>("ratesAreMultipliers", "false") });
            writer.writeIDref(DefaultTreeModel.TREE_MODEL, treePrefix + DefaultTreeModel.TREE_MODEL);
            writer.writeOpenTag("rates");
            writer.writeTag(ParameterParser.PARAMETER, new Attribute.Default<String>(XMLParser.ID, prefix + ClockType.LOCAL_CLOCK + ".relativeRates"), true);
            writer.writeCloseTag("rates");
            writer.writeOpenTag("rateIndicator");
            writer.writeTag(ParameterParser.PARAMETER, new Attribute.Default<String>(XMLParser.ID, prefix + ClockType.LOCAL_CLOCK + ".changes"), true);
            writer.writeCloseTag("rateIndicator");
            writeParameter("clockRate", "clock.rate", clockModel, writer);
            writer.writeCloseTag(tag);
            writer.writeText("");
            writer.writeOpenTag(SumStatisticParser.SUM_STATISTIC, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, prefix + "rateChanges"), new Attribute.Default<String>("name", prefix + "rateChangeCount"), new Attribute.Default<String>("elementwise", "true") });
            writer.writeIDref(ParameterParser.PARAMETER, prefix + ClockType.LOCAL_CLOCK + ".changes");
            writer.writeCloseTag(SumStatisticParser.SUM_STATISTIC);
            writeMeanRateStatistic(writer, tag, prefix, treePrefix);
            writeCoefficientOfVariationStatistic(writer, tag, prefix, treePrefix);
            writeCovarianceStatistic(writer, tag, prefix, treePrefix);
            break;
        case FIXED_LOCAL_CLOCK:
            writer.writeComment("The a priori local clock model (Yoder & Yang, 2000)");
            tag = LocalClockModelParser.LOCAL_CLOCK_MODEL;
            writer.writeOpenTag(tag, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, prefix + BranchRateModel.BRANCH_RATES) });
            writer.writeIDref(DefaultTreeModel.TREE_MODEL, treePrefix + DefaultTreeModel.TREE_MODEL);
            writeParameter(LocalClockModelParser.RATE, "clock.rate", clockModel, writer);
            for (Taxa taxonSet : options.taxonSets) {
                if (options.taxonSetsMono.get(taxonSet)) {
                    String parameterName = taxonSet.getId() + ".rate";
                    writer.writeOpenTag(LocalClockModelParser.CLADE, new Attribute[] { new Attribute.Default<String>("includeStem", options.taxonSetsIncludeStem.get(taxonSet).toString()) });
                    writeParameter(parameterName, clockModel, writer);
                    writer.writeIDref(TaxaParser.TAXA, taxonSet.getId());
                    writer.writeCloseTag(LocalClockModelParser.CLADE);
                }
            }
            writer.writeCloseTag(tag);
            writeMeanRateStatistic(writer, tag, prefix, treePrefix);
            writeCoefficientOfVariationStatistic(writer, tag, prefix, treePrefix);
            writeCovarianceStatistic(writer, tag, prefix, treePrefix);
            break;
        default:
            throw new IllegalArgumentException("Unknown clock model");
    }
}
Also used : Taxa(dr.evolution.util.Taxa) Attribute(dr.util.Attribute)

Example 17 with Taxa

use of dr.evolution.util.Taxa in project beast-mcmc by beast-dev.

the class LogGenerator method writeDemographicLogToFile.

public void writeDemographicLogToFile(XMLWriter writer, TreePriorGenerator treePriorGenerator, ClockModelGenerator clockModelGenerator, SubstitutionModelGenerator substitutionModelGenerator, TreeLikelihoodGenerator treeLikelihoodGenerator) {
    writer.writeComment("demographic log file");
    if (options.demographicLogFileName == null) {
        options.demographicLogFileName = options.fileNameStem + ".demo.log";
    }
    String header = "Demographic Model: " + options.demographicModelName;
    writer.writeOpenTag(LoggerParser.LOG, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, "fileLog"), new Attribute.Default<String>(LoggerParser.HEADER, header + ""), new Attribute.Default<String>(LoggerParser.LOG_EVERY, options.logEvery + ""), new Attribute.Default<String>(LoggerParser.FILE_NAME, options.logFileName), new Attribute.Default<Boolean>(LoggerParser.ALLOW_OVERWRITE_LOG, options.allowOverwriteLog) });
    if (options.hasData()) {
        writer.writeIDref(CompoundLikelihoodParser.JOINT, "joint");
    }
    writer.writeIDref(CompoundLikelihoodParser.PRIOR, "prior");
    for (PartitionTreeModel model : options.getPartitionTreeModels()) {
        writer.writeIDref(ParameterParser.PARAMETER, model.getPrefix() + DefaultTreeModel.TREE_MODEL + "." + TreeModelParser.ROOT_HEIGHT);
    }
    for (Taxa taxa : options.taxonSets) {
        // make tmrca(tree.name) eay to read in log for Tracer
        PartitionTreeModel treeModel = options.taxonSetsTreeModel.get(taxa);
        writer.writeIDref(TMRCAStatisticParser.TMRCA_STATISTIC, "tmrca(" + treeModel.getPrefix() + taxa.getId() + ")");
    }
    // } else { // no species
    for (PartitionTreePrior prior : options.getPartitionTreePriors()) {
        // treePriorGenerator.setModelPrefix(prior.getPrefix()); // priorName.treeModel
        treePriorGenerator.writeParameterLog(prior, writer);
    }
    for (PartitionSubstitutionModel model : options.getPartitionSubstitutionModels()) {
        substitutionModelGenerator.writeLog(model, writer);
    }
    for (PartitionClockModel model : options.getPartitionClockModels()) {
        // if (model.getRateTypeOption() == FixRateType.FIXED_MEAN) {
        // writer.writeIDref(ParameterParser.PARAMETER, model.getName());
        // if (model.getClockType() == ClockType.UNCORRELATED) {
        // switch (model.getClockDistributionType()) {
        // case LOGNORMAL:
        // writer.writeIDref(ParameterParser.PARAMETER, model.getPrefix() + ClockType.UCLD_STDEV);
        // break;
        // case GAMMA:
        // throw new UnsupportedOperationException("Uncorrelated gamma model not implemented yet");
        // //                            break;
        // case CAUCHY:
        // throw new UnsupportedOperationException("Uncorrelated Cauchy model not implemented yet");
        // //                            break;
        // case EXPONENTIAL:
        // // nothing required
        // break;
        // }
        // }
        // }
        clockModelGenerator.writeLog(model, writer);
    }
    for (PartitionClockModel model : options.getPartitionClockModels()) {
        clockModelGenerator.writeLogStatistic(model, writer);
    }
    generateInsertionPoint(ComponentGenerator.InsertionPoint.IN_FILE_LOG_PARAMETERS, writer);
    treeLikelihoodGenerator.writeTreeLikelihoodReferences(writer);
    clockModelGenerator.writeClockLikelihoodReferences(writer);
    generateInsertionPoint(ComponentGenerator.InsertionPoint.IN_FILE_LOG_LIKELIHOODS, writer);
    // coalescentLikelihood
    for (PartitionTreeModel model : options.getPartitionTreeModels()) {
        PartitionTreePrior prior = model.getPartitionTreePrior();
        treePriorGenerator.writePriorLikelihoodReferenceLog(prior, model, writer);
        writer.writeText("");
    }
    for (PartitionTreePrior prior : options.getPartitionTreePriors()) {
        if (prior.getNodeHeightPrior() == TreePriorType.EXTENDED_SKYLINE) {
            // only 1 coalescent
            writer.writeIDref(CoalescentLikelihoodParser.COALESCENT_LIKELIHOOD, prior.getPrefix() + COALESCENT);
        } else if (prior.getNodeHeightPrior() == TreePriorType.SKYGRID) {
            writer.writeIDref(GMRFSkyrideLikelihoodParser.SKYGRID_LIKELIHOOD, prior.getPrefix() + "skygrid");
        }
    }
    writer.writeCloseTag(LoggerParser.LOG);
    generateInsertionPoint(ComponentGenerator.InsertionPoint.AFTER_FILE_LOG, writer);
}
Also used : Taxa(dr.evolution.util.Taxa) Attribute(dr.util.Attribute)

Example 18 with Taxa

use of dr.evolution.util.Taxa in project beast-mcmc by beast-dev.

the class InitialTreeGenerator method writeStartingTree.

/**
 * Generate XML for the starting tree
 * @param model  PartitionTreeModel
 *
 * @param writer the writer
 */
public void writeStartingTree(PartitionTreeModel model, XMLWriter writer) {
    String prefix = model.getPrefix();
    switch(model.getStartingTreeType()) {
        case USER:
        case UPGMA:
            Parameter rootHeight = model.getParameter("treeModel.rootHeight");
            // generate a rescaled starting tree
            writer.writeComment("Construct a starting tree that is compatible with specified clade heights");
            Attribute[] attributes = (rootHeight.priorType != PriorType.NONE_TREE_PRIOR ? new Attribute[] { new Attribute.Default<String>(XMLParser.ID, prefix + STARTING_TREE), new Attribute.Default<String>(RescaledTreeParser.HEIGHT, "" + rootHeight.getInitial()) } : new Attribute[] { new Attribute.Default<String>(XMLParser.ID, prefix + STARTING_TREE) });
            writer.writeOpenTag(RescaledTreeParser.RESCALED_TREE, attributes);
            writeSourceTree(model, writer);
            if (options.taxonSets != null && options.taxonSets.size() > 0) {
                for (Taxa taxa : options.taxonSets) {
                    Double height = options.taxonSetsHeights.get(taxa);
                    if (height != null) {
                        writer.writeOpenTag(RescaledTreeParser.CLADE, new Attribute.Default<String>(RescaledTreeParser.HEIGHT, height.toString()));
                        writer.writeTag("taxa", new Attribute.Default<String>(XMLParser.IDREF, taxa.getId()), true);
                        writer.writeCloseTag(RescaledTreeParser.CLADE);
                    } else if (options.taxonSetsMono.get(taxa)) {
                        // if monophyly is enforced then placing this clade element here will force BEAST to check
                        // the clade exists in the tree.
                        writer.writeOpenTag(RescaledTreeParser.CLADE);
                        writer.writeTag("taxa", new Attribute.Default<String>(XMLParser.IDREF, taxa.getId()), true);
                        writer.writeCloseTag(RescaledTreeParser.CLADE);
                    }
                }
            }
            writer.writeCloseTag(RescaledTreeParser.RESCALED_TREE);
            break;
        case RANDOM:
            // generate a coalescent tree
            String simulatorId = prefix + STARTING_TREE;
            String taxaId = TaxaParser.TAXA;
            AbstractPartitionData partition = options.getDataPartitions(model).get(0);
            if (!options.hasIdenticalTaxa()) {
                taxaId = partition.getPartitionTreeModel().getPrefix() + TaxaParser.TAXA;
            }
            if (partition instanceof PartitionPattern && ((PartitionPattern) partition).getPatterns().hasMask()) {
                taxaId = partition.getPrefix() + TaxaParser.TAXA;
            }
            writer.writeComment("Generate a random starting tree under the coalescent process");
            if (options.taxonSets != null && options.taxonSets.size() > 0) {
                writeSubTree(simulatorId, taxaId, options.taxonList, model, writer);
            } else {
                writer.writeOpenTag(CoalescentSimulatorParser.COALESCENT_SIMULATOR, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, simulatorId) });
                writeTaxaRef(taxaId, model, writer);
                writeInitialDemoModelRef(model, writer);
                writer.writeCloseTag(CoalescentSimulatorParser.COALESCENT_SIMULATOR);
            }
            break;
        default:
            throw new IllegalArgumentException("Unknown StartingTreeType");
    }
}
Also used : Taxa(dr.evolution.util.Taxa) Attribute(dr.util.Attribute)

Example 19 with Taxa

use of dr.evolution.util.Taxa in project beast-mcmc by beast-dev.

the class InitialTreeGenerator method writeTaxaRef.

private void writeTaxaRef(String taxaId, PartitionTreeModel model, XMLWriter writer) {
    Attribute[] taxaAttribute = { new Attribute.Default<String>(XMLParser.IDREF, taxaId) };
    if (options.taxonSets != null && options.taxonSets.size() > 0) {
        // *BEAST case is in STARBEASTGenerator.writeStartingTreeForCalibration(XMLWriter writer)
        writer.writeOpenTag(OldCoalescentSimulatorParser.CONSTRAINED_TAXA);
        writer.writeTag(TaxaParser.TAXA, taxaAttribute, true);
        for (Taxa taxa : options.taxonSets) {
            if (options.taxonSetsTreeModel.get(taxa).equals(model)) {
                Parameter statistic = options.getStatistic(taxa);
                Attribute mono = new Attribute.Default<Boolean>(OldCoalescentSimulatorParser.IS_MONOPHYLETIC, options.taxonSetsMono.get(taxa));
                writer.writeOpenTag(OldCoalescentSimulatorParser.TMRCA_CONSTRAINT, mono);
                writer.writeIDref(TaxaParser.TAXA, taxa.getId());
                if (model.getPartitionTreePrior().getNodeHeightPrior() == TreePriorType.YULE_CALIBRATION && statistic.priorType == PriorType.UNIFORM_PRIOR) {
                    writeDistribution(statistic, false, writer);
                }
                writer.writeCloseTag(OldCoalescentSimulatorParser.TMRCA_CONSTRAINT);
            }
        }
        writer.writeCloseTag(OldCoalescentSimulatorParser.CONSTRAINED_TAXA);
    } else {
        writer.writeTag(TaxaParser.TAXA, taxaAttribute, true);
    }
}
Also used : Taxa(dr.evolution.util.Taxa) Attribute(dr.util.Attribute)

Example 20 with Taxa

use of dr.evolution.util.Taxa in project beast-mcmc by beast-dev.

the class TMRCAStatisticsGenerator method writeTMRCAStatisticReferences.

public void writeTMRCAStatisticReferences(XMLWriter writer) {
    for (Taxa taxa : options.taxonSets) {
        // make tmrca(tree.name) eay to read in log for Tracer
        PartitionTreeModel treeModel = options.taxonSetsTreeModel.get(taxa);
        writer.writeIDref(TMRCAStatisticParser.TMRCA_STATISTIC, "tmrca(" + treeModel.getPrefix() + taxa.getId() + ")");
    }
    for (Taxa taxa : options.taxonSets) {
        // make tmrca(tree.name) eay to read in log for Tracer
        PartitionTreeModel treeModel = options.taxonSetsTreeModel.get(taxa);
        if (treeModel.hasTipCalibrations()) {
            writer.writeIDref(TMRCAStatisticParser.TMRCA_STATISTIC, "age(" + treeModel.getPrefix() + taxa.getId() + ")");
        }
    }
}
Also used : Taxa(dr.evolution.util.Taxa) PartitionTreeModel(dr.app.beauti.options.PartitionTreeModel)

Aggregations

Taxa (dr.evolution.util.Taxa)75 Taxon (dr.evolution.util.Taxon)34 ArrayList (java.util.ArrayList)23 Tree (dr.evolution.tree.Tree)19 TaxonList (dr.evolution.util.TaxonList)15 Attribute (dr.util.Attribute)13 DefaultTreeModel (dr.evomodel.tree.DefaultTreeModel)10 TreeModel (dr.evomodel.tree.TreeModel)10 Patterns (dr.evolution.alignment.Patterns)9 Microsatellite (dr.evolution.datatype.Microsatellite)9 IOException (java.io.IOException)8 NewickImporter (dr.evolution.io.NewickImporter)7 Parameter (dr.inference.model.Parameter)6 Date (dr.evolution.util.Date)5 GammaSiteModel (dr.oldevomodel.sitemodel.GammaSiteModel)5 SimpleAlignment (dr.evolution.alignment.SimpleAlignment)4 ImportException (dr.evolution.io.Importer.ImportException)4 BranchRateModel (dr.evomodel.branchratemodel.BranchRateModel)4 CoalescentSimulator (dr.evomodel.coalescent.CoalescentSimulator)4 PartitionTreeModel (dr.app.beauti.options.PartitionTreeModel)3