use of org.vcell.sbmlsim.api.common.VcmlToSbmlResults in project vcell by virtualcell.
the class SimulationServiceImpl method getSBML.
@Override
public VcmlToSbmlResults getSBML(File vcmlFile, String applicationName, File outputFile) throws Exception {
try {
BioModel bioModel = XmlHelper.XMLToBioModel(new XMLSource(vcmlFile));
SimulationContext simContext = bioModel.getSimulationContext(applicationName);
String sbml = XmlHelper.exportSBML(bioModel, 3, 1, 0, simContext.getGeometry().getDimension() > 0, simContext, null);
FileUtils.write(outputFile, sbml);
VcmlToSbmlResults results = new VcmlToSbmlResults();
results.setSbmlFilePath(outputFile);
return results;
} catch (XmlParseException e) {
e.printStackTrace();
throw new Exception("failed to generate SBML document: " + e.getMessage());
}
}
use of org.vcell.sbmlsim.api.common.VcmlToSbmlResults in project vcell by virtualcell.
the class VCellSbmlSimCLI method process_tosbml.
private void process_tosbml() throws Exception {
Gson gson = new Gson();
if (vcmlfile == null) {
throw new CliException("vcmlfile (simulation handle option) not specified");
} else if (!vcmlfile.exists()) {
throw new CliException("simhandle (simulation handle option) not specified");
}
if (outputfile == null) {
throw new CliException("vcmlfile (simulation handle option) not specified");
} else if (!outputfile.exists()) {
throw new CliException("simhandle (simulation handle option) not specified");
}
if (application == null) {
throw new CliException("application (VCML Application name option) not specified");
}
SBMLModel model = null;
if (sbmlfile != null) {
model = new SBMLModel(sbmlfile);
} else {
throw new CliException("sbmlfile (SBML file option) not specified");
}
if (outputfile == null) {
throw new CliException("output file not specified");
}
VcmlToSbmlResults vcmlToSbmlResults = simService.getSBML(vcmlfile, application, outputfile);
String vcmlToSbmlResultsJSON = gson.toJson(vcmlToSbmlResults);
FileUtils.write(outputfile, vcmlToSbmlResultsJSON);
}
use of org.vcell.sbmlsim.api.common.VcmlToSbmlResults in project vcell by virtualcell.
the class VCellSimService method getSBML.
public File getSBML(File vcmlInput, String applicationName, File sbmlOutput) throws ExecutableException {
Gson gson = new Gson();
Executable exe = new Executable(new String[] { command().getAbsolutePath(), scriptArgDashes + "vcmlfile", vcmlInput.getAbsolutePath(), scriptArgDashes + "sbmlfile", sbmlOutput.getAbsolutePath(), "tosbml" });
int[] expectedReturnCodes = new int[] { 0 };
exe.start(expectedReturnCodes);
VcmlToSbmlResults vcmlToSbmlResults = gson.fromJson(exe.getStdoutString(), VcmlToSbmlResults.class);
return new File(vcmlToSbmlResults.getSbmlFilePath());
}
Aggregations