Debian Codegraph @

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

raw symbols SCIP
1 /*
2 * AlloppNetworkNodeSlideParser.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.operators.AlloppNetworkNodeSlide;
29 import dr.evomodel.alloppnet.speciation.AlloppSpeciesBindings;
30 import dr.evomodel.alloppnet.speciation.AlloppSpeciesNetworkModel;
31 import dr.inference.operators.MCMCOperator;
32 import dr.xml.AbstractXMLObjectParser;
33 import dr.xml.AttributeRule;
34 import dr.xml.ElementRule;
35 import dr.xml.XMLObject;
36 import dr.xml.XMLParseException;
37 import dr.xml.XMLSyntaxRule;
38
39 /**
40 *
41 * @author Graham Jones
42 * Date: 01/07/2011
43 */
44
45 /*
46
47 <networkNodeReHeight weight="94">
48 <alloppSpecies idref="alloppSpecies"/>
49 <alloppSpeciesNetwork idref="apspnetwork"/>
50 </networkNodeReHeight>
51
52 */
53
54 public class AlloppNetworkNodeSlideParser extends AbstractXMLObjectParser {
55 public static final String NETWORK_NODE_REHEIGHT = "networkNodeReHeight";
56
57
58 public String getParserName() {
59 return NETWORK_NODE_REHEIGHT;
60 }
61
62 @Override
63 public Object parseXMLObject(XMLObject xo) throws XMLParseException {
64 AlloppSpeciesBindings apsp = (AlloppSpeciesBindings) xo.getChild(AlloppSpeciesBindings.class);
65 AlloppSpeciesNetworkModel apspnet = (AlloppSpeciesNetworkModel) xo.getChild(AlloppSpeciesNetworkModel.class);
66
67 final double weight = xo.getDoubleAttribute(MCMCOperator.WEIGHT);
68 return new AlloppNetworkNodeSlide(apspnet, apsp, weight);
69 }
70
71 @Override
72 public XMLSyntaxRule[] getSyntaxRules() {
73 return new XMLSyntaxRule[]{
74 AttributeRule.newDoubleRule(MCMCOperator.WEIGHT),
75 new ElementRule(AlloppSpeciesBindings.class),
76 new ElementRule(AlloppSpeciesNetworkModel.class)
77 };
78 }
79
80 @Override
81 public String getParserDescription() {
82 return "Operator for allopolyploid species network: transforms network without breaking embedding of gene trees.";
83 }
84
85 @Override
86 public Class getReturnType() {
87 return AlloppNetworkNodeSlide.class;
88 }
89
90 }