use of dr.app.beauti.components.sequenceerror.SequenceErrorModelComponentOptions in project beast-mcmc by beast-dev.
the class PatternListGenerator method writePatternList.
/**
* Writes the pattern lists
*
* @param partition the partition data to write the pattern lists for
* @param writer the writer
*/
public void writePatternList(PartitionData partition, XMLWriter writer) {
writer.writeText("");
AncestralStatesComponentOptions ancestralStatesOptions = (AncestralStatesComponentOptions) options.getComponentOptions(AncestralStatesComponentOptions.class);
SequenceErrorModelComponentOptions sequenceErrorOptions = (SequenceErrorModelComponentOptions) options.getComponentOptions(SequenceErrorModelComponentOptions.class);
PartitionSubstitutionModel model = partition.getPartitionSubstitutionModel();
String codonHeteroPattern = model.getCodonHeteroPattern();
int partitionCount = model.getCodonPartitionCount();
boolean isAncestralStatesModel = (!ancestralStatesOptions.usingAncestralStates(partition) && !sequenceErrorOptions.usingSequenceErrorModel(partition));
boolean isCovarionModel = model.getDataType().getType() == DataType.COVARION && model.getBinarySubstitutionModel() == BinaryModelType.BIN_COVARION;
boolean unique = isAncestralStatesModel || isCovarionModel;
boolean strip = isAncestralStatesModel || isCovarionModel;
if (model.getDataType().getType() == DataType.NUCLEOTIDES && codonHeteroPattern != null && partitionCount > 1) {
if (codonHeteroPattern.equals("112")) {
writer.writeComment("The " + (unique ? "unique " : "") + "patterns for codon positions 1 & 2");
writer.writeOpenTag(MergePatternsParser.MERGE_PATTERNS, new Attribute[] { new Attribute.Default<String>(XMLParser.ID, partition.getPrefix() + model.getPrefixCodon(1) + SitePatternsParser.PATTERNS) });
writePatternList(partition, 0, 3, null, unique, strip, writer);
writePatternList(partition, 1, 3, null, unique, strip, writer);
writer.writeCloseTag(MergePatternsParser.MERGE_PATTERNS);
writer.writeComment("The " + (unique ? "unique " : "") + "patterns for codon position 3");
writePatternList(partition, 2, 3, model.getPrefixCodon(2), unique, strip, writer);
} else {
// pattern is 123
for (int i = 1; i <= 3; i++) {
writer.writeComment("The " + (unique ? "unique " : "") + "patterns for codon position " + i);
writePatternList(partition, i - 1, 3, model.getPrefixCodon(i), unique, strip, writer);
}
}
// END: pattern is 123
} else {
writePatternList(partition, 0, 1, "", unique, strip, writer);
}
}
Aggregations