Giter Site home page Giter Site logo

paroutes's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

paroutes's Issues

Could you tell me where is the file "route_distances"? I can't find it.

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

How to correctly load PaRoutes models?

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! ๐Ÿ’ฏ

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.