rxnutils.routes.deepset package¶
Submodules¶
rxnutils.routes.deepset.featurizers module¶
Module with featurizers for molecules and reactions
- rxnutils.routes.deepset.featurizers.collect_reaction_features(reaction_data, target_fingerprint, reaction_class_ranks, featurizer, prefactor=1.1, default_rank=5, default_cls='0.0')¶
Collect all reaction features and compute the prior reaction feasibility score
- Params reaction_data:
the reactions of the route
- Params target_fingerprint:
the precomputed fingerprint of the target
- Params reaction_class_ranks:
the ranks of the reaction classes
- Params featurizer:
the featurizer to use for reactions
- Params prefactor:
the factor for the feasibility score
- Params default_rank:
the rank of reactions not parameterized
- Params default_cls:
the class of reactions not parameterized
- Returns:
the prior feasibility score
- Returns:
the reaction features
- Parameters:
reaction_data (List[Dict[str, Any]])
target_fingerprint (ndarray)
reaction_class_ranks (Dict[str, int])
featurizer (Callable[[Dict[str, Any]], ndarray])
prefactor (float)
default_rank (int)
default_cls (str)
- Return type:
Tuple[float, ndarray]
- rxnutils.routes.deepset.featurizers.default_reaction_featurizer(reaction_data, radius=2, numbits=64)¶
Given an item of reaction data, returned by the reaction_data method of SynthesisRoute this features the reaction using a difference ECFP
Currently it featurizes the reaction in the retro-sense
- Params reaction_data:
the reaction as a dictionary
- Params radius:
the radius of the fingerprint
- Params numbits:
the number of bits
- Returns:
the fingerprint
- Parameters:
reaction_data (Dict[str, Any])
radius (int)
numbits (int)
- Return type:
ndarray
- rxnutils.routes.deepset.featurizers.ecfp_fingerprint(mol, radius=2, numbits=64)¶
Computes a ECFP with a given radius and length
- Params mol:
the RDKit molecule
- Params radius:
the radius of the fingerprint
- Params numbits:
the number of bits
- Returns:
the fingerprint
- Parameters:
mol (Mol)
radius (int)
numbits (int)
- Return type:
ndarray
- rxnutils.routes.deepset.featurizers.reaction_difference_fingerprint(reaction, radius=2, numbits=64)¶
Computes the difference fingerprint of given reaction
- Params reaction:
the reaction to featurize
- Params radius:
the radius of the fingerprint
- Params numbits:
the number of bits
- Returns:
the fingerprint
- Parameters:
reaction (ChemicalReaction)
radius (int)
numbits (int)
- Return type:
ndarray
rxnutils.routes.deepset.scoring module¶
Module containing routines for Deepset route scoring
This is an implementation of the code used in the following publication, original implementation by Guo Yujia
Yujia G, Kabeshov M, Le THD, Genheden S, Bergonzini G, Engkvist O, et al. A Deep Learning with Expert Augmentation Approach for Route Scoring in Organic Synthesis. ChemRxiv. 2024; doi:10.26434/chemrxiv-2024-tp7rh
- class rxnutils.routes.deepset.scoring.DeepsetModelClient(model_path)¶
Bases:
object
Interface for an in-memory instance of a Deepset model for route scoring
- Params model_path:
the path to an ONNX model file
- Parameters:
model_path (str)
- rxnutils.routes.deepset.scoring.deepset_route_score(route, model_client, scscorer, reaction_class_ranks)¶
Scores a synthesis route using a Deepset model
Currently, it uses defaults for featurizers as described in the original publication.
- Params route:
the route to score
- Params model_client:
the interface to the model
- Params scscorer:
the interface to the SCScore
- Params reaction_class_ranks:
the lookup from reaction class to rank
- Returns:
the computed score
- Parameters:
route (SynthesisRoute)
model_client (DeepsetModelClient)
scscorer (SCScore)
reaction_class_ranks (Dict[str, int])
- Return type:
float