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.

  • Safe & Robust: Includes automatic buffer overflow protection and robust array size validations for extreme edge-cases.

  • 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 via PyPI. This requires zero C/Fortran compilers on your end.

pip install ringdetect-hpc

(Note: While the PyPI package is ringdetect-hpc, the Python module is imported as 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
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
rings = find_rings(x, y, z, elements, max_ring=6)

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 (Safely capped at 100). 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.1.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.1.0-cp313-cp313-macosx_15_0_arm64.whl (874.2 kB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

ringdetect_hpc-1.1.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.1.0-cp312-cp312-macosx_15_0_arm64.whl (874.2 kB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

ringdetect_hpc-1.1.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.1.0-cp311-cp311-macosx_15_0_arm64.whl (874.2 kB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

ringdetect_hpc-1.1.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.1.0-cp310-cp310-macosx_15_0_arm64.whl (874.2 kB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

ringdetect_hpc-1.1.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.1.0-cp39-cp39-macosx_15_0_arm64.whl (874.2 kB view details)

Uploaded CPython 3.9macOS 15.0+ ARM64

ringdetect_hpc-1.1.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.1.0-cp38-cp38-macosx_15_0_arm64.whl (874.0 kB view details)

Uploaded CPython 3.8macOS 15.0+ ARM64

ringdetect_hpc-1.1.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.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ringdetect_hpc-1.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 133720ce32000fca1a2fba8c7fcfd850bc3703f1fb563ce8805fabef04f2a325
MD5 6e42011d370c68664e0ea9f6315316bd
BLAKE2b-256 1d91262c420371b102a0a8598771795d49f1928eec8bb9ca0436c6864a7dcbd8

See more details on using hashes here.

Provenance

The following attestation bundles were made for ringdetect_hpc-1.1.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.1.0-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for ringdetect_hpc-1.1.0-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 914653309506c8e8d1afe6364b3547e2629b118d1b00d0639e37840b79bca58c
MD5 3120573d7a755e199788220db88c766a
BLAKE2b-256 000bae0842894b172f0b3efad05cf2f87e9ec99d54fce29a14dc27f3749218b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for ringdetect_hpc-1.1.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.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ringdetect_hpc-1.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fce2920f424ac386dd297f11b6c51647b8594ef7773e597d9476178c3a6b230b
MD5 c79d9e60e4702230b4809221ec8628e3
BLAKE2b-256 a326c08fe9a194cae584c916b670bb14f12968eba6966a52e976451b5fef0d56

See more details on using hashes here.

Provenance

The following attestation bundles were made for ringdetect_hpc-1.1.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.1.0-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for ringdetect_hpc-1.1.0-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 5287bb05b4a0d4cba3e532192c206db271a488f7408cdc479c40dd850c0bdef9
MD5 12a752e047241a44bd557b6ff4581d23
BLAKE2b-256 749fcfe9da34eb4a160d29f421ed0d1e156558087887c101137795223af30147

See more details on using hashes here.

Provenance

The following attestation bundles were made for ringdetect_hpc-1.1.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.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ringdetect_hpc-1.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 31783616a182e226d611452e68d9fcbdaf2a26dda238cd6e43fec803fc784015
MD5 7ba8df4b2b024157f9126ed9f4d3c94e
BLAKE2b-256 6182741070f89437c72ba0de322add99b409a1c7cd1a26f275eb5c62930d4df1

See more details on using hashes here.

Provenance

The following attestation bundles were made for ringdetect_hpc-1.1.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.1.0-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for ringdetect_hpc-1.1.0-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 dd1f36ffd5b3c939ad898ad9d2c5d9af6afcf2ef5c5c992e402a98c400c627ad
MD5 890f914005231e99722ebe21a5380e4b
BLAKE2b-256 ee893d1a3da8b8930f2fccb78ea41ad47100bd8b0f3499e9ebc499d62d9f3146

See more details on using hashes here.

Provenance

The following attestation bundles were made for ringdetect_hpc-1.1.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.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ringdetect_hpc-1.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 21b0c11407394dae5a3800af853f3abeb175a07387ffe1f93005a802c4092511
MD5 c6d25ca8ecb2f287ee0950904d49a49c
BLAKE2b-256 08ccafd0770728e9737727bcd3a4d0526553dd4ea75681b71417365b29cd624c

See more details on using hashes here.

Provenance

The following attestation bundles were made for ringdetect_hpc-1.1.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.1.0-cp310-cp310-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for ringdetect_hpc-1.1.0-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 64155c50f9af8d271711e3a77d975e3ff0b60232fd232709b67adfc18192f09a
MD5 393ec1516e10c00f89dc1bddffb9d343
BLAKE2b-256 86659fb2be7fd4e6ad61cfef64484d5b1cd470de464e9fe3cfde4dfe9b8dc824

See more details on using hashes here.

Provenance

The following attestation bundles were made for ringdetect_hpc-1.1.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.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ringdetect_hpc-1.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 35754bf7e9bda1c3f0d74b0647218a29ad14fa7a5da02b59225353107b2de761
MD5 19a397691a1182a2fe28150bfe65f658
BLAKE2b-256 fc4548f515668eb4a039257405559cd3452b5ca03278618b7063c91fd2cebacc

See more details on using hashes here.

Provenance

The following attestation bundles were made for ringdetect_hpc-1.1.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.1.0-cp39-cp39-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for ringdetect_hpc-1.1.0-cp39-cp39-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 bb0dcce125aaeae1de11a4c65df7f698ac893ab11fb0a66745df9a56ce7e261e
MD5 34ffe90904bed739b94d675e89d926ec
BLAKE2b-256 e768f31d4e6c70b0537de34071bea92e62d37563731cc25c843bc5f5870ff004

See more details on using hashes here.

Provenance

The following attestation bundles were made for ringdetect_hpc-1.1.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.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ringdetect_hpc-1.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7e3e7457d4fbe50f8fb41de01ff1ea23eaf412889270d35498c2ed89fd618c4f
MD5 da0686b14736040ced6a806f19976d58
BLAKE2b-256 f17460e56551365771c98341248df24aa595221da554f8a786da74ac91979cf9

See more details on using hashes here.

Provenance

The following attestation bundles were made for ringdetect_hpc-1.1.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.1.0-cp38-cp38-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for ringdetect_hpc-1.1.0-cp38-cp38-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 abfcc4c95b69d87bc391ba9c0b7478a51e5317de12f7be9c27a04c305bfedac5
MD5 ded14a6470ec1ff47c1091691b5f9512
BLAKE2b-256 5e1def2c9a10c5f6a20c02a5a0a1e06f4612da03639ee0c094d633e7424a2940

See more details on using hashes here.

Provenance

The following attestation bundles were made for ringdetect_hpc-1.1.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.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ringdetect_hpc-1.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 20064285f3494191ebf4fd2f311a080ef313c1538c2d13eca31cd18c2ac547f4
MD5 375fa14a7775b658b3a7bb1b9683befc
BLAKE2b-256 dfb037194392037c4132538af04e880c1c23a3ee6b569caa9a3bd2682deb5bdf

See more details on using hashes here.

Provenance

The following attestation bundles were made for ringdetect_hpc-1.1.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