From ea786d22f32abfd3ec0bec6160176a5dbf0deaee Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 13 Feb 2026 16:38:20 +0000 Subject: [PATCH 1/4] Initial plan From 6a6e325037ca2f88ef02a3a6650a840bffc92161 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 13 Feb 2026 16:41:20 +0000 Subject: [PATCH 2/4] Fix StopIteration error in getAlignedMapping for Biopython > 1.79 Co-authored-by: AnthonyBogetti <34397256+AnthonyBogetti@users.noreply.github.com> --- prody/proteins/compare.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/prody/proteins/compare.py b/prody/proteins/compare.py index 752892e19..47342889b 100644 --- a/prody/proteins/compare.py +++ b/prody/proteins/compare.py @@ -1387,10 +1387,20 @@ def _findAlignment(sequence, alignment): a = this[i] b = that[i] if a not in gap_chars: - ares = next(aiter) + try: + ares = next(aiter) + except StopIteration: + # Alignment string is longer than the actual sequence + # This can happen with different Biopython versions + break amatch.append(ares.getResidue()) if b not in gap_chars: - bres = next(biter) + try: + bres = next(biter) + except StopIteration: + # Chain sequence exhausted + bmatch.append(None) + break bmatch.append(bres.getResidue()) if a == b: n_match += 1 @@ -1398,7 +1408,11 @@ def _findAlignment(sequence, alignment): else: bmatch.append(None) elif b not in gap_chars: - bres = next(biter) + try: + bres = next(biter) + except StopIteration: + # Chain sequence exhausted + break return amatch, bmatch, n_match, n_mapped def getCEAlignMapping(target, chain): From e94c4af9471ef396c0ed6e49a69d75f8cdd4ca9a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 13 Feb 2026 16:43:43 +0000 Subject: [PATCH 3/4] Add logging and fix length mismatch in StopIteration handling Co-authored-by: AnthonyBogetti <34397256+AnthonyBogetti@users.noreply.github.com> --- prody/proteins/compare.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/prody/proteins/compare.py b/prody/proteins/compare.py index 47342889b..4d8d5ecff 100644 --- a/prody/proteins/compare.py +++ b/prody/proteins/compare.py @@ -1392,14 +1392,19 @@ def _findAlignment(sequence, alignment): except StopIteration: # Alignment string is longer than the actual sequence # This can happen with different Biopython versions + LOGGER.warn('Alignment string longer than target sequence for {0}, ' + 'truncating alignment at position {1}'.format(target.getTitle(), i)) break amatch.append(ares.getResidue()) if b not in gap_chars: try: bres = next(biter) except StopIteration: - # Chain sequence exhausted - bmatch.append(None) + # Chain sequence exhausted, need to remove the last target residue + # to keep amatch and bmatch synchronized + amatch.pop() + LOGGER.warn('Alignment string longer than chain sequence for {0}, ' + 'truncating alignment at position {1}'.format(chain.getTitle(), i)) break bmatch.append(bres.getResidue()) if a == b: @@ -1412,6 +1417,8 @@ def _findAlignment(sequence, alignment): bres = next(biter) except StopIteration: # Chain sequence exhausted + LOGGER.warn('Alignment string longer than chain sequence for {0}, ' + 'truncating alignment at position {1}'.format(chain.getTitle(), i)) break return amatch, bmatch, n_match, n_mapped From 122c8cef6794194e811e68849f76df2294f83a9a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 13 Feb 2026 16:44:26 +0000 Subject: [PATCH 4/4] Use LOGGER.warning instead of deprecated LOGGER.warn Co-authored-by: AnthonyBogetti <34397256+AnthonyBogetti@users.noreply.github.com> --- prody/proteins/compare.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/prody/proteins/compare.py b/prody/proteins/compare.py index 4d8d5ecff..a287ef921 100644 --- a/prody/proteins/compare.py +++ b/prody/proteins/compare.py @@ -1392,8 +1392,8 @@ def _findAlignment(sequence, alignment): except StopIteration: # Alignment string is longer than the actual sequence # This can happen with different Biopython versions - LOGGER.warn('Alignment string longer than target sequence for {0}, ' - 'truncating alignment at position {1}'.format(target.getTitle(), i)) + LOGGER.warning('Alignment string longer than target sequence for {0}, ' + 'truncating alignment at position {1}'.format(target.getTitle(), i)) break amatch.append(ares.getResidue()) if b not in gap_chars: @@ -1403,8 +1403,8 @@ def _findAlignment(sequence, alignment): # Chain sequence exhausted, need to remove the last target residue # to keep amatch and bmatch synchronized amatch.pop() - LOGGER.warn('Alignment string longer than chain sequence for {0}, ' - 'truncating alignment at position {1}'.format(chain.getTitle(), i)) + LOGGER.warning('Alignment string longer than chain sequence for {0}, ' + 'truncating alignment at position {1}'.format(chain.getTitle(), i)) break bmatch.append(bres.getResidue()) if a == b: @@ -1417,8 +1417,8 @@ def _findAlignment(sequence, alignment): bres = next(biter) except StopIteration: # Chain sequence exhausted - LOGGER.warn('Alignment string longer than chain sequence for {0}, ' - 'truncating alignment at position {1}'.format(chain.getTitle(), i)) + LOGGER.warning('Alignment string longer than chain sequence for {0}, ' + 'truncating alignment at position {1}'.format(chain.getTitle(), i)) break return amatch, bmatch, n_match, n_mapped