Debian Codegraph @

src/dr/oldevomodelxml/clock/ACLikelihoodParser.java

raw symbols SCIP
1 /*
2 * ACLikelihoodParser.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.oldevomodelxml.clock;
27
28 import dr.oldevomodel.clock.ACLikelihood;
29 import dr.oldevomodel.clock.RateEvolutionLikelihood;
30 import dr.evomodel.tree.TreeModel;
31 import dr.inference.model.Parameter;
32 import dr.xml.*;
33
34 /**
35 */
36 public class ACLikelihoodParser extends AbstractXMLObjectParser {
37
38 public static final String AC_LIKELIHOOD = "ACLikelihood";
39
40 public static final String VARIANCE = "variance";
41 public static final String SHAPE = "shape";
42
43 public static final String DISTRIBUTION = "distribution";
44
45 public String getParserName() {
46 return AC_LIKELIHOOD;
47 }
48
49 public Object parseXMLObject(XMLObject xo) throws XMLParseException {
50
51 TreeModel tree = (TreeModel) xo.getChild(TreeModel.class);
52
53 Parameter ratesParameter = (Parameter) xo.getElementFirstChild(RateEvolutionLikelihood.RATES);
54
55 Parameter rootRate = (Parameter) xo.getElementFirstChild(RateEvolutionLikelihood.ROOTRATE);
56
57 Parameter variance = (Parameter) xo.getElementFirstChild(VARIANCE);
58
59 boolean isEpisodic = xo.getBooleanAttribute(RateEvolutionLikelihood.EPISODIC);
60
61 //Distribution distributionModel = new InverseGaussianDistribution(0,1);
62 //Parameter distribution = (Parameter) xo.getElementFirstChild(DISTRIBUTION);
63 String distribution = xo.getStringAttribute(DISTRIBUTION);
64
65 //boolean isLogSpace = xo.getAttribute(LOGSPACE, false);
66
67 //return new ACLikelihood(tree, ratesParameter, variance, rootRate, isEpisodic, isLogSpace);
68 return new ACLikelihood(tree, ratesParameter, variance, rootRate, isEpisodic, distribution);
69 }
70
71 //************************************************************************
72 // AbstractXMLObjectParser implementation
73 //************************************************************************
74
75 public String getParserDescription() {
76 return
77 "This element returns an object that can calculate the likelihood " +
78 "of rate changes in a tree under the assumption of " +
79 "distributed rate changes among lineages. " +
80 //"(log)normally distributed rate changes among lineages. " +
81 "Specifically, each branch is assumed to draw a rate from a " +
82 "distribution with mean of the rate in the " +
83 //"(log)normal distribution with mean of the rate in the " +
84 "parent branch and the given standard deviation (the variance can be optionally proportional to " +
85 "branch length).";
86 }
87
88 public Class getReturnType() {
89 return ACLikelihood.class;
90 }
91
92
93 public XMLSyntaxRule[] getSyntaxRules() {
94 return rules;
95 }
96
97 private XMLSyntaxRule[] rules = new XMLSyntaxRule[]{
98 new ElementRule(TreeModel.class),
99 new ElementRule(RateEvolutionLikelihood.RATES, Parameter.class, "The branch rates parameter", false),
100 AttributeRule.newBooleanRule(RateEvolutionLikelihood.EPISODIC, false, "true if model is branch length independent, false if length-dependent."),
101 AttributeRule.newStringRule(DISTRIBUTION, false, "The distribution to use"),
102 //AttributeRule.newBooleanRule(LOGSPACE, true, "true if model considers the log of the rates."),
103 new ElementRule(RateEvolutionLikelihood.ROOTRATE, Parameter.class, "The root rate parameter"),
104 new ElementRule(VARIANCE, Parameter.class, "The standard deviation of the distribution"),
105 //new ElementRule(VARIANCE, Parameter.class, "The standard deviation of the (log)normal distribution"),
106 //new ElementRule(DISTRIBUTION, Parameter.class, "The distribution to use"),
107 //new ElementRule(DISTRIBUTION, ParametricDistributionModel.class, "The distribution model for rates among branches", false),
108 };
109 }