Skip to content

Fix FileNotFoundError when custom template filenames use upper-case PDB codes or extensions - #851

Open
crfield18 wants to merge 3 commits into
sokrypton:mainfrom
crfield18:main
Open

crfield18 wants to merge 3 commits into
sokrypton:mainfrom
crfield18:main

Conversation

@crfield18

Copy link
Copy Markdown

File changed: AlphaFold2.ipynb

Issue

AlphaFold's _get_pdb_id_and_chain (alphafold/data/templates.py) always lowercases the 4-character PDB code before looking up the template file on disk. The notebook saves uploaded custom templates using their original casing:

for fn in uploaded.keys():
    os.rename(fn,os.path.join(custom_template_path,fn))

So uploading e.g. 5HBF.cif causes:

FileNotFoundError: [Errno 2] No such file or directory: '<jobname>/template/5hbf.cif'

Fix

Normalize the filename's stem and extension to lower case before saving:

for fn in uploaded.keys():
    base, ext = os.path.splitext(fn)
    dest_fn = base.lower() + ext.lower()
    os.rename(fn, os.path.join(custom_template_path, dest_fn))
    print(f"saved template: {fn} -> {dest_fn}")

Handles .pdb/.cif uploads in any casing (5HBF.CIF, 5hbf.PDB, etc.).

crfield18 and others added 3 commits September 2, 2026 14:28
…ectly from PDB use uppercase, causing FileNotFoundError.
Took upstream's notebook as-is and reapplied only the lower-casing fix for
custom template filenames, dropping the unrelated JSON key reordering.

Co-authored-by: Perplexity <[email protected]>
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.

1 participant