Skip to content

Commit

Permalink
Adding 'inverse' as synonym for 'negative'
Browse files Browse the repository at this point in the history
  • Loading branch information
rambaut committed Nov 9, 2023
1 parent 0494a9d commit 349bbce
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/dr/evoxml/MaskedPatternsParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class MaskedPatternsParser extends AbstractXMLObjectParser {
public static final String MASKED_PATTERNS = "maskedPatterns";
public static final String MASK = "mask";
public static final String NEGATIVE = "negative";
public static final String INVERSE = "inverse";

public String getParserName() { return MASKED_PATTERNS; }

Expand All @@ -53,7 +54,7 @@ public Object parseXMLObject(XMLObject xo) throws XMLParseException {

SiteList siteList = (SiteList)xo.getChild(SiteList.class);

boolean negativeMask = xo.getBooleanAttribute(NEGATIVE);
boolean inverseMask = xo.getBooleanAttribute(INVERSE, false) || xo.getBooleanAttribute(NEGATIVE, false);
String maskString = (String)xo.getElementFirstChild(MASK);

boolean[] mask = new boolean[siteList.getSiteCount()];
Expand All @@ -63,7 +64,7 @@ public Object parseXMLObject(XMLObject xo) throws XMLParseException {
if (k >= mask.length) {
break;
}
mask[k] = (c == '0' ? negativeMask : !negativeMask);
mask[k] = (c == '0' ? inverseMask : !inverseMask);
k++;
}
}
Expand All @@ -90,6 +91,7 @@ public Object parseXMLObject(XMLObject xo) throws XMLParseException {
public XMLSyntaxRule[] getSyntaxRules() { return rules; }

private final XMLSyntaxRule[] rules = {
AttributeRule.newBooleanRule(INVERSE, true),
AttributeRule.newBooleanRule(NEGATIVE, true),
new ElementRule(SiteList.class),
new ElementRule(MASK, String.class, "A parameter of 1s and 0s that represent included and excluded sites")
Expand Down

0 comments on commit 349bbce

Please sign in to comment.