Debian Codegraph @

src/dr/evomodelxml/speciation/SpeciesTreeBMPriorParser.java

raw symbols SCIP
1 /*
2 * SpeciesTreeBMPriorParser.java
3 *
4 * Copyright (c) 2002-2015 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.speciation;
27
28 import dr.evomodel.speciation.SpeciesTreeBMPrior;
29 import dr.evomodel.speciation.SpeciesTreeModel;
30 import dr.inference.distribution.ParametricDistributionModel;
31 import dr.inference.model.Parameter;
32 import dr.xml.*;
33
34 /**
35 */
36 public class SpeciesTreeBMPriorParser extends AbstractXMLObjectParser {
37 public static final String TIPS = "tipsDistribution";
38
39 public static final String STPRIOR = "STPopulationPrior";
40
41 public static final String LOG_ROOT = "log_root";
42 public static final String STSIGMA = "STsigma";
43 public static final String SIGMA = "sigma";
44
45 public String getParserDescription() {
46 return "";
47 }
48
49 public Class getReturnType() {
50 return SpeciesTreeBMPrior.class;
51 }
52
53 public String getParserName() {
54 return STPRIOR;
55 }
56
57 public Object parseXMLObject(XMLObject xo) throws XMLParseException {
58 final SpeciesTreeModel st = (SpeciesTreeModel) xo.getChild(SpeciesTreeModel.class);
59
60 //ParametricDistributionModel pr = (ParametricDistributionModel) xo.getChild(ParametricDistributionModel.class);
61 final Object child = xo.getChild(SIGMA);
62 Parameter popSigma = child != null ? (Parameter)((XMLObject) child).getChild(Parameter.class) : null;
63 Parameter stSigma = (Parameter)((XMLObject)xo.getChild(STSIGMA)).getChild(Parameter.class);
64
65 final XMLObject cxo = (XMLObject) xo.getChild(TIPS);
66 final ParametricDistributionModel tipsPrior =
67 (ParametricDistributionModel) cxo.getChild(ParametricDistributionModel.class);
68 final boolean logRoot = xo.getAttribute(LOG_ROOT, false);
69 return new SpeciesTreeBMPrior(st, popSigma, stSigma, tipsPrior, logRoot);
70 }
71
72 public XMLSyntaxRule[] getSyntaxRules() {
73 return new XMLSyntaxRule[]{
74 AttributeRule.newBooleanRule(LOG_ROOT, true),
75 new ElementRule(SpeciesTreeModel.class),
76 new ElementRule(TIPS,
77 new XMLSyntaxRule[] { new ElementRule(ParametricDistributionModel.class) }),
78 //new ElementRule(ParametricDistributionModel.class),
79 new ElementRule(SIGMA, new XMLSyntaxRule[] { new ElementRule(Parameter.class) }, true),
80 new ElementRule(STSIGMA, new XMLSyntaxRule[] { new ElementRule(Parameter.class) })
81 };
82 }
83 }