IHM (Integrative/Hybrid Modeling) Python Library

raw JSON →
2.10 verified Fri May 01 auth: no python

A Python library for handling mmCIF and BinaryCIF files used in integrative/hybrid modeling, as defined by the wwPDB IHM extension. Version 2.10 is current. It supports reading, writing, and validating IHM mmCIF/BinaryCIF files, with features such as restraint representation, ensemble modeling, and reference sequence handling. The library is maintained by the IHM Working Group.

pip install ihm
error ModuleNotFoundError: No module named 'ihm'
cause Library not installed.
fix
Run 'pip install ihm'.
error ModuleNotFoundError: No module named 'msgpack'
cause msgpack not installed, required for BinaryCIF support.
fix
Run 'pip install msgpack' or 'pip install ihm[bcif]'.
error AttributeError: module 'ihm' has no attribute 'CifWriter'
cause Incorrect import path; CifWriter is in ihm.format.
fix
Use 'from ihm.format import CifWriter'.
error ValueError: invalid character in entity sequence
cause Entity sequence contains invalid characters (only standard amino acid codes allowed).
fix
Check sequence for non-standard characters; use 'X' or 'O' for non-standard as needed.
gotcha The 'ihm' library only supports Python 3.6+; Python 2 is not supported.
fix Use Python 3.6 or later.
deprecated The 'ihm.format.CifWriter' class replaced the older writer pattern. Use 'from ihm.format import CifWriter' instead of deprecated 'ihm.io' or 'ihm.cif'.
fix Update imports to use 'from ihm.format import CifWriter'.
gotcha When using BinaryCIF, the msgpack package is required but not installed by default; install with 'pip install ihm[bcif]' or manually.
fix Run 'pip install msgpack' or 'pip install ihm[bcif]'.
breaking In version 2.0, the 'SeqDif' class was moved from 'ihm.reference' to 'ihm.reference.SeqDif' – old imports may break.
fix Use 'from ihm.reference import SeqDif'.

Minimal example: create a system with one protein entity, an asym unit, and an assembly, then write a mmCIF file.

import ihm
import ihm.location
import ihm.model
import ihm.restraint

# Create a minimal IHM system
system = ihm.System()

# Add a protein entity
entity = ihm.Entity()
entity.description = "My protein"
entity.sequence = "MVLSPADKTNVKAAWGKVGAHAGEYGAEALERMFLSFPTTKTYFPHFDLSHG"
system.entities.append(entity)

# Add an asym unit
asym = ihm.AsymUnit(entity=entity, details="Chain A")
system.asym_units.append(asym)

# Create an assembly
assembly = ihm.Assembly()
assembly.append(asym)

# Write a mmCIF string
from io import StringIO
from ihm.format import CifWriter
out = StringIO()
writer = CifWriter(out)
writer.write(system)
print(out.getvalue()[:500])