| 1 |
package dr.inferencexml.distribution; |
| 2 |
|
| 3 |
|
| 4 |
import dr.inference.distribution.DeterminentalPointProcessPrior; |
| 5 |
import dr.inference.distribution.RowDimensionPoissonPrior; |
| 6 |
import dr.inference.model.AdaptableSizeFastMatrixParameter; |
| 7 |
import dr.inference.model.MatrixParameterInterface; |
| 8 |
import dr.xml.*; |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
public class RowDimensionPoissonPriorParser extends AbstractXMLObjectParser{ |
| 14 |
public static final String ROW_DIMENSION_POISSON_PRIOR = "rowDimensionPoissonPrior"; |
| 15 |
public static final String UNTRUNCATED_MEAN = "untruncatedMean"; |
| 16 |
public static final String TRANSPOSE = "transpose"; |
| 17 |
|
| 18 |
@Override |
| 19 |
public Object parseXMLObject(XMLObject xo) throws XMLParseException { |
| 20 |
MatrixParameterInterface parameter; |
| 21 |
DeterminentalPointProcessPrior DPP; |
| 22 |
String id = xo.getId(); |
| 23 |
if(xo.getChild(MatrixParameterInterface.class) != null) |
| 24 |
parameter= (MatrixParameterInterface) xo.getChild(MatrixParameterInterface.class); |
| 25 |
else |
| 26 |
parameter= null; |
| 27 |
if(xo.getChild(DeterminentalPointProcessPrior.class) != null) |
| 28 |
DPP = (DeterminentalPointProcessPrior) xo.getChild(DeterminentalPointProcessPrior.class); |
| 29 |
else |
| 30 |
DPP = null; |
| 31 |
double untruncatedMean = xo.getDoubleAttribute(UNTRUNCATED_MEAN); |
| 32 |
boolean transpose = false; |
| 33 |
if(xo.hasAttribute(TRANSPOSE)) |
| 34 |
transpose = xo.getBooleanAttribute(TRANSPOSE); |
| 35 |
|
| 36 |
return new RowDimensionPoissonPrior(id, untruncatedMean, parameter, DPP, transpose); |
| 37 |
} |
| 38 |
|
| 39 |
public XMLSyntaxRule[] getSyntaxRules() { |
| 40 |
return rules; |
| 41 |
} |
| 42 |
|
| 43 |
private XMLSyntaxRule[] rules = new XMLSyntaxRule[]{ |
| 44 |
AttributeRule.newDoubleRule(UNTRUNCATED_MEAN, true), |
| 45 |
AttributeRule.newBooleanRule(TRANSPOSE, true), |
| 46 |
new OrRule( |
| 47 |
new ElementRule(MatrixParameterInterface.class), |
| 48 |
new ElementRule(DeterminentalPointProcessPrior.class) |
| 49 |
) |
| 50 |
}; |
| 51 |
|
| 52 |
@Override |
| 53 |
public String getParserDescription() { |
| 54 |
return null; |
| 55 |
} |
| 56 |
|
| 57 |
@Override |
| 58 |
public Class getReturnType() { |
| 59 |
return RowDimensionPoissonPrior.class; |
| 60 |
} |
| 61 |
|
| 62 |
@Override |
| 63 |
public String getParserName() { |
| 64 |
return ROW_DIMENSION_POISSON_PRIOR; |
| 65 |
} |
| 66 |
} |