pidibble.mmcif_parse module

synopsis:

defines the MMCIF_Parser class for parsing mmCIF files

class pidibble.mmcif_parse.MMCIF_Parser(mmcif_formats, pdb_formats, cif_data)[source]

Bases: object

A parser for mmCIF files, handling the parsing of various formats and structures.

Parameters:
  • mmcif_formats (dict) – A dictionary defining the mmCIF formats to be parsed.

  • pdb_formats (dict) – A dictionary defining the PDB formats to be parsed.

  • cif_data (object) – An object containing the CIF data to be parsed.

gen_dict(mapspec)[source]

Generate a list of dictionaries based on the specified mapping specification. This method processes the mapping specification to create dictionaries that represent parsed records from the CIF data.

Parameters:

mapspec (dict) – A dictionary containing the mapping specification, which includes keys like ‘data_obj’, ‘attr_map’, ‘splits’, ‘spawns_on’, ‘indexes’, ‘map_values’, ‘tables’, ‘spawn_data’, ‘global_maps’, ‘global_ids’, ‘list_attr’, ‘signal_attr’, ‘signal_value’, ‘allcaps’, and ‘if_dot_replace_with’.

Returns:

A list of dictionaries representing the parsed records based on the mapping specification.

Return type:

list

parse()[source]

Parse the mmCIF data and generate a dictionary of pdbrecord.PDBRecord instances. This method processes the mmCIF formats and generates a dictionary where keys are record types and values are lists of pdbrecord.PDBRecord instances.

Returns:

A dictionary where keys are record types and values are lists of pdbrecord.PDBRecord instances.

Return type:

PDBRecordDict

update_ids(idmaps, row)[source]

Update the global IDs with values from a single CIF row.

Parameters:
  • idmaps (dict) – A dictionary of ID maps, where keys are ID names and values are the corresponding CIF record field names.

  • row (dict) – A single CIF row as an {attribute: value} dict, as returned by DataCategory.getRowAttributeDict().

update_maps(maps, row)[source]

Update the global maps with values from a single CIF row.

Parameters:
  • maps (dict) – A dictionary of maps to update, where keys are map names and values are dictionaries with ‘key’ and ‘value’ keys.

  • row (dict) – A single CIF row as an {attribute: value} dict, as returned by DataCategory.getRowAttributeDict().

pidibble.mmcif_parse.rectify(val)[source]

Convert a value to its appropriate type, handling empty strings and special cases.

Parameters:

val (str) – The value to be rectified, which can be a string representation of a number or an empty string.

Returns:

The rectified value, which is an integer if the string represents a number, a float if it can be converted, or the original string if it cannot be converted.

Return type:

int or float or str

pidibble.mmcif_parse.split_ri(ri)[source]

Split a residue identifier into its sequence number and insertion code.

Parameters:

ri (str or int) – The residue identifier, which can be a string in the format ‘1234A’ or an integer like 1234.

Returns:

A tuple containing the sequence number as an integer and the insertion code as a string.

Return type:

tuple