def retrieve_results_view(request): settings = request.registry.settings GUILDifier.set_parameters(settings) if request.method == 'POST': #! if request.POST.get('session_id1') and request.POST.get('session_id2'): session_id = request.POST["session_id1"] session_id2 = request.POST["session_id2"] try: result = GUILDifier(session_id, species=None, settings=settings) result2 = GUILDifier(session_id2, species=None, settings=settings) except: # job(s) not finished / session does not exist request.session.flash('Provided job id is not valid!') return HTTPFound(location=request.route_url('home')) ready_flag = result.create_output_file() ready_flag2 = result2.create_output_file() if (ready_flag is None or ready_flag == False) or ( ready_flag2 is None or ready_flag2 == False): # Error / still running request.session.flash('Provided job id is not valid!') return HTTPFound(location=request.route_url('home')) else: return HTTPFound( location=request.route_url('result_overlap', session_id1=session_id, session_id2=session_id2, n_start="1", n_end="20", p_top="1")) if request.POST.get('session_id'): session_id = request.POST["session_id"] try: result = GUILDifier(session_id, species=None, settings=settings) except: # species.txt does not exits - job not finished request.session.flash('Provided job id is not valid!') return HTTPFound(location=request.route_url('home')) ready_flag = result.create_output_file() if ready_flag is None or ready_flag == False: # Error / still running request.session.flash('Provided job id is not valid!') return HTTPFound(location=request.route_url('home')) else: return HTTPFound( location=request.route_url('result', session_id=session_id, n_start="1", n_end="20", p_top="1")) request.session.flash('No job id is provided!') return HTTPFound(location=request.route_url('home'))
def old_run_scoring_method_view(request): if request.method == 'POST': user_entity_ids = [] for user_entity_id in request.POST: if user_entity_id != "species": user_entity_ids.append(user_entity_id) print user_entity_ids request.session["id"] = str(uuid.uuid4()) species = request.POST["species"] request.session["species"] = species result = GUILDifier(request.session["id"], species, request.registry.settings) result.prepare(user_entity_ids) result.score() result.create_output_file() request.session["file_name"] = result.output_file request.session["file_url"] = result.output_file_url request.session["n_result"] = result.n_node n_start = int(request.matchdict["n_start"]) n_end = int(request.matchdict["n_end"]) parser = GUILDScoreParser(request.session["file_name"]) values = parser.get_user_entity_info_and_scores( n_start, n_end, species) return dict(n_start=n_start, n_end=n_end, species=BIANAQuery.TAX_ID_TO_SPECIES_NAME[species], n_node=result.n_node, values=values, output_file_url=request.session["file_url"], not_last_page=n_end < (result.n_node - 20)) elif request.method == 'GET': n_start = int(request.matchdict["n_start"]) n_end = int(request.matchdict["n_end"]) if "species" not in request.session: request.session.flash('Invalid session, please start over!') return HTTPFound(location=request.route_url('home')) species = request.session["species"] parser = GUILDScoreParser(request.session["file_name"]) values = parser.get_user_entity_info_and_scores( n_start, n_end, species) n_node = request.session["n_result"] return dict(n_start=n_start, n_end=n_end, species=BIANAQuery.TAX_ID_TO_SPECIES_NAME[species], n_node=n_node, values=values, output_file_url=request.session["file_url"], not_last_page=n_end < n_node) else: request.session.flash('Invalid session, please start over!') return HTTPFound(location=request.route_url('home')) return {}
def scoring_results_overlap_view(request): settings = request.registry.settings GUILDifier.set_parameters(settings) session_id = request.matchdict["session_id1"] session_id2 = request.matchdict["session_id2"] result = GUILDifier(session_id, species=None, settings=settings) result2 = GUILDifier(session_id2, species=None, settings=settings) ready_flag = result.create_output_file() ready_flag2 = result2.create_output_file() if ready_flag is None or ready_flag2 is None: # Error request.session["id"] = session_id request.session["species"] = result.species request.session["message"] = "error/contact webmaster" return HTTPFound(location=request.route_url('status')) elif ready_flag and ready_flag2: # Finished if "id" in request.session: del request.session["id"] del request.session["species"] del request.session["message"] n_start = int(request.matchdict["n_start"]) n_end = int(request.matchdict["n_end"]) p_top = request.matchdict["p_top"] parser = GUILDScoreParser(result.output_file) parser2 = GUILDScoreParser(result2.output_file) values, values_stat = parser.overlap_with(parser2, result.n_node, result.species, int(p_top)) return dict(session_id1=session_id, session_id2=session_id2, species=BIANAQuery.TAX_ID_TO_SPECIES_NAME[result.species], n_start=n_start, n_end=min(n_end, len(values)), n_node=len(values), values=values[(n_start - 1):n_end], values_stat=values_stat, output_file_url=result.output_file_url, seed_file_url=result.seed_file_url, network_file_url=result.network_file_url, network_json=result.get_network_json(p_top), subnetwork_file_url=result.subnetwork_file_url + "." + p_top, drug_file_url=result.drug_file_url + "." + p_top, not_last_page=n_end < result.n_node, p_top=p_top, top1=p_top == "1", top5=p_top == "5", top10=p_top == "10", human=result.species == "9606") request.session["id"] = session_id request.session["species"] = result.species request.session["message"] = "queued/running" return HTTPFound(location=request.route_url('status'))
def results_ajax(request): settings = request.registry.settings GUILDifier.set_parameters(settings) session_id = request.matchdict["session_id"] n_start = int(request.matchdict["n_start"]) n_end = int(request.matchdict["n_end"]) result = GUILDifier(session_id, species = None, settings = settings) result.create_output_file() parser = GUILDScoreParser(result.output_file) values, ueids = parser.get_user_entity_info_and_scores(n_start, n_end, result.species) #! return dict(n_start = n_start, n_end = n_end, n_node = result.n_node, values = [ ";".join(map(lambda x: str(x), value)) for value in values ])
def results_overlap_ajax(request): settings = request.registry.settings GUILDifier.set_parameters(settings) session_id = request.matchdict["session_id1"] session_id2 = request.matchdict["session_id2"] n_start = int(request.matchdict["n_start"]) n_end = int(request.matchdict["n_end"]) p_top = request.matchdict["p_top"] result = GUILDifier(session_id, species = None, settings = settings) result.create_output_file() parser = GUILDScoreParser(result.output_file) result2 = GUILDifier(session_id2, species = None, settings = settings) result2.create_output_file() parser2 = GUILDScoreParser(result2.output_file) values, values_stat, values_chart, ueids = parser.overlap_with(parser2, result.n_node, result.species, int(p_top)) return dict(n_start = n_start, n_end = n_end, n_node = result.n_node, p_top = p_top, values = [ ";".join(map(lambda x: str(x), value)) for value in values[(n_start-1):n_end] ])
def scoring_results_view(request): settings = request.registry.settings GUILDifier.set_parameters(settings) session_id = request.matchdict["session_id"] result = GUILDifier(session_id, species=None, settings=settings) ready_flag = result.create_output_file() if ready_flag is None: # Error request.session["id"] = session_id request.session["species"] = result.species request.session["message"] = "error/contact webmaster" return HTTPFound(location=request.route_url('status')) elif ready_flag: # Finished if "id" in request.session: del request.session["id"] del request.session["species"] del request.session["message"] n_start = int(request.matchdict["n_start"]) n_end = int(request.matchdict["n_end"]) p_top = request.matchdict["p_top"] parser = GUILDScoreParser(result.output_file) values = parser.get_user_entity_info_and_scores( n_start, n_end, result.species) return dict(session_id=session_id, species=BIANAQuery.TAX_ID_TO_SPECIES_NAME[result.species], n_start=n_start, n_end=n_end, n_node=result.n_node, values=values, output_file_url=result.output_file_url, seed_file_url=result.seed_file_url, network_file_url=result.network_file_url, network_json=result.get_network_json(p_top), subnetwork_file_url=result.subnetwork_file_url + "." + p_top, drug_file_url=result.drug_file_url + "." + p_top, not_last_page=n_end < result.n_node, top1=p_top == "1", top5=p_top == "5", top10=p_top == "10", human=result.species == "9606") request.session["id"] = session_id request.session["species"] = result.species request.session["message"] = "queued/running" return HTTPFound(location=request.route_url('status'))