From f8e1e602dce156b479634df04f130a5768a14cb9 Mon Sep 17 00:00:00 2001 From: jcschaff Date: Mon, 27 Oct 2025 10:06:08 -0400 Subject: [PATCH 1/2] parse application parameters --- .gitignore | 4 ++++ pyvcell/vcml/models.py | 5 +++++ pyvcell/vcml/vcml_reader.py | 7 ++++++- pyvcell/vcml/vcml_writer.py | 8 ++++++++ tests/_internal/api/vcell_client/test_publication_api.py | 2 +- 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 843a187..3d0b7f6 100644 --- a/.gitignore +++ b/.gitignore @@ -178,3 +178,7 @@ test_output_1/ examples/test_output/SimID_* /examples/notebooks/*.py /examples/solver_output/zarr/ + +examples/notebooks/workspace/ + +examples/scripts/workspace/ diff --git a/pyvcell/vcml/models.py b/pyvcell/vcml/models.py index 2a8f518..844bddb 100644 --- a/pyvcell/vcml/models.py +++ b/pyvcell/vcml/models.py @@ -32,6 +32,10 @@ class Parameter(VcmlNode): unit: str +class ApplicationParameter(Parameter): + pass + + class ModelParameter(Parameter): pass @@ -370,6 +374,7 @@ class Application(VcmlNode): species_mappings: list[SpeciesMapping] = Field(default_factory=list) reaction_mappings: list[ReactionMapping] = Field(default_factory=list) simulations: list[Simulation] = Field(default_factory=list) + application_parameters: list[ApplicationParameter] = Field(default_factory=list) def __repr__(self) -> str: return f"Application(name={self.name}, geometry={self.geometry}, sims={self.simulation_names})" diff --git a/pyvcell/vcml/vcml_reader.py b/pyvcell/vcml/vcml_reader.py index b0c773c..bd22a60 100644 --- a/pyvcell/vcml/vcml_reader.py +++ b/pyvcell/vcml/vcml_reader.py @@ -144,7 +144,7 @@ def visit_Parameter(self, element: _Element, node: vc.Model | vc.Kinetics) -> No name: str = element.get("Name", default="unnamed") role = element.get("Role", default="user defined") unit = element.get("Unit", default="tbd") - parameter: vc.ModelParameter | vc.KineticsParameter + parameter: vc.ModelParameter | vc.KineticsParameter | vc.ApplicationParameter if strip_namespace(parent.tag) == "ModelParameters": model: vc.Model = node # type: ignore[assignment] model_parameter = vc.ModelParameter(name=name, value=value, role=role, unit=unit) @@ -161,6 +161,11 @@ def visit_Parameter(self, element: _Element, node: vc.Model | vc.Kinetics) -> No ) kinetics.kinetics_parameters.append(kinetics_parameter) parameter = kinetics_parameter + elif strip_namespace(parent.tag) == "ApplicationParameters": + application: vc.Application = node # type: ignore[assignment] + application_parameter = vc.ApplicationParameter(name=name, value=value, role=role, unit=unit) + application.application_parameters.append(application_parameter) + parameter = application_parameter else: raise ValueError("Unexpected parent tag") self.generic_visit(element, parameter) diff --git a/pyvcell/vcml/vcml_writer.py b/pyvcell/vcml/vcml_writer.py index 519adb7..46facaf 100644 --- a/pyvcell/vcml/vcml_writer.py +++ b/pyvcell/vcml/vcml_writer.py @@ -119,6 +119,14 @@ def write_application(self, application: Application, parent: _Element) -> None: parent.append(geometry_element) self.write_geometry(application.geometry, geometry_element) + # ---- application parameters ----- + application_parameters_element = Element("ApplicationParameters") + parent.append(application_parameters_element) + for parameter in application.application_parameters: + parameter_element = Element("Parameter", Name=parameter.name, Role=parameter.role, Unit=parameter.unit) + parameter_element.text = str(parameter.value) + application_parameters_element.append(parameter_element) + # ---- geometry context ----- geometry_context_element = Element("GeometryContext") parent.append(geometry_context_element) diff --git a/tests/_internal/api/vcell_client/test_publication_api.py b/tests/_internal/api/vcell_client/test_publication_api.py index 81945fb..de7e465 100644 --- a/tests/_internal/api/vcell_client/test_publication_api.py +++ b/tests/_internal/api/vcell_client/test_publication_api.py @@ -49,4 +49,4 @@ def test_get_publications() -> None: mathmodel_refs=[], var_date=date(year=2024, month=11, day=26), ) - assert pubs[0] == example_pub + assert example_pub in pubs From 13985a74fef836905fb99c478d7f56107a5bdc0b Mon Sep 17 00:00:00 2001 From: jcschaff Date: Mon, 27 Oct 2025 10:19:24 -0400 Subject: [PATCH 2/2] bump version to 0.1.19 --- README.md | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 44565ca..083e26b 100644 --- a/README.md +++ b/README.md @@ -77,4 +77,4 @@ coming soon. ### Geometry import example -[![Open in Colab ](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/14L3WaV42PEu7NvAQdil7i8mEL4WTPF9h?usp=sharing) \ No newline at end of file +[![Open in Colab ](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/14L3WaV42PEu7NvAQdil7i8mEL4WTPF9h?usp=sharing) diff --git a/pyproject.toml b/pyproject.toml index 9461b96..c29c55c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pyvcell" -version = "0.1.18" +version = "0.1.19" description = "This is the python wrapper for vcell modeling and simulation" authors = ["Jim Schaff "] repository = "https://github.com/virtualcell/pyvcell"