Ejemplo n.º 1
0
 def test_01_get_outcomes(self):
     t = retro_trans.RetroTransformer()
     t.load(chiral=True, refs=False, rxns=True)
     outcomes = t.get_outcomes(
         'CCOC(=O)[C@H]1C[C@@H](C(=O)N2[C@@H](c3ccccc3)CC[C@@H]2c2ccccc2)[C@@H](c2ccccc2)N1',
         100, (gc.relevanceheuristic, gc.relevance))
     precursors = outcomes.precursors
     precursors_result = [precursor.smiles_list for precursor in precursors]
     expected_precursors = [[
         'C=CC(=O)N1[C@@H](c2ccccc2)CC[C@@H]1c1ccccc1',
         'CCOC(=O)C/N=C/c1ccccc1'
     ]]
     self.assertEqual(expected_precursors, precursors_result)
Ejemplo n.º 2
0
 def test_09_get_outcomes_cache(self):
     t = retro_trans.RetroTransformer(load_all=False, use_db=True)
     t.load()
     outcomes = t.get_outcomes(
         'CCOC(=O)[C@H]1C[C@@H](C(=O)N2[C@@H](c3ccccc3)CC[C@@H]2c2ccccc2)[C@@H](c2ccccc2)N1',
         max_num_templates=100)
     precursors = outcomes[0].precursors
     precursors_result = [precursor.smiles_list for precursor in precursors]
     expected_precursors = [[
         'C=CC(=O)N1[C@@H](c2ccccc2)CC[C@@H]1c1ccccc1',
         'CCOC(=O)C/N=C/c1ccccc1'
     ]]
     self.assertEqual(expected_precursors, precursors_result)
Ejemplo n.º 3
0
# Setting logging low
from rdkit import RDLogger
lg = RDLogger.logger()
lg.setLevel(RDLogger.CRITICAL)
from database import db_client
from django.conf import settings
import makeit.utilities.io.pickle as pickle
import os
import makeit.global_config as gc

# Chiral Retro Transformer
import makeit.retrosynthetic.transformer as transformer
RetroTransformer = transformer.RetroTransformer(lookup_only=True)
RetroTransformer.load(chiral=True, refs=True, rxns=False)
RETRO_CHIRAL_FOOTNOTE = 'Using {} chiral retrosynthesis templates (mincount {} if achiral, mincount {} if chiral) from {}/{}'.format(
    gc.Relevance_Prioritization['output_size'],
    gc.RETRO_TRANSFORMS_CHIRAL['mincount'],
    gc.RETRO_TRANSFORMS_CHIRAL['mincount_chiral'],
    gc.RETRO_TRANSFORMS_CHIRAL['database'],
    gc.RETRO_TRANSFORMS_CHIRAL['collection'])

### Databases
db = db_client[settings.REACTIONS['database']]
REACTION_DB = db[settings.REACTIONS['collection']]
# RETRO_LIT_FOOTNOTE = 'Searched {} known reactions from literature'.format(REACTION_DB.count())

db = db_client[settings.INSTANCES['database']]
INSTANCE_DB = db[settings.INSTANCES['collection']]

db = db_client[settings.CHEMICALS['database']]
CHEMICAL_DB = db[settings.CHEMICALS['collection']]
Ejemplo n.º 4
0
 def test_02_apply_one_template_by_idx(self):
     t = retro_trans.RetroTransformer()
     t.load(chiral=True, refs=False, rxns=True)
     outcomes_result = t.apply_one_template_by_idx(
         1,
         'CCOC(=O)[C@H]1C[C@@H](C(=O)N2[C@@H](c3ccccc3)CC[C@@H]2c2ccccc2)[C@@H](c2ccccc2)N1',
         109659)
     expected_outcomes = [(
         1,
         'CCOC(=O)[C@H]1C[C@@H](C(=O)N2[C@@H](c3ccccc3)CC[C@@H]2c2ccccc2)[C@@H](c2ccccc2)N1',
         109659, [('C=CC(=O)N1[C@@H](c2ccccc2)CC[C@@H]1c1ccccc1', [
             0.2523617446422577, 0.1969166249036789, 0.15234193205833435,
             0.13455800712108612, 0.030202925205230713,
             0.024427464231848717, 0.023061120882630348,
             0.018903391435742378, 0.017541231587529182,
             0.01372396107763052, 0.013607553206384182,
             0.012942434288561344, 0.01270198542624712,
             0.012236274778842926, 0.00939953699707985,
             0.008472910150885582, 0.0059701986610889435,
             0.0048681264743208885, 0.004287674557417631,
             0.0042765019461512566, 0.004114005248993635,
             0.003224626649171114, 0.003134896280243993,
             0.00310404016636312, 0.002972274785861373,
             0.002696158131584525, 0.0026850011199712753,
             0.0021682260558009148, 0.002018335508182645,
             0.001683939597569406, 0.0014018624788150191,
             0.0012026543263345957, 0.001027433667331934,
             0.0010042842477560043, 0.0009036235860548913,
             0.0008185449405573308, 0.0006995245930738747,
             0.0005884007550776005, 0.0005666478537023067,
             0.000491276616230607, 0.0004684898303821683,
             0.00045587049680761993, 0.00043441925663501024,
             0.0003655038308352232, 0.0003575180599000305,
             0.0003510901879053563, 0.00034910428803414106,
             0.00030314744799397886, 0.00029094854835420847,
             0.000254554208368063, 0.00024915405083447695,
             0.00022937390895094723, 0.0001904226082842797,
             0.0001790589012671262, 0.00017418322386220098,
             0.00016860727919265628, 0.00015959763550199568,
             0.00015663796511944383, 0.00015368156891781837,
             0.0001446626556571573, 0.00014138488040771335,
             0.00013653609494213015
         ], [
             922, 33433, 11500, 7263, 4005, 3581, 5541, 150347, 62514,
             54396, 10503, 115523, 26842, 67342, 39406, 7421, 121814, 44003,
             104591, 54496, 12802, 17425, 29358, 40183, 89253, 17054, 17142,
             14952, 4909, 155144, 73901, 95665, 3419, 17528, 155365, 47886,
             31303, 974, 70550, 50432, 97960, 36674, 114062, 108, 6776,
             21165, 130595, 81282, 7635, 52, 82107, 95674, 1065, 74925,
             88017, 92158, 37880, 9606, 6613, 49535, 16476, 94670
         ], 1),
                  ('CCOC(=O)C/N=C/c1ccccc1', [
                      0.9659425020217896, 0.01252610795199871,
                      0.005059113260358572, 0.0038746828213334084,
                      0.0022534450981765985, 0.001429172931239009,
                      0.0008012531325221062, 0.0007077240734361112,
                      0.000661780999507755, 0.0006321603432297707,
                      0.0006210291176103055, 0.0005571309011429548
                  ], [
                      1287, 186, 128290, 2120, 129604, 1910, 17747, 70579,
                      303, 713, 113217, 8087
                  ], 1)], 0.9996535778045654)]
     self.assertEqual(expected_outcomes, outcomes_result)
Ejemplo n.º 5
0
# Setting logging low
from rdkit import RDLogger
lg = RDLogger.logger()
lg.setLevel(RDLogger.CRITICAL)
from database import db_client
from django.conf import settings
import makeit.utilities.io.pickle as pickle
import os
import makeit.global_config as gc

# Chiral Retro Transformer
import makeit.retrosynthetic.transformer as transformer
RetroTransformer = transformer.RetroTransformer(template_prioritizer=None,
                                                precursor_prioritizer=None,
                                                fast_filter=None)
RetroTransformer.load()
RETRO_CHIRAL_FOOTNOTE = 'Using {} chiral retrosynthesis templates from {}/{}'.format(
    gc.RELEVANCE_TEMPLATE_PRIORITIZATION['reaxys']['output_size'],
    gc.RETRO_TEMPLATES['database'], gc.RETRO_TEMPLATES['collection'])

### Databases
db = db_client[gc.REACTIONS['database']]
REACTION_DB = db[gc.REACTIONS['collection']]

db = db_client[gc.CHEMICALS['database']]
CHEMICAL_DB = db[gc.CHEMICALS['collection']]

db = db_client[gc.BUYABLES['database']]
BUYABLE_DB = db[gc.BUYABLES['collection']]

db = db_client[gc.SOLVENTS['database']]
Ejemplo n.º 6
0
# Setting logging low
from rdkit import RDLogger
lg = RDLogger.logger()
lg.setLevel(RDLogger.CRITICAL)
from database import db_client
from django.conf import settings
import makeit.utilities.io.pickle as pickle
import os
import makeit.global_config as gc

# Retro transformer
import makeit.retrosynthetic.transformer as transformer
RetroTransformer = transformer.RetroTransformer(
    mincount=gc.RETRO_TRANSFORMS['mincount'])
RetroTransformer.load(chiral=False, refs=True, rxns=False)
RetroTransformer.reorder()
RETRO_FOOTNOTE = 'Using {} retrosynthesis templates (mincount {}) from {}/{}'.format(
    len(RetroTransformer.templates), settings.RETRO_TRANSFORMS['mincount'],
    settings.RETRO_TRANSFORMS['database'],
    settings.RETRO_TRANSFORMS['collection'])

# Chiral Retro Transformer
import makeit.retrosynthetic.transformer as transformer
RetroTransformerChiral = transformer.RetroTransformer()
RetroTransformerChiral.load(chiral=True, refs=True, rxns=False)
RetroTransformerChiral.reorder()
RETRO_CHIRAL_FOOTNOTE = 'Using {} chiral retrosynthesis templates (mincount {} if achiral, mincount {} if chiral) from {}/{}'.format(
    len(RetroTransformerChiral.templates),
    settings.RETRO_TRANSFORMS_CHIRAL['mincount'],
    settings.RETRO_TRANSFORMS_CHIRAL['mincount_chiral'],
    settings.RETRO_TRANSFORMS_CHIRAL['database'],
Ejemplo n.º 7
0
}

project_root = os.path.dirname(os.path.dirname(__file__))
template_name = '{}_{}_{}_{}'.format(
    RETRO_TRANSFORMS_CHIRAL['database'],
    RETRO_TRANSFORMS_CHIRAL['collection'],
    RETRO_TRANSFORMS_CHIRAL['mincount'],
    RETRO_TRANSFORMS_CHIRAL['mincount_chiral'],
)

# Get templates and their refs
database = db_client[RETRO_TRANSFORMS_CHIRAL['database']]
RETRO_DB = database[RETRO_TRANSFORMS_CHIRAL['collection']]
import makeit.retrosynthetic.transformer as transformer
RetroTransformerChiral = transformer.RetroTransformer(
    mincount=RETRO_TRANSFORMS_CHIRAL['mincount'],
    mincount_chiral=RETRO_TRANSFORMS_CHIRAL['mincount_chiral'],
)
RetroTransformerChiral.load(chiral=True, refs=True, rxns=False)
RetroTransformerChiral.reorder()
RETRO_CHIRAL_FOOTNOTE = 'Using {} chiral retrosynthesis templates (mincount {} if achiral, mincount {} if chiral) from {}/{}'.format(
    len(RetroTransformerChiral.templates), RETRO_TRANSFORMS_CHIRAL['mincount'],
    RETRO_TRANSFORMS_CHIRAL['mincount_chiral'],
    RETRO_TRANSFORMS_CHIRAL['database'], RETRO_TRANSFORMS_CHIRAL['collection'])

print('Loaded {} templates'.format(len(RetroTransformerChiral.templates)))

## Create map from reaction ID to template ID
reaction_id_to_template_num = {}
template_num_to_template_id = {}
for tmp_num, template in enumerate(RetroTransformerChiral.templates):
    template_num_to_template_id[tmp_num] = template['_id']