deepmol.utils package

Submodules

deepmol.utils.cached_properties module

class deepmol_cached_property(func)[source]

Bases: cached_property

deepmol.utils.decorators module

inplace_decorator(method: callable) callable | None[source]

Decorator to make a method inplace.

Parameters:

method (callable) – Method to decorate.

Returns:

inplace_method – Decorated method.

Return type:

callable

modify_object_inplace_decorator(method: callable) callable | None[source]

Decorator to create a lazy copy-on-write version of a method.

This decorator performs modifications of an object that is received by the class, either inplace or on a copy of the object, depending on the value of the inplace parameter.

This applies inplace

Parameters:

method (callable) – The method to decorate.

Returns:

modify_object_wrapper – The decorated method.

Return type:

callable

timeout(timelimit)[source]

deepmol.utils.errors module

exception PreConditionViolationException(condition: str | None = None, message: str = 'Pre-condition violation')[source]

Bases: Exception

Exception raised when a pre-condition is violated.

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

get_class(name: str) object[source]

Get a class from a string.

Parameters:

name (str) – A class name you want to get.

Returns:

A class object.

Return type:

object

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) str | None[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.

normalize_labels_shape(y_pred: 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

smiles_to_mol(smiles: str, **kwargs) Mol | None[source]

Convert SMILES to RDKit molecule object. Parameters ———- smiles: str

SMILES string to convert.

kwargs:

Keyword arguments for rdkit.Chem.MolFromSmiles.

Mol

RDKit molecule object.

Module contents