| 1 |
package dr.inferencexml.operators; |
| 2 |
|
| 3 |
import dr.evomodel.continuous.OrderedLatentLiabilityLikelihood; |
| 4 |
import dr.inference.model.LatentFactorModel; |
| 5 |
import dr.inference.operators.LatentFactorLiabilityGibbsOperator; |
| 6 |
import dr.xml.*; |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
public class LatentFactorLiabilityGibbsOperatorParser extends AbstractXMLObjectParser{ |
| 12 |
public final static String LATENT_FACTOR_LIABILITY_GIBBS_OPERATOR = "latentFactorLiabilityGibbsOperator"; |
| 13 |
public final static String WEIGHT = "weight"; |
| 14 |
|
| 15 |
@Override |
| 16 |
public Object parseXMLObject(XMLObject xo) throws XMLParseException { |
| 17 |
double weight = xo.getDoubleAttribute(WEIGHT); |
| 18 |
LatentFactorModel lfm = (LatentFactorModel) xo.getChild(LatentFactorModel.class); |
| 19 |
OrderedLatentLiabilityLikelihood liabilityLikelihood = (OrderedLatentLiabilityLikelihood) xo.getChild(OrderedLatentLiabilityLikelihood.class); |
| 20 |
|
| 21 |
return new LatentFactorLiabilityGibbsOperator(weight, lfm, liabilityLikelihood); |
| 22 |
} |
| 23 |
|
| 24 |
@Override |
| 25 |
public XMLSyntaxRule[] getSyntaxRules() { |
| 26 |
return rules; |
| 27 |
} |
| 28 |
|
| 29 |
private XMLSyntaxRule[] rules = new XMLSyntaxRule[]{ |
| 30 |
AttributeRule.newDoubleRule(WEIGHT), |
| 31 |
new ElementRule(LatentFactorModel.class), |
| 32 |
new ElementRule(OrderedLatentLiabilityLikelihood.class) |
| 33 |
}; |
| 34 |
|
| 35 |
@Override |
| 36 |
public String getParserDescription() { |
| 37 |
return null; |
| 38 |
} |
| 39 |
|
| 40 |
@Override |
| 41 |
public Class getReturnType() { |
| 42 |
return LatentFactorLiabilityGibbsOperator.class; |
| 43 |
} |
| 44 |
|
| 45 |
@Override |
| 46 |
public String getParserName() { |
| 47 |
return LATENT_FACTOR_LIABILITY_GIBBS_OPERATOR; |
| 48 |
} |
| 49 |
} |