aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wqflask/base/trait.py44
-rw-r--r--wqflask/wqflask/gsearch.py166
-rwxr-xr-xwqflask/wqflask/templates/gsearch_gene.html121
-rw-r--r--wqflask/wqflask/update_search_results.py129
-rw-r--r--wqflask/wqflask/views.py12
5 files changed, 319 insertions, 153 deletions
diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py
index 6c5ca8b2..af22b5a1 100644
--- a/wqflask/base/trait.py
+++ b/wqflask/base/trait.py
@@ -308,14 +308,54 @@ class GeneralTrait(object):
if isinstance(trait_info[i], basestring):
holder = unicode(trait_info[i], "utf8", "ignore")
setattr(self, field, holder)
+<<<<<<< HEAD
+
+ description_string = unicode(str(self.description).strip(codecs.BOM_UTF8), 'utf-8')
+ target_string = unicode(str(self.probe_target_description).strip(codecs.BOM_UTF8), 'utf-8')
+
+ if len(description_string) > 1 and description_string != 'None':
+ description_display = description_string
+ else:
+ description_display = self.symbol
+
+ if (len(description_display) > 1 and description_display != 'N/A' and
+ len(target_string) > 1 and target_string != 'None'):
+ description_display = description_display + '; ' + target_string.strip()
+
+ # Save it for the jinja2 template
+ self.description_display = description_display
+
+ #XZ: trait_location_value is used for sorting
+ trait_location_repr = 'N/A'
+ trait_location_value = 1000000
+
+ if self.chr and self.mb:
+ #Checks if the chromosome number can be cast to an int (i.e. isn't "X" or "Y")
+ #This is so we can convert the location to a number used for sorting
+ trait_location_value = convert_location_to_value(self.chr, self.mb)
+ #try:
+ # trait_location_value = int(self.chr)*1000 + self.mb
+ #except ValueError:
+ # if self.chr.upper() == 'X':
+ # trait_location_value = 20*1000 + self.mb
+ # else:
+ # trait_location_value = (ord(str(self.chr).upper()[0])*1000 +
+ # self.mb)
+
+ #ZS: Put this in function currently called "convert_location_to_value"
+ self.location_repr = 'Chr%s: %.6f' % (self.chr, float(self.mb))
+ self.location_value = trait_location_value
+
+=======
+>>>>>>> e0c5c1aae3aaaa1d81bcec36835a97e169dcc2e2
if self.dataset.type == 'Publish':
self.confidential = 0
if self.pre_publication_description and not self.pubmed_id:
self.confidential = 1
-
- description = self.post_publication_description
+ description = self.post_publication_description
+
#If the dataset is confidential and the user has access to confidential
#phenotype traits, then display the pre-publication description instead
#of the post-publication description
diff --git a/wqflask/wqflask/gsearch.py b/wqflask/wqflask/gsearch.py
index 4cd3874c..4f9dc316 100644
--- a/wqflask/wqflask/gsearch.py
+++ b/wqflask/wqflask/gsearch.py
@@ -1,94 +1,94 @@
from __future__ import absolute_import, print_function, division
from flask import Flask, g
-from base.data_set import create_dataset
-from base.trait import GeneralTrait
-from dbFunction import webqtlDatabaseFunction
+#from base.data_set import create_dataset
+#from base.trait import GeneralTrait
+#from dbFunction import webqtlDatabaseFunction
-from utility.benchmark import Bench
+#from utility.benchmark import Bench
class GSearch(object):
def __init__(self, kw):
self.type = kw['type']
self.terms = kw['terms']
- if self.type == "gene":
- sql = """
- SELECT
- Species.`Name` AS species_name,
- InbredSet.`Name` AS inbredset_name,
- Tissue.`Name` AS tissue_name,
- ProbeSetFreeze.Name AS probesetfreeze_name,
- 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 Species, InbredSet, ProbeSetXRef, ProbeSet, ProbeFreeze, ProbeSetFreeze, Tissue
- WHERE InbredSet.`SpeciesId`=Species.`Id`
- 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
- AND ProbeSetFreeze.public > 0
- ORDER BY species_name, inbredset_name, tissue_name, probesetfreeze_name, probeset_name
- LIMIT 6000
- """ % (self.terms)
- with Bench("Running query"):
- re = g.db.execute(sql).fetchall()
- self.trait_list = []
- with Bench("Creating trait objects"):
- for line in re:
- dataset = create_dataset(line[3], "ProbeSet", get_samplelist=False)
- trait_id = line[4]
- #with Bench("Building trait object"):
- this_trait = GeneralTrait(dataset=dataset, name=trait_id, get_qtl_info=True, get_sample_info=False)
- self.trait_list.append(this_trait)
+ # if self.type == "gene":
+ # sql = """
+ # SELECT
+ # Species.`Name` AS species_name,
+ # InbredSet.`Name` AS inbredset_name,
+ # Tissue.`Name` AS tissue_name,
+ # ProbeSetFreeze.Name AS probesetfreeze_name,
+ # 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 Species, InbredSet, ProbeSetXRef, ProbeSet, ProbeFreeze, ProbeSetFreeze, Tissue
+ # WHERE InbredSet.`SpeciesId`=Species.`Id`
+ # 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
+ # AND ProbeSetFreeze.public > 0
+ # ORDER BY species_name, inbredset_name, tissue_name, probesetfreeze_name, probeset_name
+ # LIMIT 6000
+ # """ % (self.terms)
+ # with Bench("Running query"):
+ # re = g.db.execute(sql).fetchall()
+ # self.trait_list = []
+ # with Bench("Creating trait objects"):
+ # for line in re:
+ # dataset = create_dataset(line[3], "ProbeSet", get_samplelist=False)
+ # trait_id = line[4]
+ # with Bench("Building trait object"):
+ # this_trait = GeneralTrait(dataset=dataset, name=trait_id, get_qtl_info=True, get_sample_info=False)
+ # self.trait_list.append(this_trait)
- elif self.type == "phenotype":
- sql = """
- SELECT
- Species.`Name`,
- InbredSet.`Name`,
- PublishFreeze.`Name`,
- PublishXRef.`Id`,
- Phenotype.`Post_publication_description`,
- Publication.`Authors`,
- Publication.`Year`,
- PublishXRef.`LRS`,
- PublishXRef.`Locus`,
- PublishXRef.`additive`
- FROM Species,InbredSet,PublishFreeze,PublishXRef,Phenotype,Publication
- WHERE PublishXRef.`InbredSetId`=InbredSet.`Id`
- AND PublishFreeze.`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`, PublishXRef.`Id`
- LIMIT 6000
- """ % (self.terms, self.terms, self.terms, self.terms, self.terms, self.terms, self.terms, self.terms, self.terms, self.terms)
- re = g.db.execute(sql).fetchall()
- self.trait_list = []
- with Bench("Creating trait objects"):
- for line in re:
- dataset = create_dataset(line[2], "Publish")
- trait_id = line[3]
- this_trait = GeneralTrait(dataset=dataset, name=trait_id, get_qtl_info=True, get_sample_info=False)
- self.trait_list.append(this_trait)
+ # elif self.type == "phenotype":
+ # sql = """
+ # SELECT
+ # Species.`Name`,
+ # InbredSet.`Name`,
+ # PublishFreeze.`Name`,
+ # PublishXRef.`Id`,
+ # Phenotype.`Post_publication_description`,
+ # Publication.`Authors`,
+ # Publication.`Year`,
+ # PublishXRef.`LRS`,
+ # PublishXRef.`Locus`,
+ # PublishXRef.`additive`
+ # FROM Species,InbredSet,PublishFreeze,PublishXRef,Phenotype,Publication
+ # WHERE PublishXRef.`InbredSetId`=InbredSet.`Id`
+ # AND PublishFreeze.`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`, PublishXRef.`Id`
+ # LIMIT 6000
+ # """ % (self.terms, self.terms, self.terms, self.terms, self.terms, self.terms, self.terms, self.terms, self.terms, self.terms)
+ # re = g.db.execute(sql).fetchall()
+ # self.trait_list = []
+ # with Bench("Creating trait objects"):
+ # for line in re:
+ # dataset = create_dataset(line[2], "Publish")
+ # trait_id = line[3]
+ # this_trait = GeneralTrait(dataset=dataset, name=trait_id, get_qtl_info=True, get_sample_info=False)
+ # self.trait_list.append(this_trait)
diff --git a/wqflask/wqflask/templates/gsearch_gene.html b/wqflask/wqflask/templates/gsearch_gene.html
index 7cc9a1bd..92b0b411 100755
--- a/wqflask/wqflask/templates/gsearch_gene.html
+++ b/wqflask/wqflask/templates/gsearch_gene.html
@@ -2,10 +2,6 @@
{% block title %}Search Results{% endblock %}
{% block css %}
<link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/css/jquery.dataTables.css" />
- <link rel="stylesheet" type="text/css" href="/static/packages/DT_bootstrap/DT_bootstrap.css" />
- <link rel="stylesheet" type="text/css" href="/static/packages/TableTools/media/css/TableTools.css" />
- <link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/extensions/dataTables.fixedHeader.css" >
- <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/fixedcolumns/3.0.4/css/dataTables.fixedColumns.css">
<link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/extensions/buttons.bootstrap.css" />
{% endblock %}
{% block content %}
@@ -13,6 +9,7 @@
<div class="container">
+ <p>You searched for {{ terms }}.</p>
<p>To study a record, click on its ID below.<br />Check records below and click Add button to add to selection.</p>
<div>
@@ -26,46 +23,28 @@
<br />
<br />
- <table width="2000px" class="table table-hover table-striped" id="trait_table">
+ <div style="width: 2000px;">
+ <table width="2000px" id="trait_table" class="table table-hover table-striped" >
<thead>
- <tr>
- <th style="width: 30px;"></th>
- <th>Index</th>
- <th>Species</th>
- <th>Group</th>
- <th>Tissue</th>
- <th>Dataset</th>
- <th>Record</th>
- <th>Symbol</th>
- <th>Description</th>
- <th>Location</th>
- <th>Mean</th>
- <th style="text-align: right;">Max&nbsp;&nbsp;<br>LRS<a href="http://genenetwork.org//glossary.html#L" target="_blank"><sup style="color:#f00"> ?</sup></a></th>
- <th>Max LRS Location</th>
- <th style="text-align: right;">Additive<br>Effect<a href="http://genenetwork.org//glossary.html#A" target="_blank"><sup style="color:#f00"> ?</sup></a></th>
- </tr>
- </thead>
- <tbody>
- {% for this_trait in trait_list %}
- <TR id="trait:{{ this_trait.name }}:{{ this_trait.dataset.name }}">
- <TD><INPUT TYPE="checkbox" NAME="searchResult" class="checkbox trait_checkbox" style="transform: scale(1.5);" VALUE="{{ data_hmac('{}:{}'.format(this_trait.name, this_trait.dataset.name)) }}"></TD>
- <TD>{{ loop.index }}</TD>
- <TD>{{ this_trait.dataset.group.species }}</TD>
- <TD>{{ this_trait.dataset.group.name }}</TD>
- <TD>{{ this_trait.dataset.tissue }}</TD>
- <TD>{{ this_trait.dataset.fullname }}</TD>
- <TD><a href="{{ url_for('show_trait_page', trait_id = this_trait.name, dataset = this_trait.dataset.name)}}">{{ this_trait.name }}</a></TD>
- <TD>{{ this_trait.symbol }}</TD>
- <TD>{{ this_trait.description_display }}</TD>
- <TD>{{ this_trait.location_repr }}</TD>
- <TD align="right">{{ '%0.3f' % this_trait.mean|float }}</TD>
- <TD align="right">{{ '%0.3f' % this_trait.LRS_score_repr|float }}</TD>
- <TD>{{ this_trait.LRS_location_repr }}</TD>
- <TD align="right">{{ '%0.3f' % this_trait.additive|float }}</TD>
- </TR>
- {% endfor %}
- </tbody>
- </table>
+ <tr>
+ <th></th>
+ <th>Index</th>
+ <th>Species</th>
+ <th>Group</th>
+ <th>Tissue</th>
+ <th>Dataset</th>
+ <th>Record</th>
+ <th>Symbol</th>
+ <th>Description</th>
+ <th>Location</th>
+ <th>Mean</th>
+ <th>Max<br>LRS<a href="http://genenetwork.org/glossary.html#L" target="_blank"><sup style="color:#f00"> ?</sup></a></th>
+ <th>Max LRS Location</th>
+ <th>Additive<br>Effect<a href="http://genenetwork.org/glossary.html#A" target="_blank"><sup style="color:#f00"> ?</sup></a></th>
+ </tr>
+ </thead>
+ </table>
+ </div>
</div>
</div>
@@ -156,23 +135,18 @@
console.time("Creating table");
$('#trait_table').DataTable( {
- "columns": [
- { "type": "natural" },
- { "type": "natural" },
- { "type": "natural" },
- { "type": "cust-txt" },
- { "type": "natural" },
- { "type": "natural" },
- { "type": "natural" },
- { "type": "natural" },
- { "type": "natural", "width": "15%" },
- { "type": "natural" },
- { "type": "natural" },
- { "type": "natural" },
- { "type": "natural" },
- { "type": "cust-txt" }
- ],
- "order": [[ 1, "asc" ]],
+ "processing": true,
+ "serverSide": true,
+ "paging": false,
+ "ajax": {
+ "url": "/gsearch_updating?terms={{ terms }}&type={{ type }}",
+ "type": "POST",
+ "dataType": "json",
+ "contentType": "application/json; charset=utf-8",
+ "data": function ( args ) {
+ return { "args": JSON.stringify( args ) };
+ }
+ },
"buttons": [
{
extend: 'csvHtml5',
@@ -184,15 +158,26 @@
}
}
],
- "sDom": "RZBtir",
+ "columns": [
+ { "data": "checkbox", "orderable" : false },
+ { "data": "index", "orderable" : true },
+ { "data": "species", "orderable" : true },
+ { "data": "group", "orderable" : true },
+ { "data": "tissue", "orderable" : true },
+ { "data": "dataset", "orderable" : true },
+ { "data": "record", "orderable" : true },
+ { "data": "symbol", "orderable" : true },
+ { "data": "description", "orderable" : true },
+ { "data": "location", "orderable" : true },
+ { "data": "mean", "orderable" : true },
+ { "data": "max_lrs", "orderable" : true },
+ { "data": "max_lrs_location", "orderable" : true },
+ { "data": "additive_effect", "orderable" : true }
+ ],
+ "sDom": "Bfrti",
"autoWidth": false,
- "bLengthChange": true,
- "bDeferRender": true,
- "scrollCollapse": false,
- "colResize": {
- "tableWidthFixed": false,
- },
- "paging": false
+ "scrollY": "800px",
+ "bDeferRender": true
} );
console.timeEnd("Creating table");
diff --git a/wqflask/wqflask/update_search_results.py b/wqflask/wqflask/update_search_results.py
new file mode 100644
index 00000000..ffd7fd51
--- /dev/null
+++ b/wqflask/wqflask/update_search_results.py
@@ -0,0 +1,129 @@
+from __future__ import absolute_import, print_function, division
+
+import json
+
+from flask import Flask, g
+from base.data_set import create_dataset
+from base.trait import GeneralTrait
+from dbFunction import webqtlDatabaseFunction
+
+from utility.benchmark import Bench
+
+class GSearch(object):
+
+ def __init__(self, kw):
+ self.type = kw['type']
+ self.terms = kw['terms']
+ #self.row_range = kw['row_range']
+ if self.type == "gene":
+ sql = """
+ SELECT
+ Species.`Name` AS species_name,
+ InbredSet.`Name` AS inbredset_name,
+ Tissue.`Name` AS tissue_name,
+ ProbeSetFreeze.Name AS probesetfreeze_name,
+ 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 Species, InbredSet, ProbeSetXRef, ProbeSet, ProbeFreeze, ProbeSetFreeze, Tissue
+ WHERE InbredSet.`SpeciesId`=Species.`Id`
+ 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
+ AND ProbeSetFreeze.public > 0
+ ORDER BY species_name, inbredset_name, tissue_name, probesetfreeze_name, probeset_name
+ LIMIT 6000
+ """ % (self.terms)
+ with Bench("Running query"):
+ re = g.db.execute(sql).fetchall()
+ self.trait_list = []
+ with Bench("Creating trait objects"):
+ for line in re:
+ dataset = create_dataset(line[3], "ProbeSet", get_samplelist=False)
+ trait_id = line[4]
+ #with Bench("Building trait object"):
+ this_trait = GeneralTrait(dataset=dataset, name=trait_id, get_qtl_info=True, get_sample_info=False)
+ self.trait_list.append(this_trait)
+
+ elif self.type == "phenotype":
+ sql = """
+ SELECT
+ Species.`Name`,
+ InbredSet.`Name`,
+ PublishFreeze.`Name`,
+ PublishXRef.`Id`,
+ Phenotype.`Post_publication_description`,
+ Publication.`Authors`,
+ Publication.`Year`,
+ PublishXRef.`LRS`,
+ PublishXRef.`Locus`,
+ PublishXRef.`additive`
+ FROM Species,InbredSet,PublishFreeze,PublishXRef,Phenotype,Publication
+ WHERE PublishXRef.`InbredSetId`=InbredSet.`Id`
+ AND PublishFreeze.`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`, PublishXRef.`Id`
+ LIMIT 6000
+ """ % (self.terms, self.terms, self.terms, self.terms, self.terms, self.terms, self.terms, self.terms, self.terms, self.terms)
+ re = g.db.execute(sql).fetchall()
+ self.trait_list = []
+ with Bench("Creating trait objects"):
+ for line in re:
+ dataset = create_dataset(line[2], "Publish")
+ trait_id = line[3]
+ this_trait = GeneralTrait(dataset=dataset, name=trait_id, get_qtl_info=True, get_sample_info=False)
+ self.trait_list.append(this_trait)
+
+ self.results = self.convert_to_json()
+
+ def convert_to_json(self):
+ json_dict = {}
+ #json_dict['draw'] = self.draw,
+ json_dict['recordsTotal'] = len(self.trait_list),
+ json_dict['data'] = []
+
+ for i, trait in enumerate(self.trait_list):
+ trait_row = { "checkbox": "<INPUT TYPE=\"checkbox\" NAME=\"searchResult\" class=\"checkbox trait_checkbox\" style=\"transform: scale(1.5);\" VALUE=\"{}:{}\">".format(trait.name, trait.dataset.name),
+ "index": i+1,
+ "species": trait.dataset.group.species,
+ "group": trait.dataset.group.name,
+ "tissue": trait.dataset.tissue,
+ "dataset": trait.dataset.fullname,
+ "record": "<a href=\"/show_trait?trait_id=" + trait.name + "&dataset=" + trait.dataset.name + "\" target=\"_blank\">" + trait.name + "</a>",
+ "symbol": trait.symbol,
+ "description": trait.description_display,
+ "location": trait.location_repr,
+ "mean": trait.mean,
+ "max_lrs": trait.LRS_score_repr,
+ "max_lrs_location": trait.LRS_location_repr,
+ "additive_effect": trait.additive}
+ json_dict['data'].append(trait_row)
+
+ json_results = json.dumps(json_dict)
+ return json_results
+
+
+
+
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index bd2fff50..7854b0df 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -34,6 +34,7 @@ from flask import (render_template, request, make_response, Response,
from wqflask import search_results
from wqflask import gsearch
+from wqflask import update_search_results
from wqflask import docs
from wqflask import news
from base.data_set import DataSet # Used by YAML in marker_regression
@@ -169,6 +170,17 @@ def gsearchact():
return render_template("gsearch_gene.html", **result)
elif type == "phenotype":
return render_template("gsearch_pheno.html", **result)
+
+@app.route("/gsearch_updating", methods=('POST',))
+def gsearch_updating():
+ print("REQUEST ARGS:", request.values)
+ result = update_search_results.GSearch(request.args).__dict__
+ return result['results']
+ # type = request.args['type']
+ # if type == "gene":
+ # return render_template("gsearch_gene_updating.html", **result)
+ # elif type == "phenotype":
+ # return render_template("gsearch_pheno.html", **result)
@app.route("/docedit")
def docedit():