The macromolecular transmission format (MMTF) is a binary encoding of biological structures.
This repository holds the Python 2 and 3 compatible API, encoding and decoding libraries.
The MMTF python API is available from pip:
pip install mmtf-python
Quick getting started.
1) Get the data for a PDB structure and print the number of chains: ```python from mmtf import fetch
decoded_data = fetch("4CUP")
print("PDB Code: "+str(decoded_data.structure_id)+" has "+str(decoded_data.num_chains)+" chains")
2) Show the charge information for the first group:
python
print("Group name: "+str(decoded_data.group_list[0]["groupName"])+" has the following atomic charges: "+",".join([str(x) for x in decoded_data.group_list[0]["formalChargeList"]]))
3) Show how many bioassemblies it has:
python
print("PDB Code: "+str(decoded_data.structure_id)+" has "+str(len(decoded_data.bio_assembly))+" bioassemblies")
```
The specification outlines the float type as 32bit. Python has 64bit floats, hence when packing these per the template are dumped to the output file. Other parsers (e.g. mmtf-java
) try to load these as 32bit floats, and hence fail. We can overcome this easily by updating the msgpack.packb
call to include use_single_float=True
.
However, it seems mmtf-java
also violates the standard, and uses doubles (64bit floats) for the ncsOperatorList
, thus the above change means it can't parse the output still. Given mmtf-java
is used for the RCSB files, we can assume they won't shift to 32bit floats - it'll break their parsing for even more files.
Additionally, the msgpack-python
implementation does not support selecting doubles for only one field - https://github.com/msgpack/msgpack-python/issues/326. Instead you have to pack the biological assemblies list separately and then combine it, as in the collapsed snipped below.
For reference I have raised this issue in the mmtf-java
repo too - https://github.com/rcsb/mmtf-java/issues/53.
upgraded msgpack to >=1.0.0 removed unused ipython dependency default entity description to empty string initialize title to None
v1.0.10 - 2018-01-03 @kain88-de
Fixed - Don't leak open file handles #32
Bug fix by: @jonwedell https://github.com/rcsb/mmtf-python/pull/27