mmCIF parser written in Nim with Python bindings
Project description
nim-mmcif
Fast mmCIF (Macromolecular Crystallographic Information File) parser written in Nim with Python bindings via nimporter.
The goal of this repository is to experiment with vibe coding while building something useful for bioinformatics community, to see how much of a cross platform library can be driven to completion by transformers
Features
- 🚀 High-performance parsing of mmCIF files using Nim
- 🐍 Seamless Python integration via nimporter
- 🌍 Cross-platform support (Linux, macOS, Windows)
- 🏗️ Automatic compilation on import
- 📦 Easy installation via pip
Installation
Prerequisites
- Python 3.8 or higher
- Nim compiler (see platform-specific instructions)
From PyPI (when available)
pip install nim-mmcif
From Source
# Install Nim (platform-specific, see below)
# macOS: brew install nim
# Linux: curl https://nim-lang.org/choosenim/init.sh -sSf | sh
# Windows: scoop install nim
# Install the package
git clone https://github.com/lucidrains/nim-mmcif
cd nim-mmcif
pip install -e .
For detailed platform-specific instructions, see CROSS_PLATFORM.md.
Quick Start
import nim_mmcif
# Parse an mmCIF file
data = nim_mmcif.parse_mmcif("path/to/file.mmcif")
print(f"Found {len(data['atoms'])} atoms")
# Get atom count directly
count = nim_mmcif.get_atom_count("path/to/file.mmcif")
print(f"File contains {count} atoms")
# Get all atoms with their properties
atoms = nim_mmcif.get_atoms("path/to/file.mmcif")
for atom in atoms[:5]: # Print first 5 atoms
print(f"Atom {atom['id']}: {atom['label_atom_id']} at ({atom['x']}, {atom['y']}, {atom['z']})")
# Get just the 3D coordinates
positions = nim_mmcif.get_atom_positions("path/to/file.mmcif")
for i, (x, y, z) in enumerate(positions[:5]):
print(f"Position {i}: ({x:.3f}, {y:.3f}, {z:.3f})")
API Reference
Functions
parse_mmcif(filepath: str) -> dict
Parse an mmCIF file and return a dictionary with parsed data.
get_atom_count(filepath: str) -> int
Get the number of atoms in an mmCIF file.
get_atoms(filepath: str) -> list[dict]
Get all atoms from an mmCIF file as a list of dictionaries.
get_atom_positions(filepath: str) -> list[tuple[float, float, float]]
Get 3D coordinates of all atoms as a list of (x, y, z) tuples.
Atom Properties
Each atom dictionary contains:
type: Record type (ATOM or HETATM)id: Atom serial numberlabel_atom_id: Atom namelabel_comp_id: Residue namelabel_asym_id: Chain identifierlabel_seq_id: Residue sequence numberx,y,z: 3D coordinates (aliases for Cartn_x, Cartn_y, Cartn_z)occupancy: Occupancy factorB_iso_or_equiv: B-factor- And more...
Platform Support
| Platform | Architecture | Python | Status |
|---|---|---|---|
| Linux | x64, ARM64 | 3.8-3.12 | ✅ |
| macOS | x64, ARM64 | 3.8-3.12 | ✅ |
| Windows | x64 | 3.8-3.12 | ✅ |
Building from Source
Automatic Build
python build_nim.py
Manual Build
cd nim_mmcif
nim c --app:lib --out:nim_mmcif.so nim_mmcif.nim # Linux/macOS
nim c --app:lib --out:nim_mmcif.pyd nim_mmcif.nim # Windows
Development
Running Tests
pip install pytest
pytest tests/ -v
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests
- Submit a pull request
Documentation
- Cross-Platform Guide - Platform-specific build instructions
- Nimporter Setup - Details on nimporter integration
Performance
The Nim implementation provides significant performance improvements over pure Python parsers, especially for large mmCIF files commonly used in structural biology.
License
MIT License - see LICENSE file for details.
Acknowledgments
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nim_mmcif-0.0.10.tar.gz.
File metadata
- Download URL: nim_mmcif-0.0.10.tar.gz
- Upload date:
- Size: 18.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
691aada53d9e1753851811d2f6ae39725c963d4b45c4efab5eef6eb24e42406d
|
|
| MD5 |
11f7c69ebe57cae3c9ec4b3ca6abfded
|
|
| BLAKE2b-256 |
b21a6a15b349eb4b4c15491cae8ed2df40a6a4ec4236b0b0418493f4fd92b71b
|
File details
Details for the file nim_mmcif-0.0.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: nim_mmcif-0.0.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 86.4 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
580bc9752dd77fb015bfdc192665b4c9ae21c90f00a92604f25b8f3e31d767e7
|
|
| MD5 |
a8df76718177fd8ee84bfbd16a959f4e
|
|
| BLAKE2b-256 |
b0ece7b0d469263b43a51b662121117e6f2b1e2aecb02477b5f00d2f1076dd24
|
File details
Details for the file nim_mmcif-0.0.10-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: nim_mmcif-0.0.10-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 59.5 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68926f990b0448e4237ec479980a83f79f052c616dcad06bcedb5eb607f163fd
|
|
| MD5 |
6e983d9937963f48e561b808257a0c6c
|
|
| BLAKE2b-256 |
7734cc11fabd25a28d7d244404e8fd9314b2881950e4d4e230ef6f915b0afadb
|
File details
Details for the file nim_mmcif-0.0.10-cp312-cp312-macosx_10_9_x86_64.whl.
File metadata
- Download URL: nim_mmcif-0.0.10-cp312-cp312-macosx_10_9_x86_64.whl
- Upload date:
- Size: 59.1 kB
- Tags: CPython 3.12, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54acf1a8fc903e9ce327c451a7fba0c27c5189fd5dfb91483957037717238e23
|
|
| MD5 |
a6e895037ce655d249826400bb1dc171
|
|
| BLAKE2b-256 |
bf4590bd8591a220a50685134fe55e5d5e952a9bb4f139675209991fb8b63d32
|
File details
Details for the file nim_mmcif-0.0.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: nim_mmcif-0.0.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 86.3 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6aaa17d13b69ce3bf2c7ffe95a16b36cee2a81866fef1d953e318ee878c56d43
|
|
| MD5 |
c0c16d4e47014a241bcc04e70ad889da
|
|
| BLAKE2b-256 |
fd4b3f0266a618509a9684df200961836591c3471794bcf2650b18ea4781ac5e
|
File details
Details for the file nim_mmcif-0.0.10-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: nim_mmcif-0.0.10-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 59.5 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13500495d84fbd6dc97593216c7da2a92c8b5beddcd0f41f625793b967690e82
|
|
| MD5 |
1f9f1f17f9ae2495b681de4346ce6d43
|
|
| BLAKE2b-256 |
d810fb1c717cf38241f4c5df2babf21a3bbf397e5ed8d7d9a0a87d75964604f6
|
File details
Details for the file nim_mmcif-0.0.10-cp311-cp311-macosx_10_9_x86_64.whl.
File metadata
- Download URL: nim_mmcif-0.0.10-cp311-cp311-macosx_10_9_x86_64.whl
- Upload date:
- Size: 59.1 kB
- Tags: CPython 3.11, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d315c8021ce7414dba1510f72a4d9517be8b11968b34565a8ab240414f9a64ff
|
|
| MD5 |
7764c3073ce4f80bf46b97c38b8faaad
|
|
| BLAKE2b-256 |
b4beec9bc0a1ca1ff8d84c72f572aae59dc6624a06afa45a99c0bae28fc88a62
|
File details
Details for the file nim_mmcif-0.0.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: nim_mmcif-0.0.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 86.3 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a32847c62c58604f3bf336b511d1d6bbb464ef396fe0c15c8719a9530bd505c
|
|
| MD5 |
f6c5ceeddb45508741cfb87792adbea0
|
|
| BLAKE2b-256 |
c373f6d4ce4ebb0308b27a768e5f3482417e8dc52d3f8249d8a41f450c7c58cc
|
File details
Details for the file nim_mmcif-0.0.10-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: nim_mmcif-0.0.10-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 59.5 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c684753c18237776135cd2e5b87e75efafe3142736a2cc5ac89ad23be1743ebc
|
|
| MD5 |
be334ed2e198ebfe38dd08a688af2ba8
|
|
| BLAKE2b-256 |
636fa6c82163d172ea26e5661e7b5a477db05633e435bc75ae8682c3ac447927
|
File details
Details for the file nim_mmcif-0.0.10-cp310-cp310-macosx_10_9_x86_64.whl.
File metadata
- Download URL: nim_mmcif-0.0.10-cp310-cp310-macosx_10_9_x86_64.whl
- Upload date:
- Size: 59.1 kB
- Tags: CPython 3.10, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
412a9079970182258a06dfdec1a825d1053968b82a0d25deba488b7e1a664cc6
|
|
| MD5 |
30df91b01dc265bed4eb510d10eba296
|
|
| BLAKE2b-256 |
fc48dff84d0cc87095e7ce20e1fc430bc792311d7f5e54bb59ffa8a74e5b00cd
|
File details
Details for the file nim_mmcif-0.0.10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: nim_mmcif-0.0.10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 86.1 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6b0d9555910d9ea9f2cce3f541363f99415ee320905a0020da17468c047dd55
|
|
| MD5 |
5341f4ea99a0a2fbe49e112599b2b9a9
|
|
| BLAKE2b-256 |
ea1f240b2ce5b60a3c4c2afec06e77adcb67f7ae2b1c70d4fbcf327f2f0877c1
|
File details
Details for the file nim_mmcif-0.0.10-cp39-cp39-macosx_11_0_arm64.whl.
File metadata
- Download URL: nim_mmcif-0.0.10-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 59.5 kB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ecd7d9bff9fdacb03f8b2d9132251b21020c70dac3c2c5ebbb497d87389e98a
|
|
| MD5 |
897fb096e20f02bc465873e2731b303d
|
|
| BLAKE2b-256 |
cc5d3ae640fb6cde07ecc9a6dbe45b2676951debebfb80adea40907d1178ae07
|
File details
Details for the file nim_mmcif-0.0.10-cp39-cp39-macosx_10_9_x86_64.whl.
File metadata
- Download URL: nim_mmcif-0.0.10-cp39-cp39-macosx_10_9_x86_64.whl
- Upload date:
- Size: 59.1 kB
- Tags: CPython 3.9, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e98e8f1c7f59724f7e690e1eb3e879f4073a0d2f2bd3021476fcf8da60a8b2b
|
|
| MD5 |
5944c9b8fb6e3c415b044b73c33d04b6
|
|
| BLAKE2b-256 |
091d7c66e41c9eff40baf9d7129d1273e7823352e909adbf79fd906a3457eaae
|
File details
Details for the file nim_mmcif-0.0.10-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: nim_mmcif-0.0.10-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 16.6 kB
- Tags: CPython 3.8, manylinux: glibc 2.28+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04da48efa77fdb9179a4f8c6cea07516a74c61bf0290e2c1ed18593de8a43574
|
|
| MD5 |
aa7f24124a1e620704bc5092a06ebc00
|
|
| BLAKE2b-256 |
a92a5c99bd58ae55ec6cbee844f1199ecf769b7a5b3147d2044b025e2595b243
|
File details
Details for the file nim_mmcif-0.0.10-cp38-cp38-macosx_11_0_arm64.whl.
File metadata
- Download URL: nim_mmcif-0.0.10-cp38-cp38-macosx_11_0_arm64.whl
- Upload date:
- Size: 11.3 kB
- Tags: CPython 3.8, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e362dc29dede70e0c0bda224495a65764e63456a8d5ab6a7ae8b724928513caa
|
|
| MD5 |
a850daeab46c3aa7a5cf277a40586db8
|
|
| BLAKE2b-256 |
b861289dbcc5e769dd4071da7c4e42a1cff92749d9c6bd8ef019d9fa7dabf3b4
|
File details
Details for the file nim_mmcif-0.0.10-cp38-cp38-macosx_10_9_x86_64.whl.
File metadata
- Download URL: nim_mmcif-0.0.10-cp38-cp38-macosx_10_9_x86_64.whl
- Upload date:
- Size: 10.9 kB
- Tags: CPython 3.8, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e0bbee5dbbde8b5fb0dd421d6ef0b4877fbcefff51d9183e5f74046b39b6634
|
|
| MD5 |
5e65d8bfb96d53a4e343680dca937bea
|
|
| BLAKE2b-256 |
b33eaa8e41ed9ce9bc2593040e613384de524076a270fa94e078fc329bcbd43a
|