Example of creating a custom validator to be called during validation.
58 def __init__(self, orig=None):
60 super(MyCustomValidator, self).__init__()
62 super(MyCustomValidator, self).__init__(orig)
65 return MyCustomValidator(self)
69 if self.getDocument()
is None or self.getModel()
is None:
73 if self.getModel().getNumReactions() == 0
and self.getModel().getNumRules() == 0:
78 for i
in range(0, self.getModel().getNumRules()):
79 if self.getModel().getRule(i).getTypeCode() == libsbml.SBML_ALGEBRAIC_RULE:
80 self.getErrorLog().add(SBMLError(99999, 3, 1,
81 "This model uses algebraic rules, however this application does not support them.",
83 libsbml.LIBSBML_SEV_WARNING,
85 libsbml.LIBSBML_CAT_SBML
90 for i
in range(0, self.getModel().getNumReactions()):
92 if (self.getModel().getReaction(i).isSetFast()
and 93 self.getModel().getReaction(i).getFast()):
94 self.getErrorLog().add(SBMLError(99999, 3, 1,
95 "This model uses fast reactions, however this application does not support them.",
97 libsbml.LIBSBML_SEV_WARNING,
99 libsbml.LIBSBML_CAT_SBML
106 """Usage: addCustomValidator filename 116 document.addValidator(MyCustomValidator())
119 numErrors = document.checkConsistency()
122 document.printErrors()
128 if __name__ ==
'__main__':