A command-line program that prints information about the units of measurement used in a given SBML file.
49 """Usage: printUnits filename 53 print(
"Usage: printUnits filename")
59 if document.getNumErrors() > 0:
60 print(
"Encountered the following SBML errors:")
61 document.printErrors()
64 model = document.getModel()
67 print(
"No model present.")
70 for i
in range(0, model.getNumSpecies()):
71 s = model.getSpecies(i)
72 print(
"Species " + str(i) +
": " 73 + UnitDefinition.printUnits(s.getDerivedUnitDefinition()))
75 for i
in range(0,model.getNumCompartments()):
76 c = model.getCompartment(i)
77 print(
"Compartment " + str(i) +
": " 78 + UnitDefinition.printUnits(c.getDerivedUnitDefinition()))
80 for i
in range(0,model.getNumParameters()):
81 p = model.getParameter(i)
82 print(
"Parameter " + str(i) +
": " 83 + UnitDefinition.printUnits(p.getDerivedUnitDefinition()))
85 for i
in range(0,model.getNumInitialAssignments()):
86 ia = model.getInitialAssignment(i)
87 print(
"InitialAssignment " + str(i) +
": " 88 + UnitDefinition.printUnits(ia.getDerivedUnitDefinition()))
90 if ia.containsUndeclaredUnits():
92 print(
" undeclared units: " + tmp)
94 for i
in range(0,model.getNumEvents()):
96 print(
"Event " + str(i) +
": ")
100 + UnitDefinition.printUnits(e.getDelay().getDerivedUnitDefinition()))
102 if e.getDelay().containsUndeclaredUnits():
104 print(
" undeclared units: " + tmp)
106 for j
in range(0,e.getNumEventAssignments()):
107 ea = e.getEventAssignment(j)
108 print(
"EventAssignment " + str(j) +
": " 109 + UnitDefinition.printUnits(ea.getDerivedUnitDefinition()))
111 if ea.containsUndeclaredUnits():
113 print(
" undeclared units: " + tmp)
115 for i
in range(0,model.getNumReactions()):
116 r = model.getReaction(i)
118 print(
"Reaction " + str(i) +
": ")
120 if r.isSetKineticLaw():
121 print(
"Kinetic Law: " 122 + UnitDefinition.printUnits(r.getKineticLaw().getDerivedUnitDefinition()))
124 if r.getKineticLaw().containsUndeclaredUnits():
126 print(
" undeclared units: " + tmp)
128 for j
in range(0,r.getNumReactants()):
129 sr = r.getReactant(j)
131 if sr.isSetStoichiometryMath():
132 print(
"Reactant stoichiometryMath" + str(j) +
": " 133 + UnitDefinition.printUnits(sr.getStoichiometryMath().getDerivedUnitDefinition()))
135 if sr.getStoichiometryMath().containsUndeclaredUnits():
137 print(
" undeclared units: " + tmp)
139 for j
in range(0,r.getNumProducts()):
142 if sr.isSetStoichiometryMath():
143 print(
"Product stoichiometryMath" + str(j) +
": " 144 + UnitDefinition.printUnits(sr.getStoichiometryMath().getDerivedUnitDefinition()))
146 if sr.getStoichiometryMath().containsUndeclaredUnits():
148 print(
" undeclared units: " + tmp)
150 for i
in range(0,model.getNumRules()):
152 print(
"Rule " + str(i) +
": " 153 + UnitDefinition.printUnits(r.getDerivedUnitDefinition()))
155 if r.getStoichiometryMath().containsUndeclaredUnits():
157 print(
" undeclared units: " + tmp)
162 if __name__ ==
'__main__':