Debian Codegraph @

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

raw symbols SCIP
1 /*
2 * BirthDeathCollapseNClustersStatisticParser.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.BirthDeathCollapseModel;
29 import dr.evomodel.alloppnet.speciation.BirthDeathCollapseNClustersStatistic;
30 import dr.evomodel.speciation.SpeciesTreeModel;
31 import dr.xml.*;
32
33 /**
34 * @author Graham Jones
35 * Date: 01/09/2013
36 */
37 public class BirthDeathCollapseNClustersStatisticParser extends AbstractXMLObjectParser {
38 public static final String BDC_NCLUSTERS_STATISTIC = "bdcNClustersStatistic";
39 public static final String SPECIES_TREE = "speciesTree";
40 public static final String COLLAPSE_MODEL = "collapseModel";
41
42
43
44 public String getParserName() {
45 return BDC_NCLUSTERS_STATISTIC;
46 }
47
48
49 @Override
50 public Object parseXMLObject(XMLObject xo) throws XMLParseException {
51 xo.getAttribute("name");
52 final XMLObject spptreexo = xo.getChild(SPECIES_TREE);
53 SpeciesTreeModel spptree = (SpeciesTreeModel) spptreexo.getChild(SpeciesTreeModel.class);
54 final XMLObject cmxo = xo.getChild(COLLAPSE_MODEL);
55 BirthDeathCollapseModel bdcm = (BirthDeathCollapseModel)cmxo.getChild(BirthDeathCollapseModel.class);
56 return new BirthDeathCollapseNClustersStatistic(spptree, bdcm);
57 }
58
59
60 private XMLSyntaxRule[] spptreeRules() {
61 return new XMLSyntaxRule[]{
62 new ElementRule(SpeciesTreeModel.class)
63 };
64 }
65
66 private XMLSyntaxRule[] bdcmRules() {
67 return new XMLSyntaxRule[]{
68 new ElementRule(BirthDeathCollapseModel.class)
69 };
70 }
71
72
73
74 @Override
75 public XMLSyntaxRule[] getSyntaxRules() {
76 return new XMLSyntaxRule[]{
77 AttributeRule.newStringRule("name"),
78 new ElementRule(SPECIES_TREE, spptreeRules()),
79 new ElementRule(COLLAPSE_MODEL, bdcmRules())
80 };
81 }
82
83
84 @Override
85 public String getParserDescription() {
86 return "Statistic for number of collapsed nodes in species tree when using birth-death-collapse model.";
87 }
88
89 @Override
90 public Class getReturnType() {
91 return BirthDeathCollapseNClustersStatistic.class;
92 }
93
94
95 }