Prints the rule, reaction, and event formulas in a given SBML document.
49 def printFunctionDefinition(n, fd):
51 print(
"FunctionDefinition " + str(n) +
", " + fd.getId());
56 if (math.getNumChildren() > 1):
57 print(
"(" + (math.getLeftChild()).getName());
59 for n
in range (1, math.getNumChildren()):
60 print(
", " + (math.getChild(n)).getName());
65 if (math.getNumChildren() == 0):
66 print(
"(no body defined)");
68 math = math.getChild(math.getNumChildren() - 1);
70 print(formula +
"\n");
73 def printRuleMath(n, r):
77 if (len(r.getVariable()) > 0):
78 print(
"Rule " + str(n) +
", formula: "
79 + r.getVariable() +
" = " + formula +
"\n");
81 print(
"Rule " + str(n) +
", formula: "
82 + formula +
" = 0" +
"\n");
85 def printReactionMath(n, r):
86 if (r.isSetKineticLaw()):
87 kl = r.getKineticLaw();
90 print(
"Reaction " + str(n) +
", formula: " + formula +
"\n");
93 def printEventAssignmentMath(n, ea):
95 variable = ea.getVariable();
97 print(
" EventAssignment " + str(n)
98 +
", trigger: " + variable +
" = " + formula +
"\n");
101 def printEventMath(n, e):
104 print(
"Event " + str(n) +
" delay: " + formula +
"\n");
106 if (e.isSetTrigger()):
108 print(
"Event " + str(n) +
" trigger: " + formula +
"\n");
110 for i
in range(0,e.getNumEventAssignments()):
111 printEventAssignmentMath(i + 1, e.getEventAssignment(i));
116 for n
in range(0,m.getNumFunctionDefinitions()):
117 printFunctionDefinition(n + 1, m.getFunctionDefinition(n));
119 for n
in range(0,m.getNumRules()):
120 printRuleMath(n + 1, m.getRule(n));
124 for n
in range(0, m.getNumReactions()):
125 printReactionMath(n + 1, m.getReaction(n));
129 for n
in range(0,m.getNumEvents()):
130 printEventMath(n + 1, m.getEvent(n));
134 """Usage: printMath filename
137 print(
"\n" +
"Usage: printMath filename" +
"\n" +
"\n");
143 if (document.getNumErrors() > 0):
144 print(
"Encountered the following SBML errors:" +
"\n");
145 document.printErrors();
148 model = document.getModel();
151 print(
"No model present." +
"\n");
158 if __name__ ==
'__main__':