Skip to content

Enable user defn boresch restraints in ABFE Protocol#2019

Open
IAlibay wants to merge 16 commits into
mainfrom
abfe_user_defn_restraints
Open

Enable user defn boresch restraints in ABFE Protocol#2019
IAlibay wants to merge 16 commits into
mainfrom
abfe_user_defn_restraints

Conversation

@IAlibay

@IAlibay IAlibay commented Jun 16, 2026

Copy link
Copy Markdown
Member

Fixes #2002

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.

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

@IAlibay IAlibay changed the title Enable user defn boresch restraints Enable user defn boresch restraints in ABFE Protocol Jun 16, 2026
@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.61%. Comparing base (dab402b) to head (dbbe314).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2019      +/-   ##
==========================================
- Coverage   94.95%   90.61%   -4.34%     
==========================================
  Files         217      217              
  Lines       20758    20808      +50     
==========================================
- Hits        19710    18856     -854     
- Misses       1048     1952     +904     
Flag Coverage Δ
fast-tests 90.61% <100.00%> (?)
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.

@IAlibay

IAlibay commented Jun 17, 2026

Copy link
Copy Markdown
Member Author

pre-commit.ci autofix

@IAlibay IAlibay marked this pull request as ready for review June 17, 2026 12:19
@IAlibay

IAlibay commented Jun 17, 2026

Copy link
Copy Markdown
Member Author

pre-commit.ci autofix

@IAlibay IAlibay requested a review from hannahbaumann June 18, 2026 14:12
@hannahbaumann hannahbaumann self-assigned this Jun 18, 2026

@hannahbaumann hannahbaumann left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @IAlibay , this looks great, just added a few comments.

host_restraint_ids: tuple[int, int, int] | None = None
"""
The indices of the host component atoms to restrain.
The entries define the H0, H1, and H2 atoms in order.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would it be helpful to add how the restraints are defined, since people use different definitions of H0 vs H2 (meaning, is the bond between H0 and G0 or between H2 and G0?)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll double check but I think the docstring gets inherited from

class BoreschRestraintSettings(BaseRestraintSettings):

Which has the whole description of the restraints including my attempt at ASCII art.

"""
guest_restraint_ids: tuple[int, int, int] | None = None
"""
The indices of the guest component atoms to restraint.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is based on the only ligand indices (from the sdf), correct? Maybe worth adding that this are not the indices the ligand would have in the complex (probably obvious since the complex is not created yet, but maybe just to be extra clear).


errmsg = "``guest_atoms`` and ``host_atoms`` cannot have negative indices."
with pytest.raises(ValueError, match=errmsg):
setattr(setting, parameter, [1, 2, -3])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What happens if you pass in 4 integers?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It'll fail validation, I initially tried that test and was pleasantly surprised that pydantic was that good.

guest_rdmol=guest_rdmol,
guest_idxs=guest_atom_ids,
host_idxs=host_atom_ids,
guest_restraint_atoms_idxs=list(settings.guest_restraint_ids)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If one of these is defined and the other one is None, this will crash out here, but i wonder if it would be helpful to fail earlier.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good call, we can add a validitor for that.

@github-actions

Copy link
Copy Markdown

No API break detected ✅

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.

Add support for user-defined restraints in the ABFE Protocol

2 participants