use of org.vcell.stochtest.StochtestCompare.StochtestCompareStatus in project vcell by virtualcell.
the class StochtestCompareService method compareOne.
public void compareOne() throws IllegalArgumentException, SQLException, DataAccessException, XmlParseException, PropertyVetoException, ExpressionException, MappingException, GeometryException, ImageException, IOException {
StochtestCompare stochtestCompare = StochtestDbUtils.acceptNextWaitingStochtestCompare(conFactory);
String biomodelXML = null;
if (stochtestCompare != null) {
try {
StochtestRun stochtestRun1 = StochtestDbUtils.getStochtestRun(conFactory, stochtestCompare.stochtestRun1ref);
StochtestRun stochtestRun2 = StochtestDbUtils.getStochtestRun(conFactory, stochtestCompare.stochtestRun2ref);
if (stochtestRun1.status != StochtestRunStatus.complete) {
throw new RuntimeException("incomplete run status found: " + stochtestRun1.status.name());
}
if (stochtestRun2.status != StochtestRunStatus.complete) {
throw new RuntimeException("incomplete run status found: " + stochtestRun2.status.name());
}
TimeSeriesMultitrialData data1 = StochtestFileUtils.readData(StochtestFileUtils.getStochtestRunDataFile(baseDir, stochtestRun1));
TimeSeriesMultitrialData data2 = StochtestFileUtils.readData(StochtestFileUtils.getStochtestRunDataFile(baseDir, stochtestRun2));
SummaryStatistics results = TimeSeriesMultitrialData.statisticsSummary(data1, data2);
XmlUtil.writeXMLStringToFile(results.results(), new File(baseDir, "stochtestcompare_" + stochtestCompare.key + "_summary.txt").getPath(), false);
StochtestFileUtils.writeVarDiffData(new File(baseDir, "stochtestcompare_" + stochtestCompare.key + "_vardiff.csv"), data1, data2);
StochtestFileUtils.writeKolmogorovSmirnovTest(new File(baseDir, "stochtestcompare_" + stochtestCompare.key + "_kolmogorovSmirnov.csv"), data1, data2);
StochtestFileUtils.writeChiSquareTest(new File(baseDir, "stochtestcompare_" + stochtestCompare.key + "_chiSquared.csv"), data1, data2);
StochtestCompareStatus status = (results.pass()) ? StochtestCompareStatus.not_verydifferent : StochtestCompareStatus.verydifferent;
StochtestDbUtils.finalizeAcceptedStochtestCompare(conFactory, stochtestCompare, status, null, results);
} catch (Exception e) {
StochtestDbUtils.finalizeAcceptedStochtestCompare(conFactory, stochtestCompare, StochtestCompare.StochtestCompareStatus.failed, e.getMessage(), null);
//
// write exception trace to .txt file
//
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
e.printStackTrace(printWriter);
printWriter.flush();
System.out.println(stringWriter.getBuffer().toString());
XmlUtil.writeXMLStringToFile(stringWriter.getBuffer().toString(), new File(baseDir, "stochtestrun_" + stochtestCompare.key + "_error.txt").getPath(), false);
}
} else {
System.out.println("no compare jobs waiting");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Aggregations