/// <summary> /// Gets the SBML Model from a SBML file. If it's not possible to read the SBML file /// a error message is displayed. /// </summary> public Model GetModel(string filename) { var sbmlDoc = libsbml.readSBML(filename); if (sbmlDoc.getNumErrors() > 0) { throw new MoBiException(SBMLConstants.ModelNotRead(sbmlDoc.getErrorLog().ToString())); } convertSBML(sbmlDoc); var model = sbmlDoc.getModel(); SaveSBMLInformation(model, sbmlDoc); return(model); }
/// <summary> /// Converts a SBML document to the latest version (3.1) that is supported. /// </summary> private void convertSBML(SBMLDocument sbmlDoc) { var latestLevel = SBMLDocument.getDefaultLevel(); var latestVersion = SBMLDocument.getDefaultVersion(); if (sbmlDoc.getLevel() == latestLevel || sbmlDoc.getVersion() == latestVersion) { return; } var success = sbmlDoc.setLevelAndVersion(latestLevel, latestVersion); if (!success) { throw new MoBiException(SBMLConstants.CouldNotConvertToActualLevel(latestLevel, latestVersion, sbmlDoc.getLevel(), sbmlDoc.getVersion())); } }