From d11b71790f5f7c7eb9fe41704e1df7d8447371c9 Mon Sep 17 00:00:00 2001 From: Lei Yan Date: Tue, 12 May 2015 19:14:29 +0000 Subject: Committer: Lei Yan On branch master --- wqflask/wqflask/gsearch.py | 83 +++++++++++++++++++++ wqflask/wqflask/templates/gsearch.html | 63 ++++++++++++++++ wqflask/wqflask/templates/gsearch2.html | 55 ++++++++++++++ wqflask/wqflask/templates/gsearchact.html | 113 ++++++++++++++++++++++++++++ wqflask/wqflask/templates/gsearchact2.html | 114 +++++++++++++++++++++++++++++ wqflask/wqflask/views.py | 21 ++++++ 6 files changed, 449 insertions(+) create mode 100755 wqflask/wqflask/gsearch.py create mode 100755 wqflask/wqflask/templates/gsearch.html create mode 100755 wqflask/wqflask/templates/gsearch2.html create mode 100755 wqflask/wqflask/templates/gsearchact.html create mode 100755 wqflask/wqflask/templates/gsearchact2.html (limited to 'wqflask') diff --git a/wqflask/wqflask/gsearch.py b/wqflask/wqflask/gsearch.py new file mode 100755 index 00000000..706a3655 --- /dev/null +++ b/wqflask/wqflask/gsearch.py @@ -0,0 +1,83 @@ +from __future__ import absolute_import, print_function, division + +from flask import Flask, g + +class GSearch(object): + + # http://gn2_lei.genenetwork.org/gsearch?species=mouse&group=BXD&search_terms=shh + def __init__(self, kw): + if 'species' in kw and 'group' in kw: + self.species = kw['species'] + self.group = kw['group'] + self.terms = kw['terms'] + sql = """ + SELECT InbredSet.`Id` + FROM InbredSet,Species + WHERE InbredSet.`Name` LIKE "%s" + AND InbredSet.`SpeciesId`=Species.`Id` + AND Species.`Name` LIKE "%s" + """ % (self.group, self.species) + dbre = g.db.execute(sql).fetchone() + self.inbredset_id = dbre[0] + sql = """ + SELECT DISTINCT 0, + Tissue.`Name` AS tissue_name, + ProbeSetFreeze.FullName AS probesetfreeze_fullname, + ProbeSet.Name AS probeset_name, + ProbeSet.Symbol AS probeset_symbol, + ProbeSet.`description` AS probeset_description, + ProbeSet.Chr AS chr, + ProbeSet.Mb AS mb, + ProbeSetXRef.Mean AS mean, + ProbeSetXRef.LRS AS lrs, + ProbeSetXRef.`Locus` AS locus, + ProbeSetXRef.`pValue` AS pvalue, + ProbeSetXRef.`additive` AS additive + FROM InbredSet, ProbeSetXRef, ProbeSet, ProbeFreeze, ProbeSetFreeze, Tissue + WHERE ProbeFreeze.InbredSetId=%s + AND ProbeFreeze.`TissueId`=Tissue.`Id` + AND ProbeSetFreeze.ProbeFreezeId=ProbeFreeze.Id + AND ( MATCH (ProbeSet.Name,ProbeSet.description,ProbeSet.symbol,alias,GenbankId, UniGeneId, Probe_Target_Description) AGAINST ('%s' IN BOOLEAN MODE) ) + AND ProbeSet.Id = ProbeSetXRef.ProbeSetId + AND ProbeSetXRef.ProbeSetFreezeId=ProbeSetFreeze.Id + ORDER BY tissue_name, probesetfreeze_fullname, probeset_name + LIMIT 1000 + """ % (self.inbredset_id, self.terms) + self.results = g.db.execute(sql).fetchall() + elif 'species' in kw: + self.species = kw['species'] + self.terms = kw['terms'] + sql = """ + SELECT Species.`Id` + FROM Species + WHERE Species.`Name` LIKE "%s" + """ % (self.species) + dbre = g.db.execute(sql).fetchone() + self.species_id = dbre[0] + sql = """ + SELECT DISTINCT 0, + InbredSet.`Name` AS inbredset_name, + Tissue.`Name` AS tissue_name, + ProbeSetFreeze.FullName AS probesetfreeze_fullname, + ProbeSet.Name AS probeset_name, + ProbeSet.Symbol AS probeset_symbol, + ProbeSet.`description` AS probeset_description, + ProbeSet.Chr AS chr, + ProbeSet.Mb AS mb, + ProbeSetXRef.Mean AS mean, + ProbeSetXRef.LRS AS lrs, + ProbeSetXRef.`Locus` AS locus, + ProbeSetXRef.`pValue` AS pvalue, + ProbeSetXRef.`additive` AS additive + FROM InbredSet, ProbeSetXRef, ProbeSet, ProbeFreeze, ProbeSetFreeze, Tissue + WHERE InbredSet.`SpeciesId`=%s + AND ProbeFreeze.InbredSetId=InbredSet.`Id` + AND ProbeFreeze.`TissueId`=Tissue.`Id` + AND ProbeSetFreeze.ProbeFreezeId=ProbeFreeze.Id + AND ( MATCH (ProbeSet.Name,ProbeSet.description,ProbeSet.symbol,alias,GenbankId, UniGeneId, Probe_Target_Description) AGAINST ('%s' IN BOOLEAN MODE) ) + AND ProbeSet.Id = ProbeSetXRef.ProbeSetId + AND ProbeSetXRef.ProbeSetFreezeId=ProbeSetFreeze.Id + ORDER BY inbredset_name, tissue_name, probesetfreeze_fullname, probeset_name + LIMIT 1000 + """ % (self.species_id, self.terms) + self.results = g.db.execute(sql).fetchall() diff --git a/wqflask/wqflask/templates/gsearch.html b/wqflask/wqflask/templates/gsearch.html new file mode 100755 index 00000000..28301515 --- /dev/null +++ b/wqflask/wqflask/templates/gsearch.html @@ -0,0 +1,63 @@ +{% extends "base.html" %} +{% block title %}GeneNetwork{% endblock %} +{% block content %} + + +
+ + {{ flash_me() }} + +
+ +
+ +
+
+
+ +{%endblock%} + +{% block js %} + +{% endblock %} \ No newline at end of file diff --git a/wqflask/wqflask/templates/gsearch2.html b/wqflask/wqflask/templates/gsearch2.html new file mode 100755 index 00000000..430bf889 --- /dev/null +++ b/wqflask/wqflask/templates/gsearch2.html @@ -0,0 +1,55 @@ +{% extends "base.html" %} +{% block title %}GeneNetwork{% endblock %} +{% block content %} + + +
+ + {{ flash_me() }} + +
+ +
+ +
+
+
+ +{%endblock%} + +{% block js %} + +{% endblock %} \ No newline at end of file diff --git a/wqflask/wqflask/templates/gsearchact.html b/wqflask/wqflask/templates/gsearchact.html new file mode 100755 index 00000000..57fe25b5 --- /dev/null +++ b/wqflask/wqflask/templates/gsearchact.html @@ -0,0 +1,113 @@ +{% extends "base.html" %} +{% block title %}Search Results{% endblock %} +{% block css %} + + + +{% endblock %} +{% block content %} + + +
+ +

To study a record, click on its ID below.
Check records below and click Add button to add to selection.

+ +
+
+ + + + + +
+
+ + + + + + + + + + + + + + + + + + + + {% for this_trait in results %} + + {% for item in this_trait[1:] %} + + {% endfor %} + + {% endfor %} + + +
TissueDatasetRecordSymbolDescriptionChrMbMeanMax LRSLocusPvalueAdditive
{{ item }}
+
+
+ + + +{% endblock %} + +{% block js %} + + + + + + + + +{% endblock %} diff --git a/wqflask/wqflask/templates/gsearchact2.html b/wqflask/wqflask/templates/gsearchact2.html new file mode 100755 index 00000000..d99bfadc --- /dev/null +++ b/wqflask/wqflask/templates/gsearchact2.html @@ -0,0 +1,114 @@ +{% extends "base.html" %} +{% block title %}Search Results{% endblock %} +{% block css %} + + + +{% endblock %} +{% block content %} + + +
+ +

To study a record, click on its ID below.
Check records below and click Add button to add to selection.

+ +
+
+ + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + {% for this_trait in results %} + + {% for item in this_trait[1:] %} + + {% endfor %} + + {% endfor %} + + +
GroupTissueDatasetRecordSymbolDescriptionChrMbMeanMax LRSLocusPvalueAdditive
{{ item }}
+
+
+ + + +{% endblock %} + +{% block js %} + + + + + + + + +{% endblock %} diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 7c0f4e14..5d71dec0 100755 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -29,6 +29,7 @@ from flask import (render_template, request, make_response, Response, Flask, g, config, jsonify, redirect, url_for) from wqflask import search_results +from wqflask import gsearch from wqflask import docs from wqflask import news from base.data_set import DataSet # Used by YAML in marker_regression @@ -135,6 +136,26 @@ def search_page(): else: return render_template("search_result_page.html", **result) +@app.route("/gsearch", methods=('GET',)) +def gsearchreq(): + return render_template("gsearch.html") + +@app.route("/gsearchact", methods=('GET',)) +def gsearchact(): + print("request.args is", request.args) + result = gsearch.GSearch(request.args).__dict__ + return render_template("gsearchact.html", **result) + +@app.route("/gsearch2", methods=('GET',)) +def gsearchreq2(): + return render_template("gsearch2.html") + +@app.route("/gsearchact2", methods=('GET',)) +def gsearchact2(): + print("request.args is", request.args) + result = gsearch.GSearch(request.args).__dict__ + return render_template("gsearchact2.html", **result) + @app.route("/docedit") def docedit(): doc = docs.Docs(request.args['entry']) -- cgit v1.2.3