deepmol.utils package
Submodules
deepmol.utils.errors module
deepmol.utils.utils module
- canonicalize_mol_object(mol_object: Mol) Mol[source]
Canonicalize a molecule object.
- Parameters
mol_object (Mol) – Molecule object to canonicalize.
- Returns
Canonicalized molecule object.
- Return type
Mol
- draw_MACCS_Pattern(mol: Mol, smarts_patt_index: int, path: Optional[str] = None)[source]
Draw a molecule with a MACCS key highlighted.
- Parameters
mol (Mol) – Molecule to draw.
smarts_patt_index (int) – Index of the MACCS key to highlight.
path (str) – Path to save the image to. If None, the image is not saved.
- Returns
im – Image of the molecule with the MACCS key highlighted.
- Return type
PIL.Image.Image
- draw_morgan_bit_on_molecule(mol: Mol, bit: int, radius: int = 2, nBits: int = 2048, chiral: bool = False, molSize: Tuple[int, int] = (450, 200))[source]
Draw a molecule with a Morgan fingerprint bit highlighted.
- Parameters
mol (Mol) – Molecule to draw.
bit (int) – Bit to highlight.
radius (int) – Radius of the Morgan fingerprint.
nBits (int) – Number of bits in the Morgan fingerprint.
chiral (bool) – If True, the molecule is drawn with chiral information.
molSize (Tuple[int, int]) – Size of the molecule.
- Returns
The molecule in SVG format.
- Return type
SVG
- draw_morgan_bits(molecule: Mol, bits: Union[int, str, List[int]], radius: int = 2, nBits: int = 2048)[source]
Draw a molecule with Morgan fingerprint bits highlighted.
- Parameters
molecule (Mol) – Molecule to draw.
bits (Union[int, str, List[int]]) – Bit(s) to highlight. If ‘ON’, all bits that are set to 1 are highlighted.
radius (int) – Radius of the Morgan fingerprint.
nBits (int) – Number of bits in the Morgan fingerprint.
- Returns
Object containing the image of the molecule with the Morgan fingerprint bits highlighted.
- Return type
DrawMorganBits
- draw_rdk_bit_on_molecule(mol: Mol, bit: int, minPath: int = 1, maxPath: int = 7, fpSize: int = 2048, path_dir: Optional[str] = None, molSize: Tuple[int, int] = (450, 200))[source]
Draw a molecule with a RDK fingerprint bit highlighted.
- Parameters
mol (Mol) – Molecule to draw.
bit (int) – Bit to highlight.
minPath (int) – Minimum path length.
maxPath (int) – Maximum path length.
fpSize (int) – Number of bits in the fingerprint.
path_dir (str) – Path to save the image.
molSize (Tuple[int, int]) – Size of the molecule.
- Returns
The molecule with the fingerprint bit highlighted.
- Return type
Images
- draw_rdk_bits(mol: Mol, bits: int, minPath: int = 2, maxPath: int = 7, fpSize: int = 2048)[source]
Draw a molecule with a RDK fingerprint bit highlighted.
- Parameters
mol (Mol) – Molecule to draw.
bits (int) – Bit to highlight.
minPath (int) – Minimum path length.
maxPath (int) – Maximum path length.
fpSize (int) – Number of bits in the fingerprint.
- Returns
The molecule with the fingerprint bits.
- Return type
Draw.DrawRDKitBits
- getSubstructDepiction(mol: Mol, atomID: int, radius: int, molSize: Tuple[int, int] = (450, 200))[source]
Get a depiction of a substructure.
- Parameters
mol (Mol) – Molecule to draw.
atomID (int) – ID of the atom to highlight.
radius (int) – Radius of the substructure.
molSize (Tuple[int, int]) – Size of the molecule.
- Returns
The molecule in SVG format.
- Return type
SVG
- load_from_disk(filename: str) Any[source]
Load object from file.
- Parameters
filename (str) – A filename you want to load.
- Returns
A loaded object from file.
- Return type
Any
- load_pickle_file(input_file: str) Any[source]
Load from single, possibly gzipped, pickle file.
- Parameters
input_file (str) – The filename of pickle file. This function can load from gzipped pickle file like XXXX.pkl.gz.
- Returns
The object which is loaded from the pickle file.
- Return type
Any
- mol_to_smiles(mol: Mol, **kwargs) Optional[str][source]
Convert SMILES to RDKit molecule object. Parameters ———- mol: Mol
RDKit molecule object to convert.
- kwargs:
Keyword arguments for rdkit.Chem.MolToSmiles.
- smiles: str
SMILES string.
- moltosvg(mol: Mol, molSize: Tuple[int, int] = (450, 200), kekulize: bool = True, drawer: Optional[object] = None, **kwargs)[source]
Convert a molecule to SVG.
- Parameters
mol (Mol) – Molecule to convert.
molSize (Tuple[int, int]) – Size of the molecule.
kekulize (bool) – If True, the molecule is kekulized.
drawer (object) – Object to draw the molecule.
**kwargs – Additional arguments for the drawer.
- Returns
The molecule in SVG format.
- Return type
SVG
- normalize_labels_shape(y_pred: Union[List, ndarray], n_tasks: int) ndarray[source]
Function to transform output from predict_proba (prob(0) prob(1)) to predict format (0 or 1).
- Parameters
y_pred (array) – array with predictions
n_tasks (int) – number of tasks
- Returns
Array of predictions in the format [0, 1, 0, …]/[[0, 1, 0, …], [0, 1, 1, …], …]
- Return type
labels