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.

  • Universal Periodic Table: Automatically calculates dynamic bond cutoffs based on comprehensive covalent radii for the entire periodic table (Elements 1-96).

  • Fragment Masking (Subsetting): Instantly isolate specific active sites or ligands in massive proteins by passing a binary mask, entirely bypassing the $O(N^2)$ graph math for ignored atoms.

  • 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 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 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](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 & Fragment Masking

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)

# NEW in v1.2.0: Fragment Masking
# Only search for rings within a specific subset of atoms (0-indexed)
active_subset = [0, 1, 2, 3, 4, 5]
masked_rings = find_rings(x, y, z, elements, active_atoms=active_subset)

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
-a NEW: Active atoms mask (comma-separated ranges or single indices) to isolate sub-graphs. All -a 1-15,30,45-50
-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 Runs

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

Analyze only the active site (atoms 100 through 150) of a massive PDB protein to save CPU time:

./ring_detector 1crn.pdb -f pdb -a 100-150

📄 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, applies masking logic, 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.2.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.2.0-cp313-cp313-macosx_15_0_arm64.whl (874.6 kB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

ringdetect_hpc-1.2.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.2.0-cp312-cp312-macosx_15_0_arm64.whl (874.6 kB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

ringdetect_hpc-1.2.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.2.0-cp311-cp311-macosx_15_0_arm64.whl (874.6 kB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

ringdetect_hpc-1.2.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.2.0-cp310-cp310-macosx_15_0_arm64.whl (874.6 kB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

ringdetect_hpc-1.2.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.2.0-cp39-cp39-macosx_15_0_arm64.whl (874.6 kB view details)

Uploaded CPython 3.9macOS 15.0+ ARM64

ringdetect_hpc-1.2.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.2.0-cp38-cp38-macosx_15_0_arm64.whl (874.4 kB view details)

Uploaded CPython 3.8macOS 15.0+ ARM64

ringdetect_hpc-1.2.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.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ringdetect_hpc-1.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 11b56e85e2b83387e53d50188d1a2420812185214c53ffa1abcbc2c86a83d64a
MD5 cdbfd109e836df451faabc4cc93c1edc
BLAKE2b-256 04f88d9ad91a0989bc0ce57f9fe015c733a0e1ea2e5340746080841b03705a13

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ringdetect_hpc-1.2.0-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 c70167612a0fa0e2ff7b775e0e3e21be493a4869ae14401fd72f4ceb94cccbde
MD5 da5aeb672f3f4c93c42c8939931db572
BLAKE2b-256 9195c8687b700eecd74c8290d2dec9b07ca20108bd3fc0f727fe6d0ac16e6fb7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ringdetect_hpc-1.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0e8563c0604d1f0bb0371f646103f4f1f191ee464714d8937c9e3f054ca362ac
MD5 f51ad5b73a66555d8577ce371ffa724b
BLAKE2b-256 bce90228c373686ac90d707ed77d161c28eab094cdb571c175de359c4749cc73

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ringdetect_hpc-1.2.0-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 8dd4b3c3b003482f152c066bcdbeb0fbdea0f12978b92ca99609d215c1e0a74d
MD5 a319981076e94273059949fe5308496d
BLAKE2b-256 5cd19bceda5c0d412ff81bb774e620b182e0ca5ae7944a3751bfa003ddcee411

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ringdetect_hpc-1.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 94f5c018f869b3c1e783c58207b03bf0ffaff3878bac3f6ba87fe28a8bee3604
MD5 b4df7015c1068e828f02769d9cf8fb92
BLAKE2b-256 21fc7ce584302d3bfe8e9dceaded964736b6572990f8b4890598127291e998f2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ringdetect_hpc-1.2.0-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 5547bebd2ce8bdd00f5c07c0d7fcafd11d98c84cb971049ce82f53d45bd3b0e1
MD5 c1c25aa9af9dea8908230e920ad1bf6f
BLAKE2b-256 fa2c31036008a9b66a4b4ed92765a12c817b10b556d5dced2f57f473b9036df4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ringdetect_hpc-1.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9266c95b8188adbe75bdf24bbcb22a057456b58522b847ed9e7b341c88553263
MD5 95f0b7d942c2f4f66f805029fd69c5f9
BLAKE2b-256 5a1e53ddd93451b8b0f41c2302f25ae1de7090da7a3d7de3d8cc2be0db01b58d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ringdetect_hpc-1.2.0-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 f54906504fdb58c29305b944d7979d6ec3742c7be687dcf87bfb5ec214e2194a
MD5 2717c5d4df9c35da87946d0b5c2a661a
BLAKE2b-256 e84ad65949861172c412962cb341496c4f38c240d683b32d1abc6a214672202f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ringdetect_hpc-1.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0d909f9374fdc2a188197916cc67d345102dc54490212eab5d5e77c54949a1ab
MD5 04aa24b516a45606ff27176fbeee6cab
BLAKE2b-256 7bbd7c91e2b9ca4b51e8fbcc1780d90e243fca75bb1d4ef9f0841a1f9e9a1a44

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ringdetect_hpc-1.2.0-cp39-cp39-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 cd594a1de395c68b8f6527c2094acdb9c1ca2f92fdc4c0c080b8c934a8bf3303
MD5 81a06836a84ec3bd77f2ba0b85d5afc4
BLAKE2b-256 d1aea0bbc7ab62db9788b6e690a75891fa670d0c650a6f26b92410223d17f56a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ringdetect_hpc-1.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 54c4734534286d8b4c54e479683a2e3d92512e66c29de6592ea71eb6520e12bb
MD5 44becb11a70a843b2e1bef68bca9eb58
BLAKE2b-256 a7ae19baef05b1c5482311eebf7a46e9bbc1f43a518c854639d15632788440fc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ringdetect_hpc-1.2.0-cp38-cp38-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 82c1a03ef926b5fdc84bb7013d3a82c884bdcd2a3a9e75ff608a42784d5a1557
MD5 b18399022ef4a6eafaf2a02b3f1bda28
BLAKE2b-256 b34338b893bc4c82f0d5edb02f56c348656c65a83d6da131d01bfcb09704e049

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ringdetect_hpc-1.2.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fb161a9ce1563d8a05f10d387649dba05b49615d0aff4c7f7e7726469ed7fe9f
MD5 e7a638f106ef13b8256109a9c528d0f3
BLAKE2b-256 c53562de81768b9e8ad0586678e7ea8c04b978c32e10a18cdaade162b03e4d77

See more details on using hashes here.

Provenance

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