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