chemprop.utils#
Submodules#
Classes#
dict() -> new empty dictionary |
|
Enum where members are also (and must be) strings |
Functions#
|
Instantiate a class with optional init args, then call the instance with args. |
|
build an RDKit molecule from a SMILES string. |
|
Optionally executes a function in parallel. |
|
Make a pretty string from an input shape |
Package Contents#
- class chemprop.utils.ClassRegistry[source]#
Bases:
dict[str,Type[T]]dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s
(key, value) pairs
- dict(iterable) -> new dictionary initialized as if via:
d = {} for k, v in iterable:
d[k] = v
- dict(**kwargs) -> new dictionary initialized with the name=value pairs
in the keyword argument list. For example: dict(one=1, two=2)
- __call__#
- class chemprop.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.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.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.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