Model flattening example.
47 """usage: flattenModel.py [-p] input-filename output-filename
48 -p : list unused ports
50 if len(args) != 4
and len(args) != 3 :
70 if not os.path.exists(infile):
71 print(
"[Error] %s : No such file." % (infile))
76 sbmldoc = reader.readSBML(infile)
78 if sbmldoc.getNumErrors() > 0:
79 if sbmldoc.getError(0).getErrorId() == libsbml.XMLFileUnreadable:
82 elif sbmldoc.getError(0).getErrorId() == libsbml.XMLFileOperationError:
93 props.addOption(
"flatten comp",
True,
"flatten comp")
94 props.addOption(
"leavePorts", leavePorts,
"unused ports should be listed in the flattened model")
97 result = sbmldoc.convert(props)
98 if (result != libsbml.LIBSBML_OPERATION_SUCCESS):
100 print(
"[Error] Conversion failed... ("+ str(result) +
")")
103 writer.writeSBML(sbmldoc, outfile)
104 print(
"Flat model written to %s" % (outfile))
106 if __name__ ==
'__main__':