Debian Codegraph @

src/dr/evomodel/alloppnet/parsers/AlloppNetworkPriorParser.java

raw symbols SCIP
1 /*
2 * AlloppNetworkPriorParser.java
3 *
4 * Copyright (c) 2002-2017 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.evomodel.alloppnet.parsers;
27
28 import dr.evomodel.alloppnet.speciation.AlloppNetworkPrior;
29 import dr.evomodel.alloppnet.speciation.AlloppNetworkPriorModel;
30 import dr.evomodel.alloppnet.speciation.AlloppSpeciesNetworkModel;
31 import dr.xml.*;
32
33
34 /**
35 *
36 * @author Graham Jones
37 * Date: 01/07/2011
38 */
39
40
41 public class AlloppNetworkPriorParser extends AbstractXMLObjectParser {
42
43 public static final String APSPNETWORKPRIOR = "apspNetworkPrior";
44 public static final String MODEL = "model";
45 public static final String APSPNETWORK = "apspNetwork";
46
47
48 public String getParserName() {
49 return APSPNETWORKPRIOR;
50 }
51
52
53 /*
54 <apspNetworkPrior id="apspnetwork.prior" units="substitutions">
55 <eventRate>
56 <parameter id="apspnetwork.prior.eventRate" value="0.1" lower="0.0" upper="Infinity"/>
57 </eventRate>
58 <apspNetwork>
59 <apspNetwork idref="apspnetwork"/>
60 </apspNetwork>
61 </apspNetworkPrior>
62 */
63 @Override
64 public Object parseXMLObject(XMLObject xo) throws XMLParseException {
65 final XMLObject mxo = xo.getChild(MODEL);
66 final AlloppNetworkPriorModel anpm = (AlloppNetworkPriorModel) mxo.getChild(AlloppNetworkPriorModel.class);
67 final XMLObject asnmxo = xo.getChild(APSPNETWORK);
68 final AlloppSpeciesNetworkModel asnm = (AlloppSpeciesNetworkModel) asnmxo.getChild(AlloppSpeciesNetworkModel.class);
69 return new AlloppNetworkPrior(anpm, asnm);
70 }
71
72 private XMLSyntaxRule[] modelRules() {
73 return new XMLSyntaxRule[]{
74 new ElementRule(AlloppNetworkPriorModel.class)
75 };
76
77 }
78
79 private XMLSyntaxRule[] asnmRules() {
80 return new XMLSyntaxRule[]{
81 new ElementRule(AlloppSpeciesNetworkModel.class)
82 };
83
84 }
85
86 @Override
87 public XMLSyntaxRule[] getSyntaxRules() {
88 return new XMLSyntaxRule[]{
89 new ElementRule(MODEL, modelRules()),
90 new ElementRule(APSPNETWORK, asnmRules()),
91
92 };
93 }
94
95 @Override
96 public String getParserDescription() {
97 return "Prior for an allopolyploid species network.";
98 }
99
100 @Override
101 public Class getReturnType() {
102 return AlloppNetworkPrior.class;
103 }
104
105 }