Skip to content

HELP-23803 generate script for parsing OBS CCD IDs - #13

Open
shaochenghua wants to merge 4 commits into
masterfrom
chenghua
Open

HELP-23803 generate script for parsing OBS CCD IDs#13
shaochenghua wants to merge 4 commits into
masterfrom
chenghua

Conversation

@shaochenghua

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.py to download components.cif.gz and unzip it locally.
  • Parses chem_comp.pdbx_release_status == "OBS" records and collects their chem_comp.id values.
  • 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.

Comment thread example-use-cases/chemical-components/parse_obsolete_ccd_ids.py
Comment thread example-use-cases/chemical-components/parse_obsolete_ccd_ids.py
Comment thread example-use-cases/chemical-components/parse_obsolete_ccd_ids.py

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.cif and can slow the script substantially. Consider removing this line or making it conditional (e.g., a --verbose flag 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":

Comment thread example-use-cases/chemical-components/parse_obsolete_ccd_ids.py
Comment thread example-use-cases/chemical-components/parse_obsolete_ccd_ids.py Outdated
shaochenghua and others added 2 commits July 27, 2026 17:08
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 valasatava left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's great! Thank you!

@piehld piehld left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@piehld piehld Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines +5 to +6
This script requires the following package, which can be installed with:
pip install mmcif

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

4 participants