Fix StopIteration in alignChains with Biopython > 1.79#2221
Open
Fix StopIteration in alignChains with Biopython > 1.79#2221
Conversation
Co-authored-by: AnthonyBogetti <34397256+AnthonyBogetti@users.noreply.github.com>
Co-authored-by: AnthonyBogetti <34397256+AnthonyBogetti@users.noreply.github.com>
Co-authored-by: AnthonyBogetti <34397256+AnthonyBogetti@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix alignChains error with Biopython > 1.79
Fix StopIteration in alignChains with Biopython > 1.79
Feb 13, 2026
Member
|
@jamesmkrieger This looks reasonable to me. Can you test it and see if it works? If so, let's merge it. |
Contributor
|
Will do. I agree it seems reasonable. Thanks |
Contributor
|
No, this doesn't work. I now get another error |
Contributor
|
It seems like the problem is that the weights have the wrong shape because the last mapping has the wrong shape. We're missing 62 dummy atoms for the last chain to get it to length 82, so the whole length goes to 2280 |
Contributor
|
@copilot fix this to add enough dummy atoms after breaking the loop |
Contributor
|
@AnthonyBogetti, I don't think this actually fixes the problem at all. The problem is that Biopython pairwise local alignment no longer includes gaps. Biopython 1.79: Biopython 1.80 I will make a fix to alignBioPairwise, I think |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Biopython > 1.79's
PairwiseAlignercan produce alignment strings with more non-gap characters than actual residues in the sequences. This causesgetAlignedMapping()to exhaust sequence iterators and raise unhandledStopIteration.Changes
getAlignedMapping()around allnext()calls on sequence iteratorsamatchto prevent length mismatch betweenamatchandbmatchKey Fix
This maintains backward compatibility while handling alignment format differences across Biopython versions.
Original prompt
This section details on the original issue you should resolve
<issue_title>Biopython > 1.79 sometimes breaks alignChains</issue_title>
<issue_description>## Description of the bug.
When I run alignChains on the attached pdbs with Python 3.11 with Biopython > 1.79, I get the following error. With Biopython 1.79, the same code runs without any problems. This also means I can't use Python 3.12 as it doesn't support Biopython 1.79
ref_model.pdb
centered_model.pdb
Error log from code run shown below