Debian Codegraph @

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

raw symbols SCIP
1 /*
2 * AlloppSpeciesBindingsIndividualParser.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
30 import dr.evolution.util.Taxon;
31 import dr.evomodel.alloppnet.speciation.AlloppSpeciesBindings;
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
39 /**
40 * Parses an individual from a possibly-allopolyploid species.
41 *
42 * @author Graham Jones
43 * Date: 18/04/2011
44 */
45
46
47 /*
48 *
49 * Parses an individual (which is a list of taxa) from a
50 * possibly-allopolyploid species. Part of parsing a AlloppSpeciesBindings.
51 *
52 */
53
54 public class AlloppSpeciesBindingsIndividualParser extends
55 AbstractXMLObjectParser {
56 public static final String INDIVIDUAL = "individual";
57
58 public String getParserName() {
59 return INDIVIDUAL;
60 }
61
62 @Override
63 public Object parseXMLObject(XMLObject xo) throws XMLParseException {
64 Taxon[] taxa = new Taxon[xo.getChildCount()];
65 for (int nt = 0; nt < taxa.length; ++nt) {
66 taxa[nt] = (Taxon) xo.getChild(nt);
67 }
68 return new AlloppSpeciesBindings.Individual(xo.getId(), taxa);
69 }
70
71 @Override
72 public XMLSyntaxRule[] getSyntaxRules() {
73 return new XMLSyntaxRule[]{
74 new ElementRule(Taxon.class, 1, Integer.MAX_VALUE)
75 };
76 }
77
78
79 @Override
80 public String getParserDescription() {
81 return "Individual specimen from a species, possibly containing multiple genomes.";
82 }
83
84 @Override
85 public Class getReturnType() {
86 return AlloppSpeciesBindings.Individual.class;
87 }
88
89 }
90