Search in sources :

Example 1 with SimData

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());
    }
}
Also used : SimData(org.vcell.sbmlsim.api.common.SimData) SimDataBlock(cbit.vcell.simdata.SimDataBlock) DataSetControllerImpl(cbit.vcell.simdata.DataSetControllerImpl) OutputContext(cbit.vcell.simdata.OutputContext) XMLStreamException(javax.xml.stream.XMLStreamException) SbmlException(org.vcell.sbml.SbmlException) SBMLException(org.sbml.jsbml.SBMLException) XmlParseException(cbit.vcell.xml.XmlParseException) SolverException(cbit.vcell.solver.SolverException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException)

Example 2 with SimData

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;
}
Also used : SimData(org.vcell.sbmlsim.api.common.SimData) Gson(com.google.gson.Gson)

Example 3 with 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);
}
Also used : SimData(org.vcell.sbmlsim.api.common.SimData) VariableInfo(org.vcell.sbmlsim.api.common.VariableInfo) Gson(com.google.gson.Gson) SimulationInfo(org.vcell.sbmlsim.api.common.SimulationInfo)

Aggregations

SimData (org.vcell.sbmlsim.api.common.SimData)3 Gson (com.google.gson.Gson)2 DataSetControllerImpl (cbit.vcell.simdata.DataSetControllerImpl)1 OutputContext (cbit.vcell.simdata.OutputContext)1 SimDataBlock (cbit.vcell.simdata.SimDataBlock)1 SolverException (cbit.vcell.solver.SolverException)1 XmlParseException (cbit.vcell.xml.XmlParseException)1 IOException (java.io.IOException)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 SBMLException (org.sbml.jsbml.SBMLException)1 SbmlException (org.vcell.sbml.SbmlException)1 SimulationInfo (org.vcell.sbmlsim.api.common.SimulationInfo)1 VariableInfo (org.vcell.sbmlsim.api.common.VariableInfo)1 DataAccessException (org.vcell.util.DataAccessException)1