From eb39b41f1f73ffac48cd5a9c4180e50aee77d8ef Mon Sep 17 00:00:00 2001 From: Lei Yan Date: Fri, 24 Jul 2015 22:38:19 +0000 Subject: Committer: Lei Yan On branch master --- wqflask/wqflask/gsearch.py | 110 ++++++------------ wqflask/wqflask/templates/gsearch0.html | 48 -------- wqflask/wqflask/templates/gsearch1.html | 55 --------- wqflask/wqflask/templates/gsearch2.html | 63 ----------- wqflask/wqflask/templates/gsearch_gene.html | 159 +++++++++++++++++++++++++++ wqflask/wqflask/templates/gsearch_pheno.html | 149 +++++++++++++++++++++++++ wqflask/wqflask/templates/gsearchact.html | 147 ------------------------- wqflask/wqflask/templates/gsearchact0.html | 139 ----------------------- wqflask/wqflask/templates/gsearchact1.html | 118 -------------------- wqflask/wqflask/templates/gsearchact2.html | 137 ----------------------- wqflask/wqflask/views.py | 33 +----- 11 files changed, 346 insertions(+), 812 deletions(-) delete mode 100755 wqflask/wqflask/templates/gsearch0.html delete mode 100755 wqflask/wqflask/templates/gsearch1.html delete mode 100755 wqflask/wqflask/templates/gsearch2.html create mode 100755 wqflask/wqflask/templates/gsearch_gene.html create mode 100755 wqflask/wqflask/templates/gsearch_pheno.html delete mode 100755 wqflask/wqflask/templates/gsearchact.html delete mode 100755 wqflask/wqflask/templates/gsearchact0.html delete mode 100755 wqflask/wqflask/templates/gsearchact1.html delete mode 100755 wqflask/wqflask/templates/gsearchact2.html (limited to 'wqflask') diff --git a/wqflask/wqflask/gsearch.py b/wqflask/wqflask/gsearch.py index 4792f77b..dd0815b1 100755 --- a/wqflask/wqflask/gsearch.py +++ b/wqflask/wqflask/gsearch.py @@ -5,83 +5,9 @@ from flask import Flask, g class GSearch(object): 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() - else: - self.terms = kw['terms'] + self.type = kw['type'] + self.terms = kw['terms'] + if self.type == "gene": sql = """ SELECT Species.`Name` AS species_name, @@ -110,3 +36,33 @@ class GSearch(object): LIMIT 1000 """ % (self.terms) self.results = g.db.execute(sql).fetchall() + elif self.type == "phenotype": + sql = """ + SELECT + Species.`Name`, + InbredSet.`Name`, + PublishXRef.`Id`, + Phenotype.`Post_publication_description`, + Publication.`Authors`, + Publication.`Year`, + PublishXRef.`LRS`, + PublishXRef.`Locus`, + PublishXRef.`additive` + FROM Species,InbredSet,PublishXRef,Phenotype,Publication + WHERE PublishXRef.`InbredSetId`=InbredSet.`Id` + AND InbredSet.`SpeciesId`=Species.`Id` + AND PublishXRef.`PhenotypeId`=Phenotype.`Id` + AND PublishXRef.`PublicationId`=Publication.`Id` + AND (Phenotype.Post_publication_description REGEXP "[[:<:]]%s[[:>:]]" + OR Phenotype.Pre_publication_description REGEXP "[[:<:]]%s[[:>:]]" + OR Phenotype.Pre_publication_abbreviation REGEXP "[[:<:]]%s[[:>:]]" + OR Phenotype.Post_publication_abbreviation REGEXP "[[:<:]]%s[[:>:]]" + OR Phenotype.Lab_code REGEXP "[[:<:]]%s[[:>:]]" + OR Publication.PubMed_ID REGEXP "[[:<:]]%s[[:>:]]" + OR Publication.Abstract REGEXP "[[:<:]]%s[[:>:]]" + OR Publication.Title REGEXP "[[:<:]]%s[[:>:]]" + OR Publication.Authors REGEXP "[[:<:]]%s[[:>:]]" + OR PublishXRef.Id REGEXP "[[:<:]]%s[[:>:]]") + ORDER BY Species.`Name`, InbredSet.`Name`, Phenotype.`Post_publication_description` + """ % (self.terms, self.terms, self.terms, self.terms, self.terms, self.terms, self.terms, self.terms, self.terms, self.terms) + self.results = g.db.execute(sql).fetchall() diff --git a/wqflask/wqflask/templates/gsearch0.html b/wqflask/wqflask/templates/gsearch0.html deleted file mode 100755 index 45ab0d3b..00000000 --- a/wqflask/wqflask/templates/gsearch0.html +++ /dev/null @@ -1,48 +0,0 @@ -{% 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/gsearch1.html b/wqflask/wqflask/templates/gsearch1.html deleted file mode 100755 index 500e7f3d..00000000 --- a/wqflask/wqflask/templates/gsearch1.html +++ /dev/null @@ -1,55 +0,0 @@ -{% 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 deleted file mode 100755 index 9a6da575..00000000 --- a/wqflask/wqflask/templates/gsearch2.html +++ /dev/null @@ -1,63 +0,0 @@ -{% 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/gsearch_gene.html b/wqflask/wqflask/templates/gsearch_gene.html new file mode 100755 index 00000000..3e1cb32e --- /dev/null +++ b/wqflask/wqflask/templates/gsearch_gene.html @@ -0,0 +1,159 @@ +{% 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 %} + + {% endfor %} + + {% endfor %} + + +
IndexSymbolRecordDescriptionSpeciesGroupTissueDatasetChrMbMeanMax LRSLocusPvalueAdditive
{{ loop.index }}{{ item }}
+
+
+ + + +{% endblock %} + +{% block js %} + + + + + + + + + + + + +{% endblock %} diff --git a/wqflask/wqflask/templates/gsearch_pheno.html b/wqflask/wqflask/templates/gsearch_pheno.html new file mode 100755 index 00000000..f6b6efa3 --- /dev/null +++ b/wqflask/wqflask/templates/gsearch_pheno.html @@ -0,0 +1,149 @@ +{% 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 %} + + {% endfor %} + + {% endfor %} + + +
IndexSpeciesGroupRecord IDPhenotypeAuthorsYearMax LRSLocusAdditive
{{ loop.index }}{{ item }}
+
+
+ + + +{% endblock %} + +{% block js %} + + + + + + + + + + + + +{% endblock %} diff --git a/wqflask/wqflask/templates/gsearchact.html b/wqflask/wqflask/templates/gsearchact.html deleted file mode 100755 index 26d7b5cd..00000000 --- a/wqflask/wqflask/templates/gsearchact.html +++ /dev/null @@ -1,147 +0,0 @@ -{% 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 %} - - {% endfor %} - - {% endfor %} - - -
IndexSymbolRecordDescriptionSpeciesGroupTissueDatasetChrMbMeanMax LRSLocusPvalueAdditive
{{ loop.index }}{{ item }}
-
-
- - - -{% endblock %} - -{% block js %} - - - - - - - - - - -{% endblock %} diff --git a/wqflask/wqflask/templates/gsearchact0.html b/wqflask/wqflask/templates/gsearchact0.html deleted file mode 100755 index 54e156e1..00000000 --- a/wqflask/wqflask/templates/gsearchact0.html +++ /dev/null @@ -1,139 +0,0 @@ -{% 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 %} - - {% endfor %} - - {% endfor %} - - -
IndexSpeciesGroupTissueDatasetRecordSymbolDescriptionChrMbMeanMax LRSLocusPvalueAdditive
{{ loop.index }}{{ item }}
-
-
- - - -{% endblock %} - -{% block js %} - - - - - - - - -{% endblock %} diff --git a/wqflask/wqflask/templates/gsearchact1.html b/wqflask/wqflask/templates/gsearchact1.html deleted file mode 100755 index dcc82f91..00000000 --- a/wqflask/wqflask/templates/gsearchact1.html +++ /dev/null @@ -1,118 +0,0 @@ -{% 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 %} - - -
IndexGroupTissueDatasetRecordSymbolDescriptionChrMbMeanMax LRSLocusPvalueAdditive
{{ loop.index }}{{ item }}
-
-
- - - -{% endblock %} - -{% block js %} - - - - - - - - -{% endblock %} diff --git a/wqflask/wqflask/templates/gsearchact2.html b/wqflask/wqflask/templates/gsearchact2.html deleted file mode 100755 index 295ad2fd..00000000 --- a/wqflask/wqflask/templates/gsearchact2.html +++ /dev/null @@ -1,137 +0,0 @@ -{% 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 %} - - -
IndexTissueDatasetRecordSymbolDescriptionChrMbMeanMax LRSLocusPvalueAdditive
{{ loop.index }}{{ item }}
-
-
- - - -{% endblock %} - -{% block js %} - - - - - - - - -{% endblock %} diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index d188aea1..00c8d00d 100755 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -158,34 +158,11 @@ def search_page(): @app.route("/gsearch", methods=('GET',)) def gsearchact(): result = gsearch.GSearch(request.args).__dict__ - return render_template("gsearchact.html", **result) - -@app.route("/gsearch0", methods=('GET',)) -def gsearchreq0(): - return render_template("gsearch0.html") - -@app.route("/gsearchact0", methods=('GET',)) -def gsearchact0(): - result = gsearch.GSearch(request.args).__dict__ - return render_template("gsearchact0.html", **result) - -@app.route("/gsearch1", methods=('GET',)) -def gsearchreq1(): - return render_template("gsearch1.html") - -@app.route("/gsearchact1", methods=('GET',)) -def gsearchact1(): - result = gsearch.GSearch(request.args).__dict__ - return render_template("gsearchact1.html", **result) - -@app.route("/gsearch2", methods=('GET',)) -def gsearchreq2(): - return render_template("gsearch2.html") - -@app.route("/gsearchact2", methods=('GET',)) -def gsearchact2(): - result = gsearch.GSearch(request.args).__dict__ - return render_template("gsearchact2.html", **result) + type = request.args['type'] + if type == "gene": + return render_template("gsearch_gene.html", **result) + elif type == "phenotype": + return render_template("gsearch_pheno.html", **result) @app.route("/docedit") def docedit(): -- cgit v1.2.3