http://code.google.com/p/beast-mcmc/source/detail?r=4803
Added:
/trunk/src/dr/inference/model/NotBooleanStatistic.java
/trunk/src/dr/inferencexml/model/NotBooleanStatisticParser.java
Modified:
/trunk/src/dr/app/beast/release_parsers.properties
=======================================
--- /dev/null
+++ /trunk/src/dr/inference/model/NotBooleanStatistic.java Thu Mar 8
12:33:19 2012
@@ -0,0 +1,60 @@
+/*
+ * NotBooleanStatistic.java
+ *
+ * Copyright (c) 2002-2012 Alexei Drummond, Andrew Rambaut and Marc Suchard
+ *
+ * This file is part of BEAST.
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership and licensing.
+ *
+ * BEAST is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * BEAST is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with BEAST; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+package dr.inference.model;
+
+import java.util.List;
+
+/**
+ * @author Marc Suchard
+ */
+public class NotBooleanStatistic extends BooleanStatistic {
+
+ public NotBooleanStatistic(BooleanStatistic originalStatistic) {
+ this(originalStatistic, null);
+ }
+
+ public NotBooleanStatistic(BooleanStatistic originalStatistic,
List<Integer> mark) {
+ super(originalStatistic.getStatisticName());
+ this.originalStatistic = originalStatistic;
+ this.mark = mark;
+ }
+
+ @Override
+ public boolean getBoolean(int dim) {
+ boolean rtnValue = originalStatistic.getBoolean(dim);
+ if (mark == null || mark.contains(dim)) {
+ rtnValue = !rtnValue;
+ }
+ return rtnValue;
+ }
+
+ public int getDimension() {
+ return originalStatistic.getDimension();
+ }
+
+ private final BooleanStatistic originalStatistic;
+ private final List<Integer> mark;
+}
=======================================
--- /dev/null
+++ /trunk/src/dr/inferencexml/model/NotBooleanStatisticParser.java Thu
Mar 8 12:33:19 2012
@@ -0,0 +1,68 @@
+/*
+ * NotBooleanStatisticParser.java
+ *
+ * Copyright (c) 2002-2012 Alexei Drummond, Andrew Rambaut and Marc Suchard
+ *
+ * This file is part of BEAST.
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership and licensing.
+ *
+ * BEAST is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * BEAST is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with BEAST; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+package dr.inferencexml.model;
+
+import dr.inference.model.BooleanStatistic;
+import dr.inference.model.NotBooleanStatistic;
+import dr.xml.*;
+
+/**
+ */
+public class NotBooleanStatisticParser extends AbstractXMLObjectParser {
+
+ public static String NEGATE_STATISTIC = "notBooleanStatistic";
+
+ public String getParserName() {
+ return NEGATE_STATISTIC;
+ }
+
+ public Object parseXMLObject(XMLObject xo) throws XMLParseException {
+
+ BooleanStatistic booleanStatistic = (BooleanStatistic)
xo.getChild(BooleanStatistic.class);
+ return new NotBooleanStatistic(booleanStatistic);
+ }
+
+
//************************************************************************
+ // AbstractXMLObjectParser implementation
+
//************************************************************************
+
+ public String getParserDescription() {
+ return "This element returns a statistic that is the element-wise
negation of the child boolean statistic.";
+ }
+
+ public Class getReturnType() {
+ return BooleanStatistic.class;
+ }
+
+ public XMLSyntaxRule[] getSyntaxRules() {
+ return rules;
+ }
+
+ private XMLSyntaxRule[] rules = new XMLSyntaxRule[]{
+ new ElementRule(BooleanStatistic.class),
+ };
+
+}
=======================================
--- /trunk/src/dr/app/beast/release_parsers.properties Fri Feb 24 03:23:30
2012
+++ /trunk/src/dr/app/beast/release_parsers.properties Thu Mar 8 12:33:19
2012
@@ -1,7 +1,7 @@
#
# release_parsers.properties
#
-# Copyright (c) 2002-2011 Alexei Drummond, Andrew Rambaut and Marc Suchard
+# Copyright (c) 2002-2012 Alexei Drummond, Andrew Rambaut and Marc Suchard
#
# This file is part of BEAST.
# See the NOTICE file distributed with this work for additional
@@ -294,6 +294,7 @@
dr.inferencexml.model.RPNcalculatorStatisticParser
dr.inferencexml.model.TestStatisticParser
dr.inferencexml.model.NotStatisticParser
+dr.inferencexml.model.NotBooleanStatisticParser
dr.inferencexml.model.SubStatisticParser
dr.inferencexml.model.ThreadedCompoundLikelihoodParser