-
Notifications
You must be signed in to change notification settings - Fork 2
Apply image shifting by fragment #124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hannahbaumann
wants to merge
13
commits into
main
Choose a base branch
from
align_fragment_based
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
498c71f
Apply image shifting by fragment
hannahbaumann 3fd980b
Update tests
hannahbaumann bba1661
Merge branch 'main' into align_fragment_based
hannahbaumann e358ac1
Apply suggestion from @IAlibay
hannahbaumann eb802fd
Merge branch 'main' into align_fragment_based
IAlibay 6b9ab58
Do alignment in memory
hannahbaumann 4c0154b
Merge branch 'align_fragment_based' of https://github.com/OpenFreeEne…
hannahbaumann 9c6e82f
Merge branch 'main' into align_fragment_based
hannahbaumann 37bcadc
Raise error if protein doesnt have bonds
hannahbaumann 9ac6bb2
Merge branch 'align_fragment_based' of https://github.com/OpenFreeEne…
hannahbaumann 48dc08e
Update tests
hannahbaumann 9d97900
Fix tests
hannahbaumann 94e56f1
Add test for missing bond error
hannahbaumann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,12 @@ def apply_complex_alignment_transformations( | |
| if protein is None or not protein: | ||
| raise ValueError("protein AtomGroup is empty or None") | ||
|
|
||
| if not protein.bonds: | ||
| raise ValueError( | ||
| "protein AtomGroup has no bonds which would lead to wrong alignment. " | ||
| "Call guess_bonds() on the protein before applying these transformations." | ||
| ) | ||
|
|
||
| if isinstance(ligands, mda.AtomGroup): | ||
| raise TypeError( | ||
| "ligands must be a list of AtomGroups, not a single AtomGroup. " | ||
|
|
@@ -58,11 +64,15 @@ def apply_complex_alignment_transformations( | |
| # 1. Make molecules whole (protein + optional ligand) | ||
| transforms = [unwrap(group)] | ||
|
|
||
| # 2. Closest image shift for protein chains + ligand (if present) | ||
| 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) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it worth checking for bonds in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a check above. |
||
| # Pick the largest fragment as the reference | ||
| ref_idx = max(range(len(fragments)), key=lambda i: fragments[i].n_atoms) | ||
| reference = fragments[ref_idx] | ||
| shift_targets = [f for i, f in enumerate(fragments) if i != ref_idx] | ||
| shift_targets += ligands | ||
| if shift_targets: | ||
| transforms.append(ClosestImageShift(chains[0], shift_targets)) | ||
| transforms.append(ClosestImageShift(reference=reference, targets=shift_targets)) | ||
|
|
||
| # 3. Align on protein backbone/atoms | ||
| transforms.append(Aligner(protein)) | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.