mmcif: Read and write mmCIF files

mmcif: mmCIF format support

Read mmCIF files.

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

Bases: object

Present a table interface for a (mm)CIF category

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


Experimental API . Extend mmCIF table

table : CIFTable 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(field_name, value)

Experimental API . Return if given field has the given value

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

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

field_names : a sequence of the field names
allow_missing_fields : optional boolean (default False)
missing_value : optional 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.

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

mapping(key_names, value_names, foreach_names=None)

Experimental API . Return a dictionary for subset of the table

key_names : a field name or list of field names
value_names : a field name or list of field names
foreach_names : optional 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.

Experimental API . Return number of rows in table

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

Experimental API . Print contents of table to given file

file : CIFTable to add on to current table
fixed_width : true 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

Required field is missing

citations(model, only=None)

Experimental API . Return APA-style HTML citations for model

model : instance of a AtomicStructure

The model.

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

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

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

Experimental API . Extract CIF tables from a file

filename : str

The name of the file.

table_names : list of str

A list of CIF category names.

all_data_blocks : bool

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

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)

Experimental API . Extract mmCIF tables from previously read metadata

model : instance of a AtomicStructure

The model.

table_names : list of str

A list of mmCIF category names.


Experimental API . Return CIF 1.1 data value version of string