diff options
author | zsloan | 2020-10-19 13:43:32 -0500 |
---|---|---|
committer | GitHub | 2020-10-19 13:43:32 -0500 |
commit | 8eaae7296e2d66726975ddba0de8aecae256e63b (patch) | |
tree | 5505b932195a454c1ada10677f0e76faba6b588f /wqflask/wqflask | |
parent | 5fdb3b83566516782542d04b92a5be97f41c2330 (diff) | |
parent | 3f242af74af814d9344e1e80c5f94914c6d9b621 (diff) | |
download | genenetwork2-8eaae7296e2d66726975ddba0de8aecae256e63b.tar.gz |
Merge branch 'testing' into scroller_testing
Diffstat (limited to 'wqflask/wqflask')
32 files changed, 619 insertions, 377 deletions
diff --git a/wqflask/wqflask/__init__.py b/wqflask/wqflask/__init__.py index d729aef5..7ed9c7b8 100644 --- a/wqflask/wqflask/__init__.py +++ b/wqflask/wqflask/__init__.py @@ -12,13 +12,24 @@ logging.basicConfig(level=logging.INFO) app = Flask(__name__) -app.config.from_envvar('GN2_SETTINGS') # See http://flask.pocoo.org/docs/config/#configuring-from-files +# See http://flask.pocoo.org/docs/config/#configuring-from-files # Note no longer use the badly named WQFLASK_OVERRIDES (nyi) - +app.config.from_envvar('GN2_SETTINGS') app.jinja_env.globals.update( - undefined = jinja2.StrictUndefined, - numify = formatting.numify -) + undefined=jinja2.StrictUndefined, + numify=formatting.numify) from wqflask.api import router +from wqflask import group_manager +from wqflask import resource_manager +from wqflask import search_results +from wqflask import export_traits +from wqflask import gsearch +from wqflask import update_search_results +from wqflask import docs +from wqflask import news +from wqflask import db_info +from wqflask import user_login +from wqflask import user_session + import wqflask.views diff --git a/wqflask/wqflask/collect.py b/wqflask/wqflask/collect.py index 42a09fed..4c558bfe 100644 --- a/wqflask/wqflask/collect.py +++ b/wqflask/wqflask/collect.py @@ -1,41 +1,30 @@ from __future__ import print_function, division, absolute_import - -import os -import hashlib import datetime -import time - -import uuid -import hashlib -import base64 - -import urlparse - import simplejson as json -from flask import (Flask, g, render_template, url_for, request, make_response, - redirect, flash, jsonify) +from flask import g +from flask import render_template +from flask import url_for +from flask import request +from flask import redirect +from flask import flash from wqflask import app - -from pprint import pformat as pf - -from wqflask.database import db_session - -from wqflask import model - -from utility import Bunch, Struct, hmac +from utility import hmac from utility.formatting import numify from utility.redis_tools import get_redis_conn -Redis = get_redis_conn() -from base.trait import create_trait, retrieve_trait_info, jsonable +from base.trait import create_trait +from base.trait import retrieve_trait_info +from base.trait import jsonable from base.data_set import create_dataset -import logging from utility.logger import getLogger + logger = getLogger(__name__) +Redis = get_redis_conn() + def process_traits(unprocessed_traits): if isinstance(unprocessed_traits, basestring): diff --git a/wqflask/wqflask/correlation/corr_scatter_plot.py b/wqflask/wqflask/correlation/corr_scatter_plot.py index 819836b1..0f3d455c 100644 --- a/wqflask/wqflask/correlation/corr_scatter_plot.py +++ b/wqflask/wqflask/correlation/corr_scatter_plot.py @@ -17,8 +17,15 @@ class CorrScatterPlot(object): """Page that displays a correlation scatterplot with a line fitted to it""" def __init__(self, params): - self.dataset_1 = data_set.create_dataset(params['dataset_1']) - self.dataset_2 = data_set.create_dataset(params['dataset_2']) + if "Temp" in params['dataset_1']: + self.dataset_1 = data_set.create_dataset(dataset_name = "Temp", dataset_type = "Temp", group_name = params['dataset_1'].split("_")[1]) + else: + self.dataset_1 = data_set.create_dataset(params['dataset_1']) + if "Temp" in params['dataset_2']: + self.dataset_2 = data_set.create_dataset(dataset_name = "Temp", dataset_type = "Temp", group_name = params['dataset_2'].split("_")[1]) + else: + self.dataset_2 = data_set.create_dataset(params['dataset_2']) + #self.dataset_3 = data_set.create_dataset(params['dataset_3']) self.trait_1 = create_trait(name=params['trait_1'], dataset=self.dataset_1) self.trait_2 = create_trait(name=params['trait_2'], dataset=self.dataset_2) diff --git a/wqflask/wqflask/correlation_matrix/show_corr_matrix.py b/wqflask/wqflask/correlation_matrix/show_corr_matrix.py index 0ac94139..3beee84f 100644 --- a/wqflask/wqflask/correlation_matrix/show_corr_matrix.py +++ b/wqflask/wqflask/correlation_matrix/show_corr_matrix.py @@ -147,7 +147,7 @@ class CorrelationMatrix(object): if num_overlap < self.lowest_overlap: self.lowest_overlap = num_overlap - if num_overlap == 0: + if num_overlap < 2: corr_result_row.append([target_trait, 0, num_overlap]) pca_corr_result_row.append(0) else: diff --git a/wqflask/wqflask/db_info.py b/wqflask/wqflask/db_info.py new file mode 100644 index 00000000..f04e38bf --- /dev/null +++ b/wqflask/wqflask/db_info.py @@ -0,0 +1,127 @@ +import httplib, urllib2
+import re
+
+from flask import Flask, g
+
+from utility.logger import getLogger
+logger = getLogger(__name__ )
+
+class InfoPage(object):
+ def __init__(self, start_vars):
+ self.info = None
+ self.gn_accession_id = None
+ if 'gn_accession_id' in start_vars:
+ self.gn_accession_id = start_vars['gn_accession_id']
+ self.info_page_name = start_vars['info_page_name']
+
+ self.get_info()
+ self.get_datasets_list()
+
+ def get_info(self, create=False):
+ query_base = ("SELECT InfoPageName, GN_AccesionId, Species.MenuName, Species.TaxonomyId, Tissue.Name, InbredSet.Name, " +
+ "GeneChip.GeneChipName, GeneChip.GeoPlatform, AvgMethod.Name, Datasets.DatasetName, Datasets.GeoSeries, " +
+ "Datasets.PublicationTitle, DatasetStatus.DatasetStatusName, Datasets.Summary, Datasets.AboutCases, " +
+ "Datasets.AboutTissue, Datasets.AboutDataProcessing, Datasets.Acknowledgment, Datasets.ExperimentDesign, " +
+ "Datasets.Contributors, Datasets.Citation, Datasets.Notes, Investigators.FirstName, Investigators.LastName, " +
+ "Investigators.Address, Investigators.City, Investigators.State, Investigators.ZipCode, Investigators.Country, " +
+ "Investigators.Phone, Investigators.Email, Investigators.Url, Organizations.OrganizationName, " +
+ "InvestigatorId, DatasetId, DatasetStatusId, Datasets.AboutPlatform, InfoFileTitle, Specifics " +
+ "FROM InfoFiles " +
+ "LEFT JOIN Species USING (SpeciesId) " +
+ "LEFT JOIN Tissue USING (TissueId) " +
+ "LEFT JOIN InbredSet USING (InbredSetId) " +
+ "LEFT JOIN GeneChip USING (GeneChipId) " +
+ "LEFT JOIN AvgMethod USING (AvgMethodId) " +
+ "LEFT JOIN Datasets USING (DatasetId) " +
+ "LEFT JOIN Investigators USING (InvestigatorId) " +
+ "LEFT JOIN Organizations USING (OrganizationId) " +
+ "LEFT JOIN DatasetStatus USING (DatasetStatusId) WHERE ")
+
+ if self.gn_accession_id:
+ final_query = query_base + "GN_AccesionId = {}".format(self.gn_accession_id)
+ results = g.db.execute(final_query).fetchone()
+ if self.info_page_name and not results:
+ final_query = query_base + "InfoPageName={}".format(self.info_page_name)
+ elif self.info_page_name:
+ final_query = query_base + "InfoPageName={}".format(self.info_page_name)
+ results = g.db.execute(final_query).fetchone()
+ else:
+ raise 'No correct parameter found'
+
+ if results:
+ self.info = process_query_results(results)
+
+ if (not results or len(results) < 1) and self.info_page_name and create:
+ insert_sql = "INSERT INTO InfoFiles SET InfoFiles.InfoPageName={}".format(self.info_page_name)
+ return self.get_info()
+
+ if not self.gn_accession_id and self.info:
+ self.gn_accession_id = self.info['accession_id']
+ if not self.info_page_name and self.info:
+ self.info_page_name = self.info['info_page_name']
+
+ def get_datasets_list(self):
+ self.filelist = []
+ try:
+ response = urllib2.urlopen("http://datafiles.genenetwork.org/download/GN%s" % self.gn_accession_id)
+ data = response.read()
+
+ matches = re.findall(r"<tr>.+?</tr>", data, re.DOTALL)
+ for i, match in enumerate(matches):
+ if i == 0:
+ continue
+ cells = re.findall(r"<td.+?>.+?</td>", match, re.DOTALL)
+ full_filename = re.search(r"<a href=\"(.+?)\"", cells[1], re.DOTALL).group(1).strip()
+ filename = full_filename.split("/")[-1]
+ filesize = re.search(r">(.+?)<", cells[2]).group(1).strip()
+ filedate = "N/A" #ZS: Since we can't get it for now
+
+ self.filelist.append([filename, filedate, filesize])
+ except Exception, e:
+ pass
+
+def process_query_results(results):
+ info_ob = {
+ 'info_page_name': results[0],
+ 'accession_id': results[1],
+ 'menu_name': results[2],
+ 'taxonomy_id': results[3],
+ 'tissue_name': results[4],
+ 'group_name': results[5],
+ 'gene_chip_name': results[6],
+ 'geo_platform': results[7],
+ 'avg_method_name': results[8],
+ 'dataset_name': results[9],
+ 'geo_series': results[10],
+ 'publication_title': results[11],
+ 'dataset_status_name': results[12],
+ 'dataset_summary': results[13],
+ 'about_cases': results[14],
+ 'about_tissue': results[15],
+ 'about_data_processing': results[16],
+ 'acknowledgement': results[17],
+ 'experiment_design': results[18],
+ 'contributors': results[19],
+ 'citation': results[20],
+ 'notes': results[21],
+ 'investigator_firstname': results[22],
+ 'investigator_lastname': results[23],
+ 'investigator_address': results[24],
+ 'investigator_city': results[25],
+ 'investigator_state': results[26],
+ 'investigator_zipcode': results[27],
+ 'investigator_country': results[28],
+ 'investigator_phone': results[29],
+ 'investigator_email': results[30],
+ 'investigator_url': results[31],
+ 'organization_name': results[32],
+ 'investigator_id': results[33],
+ 'dataset_id': results[34],
+ 'dataset_status_is': results[35],
+ 'about_platform': results[36],
+ 'info_file_title': results[37],
+ 'specifics': results[38]
+ }
+
+ return info_ob
+
\ No newline at end of file diff --git a/wqflask/wqflask/docs.py b/wqflask/wqflask/docs.py index 78407e22..9fad1cf1 100644 --- a/wqflask/wqflask/docs.py +++ b/wqflask/wqflask/docs.py @@ -11,7 +11,7 @@ class Docs(object): def __init__(self, entry, start_vars={}): sql = """ - SELECT Docs.title, Docs.content + SELECT Docs.title, CAST(Docs.content AS BINARY) FROM Docs WHERE Docs.entry LIKE %s """ @@ -22,7 +22,7 @@ class Docs(object): self.content = "" else: self.title = result[0] - self.content = result[1].encode("latin1") + self.content = result[1] self.editable = "false" # ZS: Removing option to edit to see if text still gets vandalized diff --git a/wqflask/wqflask/marker_regression/run_mapping.py b/wqflask/wqflask/marker_regression/run_mapping.py index 9bde343c..8a44b3fd 100644 --- a/wqflask/wqflask/marker_regression/run_mapping.py +++ b/wqflask/wqflask/marker_regression/run_mapping.py @@ -401,9 +401,7 @@ class RunMapping(object): rs = marker['name'], pos = this_ps ) - #if 'p_value' in marker: - # logger.debug("P EXISTS:", marker['p_value']) - #else: + if 'lrs_value' in marker and marker['lrs_value'] > 0: browser_marker['p_wald'] = 10**-(marker['lrs_value']/4.61) elif 'lod_score' in marker and marker['lod_score'] > 0: @@ -417,6 +415,12 @@ class RunMapping(object): if marker['chr'] > highest_chr or marker['chr'] == "X" or marker['chr'] == "X/Y": highest_chr = marker['chr'] if ('lod_score' in marker.keys()) or ('lrs_value' in marker.keys()): + if 'Mb' in marker.keys(): + marker['display_pos'] = "Chr" + str(marker['chr']) + ": " + "{:.3f}".format(marker['Mb']) + elif 'cM' in marker.keys(): + marker['display_pos'] = "Chr" + str(marker['chr']) + ": " + "{:.3f}".format(marker['cM']) + else: + marker['display_pos'] = "N/A" self.qtl_results.append(marker) with Bench("Exporting Results"): diff --git a/wqflask/wqflask/resource_manager.py b/wqflask/wqflask/resource_manager.py index 39a07310..14ff2183 100644 --- a/wqflask/wqflask/resource_manager.py +++ b/wqflask/wqflask/resource_manager.py @@ -25,16 +25,16 @@ def manage_resource(): group_masks_with_names = get_group_names(group_masks) default_mask = resource_info['default_mask']['data'] owner_id = resource_info['owner_id'] - owner_info = get_user_by_unique_column("user_id", owner_id) - - if 'name' in owner_info: - owner_display_name = owner_info['full_name'] - elif 'user_name' in owner_info: - owner_display_name = owner_info['user_name'] - elif 'email_address' in owner_info: - owner_display_name = owner_info['email_address'] - else: - owner_display_name = None + + owner_display_name = None + if owner_id != "none": + owner_info = get_user_by_unique_column("user_id", owner_id) + if 'name' in owner_info: + owner_display_name = owner_info['full_name'] + elif 'user_name' in owner_info: + owner_display_name = owner_info['user_name'] + elif 'email_address' in owner_info: + owner_display_name = owner_info['email_address'] return render_template("admin/manage_resource.html", owner_name = owner_display_name, resource_id = resource_id, resource_info=resource_info, default_mask=default_mask, group_masks=group_masks_with_names, admin_status=admin_status) diff --git a/wqflask/wqflask/static/new/css/marker_regression.css b/wqflask/wqflask/static/new/css/marker_regression.css index f1a26a83..e0a5ceea 100644 --- a/wqflask/wqflask/static/new/css/marker_regression.css +++ b/wqflask/wqflask/static/new/css/marker_regression.css @@ -62,6 +62,10 @@ table.dataTable tbody td { padding: 4px 20px 2px 10px; } +table.dataTable tbody tr.selected { + background-color: #ffee99; +} + table.dataTable.cell-border tbody th, table.dataTable.cell-border tbody td { border-top: 1px solid #ccc; border-right: 1px solid #ccc; diff --git a/wqflask/wqflask/static/new/css/show_trait.css b/wqflask/wqflask/static/new/css/show_trait.css index 853819ea..7a7f5455 100644 --- a/wqflask/wqflask/static/new/css/show_trait.css +++ b/wqflask/wqflask/static/new/css/show_trait.css @@ -54,4 +54,8 @@ table.dataTable.cell-border tbody tr td:first-child { .trait_value_input { text-align: right; + +.glyphicon { + position: relative; + top: 2px; }
\ No newline at end of file diff --git a/wqflask/wqflask/static/new/javascript/search_results.js b/wqflask/wqflask/static/new/javascript/search_results.js index 4e87d67a..86660126 100644 --- a/wqflask/wqflask/static/new/javascript/search_results.js +++ b/wqflask/wqflask/static/new/javascript/search_results.js @@ -93,7 +93,7 @@ $(function() { }); - add = function() { + add_to_collection = function() { var traits; traits = $("#trait_table input:checked").map(function() { return $(this).val(); @@ -250,7 +250,7 @@ $(function() { $("#select_all").click(select_all); $("#deselect_all").click(deselect_all); $("#invert").click(invert); - $("#add").click(add); + $("#add").click(add_to_collection); $("#submit_bnw").click(submit_bnw); $("#export_traits").click(export_traits); $('.trait_checkbox, .btn').click(change_buttons); @@ -259,14 +259,22 @@ $(function() { let naturalAsc = $.fn.dataTableExt.oSort["natural-ci-asc"] let naturalDesc = $.fn.dataTableExt.oSort["natural-ci-desc"] + let na_equivalent_vals = ["N/A", "--", ""]; //ZS: Since there are multiple values that should be treated the same as N/A + + function extract_inner_text(the_string){ + var span = document.createElement('span'); + span.innerHTML = the_string; + return span.textContent || span.innerText; + } + function sort_NAs(a, b, sort_function){ - if (a === "N/A" && b === "N/A") { + if ( na_equivalent_vals.includes(a) && na_equivalent_vals.includes(b)) { return 0; } - if (a === "N/A"){ + if (na_equivalent_vals.includes(a)){ return 1 } - if (b === "N/A") { + if (na_equivalent_vals.includes(b)) { return -1; } return sort_function(a, b) @@ -274,11 +282,25 @@ $(function() { $.extend( $.fn.dataTableExt.oSort, { "natural-minus-na-asc": function (a, b) { - return sort_NAs(a, b, naturalAsc) + return sort_NAs(extract_inner_text(a), extract_inner_text(b), naturalAsc) }, "natural-minus-na-desc": function (a, b) { - return sort_NAs(a, b, naturalDesc) + return sort_NAs(extract_inner_text(a), extract_inner_text(b), naturalDesc) } }); + $.fn.dataTable.ext.order['dom-checkbox'] = function ( settings, col ) + { + return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) { + return $('input', td).prop('checked') ? '1' : '0'; + } ); + }; + + $.fn.dataTable.ext.order['dom-inner-text'] = function ( settings, col ) + { + return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) { + return $(td).text(); + } ); + } + });
\ No newline at end of file diff --git a/wqflask/wqflask/templates/base.html b/wqflask/wqflask/templates/base.html index 50562200..b44538cf 100644 --- a/wqflask/wqflask/templates/base.html +++ b/wqflask/wqflask/templates/base.html @@ -4,7 +4,9 @@ <head> <meta charset="utf-8"> - <title>{% block title %}{% endblock %}</title> + + <title>{% block title %}{% endblock %} GeneNetwork 2</title> + <meta name="description" content=""> <meta name="author" content=""> <link rel="icon" type="image/png" sizes="64x64" href="/static/new/images/CITGLogo.png"> @@ -19,6 +21,14 @@ {% block css %} {% endblock %} + <style> + table.dataTable thead .sorting_asc { + background-image: url({{ url_for("js", filename="DataTables/images/sort_asc_disabled.png") }}); + } + table.dataTable thead .sorting_desc { + background-image: url({{ url_for("js", filename="DataTables/images/sort_desc_disabled.png") }}); + } + </style> </head> <body style="width: 100%"> diff --git a/wqflask/wqflask/templates/collections/add.html b/wqflask/wqflask/templates/collections/add.html index 825dfb84..62b6abb5 100644 --- a/wqflask/wqflask/templates/collections/add.html +++ b/wqflask/wqflask/templates/collections/add.html @@ -5,7 +5,7 @@ or add to an existing collection.</p> </div> <div class="modal-body" style="margin-left: 20px;"> - <form action="/collections/new" data-validate="parsley" id="add_form"> + <form action="/collections/new" target="_blank" data-validate="parsley" id="add_form"> {% if traits is defined %} <input type="hidden" name="traits" value="{{ traits }}" /> {% else %} diff --git a/wqflask/wqflask/templates/collections/view.html b/wqflask/wqflask/templates/collections/view.html index dce814dd..d1a97310 100644 --- a/wqflask/wqflask/templates/collections/view.html +++ b/wqflask/wqflask/templates/collections/view.html @@ -8,7 +8,7 @@ {% block content %} <!-- Start of body --> - <div class="container" style="min-width: 2050px;"> + <div class="container"> <h1> <span id="collection_name">{{ uc.name }}</span> <input type="text" name="new_collection_name" style="font-size: 20px; display: none; width: 500px;" class="form-control" placeholder="{{ uc.name }}"> @@ -16,8 +16,6 @@ </h1> <h3>This collection has {{ '{}'.format(numify(trait_obs|count, "record", "records")) }}</h3> - <!--<hr style="height: 1px; background-color: #A9A9A9;">--> - <div> <form id="collection_form" action="/delete" method="post"> <input type="hidden" name="uc_id" id="uc_id" value="{{ uc.id }}" /> @@ -77,7 +75,7 @@ <input type="hidden" name="database_name" id="database_name" value="None"> <input type="hidden" name="export_data" id="export_data" value=""> <input type="hidden" name="file_name" id="file_name" value="collection_table"> - <button class="btn btn-default" id="export_traits">Download CSV</button> + <button class="btn btn-default" id="export_traits">Download</button> <input type="text" id="searchbox" class="form-control" style="width: 200px; display: inline; padding-bottom: 9px;" placeholder="Search Table For ..."> <input type="text" id="select_top" class="form-control" style="width: 200px; display: inline; padding-bottom: 9px;" placeholder="Select Top ..."> <button class="btn btn-default" id="deselect_all" type="button"><span class="glyphicon glyphicon-remove"></span> Deselect</button> @@ -87,7 +85,7 @@ <div style="margin-top: 10px; margin-bottom: 5px;"> <b>Show/Hide Columns:</b> </div> - <div> + <div style="min-width: 1500px;"> <table class="table-hover table-striped cell-border" id='trait_table' style="float: left;"> <thead> <tr> @@ -99,9 +97,9 @@ <th data-export="Description">Description</th> <th data-export="Location">Location</th> <th data-export="Mean">Mean</th> - <th data-export="Max LRS">Max LRS <a href="http://genenetwork.org//glossary.html#L" target="_blank"><sup>?</sup></a></th> - <th data-export="Max LRS Location">Max LRS Location</th> - <th data-export="Add. Eff.">Additive Effect <a href="http://genenetwork.org//glossary.html#A" target="_blank"><sup>?</sup></a></th> + <th data-export="Max LRS">High P <a href="http://genenetwork.org//glossary.html#L" target="_blank"><sup style="font-size: small; color: #FF0000;"> ?</sup></a></th> + <th data-export="Peak Location">Peak Location</th> + <th data-export="Add. Eff.">Effect Size <a href="http://genenetwork.org//glossary.html#A" target="_blank"><sup style="font-size: small; color: #FF0000;"> ?</sup></a></th> </tr> </thead> @@ -144,7 +142,7 @@ <TD data-export="{{ this_trait.LRS_score_repr }}" align="right">N/A</TD> {% endif %} <TD data-export="{{ this_trait.LRS_location_repr }}">{{ this_trait.LRS_location_repr }}</TD> - {% if this_trait.additive|float > 0 %} + {% if this_trait.additive|float != 0 %} <TD data-export="{{ this_trait.additive }}" align="right">{{ '%0.3f' % this_trait.additive|float }}</TD> {% else %} <TD data-export="{{ this_trait.additive }}" align="right">N/A</TD> @@ -166,13 +164,13 @@ {% block js %} <script language="javascript" type="text/javascript" src="/static/new/js_external/jszip.min.js"></script> <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='js_alt/md5.min.js') }}"></script> - <script type="text/javascript" src="/static/new/javascript/search_results.js"></script> <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="{{ url_for('js', filename='DataTablesExtensions/plugins/sorting/natural.js') }}"></script> <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/colResize/dataTables.colResize.js') }}"></script> <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/colReorder/js/dataTables.colReorder.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 type="text/javascript" src="/static/new/javascript/search_results.js"></script> <script language="javascript" type="text/javascript"> @@ -187,22 +185,22 @@ console.time("Creating table"); $('#trait_table').dataTable( { "columns": [ - { "type": "natural", "width": 10 }, + { + "orderDataType": "dom-checkbox", + "orderSequence": [ "desc", "asc"], + "width": 10 + }, { "type": "natural", "width": 50 }, { "type": "natural" }, - { "type": "natural", "width": 120 }, + { 'type': "natural-minus-na", "width": 120 }, { "type": "natural" }, { "type": "natural" }, - { "type": "natural", "width": 130 }, - { "type": "natural", "width": 35 }, - { "type": "natural", "width": 35 }, - { "type": "natural", "width": 130 }, - { "type": "natural" } + { "type": "natural", "width": 125 }, + { "type": "natural", "width": 60 }, + { "type": "natural", "width": 60 }, + { "type": "natural", "width": 125 }, + { "type": "natural", "width": 85 } ], - "columnDefs": [ { - "targets": 0, - "orderable": false - } ], "order": [[1, "asc" ]], buttons: [ { diff --git a/wqflask/wqflask/templates/correlation_matrix.html b/wqflask/wqflask/templates/correlation_matrix.html index 9b96de1c..d556f31a 100644 --- a/wqflask/wqflask/templates/correlation_matrix.html +++ b/wqflask/wqflask/templates/correlation_matrix.html @@ -51,7 +51,7 @@ {% if result[0].name == trait.name and result[0].dataset == trait.dataset %} <td nowrap="ON" align="center" bgcolor="#cccccc" style="padding: 3px; line-height: 1.1;"><a href="/show_trait?trait_id={{ trait.name }}&dataset={{ trait.dataset.name }}"><font style="font-size: 12px; color: #3071a9; font-weight: bold;" ><em>n</em><br>{{ result[2] }}</font></a></td> {% else %} - <td nowrap="ON" align="middle" class="corr_cell" style="padding: 3px; line-height: 1.1;"><a href="/corr_scatter_plot?dataset_1={{ trait.dataset.name }}&dataset_2={{ result[0].dataset.name }}&trait_1={{ trait.name }}&trait_2={{ result[0].name }}"><font style="font-size: 12px; color: #3071a9; font-weight: bold;" ><span class="corr_value">{{ '%0.2f' % result[1] }}</span><br>{{ result[2] }}</font></a></td> + <td nowrap="ON" align="middle" class="corr_cell" style="padding: 3px; line-height: 1.1;"><a href="/corr_scatter_plot?dataset_1={% if trait.dataset.name == 'Temp' %}Temp_{{ trait.dataset.group.name }}{% else %}{{ trait.dataset.name }}{% endif %}&dataset_2={% if result[0].dataset.name == 'Temp' %}Temp_{{ result[0].dataset.group.name }}{% else %}{{ result[0].dataset.name }}{% endif %}&trait_1={{ trait.name }}&trait_2={{ result[0].name }}"><font style="font-size: 12px; color: #3071a9; font-weight: bold;" ><span class="corr_value">{{ '%0.2f' % result[1] }}</span><br>{{ result[2] }}</font></a></td> {% endif %} {% endfor %} </tr> diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html index e597bea9..fb218e29 100644 --- a/wqflask/wqflask/templates/correlation_page.html +++ b/wqflask/wqflask/templates/correlation_page.html @@ -144,7 +144,7 @@ <td data-export="{{ trait.description_display }}">{{ trait.description_display }}</TD> <td data-export="{{ trait.location_repr }}" style="white-space: nowrap;">{{ trait.location_repr }}</td> <td data-export="{{ '%0.3f' % trait.mean|float }}" align="right">{{ '%0.3f' % trait.mean|float }}</td> - <td data-export="{{ '%0.3f'|format(trait.sample_r) }}"" align="right"><a target="_blank" href="corr_scatter_plot?dataset_1={{dataset.name}}&dataset_2={{trait.dataset.name}}&trait_1={{this_trait.name}}&trait_2={{trait.name}}">{{ '%0.3f'|format(trait.sample_r) }}</a></td> + <td data-export="{{ '%0.3f'|format(trait.sample_r) }}"" align="right"><a target="_blank" href="corr_scatter_plot?dataset_1={% if dataset.name == 'Temp' %}Temp_{{ dataset.group.name }}{% else %}{{ dataset.name }}{% endif %}&dataset_2={% if trait.dataset.name == 'Temp' %}Temp_{{ trait.dataset.group.name }}{% else %}{{ trait.dataset.name }}{% endif %}&trait_1={{ this_trait.name }}&trait_2={{ trait.name }}">{{ '%0.3f'|format(trait.sample_r) }}</a></td> <td data-export="{{ trait.num_overlap }}" align="right">{{ trait.num_overlap }}</td> <td data-export="{{ '%0.3e'|format(trait.sample_p) }}" align="right">{{ '%0.3e'|format(trait.sample_p) }}</td> {% if trait.lit_corr == "" or trait.lit_corr == 0.000 %} @@ -164,22 +164,26 @@ <td data-export={% if trait.additive != "" %}"{{ '%0.3f' % trait.additive|float }}"{% else %}"N/A"{% endif %} align="right">{% if trait.additive != "" %}{{ '%0.3f' % trait.additive|float }}{% else %}N/A{% endif %}</td> {% elif target_dataset.type == "Publish" %} {% if trait.abbreviation %} - <TD title="{{ trait.abbreviation }}" data-export="{{ trait.abbreviation }}">{% if trait.abbreviation|length > 20 %}{{ trait.abbreviation[:20] }}...{% else %}{{ trait.abbreviation }}{% endif %}</TD> + <td title="{{ trait.abbreviation }}" data-export="{{ trait.abbreviation }}">{% if trait.abbreviation|length > 20 %}{{ trait.abbreviation[:20] }}...{% else %}{{ trait.abbreviation }}{% endif %}</td> {% else %} - <TD data-export="N/A">N/A</TD> + <td data-export="N/A">N/A</td> {% endif %} <td data-export="{{ trait.description_display }}">{% if trait.description_display|length > 70 %}{{ trait.description_display[:70] }}...{% else %}{{ trait.description_display }}{% endif %}</td> {% if trait.authors %} <td data-export="{{ trait.authors }}">{% if trait.authors.split(',') > 6 %}{{ trait.authors.split(',')[:6]|join(', ') }}, et al.{% else %}{{ trait.authors }}{% endif %}</td> {% else %} - <TD data-export="N/A">N/A</TD> + <td data-export="N/A">N/A</td> {% endif %} <td data-export="{{ trait.pubmed_text }}"> + {% if trait.pubmed_text != "N/A" %} <a href="{{ trait.pubmed_link }}"> {{ trait.pubmed_text }} </a> + {% else %} + {{ trait.pubmed_text }} + {% endif %} </td> - <td data-export="{{ '%0.3f'|format(trait.sample_r) }}" align="right"><a target="_blank" href="corr_scatter_plot?dataset_1={{dataset.name}}&dataset_2={{trait.dataset.name}}&trait_1={{this_trait.name}}&trait_2={{trait.name}}">{{ '%0.3f'|format(trait.sample_r) }}</a></td> + <td data-export="{{ '%0.3f'|format(trait.sample_r) }}"" align="right"><a target="_blank" href="corr_scatter_plot?dataset_1={% if dataset.name == 'Temp' %}Temp_{{ dataset.group.name }}{% else %}{{ dataset.name }}{% endif %}&dataset_2={{ trait.dataset.name }}&trait_1={{ this_trait.name }}&trait_2={{ trait.name }}">{{ '%0.3f'|format(trait.sample_r) }}</a></td> <td data-export="{{ trait.num_overlap }}" align="right">{{ trait.num_overlap }}</td> <td data-export="{{ '%0.3e'|format(trait.sample_p) }}" align="right">{{ '%0.3e'|format(trait.sample_p) }}</td> <td data-export="{{ trait.LRS_score_repr }}" align="right">{{ trait.LRS_score_repr }}</td> @@ -187,7 +191,7 @@ <td data-export={% if trait.additive != "" %}"{{ '%0.3f' % trait.additive|float }}"{% else %}"N/A"{% endif %} align="right">{% if trait.additive != "" %}{{ '%0.3f' % trait.additive|float }}{% else %}N/A{% endif %}</td> {% elif target_dataset.type == "Geno" %} <td data-export="{{ trait.location_repr }}" align="right">{{ trait.location_repr }}</TD> - <td data-export="{{ '%0.3f'|format(trait.sample_r) }}" align="right"><a target="_blank" href="corr_scatter_plot?dataset_1={{dataset.name}}&dataset_2={{trait.dataset.name}}&trait_1={{this_trait.name}}&trait_2={{trait.name}}">{{ '%0.3f'|format(trait.sample_r) }}</a></td> + <td data-export="{{ '%0.3f'|format(trait.sample_r) }}"" align="right"><a target="_blank" href="corr_scatter_plot?dataset_1={% if dataset.name == 'Temp' %}Temp_{{ dataset.group.name }}{% else %}{{ dataset.name }}{% endif %}&dataset_2={{ trait.dataset.name }}&trait_1={{ this_trait.name }}&trait_2={{ trait.name }}">{{ '%0.3f'|format(trait.sample_r) }}</a></td> <td data-export="{{ trait.num_overlap }}" align="right">{{ trait.num_overlap }}</td> <td data-export="{{ '%0.3e'|format(trait.sample_p) }}" align="right">{{ '%0.3e'|format(trait.sample_p) }}</td> {% endif %} @@ -365,9 +369,9 @@ { "type": "numeric-html", 'orderSequence': [ "desc", "asc"] }, { "type": "numeric-html", 'orderSequence': [ "desc", "asc"] }, { "type": "scientific" }, - { "type": "natural" }, - { "type": "natural" }, - { "type": "natural" } + { "type": "natural-minus-na" }, + { "type": "natural-minus-na" }, + { "type": "natural-minus-na" } ], "createdRow": function ( row, data, index ) { $('td', row).eq(4).attr('title', $('td', row).eq(4).text()); @@ -419,13 +423,13 @@ { "type": "natural" }, { "type": "natural", "width": "20%" }, { "type": "natural", "width": "12%" }, - { "orderDataType": "dom-innertext" }, + { "type": "natural-minus-na" }, { "orderDataType": "dom-innertext", 'orderSequence': [ "desc", "asc"] }, { "type": "natural" }, { "type": "scientific" }, - { "type": "natural" }, - { "type": "natural" }, - { "type": "natural" } + { "type": "natural-minus-na" }, + { "type": "natural-minus-na" }, + { "type": "natural-minus-na" } ], "order": [[9, "asc" ]], "sDom": "Btir", @@ -461,7 +465,7 @@ { "type": "natural" }, { "type": "natural" }, { "orderDataType": "dom-innertext", 'orderSequence': [ "desc", "asc"] }, - { "type": "natural" }, + { "type": "natural-minus-na" }, { "type": "scientific" } ], "order": [[6, "asc" ]], diff --git a/wqflask/wqflask/templates/gsearch_gene.html b/wqflask/wqflask/templates/gsearch_gene.html index 478d6f5f..d2c78d65 100644 --- a/wqflask/wqflask/templates/gsearch_gene.html +++ b/wqflask/wqflask/templates/gsearch_gene.html @@ -59,20 +59,6 @@ </script> <script type="text/javascript" charset="utf-8"> - $.fn.dataTable.ext.order['dom-checkbox'] = function ( settings, col ) - { - return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) { - return $('input', td).prop('checked') ? '1' : '0'; - } ); - }; - - $.fn.dataTable.ext.order['dom-inner-text'] = function ( settings, col ) - { - return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) { - return $(td).text(); - } ); - } - $(document).ready( function () { $('#trait_table tr').click(function(event) { @@ -252,7 +238,7 @@ 'sDom': "pitirp", 'autoWidth': true, 'iDisplayLength': 500, - 'deferRender': true, + 'deferRender': false, 'paging': true, 'orderClasses': true, 'processing': true, diff --git a/wqflask/wqflask/templates/gsearch_pheno.html b/wqflask/wqflask/templates/gsearch_pheno.html index eb998d15..c44231f3 100644 --- a/wqflask/wqflask/templates/gsearch_pheno.html +++ b/wqflask/wqflask/templates/gsearch_pheno.html @@ -59,20 +59,6 @@ </script> <script type="text/javascript" charset="utf-8"> - $.fn.dataTable.ext.order['dom-checkbox'] = function ( settings, col ) - { - return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) { - return $('input', td).prop('checked') ? '1' : '0'; - } ); - }; - - $.fn.dataTable.ext.order['dom-inner-text'] = function ( settings, col ) - { - return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) { - return $(td).text(); - } ); - } - $(document).ready( function () { $('#trait_table tr').click(function(event) { @@ -172,6 +158,7 @@ 'title': "Record", 'type': "natural", 'data': null, + 'orderDataType': "dom-inner-text", 'render': function(data, type, row, meta) { return '<a target="_blank" href="/show_trait?trait_id=' + data.name + '&dataset=' + data.dataset + '">' + data.display_name + '</a>' } @@ -252,7 +239,7 @@ 'order': [[1, "asc" ]], 'sDom': "pitirp", 'autoWidth': false, - 'deferRender': true, + 'deferRender': false, 'iDisplayLength': 500, 'paging': true, 'orderClasses': true, diff --git a/wqflask/wqflask/templates/index_page_orig.html b/wqflask/wqflask/templates/index_page_orig.html index 06b71f53..6b3bec9a 100755 --- a/wqflask/wqflask/templates/index_page_orig.html +++ b/wqflask/wqflask/templates/index_page_orig.html @@ -17,13 +17,13 @@ </header> --> - <div class="container-fluid" style="min-width: 1200px;"> + <div class="container-fluid" style="min-width: 1210px;"> {{ flash_me() }} <div class="row" style="width: 100%;"> - <div class="col-xs-5" style="min-width: 530px; max-width: 550px;"> + <div class="col-xs-4" style="margin-right:50px; min-width: 530px; max-width: 550px;"> <section id="search"> <div> <h1>Select and search</h1> @@ -84,7 +84,7 @@ <label for="or_search" class="col-xs-1 control-label" style="padding-left: 0px; padding-right: 0px; width: 65px !important;">Get Any:</label> <div class="col-xs-10 controls" style="padding-left: 20px;"> <div class="col-8"> - <textarea onkeydown="pressed(event)" name="search_terms_or" rows="1" class="form-control search-query" style="max-width: 550px; width: 450px !important;" id="or_search"></textarea> + <textarea onkeydown="pressed(event)" name="search_terms_or" rows="1" class="form-control search-query" style="resize: vertical; max-width: 550px; width: 450px !important;" id="or_search"></textarea> </div> </div> </div> @@ -105,7 +105,7 @@ <label for="and_search" class="col-xs-1 control-label" style="padding-left: 0px; padding-right: 0px; width: 65px !important;">Combined:</label> <div class="col-xs-10 controls" style="padding-left: 20px;"> <div class="col-8"> - <textarea onkeydown="pressed(event)" name="search_terms_and" rows="1" class="form-control search-query" style="max-width: 550px; width: 450px !important;" id="and_search"></textarea> + <textarea onkeydown="pressed(event)" name="search_terms_and" rows="1" class="form-control search-query" style="resize: vertical; max-width: 550px; width: 450px !important;" id="and_search"></textarea> </div> </div> </div> @@ -184,7 +184,7 @@ </section> </div> - <div style="padding-left:80px" class="col-xs-4" style="width: 600px !important;"> + <div class="col-xs-4" style="width: 600px !important;"> <section id="affiliates"> <div class="page-header"> <h1>Affiliates</h1> diff --git a/wqflask/wqflask/templates/info_page.html b/wqflask/wqflask/templates/info_page.html new file mode 100644 index 00000000..d8b7d74c --- /dev/null +++ b/wqflask/wqflask/templates/info_page.html @@ -0,0 +1,92 @@ +{% extends "base.html" %}
+{% block title %}Policies{% endblock %}
+{% block content %}
+
+<h1 id="parent-fieldname-title">Data Set Group: {{ info.dataset_name }}
+<!--<a href="/infoshare/manager/member-studies-edit.html?DatasetId=%s"><img src="/images/modify.gif" alt="modify this page" border="0" valign="middle"></a>-->
+<span style="color:red;">{{ info.info_page_name }}</span>
+</h1>
+<table border="0" width="100%">
+<tr>
+<td valign="top" width="50%">
+<table name="info_table" cellSpacing=0 cellPadding=5 width=100% border=0>
+ <tr><td><b>Data Set:</b> {{ info.info_file_title }} <!--<a href="/infoshare/manager/member-infofile-edit.html?GN_AccesionId=%s"><img src="/images/modify.gif" alt="modify this page" border="0" valign="middle"></a>--></td></tr>
+ <tr><td><b>GN Accession:</b> GN{{ gn_accession_id }}</td></tr>
+ <tr><td><b>GEO Series:</b> <a href="http://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc={{ info.geo_series }}" target="_blank">{{ info.geo_series }}</a></td></tr>
+ <tr><td><b>Title:</b> {{ info.publication_title }}</td></tr>
+ <tr><td><b>Organism:</b> <a href="http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?mode=Info&id={{ info.taxonomy_id }}" target="_blank">{{ info.menu_name }}</a></td></tr>
+ <tr><td><b>Group:</b> {{ info.group_name }}</td></tr>
+ <tr><td><b>Tissue:</b> {{ info.tissue_name }}</td></tr>
+ <tr><td><b>Dataset Status:</b> {{ info.dataset_status_name }}</td></tr>
+ <tr><td><b>Platforms:</b> <a href="http://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc={{ info.geo_platform }}" target="_blank">{{ info.gene_chip_name }}</a></td></tr>
+ <tr><td><b>Normalization:</b> {{ info.avg_method_name }}</td></tr>
+</table>
+</td>
+<td valign="top" width="50%">
+<table border="0" width="100%">
+ <tr>
+ <td><b>Contact Information</b></td>
+ </tr>
+ <tr>
+ <td>
+ {{ info.investigator_first_name }} {{ info.inveestigator_last_name }}<br>
+ {{ info.organization_name }} <br>
+ {{ info.investigator_address }}<br>
+ {{ info.investigator_city }}, {{ info.investigator_state }} {{ info.investigator_zipcode }} {{ info.investigator_country }}<br>
+ Tel. {{ info.investigator_phone }}<br>
+ {{ info.investigator_email }}<br>
+ <a href="{{ info.investigator_url }}" target="_blank">Website</a>
+ </td>
+ </tr>
+
+<tr>
+ <td><b>Download datasets and supplementary data files</b></td>
+</tr>
+<tr>
+ <td>
+ <ul style="line-height: 160%">
+ {% for file in filelist %}
+ <li><a href="http://datafiles.genenetwork.org/download/GN{{ gn_accession_id }}/{{ file[0] }}">{{ file[0] }} ({{ file[2] }})</a></li>
+ {% endfor %}
+ </ul>
+ </td>
+</tr>
+
+<tr><td>
+</td></tr>
+
+</table>
+</td>
+</tr>
+</table>
+<HR>
+<p>
+<table name="info_table" width="100%" border="0" cellpadding="5" cellspacing="0">
+<tr><td><span style="font-size:115%%;font-weight:bold;">Specifics of this Data Set:</span></td></tr>
+ <tr><td> {{ info.specifics|safe }}<br><br></td></tr>
+<tr><td><span style="font-size:115%%;font-weight:bold;">Summary:</span></td></tr>
+ <tr><td> {{ info.dataset_summary|safe }}<br><br></td></tr>
+<tr><td><span style="font-size:115%; font-weight:bold;">About the cases used to generate this set of data:</span></td></tr>
+ <tr><td> {{ info.about_cases|safe }}<br><br></td></tr>
+<tr><td><span style="font-size:115%; font-weight:bold;">About the tissue used to generate this set of data:</span></td></tr>
+ <tr><td> {{ info.about_tissue|safe }}<br><br></td></tr>
+ <tr><td><span style="font-size:115%; font-weight:bold;">About the array platform:</span></td></tr>
+ <tr><td> {{ info.about_platform|safe }}<br><br></td></tr>
+<tr><td><span style="font-size:115%; font-weight:bold;">About data values and data processing:</span></td></tr>
+ <tr><td> {{ info.about_data_processing|safe }}<br><br></td></tr>
+<tr><td><span style="font-size:115%; font-weight:bold;">Notes:</span></td></tr>
+ <tr><td> {{ info.notes|safe }}<br><br></td></tr>
+<tr><td><span style="font-size:115%; font-weight:bold;">Experiment Type:</span></td></tr>
+ <tr><td> {{ info.experiment_design|safe }}<br><br></td></tr>
+<tr><td><span style="font-size:115%; font-weight:bold;">Contributor:</span></td></tr>
+ <tr><td> {{ info.contributors|safe }}<br><br></td></tr>
+<tr><td><span style="font-size:115%; font-weight:bold;">Citation:</span></td></tr>
+ <tr><td> {{ info.citation|safe }}<br><br></td></tr>
+<tr><td><span style="font-size:115%; font-weight:bold;">Data source acknowledgment:</span></td></tr>
+ <tr><td> {{ info.acknowledgement|safe }}<br><br></td></tr>
+<tr><td><span style="font-size:115%; font-weight:bold;">Study Id:</span></td></tr>
+ <tr><td> {{ info.dataset_id }}<br><br></td></tr>
+</table>
+</p>
+
+{% endblock %}
\ No newline at end of file diff --git a/wqflask/wqflask/templates/mapping_results.html b/wqflask/wqflask/templates/mapping_results.html index 8edda548..41d760c0 100644 --- a/wqflask/wqflask/templates/mapping_results.html +++ b/wqflask/wqflask/templates/mapping_results.html @@ -228,71 +228,61 @@ <button class="btn btn-success" id="add" disabled><span class="glyphicon glyphicon-plus-sign"></span> Add</button> <br /> <br /> - <div id="table_container" style="width:{% if 'additive' in trimmed_markers[0] %}500{% else %}470{% endif %}px;"> - <table id="trait_table" class="table-hover table-striped cell-border dataTable no-footer"> - <thead> - <tr> - <th></th> - <th>Row</th> - <th>Marker</th> - <th>{{ LRS_LOD }}</th> - <th>Chr</th> - {% if plotScale != "physic" %} - <th>cM</th> - {% else %} - <th align="right">Mb</th> - {% endif %} - {% if 'additive' in trimmed_markers[0] %} - <th>Add Eff</th> - {% endif %} - {% if 'dominance' in trimmed_markers[0] and dataset.group.genetic_type != "riset" %} - <th>Dom Eff</th> - {% endif %} - </tr> - </thead> - <tbody> - {% for marker in trimmed_markers %} - <tr> - <td align="center" style="padding: 1px 0px 1px 0px;"> - <input type="checkbox" name="selectCheck" - class="checkbox trait_checkbox" - value="{{ data_hmac('{}:{}Geno'.format(marker.name, dataset.group.name)) }}"> - </td> - <td align="right">{{ loop.index }}</td> - <td>{% if geno_db_exists == "True" %}<a href="/show_trait?trait_id={{ marker.name }}&dataset={{ dataset.group.name }}Geno">{{ marker.name }}</a>{% else %}{{ marker.name }}{% endif %}</td> - {% if LRS_LOD == "LOD" or LRS_LOD == "-log(p)" %} - {% if 'lod_score' in marker %} - <td align="right">{{ '%0.2f' | format(marker.lod_score|float) }}</td> - {% else %} - <td align="right">{{ '%0.2f' | format(marker.lrs_value|float / 4.61) }}</td> - {% endif %} - {% else %} - {% if 'lod_score' in marker %} - <td align="right">{{ '%0.2f' | format(marker.lod_score|float * 4.61) }}</td> - {% else %} - <td align="right">{{ '%0.2f' | format(marker.lrs_value|float) }}</td> - {% endif %} - {% endif %} - <td align="right">{{marker.chr}}</td> - {% if plotScale != "physic" %} - {% if 'cM' in marker %} - <td align="right">{{ '%0.3f' | format(marker.cM|float) }}</td> - {% else %} - <td align="right">{{ '%0.3f' | format(marker.Mb|float) }}</td> - {% endif %} - {% else %} - <td align="right">{{ '%0.6f' | format(marker.Mb|float) }}</td> - {% endif %} - {% if 'additive' in marker %} - <td align="right">{{ '%0.3f' | format(marker.additive|float) }}</td> - {% endif %} - {% if 'dominance' in marker and dataset.group.genetic_type != "riset" %} - <td align="right">{{ '%0.2f' | format(marker.dominance|float) }}</td> - {% endif %} - </tr> - {% endfor %} - </tbody> - </table> + <div id="table_container" style="width:{% if 'additive' in trimmed_markers[0] %}600{% else %}550{% endif %}px;"> + <table id="trait_table" class="table-hover table-striped cell-border dataTable no-footer"> + <thead> + <tr> + <th></th> + <th>Row</th> + <th>Marker</th> + {% if LRS_LOD == "-log(p)" %} + <th>–log(p)</th> + {% else %} + <th>{{ LRS_LOD }}</th> + {% endif %} + <th>Position ({% if plotScale == "physic" %}Mb{% else %}cM{% endif %})</th> + {% if 'additive' in trimmed_markers[0] %} + <th>Add Eff</th> + {% endif %} + {% if 'dominance' in trimmed_markers[0] and dataset.group.genetic_type != "riset" %} + <th>Dom Eff</th> + {% endif %} + </tr> + </thead> + <tbody> + {% for marker in trimmed_markers %} + <tr> + <td align="center" style="padding: 1px 0px 1px 0px;"> + <input type="checkbox" name="selectCheck" + class="checkbox trait_checkbox" + value="{{ data_hmac('{}:{}Geno'.format(marker.name, dataset.group.name)) }}"> + </td> + <td align="right">{{ loop.index }}</td> + <td>{% if geno_db_exists == "True" %}<a href="/show_trait?trait_id={{ marker.name }}&dataset={{ dataset.group.name }}Geno">{{ marker.name }}</a>{% else %}{{ marker.name }}{% endif %}</td> + {% if LRS_LOD == "LOD" or LRS_LOD == "-log(p)" %} + {% if 'lod_score' in marker %} + <td align="right">{{ '%0.2f' | format(marker.lod_score|float) }}</td> + {% else %} + <td align="right">{{ '%0.2f' | format(marker.lrs_value|float / 4.61) }}</td> + {% endif %} + {% else %} + {% if 'lod_score' in marker %} + <td align="right">{{ '%0.2f' | format(marker.lod_score|float * 4.61) }}</td> + {% else %} + <td align="right">{{ '%0.2f' | format(marker.lrs_value|float) }}</td> + {% endif %} + {% endif %} + <td align="right">{{ marker.display_pos }}</td> + {% if 'additive' in marker %} + <td align="right">{{ '%0.3f' | format(marker.additive|float) }}</td> + {% endif %} + {% if 'dominance' in marker and dataset.group.genetic_type != "riset" %} + <td align="right">{{ '%0.2f' | format(marker.dominance|float) }}</td> + {% endif %} + </tr> + {% endfor %} + </tbody> + </table> </div> </div> {% elif selectedChr != -1 and plotScale =="physic" and (dataset.group.species == 'mouse' or dataset.group.species == 'rat') %} @@ -362,8 +352,7 @@ "columns": [ { "type": "natural", "width": "5%" }, { "type": "natural", "width": "8%" }, - { "type": "natural", "width": "25%" }, - { "type": "natural" }, + { "type": "natural", "width": "20%" }, { "type": "natural" }, { "type": "natural" }{% if 'additive' in qtlresults[0] %}, { "type": "natural" }{% endif %}{% if 'dominance' in qtlresults[0] and dataset.group.genetic_type != "riset" %}, @@ -395,16 +384,16 @@ $('td', row).eq(9).attr("align", "right"); }, "columns": [ - { "bSortable": false}, - { "type": "natural" }, - { "type": "natural" }, - { "type": "natural" }, - { "type": "natural" }, - { "type": "natural" }, - { "type": "natural" }, - { "type": "natural" }, + { "orderDataType": "dom-checkbox" }, + { "type": "natural"}, + { "type": "natural" , "orderDataType": "dom-inner-text" }, + { "type": "natural" , "orderDataType": "dom-inner-text" }, + { "type": "natural" , "orderDataType": "dom-inner-text" }, { "type": "natural" }, { "type": "natural" }, + { "type": "natural-minus-na" }, + { "type": "natural-minus-na" }, + { "type": "natural-minus-na" , "orderDataType": "dom-inner-text" }, { "type": "natural" } ], "columnDefs": [ { diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html index 53373b41..2318bfb8 100644 --- a/wqflask/wqflask/templates/search_result_page.html +++ b/wqflask/wqflask/templates/search_result_page.html @@ -127,7 +127,7 @@ <input type="hidden" name="export_data" id="export_data" value=""> <button class="btn btn-default" id="select_all" type="button"><span class="glyphicon glyphicon-ok"></span> Select</button> <button class="btn btn-success" id="add" type="button" disabled><span class="glyphicon glyphicon-plus-sign"></span> Add</button> - <button class="btn btn-default" id="export_traits">Download CSV</button> + <button class="btn btn-default" id="export_traits">Download <span class="glyphicon glyphicon-download"></span></button> <input type="text" id="searchbox" class="form-control" style="width: 200px; display: inline;" placeholder="Search This Table For ..."> <input type="text" id="select_top" class="form-control" style="width: 200px; display: inline;" placeholder="Select Top ..."> <button class="btn btn-default" id="deselect_all" type="button"><span class="glyphicon glyphicon-remove"></span> Deselect</button> @@ -140,7 +140,6 @@ <b>Show/Hide Columns:</b> </div> {% endif %} - <!--<div id="table_container" style="min-width: {% if dataset.type == 'ProbeSet' or dataset.type == 'Publish' %}2000{% else %}380{% endif %}px;">--> <div id="table_container" {% if dataset.type == 'ProbeSet' or dataset.type == 'Publish' %}style="min-width: 1500px;"{% endif %}> <table class="table-hover table-striped cell-border" id='trait_table' style="float: left; width: {% if dataset.type == 'Geno' %}380px{% else %}100%{% endif %};"> <tbody> @@ -174,21 +173,6 @@ </script> <script type="text/javascript" charset="utf-8"> - - $.fn.dataTable.ext.order['dom-checkbox'] = function ( settings, col ) - { - return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) { - return $('input', td).prop('checked') ? '1' : '0'; - } ); - }; - - $.fn.dataTable.ext.order['dom-inner-text'] = function ( settings, col ) - { - return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) { - return $(td).text(); - } ); - } - $(document).ready( function () { $('#trait_table tr').click(function(event) { @@ -289,10 +273,9 @@ }, { 'title': "Record", - 'type': "natural", + 'type': "natural-minus-na", 'data': null, 'width': "60px", - 'orderDataType': "dom-inner-text", 'render': function(data, type, row, meta) { return '<a target="_blank" href="/show_trait?trait_id=' + data.name + '&dataset=' + data.dataset + '">' + data.display_name + '</a>' } @@ -306,7 +289,6 @@ { 'title': "Description", 'type': "natural", - 'width': "500px", 'data': null, 'render': function(data, type, row, meta) { try { @@ -319,7 +301,7 @@ { 'title': "Location", 'type': "natural-minus-na", - 'width': "120px", + 'width': "125px", 'data': "location" }, { @@ -330,23 +312,23 @@ 'orderSequence': [ "desc", "asc"] }, { - 'title': "Max LRS<a href=\"http://genenetwork.org//glossary.html#LRS\" target=\"_blank\" style=\"color: white;\"><sup>?</sup></a>", + 'title': "High P<a href=\"http://genenetwork.org//glossary.html#LRS\" target=\"_blank\" style=\"color: white;\"><sup style=\"font-size: small; color: #FF0000;\"> ?</sup></a>", 'type': "natural-minus-na", 'data': "lrs_score", - 'width': "80px", + 'width': "60px", 'orderSequence': [ "desc", "asc"] }, { - 'title': "Max LRS Location", + 'title': "Peak Location", 'type': "natural-minus-na", - 'width': "150px", + 'width': "125px", 'data': "lrs_location" }, { - 'title': "Additive Effect<a href=\"http://genenetwork.org//glossary.html#A\" target=\"_blank\" style=\"color: white;\"><sup>?</sup></a>", + 'title': "Effect Size<a href=\"http://genenetwork.org//glossary.html#A\" target=\"_blank\" style=\"color: white;\"><sup style=\"font-size: small; color: #FF0000;\"> ?</sup></a>", 'type': "natural-minus-na", 'data': "additive", - 'width': "120px", + 'width': "85px", 'orderSequence': [ "desc", "asc"] }{% elif dataset.type == 'Publish' %}, { @@ -382,17 +364,11 @@ author_string = data.authors } return author_string - // try { - // return decodeURIComponent(escape(author_string)) - // } catch(err){ - // return author_string - // } } }, { 'title': "Year", 'type': "natural-minus-na", - 'orderDataType': "dom-inner-text", 'data': null, 'width': "80px", 'render': function(data, type, row, meta) { @@ -405,20 +381,20 @@ 'orderSequence': [ "desc", "asc"] }, { - 'title': "Max LRS<a href=\"http://genenetwork.org//glossary.html#LRS\" target=\"_blank\" style=\"color: white;\"><sup>?</sup></a>", + 'title': "Max LRS<a href=\"http://genenetwork.org//glossary.html#LRS\" target=\"_blank\" style=\"color: white;\"><sup style=\"font-size: small; color: #FF0000;\"> ?</sup></a>", 'type': "natural-minus-na", 'data': "lrs_score", 'width': "80px", 'orderSequence': [ "desc", "asc"] }, { - 'title': "Max LRS Location", + 'title': "Peak Location", 'type': "natural-minus-na", - 'width': "150px", + 'width': "120px", 'data': "lrs_location" }, { - 'title': "Additive Effect<a href=\"http://genenetwork.org//glossary.html#A\" target=\"_blank\" style=\"color: white;\"><sup>?</sup></a>", + 'title': "Effect Size<a href=\"http://genenetwork.org//glossary.html#A\" target=\"_blank\" style=\"color: white;\"><sup style=\"font-size: small; color: #FF0000;\"> ?</sup></a>", 'type': "natural-minus-na", 'width': "120px", 'data': "additive", @@ -427,7 +403,7 @@ { 'title': "Location", 'type': "natural-minus-na", - 'width': "140px", + 'width': "120px", 'data': "location" }{% endif %} ], diff --git a/wqflask/wqflask/templates/show_trait.html b/wqflask/wqflask/templates/show_trait.html index 2d65f008..5ed7a90b 100644 --- a/wqflask/wqflask/templates/show_trait.html +++ b/wqflask/wqflask/templates/show_trait.html @@ -37,7 +37,7 @@ <input type="hidden" name="covariates" value=""> <input type="hidden" name="transform" value=""> - <div class="container" style="min-width: 1450px;"> + <div class="container" style="min-width: 700px;"> <div class="panel-group" id="accordion"> <div class="panel panel-default"> <div class="panel-heading" data-toggle="collapse" data-parent="#accordion" data-target="#collapseOne" aria-expanded="true"> diff --git a/wqflask/wqflask/templates/show_trait_calculate_correlations.html b/wqflask/wqflask/templates/show_trait_calculate_correlations.html index 1378b91b..9420c9c6 100644 --- a/wqflask/wqflask/templates/show_trait_calculate_correlations.html +++ b/wqflask/wqflask/templates/show_trait_calculate_correlations.html @@ -1,5 +1,5 @@ <div> - <div class="col-xs-7"> + <div class="col-xs-6" style="min-width: 800px;"> <div style="padding: 20px" class="form-horizontal"> <div class="form-group"> @@ -39,7 +39,7 @@ <div class="form-group"> <label for="corr_return_results" class="col-xs-2 control-label">Return</label> - <div class="col-xs-3 controls"> + <div class="col-xs-4 controls"> <select name="corr_return_results" class="form-control"> {% for return_result in corr_tools.return_results_menu %} <option value="{{ return_result }}" @@ -55,7 +55,7 @@ <div class="form-group"> <label for="corr_samples_group" class="col-xs-2 control-label">Samples</label> - <div class="col-xs-3 controls"> + <div class="col-xs-4 controls"> <select name="corr_samples_group" class="form-control"> {% for group, pretty_group in sample_group_types.items() %} <option value="{{ group }}">{{ pretty_group }}</option> @@ -66,7 +66,7 @@ <div id="corr_sample_method" class="form-group"> <label for="corr_sample_method" class="col-xs-2 control-label">Type</label> - <div class="col-xs-3 controls"> + <div class="col-xs-4 controls"> <select name="corr_sample_method" class="form-control"> <option value="pearson">Pearson</option> <option value="spearman">Spearman Rank</option> @@ -77,7 +77,7 @@ {% if dataset.type != "Publish" %} <div class="form-group"> <label class="col-xs-2 control-label">Min Expr</label> - <div class="col-xs-3 controls"> + <div class="col-xs-4 controls"> <input name="min_expr" value="" type="text" class="form-control" style="width: 70px;"> </div> </div> @@ -114,7 +114,7 @@ </div> </div> </div> - <div class="col-xs-5"> + <div> <span id="sample_r_desc" class="correlation_desc fs12"> The <a href="http://genenetwork.org/correlationAnnotation.html#genetic_r">Sample Correlation</a> is computed diff --git a/wqflask/wqflask/templates/show_trait_details.html b/wqflask/wqflask/templates/show_trait_details.html index 8b3e4907..4aced50c 100644 --- a/wqflask/wqflask/templates/show_trait_details.html +++ b/wqflask/wqflask/templates/show_trait_details.html @@ -215,43 +215,27 @@ <div style="margin-bottom:15px;" class="btn-toolbar"> <div class="btn-group"> - <a href="#redirect"> - <button type="button" id="add_to_collection" class="btn btn-primary" title="Add to collection">Add</button> - </a> + <button type="button" id="add_to_collection" class="btn btn-success" title="Add to Collection">Add</button> {% if this_trait.dataset.type == 'ProbeSet' or this_trait.dataset.type == 'Geno' %} {% if this_trait.symbol != None %} - <a target="_blank" href="http://gn1.genenetwork.org/webqtl/main.py?cmd=sch&gene={{ this_trait.symbol }}&alias=1&species={{ dataset.group.species }}"> - <button type="button" class="btn btn-default" title="Find similar expression data">Find</button> - </a> + <button type="button" class="btn btn-default" title="Find similar expression data" onclick="window.open('http://gn1.genenetwork.org/webqtl/main.py?cmd=sch&gene={{ this_trait.symbol }}&alias=1&species={{ dataset.group.species }}', '_blank')">Find</button> {% endif %} {% if UCSC_BLAT_URL != "" %} - <a target="_blank" href="{{ UCSC_BLAT_URL }}"> - <button type="button" class="btn btn-default" title="Check probe locations at UCSC">Verify</button> - </a> + <button type="button" class="btn btn-default" title="Check probe locations at UCSC" onclick="window.open('{{ UCSC_BLAT_URL }}', '_blank')">Verify</button> {% endif %} {% if this_trait.symbol != None %} - <a target="_blank" href="http://gn1.genenetwork.org/webqtl/main.py?FormID=geneWiki&symbol={{ this_trait.symbol }}"> - <button type="button" class="btn btn-default" title="Write or review comments about this gene">GeneWiki</button> - </a> + <button type="button" class="btn btn-default" title="Write or review comments about this gene" onclick="window.open('http://gn1.genenetwork.org/webqtl/main.py?FormID=geneWiki&symbol={{ this_trait.symbol }}', '_blank')">GeneWiki</button> {% if dataset.group.species == "mouse" or dataset.group.species == "rat" %} - <a href="/snp_browser?first_run=true&species={{ dataset.group.species }}&gene_name={{ this_trait.symbol }}&limit_strains=on"> - <button type="button" class="btn btn-default" title="View SNPs and Indels">SNPs</button> - </a> + <button type="button" class="btn btn-default" title="View SNPs and Indels" onclick="window.open('/snp_browser?first_run=true&species={{ dataset.group.species }}&gene_name={{ this_trait.symbol }}&limit_strains=on', '_blank')">SNPs</button> {% endif %} {% endif %} {% if show_probes == "True" %} - <a target="_blank" href="http://gn1.genenetwork.org/webqtl/main.py?FormID=showProbeInfo&database={{ this_trait.dataset.name }}&ProbeSetID={{ this_trait.name }}&CellID={{ this_trait.cellid }}&RISet={{ dataset.group.name }}&incparentsf1=ON"> - <button type="button" class="btn btn-default" title="Check sequence of probes">Probes</button> - </a> + <button type="button" class="btn btn-default" title="Check sequence of probes" onclick="window.open('http://gn1.genenetwork.org/webqtl/main.py?FormID=showProbeInfo&database={{ this_trait.dataset.name }}&ProbeSetID={{ this_trait.name }}&CellID={{ this_trait.cellid }}&RISet={{ dataset.group.name }}&incparentsf1=ON', '_blank')">Probes</button> {% endif %} {% endif %} - <a target="_blank" href="http://gn1.genenetwork.org/webqtl/main.py?cmd=show&db={{ this_trait.dataset.name }}&probeset={{ this_trait.name }}"> - <button type="button" id="view_in_gn1" class="btn btn-primary" title="View Trait in GN1">View in GN1</button> - </a> + <button type="button" id="view_in_gn1" class="btn btn-primary" title="View Trait in GN1" onclick="window.open('http://gn1.genenetwork.org/webqtl/main.py?cmd=show&db={{ this_trait.dataset.name }}&probeset={{ this_trait.name }}', '_blank')">Go to GN1</button> {% if admin_status == "owner" or admin_status == "edit-admins" or admin_status == "edit-access" %} - <a target="_blank" href="./resources/manage?resource_id={{ resource_id }}"> - <button type="button" id="edit_resource" class="btn btn-success" title="Edit Resource">Edit</button> - </a> + <button type="button" id="edit_resource" class="btn btn-success" title="Edit Resource" onclick="window.open('./resources/manage?resource_id={{ resource_id }}', '_blank')">Edit</button> {% endif %} </div> </div> diff --git a/wqflask/wqflask/templates/show_trait_edit_data.html b/wqflask/wqflask/templates/show_trait_edit_data.html index 05a2be73..a8ed91b1 100644 --- a/wqflask/wqflask/templates/show_trait_edit_data.html +++ b/wqflask/wqflask/templates/show_trait_edit_data.html @@ -5,7 +5,7 @@ <input type="text" id="{{ sample_type.sample_group_type }}_searchbox" class="form-control" style="width: 200px; display: inline; float: left; vertical-align: top;" placeholder="Search This Table For ..."> </div> <div style="padding-left: 10px; display: inline;"> - <input type="button" class="btn btn-default export" value="Export"> + <button class="btn btn-default export">Export <span class="glyphicon glyphicon-download-alt"></span></button> <select class="select optional span2 export_format"> <option value="excel">Excel</option> <option value="csv">CSV</option> diff --git a/wqflask/wqflask/templates/show_trait_mapping_tools.html b/wqflask/wqflask/templates/show_trait_mapping_tools.html index 27040045..94388b2f 100755 --- a/wqflask/wqflask/templates/show_trait_mapping_tools.html +++ b/wqflask/wqflask/templates/show_trait_mapping_tools.html @@ -397,8 +397,8 @@ </div> </div> </div> - <div class="col-xs-7"> - <dl style="width: 500px;"> + <div> + <dl> {% for mapping_method in dataset.group.mapping_names %} {% if mapping_method == "GEMMA" %} <dt style="padding-top: 20px;">GEMMA</dt> diff --git a/wqflask/wqflask/templates/show_trait_statistics.html b/wqflask/wqflask/templates/show_trait_statistics.html index 974081d3..7bdb3ef9 100644 --- a/wqflask/wqflask/templates/show_trait_statistics.html +++ b/wqflask/wqflask/templates/show_trait_statistics.html @@ -76,11 +76,13 @@ <i class="icon-signal"></i> Sort By Value </button> </div> + <!-- <div class="btn-group"> - <button type="button" class="btn btn-default" id="color_by_trait"> + <button type="button" class="btn btn-default" id="color_by_trait" style="margin-bottom: 5px;"> <i class="icon-tint"></i> Color by Trait </button> </div> + --> <div id="bar_chart_container"> <div id="bar_chart"></div> </div> diff --git a/wqflask/wqflask/templates/tutorials.html b/wqflask/wqflask/templates/tutorials.html index 3e6ef01c..f9d12ba5 100644 --- a/wqflask/wqflask/templates/tutorials.html +++ b/wqflask/wqflask/templates/tutorials.html @@ -15,3 +15,4 @@ and initial mapping results for Rat GWAS P50 as implemented in GeneNetwork.org</ </TR></TABLE> {% endblock %} + diff --git a/wqflask/wqflask/user_login.py b/wqflask/wqflask/user_login.py index 9331f369..077a799b 100644 --- a/wqflask/wqflask/user_login.py +++ b/wqflask/wqflask/user_login.py @@ -453,7 +453,9 @@ def register_user(params): user_details['confirmed'] = 1 user_details['registration_info'] = basic_info() - save_user(user_details, user_details['user_id']) + + if len(errors) == 0: + save_user(user_details, user_details['user_id']) return errors diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index fc9949a8..94ec7137 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -29,14 +29,7 @@ import array import sqlalchemy from wqflask import app from flask import g, Response, request, make_response, render_template, send_from_directory, jsonify, redirect, url_for, send_file -from wqflask import group_manager -from wqflask import resource_manager -from wqflask import search_results -from wqflask import export_traits -from wqflask import gsearch -from wqflask import update_search_results -from wqflask import docs -from wqflask import news + from wqflask.submit_bnw import get_bnw_input from base.data_set import create_dataset, DataSet # Used by YAML in marker_regression from wqflask.show_trait import show_trait @@ -53,6 +46,12 @@ from wqflask.correlation import corr_scatter_plot from wqflask.wgcna import wgcna_analysis from wqflask.ctl import ctl_analysis from wqflask.snp_browser import snp_browser +from wqflask.search_results import SearchResultPage +from wqflask.export_traits import export_search_results_csv +from wqflask.gsearch import GSearch +from wqflask.update_search_results import GSearch as UpdateGSearch +from wqflask.docs import Docs, update_text +from wqflask.db_info import InfoPage from utility import temp_data from utility.tools import SQL_URI,TEMPDIR,USE_REDIS,USE_GN_SERVER,GN_SERVER_URL,GN_VERSION,JS_TWITTER_POST_FETCHER_PATH,JS_GUIX_PATH, CSS_PATH @@ -66,9 +65,6 @@ from utility.benchmark import Bench from pprint import pformat as pf -from wqflask import user_login -from wqflask import user_session - from wqflask import collect from wqflask.database import db_session @@ -215,7 +211,7 @@ def search_page(): logger.info("Skipping Redis cache (USE_REDIS=False)") logger.info("request.args is", request.args) - the_search = search_results.SearchResultPage(request.args) + the_search = SearchResultPage(request.args) result = the_search.__dict__ valid_search = result['search_term_exists'] @@ -233,7 +229,7 @@ def search_page(): @app.route("/gsearch", methods=('GET',)) def gsearchact(): logger.info(request.url) - result = gsearch.GSearch(request.args).__dict__ + result = GSearch(request.args).__dict__ type = request.args['type'] if type == "gene": return render_template("gsearch_gene.html", **result) @@ -244,7 +240,7 @@ def gsearchact(): def gsearch_updating(): logger.info("REQUEST ARGS:", request.values) logger.info(request.url) - result = update_search_results.GSearch(request.args).__dict__ + result = UpdateGSearch(request.args).__dict__ return result['results'] # type = request.args['type'] # if type == "gene": @@ -257,7 +253,7 @@ def docedit(): logger.info(request.url) try: if g.user_session.record['user_email_address'] == "zachary.a.sloan@gmail.com" or g.user_session.record['user_email_address'] == "labwilliams@gmail.com": - doc = docs.Docs(request.args['entry'], request.args) + doc = Docs(request.args['entry'], request.args) return render_template("docedit.html", **doc.__dict__) else: return "You shouldn't be here!" @@ -273,7 +269,7 @@ def generated_file(filename): @app.route("/help") def help(): logger.info(request.url) - doc = docs.Docs("help", request.args) + doc = Docs("help", request.args) return render_template("docs.html", **doc.__dict__) @app.route("/wgcna_setup", methods=('POST',)) @@ -308,54 +304,54 @@ def ctl_results(): @app.route("/news") def news(): - doc = docs.Docs("news", request.args) + doc = Docs("news", request.args) return render_template("docs.html", **doc.__dict__) @app.route("/references") def references(): - doc = docs.Docs("references", request.args) + doc = Docs("references", request.args) return render_template("docs.html", **doc.__dict__) #return render_template("reference.html") @app.route("/intro") def intro(): - doc = docs.Docs("intro", request.args) + doc = Docs("intro", request.args) return render_template("docs.html", **doc.__dict__) @app.route("/policies") def policies(): - doc = docs.Docs("policies", request.args) + doc = Docs("policies", request.args) #return render_template("policies.html") return render_template("docs.html", **doc.__dict__) @app.route("/links") def links(): - #doc = docs.Docs("links", request.args) + #doc = Docs("links", request.args) #return render_template("docs.html", **doc.__dict__) return render_template("links.html") @app.route("/tutorials") def tutorials(): - #doc = docs.Docs("links", request.args) + #doc = Docs("links", request.args) #return render_template("docs.html", **doc.__dict__) return render_template("tutorials.html") @app.route("/credits") def credits(): - #doc = docs.Docs("links", request.args) + #doc = Docs("links", request.args) #return render_template("docs.html", **doc.__dict__) return render_template("credits.html") @app.route("/environments") def environments(): - doc = docs.Docs("environments", request.args) + doc = Docs("environments", request.args) return render_template("docs.html", **doc.__dict__) #return render_template("environments.html", **doc.__dict__) @app.route("/update_text", methods=('POST',)) def update_page(): - docs.update_text(request.form) - doc = docs.Docs(request.form['entry_type'], request.form) + update_text(request.form) + doc = Docs(request.form['entry_type'], request.form) return render_template("docs.html", **doc.__dict__) @app.route("/submit_trait") @@ -370,7 +366,7 @@ def create_temp_trait(): #template_vars = submit_trait.SubmitTrait(request.form) - doc = docs.Docs("links") + doc = Docs("links") return render_template("links.html", **doc.__dict__) #return render_template("show_trait.html", **template_vars.__dict__) @@ -425,7 +421,7 @@ def export_traits_csv(): logger.info("In export_traits_csv") logger.info("request.form:", request.form) logger.info(request.url) - file_list = export_traits.export_search_results_csv(request.form) + file_list = export_search_results_csv(request.form) if len(file_list) > 1: now = datetime.datetime.now() @@ -908,12 +904,24 @@ def snp_browser_page(): return render_template("snp_browser.html", **template_vars.__dict__) +@app.route("/db_info", methods=('GET',)) +def db_info_page(): + template_vars = InfoPage(request.args) + + return render_template("info_page.html", **template_vars.__dict__) + @app.route("/tutorial/WebQTLTour", methods=('GET',)) def tutorial_page(): #ZS: Currently just links to GN1 logger.info(request.url) return redirect("http://gn1.genenetwork.org/tutorial/WebQTLTour/") +@app.route("/tutorial/security", methods=('GET',)) +def security_tutorial_page(): + #ZS: Currently just links to GN1 + logger.info(request.url) + return render_template("admin/security_help.html") + @app.route("/submit_bnw", methods=('POST',)) def submit_bnw(): logger.info(request.url) diff --git a/wqflask/wqflask/wgcna/wgcna_analysis.py b/wqflask/wqflask/wgcna/wgcna_analysis.py index 880a1cb2..70077703 100644 --- a/wqflask/wqflask/wgcna/wgcna_analysis.py +++ b/wqflask/wqflask/wgcna/wgcna_analysis.py @@ -1,5 +1,8 @@ -# WGCNA analysis for GN2 -# Author / Maintainer: Danny Arends <Danny.Arends@gmail.com> +""" +WGCNA analysis for GN2 + +Author / Maintainer: Danny Arends <Danny.Arends@gmail.com> +""" import sys from numpy import * import scipy as sp # SciPy @@ -17,106 +20,138 @@ from utility import helper_functions from rpy2.robjects.packages import importr utils = importr("utils") -## Get pointers to some common R functions -r_library = ro.r["library"] # Map the library function -r_options = ro.r["options"] # Map the options function -r_read_csv = ro.r["read.csv"] # Map the read.csv function -r_dim = ro.r["dim"] # Map the dim function -r_c = ro.r["c"] # Map the c function -r_cat = ro.r["cat"] # Map the cat function -r_paste = ro.r["paste"] # Map the paste function -r_unlist = ro.r["unlist"] # Map the unlist function -r_unique = ro.r["unique"] # Map the unique function -r_length = ro.r["length"] # Map the length function -r_unlist = ro.r["unlist"] # Map the unlist function -r_list = ro.r.list # Map the list function -r_matrix = ro.r.matrix # Map the matrix function -r_seq = ro.r["seq"] # Map the seq function -r_table = ro.r["table"] # Map the table function -r_names = ro.r["names"] # Map the names function -r_sink = ro.r["sink"] # Map the sink function -r_is_NA = ro.r["is.na"] # Map the is.na function -r_file = ro.r["file"] # Map the file function -r_png = ro.r["png"] # Map the png function for plotting -r_dev_off = ro.r["dev.off"] # Map the dev.off function +# Get pointers to some common R functions +r_library = ro.r["library"] # Map the library function +r_options = ro.r["options"] # Map the options function +r_read_csv = ro.r["read.csv"] # Map the read.csv function +r_dim = ro.r["dim"] # Map the dim function +r_c = ro.r["c"] # Map the c function +r_cat = ro.r["cat"] # Map the cat function +r_paste = ro.r["paste"] # Map the paste function +r_unlist = ro.r["unlist"] # Map the unlist function +r_unique = ro.r["unique"] # Map the unique function +r_length = ro.r["length"] # Map the length function +r_unlist = ro.r["unlist"] # Map the unlist function +r_list = ro.r.list # Map the list function +r_matrix = ro.r.matrix # Map the matrix function +r_seq = ro.r["seq"] # Map the seq function +r_table = ro.r["table"] # Map the table function +r_names = ro.r["names"] # Map the names function +r_sink = ro.r["sink"] # Map the sink function +r_is_NA = ro.r["is.na"] # Map the is.na function +r_file = ro.r["file"] # Map the file function +r_png = ro.r["png"] # Map the png function for plotting +r_dev_off = ro.r["dev.off"] # Map the dev.off function + class WGCNA(object): def __init__(self): + # To log output from stdout/stderr to a file add `r_sink(log)` print("Initialization of WGCNA") - #log = r_file("/tmp/genenetwork_wcgna.log", open = "wt") - #r_sink(log) # Uncomment the r_sink() commands to log output from stdout/stderr to a file - #r_sink(log, type = "message") - r_library("WGCNA") # Load WGCNA - Should only be done once, since it is quite expensive - r_options(stringsAsFactors = False) + + # Load WGCNA - Should only be done once, since it is quite expensive + r_library("WGCNA") + r_options(stringsAsFactors=False) print("Initialization of WGCNA done, package loaded in R session") - self.r_enableWGCNAThreads = ro.r["enableWGCNAThreads"] # Map the enableWGCNAThreads function - self.r_pickSoftThreshold = ro.r["pickSoftThreshold"] # Map the pickSoftThreshold function - self.r_blockwiseModules = ro.r["blockwiseModules"] # Map the blockwiseModules function - self.r_labels2colors = ro.r["labels2colors"] # Map the labels2colors function - self.r_plotDendroAndColors = ro.r["plotDendroAndColors"] # Map the plotDendroAndColors function + # Map the enableWGCNAThreads function + self.r_enableWGCNAThreads = ro.r["enableWGCNAThreads"] + # Map the pickSoftThreshold function + self.r_pickSoftThreshold = ro.r["pickSoftThreshold"] + # Map the blockwiseModules function + self.r_blockwiseModules = ro.r["blockwiseModules"] + # Map the labels2colors function + self.r_labels2colors = ro.r["labels2colors"] + # Map the plotDendroAndColors function + self.r_plotDendroAndColors = ro.r["plotDendroAndColors"] print("Obtained pointers to WGCNA functions") def run_analysis(self, requestform): print("Starting WGCNA analysis on dataset") - self.r_enableWGCNAThreads() # Enable multi threading - self.trait_db_list = [trait.strip() for trait in requestform['trait_list'].split(',')] - print("Retrieved phenotype data from database", requestform['trait_list']) + # Enable multi threading + self.r_enableWGCNAThreads() + self.trait_db_list = [trait.strip() + for trait in requestform['trait_list'].split(',')] + print("Retrieved phenotype data from database", + requestform['trait_list']) helper_functions.get_trait_db_obs(self, self.trait_db_list) - self.input = {} # self.input contains the phenotype values we need to send to R - strains = [] # All the strains we have data for (contains duplicates) - traits = [] # All the traits we have data for (should not contain duplicates) + # self.input contains the phenotype values we need to send to R + self.input = {} + # All the strains we have data for (contains duplicates) + strains = [] + # All the traits we have data for (should not contain duplicates) + traits = [] for trait in self.trait_list: traits.append(trait[0].name) self.input[trait[0].name] = {} for strain in trait[0].data: strains.append(strain) - self.input[trait[0].name][strain] = trait[0].data[strain].value + self.input[trait[0].name][strain] = trait[0].data[strain].value # Transfer the load data from python to R - uStrainsR = r_unique(ro.Vector(strains)) # Unique strains in R vector + # Unique strains in R vector + uStrainsR = r_unique(ro.Vector(strains)) uTraitsR = r_unique(ro.Vector(traits)) # Unique traits in R vector r_cat("The number of unique strains:", r_length(uStrainsR), "\n") r_cat("The number of unique traits:", r_length(uTraitsR), "\n") - # rM is the datamatrix holding all the data in R /rows = strains columns = traits - rM = ro.r.matrix(ri.NA_Real, nrow=r_length(uStrainsR), ncol=r_length(uTraitsR), dimnames = r_list(uStrainsR, uTraitsR)) + # rM is the datamatrix holding all the data in + # R /rows = strains columns = traits + rM = ro.r.matrix(ri.NA_Real, nrow=r_length(uStrainsR), ncol=r_length( + uTraitsR), dimnames=r_list(uStrainsR, uTraitsR)) for t in uTraitsR: - trait = t[0] # R uses vectors every single element is a vector + # R uses vectors every single element is a vector + trait = t[0] for s in uStrainsR: - strain = s[0] # R uses vectors every single element is a vector - #DEBUG: print(trait, strain, " in python: ", self.input[trait].get(strain), "in R:", rM.rx(strain,trait)[0]) - rM.rx[strain, trait] = self.input[trait].get(strain) # Update the matrix location + # R uses vectors every single element is a vector + strain = s[0] + rM.rx[strain, trait] = self.input[trait].get( + strain) # Update the matrix location sys.stdout.flush() self.results = {} - self.results['nphe'] = r_length(uTraitsR)[0] # Number of phenotypes/traits - self.results['nstr'] = r_length(uStrainsR)[0] # Number of strains + # Number of phenotypes/traits + self.results['nphe'] = r_length(uTraitsR)[0] + self.results['nstr'] = r_length( + uStrainsR)[0] # Number of strains self.results['phenotypes'] = uTraitsR # Traits used - self.results['strains'] = uStrainsR # Strains used in the analysis - self.results['requestform'] = requestform # Store the user specified parameters for the output page + # Strains used in the analysis + self.results['strains'] = uStrainsR + # Store the user specified parameters for the output page + self.results['requestform'] = requestform - # Calculate soft threshold if the user specified the SoftThreshold variable + # Calculate soft threshold if the user specified the + # SoftThreshold variable if requestform.get('SoftThresholds') is not None: - powers = [int(threshold.strip()) for threshold in requestform['SoftThresholds'].rstrip().split(",")] - rpow = r_unlist(r_c(powers)) - print "SoftThresholds: {} == {}".format(powers, rpow) - self.sft = self.r_pickSoftThreshold(rM, powerVector = rpow, verbose = 5) - - print "PowerEstimate: {}".format(self.sft[0]) - self.results['PowerEstimate'] = self.sft[0] - if self.sft[0][0] is ri.NA_Integer: - print "No power is suitable for the analysis, just use 1" - self.results['Power'] = 1 # No power could be estimated - else: - self.results['Power'] = self.sft[0][0] # Use the estimated power + powers = [int(threshold.strip()) + for threshold in requestform['SoftThresholds'].rstrip().split(",")] + rpow = r_unlist(r_c(powers)) + print("SoftThresholds: {} == {}".format(powers, rpow)) + self.sft = self.r_pickSoftThreshold( + rM, powerVector=rpow, verbose=5) + + print("PowerEstimate: {}".format(self.sft[0])) + self.results['PowerEstimate'] = self.sft[0] + if self.sft[0][0] is ri.NA_Integer: + print "No power is suitable for the analysis, just use 1" + # No power could be estimated + self.results['Power'] = 1 + else: + # Use the estimated power + self.results['Power'] = self.sft[0][0] else: - # The user clicked a button, so no soft threshold selection - self.results['Power'] = requestform.get('Power') # Use the power value the user gives + # The user clicked a button, so no soft threshold selection + # Use the power value the user gives + self.results['Power'] = requestform.get('Power') # Create the block wise modules using WGCNA - network = self.r_blockwiseModules(rM, power = self.results['Power'], TOMType = requestform['TOMtype'], minModuleSize = requestform['MinModuleSize'], verbose = 3) + network = self.r_blockwiseModules( + rM, + power=self.results['Power'], + TOMType=requestform['TOMtype'], + minModuleSize=requestform['MinModuleSize'], + verbose=3) # Save the network for the GUI self.results['network'] = network @@ -130,7 +165,9 @@ class WGCNA(object): self.results['imgloc'] = GENERATED_IMAGE_DIR + self.results['imgurl'] r_png(self.results['imgloc'], width=1000, height=600, type='cairo-png') mergedColors = self.r_labels2colors(network[1]) - self.r_plotDendroAndColors(network[5][0], mergedColors, "Module colors", dendroLabels = False, hang = 0.03, addGuide = True, guideHang = 0.05) + self.r_plotDendroAndColors(network[5][0], mergedColors, + "Module colors", dendroLabels=False, + hang=0.03, addGuide=True, guideHang=0.05) r_dev_off() sys.stdout.flush() @@ -146,11 +183,9 @@ class WGCNA(object): print("Processing WGCNA output") template_vars = {} template_vars["input"] = self.input - template_vars["powers"] = self.sft[1:] # Results from the soft threshold analysis + # Results from the soft threshold analysis + template_vars["powers"] = self.sft[1:] template_vars["results"] = self.results self.render_image(results) sys.stdout.flush() - #r_sink(type = "message") # This restores R output to the stdout/stderr - #r_sink() # We should end the Rpy session more or less return(dict(template_vars)) - |