moleculekit.smallmol.util module#

moleculekit.smallmol.util.convertToString(arr)#
moleculekit.smallmol.util.depictMultipleMols(mols_list, filename=None, ipython=False, legends=None, highlightAtoms=None, mols_perrow=3)#

Depicts multiple molecules in a single grid image.

Optionally saves the image to a file and/or returns an SVG rendering for Jupyter notebooks.

Parameters:
  • mols_list (list) – The list of the rdkit molecules to depict

  • filename (str | None) – The filename of the image

  • ipython (bool) – If True, the SVG rendering for jupiter-nootebook are returned

  • legends (list | None) – List of titles subfigure for each molecule

  • highlightAtoms (list | None) – List of list of atom index to highlight.

  • mols_perrow (int) – The number of subfigures per row

Returns:

svg – An SVG rendering object if ipython is True, otherwise None

Return type:

IPython.display.SVG or None

moleculekit.smallmol.util.getChemblLigandByDrugName(drugname, returnSmile=False)#

Returns a SmallMol object of a ligand by its drug name. This molecule is retrieve from Chembl. It is possible to return also the smile of the ligand.

Parameters:
  • drugname (str) – The drug name

  • returnSmile (bool) – If True, the smile is returned

Returns:

sm – The SmallMol object for the matched drug, or None if no drug matched the name. If returnSmile is True, a tuple (sm, smile) is returned instead, where smile is the canonical SMILES string of the ligand.

Return type:

moleculekit.smallmol.smallmol.SmallMol or None

Example

>>> sm = getChemblLigandByDrugName('paracetamol')
>>> sm.numAtoms
20
>>> sm, smile = getChemblLigandByDrugName('paracetamol', returnSmile=True)
>>> smile
'CC(=O)Nc1ccc(O)cc1'
moleculekit.smallmol.util.getChemblSimilarLigandsBySmile(smi, threshold=85, returnSmiles=False)#

Returns a SmallMolLib object of the ligands having a similarity with a smile of at least the specified threshold.. This molecules are retrieve from Chembl. It is possible to return also the list smiles.

Parameters:
  • smi (str) – The smile

  • threshold (int) – The threshold value to apply for the similarity search

  • returnSmiles (bool) – If True, the list smiles is returned

Returns:

lib – A SmallMolLib containing the similar ligands. If returnSmiles is True, a tuple (lib, smiles) is returned instead, where smiles is the list of SMILES strings of the ligands.

Return type:

moleculekit.smallmol.smallmollib.SmallMolLib

Example

>>> _, smile = getChemblLigandByDrugName('ibuprofen', returnSmile=True)
>>> lib = getChemblSimilarLigandsBySmile(smile)
>>> lib.numMols
4
>>> lib, smiles = getChemblSimilarLigandsBySmile(smile, returnSmiles=True)
>>> len(smiles)
4
moleculekit.smallmol.util.getRCSBLigandByLigname(ligname, returnMol2=False)#

Returns a SmallMol object of a ligand by its three letter lignane. This molecule is retrieve from RCSB and a mol2 written. It is possible to return also the mol2 filename.

Parameters:
  • ligname (str) – The three letter ligand name

  • returnMol2 (bool) – If True, the mol2 filename is returned

Returns:

Example

>>> from moleculekit.molecule import Molecule
>>> mol = Molecule('4eiy')
>>> np.unique(mol.get('resname', 'not protein and not water'))
array(['CLR', 'NA', 'OLA', 'OLB', 'OLC', 'PEG', 'ZMA'], dtype=object)
>>> sm = getRCSBLigandByLigname('ZMA')
SmallMol module...
>>> sm.numAtoms
40
>>> sm, mol2filename = getRCSBLigandByLigname('ZMA', returnMol2=True)
>>> mol2filename
'/tmp/tmp....mol2'