Exemplo n.º 1
0
def test_product_against_rules():
    target_smiles = request.form['target_smiles']
    smarts = request.form['smarts']

    try:
        smarts_list = yaml.load(smarts, Loader=yaml.FullLoader)
    except:
        return jsonify(result={'status': 'fail'})

    try:
        rxn_list = []
        for sma in smarts_list:
            rxn_list.append(rdchiralReaction(sma))
    except:
        return jsonify(result={'status': 'fail'})

    try:
        network = Network()

        if request.form['combine_enantiomers'] == 'true':
            network.settings['combine_enantiomers'] = True
        else:
            network.settings['combine_enantiomers'] = False

        network.rxn_obj.rxns = {'test_smarts': rxn_list}
        network.rxns = {'test_smarts': rxn_list}
        network.generate(target_smiles, 1)
        nodes, edges = network.get_visjs_nodes_and_edges()
        print(nodes)
        result = {'status': 'success', 'nodes': nodes, 'edges': edges}
    except:
        result = {'status': 'fail'}

    return jsonify(result=result)
Exemplo n.º 2
0
    def _get_retrobiocat_pathways(self,
                                  row,
                                  reaction_names,
                                  combine_enantiomers=True):
        product = row['product_1_smiles']
        network = Network(print_log=False)
        network.settings.update({
            "calculate_complexities": True,
            "calculate_substrate_specificity": False,
            "get_building_blocks": False,
            "combine_enantiomers": combine_enantiomers
        })

        # Only want reactions in list
        rxns_to_keep = {}
        for rxn_name in network.rxns:
            if rxn_name in reaction_names:
                rxns_to_keep[rxn_name] = network.rxns[rxn_name]
        network.rxns = rxns_to_keep

        network.generate(product, 5)
        bfs = BFS(network=network, print_log=False, score_pathways=False)
        bfs.run()
        pathways = bfs.get_pathways()

        return pathways