aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wqflask/wqflask/gsearch.py115
-rw-r--r--wqflask/wqflask/templates/correlation_page.html4
-rw-r--r--wqflask/wqflask/templates/gsearch_gene.html15
-rw-r--r--wqflask/wqflask/templates/gsearch_pheno.html15
-rw-r--r--wqflask/wqflask/templates/loading.html12
-rw-r--r--wqflask/wqflask/templates/mapping_results.html2
-rw-r--r--wqflask/wqflask/templates/search_result_page.html4
-rw-r--r--wqflask/wqflask/templates/show_trait.html2
-rw-r--r--wqflask/wqflask/views.py13
9 files changed, 127 insertions, 55 deletions
diff --git a/wqflask/wqflask/gsearch.py b/wqflask/wqflask/gsearch.py
index fb8bdc55..8f66f7e9 100644
--- a/wqflask/wqflask/gsearch.py
+++ b/wqflask/wqflask/gsearch.py
@@ -121,16 +121,14 @@ class GSearch:
continue
max_lrs_text = "N/A"
- if this_trait['locus_chr'] != None and this_trait['locus_mb'] != None:
- max_lrs_text = "Chr" + \
- str(this_trait['locus_chr']) + \
- ": " + str(this_trait['locus_mb'])
+ if this_trait['locus_chr'] and this_trait['locus_mb']:
+ max_lrs_text = f"Chr{str(this_trait['locus_chr'])}: {str(this_trait['locus_mb'])}"
this_trait['max_lrs_text'] = max_lrs_text
trait_list.append(this_trait)
self.trait_count = len(trait_list)
- self.trait_list = json.dumps(trait_list)
+ self.trait_list = trait_list
self.header_fields = ['Index',
'Record',
@@ -146,6 +144,22 @@ class GSearch:
'Max LRS Location',
'Additive Effect']
+ self.header_data_names = [
+ 'index',
+ 'name',
+ 'species',
+ 'group',
+ 'tissue',
+ 'dataset_fullname',
+ 'symbol',
+ 'description',
+ 'location_repr',
+ 'mean',
+ 'LRS_score_repr',
+ 'max_lrs_text',
+ 'additive',
+ ]
+
elif self.type == "phenotype":
search_term = self.terms
group_clause = ""
@@ -169,24 +183,23 @@ class GSearch:
PublishXRef.`LRS`,
PublishXRef.`additive`,
InbredSet.`InbredSetCode`,
- PublishXRef.`mean`
- FROM Species,InbredSet,PublishFreeze,PublishXRef,Phenotype,Publication
- WHERE PublishXRef.`InbredSetId`=InbredSet.`Id`
- AND PublishFreeze.`InbredSetId`=InbredSet.`Id`
- AND InbredSet.`SpeciesId`=Species.`Id`
+ PublishXRef.`mean`,
+ PublishFreeze.Id,
+ Geno.Chr as geno_chr,
+ Geno.Mb as geno_mb
+ FROM Species
+ INNER JOIN InbredSet ON InbredSet.`SpeciesId`=Species.`Id`
+ INNER JOIN PublishFreeze ON PublishFreeze.`InbredSetId`=InbredSet.`Id`
+ INNER JOIN PublishXRef ON PublishXRef.`InbredSetId`=InbredSet.`Id`
+ INNER JOIN Phenotype ON PublishXRef.`PhenotypeId`=Phenotype.`Id`
+ INNER JOIN Publication ON PublishXRef.`PublicationId`=Publication.`Id`
+ LEFT JOIN Geno ON PublishXRef.Locus = Geno.Name AND Geno.SpeciesId = Species.Id
+ WHERE
+ (
+ (MATCH (Phenotype.Post_publication_description, Phenotype.Pre_publication_description, Phenotype.Pre_publication_abbreviation, Phenotype.Post_publication_abbreviation, Phenotype.Lab_code) AGAINST ('{1}' IN BOOLEAN MODE) )
+ OR (MATCH (Publication.Abstract, Publication.Title, Publication.Authors) AGAINST ('{1}' IN BOOLEAN MODE) )
+ )
{0}
- AND PublishXRef.`PhenotypeId`=Phenotype.`Id`
- AND PublishXRef.`PublicationId`=Publication.`Id`
- AND (Phenotype.Post_publication_description REGEXP "[[:<:]]{1}[[:>:]]"
- OR Phenotype.Pre_publication_description REGEXP "[[:<:]]{1}[[:>:]]"
- OR Phenotype.Pre_publication_abbreviation REGEXP "[[:<:]]{1}[[:>:]]"
- OR Phenotype.Post_publication_abbreviation REGEXP "[[:<:]]{1}[[:>:]]"
- OR Phenotype.Lab_code REGEXP "[[:<:]]{1}[[:>:]]"
- OR Publication.PubMed_ID REGEXP "[[:<:]]{1}[[:>:]]"
- OR Publication.Abstract REGEXP "[[:<:]]{1}[[:>:]]"
- OR Publication.Title REGEXP "[[:<:]]{1}[[:>:]]"
- OR Publication.Authors REGEXP "[[:<:]]{1}[[:>:]]"
- OR PublishXRef.Id REGEXP "[[:<:]]{1}[[:>:]]")
ORDER BY Species.`Name`, InbredSet.`Name`, PublishXRef.`Id`
LIMIT 6000
""".format(group_clause, search_term)
@@ -221,6 +234,9 @@ class GSearch:
this_trait['mean'] = f"{line[13]:.3f}"
else:
this_trait['mean'] = "N/A"
+ this_trait['dataset_id'] = line[14]
+ this_trait['locus_chr'] = line[15]
+ this_trait['locus_mb'] = line[16]
this_trait['authors'] = line[7]
this_trait['year'] = line[8]
if this_trait['year'].isdigit():
@@ -241,32 +257,51 @@ class GSearch:
if line[11] != "" and line[11] != None:
this_trait['additive'] = '%.3f' % line[11]
+ dataset_ob = SimpleNamespace(id=this_trait["dataset_id"], type="Publish", species=this_trait["species"])
+ permissions = check_resource_availability(dataset_ob, this_trait['name'])
+ if type(permissions['data']) is list:
+ if "view" not in permissions['data']:
+ continue
+ else:
+ if permissions['data'] == 'no-access':
+ continue
+
this_trait['max_lrs_text'] = "N/A"
- trait_ob = create_trait(
- dataset_name=this_trait['dataset'], name=this_trait['name'], get_qtl_info=True, get_sample_info=False)
- if not trait_ob:
- continue
if this_trait['dataset'] == this_trait['group'] + "Publish":
try:
- if trait_ob.locus_chr != "" and trait_ob.locus_mb != "":
- this_trait['max_lrs_text'] = "Chr" + \
- str(trait_ob.locus_chr) + \
- ": " + str(trait_ob.locus_mb)
+ if this_trait['locus_chr'] and this_trait['locus_mb']:
+ this_trait['max_lrs_text'] = f"Chr{str(this_trait['locus_chr'])}: {str(this_trait['locus_mb'])}"
except:
this_trait['max_lrs_text'] = "N/A"
trait_list.append(this_trait)
self.trait_count = len(trait_list)
- self.trait_list = json.dumps(trait_list)
+ self.trait_list = trait_list
self.header_fields = ['Index',
- 'Species',
- 'Group',
- 'Record',
- 'Description',
- 'Authors',
- 'Year',
- 'Max LRS',
- 'Max LRS Location',
- 'Additive Effect']
+ 'Species',
+ 'Group',
+ 'Record',
+ 'Description',
+ 'Authors',
+ 'Year',
+ 'Max LRS',
+ 'Max LRS Location',
+ 'Additive Effect']
+
+ self.header_data_names = [
+ 'index',
+ 'name',
+ 'species',
+ 'group',
+ 'tissue',
+ 'dataset_fullname',
+ 'symbol',
+ 'description',
+ 'location_repr',
+ 'mean',
+ 'LRS_score_repr',
+ 'max_lrs_text',
+ 'additive',
+ ]
diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html
index a9a3e1a0..4cad2749 100644
--- a/wqflask/wqflask/templates/correlation_page.html
+++ b/wqflask/wqflask/templates/correlation_page.html
@@ -4,7 +4,7 @@
<link rel="stylesheet" type="text/css" href="{{ url_for('css', filename='DataTables/css/jquery.dataTables.css') }}" />
<link rel="stylesheet" type="text/css" href="{{ url_for('js', filename='DataTablesExtensions/buttonsBootstrap/css/buttons.bootstrap.css') }}" />
<link rel="stylesheet" type="text/css" href="{{ url_for('js', filename='DataTablesExtensions/buttonStyles/css/buttons.dataTables.min.css') }}">
- <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css">
+ <link rel="stylesheet" type="text/css" href="{{ url_for('css', filename='fontawesome/css/all.min.css') }}"/>
<link rel="stylesheet" type="text/css" href="/static/new/css/trait_list.css" />
<link rel="stylesheet" type="text/css" href="/static/new/css/show_trait.css" />
{% endblock %}
@@ -141,7 +141,7 @@
<script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/buttons/js/dataTables.buttons.min.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/buttons/js/buttons.html5.min.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/plugins/sorting/natural.js') }}"></script>
- <script language="javascript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/js/all.min.js"></script>
+ <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='fontawesome/js/all.min.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/scroller/js/dataTables.scroller.min.js') }}"></script>
diff --git a/wqflask/wqflask/templates/gsearch_gene.html b/wqflask/wqflask/templates/gsearch_gene.html
index 6fd0abe8..48953d98 100644
--- a/wqflask/wqflask/templates/gsearch_gene.html
+++ b/wqflask/wqflask/templates/gsearch_gene.html
@@ -55,7 +55,15 @@
<script language="javascript" type="text/javascript" src="/static/new/javascript/search_results.js"></script>
<script type='text/javascript'>
- var the_rows = {{ trait_list|safe }};
+ var getParams = function(url) {
+ let parser = document.createElement('a');
+ parser.href = url;
+ let params = parser.search.substring(1);
+ if(params.length > 0) {
+ return ('?'+params);
+ }
+ return params;
+ };
</script>
<script type="text/javascript" charset="utf-8">
@@ -142,7 +150,6 @@
$('td', row).eq(12).attr('data-export', $('td', row).eq(12).text());
$('td', row).eq(13).attr('data-export', $('td', row).eq(13).text());
},
- 'data': the_rows,
'columns': [
{
'data': null,
@@ -237,11 +244,13 @@
'order': [[1, "asc" ]],
'sDom': "pitirp",
'autoWidth': true,
- 'iDisplayLength': 500,
'deferRender': false,
'paging': true,
'orderClasses': true,
'processing': true,
+ 'iDisplayLength': 100,
+ 'bServerSide': true,
+ 'sAjaxSource': '/gsearch_table'+getParams(window.location.href),
'language': {
'loadingRecords': '&nbsp;',
'processing': 'Loading...'
diff --git a/wqflask/wqflask/templates/gsearch_pheno.html b/wqflask/wqflask/templates/gsearch_pheno.html
index 987b51a7..af9740ae 100644
--- a/wqflask/wqflask/templates/gsearch_pheno.html
+++ b/wqflask/wqflask/templates/gsearch_pheno.html
@@ -55,7 +55,15 @@
<script language="javascript" type="text/javascript" src="/static/new/javascript/search_results.js"></script>
<script type='text/javascript'>
- var the_rows = {{ trait_list|safe }};
+ var getParams = function(url) {
+ let parser = document.createElement('a');
+ parser.href = url;
+ let params = parser.search.substring(1);
+ if(params.length > 0) {
+ return ('?'+params);
+ }
+ return params;
+ };
</script>
<script type="text/javascript" charset="utf-8">
@@ -130,7 +138,6 @@
$('td', row).eq(9).attr('data-export', $('td', row).eq(9).text());
$('td', row).eq(10).attr('data-export', $('td', row).eq(10).text());
},
- 'data': the_rows,
'columns': [
{
'data': null,
@@ -241,10 +248,12 @@
'sDom': "pitirp",
'autoWidth': false,
'deferRender': false,
- 'iDisplayLength': 500,
'paging': true,
'orderClasses': true,
'processing': true,
+ 'iDisplayLength': 100,
+ 'bServerSide': true,
+ 'sAjaxSource': '/gsearch_table'+getParams(window.location.href),
'language': {
'loadingRecords': '&nbsp;',
'processing': 'Loading...'
diff --git a/wqflask/wqflask/templates/loading.html b/wqflask/wqflask/templates/loading.html
index 1adeb2bd..6d6136ac 100644
--- a/wqflask/wqflask/templates/loading.html
+++ b/wqflask/wqflask/templates/loading.html
@@ -33,18 +33,24 @@
<br>
minor allele frequency lower limit = <b><i>{{ start_vars.maf }}</i></b>
{% endif %}
- {% if start_vars.covariates != "" and start_vars.method != "reaper" %}
<br>
+ {% if start_vars.covariates != "" and start_vars.method != "reaper" %}
{% set covariate_list = start_vars.covariates.split(",") %}
cofactors = <b><i>{% for covariate in covariate_list %}{% set this_covariate = covariate.split(":")[0] %}{{ this_covariate }}{% if not loop.last %}, {% endif %}{% endfor %}</i></b>
+ {% else %}
+ cofactors = <b><i>None</i></b>
{% endif %}
{% if start_vars.control_marker != "" and start_vars.do_control == "true" and start_vars.method != "gemma" %}
<br>
marker covariate = <b><i>{{ start_vars.control_marker }}</i></b>
{% endif %}
- {% set genofile_desc = start_vars.genofile.split(":")[1] %}
<br>
- Genotype File = <b><i>{{ genofile_desc }}</i></b>
+ {% if start_vars.genofile != "" %}
+ {% set genofile_desc = start_vars.genofile.split(":")[1] %}
+ genotype file = <b><i>{{ genofile_desc }}</i></b>
+ {% else %}
+ genotype file = <b><i>{{ start_vars.group[0] | upper }}{{ start_vars.group[1:] }}.geno</i></b>
+ {% endif %}
{% if start_vars.num_perm | int > 0 and start_vars.method != "gemma" %}
<br>
n of permutations = <b><i>{{ start_vars.num_perm }}</i></b>
diff --git a/wqflask/wqflask/templates/mapping_results.html b/wqflask/wqflask/templates/mapping_results.html
index 73d7501b..d6fc6e37 100644
--- a/wqflask/wqflask/templates/mapping_results.html
+++ b/wqflask/wqflask/templates/mapping_results.html
@@ -357,7 +357,7 @@
{% endif %}
<script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTables/js/jquery.dataTables.min.js') }}"></script>
- <script language="javascript" type="text/javascript" src="https://cdn.datatables.net/buttons/1.0.0/js/dataTables.buttons.min.js"></script>
+ <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/buttons/js/dataTables.buttons.min.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/plugins/sorting/scientific.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/plugins/sorting/natural.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ url_for('js', filename='purescript-genome-browser/js/purescript-genetics-browser.js') }}"></script>
diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html
index e7a7bc51..827bad98 100644
--- a/wqflask/wqflask/templates/search_result_page.html
+++ b/wqflask/wqflask/templates/search_result_page.html
@@ -4,7 +4,7 @@
<link rel="stylesheet" type="text/css" href="{{ url_for('css', filename='DataTables/css/jquery.dataTables.css') }}" />
<link rel="stylesheet" type="text/css" href="{{ url_for('css', filename='fontawesome/css/font-awesome.min.css') }}" />
<link rel="stylesheet" type="text/css" href="{{ url_for('js', filename='DataTablesExtensions/buttonStyles/css/buttons.dataTables.min.css') }}">
- <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css">
+ <link rel="stylesheet" type="text/css" href="{{ url_for('css', filename='fontawesome/css/all.min.css') }}"/>
<link rel="stylesheet" type="text/css" href="/static/new/css/show_trait.css" />
<link rel="stylesheet" type="text/css" href="static/new/css/trait_list.css" />
{% endblock %}
@@ -150,7 +150,7 @@
<script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/plugins/sorting/natural.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/buttons/js/dataTables.buttons.min.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/buttons/js/buttons.colVis.min.js') }}"></script>
- <script language="javascript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/js/all.min.js"></script>
+ <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='fontawesome/js/all.min.js') }}"></script>
<script language="javascript" type="text/javascript" src="/static/new/javascript/search_results.js"></script>
diff --git a/wqflask/wqflask/templates/show_trait.html b/wqflask/wqflask/templates/show_trait.html
index 09ecb7b6..fc14822c 100644
--- a/wqflask/wqflask/templates/show_trait.html
+++ b/wqflask/wqflask/templates/show_trait.html
@@ -148,7 +148,7 @@
<script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTables/js/jquery.dataTables.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/plugins/sorting/scientific.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/plugins/sorting/natural.js') }}"></script>
- <script language="javascript" type="text/javascript" src="https://cdn.datatables.net/scroller/2.0.3/js/dataTables.scroller.min.js"></script>
+ <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/scroller/js/dataTables.scroller.min.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ url_for('js', filename='nouislider/nouislider.js') }}"></script>
<script type="text/javascript" src="/static/new/javascript/initialize_show_trait_tables.js"></script>
<script type="text/javascript" src="/static/new/javascript/show_trait_mapping_tools.js"></script>
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index f3b0257c..3c875163 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -280,6 +280,19 @@ def gsearchact():
elif type == "phenotype":
return render_template("gsearch_pheno.html", **result)
+@app.route("/gsearch_table", methods=('GET',))
+def gsearchtable():
+ logger.info(request.url)
+
+ gsearch_table_data = GSearch(request.args)
+ current_page = server_side.ServerSideTable(
+ gsearch_table_data.trait_count,
+ gsearch_table_data.trait_list,
+ gsearch_table_data.header_data_names,
+ request.args,
+ ).get_page()
+
+ return flask.jsonify(current_page)
@app.route("/gsearch_updating", methods=('POST',))
def gsearch_updating():