Debian Codegraph @

src/dr/evoxml/MicrosatelliteSimulatorParser.java

raw symbols SCIP
1 /*
2 * MicrosatelliteSimulatorParser.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.evoxml;
27
28 import dr.xml.*;
29 import dr.evolution.tree.Tree;
30 import dr.evolution.alignment.Patterns;
31 import dr.evolution.util.Taxa;
32 import dr.evolution.datatype.Microsatellite;
33 import dr.oldevomodel.substmodel.MicrosatelliteModel;
34 import dr.evomodel.branchratemodel.BranchRateModel;
35 import dr.evomodel.branchratemodel.DefaultBranchRateModel;
36 import dr.oldevomodel.sitemodel.GammaSiteModel;
37 import dr.app.seqgen.MicrosatelliteSimulator;
38
39 /**
40 * @author Chieh-Hsi Wu
41 *
42 * Parser for microsatellite simulator
43 *
44 */
45 public class MicrosatelliteSimulatorParser extends AbstractXMLObjectParser {
46 public static final String MICROSATELLITE_SIMULATOR = "microsatelliteSimulator";
47
48 public String getParserName(){
49 return MICROSATELLITE_SIMULATOR;
50 }
51
52
53 public Object parseXMLObject(XMLObject xo) throws XMLParseException {
54
55 Microsatellite msatDataType = (Microsatellite)xo.getChild(Microsatellite.class);
56 Taxa taxa = (Taxa)xo.getChild(Taxa.class);
57 Tree tree = (Tree)xo.getChild(Tree.class);
58 MicrosatelliteModel msatModel = (MicrosatelliteModel)xo.getChild(MicrosatelliteModel.class);
59
60 BranchRateModel brModel = (BranchRateModel)xo.getChild(BranchRateModel.class);
61 if(brModel == null){
62 brModel = new DefaultBranchRateModel();
63 }
64
65 MicrosatelliteSimulator msatSim = new MicrosatelliteSimulator(
66 msatDataType,
67 taxa,
68 tree,
69 new GammaSiteModel(msatModel),
70 brModel
71 );
72
73 Patterns patterns = msatSim.simulateMsatPattern();
74
75 String msatPatId = xo.getAttribute("id","simMsatPat");
76 patterns.setId(msatPatId);
77 MicrosatellitePatternParser.printDetails(patterns);
78 MicrosatellitePatternParser.printMicrosatContent(patterns);
79
80 return patterns;
81
82 }
83
84 public XMLSyntaxRule[] getSyntaxRules() {
85 return new XMLSyntaxRule[]{
86 new ElementRule(Microsatellite.class),
87 new ElementRule(Taxa.class),
88 new ElementRule(Tree.class),
89 new ElementRule(MicrosatelliteModel.class),
90 new ElementRule(BranchRateModel.class, true)
91
92 };
93 }
94
95
96
97 public String getParserDescription(){
98 return "This parser facilliates simulation of microsatellites " +
99 "given a tree and infinitesimal rate model";
100 }
101
102 public Class getReturnType(){
103 return Patterns.class;
104 }
105 }