From cbee234d53ad9f38f707e0699c5750e0de5c09f5 Mon Sep 17 00:00:00 2001 From: Mohamed Lemine Ahmed Jidou Date: Tue, 21 Apr 2026 07:14:59 -0400 Subject: [PATCH] Fix pipeline crashes caused by integer overflow and OOB array access --- alphafold/common/protein.py | 3 ++- alphafold/data/parsers.py | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/alphafold/common/protein.py b/alphafold/common/protein.py index 02419fa5..c2b2d06a 100644 --- a/alphafold/common/protein.py +++ b/alphafold/common/protein.py @@ -297,7 +297,8 @@ def to_pdb(prot: Protein) -> str: charge = '' # PDB is a columnar format, every space matters here! atom_line = ( - f'{record_type:<6}{atom_index:>5} {name:<4}{alt_loc:>1}' + display_index = atom_index % 100000 + f'{record_type:<6}{display_index:>5} {name:<4}{alt_loc:>1}' f'{res_name_3:>3} {chain_ids[chain_index[i]]:>1}' f'{residue_index[i]:>4}{insertion_code:>1} ' f'{pos[0]:>8.3f}{pos[1]:>8.3f}{pos[2]:>8.3f}' diff --git a/alphafold/data/parsers.py b/alphafold/data/parsers.py index 7101782a..e70c0371 100644 --- a/alphafold/data/parsers.py +++ b/alphafold/data/parsers.py @@ -140,6 +140,11 @@ def parse_stockholm(stockholm_string: str) -> Msa: keep_columns = [i for i, res in enumerate(query) if res != '-'] # Remove the columns with gaps in the query from all sequences. + if keep_columns and len(sequence) <= max(keep_columns): + raise ValueError( + f'Malformed MSA: Hit sequence length ({len(sequence)}) is strictly ' + f'shorter than required columns ({max(keep_columns)}).' + ) aligned_sequence = ''.join([sequence[c] for c in keep_columns]) msa.append(aligned_sequence)