atomium.mmtf
Contains functions for dealing with the .mmtf file format.
- atomium.mmtf.add_chain_to_model(chain, model, atoms)[source]
Adds a ‘chain’ to a model - a chain in the .mmtf dict, which can also be a non-polymer.
- Parameters
chain (dict) – the ‘chain’ to add.
model (dict) – the model to add it to.
atoms (list) – the atoms list to work through.
- atomium.mmtf.add_het_to_dict(group, chain, atoms, d, number=None)[source]
Adds a ligand or water or residue to the appropriate dict. An ID and name will be generated for it.
- Parameters
group (dict) – the group template the het should be based on.
chain (dict) – the chain (in the real sense) the het is associated with.
atoms (list) – the atoms list to work through.
d (dict) – the dictionary to add to.
number (int) – if given, the residue number to use.
- atomium.mmtf.add_het_to_groups(het, group_type_list, group_id_list, group_list, ins_list)[source]
Updates group lists with information from a single
Het
.- Parameters
het (Het) – the Het to pack.
group_type_list (list) – the list of group types.
group_id_list (list) – the list of group IDs.
group_list (list) – the list of groups.
ins_list (list) – the list of insertion codes.
- Return type
tuple
- atomium.mmtf.add_ss_to_chain(chain)[source]
Updates polymer dictionary with secondary structure information, from information temporarily stored in its residue dicts.
- Parameters
chain (dict) – the chain to update.
- atomium.mmtf.decode_dict(d)[source]
Takes a dictionary that might have bytestring keys, lists of bytestring values, .mmtf binary values, or other weirdness, and returns a dully decoded version of it which is a JSON-valid dictionary.
- Parameters
d (dict) – the dictionary to read.
- Return type
dict
- atomium.mmtf.delta_decode(integers)[source]
Turns a list of integers into a new list of integers where the values in the first are treated as deltas to be applied to the previous value.
- Parameters
integers (list) – the integers to decode.
- Return type
list
- atomium.mmtf.get_atoms_list(mmtf_dict)[source]
Creates a list of atom dictionaries from a .mmtf dictionary by zipping together some of its fields.
- Parameters
mmtf_dict (dict) – the .mmtf dictionary to read.
- Return type
list
- atomium.mmtf.get_chain_ids_and_names(chains, ligands, waters)[source]
Takes lists of chains, ligands and waters, and returns the chain IDs and chain names that should go in the .mmtf file.
- Parameters
chains (list) – the chains to pack.
ligands (list) – the ligands to pack.
waters (list) – the waters to pack.
- Return type
list
- atomium.mmtf.get_chains_list(mmtf_dict, groups)[source]
Creates a list of chain dictionaries from a .mmtf dictionary by zipping together some of its fields.
- Parameters
mmtf_dict (dict) – the .mmtf dictionary to read.
- Return type
list
- atomium.mmtf.get_entity_list(entities, chains, ligands, waters)[source]
Takes a list of entity objects, as well as the objects they represent, and turns them into a list of .mmtf dictionaries.
- Parameters
entities (list) – the entities to pack.
chains (list) – the chains to pack.
ligands (list) – the ligands to pack.
waters (list) – the waters to pack.
- Return type
list
- atomium.mmtf.get_group_definitions_list(mmtf_dict)[source]
Gets a list of group definitions from the .mmtf dict and packs its atom attributes into atoms dicts.
- Parameters
mmtf_dict (dict) – the .mmtf dictionary to read.
- Return type
list
- atomium.mmtf.get_groups(chains, ligands, waters)[source]
Creates the relevant lists of group information from chains, ligands and waters.
- Parameters
chains (list) – the chains to pack.
ligands (list) – the ligands to pack.
waters (list) – the waters to pack.
- Return type
tuple
- atomium.mmtf.get_groups_list(mmtf_dict, group_definitions)[source]
Creates a list of group dictionaries from a .mmtf dictionary by zipping together some of its fields.
- Parameters
mmtf_dict (dict) – the .mmtf dictionary to read.
- Return type
list
- atomium.mmtf.get_groups_per_chain(chains, ligands, waters)[source]
Takes lists of chains, ligands and waters, and returns the chain counts that should go in the .mmtf file.
- Parameters
chains (list) – the chains to pack.
ligands (list) – the ligands to pack.
waters (list) – the waters to pack.
- Return type
list
- atomium.mmtf.get_structures(structure)[source]
Takes an atomic structure, and creates a list of chains within it, a list of ligands, a list of waters, a list of relevant atom properties, and a list of entities.
- Parameters
structure (AtomStructure) – the structure to unpack.
- Return type
tuple
- atomium.mmtf.mmtf_bytes_to_mmtf_dict(bytestring)[source]
Takes the raw bytestring of a .mmtf file and turns it into a normal, fully decoded JSON dictionary.
- Patam bytes bytestring
the .mmtf filestring.
- Return type
dict
- atomium.mmtf.mmtf_dict_to_data_dict(mmtf_dict)[source]
Converts an .mmtf dictionary into an atomium data dictionary, with the same standard layout that the other file formats get converted into.
- Parameters
mmtf_dict (dict) – the .mmtf dictionary.
- Return type
dict
- atomium.mmtf.mmtf_to_data_transfer(mmtf_dict, data_dict, d_cat, d_key, m_key, date=False, first=False, trim=False)[source]
A function for transfering a bit of data from a .mmtf dictionary to a data dictionary, or doing nothing if the data doesn’t exist.
- Parameters
mmtf_dict (dict) – the .mmtf dictionary to read.
data_dict (dict) – the data dictionary to update.
d_cat (str) – the top-level key in the data dictionary.
d_key (str) – the data dictionary field to update.
m_key (str) – the .mmtf field to read.
date (bool) – if True, the value will be converted to a date.
first (bool) – if True, the value’s first item will be split used.
trim (int) – if given, the value will be rounded by this amount.
- atomium.mmtf.parse_binary_field(b)[source]
Some fields in a .mmtf file cannot be unpacked by msgpack and have special .mmtf encoding, as specified in its documentation. This function takes such a field and decodes it.
- Parameters
b (bytestring) – the field to parse.
- Returns
the parsed result (type varies).
- atomium.mmtf.recursive_decode(integers, bits=16)[source]
Turns a list of integers into a new list of integers where the values in the first are merged if it looks like a higher order integer split over two integers.
(Code here adapted from the official python-mmtf package.)
- Parameters
integers (list) – the integers to decode.
- Return type
list
- atomium.mmtf.run_length_decode(integers)[source]
Expands a list of integers where every second integer is a count of the integer before it.
- Parameters
integers (list) – the integers to decode.
- Return type
list
- atomium.mmtf.structure_to_mmtf_string(structure)[source]
Converts a
AtomStructure
to a .mmtf filestring.No compression is currently performed.
- Parameters
structure (AtomStructure) – the structure to convert.
- Return type
bytes