use of org.vcell.sbmlsim.api.common.SimData in project vcell by virtualcell.
the class SimulationServiceImpl method getData.
@Override
public SimData getData(SimulationInfo simInfo, VariableInfo varInfo, int timeIndex) throws Exception {
SimulationServiceContext simServiceContext = sims.get(simInfo.getLocalId());
if (simServiceContext == null) {
throw new RuntimeException("simulation results not found");
}
DataSetControllerImpl datasetController = getDataSetController(simServiceContext);
try {
double[] times = datasetController.getDataSetTimes(simServiceContext.vcDataIdentifier);
OutputContext outputContext = new OutputContext(new AnnotatedFunction[0]);
SimDataBlock simDataBlock = datasetController.getSimDataBlock(outputContext, simServiceContext.vcDataIdentifier, varInfo.getVariableVtuName(), times[timeIndex]);
double[] dataArray = simDataBlock.getData();
SimData simData = new SimData();
simData.setData(dataArray);
return simData;
} catch (Exception e) {
e.printStackTrace();
throw new Exception("failed to retrieve data for variable " + varInfo.getVariableVtuName() + ": " + e.getMessage());
}
}
use of org.vcell.sbmlsim.api.common.SimData in project vcell by virtualcell.
the class VCellSimService method getSimData.
public SimData getSimData(SimulationHandle simHandle, VariableInfo varInfo, int timeIndex) throws ExecutableException {
Gson gson = new Gson();
String varInfoJson = gson.toJson(varInfo);
Executable exe = new Executable(new String[] { command().getAbsolutePath(), scriptArgDashes + "simhandle", Long.toString(simHandle.remoteId), scriptArgDashes + "timeindex", Integer.toString(timeIndex), scriptArgDashes + "varinfo", varInfoJson, "simdata" });
int[] expectedReturnCodes = new int[] { 0 };
exe.start(expectedReturnCodes);
SimData simData = gson.fromJson(exe.getStdoutString(), SimData.class);
return simData;
}
use of org.vcell.sbmlsim.api.common.SimData in project vcell by virtualcell.
the class VCellSbmlSimCLI method process_simdata.
private void process_simdata() throws Exception {
Gson gson = new Gson();
SimulationInfo simInfo = null;
if (simhandle != null) {
simInfo = new SimulationInfo(simhandle);
} else {
throw new CliException("simhandle (simulation handle) not specified");
}
VariableInfo varInfo = null;
if (varinfoJSON != null) {
try {
varInfo = gson.fromJson(varinfoJSON, VariableInfo.class);
} catch (Exception e) {
throw new CliException("failed to parse JSON text for varInfo: " + e.getMessage(), e);
}
} else {
throw new CliException("varinfo (variableInfo) not specified");
}
if (timepointIndex == null) {
throw new CliException("timepoint index not specified");
}
if (outputfile == null) {
throw new CliException("outputfile not specified");
}
SimData simdata = simService.getData(simInfo, varInfo, timepointIndex);
String simdataJSON = gson.toJson(simdata);
FileUtils.write(outputfile, simdataJSON);
}
Aggregations