molecularai / paroutes Goto Github PK
View Code? Open in Web Editor NEWHome of the PaRoutes framework for benchmarking multi-step retrosynthesis predictions.
License: Apache License 2.0
Home of the PaRoutes framework for benchmarking multi-step retrosynthesis predictions.
License: Apache License 2.0
the file "route_distances" is used as follow, path is "analysis/route_clusters.py"
import route_distances.lstm.defaults as defaults
from route_distances.route_distances import route_distances_calculator
from route_distances.clustering import ClusteringHelper
from route_distances.utils.type_utils import RouteDistancesCalculator
Your benchmark is very interesting and I would like to do some experiments with it, but I haven't found instructions on how to use your pre-trained models.
Would you mind telling me whether the following code correctly loads and uses your models?
import numpy as np
import pandas as pd
import h5py
from tensorflow import keras
from rdkit.Chem import AllChem
from rdchiral.main import rdchiralRunText
def get_fingerprint(smiles: str) -> np.ndarray:
mol = AllChem.MolFromSmiles(smiles)
assert mol is not None
fp = AllChem.GetMorganFingerprintAsBitVect(mol, radius=2, nBits=2048) # QUESTION: is this the right fingerprint?
return np.array(fp, dtype=float)
# Load templates
df_templates = pd.read_hdf("./data/uspto_rxn_n5_unique_templates.hdf5", key="table")
# Load model, defining custom metrics because without these it gave an error...
model = keras.models.load_model(
"./data/uspto_rxn_n5_keras_model.hdf5",
custom_objects={
"top10_acc": keras.metrics.TopKCategoricalAccuracy(k=10, name="top10_acc"),
"top50_acc": keras.metrics.TopKCategoricalAccuracy(k=10, name="top50_acc"),
}
)
# Example use case: run the best reaction for the first 2 targets
test_smiles = ["O=C(O)COCCOCCOCCOCCOCCOCCOCC(F)(F)F", "COc1cc(N)c(Cl)cc1C(=O)NCCCC1CN(Cc2ccccc2)CCO1"]
x = np.stack([get_fingerprint(s) for s in test_smiles])
template_probs = model(x).numpy()
most_likely_reactions = template_probs.argmax(axis=1)
for i, sm in enumerate(test_smiles):
reactants = rdchiralRunText(df_templates["retro_template"].values[most_likely_reactions[i]], sm)
print(f"{i}: {reactants} >> {sm}")
This code runs and produces the following output (in particular, the second reaction fails). Is this the output that you would expect?
0: ['CCOC(=O)CBr.OCCOCCOCCOCCOCCOCCOCC(F)(F)F'] >> O=C(O)COCCOCCOCCOCCOCCOCCOCC(F)(F)F
1: [] >> COc1cc(N)c(Cl)cc1C(=O)NCCCC1CN(Cc2ccccc2)CCO1
Thank you in advance for answering my question. Great manuscript and keep up the good open source work! ๐ฏ
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.