Debian Codegraph @

src/dr/evomodelxml/coalescent/GMRFBivariateCurveAnalysisParser.java

raw symbols SCIP
1 /*
2 * GMRFBivariateCurveAnalysisParser.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.evomodelxml.coalescent;
27
28 import dr.evomodel.coalescent.GMRFBivariateCurveAnalysis;
29 import dr.inferencexml.trace.TraceAnalysisParser;
30 import dr.xml.*;
31
32 import java.io.File;
33
34 /**
35 *
36 */
37 public class GMRFBivariateCurveAnalysisParser extends AbstractXMLObjectParser {
38
39 private static final String GMRF_BIVARIATE_CURVE_ANALYSIS = "gmrfBivariateCurveAnalysis";
40 private static final String END_TIME = "endTime";
41 private static final String FILE_NAME_ONE = "fileName1";
42 private static final String FILE_NAME_TWO = "fileName2";
43
44 public String getParserName() {
45 return GMRF_BIVARIATE_CURVE_ANALYSIS;
46 }
47
48 public String getParserDescription() {
49 return "Integrates two curves";
50 }
51
52 public Class getReturnType() {
53 return GMRFBivariateCurveAnalysis.class;
54 }
55
56 public Object parseXMLObject(XMLObject xo) throws XMLParseException {
57 String[] inputFileName = {
58 xo.getStringAttribute(FILE_NAME_ONE),
59 xo.getStringAttribute(FILE_NAME_TWO)};
60
61 File[] file = new File[2];
62 String[] name = new String[2];
63 String[] parent = new String[2];
64
65 for (int i = 0; i < inputFileName.length; i++) {
66 file[i] = new File(inputFileName[i]);
67 name[i] = file[i].getName();
68 parent[i] = file[i].getParent();
69
70 if (!file[i].isAbsolute()) {
71 parent[i] = System.getProperty("user.dir");
72 }
73
74 file[i] = new File(parent[i], name[i]);
75 inputFileName[i] = file[i].getName();
76 }
77
78 int burnin = -1;
79 if (xo.hasAttribute(TraceAnalysisParser.BURN_IN)) {
80 burnin = xo.getIntegerAttribute(TraceAnalysisParser.BURN_IN);
81 }
82
83 double endTime = xo.getDoubleAttribute(END_TIME);
84
85 try {
86 GMRFBivariateCurveAnalysis analysis = new GMRFBivariateCurveAnalysis(inputFileName, endTime, burnin);
87
88 // analysis.integrationReport();
89 analysis.densityReport();
90 } catch (Exception e) {
91 System.err.println(e.getMessage());
92 }
93 return null;
94 }
95
96 public XMLSyntaxRule[] getSyntaxRules() {
97 return new XMLSyntaxRule[]{
98 AttributeRule.newStringRule(FILE_NAME_ONE, false),
99 AttributeRule.newStringRule(FILE_NAME_TWO, false),
100 AttributeRule.newStringRule(END_TIME, false),
101 AttributeRule.newIntegerRule(TraceAnalysisParser.BURN_IN, true),
102 };
103 }
104
105 }