Fix residue names & numbers for the PlainMDProtocol - #2178
Conversation
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
…to resname_plainmd
…to resname_plainmd
| if _get_offmol_metadata(offmol, "residue_number") is None: | ||
| _set_offmol_metadata(offmol, "residue_number", _next_resnum()) | ||
| resnum = _next_available_number(used_resnums) | ||
| _set_offmol_metadata(offmol, "residue_number", str(resnum)) |
There was a problem hiding this comment.
I checked that OpenFF reads residue numbers into strings, so we should be doing that (it also works fine when converting to OpenMM Topologies).
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2178 +/- ##
==========================================
- Coverage 95.02% 90.25% -4.77%
==========================================
Files 206 206
Lines 20514 20531 +17
==========================================
- Hits 19493 18530 -963
- Misses 1021 2001 +980
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| def _set_offmol_resname( | ||
| offmol: OFFMolecule, | ||
| resname: str | None, | ||
| ) -> None: | ||
| """ | ||
| Helper method to set offmol residue names | ||
|
|
||
| Parameters | ||
| ---------- | ||
| offmol : openff.toolkit.Molecule | ||
| Molecule to assign a residue name to. | ||
| resname : str | None | ||
| Residue name to be set. Set to None to clear it. | ||
|
|
||
| Returns | ||
| ------- | ||
| None | ||
| """ | ||
| _set_offmol_metadata(offmol, "residue_name", resname) | ||
|
|
||
|
|
||
| def _get_offmol_resname(offmol: OFFMolecule) -> str | None: | ||
| """ | ||
| Helper method to get an offmol's residue name and make sure it is | ||
| consistent across all atoms in the Molecule. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| offmol : openff.toolkit.Molecule | ||
| Molecule to get the residue name from. | ||
|
|
||
| Returns | ||
| ------- | ||
| resname : Optional[str] | ||
| Residue name of the molecule. ``None`` if the Molecule | ||
| does not have a residue name, or if the residue name is | ||
| inconsistent across all the atoms. | ||
| """ | ||
| return _get_offmol_metadata(offmol, "residue_name") |
There was a problem hiding this comment.
Do we still need these, it looks like you are using the general metadata functions in the plainMD now but assign_offmol_residue_metadata is using a mix, if the changes to plain MD are the prefered pattern lets remove these.
hannahbaumann
left a comment
There was a problem hiding this comment.
Thanks @IAlibay ! Approving early, but agreeing with Josh's comments!
Fix #2158
LLM / AI generated code disclosure
LLMs or other AI-powered tools (beyond simple IDE use cases) were used in this contribution: no
If yes, please provide details here:
Checklist
newsentry, or the changes are not user-facing.pre-commit.ci autofix.Manual Tests: these are slow so don't need to be run every commit, only before merging and when relevant changes are made (generally at reviewer-discretion).
Developers certificate of origin