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)
108 reference2 = reaction1.createProduct()
109 reference2.setSpecies(species2.getId())
110 reference2.setId(
"SpeciesReference_2")
111 reference2.setConstant(
False)
113 reaction2 = model.createReaction()
114 reaction2.setId(
"Reaction_2")
115 reaction2.setReversible(
False)
116 reaction2.setFast(
False)
118 reference3 = reaction2.createReactant()
119 reference3.setSpecies(species2.getId())
120 reference3.setId(
"SpeciesReference_3")
121 reference3.setConstant(
False)
123 reference4 = reaction2.createProduct()
124 reference4.setSpecies(species1.getId())
125 reference4.setId(
"SpeciesReference_4")
126 reference4.setConstant(
False)
133 layoutns = LayoutPkgNamespaces(3, 1, 1)
142 mplugin = (model.getPlugin(
"layout"))
146 "[Fatal Error] Layout Extension Level " + layoutns.getLevel() +
" Version " + layoutns.getVersion() +
" package version " + layoutns.getPackageVersion() +
" is not registered.")
152 layout = mplugin.createLayout()
153 layout.setId(
"Layout_1")
154 layout.setDimensions(Dimensions(layoutns, 400.0, 220.0))
158 compartmentGlyph = layout.createCompartmentGlyph()
159 compartmentGlyph.setId(
"CompartmentGlyph_1")
160 compartmentGlyph.setCompartmentId(compartment.getId())
161 compartmentGlyph.setBoundingBox(BoundingBox(layoutns,
"bb1", 5, 5, 390, 210))
165 speciesGlyph1 = layout.createSpeciesGlyph()
166 speciesGlyph1.setId(
"SpeciesGlyph_1")
167 speciesGlyph1.setSpeciesId(species1.getId())
168 speciesGlyph1.setBoundingBox(BoundingBox(layoutns,
"bb2", 80, 26, 240, 24))
170 textGlyph1 = layout.createTextGlyph()
171 textGlyph1.setId(
"TextGlyph_01")
172 textGlyph1.setBoundingBox(BoundingBox(layoutns,
"bbA", 92, 26, 228, 24))
173 textGlyph1.setOriginOfTextId(speciesGlyph1.getId())
174 textGlyph1.setGraphicalObjectId(speciesGlyph1.getId())
176 speciesGlyph2 = layout.createSpeciesGlyph()
177 speciesGlyph2.setId(
"SpeciesGlyph_2")
178 speciesGlyph2.setSpeciesId(species2.getId())
179 speciesGlyph2.setBoundingBox(BoundingBox(layoutns,
"bb3", 80, 170, 240, 24))
181 textGlyph2 = layout.createTextGlyph()
182 textGlyph2.setId(
"TextGlyph_02")
183 textGlyph2.setBoundingBox(BoundingBox(layoutns,
"bbB", 92, 170, 228, 24))
184 textGlyph2.setOriginOfTextId(speciesGlyph2.getId())
185 textGlyph2.setGraphicalObjectId(speciesGlyph2.getId())
189 reactionGlyph1 = layout.createReactionGlyph()
190 reactionGlyph1.setId(
"ReactionGlyph_1")
191 reactionGlyph1.setReactionId(reaction1.getId())
193 reactionCurve1 = reactionGlyph1.getCurve()
194 ls = reactionCurve1.createLineSegment()
195 ls.setStart(Point(layoutns, 165, 105))
196 ls.setEnd(Point(layoutns, 165, 115))
198 reactionGlyph2 = layout.createReactionGlyph()
199 reactionGlyph2.setId(
"ReactionGlyph_1")
200 reactionGlyph2.setReactionId(reaction2.getId())
202 reactionCurve2 = reactionGlyph2.getCurve()
203 ls = reactionCurve2.createLineSegment()
204 ls.setStart(Point(layoutns, 235, 105))
205 ls.setEnd(Point(layoutns, 235, 115))
209 speciesReferenceGlyph1 = reactionGlyph1.createSpeciesReferenceGlyph()
210 speciesReferenceGlyph1.setId(
"SpeciesReferenceGlyph_1")
211 speciesReferenceGlyph1.setSpeciesGlyphId(speciesGlyph1.getId())
212 speciesReferenceGlyph1.setSpeciesReferenceId(reference1.getId())
213 speciesReferenceGlyph1.setRole(SPECIES_ROLE_SUBSTRATE)
215 speciesReferenceCurve1 = speciesReferenceGlyph1.getCurve()
216 cb = speciesReferenceCurve1.createCubicBezier()
217 cb.setStart(Point(layoutns, 165, 105))
218 cb.setBasePoint1(Point(layoutns, 165, 90))
219 cb.setBasePoint2(Point(layoutns, 165, 90))
220 cb.setEnd(Point(layoutns, 195, 60))
222 speciesReferenceGlyph2 = reactionGlyph1.createSpeciesReferenceGlyph()
223 speciesReferenceGlyph2.setId(
"SpeciesReferenceGlyph_2")
224 speciesReferenceGlyph2.setSpeciesGlyphId(speciesGlyph2.getId())
225 speciesReferenceGlyph2.setSpeciesReferenceId(reference2.getId())
226 speciesReferenceGlyph2.setRole(SPECIES_ROLE_PRODUCT)
228 speciesReferenceCurve2 = speciesReferenceGlyph2.getCurve()
229 cb = speciesReferenceCurve2.createCubicBezier()
230 cb.setStart(Point(layoutns, 165, 115))
231 cb.setBasePoint1(Point(layoutns, 165, 130))
232 cb.setBasePoint2(Point(layoutns, 165, 130))
233 cb.setEnd(Point(layoutns, 195, 160))
235 speciesReferenceGlyph3 = reactionGlyph2.createSpeciesReferenceGlyph()
236 speciesReferenceGlyph3.setId(
"SpeciesReferenceGlyph_3")
237 speciesReferenceGlyph3.setSpeciesGlyphId(speciesGlyph2.getId())
238 speciesReferenceGlyph3.setSpeciesReferenceId(reference3.getId())
239 speciesReferenceGlyph3.setRole(SPECIES_ROLE_SUBSTRATE)
241 speciesReferenceCurve3 = speciesReferenceGlyph3.getCurve()
242 cb = speciesReferenceCurve3.createCubicBezier()
243 cb.setStart(Point(layoutns, 235, 115))
244 cb.setBasePoint1(Point(layoutns, 235, 130))
245 cb.setBasePoint2(Point(layoutns, 235, 130))
246 cb.setEnd(Point(layoutns, 205, 160))
248 speciesReferenceGlyph4 = reactionGlyph2.createSpeciesReferenceGlyph()
249 speciesReferenceGlyph4.setId(
"SpeciesReferenceGlyph_4")
250 speciesReferenceGlyph4.setSpeciesGlyphId(speciesGlyph1.getId())
251 speciesReferenceGlyph4.setSpeciesReferenceId(reference4.getId())
252 speciesReferenceGlyph4.setRole(SPECIES_ROLE_PRODUCT)
254 speciesReferenceCurve4 = speciesReferenceGlyph4.getCurve()
255 cb = speciesReferenceCurve4.createCubicBezier()
256 cb.setStart(Point(layoutns, 235, 105))
257 cb.setBasePoint1(Point(layoutns, 235, 90))
258 cb.setBasePoint2(Point(layoutns, 235, 90))
259 cb.setEnd(Point(layoutns, 205, 60))
261 writeSBML(document,
"layout_example1_L3-python.xml")