Debian Codegraph @

src/dr/oldevomodelxml/treelikelihood/MicrosatelliteSamplerTreeLikelihoodParser.java

raw symbols SCIP
1 /*
2 * MicrosatelliteSamplerTreeLikelihoodParser.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.evomodel.branchratemodel.BranchRateModel;
29 import dr.evomodel.branchratemodel.StrictClockBranchRates;
30 import dr.oldevomodel.substmodel.MicrosatelliteModel;
31 import dr.evomodel.tree.MicrosatelliteSamplerTreeModel;
32 import dr.oldevomodel.treelikelihood.MicrosatelliteSamplerTreeLikelihood;
33 import dr.inference.model.Parameter;
34 import dr.xml.*;
35
36 /**
37 * @author Chieh-Hsi Wu
38 *
39 * Parser for MicrosatelliteSamplerTreeLikelihood
40 */
41 @Deprecated // Switching to BEAGLE
42 public class MicrosatelliteSamplerTreeLikelihoodParser extends AbstractXMLObjectParser {
43 public static final String TREE_LIKELIHOOD = "microsatelliteSamplerTreeLikelihood";
44 public static final String MUTATION_RATE = "mutationRate";
45 public static final String BRANCH_RATE_MODEL = "branchRateModel";
46 public String getParserName(){
47 return TREE_LIKELIHOOD;
48 }
49
50 public XMLSyntaxRule[] getSyntaxRules() {
51 return rules;
52 }
53
54 public Object parseXMLObject(XMLObject xo) throws XMLParseException {
55 MicrosatelliteSamplerTreeModel mstModel = (MicrosatelliteSamplerTreeModel)xo.getChild(MicrosatelliteSamplerTreeModel.class);
56 MicrosatelliteModel microsatelliteModel = (MicrosatelliteModel)xo.getChild(MicrosatelliteModel.class);
57
58 BranchRateModel branchRateModel;
59 Object cxo = xo.getChild(BranchRateModel.class);
60
61 if(xo.getChild(BranchRateModel.class) !=null){
62
63 branchRateModel = (BranchRateModel)cxo;
64 System.out.println("BranchRateModel provided to MicrosatelliteSamplerTreeLikelihood");
65
66 }else if(xo.hasChildNamed(MUTATION_RATE)){
67
68 Parameter muRate = (Parameter)xo.getElementFirstChild(MUTATION_RATE);
69 branchRateModel = new StrictClockBranchRates(muRate);
70 System.out.println("mutation rate provided to MicrosatelliteSamplerTreeLikelihood");
71
72 }else{
73 branchRateModel = new StrictClockBranchRates(new Parameter.Default(1.0));
74 }
75
76 return new MicrosatelliteSamplerTreeLikelihood(mstModel,microsatelliteModel, branchRateModel);
77 }
78
79 private final XMLSyntaxRule[] rules = {
80 new ElementRule(MicrosatelliteSamplerTreeModel.class),
81 new ElementRule(MicrosatelliteModel.class),
82 new ElementRule(MUTATION_RATE, new XMLSyntaxRule[]{new ElementRule(Parameter.class)},true),
83 new ElementRule(BranchRateModel.class,true)
84 };
85
86 public String getParserDescription(){
87 return "this parser returns an object of the TreeMicrosatelliteSamplerLikelihood class";
88 }
89
90 public Class getReturnType(){
91 return MicrosatelliteSamplerTreeLikelihood.class;
92 }
93
94
95 }