Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add abstraction for (SBML) models #133

Merged
merged 32 commits into from
Jun 22, 2022
Merged

Add abstraction for (SBML) models #133

merged 32 commits into from
Jun 22, 2022

Conversation

dweindl
Copy link
Member

@dweindl dweindl commented Apr 28, 2022

Add abstraction for models. This helps to keep libsbml code closely together and to potentially accommodate non-SBML models in the future(PEtab-dev/PEtab#538).

Wraps libsbml.Model using petab.models.Model and replaces the respective function arguments. In the (what I consider) most relevant function for downstream use, the sbml_model argument is kept, but deprecated.

@codecov-commenter
Copy link

codecov-commenter commented Apr 28, 2022

Codecov Report

Merging #133 (d540c47) into develop (7a0b77e) will increase coverage by 0.11%.
The diff coverage is 74.04%.

@@             Coverage Diff             @@
##           develop     #133      +/-   ##
===========================================
+ Coverage    77.14%   77.25%   +0.11%     
===========================================
  Files           26       29       +3     
  Lines         2437     2572     +135     
  Branches       579      593      +14     
===========================================
+ Hits          1880     1987     +107     
- Misses         404      428      +24     
- Partials       153      157       +4     
Impacted Files Coverage Δ
petab/lint.py 67.55% <51.85%> (-0.30%) ⬇️
petab/problem.py 67.19% <64.91%> (-0.58%) ⬇️
petab/parameters.py 88.19% <71.42%> (+0.30%) ⬆️
petab/models/model.py 72.00% <72.00%> (ø)
petab/parameter_mapping.py 70.15% <78.26%> (-0.18%) ⬇️
petab/models/sbml_model.py 91.37% <91.37%> (ø)
petab/models/__init__.py 100.00% <100.00%> (ø)
petab/observables.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7a0b77e...d540c47. Read the comment docs.

@dweindl dweindl marked this pull request as ready for review May 20, 2022 14:29
@dweindl dweindl requested a review from dilpath May 25, 2022 08:48
Copy link
Member

@dilpath dilpath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not look at it in a lot of detail, but looks good 👍

petab/lint.py Show resolved Hide resolved
petab/lint.py Outdated Show resolved Hide resolved
petab/lint.py Outdated Show resolved Hide resolved
Comment on lines +1 to +3
MODEL_TYPE_SBML = 'sbml'

known_model_types = {MODEL_TYPE_SBML}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be here or the constants file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer keeping it more modular, but could consider importing it in petab.C

petab/models/model.py Outdated Show resolved Hide resolved
petab/models/sbml_model.py Outdated Show resolved Hide resolved
petab/models/model.py Outdated Show resolved Hide resolved
petab/parameters.py Outdated Show resolved Hide resolved
Comment on lines +233 to +259
measurement_files = [
get_path(f) for f in problem0.get(MEASUREMENT_FILES, [])]
# If there are multiple tables, we will merge them
measurement_df = core.concat_tables(
measurement_files, measurements.get_measurement_df) \
if measurement_files else None

condition_files = [
get_path(f) for f in problem0.get(CONDITION_FILES, [])]
# If there are multiple tables, we will merge them
condition_df = core.concat_tables(
condition_files, conditions.get_condition_df) \
if condition_files else None

visualization_files = [
get_path(f) for f in problem0.get(VISUALIZATION_FILES, [])]
# If there are multiple tables, we will merge them
visualization_df = core.concat_tables(
visualization_files, core.get_visualization_df) \
if visualization_files else None

observable_files = [
get_path(f) for f in problem0.get(OBSERVABLE_FILES, [])]
# If there are multiple tables, we will merge them
observable_df = core.concat_tables(
observable_files, observables.get_observable_df) \
if observable_files else None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repeated code but fine as is

dweindl and others added 9 commits June 20, 2022 16:15
Co-authored-by: Dilan Pathirana <59329744+dilpath@users.noreply.github.com>
Co-authored-by: Dilan Pathirana <59329744+dilpath@users.noreply.github.com>
Copy link
Collaborator

@FFroehlich FFroehlich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -154,7 +154,7 @@ def get_unique_parameters(series):

def split_parameter_replacement_list(
list_string: Union[str, numbers.Number],
delim: str = ';') -> List[Union[str, numbers.Number]]:
delim: str = PARAMETER_SEPARATOR) -> List[Union[str, numbers.Number]]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it ever make sense to pass anything but PARAMETER_SEPARATOR here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not for now. If the separator ever changes, it can be useful, but shouldn't hurt keeping the optional argument.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but why is it optional for this specific function (in contrast to all the other code, where it isn't optional)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because adding it to the whole potential call stack will be a mess 🙈

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥇

@dweindl dweindl merged commit e3a8f82 into develop Jun 22, 2022
@dweindl dweindl deleted the abstract_model branch June 22, 2022 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants