Debian Codegraph @

src/dr/evomodelxml/treelikelihood/ApproximatePoissonTreeLikelihoodParser.java

raw symbols SCIP
1 /*
2 * BeagleTreeLikelihoodParser.java
3 *
4 * Copyright (c) 2002-2016 Alexei Drummond, Andrew Rambaut and Marc Suchard
5 *
6 * This file is part of BEAST.
7 * See the NOTICE file distributed with this work for additional
8 * information regarding copyright ownership and licensing.
9 *
10 * BEAST is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as
12 * published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * BEAST is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with BEAST; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301 USA
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 * @author Andrew Rambaut
37 * @version $Id$
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 // AbstractXMLObjectParser implementation
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 }