Debian Codegraph @

src/dr/evomodelxml/branchmodel/ExternalInternalBranchModelParser.java

raw symbols SCIP
1 /*
2 * ExternalInternalBranchModelParser.java
3 *
4 * Copyright (c) 2002-2016 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.evomodelxml.branchmodel;
27
28 import dr.evomodel.branchmodel.BranchSpecificBranchModel;
29 import dr.evomodel.branchmodel.ExternalInternalBranchModel;
30 import dr.evomodel.substmodel.SubstitutionModel;
31 import dr.evomodel.tree.TreeModel;
32 import dr.xml.*;
33
34 import java.util.logging.Logger;
35
36 /**
37 * @author Andrew Rambaut
38 */
39 public class ExternalInternalBranchModelParser extends AbstractXMLObjectParser {
40
41 public static final String EXTERNAL_INTERNAL_BRANCH_MODEL = "externalInternalBranchModel";
42 public static final String EXTERNAL_BRANCHES = "externalBranches";
43
44 public String getParserName() {
45 return EXTERNAL_INTERNAL_BRANCH_MODEL;
46 }
47
48 public Object parseXMLObject(XMLObject xo) throws XMLParseException {
49
50 Logger.getLogger("dr.evomodel").info("\nUsing external-internal branch model.");
51
52 TreeModel tree = (TreeModel) xo.getChild(TreeModel.class);
53 SubstitutionModel internalSubstitutionModel = (SubstitutionModel) xo.getChild(SubstitutionModel.class);
54 SubstitutionModel externalSubstitutionModel = (SubstitutionModel) xo.getElementFirstChild(EXTERNAL_BRANCHES);
55
56 return new ExternalInternalBranchModel(tree, externalSubstitutionModel, internalSubstitutionModel);
57 }
58
59 //************************************************************************
60 // AbstractXMLObjectParser implementation
61 //************************************************************************
62
63 public String getParserDescription() {
64 return
65 "This element provides a branch model which allows different substitution models" +
66 "on internal and external branches of the tree.";
67 }
68
69 public Class getReturnType() {
70 return BranchSpecificBranchModel.class;
71 }
72
73 public XMLSyntaxRule[] getSyntaxRules() {
74 return rules;
75 }
76
77 private final XMLSyntaxRule[] rules = {
78 new ElementRule(TreeModel.class, "The tree"),
79 new ElementRule(SubstitutionModel.class, "The substitution model for internal branches"),
80 new ElementRule(EXTERNAL_BRANCHES,
81 new XMLSyntaxRule[]{
82 new ElementRule(SubstitutionModel.class, "The external branch substitution model"),
83 }, false)
84 };
85
86 }