Skip to main content

HARMONSMILE: Harmonize SMILES Strings for Cheminformatics and Machine Learning

License: LGPL v3 Version PyPI Python Docs


Description

HARMONSMILE solves a common problem in cheminformatics: SMILES strings for the same molecule look different depending on the source (PubChem, ChEMBL, COCONUT, in-house databases). This inconsistency breaks comparisons, deduplication, and machine learning pipelines that expect a uniform molecular representation.

It is intended for computational chemists, cheminformatics researchers, ML practitioners preparing molecular datasets, and maintainers integrating PubChem, ChEMBL, and in-house sources.


Purpose

The primary objective of HARMONSMILE is to automate the preparation, standardization, and harmonization of molecular structure tables for cheminformatics workflows and machine learning applications within the computational drug discovery pipeline.

The platform enables:

  • Source-aware molecular table preparation: Ingests molecular identifiers or SMILES from PubChem, ChEMBL, and independent tabular datasets while preserving source traceability.
  • Deterministic identifier handling: Uses robust, alias-aware input detection for PubChem CIDs and emits a canonical PubChem_CID output column for downstream interoperability.
  • RDKit canonicalization: Generates SMILES_RDKit as a canonical/isomeric/Kekulé RDKit representation, preserving compatibility with workflows that use Kekulized SMILES for deduplication or comparison.
  • SMILES harmonization: Generates SMILES_Harmonized as a canonical/isomeric/aromatic representation after controlled RDKit-native standardization and harmonization.
  • Auditable status reporting: Reports harmonization outcomes through SMILES_Harmonization_Status and SMILES_Harmonization_Message, distinguishing successful harmonization, controlled transformations, unsupported ambiguous structures, and failures.
  • Cross-source comparison: Preserves structural bridge fields such as InChI and InChIKey to support comparison across PubChem, ChEMBL, and independent molecular databases.

SMILES Column Contract

HARMONSMILE exposes three universal SMILES representations in pipeline outputs:

  • SMILES: source/input SMILES. This is the value used as input for RDKit canonicalization and lab harmonization.
  • SMILES_RDKit: RDKit canonical + isomeric + Kekulized representation, produced by RDKitStandardizer.to_iso_kek(SMILES). This column is preserved for compatibility with v0.2.5. It is not a full chemical harmonization layer and does not intentionally desalt, neutralize, reionize, or canonicalize tautomers.
  • SMILES_Harmonized: lab-harmonized representation, produced by RDKitStandardizer.to_lab_harmonized(SMILES). It uses an RDKit-native MolStandardize policy with validation before automatic modification, controlled parent generation for simple salts/counterions, normalization, uncharging, reionization, optional tautomer canonicalization, and final canonical/isomeric/aromatic serialization.

SMILES_Harmonized is intended for database harmonization, deduplication, and cross-source matching. It is not guaranteed to represent the most stable, most abundant, pH-specific, or biologically active tautomer. HARMONSMILE does not export tautomer ensembles; it stores one canonical harmonized representation per input row. Source traceability is preserved through SMILES and SMILES_RDKit.

Rows are not dropped when harmonization fails. Instead, the result is carried in:

  • SMILES_Harmonization_Status: short filterable status returned by the harmonization engine: ok, ok_with_warnings, unsupported, or failed.
  • SMILES_Harmonization_Message: short auditable message for warnings, unsupported structures, or failures; empty/None for successful ok rows.

Some sources may also provide source-specific SMILES columns. For example, ConnectivitySMILES is a PubChem-provided connectivity SMILES column preserved when available; it is not generated by HARMONSMILE and is not present for all sources.


Installation

For package users:

Create and activate a Python environment:

conda create -n harmonsmile_env python=3.11
conda activate harmonsmile_env

Install HARMONSMILE from PyPI:

pip install harmonsmile

For contributors/developers:

Clone the repository:

git clone https://github.com/NanoBiostructuresRG/harmonsmile.git
cd harmonsmile

Create and activate the development environment:

conda env create -f environment.yml
conda activate harmonsmile_env

Install HARMONSMILE in editable mode with development dependencies:

python -m pip install -e .[dev]

RDKit is a required runtime dependency (rdkit>=2022.09). For package users, it is declared in pyproject.toml and installed through the package dependency resolver. For contributors, environment.yml preinstalls RDKit from conda-forge for a stable local scientific stack.


Quick Start

Python API

Standardize a single SMILES string:

from harmonsmile import RDKitStandardizer

std = RDKitStandardizer()
print(std.to_iso_kek("c1ccccc1"))    # canonical + isomeric + Kekulized
print(std.to_conn_kek("c1ccccc1"))   # canonical + connectivity-only + Kekulized

Fetch properties from PubChem and harmonize:

from harmonsmile import PubChemIngest, PubChemConfig, save_table

cfg = PubChemConfig(
    input_path="examples/example_pubchem.csv",   # requires: id, PubChem CID
)
df = PubChemIngest(cfg).run()
save_table(df, "results/example_pubchem_harmonized.csv")

Fetch properties from ChEMBL and harmonize:

from harmonsmile import ChEMBLIngest, ChEMBLConfig, save_table

cfg = ChEMBLConfig(
    input_path="examples/example_chembl.csv",    # requires: id, ChEMBL ID
)
df = ChEMBLIngest(cfg).run()
save_table(df, "results/example_chembl_harmonized.csv")

Harmonize any file with a SMILES column (COCONUT, in-house, etc.):

from harmonsmile import SMILESPrep, SMILESConfig, save_table

cfg = SMILESConfig(
    input_path="examples/example_smiles.csv",
    smiles_col="SMILES",                      # any column name
)
df = SMILESPrep(cfg).run()
save_table(df, "results/example_smiles_harmonized.csv")

Command-Line Interface

# PubChem pipeline
harmonsmile --pubchem-in examples/database1.csv --pubchem-out results/database1_harmonized.csv

# SMILES pipeline (COCONUT, independent, etc.)
harmonsmile --smiles-in examples/database2.csv --smiles-col canonical_smiles \
            --smiles-out results/database2_harmonized.csv

# Both pipelines in one run
harmonsmile \
  --pubchem-in examples/database1.csv --pubchem-out results/database1_harmonized.csv \
  --smiles-in  examples/database2.csv --smiles-col  canonical_smiles \
  --smiles-out results/database2_harmonized.csv

# Single Entry - fetch one compound by ID
harmonsmile --pubchem-cid 2723949
harmonsmile --chembl-id CHEMBL294199

# Check version
harmonsmile --version

Also available as a Python module:

python -m harmonsmile --pubchem-in examples/database1.csv --pubchem-out results/out.csv

Pipelines

Pipeline Config Source Input API
PubChemIngest PubChemConfig PubChem CSV with PubChem CID column REST (public)
ChEMBLIngest ChEMBLConfig ChEMBL CSV with ChEMBL ID column REST (public)
SMILESPrep SMILESConfig Any CSV/Excel with any SMILES column Local file

All pipelines preserve the source SMILES, append SMILES_RDKit, and append the lab harmonization columns SMILES_Harmonized, SMILES_Harmonization_Status, and SMILES_Harmonization_Message. Pipeline .run() methods return a pandas.DataFrame and do not write files. Use save_table(df, path) to persist results from Python, or use the CLI --*-out options.


Input Format

Pipeline Required columns
PubChemIngest id (optional), PubChem CID
ChEMBLIngest id (optional), ChEMBL ID
SMILESPrep id (optional), <smiles_col> (any name)

Supported file formats: CSV, TSV, XLSX, XLS.


Roadmap

  • v0.3.0 - Lab-harmonized SMILES contract/layer for database harmonization, deduplication, and cross-source matching.

Development

Project Structure

HARMONSMILE/
|-- harmonsmile/
|   |-- __init__.py        # Public API
|   |-- __main__.py        # python -m harmonsmile entry point
|   |-- _cli.py            # CLI implementation
|   |-- chembl.py          # ChEMBL REST client
|   |-- config.py          # PubChemConfig, ChEMBLConfig, SMILESConfig dataclasses
|   |-- io.py              # Table I/O utilities
|   |-- pipelines.py       # PubChemIngest, ChEMBLIngest, SMILESPrep
|   |-- pubchem.py         # PubChem REST client
|   |-- standardize.py     # RDKitStandardizer
|   `-- version.py         # Package version metadata
|-- tests/                 # Unit test suite (pytest) - 146 tests
|-- examples/              # Example scripts and datasets
|-- pyproject.toml
|-- environment.yml
|-- mkdocs.yml
|-- requirements-dev.txt
|-- CHANGELOG.md
|-- CITATION.cff
|-- CODE_OF_CONDUCT.md
|-- CONTRIBUTING.md
|-- COPYING
|-- COPYING.LESSER
|-- LICENSE
`-- README.md

Running Tests

python -m pytest tests -p no:cacheprovider --basetemp .pytest_tmp

Contributing

Contributions are welcome. Please open an issue before submitting a pull request. Follow the existing code style: NumPy-style docstrings, type hints, and SPDX license headers in all source files.

See CONTRIBUTING.md for full guidelines. Please also read our Code of Conduct.


Citation

If you use HARMONSMILE in your research, please cite it using the metadata in CITATION.cff or the format below:

Contreras-Torres, F. F. (2026). HARMONSMILE: Harmonize SMILES Strings for
Cheminformatics and Machine Learning. Zenodo. https://doi.org/10.5281/zenodo.20275498

Author

Developed by Flavio F. Contreras-Torres (Tecnologico de Monterrey) Monterrey, Mexico - May 2026


License

This project is licensed under the terms of the GNU Lesser General Public License v3.0 or later. SPDX identifier: LGPL-3.0-or-later.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

harmonsmile-0.3.2.tar.gz (56.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

harmonsmile-0.3.2-py3-none-any.whl (40.3 kB view details)

Uploaded Python 3

File details

Details for the file harmonsmile-0.3.2.tar.gz.

File metadata

  • Download URL: harmonsmile-0.3.2.tar.gz
  • Upload date:
  • Size: 56.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for harmonsmile-0.3.2.tar.gz
Algorithm Hash digest
SHA256 fad6d230f5c2de5da411c475c437b85dc6fe07e53f008cb97aed0665b81d75ab
MD5 d849ba73416fc966606af4c9c5488c41
BLAKE2b-256 a7dc3e55a418976ad34f57d0359bebf021ef18b0079cc27720d8653301f096de

See more details on using hashes here.

Provenance

The following attestation bundles were made for harmonsmile-0.3.2.tar.gz:

Publisher: publish-to-pypi.yml on NanoBiostructuresRG/harmonsmile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file harmonsmile-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: harmonsmile-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 40.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for harmonsmile-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c39aeb4b666ddbcf50f33ac7905e91e291655579c3c4198c24e15a99a617d229
MD5 3cd7d348a57cd6133bbc119ac308650a
BLAKE2b-256 06937d184b7a7bfa2233d29f1a7bf2b34097542930022f87d9fd9a43557623eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for harmonsmile-0.3.2-py3-none-any.whl:

Publisher: publish-to-pypi.yml on NanoBiostructuresRG/harmonsmile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.3.3

2 files

This release

0.3.2 This release

2 files

0.3.1

2 files

0.3.0

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page