Skip to main content

Pure Python chemistry library with zero dependencies

Project description

chiralipy

Chiralipy is a pure Python library for SMILES/SMARTS parsing, canonicalization, and molecular manipulation.

Installation

pip install -e .

Quick Start

from chiralipy import parse, canonical_smiles

# Parse and canonicalize
mol = parse("C(C)CC")
print(canonical_smiles(mol))  # CCCC

# Substructure matching
from chiralipy.match import substructure_search
mol = parse("c1ccccc1CCO")
pattern = parse("[OH]")
matches = substructure_search(mol, pattern)  # [(7,)]

# BRICS decomposition
from chiralipy.decompose import brics_decompose
mol = parse("CCOc1ccc(CC)cc1")
fragments = brics_decompose(mol)
print(sorted(fragments))
# ['[16*]c1ccc([16*])cc1', '[3*]O[4*]', '[4*]CC', '[8*]CC']

Features

  • SMILES/SMARTS parsing with full stereochemistry support
  • Canonical SMILES generation
  • Substructure matching (RDKit-compatible)
  • BRICS decomposition for retrosynthetic fragmentation
  • Aromaticity perception based on Hückel's 4n+2 rule
  • Ring detection (SSSR algorithm)
  • Zero dependencies — pure Python

Core API

from chiralipy import parse, canonical_smiles, to_smiles

from chiralipy.match import substructure_search, has_substructure
from chiralipy.decompose import brics_decompose, get_scaffold
from chiralipy.rings import find_sssr
from chiralipy.transform import kekulize

Benchmark: BRICS Decomposition

Comparison against RDKit (C++ implementation):

Molecule            Atoms  Bonds   RDKit ms  chiralipy ms    Ratio
----------------------------------------------------------------
small_ether             5      4     0.37       0.60      1.62x
medium_drug            15     15     0.88       1.89      2.13x
drug_like              37     41     3.54       5.05      1.43x
large_complex          84     98     5.04      13.33      2.64x

Average: ~2x slower than RDKit

License

MIT

Project details


Download files

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

Source Distribution

chiralipy-0.1.0.tar.gz (77.0 kB view details)

Uploaded Source

Built Distribution

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

chiralipy-0.1.0-py3-none-any.whl (63.2 kB view details)

Uploaded Python 3

File details

Details for the file chiralipy-0.1.0.tar.gz.

File metadata

  • Download URL: chiralipy-0.1.0.tar.gz
  • Upload date:
  • Size: 77.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for chiralipy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c3f8b778f22499a32207369a608e996b2d1e2e4c39a0f3871dd557396a4f347d
MD5 fd265cb10843a424aa27d6013bebab39
BLAKE2b-256 7e3ef8ced9735fb5803a358ef04726e023a12c7c19180d45d55ae877f6d0393f

See more details on using hashes here.

Provenance

The following attestation bundles were made for chiralipy-0.1.0.tar.gz:

Publisher: python-publish.yml on levlai/chiralipy

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

File details

Details for the file chiralipy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: chiralipy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 63.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for chiralipy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 060babf409566f728f6992a08617d733ece3804f22387c7b12ce128a2e2900b0
MD5 6a49a453825aaa9dccac6f2c0ce1607a
BLAKE2b-256 5631e50a5a2b991a174abac2850763c6bd1811399d91173c2f9673cc7b918e33

See more details on using hashes here.

Provenance

The following attestation bundles were made for chiralipy-0.1.0-py3-none-any.whl:

Publisher: python-publish.yml on levlai/chiralipy

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page