@@ -212,10 +212,6 @@ def test_vcml_reader_bunny_3D(vcml_spatial_bunny_3d_path: Path) -> None:
212212 ("background" , 0 , "image" , None ),
213213 ("roi_1" , 1 , "image" , None ),
214214 ]
215- assert [(sv .name , sv .handle , sv .subvolume_type .name , sv .analytic_expr ) for sv in geom .subvolumes ] == [
216- ("background" , 0 , "image" , None ),
217- ("roi_1" , 1 , "image" , None ),
218- ]
219215 assert [(sc .name , sc .subvolume_ref_1 , sc .subvolume_ref_2 ) for sc in geom .surface_classes ] == [
220216 ("background_roi_1_membrane" , "background" , "roi_1" )
221217 ]
@@ -241,6 +237,87 @@ def test_vcml_reader_bunny_3D(vcml_spatial_bunny_3d_path: Path) -> None:
241237 ]
242238
243239
240+ def test_vcml_tutorial_multiapp_pde (vcml_tutorial_multiapp_pde_path : Path ) -> None :
241+ with open (vcml_tutorial_multiapp_pde_path ) as f :
242+ xml_string = f .read ()
243+
244+ biomodel = vc .VcmlReader .biomodel_from_str (xml_string )
245+ assert biomodel is not None and biomodel .name == "Tutorial_MultiApp"
246+ model = biomodel .model
247+ assert model is not None and model .name == "unnamed"
248+
249+ assert [p .name for p in model .model_parameters ] == []
250+ assert [r .name for r in model .reactions ] == ["r0" , "flux0" ]
251+ assert [(c .name , c .dim ) for c in model .compartments ] == [("cyt" , 3 ), ("nuc" , 3 ), ("EC" , 3 ), ("pm" , 2 ), ("nm" , 2 )]
252+ assert [(s .name , s .compartment_name ) for s in model .species ] == [
253+ ("Ran_cyt" , "cyt" ),
254+ ("C_cyt" , "cyt" ),
255+ ("RanC_nuc" , "nuc" ),
256+ ("RanC_cyt" , "cyt" ),
257+ ]
258+
259+ r0 : vc .Reaction = model .reactions [0 ]
260+ assert [(r .name , r .stoichiometry ) for r in r0 .reactants ] == [("RanC_cyt" , 1 )]
261+ assert [(p .name , p .stoichiometry ) for p in r0 .products ] == [("Ran_cyt" , 1 ), ("C_cyt" , 1 )]
262+ assert r0 .kinetics is not None and r0 .kinetics .kinetics_type == "MassAction"
263+ assert r0 .compartment_name == "cyt"
264+ assert {p .name : p .value for p in r0 .kinetics .kinetics_parameters } == {
265+ "J" : "((Kf * RanC_cyt) - ((Kr * Ran_cyt) * C_cyt))" ,
266+ "Kf" : 1.0 ,
267+ "Kr" : 1000.0 ,
268+ }
269+
270+ r1 : vc .Reaction = model .reactions [1 ]
271+ assert [(r .name , r .stoichiometry ) for r in r1 .reactants ] == [("RanC_cyt" , 1 )]
272+ assert [(p .name , p .stoichiometry ) for p in r1 .products ] == [("RanC_nuc" , 1 )]
273+ assert r1 .kinetics is not None and r1 .kinetics .kinetics_type == "GeneralKinetics"
274+ assert r1 .compartment_name == "nm"
275+ assert {p .name : p .value for p in r1 .kinetics .kinetics_parameters } == {
276+ "I" : 0.0 ,
277+ "J" : "(kfl * (RanC_cyt - RanC_nuc))" ,
278+ "kfl" : 2.0 ,
279+ "netValence" : 1.0 ,
280+ }
281+
282+ assert [a .name for a in biomodel .applications ] == ["3D pde" ]
283+ app0 = biomodel .applications [0 ]
284+ assert app0 .stochastic is False
285+
286+ geom = app0 .geometry
287+ assert (geom .name , geom .dim ) == ("Site visit _Application0_20111127_1900085476" , 3 )
288+ assert geom .extent == (74.24 , 74.24 , 26.0 )
289+ assert geom .origin == (0.0 , 0.0 , 0.0 )
290+ assert [(sv .name , sv .handle , sv .subvolume_type .name , sv .image_pixel_value ) for sv in geom .subvolumes ] == [
291+ ("ec" , 0 , "image" , 1 ),
292+ ("cytosol" , 1 , "image" , 2 ),
293+ ("Nucleus" , 2 , "image" , 3 ),
294+ ]
295+ assert [(sc .name , sc .subvolume_ref_1 , sc .subvolume_ref_2 ) for sc in geom .surface_classes ] == [
296+ ("cytosol_ec_membrane" , "cytosol" , "ec" ),
297+ ("Nucleus_cytosol_membrane" , "Nucleus" , "cytosol" ),
298+ ]
299+
300+ assert [
301+ (cm .compartment_name , cm .geometry_class_name , cm .unit_size_0 , cm .boundary_types )
302+ for cm in app0 .compartment_mappings
303+ ] == [
304+ ("cyt" , "cytosol" , 1.0 , ["flux" , "flux" , "flux" , "flux" , "flux" , "flux" ]),
305+ ("nuc" , "Nucleus" , 1.0 , ["flux" , "flux" , "flux" , "flux" , "flux" , "flux" ]),
306+ ("EC" , "ec" , 1.0 , ["flux" , "flux" , "flux" , "flux" , "flux" , "flux" ]),
307+ ("pm" , "cytosol_ec_membrane" , 1.0 , ["flux" , "flux" , "flux" , "flux" , "flux" , "flux" ]),
308+ ("nm" , "Nucleus_cytosol_membrane" , 1.0 , ["flux" , "flux" , "flux" , "flux" , "flux" , "flux" ]),
309+ ]
310+
311+ assert [(sm .species_name , sm .diff_coef , sm .init_conc , sm .boundary_values ) for sm in app0 .species_mappings ] == [
312+ ("Ran_cyt" , 10.0 , 0.0 , []),
313+ ("C_cyt" , 10.0 , 0.0 , []),
314+ ("RanC_cyt" , 10.0 , 0.0 , []),
315+ ("RanC_nuc" , 10.0 , 0.00045 , []),
316+ ]
317+
318+ assert [[(rm .reaction_name , rm .included ) for rm in app0 .reaction_mappings ]] == [[("r0" , True ), ("flux0" , True )]]
319+
320+
244321def test_xml_print_visitor (vcml_spatial_model_1d_path : Path ) -> None :
245322 with open (vcml_spatial_model_1d_path ) as f :
246323 xml_string = f .read ()
0 commit comments