Search in sources :

Example 1 with VcmlToSbmlResults

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());
    }
}
Also used : VcmlToSbmlResults(org.vcell.sbmlsim.api.common.VcmlToSbmlResults) BioModel(cbit.vcell.biomodel.BioModel) XmlParseException(cbit.vcell.xml.XmlParseException) SimulationContext(cbit.vcell.mapping.SimulationContext) XMLSource(cbit.vcell.xml.XMLSource) 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 VcmlToSbmlResults

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

Example 3 with VcmlToSbmlResults

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

Aggregations

VcmlToSbmlResults (org.vcell.sbmlsim.api.common.VcmlToSbmlResults)3 Gson (com.google.gson.Gson)2 BioModel (cbit.vcell.biomodel.BioModel)1 SimulationContext (cbit.vcell.mapping.SimulationContext)1 SolverException (cbit.vcell.solver.SolverException)1 XMLSource (cbit.vcell.xml.XMLSource)1 XmlParseException (cbit.vcell.xml.XmlParseException)1 File (java.io.File)1 IOException (java.io.IOException)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 SBMLException (org.sbml.jsbml.SBMLException)1 SbmlException (org.vcell.sbml.SbmlException)1 SBMLModel (org.vcell.sbmlsim.api.common.SBMLModel)1 DataAccessException (org.vcell.util.DataAccessException)1