-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add simulations to vcml read/write and vcml driven simulations
- Loading branch information
Showing
14 changed files
with
684 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import os | ||
from pathlib import Path | ||
from typing import Any, Union | ||
|
||
import pyvcell.vcml as vc | ||
|
||
|
||
class VcmlSpatialModel: | ||
""" | ||
Spatial extension of `libsbml.Model`. All class methods are inherited from `libsbml.Model`: see libsbml documentation for more details. | ||
This class is constructed with one of 3 entrypoints: either the filepath to a valid SBMLSpatial model, OR level, version, model_id, OR model_id | ||
""" | ||
|
||
_bio_model: vc.Biomodel | ||
|
||
def __init__(self, filepath: Path) -> None: | ||
reader: vc.VcmlReader = vc.VcmlReader() | ||
# read filepath as string | ||
with open(filepath, "r") as file: | ||
self._bio_model = reader.parse_biomodel(file.read()) | ||
|
||
@property | ||
def bio_model(self) -> vc.Biomodel: | ||
return self._bio_model | ||
|
||
@property | ||
def model(self) -> vc.Model: | ||
if self._bio_model.model is None: | ||
raise ValueError("Model is not defined in the VCML document.") | ||
return self._bio_model.model | ||
|
||
def export(self, filename: Union[os.PathLike[str], str]) -> None: | ||
document = vc.VCMLDocument(biomodel=self._bio_model) | ||
vcml_str: str = vc.VcmlWriter().write_vcml(document=document) | ||
with open(filename, "w") as file: | ||
file.write(vcml_str) | ||
|
||
@property | ||
def model_parameters(self) -> list[vc.ModelParameter]: | ||
if self._bio_model.model is None: | ||
raise ValueError("Model is not defined in the VCML document.") | ||
return self._bio_model.model.model_parameters | ||
|
||
@property | ||
def kinetics_parameters(self) -> list[vc.KineticsParameter]: | ||
kinetics_parameters: list[vc.KineticsParameter] = [] | ||
for reaction in self.model.reactions: | ||
if reaction.kinetics is None: | ||
continue | ||
for param in reaction.kinetics.kinetics_parameters: | ||
param.reaction_name = reaction.name | ||
kinetics_parameters.append(param) | ||
return kinetics_parameters | ||
|
||
@property | ||
def applications(self) -> list[vc.Application]: | ||
return self.bio_model.applications | ||
|
||
@property | ||
def simulations(self) -> list[vc.Simulation]: | ||
sims: list[vc.Simulation] = [] | ||
for app in self.applications: | ||
sims.extend(app.simulations) | ||
return sims |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from tests.fixtures.data_fixtures import solver_output_path, solver_output_simid_jobid, zarr_path # noqa: F401 | ||
from tests.fixtures.model_fixtures import sbml_spatial_model_1d_path, sbml_spatial_model_3d_path # noqa: F401 | ||
from tests.fixtures.vcell_model_fixtures import vcml_spatial_model_1d_path # noqa: F401 | ||
from tests.fixtures.vcell_model_fixtures import vcml_spatial_model_1d_path, vcml_spatial_small_3d_path # noqa: F401 |
Oops, something went wrong.