-
Notifications
You must be signed in to change notification settings - Fork 7
Add PySBModel for handling of PySB models #145
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
Conversation
045c364 to
3fd9d55
Compare
Codecov Report
@@ 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
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
dilpath
left a comment
There was a problem hiding this 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
| # 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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| MODEL_TYPE_SBML = 'sbml' | ||
| MODEL_TYPE_PYSB = 'pysb' | ||
|
|
||
| known_model_types = {MODEL_TYPE_SBML} | ||
| known_model_types = { | ||
| MODEL_TYPE_SBML, | ||
| MODEL_TYPE_PYSB, | ||
| } |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
| :param model_id: PEtab model ID for the given model | ||
| :returns: A :py:class:`Model` instance representing the given model | ||
| """ | ||
| from . import MODEL_TYPE_SBML, MODEL_TYPE_PYSB, known_model_types |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move to header?
There was a problem hiding this comment.
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/yaml.py
Outdated
| mapping_file = get_rel_to_yaml([mapping_file])[0]\ | ||
| if mapping_file else None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| mapping_file = get_rel_to_yaml([mapping_file])[0]\ | |
| if mapping_file else None | |
| mapping_file = get_rel_to_yaml(mapping_file) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]...
There was a problem hiding this comment.
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.
Co-authored-by: Dilan Pathirana <59329744+dilpath@users.noreply.github.com>
Co-authored-by: Dilan Pathirana <59329744+dilpath@users.noreply.github.com>
FFroehlich
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Draft for handling PySB models in PEtab.
sbml_filestomodel_files