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)