Skip to content

Commit 4ab90b1

Browse files
committed
Add exclude_unmodeled_species option to thin layers
Introduces the exclude_unmodeled_species parameter to BaseThinLayer and ThinLayerPysces, allowing control over whether unmodeled species are removed from EnzymeML documents during processing.
1 parent 56bb571 commit 4ab90b1

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

pyenzyme/thinlayers/base.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ class BaseThinLayer(ABC):
3030

3131
enzmldoc: v2.EnzymeMLDocument
3232
measurement_ids: List[str]
33+
exclude_unmodeled_species: bool = True
3334

3435
def __init__(
3536
self,
3637
enzmldoc: v2.EnzymeMLDocument,
3738
measurement_ids: Optional[List[str]] = None,
3839
df_per_measurement: bool = False,
40+
exclude_unmodeled_species: bool = True,
3941
):
4042
assert isinstance(enzmldoc, v2.EnzymeMLDocument)
4143
assert isinstance(measurement_ids, list) or measurement_ids is None
@@ -52,6 +54,7 @@ def __init__(
5254
self.fitted_doc = enzmldoc.model_copy(deep=True)
5355
self.measurement_ids = measurement_ids
5456
self.df_per_measurement = df_per_measurement
57+
self.exclude_unmodeled_species = exclude_unmodeled_species
5558

5659
@staticmethod
5760
def _remove_unmodeled_species(enzmldoc: v2.EnzymeMLDocument) -> v2.EnzymeMLDocument:
@@ -258,7 +261,12 @@ def df(self) -> pd.DataFrame:
258261
Raises:
259262
ValueError: If the conversion doesn't return a DataFrame.
260263
"""
261-
df = pe.to_pandas(self.enzmldoc, per_measurement=False)
264+
if self.exclude_unmodeled_species:
265+
enzmldoc = self._remove_unmodeled_species(self.enzmldoc)
266+
else:
267+
enzmldoc = self.enzmldoc
268+
269+
df = pe.to_pandas(enzmldoc, per_measurement=False)
262270

263271
# Drop all this rows where "id" is within measurement_ids
264272
df = (

pyenzyme/thinlayers/psyces.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def __init__(
8989
enzmldoc=enzmldoc,
9090
measurement_ids=measurement_ids,
9191
df_per_measurement=False,
92+
exclude_unmodeled_species=True,
9293
)
9394

9495
if not isinstance(model_dir, Path):

0 commit comments

Comments
 (0)