-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release single-step evaluation framework and wrappers for several mod…
…el types (#14) This (fairly large) PR releases the majority of the single-step evaluation code, including the eval script itself, inference wrappers for seven model types, and glue code to plug these models into search. A few notable things which are still missing, to be added in future PRs to avoid making this one even larger: - Detailed setup instructions for each model type (e.g. environment definitions). - Model checkpoints for each model type. - More tests covering `syntheseus/reaction_prediction` (currently the coverage is quite low, partly because the wrappers themselves cannot be tested easily without setting up dedicated environments for each, but there are also places which are just not adequately covered by tests yet).
- Loading branch information
Showing
40 changed files
with
2,559 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from typing import Optional | ||
|
||
from rdkit import Chem | ||
|
||
from syntheseus.interface.bag import Bag | ||
from syntheseus.interface.molecule import SMILES_SEPARATOR, Molecule | ||
|
||
ATOM_MAPPING_PROP_NAME = "molAtomMapNumber" | ||
|
||
|
||
def remove_atom_mapping_from_mol(mol: Chem.Mol) -> None: | ||
"""Removed the atom mapping from an rdkit molecule modifying it in place.""" | ||
for atom in mol.GetAtoms(): | ||
atom.ClearProp(ATOM_MAPPING_PROP_NAME) | ||
|
||
|
||
def remove_atom_mapping(smiles: str) -> str: | ||
"""Removes the atom mapping from a SMILES string. | ||
Args: | ||
smiles: Molecule SMILES to be modified. | ||
Returns: | ||
str: Input SMILES with atom map numbers stripped away. | ||
""" | ||
mol = Chem.MolFromSmiles(smiles) | ||
remove_atom_mapping_from_mol(mol) | ||
|
||
return Chem.MolToSmiles(mol) | ||
|
||
|
||
def molecule_bag_from_smiles_strict(smiles: str) -> Bag[Molecule]: | ||
return Bag([Molecule(component) for component in smiles.split(SMILES_SEPARATOR)]) | ||
|
||
|
||
def molecule_bag_from_smiles(smiles: str) -> Optional[Bag[Molecule]]: | ||
try: | ||
return molecule_bag_from_smiles_strict(smiles) | ||
except ValueError: | ||
# If any of the components ends up invalid we return `None` instead. | ||
return None | ||
|
||
|
||
def molecule_bag_to_smiles(mols: Bag[Molecule]) -> str: | ||
return SMILES_SEPARATOR.join(mol.smiles for mol in mols) |
Empty file.
Oops, something went wrong.