Debian Codegraph @

src/dr/evomodelxml/branchratemodel/FixedDriftModelParser.java

raw symbols SCIP
1 /*
2 * FixedDriftModelParser.java
3 *
4 * Copyright (c) 2002-2015 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.evomodelxml.branchratemodel;
27
28 import dr.evolution.util.TaxonList;
29 import dr.evomodel.branchratemodel.FixedDriftModel;
30 import dr.evomodel.tree.TreeModel;
31 import dr.inference.model.Parameter;
32 import dr.xml.*;
33
34 import java.util.logging.Logger;
35
36 /**
37 * Created by mandevgill on 12/22/14.
38 */
39 public class FixedDriftModelParser extends AbstractXMLObjectParser {
40 public static final String FIXED_DRIFT = "fixedDriftModel";
41 /*
42 public static final String RATE_ONE = "rateOne";
43 public static final String RATE_TWO = "rateTwo";
44 public static final String REMAINING_RATES = "remainingRates";
45 public static final String RATE_ONE_ID = "rateOneID";
46 public static final String RATE_TWO_ID = "rateTwoID";
47 */
48 public static final String BACKBONE_DRIFT = "backboneDrift";
49
50 public static final String OTHER_DRIFT = "otherDrift";
51
52 public static final String BACKBONE_TAXON_LIST = "backboneTaxonList";
53
54 public String getParserName() {
55 return FIXED_DRIFT;
56 }
57
58 public Object parseXMLObject(XMLObject xo) throws XMLParseException {
59
60 /*
61 String idOne = xo.getStringAttribute(RATE_ONE_ID);
62
63 String idTwo = xo.getStringAttribute(RATE_TWO_ID);
64
65 Parameter rateOne = (Parameter) xo.getElementFirstChild(RATE_ONE);
66
67 Parameter rateTwo = (Parameter) xo.getElementFirstChild(RATE_TWO);
68
69 Parameter remainingRates = (Parameter) xo.getElementFirstChild(REMAINING_RATES);
70 */
71
72 TaxonList taxonList = (TaxonList) xo.getElementFirstChild(BACKBONE_TAXON_LIST);
73
74 TreeModel treeModel = (TreeModel) xo.getChild(TreeModel.class);
75
76 Parameter backboneDrift = (Parameter) xo.getElementFirstChild(BACKBONE_DRIFT);
77
78 Parameter otherDrift = (Parameter) xo.getElementFirstChild(OTHER_DRIFT);
79
80 Logger.getLogger("dr.evomodel").info("Using fixed drift model.");
81
82
83 return new FixedDriftModel(treeModel, backboneDrift, otherDrift, taxonList);
84 // return new FixedDriftModel(rateOne, rateTwo, remainingRates, idOne, idTwo);
85 }
86
87 //************************************************************************
88 // AbstractXMLObjectParser implementation
89 //************************************************************************
90
91 public String getParserDescription() {
92 return
93 "This element returns a relaxed drift model.";
94 }
95
96 public Class getReturnType() {
97 return FixedDriftModel.class;
98 }
99
100 public XMLSyntaxRule[] getSyntaxRules() {
101 return rules;
102 }
103
104 private XMLSyntaxRule[] rules = new XMLSyntaxRule[]{
105 new ElementRule(BACKBONE_DRIFT, Parameter.class, "backbone drift rate", false),
106 new ElementRule(OTHER_DRIFT, Parameter.class, "other drift rate", false)
107 /*
108 AttributeRule.newStringRule(RATE_ONE_ID, false),
109 AttributeRule.newStringRule(RATE_TWO_ID, false),
110 new ElementRule(RATE_ONE, Parameter.class, "rate one parameter", false),
111 new ElementRule(RATE_TWO, Parameter.class, "rate two parameter", false),
112 new ElementRule(REMAINING_RATES, Parameter.class, "remaining rates parameter", false)
113 */
114 };
115
116
117 }