Skip to content

Modify residue names of ligands and cofactors in the SepTop and ABFE protocols - #2118

Open
hannahbaumann wants to merge 18 commits into
mainfrom
change_names_abfe_septop
Open

Modify residue names of ligands and cofactors in the SepTop and ABFE protocols#2118
hannahbaumann wants to merge 18 commits into
mainfrom
change_names_abfe_septop

Conversation

@hannahbaumann

@hannahbaumann hannahbaumann commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

This implements now a helper function to assign residue names and numbers, making sure that any user provided name and number stays and doesn't conflict with other assigned names or residue numbers. The ligands and cofactors now get assigned mostly the same name (LIG for the ligands and COF for the cofactors). They are then distiguishable only by the residue number. As we had discussed in the previous PR, that might be more intuitive for people.

LLM / AI generated code disclosure

LLMs or other AI-powered tools (beyond simple IDE use cases) were used in this contribution: yes / no
If yes, please provide details here:

Checklist

  • All new code is appropriately documented (user-facing code must have complete docstrings).
  • Added a news entry, or the changes are not user-facing.
  • Ran pre-commit: you can run pre-commit locally or comment on this PR with pre-commit.ci autofix.
  • Filled in the AI generated code disclosure.

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

Comment thread src/openfe/protocols/openmm_afe/base_afe_units.py Outdated
@hannahbaumann

Copy link
Copy Markdown
Contributor Author

pre-commit.ci autofix

Comment thread src/openfe/protocols/openmm_septop/septop_units.py Outdated
@hannahbaumann

Copy link
Copy Markdown
Contributor Author

pre-commit.ci autofix

@hannahbaumann hannahbaumann changed the title [WIP] Modify residue names of ligands and cofactors in the SepTop and ABFE protocols Modify residue names of ligands and cofactors in the SepTop and ABFE protocols Aug 6, 2026
alchem_comps["stateA"][0],
alchem_comps["stateB"][0],
)
smc_off_B = {smc_B: smc_B.to_openff()}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I decided to change this since this was overwriting the original off molecule which let to the residue info to got lost, so I thought it would be better to just update the position instead of creating a new molecule.

@hannahbaumann

Copy link
Copy Markdown
Contributor Author

pre-commit.ci autofix

@hannahbaumann
hannahbaumann requested a review from IAlibay August 6, 2026 12:55
@IAlibay IAlibay self-assigned this Aug 6, 2026
@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.96907% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.50%. Comparing base (1d4610b) to head (512cbec).

Files with missing lines Patch % Lines
...openfe/protocols/openmm_utils/offmolecule_utils.py 97.56% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2118      +/-   ##
==========================================
- Coverage   95.14%   90.50%   -4.64%     
==========================================
  Files         213      213              
  Lines       20916    20970      +54     
==========================================
- Hits        19900    18979     -921     
- Misses       1016     1991     +975     
Flag Coverage Δ
fast-tests 90.50% <98.96%> (?)
slow-tests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

assert name is not None
names.add(name)
alchem_resnames = sorted(names)
assigned = assign_offmol_residue_metadata(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is really clean, I like it.

@github-actions

Copy link
Copy Markdown

No API break detected ✅

View workflow run

Griffe output
$ griffe check "openfe" -s src --no-inspection --no-color --verbose -a origin/main

$ griffe check "openfecli" -s src --no-inspection --no-color --verbose -a origin/main

@IAlibay IAlibay left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just a few small things, otherwise lgtm so I'm approving early.

@@ -890,11 +901,10 @@ class SepTopSolventSetupUnit(SepTopSolventMixin, BaseSepTopSetupUnit):
def _update_positions(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If I understand correctly, this now only gets you the offset but doesn't update positions?
If so, can we rename the method name to match what it does?

Comment on lines +114 to +115
_LIGAND_RESNAME, _LIGAND_STEM = "LIG", "LG"
_COFACTOR_RESNAME, _COFACTOR_STEM = "COF", "CF"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It doesn't look like you're using these variables anywhere - generally it's better to not have globally defined variables hanging about outside of a method unless you want to give some kind of user control.

Can you just let the strings be defined in the method itself? If you want the users to control them, it might be better to have it all be defined as kwargs.

assert all("residue_name" not in a.metadata for a in mol.atoms)


def _build(benzene_modifications, specs):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you maybe move all of this to a pytest class so it's clearer that this is a method specifically for the one test? (ideally also renaming _build to something else, but that's not as necessary once it's in a class)

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.

2 participants