mmcif: Read and write mmCIF files

mmcif: mmCIF format support

Read mmCIF files.

class CIFTable(table_name, tags=None, data=None)

Bases: object

Supported API. Present a table interface for a (mm)CIF category

Tags should be in the mixed case version given in the associated dictionary

extend(self, table)

Supported API . Extend mmCIF table

Parameters
tableCIFTable to add on to current table
If a column with a given tag exists, then that column is extended.
Otherwise, a new column is added to the table.
field_has(self, field_name, value)

Supported API . Return if given field has the given value

fields(self, field_names, *, allow_missing_fields=False, missing_value='')

Supported API . Return subset of rows of the table for the given fields

Parameters
field_namesa sequence of the field names
allow_missing_fieldsoptional boolean (default False)
missing_valueoptional missing_value object (default ‘’)
A list of tuples is return where each tuple’s items are the values
corresponding to the given field names in the given order. If
missing fields are allowed, then the corresponding items are the
missing_value object.
has_field(self, field_name)

Supported API . Return if given field name is in the table

mapping(self, key_names, value_names, foreach_names=None)

Supported API . Return a dictionary for subset of the table

Parameters
key_namesa field name or list of field names
value_namesa field name or list of field names
foreach_namesoptional field name or list of field names
If foreach_names is not given, then the resulting dictionary is whose
keys are the values of the key field(s) and the values are the values
of the value field(s). If foreach_names is given, then the result is
a dicttionary of dictionaries, with the nested dictionaries as above,
and the outer dictionary’s keys are the values of the foreach fields.
num_rows(self)

Supported API . Return number of rows in table

print(self, file=None, *, fixed_width=False)

Supported API . Print contents of table to given file

Parameters
fileCIFTable to add on to current table
fixed_widthtrue if fixed width columns should be used
The fixed width column output matches the PDBx/mmCIF style syntax.
If fixed_width is asked for and it is not possible to have
fixed width columns (e.g., there is a newline in a string field),
then the first row is broken up into multiple lines.
exception TableMissingFieldsError

Bases: ValueError

Supported API. Required field is missing

citations(model, only=None)

Experimental API . Return APA-style HTML citations for model

Parameters
modelinstance of a AtomicStructure

The model.

fetch_mmcif(session, pdb_id, fetch_source='rcsb', ignore_cache=False, structure_factors=False, over_sampling=1.5, **kw)

Experimental API . Get mmCIF file by PDB identifier via the Internet

find_template_residue(session, name)

Supported API . Lookup mmCIF component template residue.

The component is fetched from the web if not already loaded

get_cif_tables(filename, table_names, *, all_data_blocks=False)

Supported API . Extract CIF tables from a file

Parameters
filenamestr

The name of the file.

table_nameslist of str

A list of CIF category names.

all_data_blocksbool

If true, return tables from data blocks in file. Default is False.

Returns
list or dictionary

If all_data_blocks is false, return list of CIF tables found and all of the data values in a CIFTable. If all_data_blocks is true, return an ordered dictionary of tables per data block.

get_mmcif_tables_from_metadata(model, table_names)

Supported API . Extract mmCIF tables from previously read metadata

Parameters
modelinstance of a AtomicStructure

The model.

table_nameslist of str

A list of mmCIF category names.

load_mmCIF_templates(filename)

Supported API . Load mmCIF component templates from given file

The file format should match the components.cif file from the PDB

quote(s, max_len=60)

Experimental API . Return CIF 1.1 data value version of string