Example of converting an SBML Level 3 model using the Flux Balance Constraints package to a COBRA-style SBML Level 2 model.
47 """usage: convertFbcToCobra.py input-filename output-filename
56 if not os.path.exists(infile):
57 print(
"[Error] %s : No such file." % (infile))
62 sbmldoc = reader.readSBML(infile)
64 if sbmldoc.getNumErrors() > 0:
65 if sbmldoc.getError(0).getErrorId() == libsbml.XMLFileUnreadable:
68 elif sbmldoc.getError(0).getErrorId() == libsbml.XMLFileOperationError:
78 props.addOption(
"convert fbc to cobra",
True,
"Convert FBC model to Cobra model")
79 result = sbmldoc.convert(props)
80 if (result != libsbml.LIBSBML_OPERATION_SUCCESS):
81 print(
"[Error] Conversion failed... (%d)" %(result))
84 writer.writeSBML(sbmldoc, outfile)
85 print(
"[OK] converted file %s to %s" % (infile, outfile))
87 if __name__ ==
'__main__':