Skip to main content

Fast CIF file parsing for molecular structures

Project description

Overview

ciffy is a fast CIF file parser for molecular structures, with a C backend and Python interface.

Installation

From PyPI

pip install ciffy

From Source

git clone https://github.com/hmblair/ciffy.git
cd ciffy
pip install -r requirements.txt
pip install torch-scatter --no-build-isolation
pip install -e .

Note on torch-scatter

ciffy requires torch-scatter, which may need to be installed separately depending on your platform:

Linux/Windows with CUDA:

# Replace CUDA with your version (e.g., cu118, cu121) or cpu
pip install torch-scatter -f https://data.pyg.org/whl/torch-2.7.0+${CUDA}.html

macOS or if pre-built wheels are unavailable:

pip install torch-scatter --no-build-isolation

Usage

import ciffy

# Load a structure from a CIF file
polymer = ciffy.load("structure.cif")

# Basic information
print(polymer)  # Summary of chains, residues, atoms

# Access coordinates and properties
coords = polymer.coordinates      # (N, 3) tensor
atoms = polymer.atoms             # (N,) tensor of atom types
sequence = polymer.str()          # Sequence string

# Geometric operations
centered, means = polymer.center(ciffy.MOLECULE)
aligned, Q = polymer.align(ciffy.CHAIN)
distances = polymer.pd(ciffy.RESIDUE)

# Selection
rna_chains = polymer.subset(ciffy.RNA)
backbone = polymer.backbone()

# Iterate over chains
for chain in polymer.chains(ciffy.RNA):
    print(chain.id(), chain.str())

# Compute RMSD between structures
rmsd = ciffy.rmsd(polymer1, polymer2, ciffy.MOLECULE)

Module Structure

ciffy/
├── types/          # Scale, Molecule enums
├── biochemistry/   # Element, Residue, nucleotide definitions
├── operations/     # Reduction, alignment operations
├── io/             # File loading and writing
└── utils/          # Helper functions and base classes

Testing

pip install pytest
pytest tests/

Project details


Download files

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

Source Distribution

ciffy-0.4.7.tar.gz (47.7 kB view details)

Uploaded Source

File details

Details for the file ciffy-0.4.7.tar.gz.

File metadata

  • Download URL: ciffy-0.4.7.tar.gz
  • Upload date:
  • Size: 47.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ciffy-0.4.7.tar.gz
Algorithm Hash digest
SHA256 966b47f032fa944128e8cfc497f0a7de8bf61121334cb1824fd0b8858c078481
MD5 f6ac9891348f6796772196113f2aa6b0
BLAKE2b-256 6c6a6f48cba4c463a05f162ae0050a42c8605c0b811ca036fc4538a563d3f883

See more details on using hashes here.

Provenance

The following attestation bundles were made for ciffy-0.4.7.tar.gz:

Publisher: pypi.yml on hmblair/ciffy

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