Lib mmCIF

Handle CIF data.

class idpconfgen.libs.libcif.CIFParser(datastr, label_priority='auth')[source]

mmCIFParser for structural data ONLY.

That is, fields from the m_site.` group.

Parameters:

datastr (str) – The content of the mmCIF file in string format.

property altloc

The altloc field of the current line.

property atname

The atom name field of the current line.

property chainid

The chainID field of the current line.

property charge

The charge field of the current line.

property element

The element field of the current line.

get_line_elements_for_PDB(line=None)[source]

Retrieve line elements.

Parameters:

line (int, optional) – If given retrieve values for that line and sets that as current line. Else, retrieves values for current line.

Returns:

list – The values of the line.

get_value(label)[source]

Retrieve the label value for the current line.

property icode

The icode field of the current line.

property line

The current line number.

property occ

The occupancy field of the current line.

read_cif(datastr)[source]

Read ‘atom_site.’ entries to dictionary.

property record

The record field of the current line.

property resname

The resname field of the current line.

property resseq

The resSeq field of the current line.

property serial

The serial field of the current line.

property tempfactor

The tempfactor field of the current line.

property xcoord

The Xcoord field of the current line.

property ycoord

The Ycoord field of the current line.

property zcoord

The Zcoord field of the current line.

idpconfgen.libs.libcif.find_cif_atom_site_headers(lines, cif_dict)[source]

Find _atom_site. headers.

Given a list of mmCIF lines, finds headers of _atom_site.

Parameters:
  • lines (list) – The lines of the mmCIF files are read by file.readlines().

  • cif_dict (dict) – A dictionary where to initiate the atom_site. keys. Keys are assigned empty list as value.

Returns:

int – The index of lines where the _atom_site. structural information starts.

Raises:

CIFFileError – If any _atom_site. keys are found in lines.

idpconfgen.libs.libcif.is_cif(datastr)[source]

Detect if datastr is a CIF file.

idpconfgen.libs.libcif.parse_cif_line(line)[source]

Parse CIF line according to CIF_LINE_REGEX.

Parameters:

line (str) – The line to parse.

Returns:

list – A list with the parsed line elements.

idpconfgen.libs.libcif.populate_cif_dictionary(lines, start_index, cif_dict)[source]

Populate mmCIF dictionary.

Expects atom coordinate information to be consecutive, otherwise reading will be incomplete or errors will occur.

Parameters:
  • lines (list) – The mmCIF lines. Normally the whole mmCIF file content.

  • start_index (int) – The line index, that is, line number 0-indexed, where the actual atom_site. structural information starts, that is, the first ATOM/HETATM line.

  • cif_dict (dict) – The mmCIF dictionary to populate. The dict keys should be previously prepared and should match the data in the lines.

Returns:

None – Edits dictionary in place.

Raises:

InvalidCIFLineError – If the number of fields in parsed line do not match expected _atom_site. fields in the dictionary.