| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
package dr.evoxml; |
| 27 |
|
| 28 |
import dr.xml.*; |
| 29 |
import dr.inference.model.Parameter; |
| 30 |
import dr.inference.model.PearsonCorrelation; |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
public class PearsonCorrelationParser extends AbstractXMLObjectParser { |
| 37 |
|
| 38 |
public static final String PEARSON_CORRELATION = "pearsonCorrelation"; |
| 39 |
public static final String LOG = "log"; |
| 40 |
|
| 41 |
public String getParserName() { return PEARSON_CORRELATION; } |
| 42 |
|
| 43 |
public Object parseXMLObject(XMLObject xo) throws XMLParseException { |
| 44 |
|
| 45 |
boolean log = xo.getAttribute(LOG, false); |
| 46 |
Parameter X = (Parameter)xo.getChild(0); |
| 47 |
Parameter Y = (Parameter)xo.getChild(1); |
| 48 |
|
| 49 |
|
| 50 |
PearsonCorrelation pearsonCorrelation = new PearsonCorrelation(X, Y, log); |
| 51 |
return pearsonCorrelation; |
| 52 |
|
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
public String getParserDescription() { |
| 60 |
return "A Pearson Correlation between two Parameters"; |
| 61 |
} |
| 62 |
|
| 63 |
public String getExample() { |
| 64 |
return "<pearsonCorrelation id=\"r\" log=\"true\">\n"+ |
| 65 |
" <parameter idref=\"param1\"/>\n"+ |
| 66 |
" <parameter idref=\"param2\"/>\n"+ |
| 67 |
"</pearsonCorrelation>\n"; |
| 68 |
} |
| 69 |
|
| 70 |
public Class getReturnType() { return PearsonCorrelation.class; } |
| 71 |
|
| 72 |
public XMLSyntaxRule[] getSyntaxRules() { return rules; } |
| 73 |
|
| 74 |
private final XMLSyntaxRule[] rules = { |
| 75 |
|
| 76 |
new ElementRule(Parameter.class, 2, 2), |
| 77 |
|
| 78 |
AttributeRule.newBooleanRule(LOG, true), |
| 79 |
}; |
| 80 |
|
| 81 |
} |