Conversation
Introduces a method to filter out species not referenced in reactions or ODEs from EnzymeML documents, and updates measurements accordingly. Adds unit tests to verify correct removal and preservation of unmodeled species based on the new flag.
Replaced usage of deepcopy with dill serialization for copying model objects in InitMap. Added dill as a dependency in pyproject.toml to support this change.
The deepcopy import was not used in pyenzyme/thinlayers/psyces.py and has been removed to clean up the code.
There was a problem hiding this comment.
Pull Request Overview
This pull request introduces functionality to automatically remove unmodeled species from EnzymeML documents in the thin layer base class, improving data consistency and model handling. The changes enable filtering out species that aren't referenced in reactions or ODE equations, along with their associated measurements.
- Adds a
remove_unmodeled_speciesparameter toBaseThinLayerwith automatic species filtering - Replaces
deepcopywithdillfor better PySCeS model serialization - Adds comprehensive unit tests for the new species removal functionality
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pyenzyme/thinlayers/base.py | Implements core species filtering logic and adds constructor parameter |
| pyenzyme/thinlayers/psyces.py | Switches from deepcopy to dill for model copying |
| pyproject.toml | Adds dill dependency for serialization |
| tests/unit/test_thinlayer.py | Adds comprehensive test suite for species removal functionality |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
The unnecessary 'noqa: F401' comment was removed from the dill import statement in psyces.py, as the import is now used.
The 'remove_unmodeled_species' parameter was removed from BaseThinLayer and related tests. Unmodeled species are now always removed during optimization, simplifying the API and test logic.
Introduces the exclude_unmodeled_species parameter to BaseThinLayer and ThinLayerPysces, allowing control over whether unmodeled species are removed from EnzymeML documents during processing.
|
@jmrohwer As discussed today, I’ve moved the dataset pruning of unmodeled species outside of the Can you test this PR with your data? |
This pull request is based on the discussion in #82 and introduces functionality to automatically remove unmodeled species from EnzymeML documents in the thin layer base class, improves model copying in the Psyces thin layer, and adds comprehensive unit tests for the new behavior. The most important changes are grouped below by theme.
Core functionality: Automatic removal of unmodeled species
remove_unmodeled_speciesparameter to theBaseThinLayerconstructor inpyenzyme/thinlayers/base.py. When enabled, species not referenced in any reaction or ODE equation, as well as measurements containing only such species, are removed from the EnzymeML document. The new static method_remove_unmodeled_speciesimplements this logic.Testing and validation
tests/unit/test_thinlayer.pythat verifies correct removal of unmodeled species and measurements, and ensures the option to preserve unmodeled species works as intended. Includes a mock thin layer for testing.Serialization and model handling
deepcopytodillfor copying PySCeS models into_pysces_modelto improve compatibility and reliability. Also addeddillas a dependency inpyproject.toml. [1] [2] [3]Dependency management
dillas a required dependency topyproject.tomlto support serialization of complex Python objects.These changes improve the robustness of thin layer initialization, ensure data consistency, and provide thorough test coverage for the new species filtering logic.
This change is