Debian Codegraph @

src/dr/evomodel/continuous/RootTraitStatistic.java

raw symbols SCIP
1 /*
2 * RootTraitStatistic.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.evomodel.continuous;
27
28 import dr.inference.model.Statistic;
29 import dr.xml.*;
30
31 /**
32 *
33 * Gabriela Cybis
34 *
35 * */
36 public class RootTraitStatistic extends Statistic.Abstract{
37
38
39 private int dimension;
40 public static final String SAMPLED_ROOT_TRAITS = "sampledRootTraits";
41 private IntegratedMultivariateTraitLikelihood likelihood;
42
43 public RootTraitStatistic( IntegratedMultivariateTraitLikelihood likelihood, String id){
44 this.likelihood=likelihood;
45 setId(id);
46
47 this.dimension = likelihood.dimTrait;
48
49
50
51 }
52
53
54
55
56 public int getDimension() {
57 return dimension;
58 }
59 public String getDimensionName(int dim){
60 return "root." + likelihood.getTraitName() + dim;
61 }
62
63 public double getStatisticValue(int dim) {
64
65 return likelihood.getRootNodeTrait()[dim];
66 }
67
68
69
70
71
72
73
74
75 public static XMLObjectParser PARSER = new AbstractXMLObjectParser() {
76
77 public Object parseXMLObject(XMLObject xo) throws XMLParseException {
78
79 IntegratedMultivariateTraitLikelihood likelihood = (IntegratedMultivariateTraitLikelihood)
80 xo.getChild(IntegratedMultivariateTraitLikelihood.class);
81
82 String id = xo.getId();
83
84 return new RootTraitStatistic(likelihood, id);
85 }
86
87 public XMLSyntaxRule[] getSyntaxRules() {
88 return new XMLSyntaxRule[] {
89 new ElementRule(IntegratedMultivariateTraitLikelihood.class),
90
91 };
92 }
93
94 public String getParserDescription() {
95 return null;
96 }
97
98 public Class getReturnType() {
99 return RootTraitStatistic.class;
100 }
101
102 public String getParserName() {
103 return SAMPLED_ROOT_TRAITS;
104 }
105 };
106
107 }