Validates one or more SBML files.
49 def __init__(self, ucheck):
54 def validate(self, file):
55 if not os.path.exists(file):
56 print(
"[Error] %s : No such file." % infile)
63 timeRead = (stop - start)*1000
64 errors = sbmlDoc.getNumErrors()
74 for i
in range(errors):
75 severity = sbmlDoc.getError(i).getSeverity()
76 if (severity == libsbml.LIBSBML_SEV_ERROR)
or (severity == libsbml.LIBSBML_SEV_FATAL):
82 errMsgRead = sbmlDoc.getErrorLog().toString()
96 errMsgRead +=
"Further consistency checking and validation aborted." 99 sbmlDoc.setConsistencyChecks(libsbml.LIBSBML_CAT_UNITS_CONSISTENCY, self.ucheck)
101 failures = sbmlDoc.checkConsistency()
103 timeCC = (stop - start)*1000
109 for i
in range(failures):
110 severity = sbmlDoc.getError(i).getSeverity()
111 if (severity == libsbml.LIBSBML_SEV_ERROR)
or (severity == libsbml.LIBSBML_SEV_FATAL):
120 errMsgCC = sbmlDoc.getErrorLog().toString()
126 print(
" filename : %s" % file)
127 print(
" file size (byte) : %d" % (os.path.getsize(file)))
128 print(
" read time (ms) : %f" % timeRead)
131 print(
" c-check time (ms) : %f" % timeCC)
133 print(
" c-check time (ms) : skipped")
135 print(
" validation error(s) : %d" % (numReadErr + numCCErr))
137 print(
" (consistency error(s)): %d" % numCCErr)
139 print(
" (consistency error(s)): skipped")
141 print(
" validation warning(s) : %d" % (numReadWarn + numCCWarn))
143 print(
" (consistency warning(s)): %d" % numCCWarn)
145 print(
" (consistency warning(s)): skipped")
147 if errMsgRead
or errMsgCC:
149 print(
"===== validation error/warning messages =====\n")
153 print(
"*** consistency check ***\n")
158 """usage: validateSBML.py [-u] inputfile1 [inputfile2 ...] 159 -u skips unit consistency check 164 elif (len(args) == 1)
and (args[1] ==
"-u"):
168 enableUnitCCheck =
True 171 enableUnitCCheck =
False 173 validator = validateSBML(enableUnitCCheck)
177 for i
in range(1,len(args)):
180 print(
"---------------------------------------------------------------------------")
181 validator.validate(args[i])
184 numinvalid = validator.numinvalid
186 print(
"---------------------------------------------------------------------------")
187 print(
"Validated %d files, %d valid files, %d invalid files" % (fnum, fnum - numinvalid, numinvalid))
188 if not enableUnitCCheck:
189 print(
"(Unit consistency checks skipped)")
194 if __name__ ==
'__main__':