chemprop.utils.utils#
Classes#
Enum where members are also (and must be) strings |
Functions#
|
build an RDKit molecule from a SMILES string. |
|
Instantiate a class with optional init args, then call the instance with args. |
|
Optionally executes a function in parallel. |
|
Make a pretty string from an input shape |
Module Contents#
- class chemprop.utils.utils.EnumMapping[source]#
Bases:
enum.StrEnumEnum where members are also (and must be) strings
- classmethod get(name)[source]#
- Parameters:
name (str | EnumMapping)
- Return type:
- chemprop.utils.utils.make_mol(smi, keep_h=False, add_h=False, ignore_stereo=False, reorder_atoms=False)[source]#
build an RDKit molecule from a SMILES string.
- Parameters:
smi (str) – a SMILES string.
keep_h (bool, optional) – whether to keep hydrogens in the input smiles. This does not add hydrogens, it only keeps them if they are specified. Default is False.
add_h (bool, optional) – whether to add hydrogens to the molecule. Default is False.
ignore_stereo (bool, optional) – whether to ignore stereochemical information (R/S and Cis/Trans) when constructing the molecule. Default is False.
reorder_atoms (bool, optional) – whether to reorder the atoms in the molecule by their atom map numbers. This is useful when the order of atoms in the SMILES string does not match the atom mapping, e.g. ‘[F:2][Cl:1]’. Default is False. NOTE: This does not reorder the bonds.
- Returns:
the RDKit molecule.
- Return type:
Chem.Mol
- chemprop.utils.utils.create_and_call_object(cls, call_args=(), call_kwargs=None, init_args=(), init_kwargs=None)[source]#
Instantiate a class with optional init args, then call the instance with args. This is useful for parallel calls to methods that contain boost functions.
- Parameters:
cls (Type)
call_args (tuple)
call_kwargs (dict)
init_args (tuple)
init_kwargs (dict)
- Return type:
Any
- chemprop.utils.utils.parallel_execute(exe_func, func_args=(), func_kwargs=(), n_workers=0)[source]#
Optionally executes a function in parallel.
- Parameters:
exe_func (Callable) – function to execute.
func_args (Iterable) – arguments for each iteration of function execution.
func_kwargs (Iterable) – keyword arguments for each iteration of function execution.
n_workers (int, optional) – Number of parallel workers.
- Returns:
list of function outputs for each argument.
- Return type:
list