Debian Codegraph @

src/dr/inferencexml/distribution/ModelSpecificPseudoPriorLikelihoodParser.java

raw symbols SCIP
1 /*
2 * ModelSpecificPseudoPriorLikelihoodParser.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.inferencexml.distribution;
27
28 import dr.xml.AbstractXMLObjectParser;
29 import dr.xml.XMLObject;
30 import dr.xml.XMLParseException;
31 import dr.xml.XMLSyntaxRule;
32 import dr.inference.distribution.DistributionLikelihood;
33 import dr.inference.distribution.ModelSpecificPseudoPriorLikelihood;
34 import dr.inference.model.Parameter;
35 import dr.math.distributions.Distribution;
36
37 /**
38 * @author Chieh-Hsi Wu
39 */
40 public class ModelSpecificPseudoPriorLikelihoodParser extends AbstractXMLObjectParser {
41 public static final String MODEL_SPECIFIC_PSEUDO_PRIOR = "modelSpecificPseudoPrior";
42 public static final String PRIOR = "priorLik";
43 public static final String PSEUDO_PRIOR = "pseudoPriorLik";
44 public static final String MODELS = "models";
45 public static final String MODEL_INDICATOR = "modelIndicator";
46 public static final String SELECTED_VARIABLE = "selectedVariable";
47
48
49 public String getParserName() {
50 return MODEL_SPECIFIC_PSEUDO_PRIOR;
51 }
52
53 public Object parseXMLObject(XMLObject xo) throws XMLParseException {
54 DistributionLikelihood priorLikelihood = (DistributionLikelihood)xo.getElementFirstChild(PRIOR);
55 DistributionLikelihood pseudoPriorLikelihood = (DistributionLikelihood)xo.getElementFirstChild(PSEUDO_PRIOR);
56 Distribution prior = priorLikelihood.getDistribution();
57 Distribution pseudoPrior = pseudoPriorLikelihood.getDistribution();
58 Parameter modelIndicator = (Parameter)xo.getElementFirstChild(MODEL_INDICATOR);
59 int[] models = xo.getIntegerArrayAttribute(MODELS);
60 Parameter selectedVariable = (Parameter)xo.getElementFirstChild(SELECTED_VARIABLE);
61
62
63 ModelSpecificPseudoPriorLikelihood likelihood =
64 new ModelSpecificPseudoPriorLikelihood(
65 prior,
66 pseudoPrior,
67 modelIndicator,
68 models
69 );
70 likelihood.addData(selectedVariable);
71
72
73 return likelihood;
74 }
75
76 //************************************************************************
77 // AbstractXMLObjectParser implementation
78 //************************************************************************
79
80 public XMLSyntaxRule[] getSyntaxRules() {
81 return rules;
82 }
83
84 private final XMLSyntaxRule[] rules = {
85
86 };
87
88 public String getParserDescription() {
89 return "Calculates the likelihood of some data given some parametric or empirical distribution.";
90 }
91
92 public Class getReturnType() {
93 return ModelSpecificPseudoPriorLikelihood.class;
94 }
95 }