HELP-23803 generate script for parsing OBS CCD IDs - #13
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a standalone Python utility script under the chemical-components example use cases to download the wwPDB CCD components CIF, parse for obsolete chemical component IDs, and write them to obsolete_ccd_id.list.
Changes:
- Introduces
parse_obsolete_ccd_ids.pyto downloadcomponents.cif.gzand unzip it locally. - Parses
chem_comp.pdbx_release_status == "OBS"records and collects theirchem_comp.idvalues. - Writes the obsolete CCD IDs to a newline-delimited output file.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
example-use-cases/chemical-components/parse_obsolete_ccd_ids.py:71
- Printing once per CCD data block will produce tens of thousands of lines for
components.cifand can slow the script substantially. Consider removing this line or making it conditional (e.g., a--verboseflag or periodic progress updates).
for data_container in l_data_container:
print("check CCD %s" % data_container.getName())
if data_container.getObj("chem_comp").getValue("pdbx_release_status", 0) == "OBS":
add error import Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
valasatava
left a comment
There was a problem hiding this comment.
It's great! Thank you!
piehld
left a comment
There was a problem hiding this comment.
Thanks @shaochenghua! Sorry for the delay in review. Please see my comments below.
| import shutil | ||
| import urllib.request | ||
| import urllib.error | ||
| from mmcif.io.IoAdapterCore import IoAdapterCore |
There was a problem hiding this comment.
Note that the mmcif package is only built for Linux and Mac, so if the user has a Windows, they will need to run this in a Unix environment (or via a Jupyter notebook).
| Returns: | ||
| str or None: Unzipped local filename on success, otherwise None. | ||
| """ | ||
| url = "https://files.wwpdb.org/pub/pdb/data/monomers/components.cif.gz" |
There was a problem hiding this comment.
This URL is going to change in the Beta Archive: https://files-beta.wwpdb.org/pub/wwpdb/refdata/chem_comp/components.cif.gz
You may want to introduce a try/except for when the transition happens, so that this script doesn't break.
E.g., first try https://files.wwpdb.org/pub/pdb/data/monomers/components.cif.gz, else try https://files.wwpdb.org/pub/wwpdb/refdata/chem_comp/components.cif.gz
| This script requires the following package, which can be installed with: | ||
| pip install mmcif |
There was a problem hiding this comment.
| This script requires the following package, which can be installed with: | |
| pip install mmcif | |
| This script requires the `mmcif` package, which can be installed with: | |
| pip install mmcif | |
| To run this script: | |
| python3 parse_obsolete_ccd_ids.py | |
| io = IoAdapterCore() | ||
| l_data_container = io.readFile(filename_in) | ||
| for data_container in l_data_container: | ||
| print("check CCD %s" % data_container.getName()) |
There was a problem hiding this comment.
This produces a huge output to stdout. I would either remove this, or replace all print statements to be logging statements, and make this one a DEBUG statement.
No description provided.