Пример #1
0
def generate_citations(radius=3):
    """Returns a list of text citations associated with some location, word
    or topic (cluster)."""

    clicked_on = request.args.get("options")

    if clicked_on == "location":
        x_coord = float(request.args.get("xcoord"))
        y_coord = float(request.args.get("ycoord"))
        z_coord = float(request.args.get("zcoord"))

        pmids = Activation.get_pmids_from_xyz(x_coord, y_coord, z_coord, radius)

    elif clicked_on == "word":
        word = request.args.get("word")

        # Get the pmids for a word
        pmids = StudyTerm.get_pmid_by_term(word)

    elif clicked_on == "cluster":
        cluster = request.args.get("cluster")

        # Get the words for a cluster
        # Then get the top studies for the words
        words = TermCluster.get_words_in_cluster(cluster)
        pmids = StudyTerm.get_pmid_by_term(words)

    elif clicked_on == "study":

        pmid = request.args.get("pmid")
        study = Study.get_study_by_pmid(pmid)

        # Look for cluster-mate studies
        pmids = study.get_cluster_mates()

    citations = Study.get_references(pmids)

    return jsonify(citations)