Registry / data / modelcif

modelcif

JSON →
library1.7pypypi✓ verified 84d ago

A Python package for handling ModelCIF mmCIF and BinaryCIF files, used for representing comparative protein structure models and their metadata. It builds on the ihm library and supports reading/writing ModelCIF dictionaries, including references, alignments, quality metrics, and protocol steps. Current version is 1.7, with a release cadence of approximately every 6 months. Requires Python >=3.6.

pip install modelcif
INSTALL
IMPORT
SIG · MODELCIF
M
modelcif
datapythonv1.7
Install
3.6s avg
Import
101ms
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.7 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.106s · 20.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.6s · import 0.096s · 22MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

System
from modelcif import System
from modelcif.system import System
System is in top-level __init__.py, not a separate module.
Model
from modelcif.model import Model
from modelcif import Model
Model class is in modelcif.model module.
TargetReference
from modelcif.reference import TargetReference
from modelcif import TargetReference
TargetReference is in the reference submodule.

Create a minimal ModelCIF system with one model, write it to a mmCIF file, and read it back.

import modelcif import modelcif.reader import modelcif.model import tempfile, os # create a simple system sys = modelcif.System("Example model") # add a model model = modelcif.model.Model(sys, "model_1") # write to a temporary file with tempfile.NamedTemporaryFile(suffix='.cif', delete=False) as f: fname = f.name sys.write(fname) # read back sys2 = modelcif.reader.read(fname) print(len(sys2.models)) os.unlink(fname)
Debug
Known issues
deprecatedThe 'align_begin' and 'align_end' arguments to TargetReference are deprecated since version 1.0.
fix
Use the new Sequence-based API; provide full database sequence and differences via insertion/deletion classes.
affects: >=1.0
gotchaWriting files with waters requires the pdbx_poly_seq_scheme and pdbx_nonpoly_scheme tables; these are handled automatically since version 1.5, but older versions may lose water info.
fix
Upgrade to modelcif >=1.5 or manually populate the scheme tables.
affects: <1.5
gotchaThe 'is_primary' attribute of TargetReference may not be correctly set when reading files that contain '_struct_ref' but no '_ma_target_ref_db_details' table prior to version 1.5.
fix
Upgrade to modelcif >=1.5 or ensure '_ma_target_ref_db_details' is present in input files.
affects: <1.5
Errors
Common errors & fixes
ImportError: cannot import name 'System' from 'modelcif'
Attempting to import from a submodule that does not exist or wrong casing.
fix
Use 'from modelcif import System'.
AttributeError: 'System' object has no attribute 'write'
Using an older version of modelcif where write is not a method of System; it may be accessed via a different API.
fix
Ensure you have modelcif >=0.7 and use sys.write(filename).
TypeError: __init__() got an unexpected keyword argument 'align_begin'
Deprecated argument used with TargetReference in modelcif >=1.0.
fix
Remove align_begin and align_end; use the new reference sequence API.
Upgrade
Version history
1.7latest on PyPI · released Apr 11, 2026
Audit
Dependencies
ihmrequiredCore dependency for mmCIF handling; modelcif extends ihm classes.
Agent activity
6 hits · last 30 days
node
6
Resources
modelcif — pip install modelcif · libregistry