Skip to main content

A blisteringly fast Fortran engine for molecular cycle perception.

Project description

RingDetect-HPC

PyPI version License: MIT

A blisteringly fast command-line utility and Python library for detecting specific molecular rings (cycles) from various structural coordinate files (XYZ, PDB, MOL, CSV) and Python objects (ASE, RDKit).

Built for computational chemistry pipelines (like EDDB, topological analysis, and materials science), RingDetect-HPC pairs a C/Python frontend for dynamic memory management with a Fortran 2008 backend for heavy graph traversal. It is deeply parallelized using OpenMP to process massive macromolecular systems and crystal lattices in fractions of a second.

🚀 Key Features

  • Dual Interface: Run it as a standalone, zero-dependency command-line executable, or import it natively into your Python workflows with zero-copy array pointers.
  • Periodic Boundary Conditions (PBC): Seamlessly handles MOFs, zeolites, and crystal lattices by applying the Minimum Image Convention (MIC) during spatial hashing.
  • Geometric Planarity Checking: Automatically computes normal vectors on the fly to detect if a cycle is geometrically planar (aromaticity/conformation indicator).
  • O(N) Spatial Hashing: Instantly builds adjacency matrices without O(N^2) distance bottlenecks.
  • Zero-Allocation Search: Uses in-place array mutation during Depth-First Search (DFS) to completely eliminate RAM allocation locks.
  • JSON Export: Output raw paths to standard text files, or strict JSON formats for easy parsing by Pandas and web dashboards.

📦 Installation

You can install RingDetect-HPC in two ways, depending on your workflow.

Option 1: Python Library (Recommended)

Pre-compiled binaries (wheels) are available for Linux and macOS. This requires zero C/Fortran compilers on your end.

pip install ringdetect

Option 2: Bare-Metal CLI (For HPC Clusters)

If you want the standalone executable, you can compile from source. Zero dependencies required other than standard compilers (gcc, gfortran, make).

git clone [https://github.com/ouielba90/RingDetect-HPC.git](https://github.com/ouielba90/RingDetect-HPC.git)
cd RingDetect-HPC
make

(This generates a highly optimized executable named ring_detector.)


🐍 Python Usage

The Python API uses ctypes to pass data directly into Fortran's RAM without writing temporary files.

1. Raw Coordinates

from ringdetect import find_rings

x = [0.0000, 1.2098, 1.2098, 0.0000, -1.2098, -1.2098]
y = [1.3970, 0.6985, -0.6985, -1.3970, -0.6985, 0.6985]
z = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
elements = ["C", "C", "C", "C", "C", "C"]

# Find up to 6-membered rings using 4 CPU cores
rings = find_rings(x, y, z, elements, max_ring=6, threads=4)

print(rings)
# Output: [{'size': 6, 'planar': True, 'indices': [1, 2, 3, 4, 5, 6]}]

2. Third-Party Integrations (ASE & RDKit)

If you are already using popular computational chemistry libraries, you can pass those objects directly:

from ringdetect import find_rings_ase, find_rings_rdkit
from ase.io import read
from rdkit import Chem

# With ASE (Automatically detects Periodic Boundary Conditions!)
atoms = read("crystal_lattice.cif")
rings = find_rings_ase(atoms, max_ring=8)

# With RDKit
mol = Chem.MolFromMolFile("molecule.mol")
rings = find_rings_rdkit(mol, max_ring=6)

💻 CLI Usage

./ring_detector <molecule_file> [OPTIONS]

Command Line Options

Flag Description Default Example
-h, --help Show the help menu. ./ring_detector -h
-f Set the input coordinate format (xyz, raw, csv, idx, pdb, mol). xyz -f pdb
-c Set unit cell dimensions (X Y Z) for Periodic Boundary Conditions. 0.0 0.0 0.0 -c 15.5 15.5 15.5
-m Maximum ring depth to search. 6 -m 10
-r Target specific ring sizes (comma-separated). Overrides -m. All -r 5,6
-p Number of OpenMP threads to use. (0 = All physical cores) 0 -p 8
-s Character used to separate atom indices in the output file. ' ' -s -
-j Output results in strict JSON format instead of standard text. OFF -j

Example Run

To search a crystal XYZ file for only 5-membered and 6-membered rings, applying a 15.0 Å unit cell, using 8 CPU cores, and outputting to JSON:

./ring_detector crystal.xyz -c 15.0 15.0 15.0 -r 5,6 -p 8 -j

📄 Output Formats

The engine dynamically generates output using the base name of your input (e.g., running c60.xyz generates c60.rings or c60.json in the execution directory).

Standard Text (.rings)

Heavily optimized for downstream text parsing. Includes geometric planarity detection.

5-MR: 1-5-4-10-9
6-MR (PLANAR): 1-2-15-14-13-12
6-MR: 2-3-17-16-15-1

JSON Format (-j)

Strict JSON payload, perfect for loading directly into Pandas DataFrames or web interfaces.

{
  "molecule": "c60",
  "total_atoms": 60,
  "rings": [
    {"size": 5, "planar": false, "indices": [1, 5, 4, 10, 9]},
    {"size": 6, "planar": true, "indices": [1, 2, 15, 14, 13, 12]}
  ]
}

🏗️ Architecture Stack

  1. src/main.c / ringdetect/engine.py: Executes data parsing (skipping PDB headers, extracting ASE geometry, etc.), translates atomic symbols to covalent radii, allocates contiguous memory blocks, and passes zero-copy pointers to Fortran.
  2. src/ring_engine.f90: Receives pointers via iso_c_binding, builds the OpenMP spatial hash (applying Minimum Image Convention if PBC is active), and launches an optimized, lock-free Depth-First Search with in-flight vector math to isolate and classify the Minimum Cycle Basis. Temp files are streamed dynamically and merged instantly upon completion.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

ringdetect_hpc-1.0.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

ringdetect_hpc-1.0.0-cp313-cp313-macosx_15_0_arm64.whl (872.6 kB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

ringdetect_hpc-1.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

ringdetect_hpc-1.0.0-cp312-cp312-macosx_15_0_arm64.whl (872.6 kB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

ringdetect_hpc-1.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

ringdetect_hpc-1.0.0-cp311-cp311-macosx_15_0_arm64.whl (872.6 kB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

ringdetect_hpc-1.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

ringdetect_hpc-1.0.0-cp310-cp310-macosx_15_0_arm64.whl (872.6 kB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

ringdetect_hpc-1.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

ringdetect_hpc-1.0.0-cp39-cp39-macosx_15_0_arm64.whl (872.6 kB view details)

Uploaded CPython 3.9macOS 15.0+ ARM64

ringdetect_hpc-1.0.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

ringdetect_hpc-1.0.0-cp38-cp38-macosx_15_0_arm64.whl (872.6 kB view details)

Uploaded CPython 3.8macOS 15.0+ ARM64

ringdetect_hpc-1.0.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

File details

Details for the file ringdetect_hpc-1.0.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ringdetect_hpc-1.0.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b35e2270d8798eb365a93d66c0cb986f4957aaabe9043fedc39796ef81f2db35
MD5 653e1b0d5b4c44eed1d1967ca532c3ec
BLAKE2b-256 c2731364134e116a570b32624880c05cf1673858f6f85ff0cfc03b9940a03db8

See more details on using hashes here.

Provenance

The following attestation bundles were made for ringdetect_hpc-1.0.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build_wheels.yml on ouielba90/RingDetect-HPC

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

File details

Details for the file ringdetect_hpc-1.0.0-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for ringdetect_hpc-1.0.0-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 03cf4ec196e0e6cc08565e4c50efc176996be3bdbc72ae3b7243fa353560babf
MD5 fe9516b574ec14f9ded986e591c3f675
BLAKE2b-256 16c5d3c074a857c4488a106bb5b6e81a25a6d9e758a47249a4c2cc5f87a212b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for ringdetect_hpc-1.0.0-cp313-cp313-macosx_15_0_arm64.whl:

Publisher: build_wheels.yml on ouielba90/RingDetect-HPC

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

File details

Details for the file ringdetect_hpc-1.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ringdetect_hpc-1.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5e627d9120db27461f7a5ec35471ad0013a3ec38ee17a51cef0a4ee04c2eef5f
MD5 ebc4208f6052b2466da1df2f1e556b5a
BLAKE2b-256 b30f1e312ee9f8118db8bb0a0dfebf772b6b0fecbd8b335a50ceeb3ef5a766a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for ringdetect_hpc-1.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build_wheels.yml on ouielba90/RingDetect-HPC

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

File details

Details for the file ringdetect_hpc-1.0.0-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for ringdetect_hpc-1.0.0-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 12e443a297ad3ecbc779ac75fffb4da0f99ab4f012cb605f1a7066dfaebc6571
MD5 d71f5037a4fde2c78d9a29bd5b1b95f4
BLAKE2b-256 7f1f0b03fb698e5391f47d300ff3f0e89868c7c8ba84f53c52787d633ec703cc

See more details on using hashes here.

Provenance

The following attestation bundles were made for ringdetect_hpc-1.0.0-cp312-cp312-macosx_15_0_arm64.whl:

Publisher: build_wheels.yml on ouielba90/RingDetect-HPC

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

File details

Details for the file ringdetect_hpc-1.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ringdetect_hpc-1.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 67b972bc539da1af334ef31a3e3077807a02aef557583a875cd9eecd4fbbfad4
MD5 276e0efa15e05ff69a1856ffb35c46a0
BLAKE2b-256 74f7f06b8746700e90829778af4855f18b0cc0f7df2ea4c67469ddfbb8ef9bfa

See more details on using hashes here.

Provenance

The following attestation bundles were made for ringdetect_hpc-1.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build_wheels.yml on ouielba90/RingDetect-HPC

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

File details

Details for the file ringdetect_hpc-1.0.0-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for ringdetect_hpc-1.0.0-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 34486a194027702513eb851a6c40f4c0b61b9ab94f5ac0cfe1d76c1ef800ccae
MD5 af260497bbf05cd2878233314e5a6807
BLAKE2b-256 1fd912993bc107eb65cb0f90070f6f4d2949b1866ceed437893f59052ddc3d70

See more details on using hashes here.

Provenance

The following attestation bundles were made for ringdetect_hpc-1.0.0-cp311-cp311-macosx_15_0_arm64.whl:

Publisher: build_wheels.yml on ouielba90/RingDetect-HPC

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

File details

Details for the file ringdetect_hpc-1.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ringdetect_hpc-1.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b1f8b5c98bdf42d187cf70af8dc1daad3856acd1f858775a6dfc92030b899087
MD5 462d6b5a1c58d0b35fdd544dbd9a898a
BLAKE2b-256 ea7396eb2c84502d12b8a902c9abf6c41acbcb69d7d58dc26c1d9942a6a555f5

See more details on using hashes here.

Provenance

The following attestation bundles were made for ringdetect_hpc-1.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build_wheels.yml on ouielba90/RingDetect-HPC

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

File details

Details for the file ringdetect_hpc-1.0.0-cp310-cp310-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for ringdetect_hpc-1.0.0-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 cc738fcd769e858d611a8c1bfadca4747328cee73df31293557f2e8e0320f694
MD5 b9650e5766fd11a9e50f15481265ba4c
BLAKE2b-256 91f22c6fe3234b56a67106f82de5470ce7bab8488c75369722bf6b4ab6a2f3c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for ringdetect_hpc-1.0.0-cp310-cp310-macosx_15_0_arm64.whl:

Publisher: build_wheels.yml on ouielba90/RingDetect-HPC

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

File details

Details for the file ringdetect_hpc-1.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ringdetect_hpc-1.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 10f1a47abe9300b9817aec4cae758edeecb5b8dd76a628f288b48bf25c47d3eb
MD5 58a262d3cc7afaaf2c87997ff932df4d
BLAKE2b-256 52a587ae3883d6659f7928a52ef9b5df304763fad934ab5de2acee36de46ea01

See more details on using hashes here.

Provenance

The following attestation bundles were made for ringdetect_hpc-1.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build_wheels.yml on ouielba90/RingDetect-HPC

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

File details

Details for the file ringdetect_hpc-1.0.0-cp39-cp39-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for ringdetect_hpc-1.0.0-cp39-cp39-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 9e3d7b7c793655409207a568bdc9d31f7305b54f82da9a5d6e0bfb87bac58e63
MD5 04efe5472f2de8c304294d5b4c6ebcc2
BLAKE2b-256 af2e837c162350af016076a15f13e48926d92f0f28b0dec5029b1adce1098d82

See more details on using hashes here.

Provenance

The following attestation bundles were made for ringdetect_hpc-1.0.0-cp39-cp39-macosx_15_0_arm64.whl:

Publisher: build_wheels.yml on ouielba90/RingDetect-HPC

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

File details

Details for the file ringdetect_hpc-1.0.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ringdetect_hpc-1.0.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2dda6858336bcaa40fb4d54afbf1ce633a7f2ae9f4e0b5c7717e1aaf28257f6d
MD5 7fd030e7e237cd2934556623151cb9e4
BLAKE2b-256 91c78a0dbbef6b52910d31969ab8f0468e647801b41f523cc79028cea8230d93

See more details on using hashes here.

Provenance

The following attestation bundles were made for ringdetect_hpc-1.0.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build_wheels.yml on ouielba90/RingDetect-HPC

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

File details

Details for the file ringdetect_hpc-1.0.0-cp38-cp38-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for ringdetect_hpc-1.0.0-cp38-cp38-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 c12057033e388e1b7faed33be14fbab19341994213a879bb09b6f223b74cf7f4
MD5 e61da43ca067a7cb5e411e0e5d945245
BLAKE2b-256 a10406dac470709f6756850560732c70d15aad61a8f526b5dd6bc7f360cd7f78

See more details on using hashes here.

Provenance

The following attestation bundles were made for ringdetect_hpc-1.0.0-cp38-cp38-macosx_15_0_arm64.whl:

Publisher: build_wheels.yml on ouielba90/RingDetect-HPC

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

File details

Details for the file ringdetect_hpc-1.0.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ringdetect_hpc-1.0.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dae0e455ac7a48f955713e697f3b4d2959d235d66dde7a1fffc7580336a2c578
MD5 be1af943a647cd536ff7df1d618e38c9
BLAKE2b-256 8dd494ff784c21c895b43febb6e773017249b9c0c7755dc9d099cd38e2062024

See more details on using hashes here.

Provenance

The following attestation bundles were made for ringdetect_hpc-1.0.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build_wheels.yml on ouielba90/RingDetect-HPC

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