gmol.base.wrapper.rdkit#

Functions

find_all_bonds_with_atom_idx(mol, atom_indices)

Find all chemical bonds in the molecule given atom indices.

generate_conformer(mol[, max_attempts, ...])

get_all_bonds(mol)

mol2smi(mol[, kekuleSmiles])

read_mols(file_path[, sanitize, remove_h])

Read a molecular file into a list of RDKit Mol objects.

smi2mol(smiles[, kekuilze, sanitize])

write_mols(save_path, mols[, sdf_kekulize])

Write a list of RDKit Mol objects to a file.

smi2mol(smiles: str, kekuilze: bool = False, sanitize: bool = True) Mol#
mol2smi(mol: Mol, kekuleSmiles: bool = True) str#
get_all_bonds(mol: Mol) list[tuple[int, int]]#
find_all_bonds_with_atom_idx(mol: Mol, atom_indices: list[int]) list[tuple[int, int]]#

Find all chemical bonds in the molecule given atom indices.

generate_conformer(mol: Mol, max_attempts: int = 5, optimize_iters: int = 500, ignore_failures: bool = True) Mol#
read_mols(file_path: Path | str, sanitize: bool = True, remove_h: bool = False) list[Mol]#

Read a molecular file into a list of RDKit Mol objects.

Supported formats: .mol2, .sdf, .pdb.

Parameters:
  • file_path – Path to the molecular file.

  • sanitize – If True, sanitize each molecule after reading.

  • remove_h – If True, remove explicit hydrogens from each molecule.

Returns:

List of RDKit Mol objects; entries that failed to parse are omitted.

write_mols(save_path: Path | str, mols: Mol | None | Iterable[Mol | None], sdf_kekulize: bool = False) None#

Write a list of RDKit Mol objects to a file.

Supported extensions are .sdf and .pdb.

Parameters:
  • save_path – Path to the output file.

  • mols – Molecule or list of molecules to write; None entries are skipped.

  • sdf_kekulize – If True, kekulize molecules when writing to an SDF file.