Example of creating a custom validator to be called during validation.
56 def __init__(self, orig = None):
58 super(MyCustomValidator,self).__init__()
60 super(MyCustomValidator,self).__init__(orig)
62 return MyCustomValidator(self)
65 if (self.getDocument() ==
None or self.getModel() ==
None):
69 if (self.getModel().getNumReactions() == 0
and self.getModel().getNumRules() == 0):
74 for i
in range(0, self.getModel().getNumRules()):
75 if (self.getModel().getRule(i).getTypeCode() == libsbml.SBML_ALGEBRAIC_RULE):
76 self.getErrorLog().add(SBMLError(99999, 3, 1,
77 "This model uses algebraic rules, however this application does not support them.",
79 libsbml.LIBSBML_SEV_WARNING,
80 libsbml.LIBSBML_CAT_SBML
82 numErrors = numErrors + 1;
85 for i
in range (0, self.getModel().getNumReactions()):
87 if (self.getModel().getReaction(i).isSetFast()
and
88 self.getModel().getReaction(i).getFast()):
89 self.getErrorLog().add(SBMLError(99999, 3, 1,
90 "This model uses fast reactions, however this application does not support them.",
92 libsbml.LIBSBML_SEV_WARNING,
93 libsbml.LIBSBML_CAT_SBML
95 numErrors = numErrors + 1;
99 """Usage: addCustomValidator filename
109 document.addValidator(MyCustomValidator());
112 numErrors = document.checkConsistency();
115 document.printErrors();
120 if __name__ ==
'__main__':