| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 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 |
|
| 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 |
} |