Add proper error handling for missing required fields in mmCIF parser #2198
+46
−10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The mmCIF parser raised cryptic
KeyErrorexceptions when required fields were missing from files (e.g., PDB entry 7O07), making it difficult to diagnose malformed files.Changes
Added try/except blocks with informative error messages for 10 required mmCIF fields in
prody/proteins/ciffile.py:pdbx_PDB_model_num,group_PDBid,type_symbol,label_atom_id,label_alt_idlabel_asym_id,auth_asym_idCartn_x,Cartn_y,Cartn_zEach missing field now raises
MMCIFParseErrorwith the field name instead of rawKeyError.Example
The coordinate fields use separate try/except blocks to identify exactly which coordinate (x/y/z) is missing rather than a generic "coordinate field" message.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
files.rcsb.org/usr/bin/python3 python3 -c import prody; prody.parsePDB('7O07')(dns block)/usr/bin/wget wget -q REDACTED -O 7o07.pdb re/include(dns block)/usr/bin/wget wget -q REDACTED -O 7o07.cif(dns block)ftp.wwpdb.org/usr/bin/python3 python3 -c import prody; prody.parsePDB('7O07')(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.