use of cbit.vcell.solver.OutputFunctionContext in project vcell by virtualcell.
the class SimulationContextDbDriver method getSimulationContextSQL.
/**
* getModel method comment.
*/
private SimulationContext getSimulationContextSQL(QueryHashtable dbc, Connection con, User user, KeyValue simContextKey) throws /*, ReactStepDbDriver reactStepDB*/
SQLException, DataAccessException, IllegalMappingException, PropertyVetoException {
SimulationContext simContext = null;
String sql;
Field[] f = { new cbit.sql.StarField(simContextTable), userTable.userid };
Table[] t = { simContextTable, userTable };
String condition = simContextTable.id.getQualifiedColName() + " = " + simContextKey + " AND " + simContextTable.ownerRef.getQualifiedColName() + " = " + userTable.id.getQualifiedColName();
sql = DatabasePolicySQL.enforceOwnershipSelect(user, f, t, (OuterJoin) null, condition, null, dbSyntax);
// System.out.println(sql);
Statement stmt = con.createStatement();
try {
ResultSet rset = stmt.executeQuery(sql);
if (rset.next()) {
simContext = simContextTable.getSimContext(dbc, con, user, rset, geomDB, modelDB, mathDescDB);
} else {
throw new ObjectNotFoundException("SimulationContext id=" + simContextKey + " not found for user '" + user + "'");
}
} finally {
stmt.close();
}
DataSymbolTable.table.populateDataSymbols(con, simContextKey, simContext.getDataContext(), user, simContext.getModel().getUnitSystem());
ArrayList<AnnotatedFunction> outputFunctionList = ApplicationMathTable.table.getOutputFunctionsSimcontext(con, simContextKey, dbSyntax);
if (outputFunctionList != null) {
OutputFunctionContext outputFnContext = simContext.getOutputFunctionContext();
outputFnContext.setOutputFunctions(outputFunctionList);
}
SimContextTable.table.readAppComponents(con, simContext, dbSyntax);
assignStimuliSQL(con, simContextKey, simContext);
assignStructureMappingsSQL(dbc, con, simContextKey, simContext);
assignSpeciesContextSpecsSQL(con, simContextKey, simContext);
assignReactionSpecsSQL(con, simContextKey, simContext);
for (GeometryClass gc : simContext.getGeometry().getGeometryClasses()) {
try {
StructureSizeSolver.updateUnitStructureSizes(simContext, gc);
} catch (Exception e) {
lg.error("failed to updateUnitStructureSizes", e);
}
}
simContext.getGeometryContext().enforceHierarchicalBoundaryConditions(simContext.getModel().getStructureTopology());
simContext.getModel().refreshDependencies();
assignAnalysisTasksSQL(con, simContextKey, simContext);
// really needed to calculate MembraneMapping parameters that are not stored (inside/outside flux correction factors).
simContext.refreshDependencies();
return simContext;
}
use of cbit.vcell.solver.OutputFunctionContext in project vcell by virtualcell.
the class CLIUtils method exportPDE2HDF5.
public static void exportPDE2HDF5(cbit.vcell.solver.Simulation sim, File userDir, File hdf5OutputFile) throws DataAccessException, IOException {
SimulationContext sc = (SimulationContext) sim.getSimulationOwner();
BioModel bm = sc.getBioModel();
// VCSimulationIdentifier vcSimID = new VCSimulationIdentifier(sim.getKey(), sim.getSimulationInfo().getVersion().getOwner());
User user = new User(userDir.getName(), null);
VCSimulationIdentifier vcSimID = new VCSimulationIdentifier(sim.getKey(), user);
if (sim.getScanCount() > 1) {
throw new IllegalArgumentException("Parameter scans to be implemented");
}
VCSimulationDataIdentifier vcId = new VCSimulationDataIdentifier(vcSimID, 0);
Species[] species = bm.getModel().getSpecies();
String[] variableNames = new String[species.length];
for (int i = 0; i < species.length; i++) {
variableNames[i] = species[i].getCommonName();
}
VariableSpecs variableSpecs = new VariableSpecs(variableNames, ExportConstants.VARIABLE_MULTI);
DataSetControllerImpl dsControllerImpl = new DataSetControllerImpl(null, userDir.getParentFile(), null);
double[] dataSetTimes = dsControllerImpl.getDataSetTimes(vcId);
TimeSpecs timeSpecs = new TimeSpecs(0, dataSetTimes.length - 1, dataSetTimes, ExportConstants.TIME_RANGE);
timeSpecs = new TimeSpecs(0, 0, dataSetTimes, ExportConstants.TIME_RANGE);
int geoMode = ExportConstants.GEOMETRY_FULL;
SpatialSelection[] selections = new SpatialSelection[0];
selections = null;
int axis = 2;
int sliceNumber = 0;
GeometrySpecs geometrySpecs = new GeometrySpecs(selections, axis, sliceNumber, geoMode);
ExportConstants.DataType dataType = ExportConstants.DataType.PDE_VARIABLE_DATA;
boolean switchRowsColumns = false;
// String simulationName,VCSimulationIdentifier vcSimulationIdentifier,ExportParamScanInfo exportParamScanInfo
ExportSpecs.SimNameSimDataID snsdi = new ExportSpecs.SimNameSimDataID(sim.getName(), vcSimID, null);
ExportSpecs.SimNameSimDataID[] simNameSimDataIDs = { snsdi };
int[] exportMultipleParamScans = null;
boolean isHDF5 = true;
FormatSpecificSpecs formatSpecificSpecs = new ASCIISpecs(ExportFormat.CSV, dataType, switchRowsColumns, simNameSimDataIDs, exportMultipleParamScans, csvRoiLayout.var_time_val, isHDF5);
OutputFunctionContext ofc = sc.getOutputFunctionContext();
ArrayList<AnnotatedFunction> outputFunctionsList = ofc.getOutputFunctionsList();
AnnotatedFunction[] af = outputFunctionsList.toArray(new AnnotatedFunction[0]);
OutputContext outputContext = new OutputContext(af);
ExportServiceImpl exportServiceImpl = new ExportServiceImpl();
ASCIIExporter ae = new ASCIIExporter(exportServiceImpl);
String contextName = bm.getName() + ":" + sc.getName();
ExportSpecs exportSpecs = new ExportSpecs(vcId, ExportFormat.HDF5, variableSpecs, timeSpecs, geometrySpecs, formatSpecificSpecs, sim.getName(), contextName);
DataServerImpl dataServerImpl = new DataServerImpl(dsControllerImpl, exportServiceImpl);
FileDataContainerManager fileDataContainerManager = new FileDataContainerManager();
JobRequest jobRequest = JobRequest.createExportJobRequest(vcId.getOwner());
Collection<ExportOutput> eo = ae.makeASCIIData(outputContext, jobRequest, vcId.getOwner(), dataServerImpl, exportSpecs, fileDataContainerManager);
Iterator<ExportOutput> iterator = eo.iterator();
ExportOutput aaa = iterator.next();
if (((ASCIISpecs) exportSpecs.getFormatSpecificSpecs()).isHDF5()) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
// Get location of temp HDF5 file
aaa.writeDataToOutputStream(baos, fileDataContainerManager);
File tempHDF5File = new File(baos.toString());
Files.copy(tempHDF5File, hdf5OutputFile);
tempHDF5File.delete();
}
}
use of cbit.vcell.solver.OutputFunctionContext in project vcell by virtualcell.
the class OutputFunctionsListTableModel method setOutputFunctionContext.
public void setOutputFunctionContext(OutputFunctionContext newValue) {
OutputFunctionContext oldValue = this.outputFunctionContext;
if (oldValue != null) {
oldValue.removePropertyChangeListener(this);
oldValue.getSimulationOwner().removePropertyChangeListener(this);
}
this.outputFunctionContext = newValue;
if (this.outputFunctionContext != null) {
this.outputFunctionContext.addPropertyChangeListener(this);
newValue.getSimulationOwner().addPropertyChangeListener(this);
}
if (newValue == null) {
setData(null);
} else {
fireTableStructureChanged();
setData(newValue.getOutputFunctionsList());
}
}
Aggregations