def full_graph(request): """ Get the full graph for a molecule from an input smiles :param request: :return: """ graph_choice = os.environ.get("NEO4J_QUERY", "neo4j") if "graph_choice" in request.GET: graph_choice = request.GET["graph_choice"] if "smiles" in request.GET: smiles = request.GET["smiles"] out_dict = get_full_graph(smiles, graph_choice) decoration_list = get_add_del_link(smiles) if not out_dict: return HttpResponse("EMPTY RESULT SET") return HttpResponse(order_stuctures(out_dict, decoration_list)) else: return HttpResponse("Please insert SMILES")
def run_for_smiles(smiles): core_list = [ item for sublist in get_add_del_link(smiles) for item in sublist ] out_dict = get_full_graph(smiles) if out_dict is None: return None new_dict = {} for key in out_dict: smi_key = key.split("_")[0] if smi_key in new_dict: new_dict[smi_key].extend(out_dict[key]) else: new_dict[smi_key] = out_dict[key] res_dict = {} for smi in core_list: if smi in new_dict: res_dict[smi] = get_sum_stats(new_dict[smi], smiles) else: res_dict[smi] = None return res_dict
def get_graph(self, obj): return get_full_graph(obj.smiles, self.graph_choice, isomericSmiles=True)