| 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.evomodelxml.treelikelihood; |
| 27 |
|
| 28 |
import dr.evolution.tree.Tree; |
| 29 |
import dr.evomodel.branchratemodel.BranchRateModel; |
| 30 |
import dr.evomodel.tree.TreeModel; |
| 31 |
import dr.evomodel.treelikelihood.ApproximatePoissonTreeLikelihood; |
| 32 |
import dr.inference.model.Likelihood; |
| 33 |
import dr.xml.*; |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
public class ApproximatePoissonTreeLikelihoodParser extends AbstractXMLObjectParser { |
| 40 |
|
| 41 |
public static final String TREE_LIKELIHOOD = "approximateTreeLikelihood"; |
| 42 |
public static final String DATA = "data"; |
| 43 |
|
| 44 |
public String getParserName() { |
| 45 |
return TREE_LIKELIHOOD; |
| 46 |
} |
| 47 |
|
| 48 |
public Object parseXMLObject(XMLObject xo) throws XMLParseException { |
| 49 |
int sequenceLength = xo.getIntegerAttribute("sequenceLength"); |
| 50 |
Tree dataTree = (Tree) xo.getElementFirstChild("data"); |
| 51 |
TreeModel treeModel = (TreeModel) xo.getChild(TreeModel.class); |
| 52 |
BranchRateModel branchRateModel = (BranchRateModel) xo.getChild(BranchRateModel.class); |
| 53 |
|
| 54 |
return new ApproximatePoissonTreeLikelihood(TREE_LIKELIHOOD, dataTree, sequenceLength, treeModel, branchRateModel); |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
public String getParserDescription() { |
| 62 |
return "This element represents the likelihood of a patternlist on a tree given the site model."; |
| 63 |
} |
| 64 |
|
| 65 |
public Class getReturnType() { |
| 66 |
return Likelihood.class; |
| 67 |
} |
| 68 |
|
| 69 |
public static final XMLSyntaxRule[] rules = { |
| 70 |
AttributeRule.newIntegerRule("sequenceLength", false), |
| 71 |
new ElementRule(DATA, new XMLSyntaxRule[] { |
| 72 |
new ElementRule(Tree.class) |
| 73 |
}), |
| 74 |
new ElementRule(TreeModel.class), |
| 75 |
new ElementRule(BranchRateModel.class, true), |
| 76 |
}; |
| 77 |
|
| 78 |
public XMLSyntaxRule[] getSyntaxRules() { |
| 79 |
return rules; |
| 80 |
} |
| 81 |
} |