Example demonstrating how to convert SBML documents between SBML Levels.
50 """Usage: convertSBML input-filename output-filename
51 This program will attempt to convert a model either to
52 SBML Level 3 Version 1 (if the model is not already) or, if
53 the model is already expressed in Level 3 Version 1, this
54 program will attempt to convert the model to Level 1 Version 2.
57 latestLevel = SBMLDocument.getDefaultLevel();
58 latestVersion = SBMLDocument.getDefaultVersion();
70 errors = document.getNumErrors();
73 print(
"Encountered the following SBML errors:" +
"\n");
74 document.printErrors();
75 print(
"Conversion skipped. Please correct the problems above first."
86 olevel = document.getLevel();
87 oversion = document.getVersion();
90 if (olevel < latestLevel
or oversion < latestVersion):
91 print (
"Attempting to convert Level " + str(olevel) +
" Version " + str(oversion)
92 +
" model to Level " + str(latestLevel)
93 +
" Version " + str(latestVersion) +
"." +
"\n");
94 success = document.setLevelAndVersion(latestLevel, latestVersion);
96 print (
"Attempting to convert Level " + str(olevel) +
" Version " + str(oversion)
97 +
" model to Level 1 Version 2." +
"\n");
98 success = document.setLevelAndVersion(1, 2);
100 errors = document.getNumErrors();
103 print(
"Unable to perform conversion due to the following:" +
"\n");
104 document.printErrors();
106 print(
"Conversion skipped. Either libSBML does not (yet)" +
"\n"
107 +
"have the ability to convert this model or (automatic)" +
"\n"
108 +
"conversion is not possible in this case." +
"\n");
112 print(
"Information may have been lost in conversion; but a valid model ");
113 print(
"was produced by the conversion.\nThe following information ");
114 print(
"was provided:\n");
115 document.printErrors();
118 print(
"Conversion completed." +
"\n");
122 if __name__ ==
'__main__':