Search in sources :

Example 1 with Attribute

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

the class LinkedParameterComponentGenerator method generateJointParameter.

private void generateJointParameter(LinkedParameter linkedParameter, List<Parameter> parameters, XMLWriter writer) {
    writer.writeOpenTag("jointParameter", new Attribute[] { new Attribute.Default<String>(XMLParser.ID, linkedParameter.getName()) });
    for (Parameter parameter : parameters) {
        writer.writeTag(ParameterParser.PARAMETER, new Attribute.Default<String>(XMLParser.IDREF, parameter.getName()), true);
    }
    writer.writeCloseTag("jointParameter");
}
Also used : Attribute(dr.util.Attribute) Parameter(dr.app.beauti.options.Parameter)

Example 2 with Attribute

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

the class SequenceErrorModelComponentGenerator method writeHypermutationAlignments.

private void writeHypermutationAlignments(XMLWriter writer, SequenceErrorModelComponentOptions component) {
    for (AbstractPartitionData partition : options.getDataPartitions()) {
        //partition.getName() + ".";
        String prefix = partition.getPrefix();
        if (component.isHypermutation(partition)) {
            SequenceErrorType errorType = component.getSequenceErrorType(partition);
            final String errorTypeName;
            switch(errorType) {
                case HYPERMUTATION_ALL:
                    errorTypeName = HypermutantAlignment.APOBECType.ALL.toString();
                    break;
                case HYPERMUTATION_BOTH:
                    errorTypeName = HypermutantAlignment.APOBECType.BOTH.toString();
                    break;
                case HYPERMUTATION_HA3F:
                    errorTypeName = HypermutantAlignment.APOBECType.HA3F.toString();
                    break;
                case HYPERMUTATION_HA3G:
                    errorTypeName = HypermutantAlignment.APOBECType.HA3G.toString();
                    break;
                default:
                    throw new RuntimeException("Unknown ErrorModelType: " + errorType.toString());
            }
            writer.writeOpenTag(HypermutantAlignmentParser.HYPERMUTANT_ALIGNMENT, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, prefix + "hypermutants"), new Attribute.Default<String>("type", errorTypeName) });
            writer.writeIDref("alignment", partition.getTaxonList().getId());
            writer.writeCloseTag(HypermutantAlignmentParser.HYPERMUTANT_ALIGNMENT);
        }
    }
}
Also used : AbstractPartitionData(dr.app.beauti.options.AbstractPartitionData) Attribute(dr.util.Attribute) SequenceErrorType(dr.app.beauti.types.SequenceErrorType)

Example 3 with Attribute

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

the class SequenceErrorModelComponentGenerator method writeErrorModels.

private void writeErrorModels(XMLWriter writer, SequenceErrorModelComponentOptions component) {
    for (AbstractPartitionData partition : options.getDataPartitions()) {
        //partition.getName() + ".";
        String prefix = partition.getPrefix();
        SequenceErrorType errorType = component.getSequenceErrorType(partition);
        if (component.isHypermutation(partition)) {
            writer.writeOpenTag(HypermutantErrorModel.HYPERMUTANT_ERROR_MODEL, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, prefix + SequenceErrorModelComponentOptions.ERROR_MODEL) });
            writer.writeIDref(HypermutantAlignmentParser.HYPERMUTANT_ALIGNMENT, prefix + "hypermutants");
            writeParameter(HypermutantErrorModel.HYPERMUTATION_RATE, prefix + SequenceErrorModelComponentOptions.HYPERMUTION_RATE_PARAMETER, 1, writer);
            writeParameter(HypermutantErrorModel.HYPERMUTATION_INDICATORS, prefix + SequenceErrorModelComponentOptions.HYPERMUTANT_INDICATOR_PARAMETER, 1, writer);
            writer.writeCloseTag(HypermutantErrorModel.HYPERMUTANT_ERROR_MODEL);
            writer.writeOpenTag(SumStatisticParser.SUM_STATISTIC, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, prefix + SequenceErrorModelComponentOptions.HYPERMUTANT_COUNT_STATISTIC), new Attribute.Default<Boolean>(SumStatisticParser.ELEMENTWISE, true) });
            writer.writeIDref(ParameterParser.PARAMETER, prefix + SequenceErrorModelComponentOptions.HYPERMUTANT_INDICATOR_PARAMETER);
            writer.writeCloseTag(SumStatisticParser.SUM_STATISTIC);
        } else if (errorType != SequenceErrorType.NO_ERROR) {
            final String errorTypeName = (errorType == SequenceErrorType.AGE_TRANSITIONS || errorType == SequenceErrorType.BASE_TRANSITIONS ? "transitions" : "all");
            writer.writeOpenTag(SequenceErrorModelParser.SEQUENCE_ERROR_MODEL, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, prefix + SequenceErrorModelComponentOptions.ERROR_MODEL), new Attribute.Default<String>("type", errorTypeName) });
            if (component.hasAgeDependentRate(partition)) {
                writeParameter(SequenceErrorModelComponentOptions.AGE_RATE, prefix + SequenceErrorModelComponentOptions.AGE_RATE_PARAMETER, 1, writer);
            }
            if (component.hasBaseRate(partition)) {
                writeParameter(SequenceErrorModelComponentOptions.BASE_RATE, prefix + SequenceErrorModelComponentOptions.BASE_RATE_PARAMETER, 1, writer);
            }
            writer.writeCloseTag(SequenceErrorModelParser.SEQUENCE_ERROR_MODEL);
        }
    }
}
Also used : AbstractPartitionData(dr.app.beauti.options.AbstractPartitionData) Attribute(dr.util.Attribute) SequenceErrorType(dr.app.beauti.types.SequenceErrorType)

Example 4 with Attribute

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

the class DiscreteTraitsComponentGenerator method writeTreeLikelihood.

/**
     * Write Tree Likelihood
     *
     * @param partition PartitionData
     * @param writer    XMLWriter
     */
public void writeTreeLikelihood(AbstractPartitionData partition, XMLWriter writer) {
    String prefix = partition.getName() + ".";
    PartitionSubstitutionModel substModel = partition.getPartitionSubstitutionModel();
    PartitionTreeModel treeModel = partition.getPartitionTreeModel();
    PartitionClockModel clockModel = partition.getPartitionClockModel();
    AncestralStatesComponentOptions ancestralStatesOptions = (AncestralStatesComponentOptions) options.getComponentOptions(AncestralStatesComponentOptions.class);
    String treeLikelihoodTag = TreeLikelihoodParser.ANCESTRAL_TREE_LIKELIHOOD;
    if (ancestralStatesOptions.isCountingStates(partition)) {
        treeLikelihoodTag = MarkovJumpsTreeLikelihoodParser.MARKOV_JUMP_TREE_LIKELIHOOD;
    }
    writer.writeOpenTag(treeLikelihoodTag, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, prefix + TreeLikelihoodParser.TREE_LIKELIHOOD), new Attribute.Default<String>(AncestralStateTreeLikelihoodParser.RECONSTRUCTION_TAG_NAME, prefix + AncestralStateTreeLikelihoodParser.RECONSTRUCTION_TAG) });
    writer.writeIDref(AttributePatternsParser.ATTRIBUTE_PATTERNS, prefix + "pattern");
    writer.writeIDref(TreeModel.TREE_MODEL, treeModel.getPrefix() + TreeModel.TREE_MODEL);
    writer.writeIDref(SiteModel.SITE_MODEL, substModel.getName() + "." + SiteModel.SITE_MODEL);
    writer.writeIDref(GeneralSubstitutionModelParser.GENERAL_SUBSTITUTION_MODEL, substModel.getName() + "." + AbstractSubstitutionModel.MODEL);
    ClockModelGenerator.writeBranchRatesModelRef(clockModel, writer);
    if (substModel.getDiscreteSubstType() == DiscreteSubstModelType.ASYM_SUBST) {
        int stateCount = options.getStatesForDiscreteModel(substModel).size();
        writer.writeComment("The root state frequencies");
        writeDiscreteFrequencyModel(partition.getPrefix() + "root.", substModel.getName() + ".", stateCount, true, writer);
    }
    getCallingGenerator().generateInsertionPoint(ComponentGenerator.InsertionPoint.IN_TREE_LIKELIHOOD, partition, writer);
    writer.writeCloseTag(treeLikelihoodTag);
}
Also used : Attribute(dr.util.Attribute) AncestralStatesComponentOptions(dr.app.beauti.components.ancestralstates.AncestralStatesComponentOptions)

Example 5 with Attribute

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

the class HierarchicalModelComponentGenerator method generateDistribution.

private void generateDistribution(HierarchicalPhylogeneticModel hpm, XMLWriter writer) {
    writer.writeOpenTag(DistributionLikelihood.DISTRIBUTION_LIKELIHOOD, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, getDistributionName(hpm)) });
    // Add parameters as data
    writer.writeOpenTag(DistributionLikelihoodParser.DATA);
    for (Parameter parameter : hpm.getArgumentParameterList()) {
        writeParameterRef(parameter.getName(), writer);
    }
    writer.writeCloseTag(DistributionLikelihoodParser.DATA);
    // Add HPM model
    writer.writeOpenTag(DistributionLikelihoodParser.DISTRIBUTION);
    writer.writeOpenTag(getModelTagName(hpm), getModelAttributes(hpm));
    writeParameter(NormalDistributionModelParser.MEAN, hpm.getConditionalParameterList().get(0).getName(), 1, hpm.getConditionalParameterList().get(0).getInitial(), Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, writer);
    writeParameter(NormalDistributionModelParser.PREC, hpm.getConditionalParameterList().get(1).getName(), 1, hpm.getConditionalParameterList().get(1).getInitial(), 0.0, Double.POSITIVE_INFINITY, writer);
    writer.writeCloseTag(getModelTagName(hpm));
    writer.writeCloseTag(DistributionLikelihoodParser.DISTRIBUTION);
    writer.writeCloseTag(DistributionLikelihood.DISTRIBUTION_LIKELIHOOD);
}
Also used : Attribute(dr.util.Attribute) Parameter(dr.app.beauti.options.Parameter)

Aggregations

Attribute (dr.util.Attribute)45 Taxa (dr.evolution.util.Taxa)11 Taxon (dr.evolution.util.Taxon)11 Parameter (dr.app.beauti.options.Parameter)6 AbstractPartitionData (dr.app.beauti.options.AbstractPartitionData)5 PartitionTreeModel (dr.app.beauti.options.PartitionTreeModel)5 PartitionSubstitutionModel (dr.app.beauti.options.PartitionSubstitutionModel)4 TreePriorType (dr.app.beauti.types.TreePriorType)4 AncestralStatesComponentOptions (dr.app.beauti.components.ancestralstates.AncestralStatesComponentOptions)3 DataType (dr.evolution.datatype.DataType)3 ArrayList (java.util.ArrayList)3 SequenceErrorType (dr.app.beauti.types.SequenceErrorType)2 Alignment (dr.evolution.alignment.Alignment)2 SitePatterns (dr.evolution.alignment.SitePatterns)2 Date (dr.evolution.util.Date)2 TaxonList (dr.evolution.util.TaxonList)2 HashSet (java.util.HashSet)2 SequenceErrorModelComponentOptions (dr.app.beauti.components.sequenceerror.SequenceErrorModelComponentOptions)1 TreePriorParameterizationType (dr.app.beauti.types.TreePriorParameterizationType)1 XMLWriter (dr.app.beauti.util.XMLWriter)1