Skip to content

Apply image shifting by fragment - #124

Merged
hannahbaumann merged 14 commits into
mainfrom
align_fragment_based
Oct 9, 2026
Merged

hannahbaumann merged 14 commits into
mainfrom
align_fragment_based

Conversation

@hannahbaumann

@hannahbaumann hannahbaumann commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

When two chains of a protein have the same segid, the PBC are not handled correctly during alignment since they would appear as one segment. This PR switches to use the protein.fragments instead. For fragments to be recognized correctly, we first need to guess the bonds in the protein.
Having the large fragments now makes unwrap() very slow which is fragment based.

@hannahbaumann hannahbaumann self-assigned this Jul 8, 2026
@codecov

codecov Bot commented Jul 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.38%. Comparing base (988b7de) to head (933e835).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #124      +/-   ##
==========================================
+ Coverage   98.35%   98.38%   +0.02%     
==========================================
  Files          10       10              
  Lines         487      496       +9     
==========================================
+ Hits          479      488       +9     
  Misses          8        8              

☔ 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.

@hannahbaumann hannahbaumann changed the title [WIP] Apply image shifting by fragment Apply image shifting by fragment Jul 9, 2026
@hannahbaumann
hannahbaumann requested review from IAlibay and jthorton July 9, 2026 07:56
@@ -58,11 +58,15 @@ def apply_complex_alignment_transformations(
# 1. Make molecules whole (protein + optional ligand)
transforms = [unwrap(group)]

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.

This now makes the alignment very very slow. Unwrap loops over the fragments and before (when there was no bond information), there were a lot of fragments that were very small.

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.

How much of a problem is this in practice?

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.

@IAlibay I just checked the timing, for a single lambda windows, 51 frames, the applying of the transformations took ~16 sec, but since this happens multiple times, each time for each analysis, this is x4.
I just switched it to doing the applying the alignments first and storing it in memory, no it's faster. It will still be a considerable cost for e.g. ABFE with the many lambda windows though.

@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.

One thing to fix, one question, and a missing news entry.

Otherwise it looks great to me!

@@ -58,11 +58,15 @@ def apply_complex_alignment_transformations(
# 1. Make molecules whole (protein + optional ligand)
transforms = [unwrap(group)]

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.

How much of a problem is this in practice?

chains = [seg.atoms for seg in protein.segments]
shift_targets = chains[1:] + ligands
# 2. Closest image shift for protein fragments + ligand (if present)
fragments = list(protein.fragments)

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.

Is it worth checking for bonds in protein before you do this?

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.

Added a check above.

Comment thread src/openfe_analysis/rmsd.py Outdated
@hannahbaumann
hannahbaumann requested a review from IAlibay August 12, 2026 12:26
@hannahbaumann

Copy link
Copy Markdown
Contributor Author

@IAlibay here some timing data on a SepTop A2A system, 100 frames.

19 states x 101 analyzed frames

stage                   calls   total (s)    % wall
build_universe             19       0.129      0.1%
register_transforms     19       4.096      1.7%
transforms                    19     217.842     90.7%
protein_2D_RMSD            19       1.257      0.5%
ligand_RMSD                38       2.483      1.0%
ligand_COM_drift           38       0.036      0.0%
other (plot/npz/io)                14.226      5.9%
WALL TOTAL                        240.06

So it's on the order of minutes, would this be ok? I'd have to update the structural analysis in SepTop and ABFE to tranfer the universe to memory to not redo the transformations for each analysis class.

@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.

this looks good to me, thanks

@hannahbaumann
hannahbaumann merged commit 065eb4a into main Oct 9, 2026
9 checks passed
@hannahbaumann
hannahbaumann deleted the align_fragment_based branch October 9, 2026 10:04
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