use of dr.app.beauti.options.AbstractPartitionData in project beast-mcmc by beast-dev.
the class SequenceErrorModelComponentGenerator method generate.
protected void generate(final InsertionPoint point, final Object item, final String prefix, final XMLWriter writer) {
SequenceErrorModelComponentOptions component = (SequenceErrorModelComponentOptions) options.getComponentOptions(SequenceErrorModelComponentOptions.class);
switch(point) {
case AFTER_PATTERNS:
writeHypermutationAlignments(writer, component);
break;
case AFTER_SITE_MODEL:
writeErrorModels(writer, component);
break;
case IN_TREE_LIKELIHOOD:
AbstractPartitionData partition = (AbstractPartitionData) item;
SequenceErrorType errorType = component.getSequenceErrorType(partition);
if (errorType != SequenceErrorType.NO_ERROR) {
writer.writeIDref(SequenceErrorModelParser.SEQUENCE_ERROR_MODEL, partition.getPrefix() + "errorModel");
}
break;
case IN_FILE_LOG_PARAMETERS:
writeLogParameters(writer, component);
break;
default:
throw new IllegalArgumentException("This insertion point is not implemented for " + this.getClass().getName());
}
}
use of dr.app.beauti.options.AbstractPartitionData in project beast-mcmc by beast-dev.
the class SequenceErrorModelComponentGenerator method writeLogParameters.
private void writeLogParameters(final XMLWriter writer, final SequenceErrorModelComponentOptions component) {
for (AbstractPartitionData partition : options.getDataPartitions()) {
//partition.getName() + ".";
String prefix = partition.getPrefix();
SequenceErrorType errorType = component.getSequenceErrorType(partition);
if (errorType != SequenceErrorType.NO_ERROR) {
if (component.isHypermutation(partition)) {
writer.writeIDref(ParameterParser.PARAMETER, prefix + SequenceErrorModelComponentOptions.HYPERMUTION_RATE_PARAMETER);
writer.writeIDref(StatisticParser.STATISTIC, prefix + SequenceErrorModelComponentOptions.HYPERMUTANT_COUNT_STATISTIC);
writer.writeOpenTag(StatisticParser.STATISTIC, new Attribute.Default<String>("name", "isHypermutated"));
writer.writeIDref(HypermutantErrorModel.HYPERMUTANT_ERROR_MODEL, prefix + SequenceErrorModelComponentOptions.ERROR_MODEL);
writer.writeCloseTag(StatisticParser.STATISTIC);
}
if (component.hasAgeDependentRate(partition)) {
writer.writeIDref(ParameterParser.PARAMETER, prefix + SequenceErrorModelComponentOptions.AGE_RATE_PARAMETER);
}
if (component.hasBaseRate(partition)) {
writer.writeIDref(ParameterParser.PARAMETER, prefix + SequenceErrorModelComponentOptions.BASE_RATE_PARAMETER);
}
}
}
}
use of dr.app.beauti.options.AbstractPartitionData 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);
}
}
}
use of dr.app.beauti.options.AbstractPartitionData 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);
}
}
}
use of dr.app.beauti.options.AbstractPartitionData in project beast-mcmc by beast-dev.
the class GenerateTreeDialog method showDialog.
public int showDialog(BeautiOptions options) {
JOptionPane optionPane = new JOptionPane(optionPanel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, null);
optionPane.setBorder(new EmptyBorder(12, 12, 12, 12));
partitionCombo.removeAllItems();
for (AbstractPartitionData partition : options.dataPartitions) {
partitionCombo.addItem(partition);
}
final JDialog dialog = optionPane.createDialog(frame, "Construct New Tree");
dialog.pack();
dialog.setVisible(true);
int result = JOptionPane.CANCEL_OPTION;
Integer value = (Integer) optionPane.getValue();
if (value != null && value != -1) {
result = value;
}
return result;
}
Aggregations