Skip to content

Skip template mmCIFs that biopython cannot parse (#610) - #866

Open
AtharvaTilewale wants to merge 1 commit into
sokrypton:mainfrom
AtharvaTilewale:fix/610-skip-unparsable-templates
Open

AtharvaTilewale wants to merge 1 commit into
sokrypton:mainfrom
AtharvaTilewale:fix/610-skip-unparsable-templates

Conversation

@AtharvaTilewale

@AtharvaTilewale AtharvaTilewale commented Oct 24, 2026 •

Copy link
Copy Markdown

Problem

With --templates --local-pdb-path ..., a single malformed entry in a local PDB mirror aborts the whole colabfold_batch run:

  File ".../colabfold/batch.py", line 240, in mk_hhsearch_db
    structure = parser.get_structure("none", cif_fh)
Bio.PDB.PDBExceptions.PDBConstructionException: Atom C defined twice in residue <Residue LYS het=  resseq=91 icode= >

Reported in #610 for entries such as 4udf and 1ejg.

Root cause

mk_hhsearch_db parses every *.cif in the template directory with MMCIFParser and has no exception handling, so one unparsable file ends the run even though the other templates are fine. The surrounding code already warns-and-continues for the comparable cases (multiple models, insertion codes).

What the fix does

Catch PDBConstructionException around parser.get_structure, log a warning naming the file, and continue with the next template. A skipped file is simply absent from the hhsearch database, so it cannot be selected as a hit.

Other failure modes (e.g. the ValueError that validate_and_fix_mmcif raises for mmCIFs that are missing required fields) are deliberately left untouched here.

Validation

Added tests/test_templates.py, which writes two synthetic one-residue mmCIFs into a temp directory — one valid, one with an atom defined twice, as in the report — runs mk_hhsearch_db on it, and checks that the run completes, the bad file is warned about, and the good chain is in pdb70_a3m.ffdata while the bad one is not.

Pre-patch (git stash push colabfold/batch.py, test kept):

$ pytest tests/test_templates.py -q
    raise PDBConstructionException(
E   Bio.PDB.PDBExceptions.PDBConstructionException: Atom C defined twice in residue <Residue LYS het=  resseq=1 icode= >
1 failed

Post-patch:

$ pytest tests/test_templates.py -q
1 passed

$ pytest -q
29 passed, 20 skipped, 7 errors

The 7 errors are tests/test_colabfold.py prediction tests, which need network access to download parameters/MSAs; they error identically on unmodified main in this environment (baseline there is 28 passed, 20 skipped, 7 errors).

Fixes #610

Disclosure: this change was prepared with AI assistance and validated locally as described above.

mk_hhsearch_db parses every file in the template directory, so a single
malformed entry of a local PDB mirror (e.g. 4udf or 1ejg, "Atom C defined
twice") raised PDBConstructionException and aborted the whole run. Warn
and skip that file instead, so the remaining templates are still used.

Fixes sokrypton#610
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error in Local Template Search

1 participant