62 sbmlns = SBMLNamespaces (3, 1,
"layout", 1)
64 document=SBMLDocument(sbmlns)
66 document.setPkgRequired (
"layout",
True)
70 model=document.createModel()
71 model.setId(
"TestModel")
72 document.setModel(model)
76 compartment=model.createCompartment()
77 compartment.setId(
"Compartment_1")
78 compartment.setConstant (
True)
81 species1=model.createSpecies()
82 species1.setId(
"Species_1")
83 species1.setCompartment(compartment.getId())
84 species1.setHasOnlySubstanceUnits (
False)
85 species1.setBoundaryCondition (
False)
86 species1.setConstant (
False)
88 species2=model.createSpecies()
89 species2.setId(
"Species_2")
90 species2.setCompartment(compartment.getId())
91 species2.setCompartment (compartment.getId ())
92 species2.setHasOnlySubstanceUnits (
False)
93 species2.setBoundaryCondition (
False)
94 species2.setConstant (
False)
98 reaction1=model.createReaction()
99 reaction1.setId(
"Reaction_1")
100 reaction1.setReversible(
False)
101 reaction1.setFast (
False)
103 reference1=reaction1.createReactant ()
104 reference1.setSpecies(species1.getId())
105 reference1.setId(
"SpeciesReference_1")
106 reference1.setConstant (
False)
109 reference2= reaction1.createProduct ()
110 reference2.setSpecies(species2.getId())
111 reference2.setId(
"SpeciesReference_2")
112 reference2.setConstant (
False)
114 reaction2=model.createReaction()
115 reaction2.setId(
"Reaction_2")
116 reaction2.setReversible(
False)
117 reaction2.setFast (
False)
119 reference3=reaction2.createReactant ()
120 reference3.setSpecies(species2.getId())
121 reference3.setId(
"SpeciesReference_3")
122 reference3.setConstant (
False)
124 reference4=reaction2.createProduct ()
125 reference4.setSpecies(species1.getId())
126 reference4.setId(
"SpeciesReference_4")
127 reference4.setConstant (
False)
135 layoutns = LayoutPkgNamespaces (3, 1, 1)
145 mplugin = (model.getPlugin (
"layout"))
148 if (mplugin ==
None):
149 print (
"[Fatal Error] Layout Extension Level " + layoutns.getLevel () +
" Version " + layoutns.getVersion () +
" package version " + layoutns.getPackageVersion () +
" is not registered.")
155 layout = mplugin.createLayout ()
156 layout.setId(
"Layout_1")
157 layout.setDimensions(Dimensions(layoutns,400.0,220.0))
161 compartmentGlyph=layout.createCompartmentGlyph()
162 compartmentGlyph.setId(
"CompartmentGlyph_1")
163 compartmentGlyph.setCompartmentId(compartment.getId())
164 compartmentGlyph.setBoundingBox(BoundingBox(layoutns,
"bb1",5,5,390,210))
169 speciesGlyph1=layout.createSpeciesGlyph()
170 speciesGlyph1.setId(
"SpeciesGlyph_1")
171 speciesGlyph1.setSpeciesId(species1.getId())
172 speciesGlyph1.setBoundingBox(BoundingBox(layoutns,
"bb2",80,26,240,24))
174 textGlyph1=layout.createTextGlyph()
175 textGlyph1.setId(
"TextGlyph_01")
176 textGlyph1.setBoundingBox(BoundingBox(layoutns,
"bbA",92,26,228,24))
177 textGlyph1.setOriginOfTextId(speciesGlyph1.getId())
178 textGlyph1.setGraphicalObjectId(speciesGlyph1.getId())
181 speciesGlyph2=layout.createSpeciesGlyph()
182 speciesGlyph2.setId(
"SpeciesGlyph_2")
183 speciesGlyph2.setSpeciesId(species2.getId())
184 speciesGlyph2.setBoundingBox(BoundingBox(layoutns,
"bb3",80,170,240,24))
186 textGlyph2=layout.createTextGlyph()
187 textGlyph2.setId(
"TextGlyph_02")
188 textGlyph2.setBoundingBox(BoundingBox(layoutns,
"bbB",92,170,228,24))
189 textGlyph2.setOriginOfTextId(speciesGlyph2.getId())
190 textGlyph2.setGraphicalObjectId(speciesGlyph2.getId())
194 reactionGlyph1=layout.createReactionGlyph()
195 reactionGlyph1.setId(
"ReactionGlyph_1")
196 reactionGlyph1.setReactionId(reaction1.getId())
198 reactionCurve1=reactionGlyph1.getCurve()
199 ls=reactionCurve1.createLineSegment()
200 ls.setStart(Point(layoutns,165,105))
201 ls.setEnd(Point(layoutns,165,115))
203 reactionGlyph2=layout.createReactionGlyph()
204 reactionGlyph2.setId(
"ReactionGlyph_1")
205 reactionGlyph2.setReactionId(reaction2.getId())
207 reactionCurve2=reactionGlyph2.getCurve()
208 ls=reactionCurve2.createLineSegment()
209 ls.setStart(Point(layoutns,235,105))
210 ls.setEnd(Point(layoutns,235,115))
214 speciesReferenceGlyph1=reactionGlyph1.createSpeciesReferenceGlyph()
215 speciesReferenceGlyph1.setId(
"SpeciesReferenceGlyph_1")
216 speciesReferenceGlyph1.setSpeciesGlyphId(speciesGlyph1.getId())
217 speciesReferenceGlyph1.setSpeciesReferenceId(reference1.getId())
218 speciesReferenceGlyph1.setRole(SPECIES_ROLE_SUBSTRATE)
220 speciesReferenceCurve1=speciesReferenceGlyph1.getCurve()
221 cb=speciesReferenceCurve1.createCubicBezier()
222 cb.setStart(Point(layoutns,165,105))
223 cb.setBasePoint1(Point(layoutns,165,90))
224 cb.setBasePoint2(Point(layoutns,165,90))
225 cb.setEnd(Point(layoutns,195,60))
227 speciesReferenceGlyph2=reactionGlyph1.createSpeciesReferenceGlyph()
228 speciesReferenceGlyph2.setId(
"SpeciesReferenceGlyph_2")
229 speciesReferenceGlyph2.setSpeciesGlyphId(speciesGlyph2.getId())
230 speciesReferenceGlyph2.setSpeciesReferenceId(reference2.getId())
231 speciesReferenceGlyph2.setRole(SPECIES_ROLE_PRODUCT)
233 speciesReferenceCurve2=speciesReferenceGlyph2.getCurve()
234 cb=speciesReferenceCurve2.createCubicBezier()
235 cb.setStart(Point(layoutns,165,115))
236 cb.setBasePoint1(Point(layoutns,165,130))
237 cb.setBasePoint2(Point(layoutns,165,130))
238 cb.setEnd(Point(layoutns,195,160))
241 speciesReferenceGlyph3=reactionGlyph2.createSpeciesReferenceGlyph()
242 speciesReferenceGlyph3.setId(
"SpeciesReferenceGlyph_3")
243 speciesReferenceGlyph3.setSpeciesGlyphId(speciesGlyph2.getId())
244 speciesReferenceGlyph3.setSpeciesReferenceId(reference3.getId())
245 speciesReferenceGlyph3.setRole(SPECIES_ROLE_SUBSTRATE)
247 speciesReferenceCurve3=speciesReferenceGlyph3.getCurve()
248 cb=speciesReferenceCurve3.createCubicBezier()
249 cb.setStart(Point(layoutns,235,115))
250 cb.setBasePoint1(Point(layoutns,235,130))
251 cb.setBasePoint2(Point(layoutns,235,130))
252 cb.setEnd(Point(layoutns,205,160))
254 speciesReferenceGlyph4=reactionGlyph2.createSpeciesReferenceGlyph()
255 speciesReferenceGlyph4.setId(
"SpeciesReferenceGlyph_4")
256 speciesReferenceGlyph4.setSpeciesGlyphId(speciesGlyph1.getId())
257 speciesReferenceGlyph4.setSpeciesReferenceId(reference4.getId())
258 speciesReferenceGlyph4.setRole(SPECIES_ROLE_PRODUCT)
260 speciesReferenceCurve4=speciesReferenceGlyph4.getCurve()
261 cb=speciesReferenceCurve4.createCubicBezier()
262 cb.setStart(Point(layoutns,235,105))
263 cb.setBasePoint1(Point(layoutns,235,90))
264 cb.setBasePoint2(Point(layoutns,235,90))
265 cb.setEnd(Point(layoutns,205,60))
267 writeSBML(document,
"layout_example1_L3-python.xml")