meeko.rdkit_mol_create module#
- class meeko.rdkit_mol_create.RDKitMolCreate[source]#
Bases:
objectUtilities for constructing RDKit molecules from PDBQT docking results.
- classmethod from_pdbqt_mol(pdbqt_mol, only_cluster_leads=False, keep_flexres=False)[source]#
Convert a PDBQT molecule into a list of RDKit molecules.
- Parameters:
pdbqt_mol (PDBQT) – The PDBQT molecule to convert.
only_cluster_leads (bool, optional) – If True, only cluster leads are converted. Default is False.
keep_flexres (bool, optional) – If True, flexible residues are kept. Default is False.
- Returns:
A list of RDKit molecules. Each molecule corresponds to a pose in the PDBQT molecule.
- Return type:
list
- Raises:
RuntimeError – If no cluster leads are found in the PDBQT molecule and only_cluster_leads is True.
ValueError – If some atoms of a ligand are parsed as sidechain but not all.
- classmethod guess_flexres_smiles(resname, atom_names)[source]#
Determine a SMILES string for flexres based on atom names, as well as the equivalent of smile_index_map and smiles_h_parent which are written to PDBQT remarks for regular small molecules.
- Parameters:
resname (str) – The residue name of the flexible residue.
atom_names (list of str) – The names of the atoms in the flexible residue.
- Returns:
- A tuple containing:
smiles: SMILES string starting at C-alpha (excludes most of the backbone)
- index_map: list of pairs of integers, first in pair is index in the smiles,
second is index of corresponding atom in atom_names
- h_parent: list of pairs of integers, first in pair is index of a heavy atom
in the smiles, second is index of a hydrogen in atom_names. The hydrogen is bonded to the heavy atom.
- Return type:
tuple[str, list, list]
- classmethod add_pose_to_mol(mol, ligand_coordinates, index_map)[source]#
Add given coordinates to given molecule as new conformer.
- Parameters:
mol (Chem.Mol) – The RDKit molecule to which the coordinates will be added.
ligand_coordinates (list[list[float]]) – 2D array of shape (nr_atom, 3).
index_map (list[int]) – list of nr_atom pairs of integers, 1-indexed. In each pair, the first int is the index in mol, and the second int is the index in ligand_coordinates (PDBQT).
- Returns:
mol – The RDKit molecule with the new conformer added.
- Return type:
Chem.Mol
- Raises:
RuntimeError – Will raise error if number of coordinates provided does not match the number of atoms there should be coordinates for.
- static add_hydrogens(mol, coordinates_list, h_parent)[source]#
Add hydrogen atoms to ligand RDKit mol, adjust the positions of polar hydrogens to match pdbqt.
- Parameters:
mol (Chem.Mol) – The RDKit molecule to which the hydrogens will be added.
coordinates_list (list[list[float]]) – 2D array of shape (nr_atom, 3).
h_parent (list[int]) – list of pairs of integers, 1-indexed. In each pair, the first int is the index in mol, and the second int is the index in coordinates_list
- Returns:
mol – The RDKit molecule with the new hydrogens added.
- Return type:
Chem.Mol
- static combine_rdkit_mols(mol_list)[source]#
Combines list of rdkit molecules into a single one using Chem.CombineMols.
- Parameters:
mol_list (list[Chem.Mol]) – List of RDKit molecules to combine.
- Returns:
Combined RDKit molecule with all conformers from the input list. If all input molecules are None, returns None.
- Return type:
Chem.Mol
- classmethod add_sandbox_coordinates(dlgstring, rdmol, index_map, h_parent, groupname=None)[source]#
Parse coordinates from a DLG file and append to RDKit mol. The coordinates are sorted by energy, and the best pose is added first. The function also adds the pose index to the RDKit molecule. The coordinates are added as conformers to the RDKit molecule. The function also adds the pose index to the RDKit molecule.
- Parameters:
dlgstring (str) – The DLG file content as a string.
rdmol (Chem.Mol) – The RDKit molecule to which the coordinates will be added.
index_map (list[int]) – List of pairs of integers, 1-indexed. In each pair, the first int is the index in mol, and the second int is the index in coordinates_list.
h_parent (list[int]) – List of pairs of integers, 1-indexed. In each pair, the first int is the index in mol, and the second int is the index in coordinates_list.
groupname (str, optional) – The name of the group to filter the coordinates. If None, all coordinates are used. Default is None.
- Returns:
- A tuple containing:
rdmol: The RDKit molecule with the new conformers added.
energy: A dictionary containing the intermolecular and intramolecular energies for each pose, as well as the pose index.
- Return type:
tuple[Chem.Mol, dict]
- static write_sd_string(pdbqt_mol, only_cluster_leads=False, keep_flexres=False)[source]#
Write a multi-conformer SDF string from a PDBQT molecule.
- Parameters:
pdbqt_mol (PDBQT) – The PDBQT molecule to convert.
only_cluster_leads (bool, optional) – If True, only cluster leads are converted. Default is False.
keep_flexres (bool, optional) – If True, flexible residues are kept. Default is False.
- Returns:
- A tuple containing:
output_string: The multi-conformer SDF string.
failures: A list of indices of failed conversions.
- Return type:
tuple[str, list]