Debian Codegraph @

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

raw symbols SCIP
1 /*
2 * MulSpeciesTreePriorParser.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
29 import dr.evomodel.alloppnet.speciation.MulSpeciesTreeModel;
30 import dr.evomodel.alloppnet.speciation.MulSpeciesTreePrior;
31 import dr.evomodel.speciation.SpeciationModel;
32 import dr.xml.AbstractXMLObjectParser;
33 import dr.xml.ElementRule;
34 import dr.xml.XMLObject;
35 import dr.xml.XMLParseException;
36 import dr.xml.XMLSyntaxRule;
37
38 public class MulSpeciesTreePriorParser extends AbstractXMLObjectParser {
39 public static final String MUL_SPECIES_TREE_PRIOR = "mulSpeciesTreePrior";
40 public static final String MODEL = "model";
41 public static final String MUL_SPECIES_TREE = "mulTree";
42
43
44 public String getParserName() {
45 return MUL_SPECIES_TREE_PRIOR;
46 }
47
48
49 @Override
50 public Object parseXMLObject(XMLObject xo) throws XMLParseException {
51 final XMLObject mxo = xo.getChild(MODEL);
52 final SpeciationModel sppm = (SpeciationModel) mxo.getChild(SpeciationModel.class);
53 final XMLObject mulsptxo = xo.getChild(MUL_SPECIES_TREE);
54 final MulSpeciesTreeModel mulspt = (MulSpeciesTreeModel) mulsptxo.getChild(MulSpeciesTreeModel.class);
55 return new MulSpeciesTreePrior(sppm, mulspt);
56 }
57
58 private XMLSyntaxRule[] modelRules() {
59 return new XMLSyntaxRule[]{
60 new ElementRule(SpeciationModel.class)
61 };
62 }
63
64 private XMLSyntaxRule[] mulsptRules() {
65 return new XMLSyntaxRule[]{
66 new ElementRule(MulSpeciesTreeModel.class)
67 };
68 }
69
70 @Override
71 public XMLSyntaxRule[] getSyntaxRules() {
72 return new XMLSyntaxRule[]{
73 new ElementRule(MODEL, modelRules()),
74 new ElementRule(MUL_SPECIES_TREE, mulsptRules()),
75
76 };
77 }
78
79
80
81 @Override
82 public String getParserDescription() {
83 return "Prior for a multiply-labelled species tree for allopolyploids.";
84 }
85
86 @Override
87 public Class getReturnType() {
88 return MulSpeciesTreePrior.class;
89 }
90
91 }