mmcif: Read and write mmCIF files

mmcif: mmCIF format support

Read mmCIF files.

class CIFTable

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()

Supported API . Extend mmCIF table

Parameters
  • table (CIFTable to add on to current table) –

  • exists (If a column with a given tag) –

  • extended. (then that column is) –

  • Otherwise

  • table. (a new column is added to the) –

field_has()

Supported API . Return if given field has the given value

fields()

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

Parameters
  • 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.

has_field()

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

mapping()

Supported API . Return a dictionary for subset of the table

Parameters
  • 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.

num_rows()

Supported API . Return number of rows in table

print()

Supported API . Print contents of table to given file

Parameters
  • 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

Supported API. Required field is missing

add_citation()

Experimental API . Add citation to model’s mmCIF metadata

Parameters
  • model – instance of a AtomicStructure The model.

  • citation_id – string The citation identifier.

  • info – dictionary Information about citation

  • authors – sequence Optional sequence of the authors.

  • editors – sequence Optional sequence of book or book chapter editors.

  • metadata – optional metadata dictonary Allow reuse of existing metadata dictionary.

Update the mmCIF ‘citation’, ‘citation_author’, and ‘citation_editor’ tables with the given informaiton. If the citation_id is already present in the citation table, then nothing is done.

The info dictionary is for the relevant data items from the mmCIF citation category, http://mmcif.wwpdb.org/dictionaries/mmcif_pdbx_v40.dic/Categories/citation.html except for the citation id which is given as an argument to this function. The capitalization should match that in the mmCIF dictionary. In particular, the following data items are supported:

‘title’, ‘journal_abbrev’, ‘journal_volume’, ‘year’, ‘page_first’, ‘page_last’, ‘journal_issue’, ‘pdbx_database_id_PubMed’, ‘pdbx_database_id_DOI’

add_software()

Experimental API . Add citation to model’s mmCIF metadata

Parameters
  • model – instance of a AtomicStructure The model.

  • info – dictionary Information about software

  • metadata – optional metadata dictonary Allow reuse of existing metadata dictionary.

Update the mmCIF ‘software’ table with the given informaiton. If the name is already present in the software table, then nothing is done.

The info dictionary is for the relevant data items from the mmCIF softare category, http://mmcif.wwpdb.org/dictionaries/mmcif_pdbx_v40.dic/Categories/software.html except for the name, which is given as an argument to the function, and pdbx_ordinal, which is computed. The capitalization should match that in the mmCIF dictionary. In particular, the following data items are supported:

‘name’, ‘version’, ‘location’, ‘classification’, ‘os’, ‘type’, ‘citation_id’

citations()

Experimental API . Return APA-style HTML citations for model

Parameters

model (instance of a AtomicStructure) – The model.

fetch_ccd()

Experimental API . Get structure for CCD component

fetch_mmcif()

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

find_template_residue()

Supported API . Lookup mmCIF component template residue.

The component is fetched from the web if not already loaded

get_cif_tables()

Supported API . Extract CIF tables from a file

Parameters
  • 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.

Returns

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.

Return type

list or dictionary

get_mmcif_tables()

Experimental API . Deprecated API. Use get_cif_tables() instead.

get_mmcif_tables_from_metadata()

Supported API . Extract mmCIF tables from previously read metadata

Parameters
  • model (instance of a AtomicStructure) – The model.

  • table_names (list of str) – A list of mmCIF category names.

  • metadata (optional metadata dictonary) – Allow reuse of existing metadata dictionary.

load_mmCIF_templates()

Supported API . Load mmCIF component templates from given file

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