Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions petab/v1/C.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,15 +335,6 @@
PROBLEMS = "problems"
#: SBML files key in the YAML file
SBML_FILES = "sbml_files"
#: Model files key in the YAML file
# (PEtab v2.0 -- DEPRECATED: use value from petab.v2.C)
MODEL_FILES = "model_files"
#: Model location key in the YAML file
# (PEtab v2.0 -- DEPRECATED: use value from petab.v2.C)
MODEL_LOCATION = "location"
#: Model language key in the YAML file
# (PEtab v2.0 -- DEPRECATED: use value from petab.v2.C)
MODEL_LANGUAGE = "language"
#: Condition files key in the YAML file
CONDITION_FILES = "condition_files"
#: Measurement files key in the YAML file
Expand All @@ -352,25 +343,6 @@
OBSERVABLE_FILES = "observable_files"
#: Visualization files key in the YAML file
VISUALIZATION_FILES = "visualization_files"
#: Mapping files key in the YAML file
# (PEtab v2.0 -- DEPRECATED: use value from petab.v2.C)
MAPPING_FILES = "mapping_files"
#: Extensions key in the YAML file
# (PEtab v2.0 -- DEPRECATED: use value from petab.v2.C)
EXTENSIONS = "extensions"


# MAPPING

#: PEtab entity ID column in the mapping table
# (PEtab v2.0 -- DEPRECATED: use value from petab.v2.C)
PETAB_ENTITY_ID = "petabEntityId"
#: Model entity ID column in the mapping table
# (PEtab v2.0 -- DEPRECATED: use value from petab.v2.C)
MODEL_ENTITY_ID = "modelEntityId"
#: Required columns of the mapping table
# (PEtab v2.0 -- DEPRECATED: use value from petab.v2.C)
MAPPING_DF_REQUIRED_COLS = [PETAB_ENTITY_ID, MODEL_ENTITY_ID]

# MORE

Expand Down
1 change: 0 additions & 1 deletion petab/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from .core import *
from .format_version import __format_version__ # noqa: F401
from .lint import *
from .mapping import *
from .measurements import *
from .models import Model # noqa: F401
from .observables import *
Expand Down
63 changes: 1 addition & 62 deletions petab/v1/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,13 @@ def check_condition_df(
df: pd.DataFrame,
model: Model | None = None,
observable_df: pd.DataFrame | None = None,
mapping_df: pd.DataFrame | None = None,
) -> None:
"""Run sanity checks on PEtab condition table

Arguments:
df: PEtab condition DataFrame
model: Model for additional checking of parameter IDs
observable_df: PEtab observables DataFrame
mapping_df: PEtab mapping DataFrame

Raises:
AssertionError: in case of problems
Expand Down Expand Up @@ -141,11 +139,8 @@ def check_condition_df(
petab.get_output_parameters(
model=model,
observable_df=observable_df,
mapping_df=mapping_df,
)
)
if mapping_df is not None:
allowed_cols |= set(mapping_df.index.values)
for column_name in df.columns:
if (
column_name != CONDITION_NAME
Expand Down Expand Up @@ -217,7 +212,6 @@ def check_parameter_df(
observable_df: pd.DataFrame | None = None,
measurement_df: pd.DataFrame | None = None,
condition_df: pd.DataFrame | None = None,
mapping_df: pd.DataFrame | None = None,
) -> None:
"""Run sanity checks on PEtab parameter table

Expand All @@ -227,7 +221,6 @@ def check_parameter_df(
observable_df: PEtab observable table for additional checks
measurement_df: PEtab measurement table for additional checks
condition_df: PEtab condition table for additional checks
mapping_df: PEtab mapping table for additional checks

Raises:
AssertionError: in case of problems
Expand Down Expand Up @@ -286,7 +279,7 @@ def check_parameter_df(

if model and measurement_df is not None and condition_df is not None:
assert_all_parameters_present_in_parameter_df(
df, model, observable_df, measurement_df, condition_df, mapping_df
df, model, observable_df, measurement_df, condition_df
)


Expand Down Expand Up @@ -355,7 +348,6 @@ def assert_all_parameters_present_in_parameter_df(
observable_df: pd.DataFrame,
measurement_df: pd.DataFrame,
condition_df: pd.DataFrame,
mapping_df: pd.DataFrame = None,
) -> None:
"""Ensure all required parameters are contained in the parameter table
with no additional ones
Expand All @@ -366,7 +358,6 @@ def assert_all_parameters_present_in_parameter_df(
observable_df: PEtab observable table
measurement_df: PEtab measurement table
condition_df: PEtab condition table
mapping_df: PEtab mapping table for additional checks

Raises:
AssertionError: in case of problems
Expand All @@ -376,42 +367,19 @@ def assert_all_parameters_present_in_parameter_df(
condition_df=condition_df,
observable_df=observable_df,
measurement_df=measurement_df,
mapping_df=mapping_df,
)

allowed = parameters.get_valid_parameters_for_parameter_table(
model=model,
condition_df=condition_df,
observable_df=observable_df,
measurement_df=measurement_df,
mapping_df=mapping_df,
)

actual = set(parameter_df.index)
missing = required - actual
extraneous = actual - allowed

# missing parameters might be present under a different name based on
# the mapping table
if missing and mapping_df is not None:
model_to_petab_mapping = {}
for map_from, map_to in zip(
mapping_df.index.values, mapping_df[MODEL_ENTITY_ID], strict=True
):
if map_to in model_to_petab_mapping:
model_to_petab_mapping[map_to].append(map_from)
else:
model_to_petab_mapping[map_to] = [map_from]
missing = {
missing_id
for missing_id in missing
if missing_id not in model_to_petab_mapping
or all(
mapping_parameter not in actual
for mapping_parameter in model_to_petab_mapping[missing_id]
)
}

if missing:
raise AssertionError(
"Missing parameter(s) in the model or the "
Expand Down Expand Up @@ -893,13 +861,6 @@ def lint_problem(problem: "petab.Problem") -> bool:
# pylint: disable=too-many-statements
errors_occurred = False

if problem.extensions_config:
logger.warning(
"Validation of PEtab extensions is not yet implemented, "
"but the given problem uses the following extensions: "
f"{'', ''.join(problem.extensions_config.keys())}"
)

# Run checks on individual files
if problem.model is not None:
logger.info("Checking model...")
Expand All @@ -914,7 +875,6 @@ def lint_problem(problem: "petab.Problem") -> bool:
problem.condition_df,
model=problem.model,
observable_df=problem.observable_df,
mapping_df=problem.mapping_df,
)
except AssertionError as e:
logger.error(e)
Expand Down Expand Up @@ -963,7 +923,6 @@ def lint_problem(problem: "petab.Problem") -> bool:
problem.observable_df,
problem.measurement_df,
problem.condition_df,
problem.mapping_df,
)
except AssertionError as e:
logger.error(e)
Expand All @@ -981,7 +940,6 @@ def lint_problem(problem: "petab.Problem") -> bool:
problem.model,
problem.condition_df,
problem.parameter_df,
problem.mapping_df,
)
except AssertionError as e:
logger.error(e)
Expand Down Expand Up @@ -1017,7 +975,6 @@ def assert_model_parameters_in_condition_or_parameter_table(
model: Model,
condition_df: pd.DataFrame,
parameter_df: pd.DataFrame,
mapping_df: pd.DataFrame = None,
observable_df: pd.DataFrame = None,
measurement_df: pd.DataFrame = None,
) -> None:
Expand All @@ -1029,38 +986,20 @@ def assert_model_parameters_in_condition_or_parameter_table(
parameter_df: PEtab parameter DataFrame
model: PEtab model
condition_df: PEtab condition table
mapping_df: PEtab mapping table
observable_df: PEtab observable table
measurement_df: PEtab measurement table

Raises:
AssertionError: in case of problems
"""
allowed_in_condition_cols = set(model.get_valid_ids_for_condition_table())
if mapping_df is not None:
allowed_in_condition_cols |= {
from_id
for from_id, to_id in zip(
mapping_df.index.values,
mapping_df[MODEL_ENTITY_ID],
strict=True,
)
if not pd.isna(to_id)
and (
# mapping table entities mapping to already allowed parameters
to_id in allowed_in_condition_cols
# mapping table entities mapping to species
or model.is_state_variable(to_id)
)
}

allowed_in_parameter_table = (
parameters.get_valid_parameters_for_parameter_table(
model=model,
condition_df=condition_df,
observable_df=observable_df,
measurement_df=measurement_df,
mapping_df=mapping_df,
)
)

Expand Down
12 changes: 0 additions & 12 deletions petab/v1/observables.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def get_output_parameters(
model: Model,
observables: bool = True,
noise: bool = True,
mapping_df: pd.DataFrame = None,
) -> list[str]:
"""Get output parameters

Expand All @@ -92,7 +91,6 @@ def get_output_parameters(
model: The underlying model
observables: Include parameters from observableFormulas
noise: Include parameters from noiseFormulas
mapping_df: PEtab mapping table

Returns:
List of output parameter IDs
Expand All @@ -114,16 +112,6 @@ def get_output_parameters(
if model.symbol_allowed_in_observable_formula(sym):
continue

# does it map to a model entity?
if (
mapping_df is not None
and sym in mapping_df.index
and model.symbol_allowed_in_observable_formula(
mapping_df.loc[sym, MODEL_ENTITY_ID]
)
):
continue

output_parameters[sym] = None

return list(output_parameters.keys())
Expand Down
Loading
Loading