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());
}
}
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;
}
}
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());
}
}
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());
}
}
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());
}
}
Aggregations