Search in sources :

Example 1 with ThriftDataAccessException

use of org.vcell.vcellij.api.ThriftDataAccessException in project vcell by virtualcell.

the class SimulationServiceImpl method getTimePoints.

public List<Double> getTimePoints(SimulationInfo simInfo) throws ThriftDataAccessException, TException {
    SimulationServiceContext simServiceContext = sims.get(simInfo.id);
    if (simServiceContext == null) {
        throw new ThriftDataAccessException("simulation results not found");
    }
    try {
        DataSetControllerImpl datasetController = getDataSetController(simServiceContext);
        ArrayList<Double> times = new ArrayList<Double>();
        double[] timeArray;
        timeArray = datasetController.getDataSetTimes(simServiceContext.vcDataIdentifier);
        for (double t : timeArray) {
            times.add(t);
        }
        return times;
    } catch (Exception e) {
        e.printStackTrace();
        throw new ThriftDataAccessException("failed to retrieve times for simulation: " + e.getMessage());
    }
}
Also used : ArrayList(java.util.ArrayList) ThriftDataAccessException(org.vcell.vcellij.api.ThriftDataAccessException) DataSetControllerImpl(cbit.vcell.simdata.DataSetControllerImpl) XMLStreamException(javax.xml.stream.XMLStreamException) ThriftDataAccessException(org.vcell.vcellij.api.ThriftDataAccessException) SbmlException(org.vcell.sbml.SbmlException) SBMLException(org.sbml.jsbml.SBMLException) XmlParseException(cbit.vcell.xml.XmlParseException) SolverException(cbit.vcell.solver.SolverException) TException(org.apache.thrift.TException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException)

Example 2 with ThriftDataAccessException

use of org.vcell.vcellij.api.ThriftDataAccessException in project vcell by virtualcell.

the class SimulationServiceImpl method computeModel.

public SimulationInfo computeModel(SBMLModel model, SimulationSpec simSpec) throws ThriftDataAccessException, TException {
    try {
        SBMLImporter importer = new SBMLImporter(model.getFilepath(), vcLogger(), true);
        BioModel bioModel = importer.getBioModel();
        return computeModel(bioModel, simSpec, null);
    } catch (Exception exc) {
        exc.printStackTrace(System.out);
        return null;
    }
}
Also used : SBMLImporter(org.vcell.sbml.vcell.SBMLImporter) BioModel(cbit.vcell.biomodel.BioModel) XMLStreamException(javax.xml.stream.XMLStreamException) ThriftDataAccessException(org.vcell.vcellij.api.ThriftDataAccessException) SbmlException(org.vcell.sbml.SbmlException) SBMLException(org.sbml.jsbml.SBMLException) XmlParseException(cbit.vcell.xml.XmlParseException) SolverException(cbit.vcell.solver.SolverException) TException(org.apache.thrift.TException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException)

Example 3 with ThriftDataAccessException

use of org.vcell.vcellij.api.ThriftDataAccessException in project vcell by virtualcell.

the class SimulationServiceImpl method getSBML.

public String getSBML(String vcml, String applicationName) throws ThriftDataAccessException, TException {
    try {
        BioModel bioModel = XmlHelper.XMLToBioModel(new XMLSource(vcml));
        SimulationContext simContext = bioModel.getSimulationContext(applicationName);
        SBMLExporter exporter = new SBMLExporter(simContext, 3, 1, simContext.getGeometry().getDimension() > 0);
        VCellSBMLDoc sbmlDoc = exporter.convertToSBML();
        return sbmlDoc.xmlString;
    } catch (SBMLException | XmlParseException | SbmlException | XMLStreamException e) {
        e.printStackTrace();
        throw new ThriftDataAccessException("failed to generate SBML document: " + e.getMessage());
    }
}
Also used : SBMLException(org.sbml.jsbml.SBMLException) XMLStreamException(javax.xml.stream.XMLStreamException) BioModel(cbit.vcell.biomodel.BioModel) VCellSBMLDoc(org.vcell.sbml.vcell.SBMLExporter.VCellSBMLDoc) ThriftDataAccessException(org.vcell.vcellij.api.ThriftDataAccessException) SBMLExporter(org.vcell.sbml.vcell.SBMLExporter) XmlParseException(cbit.vcell.xml.XmlParseException) SbmlException(org.vcell.sbml.SbmlException) SimulationContext(cbit.vcell.mapping.SimulationContext) XMLSource(cbit.vcell.xml.XMLSource)

Example 4 with ThriftDataAccessException

use of org.vcell.vcellij.api.ThriftDataAccessException in project vcell by virtualcell.

the class SimulationServiceImpl method getData.

public List<Double> getData(SimulationInfo simInfo, VariableInfo varInfo, int timeIndex) throws ThriftDataAccessException, TException {
    SimulationServiceContext simServiceContext = sims.get(simInfo.id);
    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();
        ArrayList<Double> dataList = new ArrayList<Double>();
        for (double d : dataArray) {
            dataList.add(d);
        }
        return dataList;
    } catch (Exception e) {
        e.printStackTrace();
        throw new ThriftDataAccessException("failed to retrieve data for variable " + varInfo.getVariableVtuName() + ": " + e.getMessage());
    }
}
Also used : SimDataBlock(cbit.vcell.simdata.SimDataBlock) ArrayList(java.util.ArrayList) ThriftDataAccessException(org.vcell.vcellij.api.ThriftDataAccessException) DataSetControllerImpl(cbit.vcell.simdata.DataSetControllerImpl) OutputContext(cbit.vcell.simdata.OutputContext) XMLStreamException(javax.xml.stream.XMLStreamException) ThriftDataAccessException(org.vcell.vcellij.api.ThriftDataAccessException) SbmlException(org.vcell.sbml.SbmlException) SBMLException(org.sbml.jsbml.SBMLException) XmlParseException(cbit.vcell.xml.XmlParseException) SolverException(cbit.vcell.solver.SolverException) TException(org.apache.thrift.TException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException)

Example 5 with ThriftDataAccessException

use of org.vcell.vcellij.api.ThriftDataAccessException in project vcell by virtualcell.

the class SimulationServiceImpl method getVariableList.

public List<VariableInfo> getVariableList(SimulationInfo simInfo) throws ThriftDataAccessException, TException {
    SimulationServiceContext simServiceContext = sims.get(simInfo.id);
    if (simServiceContext == null) {
        throw new ThriftDataAccessException("simulation results not found");
    }
    try {
        DataSetControllerImpl datasetController = getDataSetController(simServiceContext);
        OutputContext outputContext = new OutputContext(new AnnotatedFunction[0]);
        final DataIdentifier[] dataIdentifiers;
        try {
            dataIdentifiers = datasetController.getDataIdentifiers(outputContext, simServiceContext.vcDataIdentifier);
        } catch (IOException | DataAccessException e) {
            e.printStackTrace();
            throw new RuntimeException("failed to retrieve variable information: " + e.getMessage(), e);
        }
        ArrayList<VariableInfo> varInfos = new ArrayList<VariableInfo>();
        for (DataIdentifier dataIdentifier : dataIdentifiers) {
            final DomainType domainType;
            if (dataIdentifier.getVariableType().equals(VariableType.VOLUME)) {
                domainType = DomainType.VOLUME;
            } else if (dataIdentifier.getVariableType().equals(VariableType.MEMBRANE)) {
                domainType = DomainType.MEMBRANE;
            } else {
                continue;
            }
            String domainName = "";
            if (dataIdentifier.getDomain() != null) {
                domainName = dataIdentifier.getDomain().getName();
            }
            VariableInfo varInfo = new VariableInfo(dataIdentifier.getName(), dataIdentifier.getDisplayName(), domainName, domainType);
            varInfos.add(varInfo);
        }
        return varInfos;
    } catch (Exception e) {
        e.printStackTrace();
        throw new ThriftDataAccessException("failed to retrieve variable list: " + e.getMessage());
    }
}
Also used : VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) DataIdentifier(cbit.vcell.simdata.DataIdentifier) VariableInfo(org.vcell.vcellij.api.VariableInfo) ArrayList(java.util.ArrayList) IOException(java.io.IOException) OutputContext(cbit.vcell.simdata.OutputContext) XMLStreamException(javax.xml.stream.XMLStreamException) ThriftDataAccessException(org.vcell.vcellij.api.ThriftDataAccessException) SbmlException(org.vcell.sbml.SbmlException) SBMLException(org.sbml.jsbml.SBMLException) XmlParseException(cbit.vcell.xml.XmlParseException) SolverException(cbit.vcell.solver.SolverException) TException(org.apache.thrift.TException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) DomainType(org.vcell.vcellij.api.DomainType) ThriftDataAccessException(org.vcell.vcellij.api.ThriftDataAccessException) DataSetControllerImpl(cbit.vcell.simdata.DataSetControllerImpl) ThriftDataAccessException(org.vcell.vcellij.api.ThriftDataAccessException) DataAccessException(org.vcell.util.DataAccessException)

Aggregations

XmlParseException (cbit.vcell.xml.XmlParseException)5 XMLStreamException (javax.xml.stream.XMLStreamException)5 SBMLException (org.sbml.jsbml.SBMLException)5 SbmlException (org.vcell.sbml.SbmlException)5 ThriftDataAccessException (org.vcell.vcellij.api.ThriftDataAccessException)5 SolverException (cbit.vcell.solver.SolverException)4 IOException (java.io.IOException)4 TException (org.apache.thrift.TException)4 DataAccessException (org.vcell.util.DataAccessException)4 DataSetControllerImpl (cbit.vcell.simdata.DataSetControllerImpl)3 ArrayList (java.util.ArrayList)3 BioModel (cbit.vcell.biomodel.BioModel)2 OutputContext (cbit.vcell.simdata.OutputContext)2 SimulationContext (cbit.vcell.mapping.SimulationContext)1 DataIdentifier (cbit.vcell.simdata.DataIdentifier)1 SimDataBlock (cbit.vcell.simdata.SimDataBlock)1 VCSimulationDataIdentifier (cbit.vcell.solver.VCSimulationDataIdentifier)1 XMLSource (cbit.vcell.xml.XMLSource)1 SBMLExporter (org.vcell.sbml.vcell.SBMLExporter)1 VCellSBMLDoc (org.vcell.sbml.vcell.SBMLExporter.VCellSBMLDoc)1