moleculekit.smallmol.smallmollib module#
- class moleculekit.smallmol.smallmollib.SmallMolLib(libfile=None, removeHs=False, fixHs=True, sanitize=True, _logger=True)#
Bases:
objectClass to manage ligands databases (sdf). Ligands are stored as moleculekit.smallmol.smallmol.SmallMol objects and fields type in the sdf are stored in a list
- Parameters:
Example
>>> import os >>> lib = SmallMolLib('fda_drugs_light.sdf') >>> lib.numMols 100
Methods
Attributes
- appendSmallLib(smallLib, strictField=False, strictDirection=1)#
Merge two moleculekit.smallmol.smallmol.SmallMolLib objects
- Parameters:
smallLib (
SmallMolLib) – The new SmallMolLib to mergestrictField (
bool) – Currently unused. Default: FalsestrictDirection (
int) – Currently unused. Default: 1
- appendSmallMol(smallmolecule, strictField=False, strictDirection=0)#
Adds a new moleculekit.smallmol.smallmol.SmallMol object in the current SmallMolLib object
- copy()#
Returns a deep copy of the SmallMolLib object.
- Returns:
newlib – A copy of the object
- Return type:
- depict(ids=None, sketch=True, filename=None, ipython=False, optimize=False, optimizemode='std', removeHs=True, legends=None, highlightAtoms=None, mols_perrow=3)#
Depicts the molecules into a grid. It is possible to save it into an svg file and also generates a jupiter-notebook rendering
- Parameters:
sketch (
bool) – Set to True for 2D depictionipython (
bool) – Set to True to return the jupiter-notebook renderingoptimize (
bool) – Set to True to optimize the conformation. Works only with 3D.optimizemode (
str) – Set the optimization mode for 3D conformationremoveHs (
bool) – Set to True to hide hydrogens in the depictionlegends (
str|None) – A legend text to add under each molecule. Can be ‘names’:the name of the molecule; ‘items’: a incremental id, or any other SDF property name.highlightAtoms (
list|None) – A List of atom to highligh for each molecule. It can be also a list of atom list, in this case different colors will be usedmols_perrow (
int) – The number of molecules to depict per row of the grid
- Returns:
ipython_svg – An SVG rendering object if
ipythonis True, otherwise None- Return type:
IPython.display.SVGorNone
- getMols(ids=None)#
Returns the SmallMol objects that corresponds ot the indexes of the list passed
- Parameters:
ids (
list|None) – The index list of the molecules to return- Returns:
smallmollist – The list of SmallMol objects
- Return type:
Example
>>> lib2 = lib.getMols([1,2,3]) >>> len(lib2) 3
- property numMols: int#
Returns the number of molecules in the library.
- Returns:
nummols – The number of molecules
- Return type:
- removeMols(ids)#
Removes the moleculekit.smallmol.smallmol.SmallMol object based on the indexes in the list
- Parameters:
ids (
list) – The list of molecules index to remove from the SmallMolLib
- toDataFrame(fields=None, molAsImage=True, sketch=True)#
Returns a pandas.DataFrame of the SmallMolLib object.
- Parameters:
- Returns:
dataframe – The pandas DataFrame
- Return type:
pandas.DataFrame
- writeSdf(sdf_name, fields=None)#
Writes an sdf file with molecules stored. Is it possible also to manage which field will be written
- writeSmiles(smi_name, explicitHs=True, names=False, header=None)#
Writes a smi file with molecules stored. Is it possible to specify the header of the smi file. The name of the ligands can be their ligand name or a sequential ID.
- Parameters:
smi_name (
str) – The ouput smi filenameexplicitHs (
bool) – Set as True to write explicit hydrogens in the SMILES strings.names (
bool) – Set as True to use the own ligand name for each ligand. Otherwise a sequential ID will be usedheader (
str|None) – The header of the smi file. If is None the smi filename will be used.
- moleculekit.smallmol.smallmollib.SmallMolStack#
alias of
SmallMolLib
- moleculekit.smallmol.smallmollib.csvReader(file, removeHs, fixHs, isgzip=False, _logger=True)#
- moleculekit.smallmol.smallmollib.sdfReader(file, removeHs, fixHs, sanitize, isgzip=False, _logger=True)#
- moleculekit.smallmol.smallmollib.smiReader(file, removeHs, fixHs, isgzip=False, _logger=True)#