Debian Codegraph @

src/dr/oldevomodelxml/treelikelihood/AncestralStateTreeLikelihoodParser.java

raw symbols SCIP
1 /*
2 * AncestralStateTreeLikelihoodParser.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.treelikelihood;
27
28 import dr.evolution.alignment.PatternList;
29 import dr.evomodel.branchratemodel.BranchRateModel;
30 import dr.oldevomodel.sitemodel.SiteModel;
31 import dr.evomodel.tree.TreeModel;
32 import dr.oldevomodel.treelikelihood.AncestralStateTreeLikelihood;
33 import dr.xml.*;
34
35 /**
36 */
37 @Deprecated // Switching to BEAGLE
38 public class AncestralStateTreeLikelihoodParser extends AbstractXMLObjectParser {
39
40 public static final String RECONSTRUCTING_TREE_LIKELIHOOD = "ancestralTreeLikelihood";
41 public static final String RECONSTRUCTION_TAG = AncestralStateTreeLikelihood.STATES_KEY;
42 public static final String RECONSTRUCTION_TAG_NAME = "stateTagName";
43 public static final String MAP_RECONSTRUCTION = "useMAP";
44 public static final String MARGINAL_LIKELIHOOD = "useMarginalLikelihood";
45
46 public String[] getParserNames() {
47 return new String[]{
48 getParserName(), "beast_" + getParserName()
49 };
50 }
51
52 public String getParserName() {
53 return RECONSTRUCTING_TREE_LIKELIHOOD;
54 }
55
56 public Object parseXMLObject(XMLObject xo) throws XMLParseException {
57
58 throw new XMLParseException("Ancestral state functionality is only support when using the BEAGLE library.\nAvailable from http://github.com/beagle-dev/beagle-lib/");
59
60 // boolean useAmbiguities = xo.getAttribute(TreeLikelihoodParser.USE_AMBIGUITIES, false);
61 // boolean storePartials = xo.getAttribute(TreeLikelihoodParser.STORE_PARTIALS, true);
62 //
63 // PatternList patternList = (PatternList) xo.getChild(PatternList.class);
64 // TreeModel treeModel = (TreeModel) xo.getChild(TreeModel.class);
65 // SiteModel siteModel = (SiteModel) xo.getChild(SiteModel.class);
66 //
67 // BranchRateModel branchRateModel = (BranchRateModel) xo.getChild(BranchRateModel.class);
68 //
69 // DataType dataType = ((SubstitutionModel) xo.getChild(SubstitutionModel.class)).getDataType();
70 //
71 // boolean useMAP = xo.getAttribute(MAP_RECONSTRUCTION, false);
72 // boolean useMarginalLogLikelihood = xo.getAttribute(MARGINAL_LIKELIHOOD, true);
73 //
74 // // default tag is RECONSTRUCTION_TAG
75 // String tag = xo.getAttribute(RECONSTRUCTION_TAG_NAME, RECONSTRUCTION_TAG);
76 //
77 // boolean forceRescaling = xo.getAttribute(TreeLikelihoodParser.FORCE_RESCALING, false);
78 //
79 // return new AncestralStateTreeLikelihood(patternList, treeModel, siteModel,
80 // branchRateModel, useAmbiguities, storePartials, dataType, tag, forceRescaling,
81 // useMAP, useMarginalLogLikelihood);
82 }
83
84 //************************************************************************
85 // AbstractXMLObjectParser implementation
86 //************************************************************************
87
88 public String getParserDescription() {
89 return "This element represents the likelihood of a patternlist on a tree given the site model.";
90 }
91
92 public Class getReturnType() {
93 return AncestralStateTreeLikelihood.class;
94 }
95
96 public XMLSyntaxRule[] getSyntaxRules() {
97 return rules;
98 }
99
100 private XMLSyntaxRule[] rules = new XMLSyntaxRule[]{
101 AttributeRule.newBooleanRule(TreeLikelihoodParser.USE_AMBIGUITIES, true),
102 AttributeRule.newBooleanRule(TreeLikelihoodParser.STORE_PARTIALS, true),
103 AttributeRule.newStringRule(RECONSTRUCTION_TAG_NAME, true),
104 AttributeRule.newBooleanRule(TreeLikelihoodParser.FORCE_RESCALING, true),
105 AttributeRule.newBooleanRule(MAP_RECONSTRUCTION, true),
106 AttributeRule.newBooleanRule(MARGINAL_LIKELIHOOD, true),
107 new ElementRule(PatternList.class),
108 new ElementRule(TreeModel.class),
109 new ElementRule(SiteModel.class),
110 new ElementRule(BranchRateModel.class, true)
111 };
112 }