pidibble.mmcif_parse module

synopsis:

defines the MMCIF_Parser class for parsing mmCIF files

class pidibble.mmcif_parse.MMCIFDict(data, linkers={}, blankers=[' ', '', '?'])[source]

Bases: UserDict

A dictionary-like class for handling mmCIF data with custom key resolution. This class extends UserDict to provide additional functionality for mmCIF data handling.

Parameters:
  • data (dict) – The initial data to populate the MMCIFDict.

  • linkers (dict, optional) – A dictionary mapping keys to other keys for resolving linked values.

  • blankers (list, optional) – A list of values that should be treated as empty strings. Defaults to [’ ‘, ‘’, ‘?’].

get(key)[source]

Retrieve a value from the MMCIFDict by key, resolving linked keys if necessary. If the value is in the blankers list, it returns an empty string.

Parameters:

key (str) – The key to retrieve from the MMCIFDict.

Returns:

The value associated with the key, or an empty string if the value is in the blankers list.

Return type:

str

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, cifrec, idx)[source]

Update the global IDs with values from the CIF record at a specific index.

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

  • cifrec (object) – The CIF record object containing the data to update the IDs.

  • idx (int) – The index in the CIF record to retrieve values from.

update_maps(maps, cifrec, idx)[source]

Update the global maps with values from the CIF record at a specific index.

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

  • cifrec (object) – The CIF record object containing the data to update the maps.

  • idx (int) – The index in the CIF record to retrieve values from.

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.resolve(key, aDict)[source]

Stub function to resolve a key in a dictionary. This function is a placeholder and does not perform any actual resolution.

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