use of dr.app.beauti.options.PartitionTreeModel in project beast-mcmc by beast-dev.
the class TipDateSamplingComponentGenerator method writeJointParameters.
private void writeJointParameters(XMLWriter writer, TaxonList taxa) {
for (int i = 0; i < taxa.getTaxonCount(); i++) {
Taxon taxon = taxa.getTaxon(i);
Set<PartitionTreeModel> treeModels = new HashSet<PartitionTreeModel>();
for (PartitionTreeModel treeModel : options.getPartitionTreeModels()) {
for (AbstractPartitionData data : options.getDataPartitions(treeModel)) {
if (data.getTaxonList().asList().contains(taxon)) {
treeModels.add(treeModel);
}
}
}
// if we are sampling within precisions then only include this leaf if precision > 0
if (treeModels.size() > 0) {
writer.writeOpenTag("jointParameter", new Attribute[] { new Attribute.Default<String>(XMLParser.ID, "age(" + taxon.getId() + ")") });
for (PartitionTreeModel treeModel : treeModels) {
writer.writeTag(ParameterParser.PARAMETER, new Attribute.Default<String>(XMLParser.IDREF, treeModel.getPrefix() + "age(" + taxon.getId() + ")"), true);
}
writer.writeCloseTag("jointParameter");
}
}
}
use of dr.app.beauti.options.PartitionTreeModel in project beast-mcmc by beast-dev.
the class TipDateSamplingComponentGenerator method generate.
protected void generate(final InsertionPoint point, final Object item, final String prefix, final XMLWriter writer) {
TipDateSamplingComponentOptions comp = (TipDateSamplingComponentOptions) options.getComponentOptions(TipDateSamplingComponentOptions.class);
TaxonList taxa = comp.getTaxonSet();
switch(point) {
case IN_TREE_MODEL:
{
writeLeafHeightParameters(writer, (PartitionTreeModel) item, taxa);
}
break;
case AFTER_TREE_MODEL:
if (options.getPartitionTreeModels().size() > 1) {
// we have multiple treeModels with some or all the same taxa - create a JointParameter for each...
writeJointParameters(writer, taxa);
}
if (comp.tipDateSamplingType == TipDateSamplingType.SAMPLE_JOINT) {
writer.writeOpenTag("compoundParameter", new Attribute[] { new Attribute.Default<String>(XMLParser.ID, "treeModel.tipDates") });
for (int i = 0; i < taxa.getTaxonCount(); i++) {
Taxon taxon = taxa.getTaxon(i);
writer.writeIDref(ParameterParser.PARAMETER, "age(" + taxon.getId() + ")");
}
writer.writeCloseTag("compoundParameter");
}
break;
case IN_MCMC_PRIOR:
if (comp.tipDateSamplingType == TipDateSamplingType.SAMPLE_INDIVIDUALLY || comp.tipDateSamplingType == TipDateSamplingType.SAMPLE_PRECISION) {
// nothing to do - individual parameter priors are written automatically
} else if (comp.tipDateSamplingType == TipDateSamplingType.SAMPLE_JOINT) {
}
break;
case IN_FILE_LOG_PARAMETERS:
if (comp.tipDateSamplingType == TipDateSamplingType.SAMPLE_INDIVIDUALLY || comp.tipDateSamplingType == TipDateSamplingType.SAMPLE_PRECISION) {
for (int i = 0; i < taxa.getTaxonCount(); i++) {
Taxon taxon = taxa.getTaxon(i);
writer.writeIDref(ParameterParser.PARAMETER, "age(" + taxon.getId() + ")");
}
} else if (comp.tipDateSamplingType == TipDateSamplingType.SAMPLE_JOINT) {
writer.writeIDref(ParameterParser.PARAMETER, "treeModel.tipDates");
}
break;
default:
throw new IllegalArgumentException("This insertion point is not implemented for " + this.getClass().getName());
}
}
use of dr.app.beauti.options.PartitionTreeModel in project beast-mcmc by beast-dev.
the class TipDateSamplingComponentGenerator method writeLeafHeightParameters.
private void writeLeafHeightParameters(XMLWriter writer, PartitionTreeModel item, TaxonList taxa) {
// only include this taxon as a leaf height if it found in this partition.
PartitionTreeModel treeModel = (PartitionTreeModel) item;
Set<Taxon> taxonSet = new HashSet<Taxon>();
for (AbstractPartitionData data : options.getDataPartitions(treeModel)) {
if (data.getTaxonList() != null) {
for (Taxon taxon : data.getTaxonList()) {
taxonSet.add(taxon);
}
}
}
for (int i = 0; i < taxa.getTaxonCount(); i++) {
Taxon taxon = taxa.getTaxon(i);
if (taxonSet.contains(taxon)) {
// if we are sampling within precisions then only include this leaf if precision > 0
writer.writeOpenTag("leafHeight", new Attribute[] { new Attribute.Default<String>(TaxonParser.TAXON, taxon.getId()) });
writer.writeTag(ParameterParser.PARAMETER, new Attribute.Default<String>(XMLParser.ID, treeModel.getPrefix() + "age(" + taxon.getId() + ")"), true);
writer.writeCloseTag("leafHeight");
}
}
}
Aggregations