use of cbit.vcell.xml.XMLSource in project vcell by virtualcell.
the class ClientDocumentManager method getGeometryFromDatabaseXML.
/**
* Insert the method's description here.
* Creation date: (9/22/2004 5:22:40 PM)
* @return cbit.vcell.mathmodel.MathModel
* @param mathModelXML java.lang.String
*/
private Geometry getGeometryFromDatabaseXML(String geometryXML) throws DataAccessException {
try {
Geometry geometry = XmlHelper.XMLToGeometry(new XMLSource(geometryXML));
geometry.refreshDependencies();
try {
if (geometry.getDimension() > 0) {
geometry.getGeometrySurfaceDescription().updateAll();
}
} catch (Exception e) {
e.printStackTrace(System.out);
throw new DataAccessException("Geometric surface generation error:\n" + e.getMessage());
}
return geometry;
} catch (XmlParseException e) {
e.printStackTrace();
throw new DataAccessException(e.getClass().getName() + ": " + e.getMessage());
}
}
use of cbit.vcell.xml.XMLSource in project vcell by virtualcell.
the class ClientDocumentManager method getMathModelXML.
/**
* Insert the method's description here.
* Creation date: (3/29/2004 4:04:16 PM)
* @return java.lang.String
* @param vType cbit.sql.VersionableType
* @param vKey cbit.sql.KeyValue
*/
private XMLHolder<MathModel> getMathModelXML(KeyValue vKey) throws DataAccessException {
try {
String xmlString = (String) xmlHash.get(vKey);
if (xmlString == null) {
xmlString = sessionManager.getUserMetaDbServer().getMathModelXML(vKey).toString();
if (xmlString != null) {
MathModel mathModel = XmlHelper.XMLToMathModel(new XMLSource(xmlString));
String newXmlString = XmlHelper.mathModelToXML(mathModel);
xmlHash.put(vKey, newXmlString);
return new XMLHolder<MathModel>(newXmlString, mathModel);
} else {
throw new RuntimeException("unexpected: UserMetaDbServer.getMathModelXML() returned null");
}
} else {
return new XMLHolder<MathModel>(xmlString);
}
} catch (ObjectNotFoundException e) {
throw new DataAccessException("MathModel (id=" + vKey + ") does not exist. It either " + "has been deleted or its reference is outdated. Please use menu 'Server->Reconnect' to update document references.");
} catch (Exception e) {
e.printStackTrace(System.out);
throw FailToLoadDocumentExc.createException(e, vKey, this);
}
}
use of cbit.vcell.xml.XMLSource in project vcell by virtualcell.
the class ClientDocumentManager method getGeometry.
/**
* Insert the method's description here.
* Creation date: (11/14/00 4:02:44 PM)
* @return cbit.vcell.biomodel.BioModel
* @param bioModelInfo cbit.vcell.biomodel.BioModelInfo
*/
public Geometry getGeometry(GeometryInfo geometryInfo) throws DataAccessException {
Geometry geometry = null;
try {
XMLSource geomSource = new XMLSource(getGeometryXML(geometryInfo.getVersion().getVersionKey()));
geometry = XmlHelper.XMLToGeometry(geomSource);
} catch (XmlParseException e) {
e.printStackTrace(System.out);
throw new DataAccessException(e.getMessage());
}
try {
if (geometry.getDimension() > 0 && geometry.getGeometrySurfaceDescription().getGeometricRegions() == null) {
geometry.getGeometrySurfaceDescription().updateAll();
}
} catch (Exception e) {
e.printStackTrace(System.out);
// throw new DataAccessException("Geometric surface generation error:\n"+e.getMessage());
}
return geometry;
}
use of cbit.vcell.xml.XMLSource in project vcell by virtualcell.
the class ClientDocumentManager method getMathModelFromDatabaseXML.
/**
* Insert the method's description here.
* Creation date: (9/22/2004 5:22:40 PM)
* @return cbit.vcell.mathmodel.MathModel
* @param mathModelXML java.lang.String
*/
private MathModel getMathModelFromDatabaseXML(XMLHolder<MathModel> mathModelXML) throws DataAccessException {
try {
MathModel mm = mathModelXML.getDocument();
if (mm == null) {
mm = XmlHelper.XMLToMathModel(new XMLSource(mathModelXML.getXmlString()));
}
cacheSimulations(mm.getSimulations());
mm.refreshDependencies();
try {
if (mm.getMathDescription().getGeometry().getDimension() > 0 && mm.getMathDescription().getGeometry().getGeometrySurfaceDescription().getGeometricRegions() == null) {
mm.getMathDescription().getGeometry().getGeometrySurfaceDescription().updateAll();
}
} catch (Exception e) {
e.printStackTrace(System.out);
throw new DataAccessException("Geometric surface generation error:\n" + e.getMessage());
}
return mm;
} catch (XmlParseException e) {
e.printStackTrace();
throw new DataAccessException(e.getClass().getName() + ": " + e.getMessage());
}
}
use of cbit.vcell.xml.XMLSource in project vcell by virtualcell.
the class HybridSolverTester method runHybridTest.
public void runHybridTest(String site) {
try {
double[] timePoints = null;
File mathModelFile = new File(mathModelVCMLFileName);
XMLSource vcmlSource = new XMLSource(mathModelFile);
MathModel mathModel = XmlHelper.XMLToMathModel(vcmlSource);
File simDataDir = mathModelFile.getParentFile();
Simulation sim = mathModel.getSimulations()[0];
// run multiple trials and each run will have a simID = origSimID + i
for (int i = 0; i < numRuns; i++) {
System.out.println("--------------Trial No: " + (startTrialNo + i) + "----------------");
// replace random seed
sim.getSolverTaskDescription().getSmoldynSimulationOptions().setRandomSeed(new Integer(startTrialNo + i));
// create sim job
int jobIndex = startTrialNo + i;
SimulationTask simTask = new SimulationTask(new SimulationJob(sim, jobIndex, null), 0);
/*
* When you want to run the multiple trials on local uncomment the line below.
*/
// ResourceUtil.prepareSolverExecutable(sim.getSolverTaskDescription().getSolverDescription());
/*
* When you want to run the multiple trials on server (without VCell user interface), use the next line of code
* Corresponding changes should be made in the shell script runhybridtest for the location of executable on server
*/
FVSolverStandalone fvSolver = new FVSolverStandalone(simTask, simDataDir, false);
fvSolver.startSolver();
SolverStatus status = fvSolver.getSolverStatus();
while (status.getStatus() != SolverStatus.SOLVER_FINISHED && status.getStatus() != SolverStatus.SOLVER_ABORTED) {
System.out.println("progress: " + (int) (fvSolver.getProgress() * 100) + "%");
// ask status every 2 seconds
Thread.sleep(2000);
status = fvSolver.getSolverStatus();
}
if (status.getStatus() == SolverStatus.SOLVER_FINISHED) {
// get data
VCSimulationIdentifier vcSimID = new VCSimulationIdentifier(sim.getVersion().getVersionKey(), sim.getVersion().getOwner());
VCSimulationDataIdentifier vcSimDataID = new VCSimulationDataIdentifier(vcSimID, jobIndex);
File hdf5File = new File(simDataDir, vcSimDataID.getID() + SimDataConstants.DATA_PROCESSING_OUTPUT_EXTENSION_HDF5);
DataOperationResults.DataProcessingOutputInfo dataProcessingOutputInfo = (DataOperationResults.DataProcessingOutputInfo) DataSetControllerImpl.getDataProcessingOutput(new DataOperation.DataProcessingOutputInfoOP(vcSimDataID, false, null), hdf5File);
if (i == 0) {
// do only one time
timePoints = dataProcessingOutputInfo.getVariableTimePoints();
for (int j = 0; j < varNames.length; j++) {
// row: numTimePoints, col:first col time + numRuns
double[][] data = new double[numRuns + 1][timePoints.length];
data[0] = timePoints;
results.add(data);
}
}
// write into results after each run
for (int j = 0; j < varNames.length; j++) {
results.get(j)[i + 1] = dataProcessingOutputInfo.getVariableStatValues().get(varNames[j]);
}
// delete the file generated for this run
deleteSimFiles(simDataDir, vcSimDataID);
} else {
throw new Exception("Sover did not finish normally." + status);
}
}
// write to output file, tab delimited
if (results != null && results.size() > 0) {
for (int j = 0; j < varNames.length; j++) {
File file = new File(simDataDir, "SimID_" + sim.getVersion().getVersionKey().toString() + "_" + varNames[j] + "_" + startTrialNo + ".txt");
PrintWriter pw = new PrintWriter(file);
double[][] data = results.get(j);
if (data != null) {
for (int k = 0; k < data.length; k++) {
if (!bPrintTime && k == 0) {
continue;
}
String rowStr = (k == 0) ? "Time\t" : ("trialNo_" + (startTrialNo + k - 1) + "\t");
double[] rowData = data[k];
for (int q = 0; q < rowData.length; q++) {
rowStr += rowData[q] + "\t";
}
pw.println(rowStr);
}
}
pw.close();
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Aggregations