MMTF-Python

1.1.3 · maintenance · verified Thu Apr 16

MMTF-Python is a Python library for decoding, encoding, and working with the Macromolecular Transmission Format (MMTF), a binary encoding designed for efficient storage and transmission of biological structures. The current version is 1.1.3, released in July 2022. While the library is stable, the RCSB PDB no longer serves MMTF data by default, encouraging a switch to BinaryCIF (BCIF). Therefore, the project is considered to be in maintenance mode.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to fetch and access basic structural information from a PDB entry using the MMTF format. It retrieves the structure for PDB ID 4CUP and prints its code, number of chains, formal charges for the first group, and the count of bioassemblies.

from mmtf import fetch

# Get the data for a PDB structure (e.g., 4CUP)
decoded_data = fetch("4CUP")

print(f"PDB Code: {decoded_data.structure_id} has {decoded_data.num_chains} chains")

# Show the charge information for the first group
if decoded_data.group_list and decoded_data.group_list[0]:
    group_name = decoded_data.group_list[0].get("groupName", "N/A")
    charges = decoded_data.group_list[0].get("formalChargeList", [])
    print(f"Group name: {group_name} has the following atomic charges: {','.join(map(str, charges))}")

# Show how many bioassemblies it has
print(f"PDB Code: {decoded_data.structure_id} has {len(decoded_data.bio_assembly)} bioassemblies")

view raw JSON →