Beispiel #1
0
def find_synthesis():

    args = arg_parser.get_args()
    makeit = MAKEIT(
        args.TARGET, args.expansion_time, args.max_depth, args.max_branching,
        args.max_trees, args.retro_mincount, args.retro_mincount_chiral,
        args.synth_mincount, args.rank_threshold, args.prob_threshold,
        args.max_contexts, args.template_count, args.max_ppg, args.output,
        args.chiral, args.nproc, args.celery, args.context_recommender,
        args.forward_scoring, args.tree_scoring, args.context_prioritization,
        args.template_prioritization, args.precursor_prioritization,
        args.parallel_tree, args.precursor_score_mode,
        args.max_cum_template_prob, args.apply_fast_filter,
        args.filter_threshold)
    MyLogger.initialize_logFile(makeit.output_dir_root, makeit.case_dir)

    tree_status, trees = makeit.construct_buyable_trees()
    MyLogger.print_and_log(
        'MAKEIT generated {} buyable tree(s) that meet(s) all constraints.'.
        format(len(trees)), makeit_loc)
    feasible_trees = makeit.evaluate_synthesis_trees(trees)
    MyLogger.print_and_log(
        'MAKEIT found {} tree(s) that are(is) likely to result in a successful synthesis.'
        .format(len(feasible_trees)), makeit_loc)

    def writefunc(string):
        return MyLogger.print_and_log(string, makeit_loc)

    for i, feasible_tree in enumerate(
            sorted(feasible_trees, key=lambda x: x['score'], reverse=True)):
        MyLogger.print_and_log('', makeit_loc)
        MyLogger.print_and_log(
            'Feasible tree {}, plausible = {}, overall score = {}'.format(
                i + 1, feasible_tree['plausible'], feasible_tree['score']),
            makeit_loc)
        print_at_depth(feasible_tree['tree'], writefunc=writefunc)

    with open(
            os.path.join(makeit.output_dir_root,
                         '{}_trees.html'.format(makeit.case_dir)), 'w') as fid:

        def writefunc(string):
            return fid.write('{}<br>\n'.format(string))

        fid.write('<html><title>Results for {}</title>\n'.format(args.TARGET))
        fid.write('<body>\n')
        fid.write('<h1>{}</h1><br>\n'.format(args.TARGET))
        fid.write('<i><b>Settings: </b>{}</i><br>\n'.format(args.__dict__))
        for i, feasible_tree in enumerate(
                sorted(feasible_trees, key=lambda x: x['score'],
                       reverse=True)):
            writefunc(
                '<h3>Feasible tree {}, plausible = {}, overall score = {}</h3><br>'
                .format(i + 1, feasible_tree['plausible'],
                        feasible_tree['score']))
            print_at_depth(feasible_tree['tree'],
                           writefunc=writefunc,
                           delim='&nbsp;',
                           img=True)
        fid.write('</body>\n')
Beispiel #2
0
                    if stop_if in product.smiles_list:
                        print(
                            'Found true product - skipping remaining templates to apply'
                        )
                        return True
                else:
                    results.append(product)
            # Were we trying to stop early?
            if stop_if:
                return False

        return results


if __name__ == '__main__':
    MyLogger.initialize_logFile()
    ft = ForwardTransformer(mincount=10)
    ft.load()

    template_count = ft.template_count()
    smiles = 'NC(=O)[C@H](CCC=O)N1C(=O)c2ccccc2C1=O'
    for batch_size in range(100, 1000, 100):
        print()
        print(batch_size)
        outcomes = []
        i = 0
        for start_at in range(0, template_count, batch_size):
            i += 1
            outcomes.append(
                ft.get_outcomes(smiles,
                                100,