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 static structural coordinate files (XYZ, PDB, MOL, CSV), Python objects (ASE, RDKit), and massive Molecular Dynamics (MD) trajectories.

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

  • MD Trajectory Analysis: Natively parse multi-frame .xyz files (10,000+ frames) or read directly from standard input pipelines to analyze ring dynamics over time.
  • 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.

📦 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)

# Fragment Masking: Only search for rings within a specific subset of atoms
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)

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)

3. Molecular Dynamics (MDAnalysis)

Loop over massive compressed trajectories natively in Python without writing intermediate files:

import MDAnalysis as mda
from ringdetect import find_rings

u = mda.Universe("protein.pdb", "trajectory.xtc")
protein = u.select_atoms("protein")

for ts in u.trajectory:
    pos = protein.positions
    rings = find_rings(pos[:,0], pos[:,1], pos[:,2], list(protein.elements))
    print(f"Frame {ts.frame}: {len(rings)} rings detected.")

💻 CLI Usage

./ring_detector <molecule_file> [OPTIONS]

(Note: To read from standard input, use - as the <molecule_file> name).

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 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

Analyze a 10,000-frame MD trajectory using 8 P-cores and outputting to JSON:

./ring_detector md_trajectory.xyz -f xyz -j -p 8

Pipe directly from GROMACS to avoid saving a massive text file to your disk:

gmx trjconv -s prod.tpr -f prod.xtc -o .xyz | ./ring_detector - -f xyz -j

📄 Output Formats

The engine dynamically generates output using the base name of your input. For multi-frame trajectories, output is automatically grouped by frame.

Standard Text (.rings)

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

=== FRAME 1 ===
5-MR: 1-5-4-10-9
6-MR (PLANAR): 1-2-15-14-13-12
=== FRAME 2 ===
5-MR: 1-5-4-10-9

JSON Format (-j)

Strict JSON payload, perfect for loading directly into Pandas DataFrames for plotting frame-by-frame network stability.

{
  "molecule": "md_trajectory",
  "frames": [
    {
      "frame": 1,
      "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, manages multi-frame I/O streams, 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.3.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.3.0-cp313-cp313-macosx_15_0_arm64.whl (874.8 kB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

ringdetect_hpc-1.3.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.3.0-cp312-cp312-macosx_15_0_arm64.whl (874.8 kB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

ringdetect_hpc-1.3.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.3.0-cp311-cp311-macosx_15_0_arm64.whl (874.8 kB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

ringdetect_hpc-1.3.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.3.0-cp310-cp310-macosx_15_0_arm64.whl (874.8 kB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

ringdetect_hpc-1.3.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.3.0-cp39-cp39-macosx_15_0_arm64.whl (874.8 kB view details)

Uploaded CPython 3.9macOS 15.0+ ARM64

ringdetect_hpc-1.3.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.3.0-cp38-cp38-macosx_15_0_arm64.whl (874.6 kB view details)

Uploaded CPython 3.8macOS 15.0+ ARM64

ringdetect_hpc-1.3.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.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ringdetect_hpc-1.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f4b3bd8bd94d0649cb2f7a4c94042f33695644e2cfbac75793457254cae51325
MD5 50b001fa244779bafd210e662b8f506c
BLAKE2b-256 7b741a57c901edf36abacaf15775ea57f44f072b92a9e2fb027994bfffb79583

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ringdetect_hpc-1.3.0-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 cea2baf9726da5ac8dd6e20214b2c3aebf1c74460495a0cd8cf8522d0905c25e
MD5 0dfaa3799097c1dab417b1e305ec3c7b
BLAKE2b-256 6c2d3af1414653125b6df307d83be587d7cd26ba6ac17b19df6eb8fe0328547b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ringdetect_hpc-1.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 36d6e95e8a2426130c291e2bf5a047dd4c650487721eb1e45390cab5ca309399
MD5 52f68ac332af33cdfc3dd5d8384fc38e
BLAKE2b-256 64b062eeaf62d8600f741957fb06da4939f687a4b0005dc35f17dae9c709d850

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ringdetect_hpc-1.3.0-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 bcdc73c7e2d81b741fd2089a6cad61db0c4cbad9e2c531b82598f169d419925b
MD5 16c6ba36cef44c3ec7041914fbf64740
BLAKE2b-256 4977e7426c606d60df0b5545966ef4c64f63b0d5239d1b40ff1e13d98dc835eb

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ringdetect_hpc-1.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 47dc7f7dc59981003cebf7c4665b02c5c6c5ef5f2c4b1a174366e4cf286f313b
MD5 f027d7e312da042462afd15ea4d43b22
BLAKE2b-256 ee690d837507614d98981fb0906e1a8024469ad4c80e3eca75e1942e81fe47c0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ringdetect_hpc-1.3.0-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 e637361f4b6539bc5e1440e0f8376b6255eff11678d6c056144bba7259634859
MD5 27bc21387cff513fb7fe2eb85fec839b
BLAKE2b-256 13ab1742a3c62a56909b8893e5c0611511d251da24ca73108a67e4be664ea4e8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ringdetect_hpc-1.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 010eae20dff95cb5083c81369a12db54bf2f7aa2b1e4d9037de21e269f9028d6
MD5 38951d520c1adeb17a9504a70de5a0e2
BLAKE2b-256 6b38a3d9d6abca3c4b72fc074bfe5f3bf7452296655b3657c7c93a0b9a92a4a3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ringdetect_hpc-1.3.0-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 168eb6601db5d304248ace281037a7fd2b53352fcabacafef445ef03eb6c6953
MD5 fc939679dac2791c08eb7cf62c79f7a6
BLAKE2b-256 be99a1202ace11798f865c0f7b398e19381668b6a46a61a40243a890c540b18c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ringdetect_hpc-1.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1665c2975c125e2c185c4868b566d41a8f766c1aa0142e0b390f46910c424777
MD5 5c9e6182f588c12a22e56e4ab72d2cb3
BLAKE2b-256 55ae4ffbd0648fadcad1cb803b51cfcadf309270b985fa3529ae00a9c937bae3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ringdetect_hpc-1.3.0-cp39-cp39-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 f3eb7d0f5f3d627ffebe9fc2493d81fb32cc33a747608a7d0cd2b22f405be5d2
MD5 e748e88b3eb756c5ee689daa220c7e58
BLAKE2b-256 6dd0ab03764d380bdaa833ef45ac8fa30380af2c6c5527da0cc1843e39ad1b36

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ringdetect_hpc-1.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1c5db6743c492ce722b68921a28d949cd1a53886fd4bc850c999f63a867cfbe3
MD5 20804af3af806bbf21b11138da12065c
BLAKE2b-256 c0dc4f79445a790a1f9fb4b00c09cc797248ca790ac82ec0eaff2b1601e11da9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ringdetect_hpc-1.3.0-cp38-cp38-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 23cd5e65cf41fb444881c18d6459e76eab7f5948583dd59b6a1425c3498e34f3
MD5 03ddb04d49dcb2bbe5326169b5cbede5
BLAKE2b-256 74d4aba831f571381b08f12e2d93d474242c57ee84c47d2fe46e0748191dbb57

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ringdetect_hpc-1.3.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 85f96769d03ea2463f48b5a284e4a8e98b51ebd799afac7f83a24a436a68afc9
MD5 75b71df1ae08c14529964cf08a60c988
BLAKE2b-256 ba2affd6313489f42151176b8b88f2bc26aadf8669b9cbb9691ca4c9fd7f5926

See more details on using hashes here.

Provenance

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