示例#1
0
文件: views.py 项目: emreg00/GUILDify
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 {}
示例#2
0
文件: views.py 项目: emreg00/GUILDify
def run_scoring_method_view(request):
    settings = request.registry.settings
    GUILDifier.set_parameters(settings)
    if request.method == 'POST':
        #print request.POST
        user_entity_ids = []
        for user_entity_id in request.POST:
            try:
                int(user_entity_id)
            except:
                continue
            user_entity_ids.append(user_entity_id)
        print user_entity_ids
        session_id = str(uuid.uuid4())
        print "Session:", session_id
        species = request.POST["species"]
        scoring_parameters = {}
        if "netscore" in request.POST:
            scoring_parameters["ns"] = [
                int(request.POST["repetitionSelector"]),
                int(request.POST["iterationSelector"])
            ]
        if "netzcore" in request.POST:
            scoring_parameters["nz"] = [
                int(request.POST["repetitionZelector"])
            ]
        if "netshort" in request.POST:
            scoring_parameters["nd"] = None
        result = GUILDifier(session_id, species, settings)
        result.prepare(user_entity_ids)
        result.score(scoring_parameters)
        return dict(session_id=session_id,
                    species=BIANAQuery.TAX_ID_TO_SPECIES_NAME[species],
                    seed_file_url=result.seed_file_url,
                    network_file_url=result.network_file_url,
                    message="submitted",
                    submitted=True)
    elif "id" in request.session:
        session_id = request.session["id"]
        species = request.session["species"]
        message = request.session["message"]
        result = GUILDifier(session_id, species, settings)
        return dict(session_id=session_id,
                    species=BIANAQuery.TAX_ID_TO_SPECIES_NAME[species],
                    seed_file_url=result.seed_file_url,
                    network_file_url=result.network_file_url,
                    message=message,
                    submitted=False)
    request.session.flash('Invalid session, please start over!')
    return HTTPFound(location=request.route_url('home'))
示例#3
0
    def genes_to_scores(self, query_ids, species, parameters):
        """
	parameters containing scoring parameters
	"""
        #g = get_guildify()
        settings = self.get_settings()
        GUILDifier.set_parameters(settings)
        user_entity_ids = []
        for user_entity_id in query_ids:
            try:
                int(user_entity_id)
            except:
                continue
            user_entity_ids.append(user_entity_id)
        print user_entity_ids
        session_id = str(uuid.uuid4())
        print "Session:", session_id
        scoring_parameters = {}
        if "netscore" in parameters:
            scoring_parameters["ns"] = [
                int(parameters["repetitionSelector"]),
                int(parameters["iterationSelector"])
            ]
        if "netzcore" in parameters:
            scoring_parameters["nz"] = [int(parameters["repetitionZelector"])]
        if "netshort" in parameters:
            scoring_parameters["nd"] = None
        result = GUILDifier(session_id, species, settings)
        result.prepare(user_entity_ids)
        result.score(scoring_parameters)
        return dict(session_id=session_id,
                    species=BIANAQuery.TAX_ID_TO_SPECIES_NAME[species],
                    seed_file_url=result.seed_file_url,
                    network_file_url=result.network_file_url,
                    message="submitted",
                    submitted=True)