Skip to content

Commit

Permalink
Fix parameter check constant (#82)
Browse files Browse the repository at this point in the history
* Remove .DS_Store

* More informative error message

* Fix linter error for constant parameters

* Don't abuse parameter const-ness

* Adapt tests

* Update doc
  • Loading branch information
dweindl committed Mar 19, 2019
1 parent 7b849a0 commit 22d6764
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 25 deletions.
Binary file removed .DS_Store
Binary file not shown.
12 changes: 6 additions & 6 deletions doc/documentation_data_format.md
Expand Up @@ -235,15 +235,15 @@ numeric value or `inf` (lower-case) for steady-state measurements.

A tab-separated value text file containing information on model parameters.

This table must comprise the following parameters:
- All parameters from the SBML model, except for:
- `constant` and/or `boundaryCondition` parameters (see SBML specs)
- placeholder parameters (see `observableParameters` and `noiseParameters`
above)
- parameters included as column names in the *condition table*
This table must include the following parameters:
- Named parameter overrides introduced in the *conditions table*
- Named parameter overrides introduced in the *measurement table*

and must not include
- placeholder parameters (see `observableParameters` and `noiseParameters`
above)
- parameters included as column names in the *condition table*

One row per parameter with arbitrary order of rows and columns:

| parameterId | [parameterName] | parameterScale | lowerBound |upperBound | nominalValue | estimate | [priorType] | [priorParameters] |
Expand Down
20 changes: 7 additions & 13 deletions petab/lint.py
Expand Up @@ -294,8 +294,9 @@ def assert_overrides_match_parameter_count(measurement_df, observables, noise):
if not len(replacements) == 1 \
or not isinstance(replacements[0], numbers.Number):
raise AssertionError(
f'No place holders specified in model for:\n{row}\n'
f'But parameter name or multiple overrides provided.')
f'No placeholders specified in noise model for:\n{row}\n'
f'But parameter name or multiple overrides provided in '
'noiseParameters column.')


def lint_problem(problem: 'core.Problem'):
Expand Down Expand Up @@ -390,12 +391,10 @@ def assert_model_parameters_in_condition_or_parameter_table(
sbml_model: libsbml.Model,
condition_df: pd.DataFrame,
parameter_df: pd.DataFrame):
"""Model non-placeholder model parameters must be either specified in the
condition or parameter table, unless they are AssignmentRule target, in
which case they must not occur in either.
Check that.
NOTE: SBML local parameters are ignored here"""
"""Model parameters that are targets of AssignmentRule must not be present
in parameter table or in condition table columns. Other parameters must
only be present in either in parameter table or condition table columns.
Check that."""

for parameter in sbml_model.getListOfParameters():
parameter_id = parameter.getId()
Expand All @@ -416,11 +415,6 @@ def assert_model_parameters_in_condition_or_parameter_table(
"present in condition table or in parameter "
"table.")

if not is_assignee and not in_parameter_df and not in_condition_df:
raise AssertionError(f"Model parameter '{parameter_id}' neither "
"present in condition table nor in parameter "
"table.")

if in_parameter_df and in_condition_df:
raise AssertionError(f"Model parameter '{parameter_id}' present "
"in both condition table and parameter "
Expand Down
7 changes: 1 addition & 6 deletions tests/test_lint.py
Expand Up @@ -159,10 +159,6 @@ def test_assert_model_parameters_in_condition_or_parameter_table():
sbml.add_global_parameter(model, 'noiseParameter1_')
sbml.add_global_parameter(model, 'observableParameter1_')

with pytest.raises(AssertionError):
lint.assert_model_parameters_in_condition_or_parameter_table(
model, pd.DataFrame(), pd.DataFrame())

lint.assert_model_parameters_in_condition_or_parameter_table(
model, pd.DataFrame(columns=['parameter1']), pd.DataFrame()
)
Expand All @@ -176,8 +172,7 @@ def test_assert_model_parameters_in_condition_or_parameter_table():
pd.DataFrame(columns=['parameter1']),
pd.DataFrame(index=['parameter1']))

with pytest.raises(AssertionError):
lint.assert_model_parameters_in_condition_or_parameter_table(
lint.assert_model_parameters_in_condition_or_parameter_table(
model, pd.DataFrame(), pd.DataFrame())

sbml.create_assigment_rule(model, assignee_id='parameter1',
Expand Down

0 comments on commit 22d6764

Please sign in to comment.