helpers

pdbeccdutils.helpers.cif_tools

Set of methods to format data for gemmi parser

pdbeccdutils.helpers.cif_tools.fix_updated_mmcif(input_str: str, output_str: str) None

Keeps only first model, remove alternate conformations of atoms and residues. Updates _pdbx_branch_scheme, _struct_conn, _pdbx_nonpoly_scheme and _atom_site

Parameters:
  • input_str – Path to input structure

  • output_str – Path to write processed structure

pdbeccdutils.helpers.cif_tools.get_ccd_cif_enriched_dir(het_code, base_dir)

Path to enriched CCD CIF file directory for specified hetcode.

pdbeccdutils.helpers.cif_tools.get_prd_cif_enriched_dir(prdcc_code, base_dir)

Path to enriched PRD CIF file directory for specified PRD/PRDCC code.

pdbeccdutils.helpers.cif_tools.get_prd_code(prdcc_code: str)

Returns PRD code from PRDCC code

Parameters:

prdcc_code – ID of PRD

pdbeccdutils.helpers.cif_tools.get_prdcc_code(prd_code: str)

Returns PRDCC code from PRD code

Parameters:

prdcc_code – ID of PRD

pdbeccdutils.helpers.cif_tools.preprocess_cif_category(cif_block, label)

Checks if the category is present in gemmi.cif.Block object

Parameters:
  • cif_block (Block) – mmcif Block from gemmi.

  • label (str) – name of the category

Returns:

Possible error encountered

Return type:

str

pdbeccdutils.helpers.drawing

Module helper providing drawing functionality based on RDKit

pdbeccdutils.helpers.drawing.convert_svg(svg_string, ccd_id, mol: Mol)

Parse information from SVG depiction into object.

Parameters:
  • svg_string (str) – SVG as string.

  • ccd_id (str) – CCD ID.

  • mol (rdkit.Chem.Mol) – RDKit mol object used for depiction.

Returns:

JSON-style information for the 2D depiction.

Return type:

dict

pdbeccdutils.helpers.drawing.draw_molecule(mol, drawer, file_name, wedge_bonds, atom_highlight, bond_highlight)

Draw SVG image from the RDKit molecule.

Parameters:
  • mol (rdkit.Chem.rdchem.Mol) – Rdkit mol object to be depicted.

  • drawer (rdkit.Chem.Draw.MolDrawing.DrawingOptions) – RDKit object with parameters for drawing depiction.

  • file_name (str) – Path where the depiction will be saved.

  • wedge_bonds (bool) – Whether or not to wedge bonds.

  • atom_highlight (dict) – Dictionary with atom id and RGB mapping color mapping.

  • bond_highlight (dict) – Dictionary with mapping of atom ids and RGB colors.

pdbeccdutils.helpers.drawing.get_drawing_scale(mol)

Calculate molecule resolution given 50points per Angstroom

Parameters:

mol (rdkit.Chem.rdchem.Mol) – Rdkit mol object.

Returns:

Dimension of the depictions (x, y).

Return type:

[tuple[int,int]]

pdbeccdutils.helpers.drawing.save_no_image(path_to_image, default_msg=None, width=200)

Generate pretty image with ‘No image available’ message in case the 2D depiction cannot be created.

Parameters:
  • path_to_image (str) – path to the image

  • width (int, optional) – Defaults to 200. width of the image

pdbeccdutils.helpers.conversions

pdbeccdutils.helpers.conversions.listit(t)

Format deep tuples into deep list

Parameters:

t (tuple of tuples) – deep tuples

Returns:

deep list

Return type:

list[list]

pdbeccdutils.helpers.conversions.str_to_float(f)

Converts a string into float. Returns 0.0 if a string cannot be converted.

Parameters:

i (str) – string representation of a float

Returns:

conversion of the string

Return type:

float

pdbeccdutils.helpers.conversions.str_to_int(i)

Converts a string into integer. Returns 0 if a string cannot be converted.

Parameters:

i (str) – string representation of an integer

Returns:

conversion of the string

Return type:

int

pdbeccdutils.helpers.helper

Generic helper functions that may be re-used

pdbeccdutils.helpers.helper.bond_pdb_order(value_order)

Transpils mmcif bond order into rdkit language

Parameters:

value_order (str) – bond type as a str

Returns:

– bond type

Return type:

rdkit.Chem.rdchem.BondType

pdbeccdutils.helpers.helper.check_args(args: Namespace) None

Validates supplied arguments.

Parameters:

args – An argparse namespace containing the required arguments

pdbeccdutils.helpers.helper.get_additional_fields(auth_asym_id: str) tuple[str, str]

Gets original auth_asym_id and assembly operator from auth_asym_id in assembly file

Parameters:

auth_asym_id – auth_asym_id value form mmCIF file

Returns:

A tuple of (orig_auth_asym_id, operator), where orig_auth_asym_id is the auth_asym_id in input structure and operator is the operator used by model-server

pdbeccdutils.helpers.helper.set_up_logger(args: Namespace) Logger

Sets up application level logging

Parameters:

args – Parsed arguments.

Returns:

Application logger.

pdbeccdutils.helpers.helper.validate_path_exists(parameter: str, value: str) None

Checks if the parameter exists.

Parameters:
  • parameter – Name of the input parameter

  • value – Value of the input parameter

pdbeccdutils.helpers.mol_tools

Set of methods for molecular sanitization and work with conformers

pdbeccdutils.helpers.mol_tools.change_bonds_type(mol, from_type, to_type) None

alters all bonds that are from_type to to_type

Parameters:
  • mol (rdkit.Chem.rdchem.Mol) – Mol object from RDKit

  • from_type – Bond type to be changed

  • to_type – Type of bond to be set

pdbeccdutils.helpers.mol_tools.correct_atom_coords(conformer, atom_id)

Replace nan values of atom coordinates with zero

Parameters:
  • conformer – conformer of mol

  • atom_id – id of atom to be corrected

pdbeccdutils.helpers.mol_tools.fix_conformer(conformer)

In place fixing of rdkit conformer. In certain cases the resulting conformer (mainly from depiction process) can contain not valid atom coordinatesp [NaN, NaN, NaN]. This results in errors in downstream processes so that it is easier to fix it when the problem occurs

Parameters:

conformer (rdkit.Chem.rdchem.Conformer) – RDKit conformer

pdbeccdutils.helpers.mol_tools.fix_molecule(rwmol: RWMol)

Single molecule sanitization process. Presently, only valence errors are taken care are of.

Parameters:

rwmol (rdkit.Chem.rdchem.RWMol) – rdkit molecule to be sanitized

Returns:

Whether or not sanitization succeeded

Return type:

bool

pdbeccdutils.helpers.mol_tools.get_conformer(rwmol, c_type)

Returns requested Conformer from mol

pdbeccdutils.helpers.mol_tools.inchi_from_mol(mol: Mol) InChIFromRDKit

Provides the InChI calculated by RDKit.

Parameters:

mol – rdkit.Chem.rdchem.Mol object

Returns:

NamedTuple containing inchi, warnings and errors generated.

Return type:

InChIFromRDKit

pdbeccdutils.helpers.mol_tools.inchikey_from_inchi(inchi: str) str

Provides the InChIKey calculated by RDKit from InChI.

Parameters:

inchi – InChI calulcated by RDKit

Returns:

the InChIKey or ‘’ if there was an error finding it.

Return type:

str

pdbeccdutils.helpers.mol_tools.is_degenerate_conformer(conformer)

Determine if given conformer has missing coordinates or is missing completelly from the rdkit.Mol object. This can be used to determine, whether or not the coordinates should be regenerated.

Parameters:

conformer (rdkit.Chem.rdchem.Conformer) – conformer to check

Returns:

true if more then 1 atom has coordinates [0, 0, 0]

Return type:

bool

pdbeccdutils.helpers.mol_tools.mol_from_inchi(inchi: str) MolFromRDKit

Generates rdkit.Chem.rdchem.Mol object from InChI.

Parameters:

inchi – InChI descriptor of a molecule

Returns:

NamedTuple containing mol, warnings and errors generated.

Return type:

MolFromRDKit

pdbeccdutils.helpers.mol_tools.rdkit_object_property(object, property: str)

Returns the value of property set to the rdkit object

Parameters:

object – rdkit.Chem.rdchem object with GetProp

pdbeccdutils.helpers.mol_tools.sanitize(rwmol)

Attempts to sanitize mol in place. RDKit’s standard error can be processed in order to find out what went wrong with sanitization to fix the molecule.

Parameters:

rwmol (rdkit.Chem.rdchem.RWMol) – rdkit molecule to be sanitized

Returns:

Result of the sanitization process.

Return type:

bool