Super useful resource—thanks!

#1
by DuckyPhD - opened

Thanks for providing this PubChem snapshot! I stream-parsed all 173 ZIPs and confirmed ~119 M CID–SMILES entries.
Note that despite the numeric ranges in the filenames, each file actually contains < 500 k compounds, so the naming can be a bit misleading.

MolSSI AI Hub org

Thanks for providing this PubChem snapshot! I stream-parsed all 173 ZIPs and confirmed ~119 M CID–SMILES entries.
Note that despite the numeric ranges in the filenames, each file actually contains < 500 k compounds, so the naming can be a bit misleading.

Hi @DuckyPhD and thank you for your comment. Credit goes to the PubChem team for doing a fantastic job on this dataset over the years.
We merely made them ML-ready for a broader usage by the computational molecular science community.

You observation is valid but I do disagree that the absence of some Compound IDs (CIDs) in each range may be misleading. The file index ranges (steps of 500k) are reflective of the structure of the PubChem source file repository PubChem FTP repository as detailed in the PubChem documentation. The absence of some CIDs is simply reflective of the dynamic nature of the PubChem dataset: entries are continuously added or removed from the dataset but CIDs remain unique. In order to ensure the reproducibility of the workflows using our dataset snapshots, we have added a calendar versioning tag to each dataset.

Hi @smostafanejad and the MolSSI AI Hub team—thanks again for making this snapshot available! I’ve been working with the CID–SMILES pairs (all ~112 million entries) and they’ve been incredibly helpful. I was wondering: is there a way to access or download the full JSON records for each of those ~112 million compounds (i.e., with all associated metadata and fields), if those are available? Having the complete JSON would streamline downstream parsing and feature extraction in my workflows. Thanks in advance for any pointers!

MolSSI AI Hub org

Hi @smostafanejad and the MolSSI AI Hub team—thanks again for making this snapshot available! I’ve been working with the CID–SMILES pairs (all ~112 million entries) and they’ve been incredibly helpful. I was wondering: is there a way to access or download the full JSON records for each of those ~112 million compounds (i.e., with all associated metadata and fields), if those are available? Having the complete JSON would streamline downstream parsing and feature extraction in my workflows. Thanks in advance for any pointers!

There are at least two ways you can do it:

  • The Hugging Face dataset is hosted in a git repository on the Hub. So, you can clone it:
# Make sure git-lfs is installed (https://git-lfs.com)
git lfs install
# clone the repository on local disk
git clone https://huggingface.co/datasets/molssiai-hub/pubchem-04-18-2025
  • A simpler way might be to just turn off the streaming mode in your load_dataset function by setting streaming=False (it is False by default). You can use a snippet like the one below
ds = load_dataset(
    path="molssiai-hub/pubchem-04-18-2025",
    trust_remote_code=True,
    cache_dir="./tmp"
)

The function call above stores the json files in the tmp folder within current working directory. The JSON files are stored by their SHA256 hash number (used as filenames) and do not have a .json extension.
If you have a powerful machine with many cores, you can add the num_proc=N (where N is the number of parallel processes) to your function call to speed up the process.
Hope this helps.

Thanks so much for the detailed explanation and support, @smostafanejad ! Just to clarify what I meant: on the PubChem compound pages, each compound (like aspirin, CID 2244) has a full JSON record that can be accessed via the PUG-View API, for example: https://pubchem.ncbi.nlm.nih.gov/rest/pug_view/data/compound/2244/JSON/?response_type=display

I was wondering if there’s a way to get a similar full metadata JSON for all ~112M compounds in the snapshot (in bulk or batch mode) — not just CID–SMILES pairs, but including full category information like pharmacology, properties, etc., that are usually bundled in the official PubChem JSON format.

If that's not included in the dataset, I might explore API batching or scraping, but I wanted to check first in case there's already a more efficient option. Thanks again for the amazing work!

MolSSI AI Hub org

Thanks so much for the detailed explanation and support, @smostafanejad ! Just to clarify what I meant: on the PubChem compound pages, each compound (like aspirin, CID 2244) has a full JSON record that can be accessed via the PUG-View API, for example: https://pubchem.ncbi.nlm.nih.gov/rest/pug_view/data/compound/2244/JSON/?response_type=display

I was wondering if there’s a way to get a similar full metadata JSON for all ~112M compounds in the snapshot (in bulk or batch mode) — not just CID–SMILES pairs, but including full category information like pharmacology, properties, etc., that are usually bundled in the official PubChem JSON format.

If that's not included in the dataset, I might explore API batching or scraping, but I wanted to check first in case there's already a more efficient option. Thanks again for the amazing work!

I'm afraid that is the way to go if you would like to have all that data locally. Good luck!

smostafanejad changed discussion status to closed
Your need to confirm your account before you can post a new comment.

Sign up or log in to comment