Skip to content

Add CMAPTorsionForce support #1695

Merged
IAlibay merged 15 commits intomainfrom
cmap_supp
Dec 1, 2025
Merged

Add CMAPTorsionForce support #1695
IAlibay merged 15 commits intomainfrom
cmap_supp

Conversation

@jthorton
Copy link
Collaborator

@jthorton jthorton commented Nov 25, 2025

Fixes #1658 by adding support for CMAPTorsionForce not in the alchemical region for the relative hybrid topology protocol. Tests developed in jthorton/htf-tinker#2 are also included to add better coverage of the factory 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 by making a comment with pre-commit.ci autofix before requesting review.

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

@jthorton
Copy link
Collaborator Author

pre-commit.ci autofix

@jthorton jthorton requested review from IAlibay and atravitz November 25, 2025 10:18
# Conflicts:
#	openfe/tests/conftest.py
#	openfe/tests/protocols/openmm_rfe/test_relative.py
@jthorton
Copy link
Collaborator Author

pre-commit.ci autofix

Copy link
Contributor

@atravitz atravitz left a comment

Choose a reason for hiding this comment

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

with the addition of this test data, we should revisit our "what to zip" conversation.

raise RuntimeError(f"Inconsistent CMAPTorsionForce between end states expected to be present in both"
f"but found in old: {bool(cmap_old)} and new: {bool(cmap_new)}")

if cmap_new == cmap_old is None:
Copy link
Contributor

Choose a reason for hiding this comment

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

You check this both here and here, so this code path will likely not be hit by tests.

Copy link
Collaborator Author

@jthorton jthorton Nov 27, 2025

Choose a reason for hiding this comment

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

Reworked slightly to only check in the main _handle_cmap_torsion_force function.

Copy link
Member

@IAlibay IAlibay left a comment

Choose a reason for hiding this comment

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

Just seeing @atravitz's comment re: gzipping and I'm going to be a bit more opiniated.


@staticmethod
def _verify_cmap_compatibility(
cmap_old: openmm.CMAPTorsionForce | None,
Copy link
Member

Choose a reason for hiding this comment

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

Could not account for the None? Also, indentation is odd here, did ruff formatting pass?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Somehow ruff did work :/, not sure what you mean with regards to the None.

Copy link
Member

Choose a reason for hiding this comment

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

Since you're testing for None before you get to this method, I was wondering if it made sense for you to not do that in both places. So technically if you wanted, you could just assume that these parameters are never None and that you did the checking ahead of time?

Copy link
Member

Choose a reason for hiding this comment

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

Alternatively, just don't check for None in the method that calls this method.


# verify compatibility and extract numbers of maps and torsions
(
cmap_old,
Copy link
Member

Choose a reason for hiding this comment

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

It's unclear to me, why return the input cmaps?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just so we don't have to pull them out twice, but happy to change this if it makes it easier to follow?

Copy link
Member

Choose a reason for hiding this comment

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

I'm confused, why would we be pulling them twice? I.e. aren't they just the same as what we give in the input?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ohh you mean the force objects rather than the cmap grids, yeah we can stop returning the forces as well!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this is left over from the first design where the systems are passed in and these are extracted good catch!

@codecov
Copy link

codecov bot commented Nov 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.15%. Comparing base (013b4b3) to head (1986599).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1695      +/-   ##
==========================================
- Coverage   95.41%   93.15%   -2.27%     
==========================================
  Files         185      187       +2     
  Lines       16045    16231     +186     
==========================================
- Hits        15310    15120     -190     
- Misses        735     1111     +376     
Flag Coverage Δ
fast-tests 93.15% <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 Sentry.
📢 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.

Co-authored-by: Alyssa Travitz <31974495+atravitz@users.noreply.github.com>
@jthorton
Copy link
Collaborator Author

pre-commit.ci autofix

Copy link
Member

@IAlibay IAlibay left a comment

Choose a reason for hiding this comment

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

One question about that sigma_old change - my understanding is that it doesn't matter because the LJ component should be zeroed out with epsilon set to zero (and you have to keep sigma non zero because otherwise all the problems happen). But it's unclear to me if there's an ulterior motive behind the change.

jthorton and others added 2 commits December 1, 2025 11:31
Co-authored-by: Irfan Alibay <IAlibay@users.noreply.github.com>
@github-actions
Copy link

github-actions bot commented Dec 1, 2025

No API break detected ✅

@jthorton
Copy link
Collaborator Author

jthorton commented Dec 1, 2025

One question about that sigma_old change - my understanding is that it doesn't matter because the LJ component should be zeroed out with epsilon set to zero (and you have to keep sigma non zero because otherwise all the problems happen). But it's unclear to me if there's an ulterior motive behind the change.

No thats correct, this is from the other general tests that I was doing on the HTF, I set it to what I expected it to be but as you point out this does not change the result as the energy is always zero with epsilon set to zero.

Copy link
Member

@IAlibay IAlibay left a comment

Choose a reason for hiding this comment

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

lgtm, thanks!

@IAlibay IAlibay merged commit 35a9999 into main Dec 1, 2025
13 checks passed
@IAlibay IAlibay deleted the cmap_supp branch December 1, 2025 14:19
atravitz added a commit that referenced this pull request Dec 3, 2025
Adds support for CMAPTorsionForce in relative hybrid topology simulations.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Irfan Alibay <IAlibay@users.noreply.github.com>
Co-authored-by: Alyssa Travitz <31974495+atravitz@users.noreply.github.com>
@atravitz atravitz mentioned this pull request Dec 4, 2025
7 tasks
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.

Support for ff19SB force field (CMAPTorsionForce compatibility)

3 participants