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 PySBModel for handling of PySB models #145

Merged
merged 26 commits into from
Mar 9, 2023
Merged

Add PySBModel for handling of PySB models #145

merged 26 commits into from
Mar 9, 2023

Conversation

dweindl
Copy link
Member

@dweindl dweindl commented May 4, 2022

Draft for handling PySB models in PEtab.

  • adds newly introduced model IDs in yaml file to petab.Model, and handles change form sbml_files to model_files
  • adds support for the newly introduced model<->petab entity mapping file

@dweindl dweindl force-pushed the model_pysb branch 2 times, most recently from 045c364 to 3fd9d55 Compare May 24, 2022 15:11
@codecov-commenter
Copy link

codecov-commenter commented May 24, 2022

Codecov Report

Merging #145 (91e5de4) into develop (751b628) will decrease coverage by 1.82%.
The diff coverage is 57.50%.

@@             Coverage Diff             @@
##           develop     #145      +/-   ##
===========================================
- Coverage    78.07%   76.25%   -1.82%     
===========================================
  Files           32       34       +2     
  Lines         2915     3155     +240     
  Branches       690      764      +74     
===========================================
+ Hits          2276     2406     +130     
- Misses         461      552      +91     
- Partials       178      197      +19     
Impacted Files Coverage Δ
petab/lint.py 72.20% <14.28%> (-2.35%) ⬇️
petab/problem.py 64.51% <27.27%> (-2.79%) ⬇️
petab/parameters.py 84.53% <57.14%> (-2.68%) ⬇️
petab/mapping.py 57.89% <57.89%> (ø)
petab/observables.py 97.26% <60.00%> (-2.74%) ⬇️
petab/models/pysb_model.py 60.80% <60.80%> (ø)
petab/models/model.py 68.33% <64.28%> (-3.67%) ⬇️
petab/models/sbml_model.py 88.40% <66.66%> (-7.96%) ⬇️
petab/yaml.py 85.88% <66.66%> (-1.93%) ⬇️
petab/C.py 100.00% <100.00%> (ø)
... and 5 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Base automatically changed from abstract_model to develop June 22, 2022 15:01
petab/problem.py Outdated Show resolved Hide resolved
@dweindl dweindl marked this pull request as ready for review February 28, 2023 18:12
@dweindl dweindl requested a review from a team as a code owner February 28, 2023 18:13
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.

Looks good 👍 Did not properly check the pysb_model.py or test_model_pysb.py files, but code quality is good. There are some TODOs left in the code

petab/C.py Show resolved Hide resolved
petab/lint.py Outdated Show resolved Hide resolved
# mapping table entities mapping to already allowed parameters
if to_id in allowed_in_condition_cols
# mapping table entities mapping to species
or model.is_state_variable(to_id)
Copy link
Member

Choose a reason for hiding this comment

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

Should these state variables be provided by model.get_valid_ids_for_condition_table() instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right. Needs to be changed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm. The problem here is that the list of allowed species could be very long (potentially infinite) for rule-based models. But it doesn't make sense to not include them in model.get_valid_ids_for_condition_table.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, no, it makes sense the way it is. For SBML, to_id in allowed_in_condition_cols will always do the job. For PySB, the species ID itself is not allowed in the condition table, because they don't match our PEtab identifier requirements. That's why we have the mapping table. For this case, we need the model.is_state_variable(to_id) part.

petab/mapping.py Outdated Show resolved Hide resolved
petab/mapping.py Outdated Show resolved Hide resolved
Comment on lines 1 to +7
MODEL_TYPE_SBML = 'sbml'
MODEL_TYPE_PYSB = 'pysb'

known_model_types = {MODEL_TYPE_SBML}
known_model_types = {
MODEL_TYPE_SBML,
MODEL_TYPE_PYSB,
}
Copy link
Member

Choose a reason for hiding this comment

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

Could use ModelType.SBML/PYSB enum

Copy link
Member Author

Choose a reason for hiding this comment

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

Would keep that for later.

:returns: A :py:class:`Model` instance representing the given model
"""
from . import MODEL_TYPE_SBML, MODEL_TYPE_PYSB, known_model_types
Copy link
Member

Choose a reason for hiding this comment

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

Move to header?

Copy link
Member Author

Choose a reason for hiding this comment

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

Would cause circular import issues. petab/models/__init__.py imports from petab/models/model.py

petab/models/sbml_model.py Outdated Show resolved Hide resolved
petab/yaml.py Outdated
Comment on lines 259 to 260
mapping_file = get_rel_to_yaml([mapping_file])[0]\
if mapping_file 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.

Suggested change
mapping_file = get_rel_to_yaml([mapping_file])[0]\
if mapping_file else None
mapping_file = get_rel_to_yaml(mapping_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.

Right, so far it's only a single file name.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, now I'm confused by my suggestion, because get_rel_to_yaml expects List[str]...

Copy link
Member Author

Choose a reason for hiding this comment

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

And it makes more sense to change it to a list of filenames for coherence with the other file types.

dweindl and others added 7 commits March 8, 2023 15:22
Co-authored-by: Dilan Pathirana <59329744+dilpath@users.noreply.github.com>
Co-authored-by: Dilan Pathirana <59329744+dilpath@users.noreply.github.com>
@dweindl dweindl requested a review from FFroehlich March 8, 2023 15:15
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.

👍

@dweindl dweindl merged commit 92ad3b9 into develop Mar 9, 2023
@dweindl dweindl deleted the model_pysb branch March 9, 2023 12: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.

4 participants