diff options
-rwxr-xr-x | wqflask/wqflask/gsearch.py | 110 | ||||
-rwxr-xr-x | wqflask/wqflask/templates/gsearch0.html | 48 | ||||
-rwxr-xr-x | wqflask/wqflask/templates/gsearch1.html | 55 | ||||
-rwxr-xr-x | wqflask/wqflask/templates/gsearch2.html | 63 | ||||
-rwxr-xr-x | wqflask/wqflask/templates/gsearch_gene.html (renamed from wqflask/wqflask/templates/gsearchact.html) | 46 | ||||
-rwxr-xr-x | wqflask/wqflask/templates/gsearch_pheno.html (renamed from wqflask/wqflask/templates/gsearchact0.html) | 88 | ||||
-rwxr-xr-x | wqflask/wqflask/templates/gsearchact1.html | 118 | ||||
-rwxr-xr-x | wqflask/wqflask/templates/gsearchact2.html | 137 | ||||
-rwxr-xr-x | wqflask/wqflask/views.py | 33 |
9 files changed, 116 insertions, 582 deletions
diff --git a/wqflask/wqflask/gsearch.py b/wqflask/wqflask/gsearch.py index 4792f77b..dd0815b1 100755 --- a/wqflask/wqflask/gsearch.py +++ b/wqflask/wqflask/gsearch.py @@ -5,83 +5,9 @@ from flask import Flask, g class GSearch(object): def __init__(self, kw): - if 'species' in kw and 'group' in kw: - self.species = kw['species'] - self.group = kw['group'] - self.terms = kw['terms'] - sql = """ - SELECT InbredSet.`Id` - FROM InbredSet,Species - WHERE InbredSet.`Name` LIKE "%s" - AND InbredSet.`SpeciesId`=Species.`Id` - AND Species.`Name` LIKE "%s" - """ % (self.group, self.species) - dbre = g.db.execute(sql).fetchone() - self.inbredset_id = dbre[0] - sql = """ - SELECT DISTINCT 0, - Tissue.`Name` AS tissue_name, - ProbeSetFreeze.FullName AS probesetfreeze_fullname, - ProbeSet.Name AS probeset_name, - ProbeSet.Symbol AS probeset_symbol, - ProbeSet.`description` AS probeset_description, - ProbeSet.Chr AS chr, - ProbeSet.Mb AS mb, - ProbeSetXRef.Mean AS mean, - ProbeSetXRef.LRS AS lrs, - ProbeSetXRef.`Locus` AS locus, - ProbeSetXRef.`pValue` AS pvalue, - ProbeSetXRef.`additive` AS additive - FROM InbredSet, ProbeSetXRef, ProbeSet, ProbeFreeze, ProbeSetFreeze, Tissue - WHERE ProbeFreeze.InbredSetId=%s - AND ProbeFreeze.`TissueId`=Tissue.`Id` - AND ProbeSetFreeze.ProbeFreezeId=ProbeFreeze.Id - AND ( MATCH (ProbeSet.Name,ProbeSet.description,ProbeSet.symbol,alias,GenbankId, UniGeneId, Probe_Target_Description) AGAINST ('%s' IN BOOLEAN MODE) ) - AND ProbeSet.Id = ProbeSetXRef.ProbeSetId - AND ProbeSetXRef.ProbeSetFreezeId=ProbeSetFreeze.Id - ORDER BY tissue_name, probesetfreeze_fullname, probeset_name - LIMIT 1000 - """ % (self.inbredset_id, self.terms) - self.results = g.db.execute(sql).fetchall() - elif 'species' in kw: - self.species = kw['species'] - self.terms = kw['terms'] - sql = """ - SELECT Species.`Id` - FROM Species - WHERE Species.`Name` LIKE "%s" - """ % (self.species) - dbre = g.db.execute(sql).fetchone() - self.species_id = dbre[0] - sql = """ - SELECT DISTINCT 0, - InbredSet.`Name` AS inbredset_name, - Tissue.`Name` AS tissue_name, - ProbeSetFreeze.FullName AS probesetfreeze_fullname, - ProbeSet.Name AS probeset_name, - ProbeSet.Symbol AS probeset_symbol, - ProbeSet.`description` AS probeset_description, - ProbeSet.Chr AS chr, - ProbeSet.Mb AS mb, - ProbeSetXRef.Mean AS mean, - ProbeSetXRef.LRS AS lrs, - ProbeSetXRef.`Locus` AS locus, - ProbeSetXRef.`pValue` AS pvalue, - ProbeSetXRef.`additive` AS additive - FROM InbredSet, ProbeSetXRef, ProbeSet, ProbeFreeze, ProbeSetFreeze, Tissue - WHERE InbredSet.`SpeciesId`=%s - AND ProbeFreeze.InbredSetId=InbredSet.`Id` - AND ProbeFreeze.`TissueId`=Tissue.`Id` - AND ProbeSetFreeze.ProbeFreezeId=ProbeFreeze.Id - AND ( MATCH (ProbeSet.Name,ProbeSet.description,ProbeSet.symbol,alias,GenbankId, UniGeneId, Probe_Target_Description) AGAINST ('%s' IN BOOLEAN MODE) ) - AND ProbeSet.Id = ProbeSetXRef.ProbeSetId - AND ProbeSetXRef.ProbeSetFreezeId=ProbeSetFreeze.Id - ORDER BY inbredset_name, tissue_name, probesetfreeze_fullname, probeset_name - LIMIT 1000 - """ % (self.species_id, self.terms) - self.results = g.db.execute(sql).fetchall() - else: - self.terms = kw['terms'] + self.type = kw['type'] + self.terms = kw['terms'] + if self.type == "gene": sql = """ SELECT Species.`Name` AS species_name, @@ -110,3 +36,33 @@ class GSearch(object): LIMIT 1000 """ % (self.terms) self.results = g.db.execute(sql).fetchall() + elif self.type == "phenotype": + sql = """ + SELECT + Species.`Name`, + InbredSet.`Name`, + PublishXRef.`Id`, + Phenotype.`Post_publication_description`, + Publication.`Authors`, + Publication.`Year`, + PublishXRef.`LRS`, + PublishXRef.`Locus`, + PublishXRef.`additive` + FROM Species,InbredSet,PublishXRef,Phenotype,Publication + WHERE PublishXRef.`InbredSetId`=InbredSet.`Id` + AND InbredSet.`SpeciesId`=Species.`Id` + AND PublishXRef.`PhenotypeId`=Phenotype.`Id` + AND PublishXRef.`PublicationId`=Publication.`Id` + AND (Phenotype.Post_publication_description REGEXP "[[:<:]]%s[[:>:]]" + OR Phenotype.Pre_publication_description REGEXP "[[:<:]]%s[[:>:]]" + OR Phenotype.Pre_publication_abbreviation REGEXP "[[:<:]]%s[[:>:]]" + OR Phenotype.Post_publication_abbreviation REGEXP "[[:<:]]%s[[:>:]]" + OR Phenotype.Lab_code REGEXP "[[:<:]]%s[[:>:]]" + OR Publication.PubMed_ID REGEXP "[[:<:]]%s[[:>:]]" + OR Publication.Abstract REGEXP "[[:<:]]%s[[:>:]]" + OR Publication.Title REGEXP "[[:<:]]%s[[:>:]]" + OR Publication.Authors REGEXP "[[:<:]]%s[[:>:]]" + OR PublishXRef.Id REGEXP "[[:<:]]%s[[:>:]]") + ORDER BY Species.`Name`, InbredSet.`Name`, Phenotype.`Post_publication_description` + """ % (self.terms, self.terms, self.terms, self.terms, self.terms, self.terms, self.terms, self.terms, self.terms, self.terms) + self.results = g.db.execute(sql).fetchall() diff --git a/wqflask/wqflask/templates/gsearch0.html b/wqflask/wqflask/templates/gsearch0.html deleted file mode 100755 index 45ab0d3b..00000000 --- a/wqflask/wqflask/templates/gsearch0.html +++ /dev/null @@ -1,48 +0,0 @@ -{% extends "base.html" %} -{% block title %}GeneNetwork{% endblock %} -{% block content %} -<!-- Start of body --> - - <div class="container-fluid"> - - {{ flash_me() }} - - <div class="row" style="width: 1200px !important;"> - - <div class="col-xs-5 col-xs-5"> - <section id="search"> - <div class="page-header"> - <h1>Global Search</h1> - </div> - <form method="get" action="/gsearchact0" name="SEARCHFORM"> - <fieldset> - <div style="padding: 20px" class="form-horizontal"> - - <div class="form-group"> - <label for="tfor" class="col-xs-1 control-label" style="width: 65px !important;">Search:</label> - <div class="col-xs-10 controls"> - <textarea name="terms" rows="2" class="form-control search-query" style="width: 450px !important;" id="tfor"></textarea> - </div> - </div> - - <!-- SEARCH, MAKE DEFAULT, ADVANCED SEARCH --> - - <div class="form-group"> - - <div class="col-xs-3 controls" style="width: 100px !important;"> - <input id="btsearch" type="submit" class="btn btn-primary form-control" value="Search"> - </div> - </div> - </div> - </fieldset> - </form> - </section> - </div> - </div> - </div> - -{%endblock%} - -{% block js %} - <script src="/static/new/javascript/dataset_select_menu.js"></script> -{% endblock %}
\ No newline at end of file diff --git a/wqflask/wqflask/templates/gsearch1.html b/wqflask/wqflask/templates/gsearch1.html deleted file mode 100755 index 500e7f3d..00000000 --- a/wqflask/wqflask/templates/gsearch1.html +++ /dev/null @@ -1,55 +0,0 @@ -{% extends "base.html" %} -{% block title %}GeneNetwork{% endblock %} -{% block content %} -<!-- Start of body --> - - <div class="container-fluid"> - - {{ flash_me() }} - - <div class="row" style="width: 1200px !important;"> - - <div class="col-xs-5 col-xs-5"> - <section id="search"> - <div class="page-header"> - <h1>Global Search</h1> - </div> - <form method="get" action="/gsearchact1" name="SEARCHFORM"> - <fieldset> - <div style="padding: 20px" class="form-horizontal"> - - <div class="form-group"> - <label for="species" class="col-xs-1 control-label" style="width: 65px !important;">Species:</label> - <div class="col-xs-4 controls"> - <select name="species" id="species" class="form-control selectpicker span3" style="width: 300px !important;"></select> - </div> - </div> - - <div class="form-group"> - <label for="tfor" class="col-xs-1 control-label" style="width: 65px !important;">Search:</label> - <div class="col-xs-10 controls"> - <textarea name="terms" rows="2" class="form-control search-query" style="width: 450px !important;" id="tfor"></textarea> - </div> - </div> - - <!-- SEARCH, MAKE DEFAULT, ADVANCED SEARCH --> - - <div class="form-group"> - - <div class="col-xs-3 controls" style="width: 100px !important;"> - <input id="btsearch" type="submit" class="btn btn-primary form-control" value="Search"> - </div> - </div> - </div> - </fieldset> - </form> - </section> - </div> - </div> - </div> - -{%endblock%} - -{% block js %} - <script src="/static/new/javascript/dataset_select_menu.js"></script> -{% endblock %}
\ No newline at end of file diff --git a/wqflask/wqflask/templates/gsearch2.html b/wqflask/wqflask/templates/gsearch2.html deleted file mode 100755 index 9a6da575..00000000 --- a/wqflask/wqflask/templates/gsearch2.html +++ /dev/null @@ -1,63 +0,0 @@ -{% extends "base.html" %} -{% block title %}GeneNetwork{% endblock %} -{% block content %} -<!-- Start of body --> - - <div class="container-fluid"> - - {{ flash_me() }} - - <div class="row" style="width: 1200px !important;"> - - <div class="col-xs-5 col-xs-5"> - <section id="search"> - <div class="page-header"> - <h1>Global Search</h1> - </div> - <form method="get" action="/gsearchact2" name="SEARCHFORM"> - <fieldset> - <div style="padding: 20px" class="form-horizontal"> - - <div class="form-group"> - <label for="species" class="col-xs-1 control-label" style="width: 65px !important;">Species:</label> - <div class="col-xs-4 controls"> - <select name="species" id="species" class="form-control selectpicker span3" style="width: 300px !important;"></select> - </div> - </div> - - <div class="form-group"> - <label for="group" class="col-xs-1 control-label" style="width: 65px !important;">Group:</label> - <div class="col-xs-4 controls input-append"> - <select name="group" id="group" class="form-control selectpicker span3" style="width: 300px !important;"></select> - <i class="icon-question-sign"></i> - </div> - </div> - - <div class="form-group"> - <label for="tfor" class="col-xs-1 control-label" style="width: 65px !important;">Search:</label> - <div class="col-xs-10 controls"> - <textarea name="terms" rows="2" class="form-control search-query" style="width: 450px !important;" id="tfor"></textarea> - </div> - </div> - - <!-- SEARCH, MAKE DEFAULT, ADVANCED SEARCH --> - - <div class="form-group"> - - <div class="col-xs-3 controls" style="width: 100px !important;"> - <input id="btsearch" type="submit" class="btn btn-primary form-control" value="Search"> - </div> - </div> - </div> - </fieldset> - </form> - </section> - </div> - </div> - </div> - -{%endblock%} - -{% block js %} - <script src="/static/new/javascript/dataset_select_menu.js"></script> -{% endblock %}
\ No newline at end of file diff --git a/wqflask/wqflask/templates/gsearchact.html b/wqflask/wqflask/templates/gsearch_gene.html index 26d7b5cd..3e1cb32e 100755 --- a/wqflask/wqflask/templates/gsearchact.html +++ b/wqflask/wqflask/templates/gsearch_gene.html @@ -4,6 +4,8 @@ <link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/css/jquery.dataTables.css" /> <link rel="stylesheet" type="text/css" href="/static/packages/DT_bootstrap/DT_bootstrap.css" /> <link rel="stylesheet" type="text/css" href="/static/packages/TableTools/media/css/TableTools.css" /> + <link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/extensions/dataTables.fixedHeader.css" > + <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/fixedcolumns/3.0.4/css/dataTables.fixedColumns.css"> {% endblock %} {% block content %} <!-- Start of body --> @@ -24,7 +26,6 @@ <table class="table table-hover table-striped" id="trait_table"> <thead> <tr> - <th></th> <th>Index</th> <th>Symbol</th> <th>Record</th> @@ -46,8 +47,7 @@ <tbody> {% for this_trait in results %} <TR> - <td><input type="checkbox"></td> - <td>{{ loop.index }}</td> + <td><input type="checkbox">{{ loop.index }}</td> {% for item in this_trait %} <TD>{{ item }}</TD> {% endfor %} @@ -64,31 +64,46 @@ {% endblock %} {% block js %} - <script type="text/javascript" src="/static/new/javascript/search_results.js"></script> + <script type="text/javascript" src="/static/new/javascript/search_results.js"></script> <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/jquery.dataTables.min.js"></script> <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/dataTables.naturalSort.js"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/extensions/dataTables.colResize.js"></script> + <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/extensions/dataTables.colResize.js"></script> <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/extensions/dataTables.colReorder.js"></script> + <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/extensions/dataTables.fixedHeader.js"></script> + <script language="javascript" type="text/javascript" src="//cdn.datatables.net/fixedcolumns/3.0.4/js/dataTables.fixedColumns.min.js"></script> <script language="javascript" type="text/javascript" src="/static/packages/DT_bootstrap/DT_bootstrap.js"></script> <script language="javascript" type="text/javascript" src="/static/packages/TableTools/media/js/TableTools.min.js"></script> - <script type="text/javascript" charset="utf-8"> + + <script type="text/javascript" charset="utf-8"> function getValue(x) { if (x.indexOf('input') >= 0) { if ($(x).val() == 'x') { - return 0 + return 0; } else { return parseFloat($(x).val()); } } + else if (isNaN(x)) { + return x; + } return parseFloat(x); } jQuery.fn.dataTableExt.oSort['cust-txt-asc'] = function (a, b) { var x = getValue(a); - var y = getValue(b); - return ((x < y) ? -1 : ((x > y) ? 1 : 0)); + var y = getValue(b); + + if (x == 'N/A' || x == '') { + return 1; + } + else if (y == 'N/A' || y == '') { + return -1; + } + else { + return ((x < y) ? -1 : ((x > y) ? 1 : 0)); + } }; jQuery.fn.dataTableExt.oSort['cust-txt-desc'] = function (a, b) { @@ -97,7 +112,6 @@ return ((x < y) ? 1 : ((x > y) ? -1 : 0)); }; - $(document).ready( function () { $('#trait_table tr').click(function(event) { @@ -109,8 +123,6 @@ console.time("Creating table"); $('#trait_table').DataTable( { "columns": [ - { "sortable": false }, - { "sortable": true }, { "type": "natural" }, { "type": "natural" }, { "type": "natural", "width": "35%" }, @@ -122,26 +134,26 @@ { "type": "natural", "width": "12%" }, { "type": "natural", "width": "12%" }, { "type": "natural", "width": "15%" }, + { "type": "natural" }, + { "type": "natural" }, + { "type": "natural" }, { "type": "cust-txt" } ], - - "sDom": "tir", + "sDom": "RJtir", "iDisplayLength": -1, "autoWidth": true, "bLengthChange": true, "bDeferRender": true, "bSortClasses": false, "scrollY": "700px", - "scrollCollapse": true, + "scrollCollapse": false, "colResize": { "tableWidthFixed": false, }, "paging": false } ); - console.timeEnd("Creating table"); }); </script> - {% endblock %} diff --git a/wqflask/wqflask/templates/gsearchact0.html b/wqflask/wqflask/templates/gsearch_pheno.html index 54e156e1..f6b6efa3 100755 --- a/wqflask/wqflask/templates/gsearchact0.html +++ b/wqflask/wqflask/templates/gsearch_pheno.html @@ -4,6 +4,8 @@ <link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/css/jquery.dataTables.css" /> <link rel="stylesheet" type="text/css" href="/static/packages/DT_bootstrap/DT_bootstrap.css" /> <link rel="stylesheet" type="text/css" href="/static/packages/TableTools/media/css/TableTools.css" /> + <link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/extensions/dataTables.fixedHeader.css" > + <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/fixedcolumns/3.0.4/css/dataTables.fixedColumns.css"> {% endblock %} {% block content %} <!-- Start of body --> @@ -24,21 +26,15 @@ <table class="table table-hover table-striped" id="trait_table"> <thead> <tr> - <th></th> <th>Index</th> <th>Species</th> <th>Group</th> - <th>Tissue</th> - <th>Dataset</th> - <th>Record</th> - <th>Symbol</th> - <th>Description</th> - <th>Chr</th> - <th>Mb</th> - <th>Mean</th> + <th>Record ID</th> + <th>Phenotype</th> + <th>Authors</th> + <th>Year</th> <th>Max LRS</th> <th>Locus</th> - <th>Pvalue</th> <th>Additive</th> </tr> </thead> @@ -46,8 +42,7 @@ <tbody> {% for this_trait in results %} <TR> - <td><input type="checkbox"></td> - <td>{{ loop.index }}</td> + <td><input type="checkbox">{{ loop.index }}</td> {% for item in this_trait %} <TD>{{ item }}</TD> {% endfor %} @@ -64,29 +59,46 @@ {% endblock %} {% block js %} - <script type="text/javascript" src="/static/new/javascript/search_results.js"></script> + <script type="text/javascript" src="/static/new/javascript/search_results.js"></script> <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/jquery.dataTables.min.js"></script> <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/dataTables.naturalSort.js"></script> + <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/extensions/dataTables.colResize.js"></script> + <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/extensions/dataTables.colReorder.js"></script> + <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/extensions/dataTables.fixedHeader.js"></script> + <script language="javascript" type="text/javascript" src="//cdn.datatables.net/fixedcolumns/3.0.4/js/dataTables.fixedColumns.min.js"></script> <script language="javascript" type="text/javascript" src="/static/packages/DT_bootstrap/DT_bootstrap.js"></script> <script language="javascript" type="text/javascript" src="/static/packages/TableTools/media/js/TableTools.min.js"></script> - <script type="text/javascript" charset="utf-8"> + + <script type="text/javascript" charset="utf-8"> function getValue(x) { if (x.indexOf('input') >= 0) { if ($(x).val() == 'x') { - return 0 + return 0; } else { return parseFloat($(x).val()); } } + else if (isNaN(x)) { + return x; + } return parseFloat(x); } jQuery.fn.dataTableExt.oSort['cust-txt-asc'] = function (a, b) { var x = getValue(a); - var y = getValue(b); - return ((x < y) ? -1 : ((x > y) ? 1 : 0)); + var y = getValue(b); + + if (x == 'N/A' || x == '') { + return 1; + } + else if (y == 'N/A' || y == '') { + return -1; + } + else { + return ((x < y) ? -1 : ((x > y) ? 1 : 0)); + } }; jQuery.fn.dataTableExt.oSort['cust-txt-desc'] = function (a, b) { @@ -95,7 +107,6 @@ return ((x < y) ? 1 : ((x > y) ? -1 : 0)); }; - $(document).ready( function () { $('#trait_table tr').click(function(event) { @@ -105,35 +116,34 @@ }); console.time("Creating table"); - $('#trait_table').dataTable( { - "aoColumns": [ - { "bSortable": false }, - { "bSortable": true }, - { "sType": "natural" }, - { "sType": "natural" }, - { "sType": "natural", "sWidth": "35%" }, - { "sType": "natural", "sWidth": "15%" }, - { "sType": "cust-txt" }, - { "sType": "natural", "sWidth": "12%" }, - { "sType": "natural", "sWidth": "12%" }, - { "sType": "natural", "sWidth": "12%" }, - { "sType": "natural", "sWidth": "12%" }, - { "sType": "natural", "sWidth": "12%" }, - { "sType": "natural", "sWidth": "15%" }, - { "sType": "cust-txt" } + $('#trait_table').DataTable( { + "columns": [ + { "type": "natural" }, + { "type": "natural" }, + { "type": "natural" }, + { "type": "natural" }, + { "type": "natural" }, + { "type": "natural" }, + { "type": "natural" }, + { "type": "natural" }, + { "type": "natural" }, + { "type": "natural" } ], - - "sDom": "tir", + "sDom": "RJtir", "iDisplayLength": -1, "autoWidth": true, "bLengthChange": true, "bDeferRender": true, - "bSortClasses": false + "bSortClasses": false, + "scrollY": "700px", + "scrollCollapse": false, + "colResize": { + "tableWidthFixed": false, + }, + "paging": false } ); - console.timeEnd("Creating table"); }); </script> - {% endblock %} diff --git a/wqflask/wqflask/templates/gsearchact1.html b/wqflask/wqflask/templates/gsearchact1.html deleted file mode 100755 index dcc82f91..00000000 --- a/wqflask/wqflask/templates/gsearchact1.html +++ /dev/null @@ -1,118 +0,0 @@ -{% extends "base.html" %} -{% block title %}Search Results{% endblock %} -{% block css %} - <link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/css/jquery.dataTables.css" /> - <link rel="stylesheet" type="text/css" href="/static/packages/DT_bootstrap/DT_bootstrap.css" /> - <link rel="stylesheet" type="text/css" href="/static/packages/TableTools/media/css/TableTools.css" /> -{% endblock %} -{% block content %} -<!-- Start of body --> - - <div class="container"> - - <p>To study a record, click on its ID below.<br />Check records below and click Add button to add to selection.</p> - - <div> - <br /> - <button class="btn btn-default" id="select_all"><span class="glyphicon glyphicon-ok"></span> Select All</button> - <button class="btn btn-default" id="deselect_all"><span class="glyphicon glyphicon-remove"></span> Deselect All</button> - <button class="btn btn-default" id="invert"><span class="glyphicon glyphicon-resize-vertical"></span> Invert</button> - <button class="btn btn-default" id="add"><span class="glyphicon glyphicon-plus-sign"></span> Add</button> - <button class="btn btn-primary pull-right"><span class="glyphicon glyphicon-download"></span> Download Table</button> - <br /> - <br /> - <table class="table table-hover table-striped" id='' style="width: 100%;"> - <thead> - <tr> - <th></th> - <th>Index</th> - <th>Group</th> - <th>Tissue</th> - <th>Dataset</th> - <th>Record</th> - <th>Symbol</th> - <th>Description</th> - <th>Chr</th> - <th>Mb</th> - <th>Mean</th> - <th>Max LRS</th> - <th>Locus</th> - <th>Pvalue</th> - <th>Additive</th> - </tr> - </thead> - - <tbody> - {% for this_trait in results %} - <TR> - <td><input type="checkbox"></td> - <td>{{ loop.index }}</td> - {% for item in this_trait[1:] %} - <TD>{{ item }}</TD> - {% endfor %} - </TR> - {% endfor %} - </tbody> - - </table> - </div> - </div> - -<!-- End of body --> - -{% endblock %} - -{% block js %} - <script type="text/javascript" src="/static/new/javascript/search_results.js"></script> - - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/jquery.dataTables.min.js"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/dataTables.naturalSort.js"></script> - <script language="javascript" type="text/javascript" src="/static/packages/DT_bootstrap/DT_bootstrap.js"></script> - <script language="javascript" type="text/javascript" src="/static/packages/TableTools/media/js/TableTools.min.js"></script> - <script type="text/javascript" charset="utf-8"> - function getValue(x) { - if (x.indexOf('input') >= 0) { - if ($(x).val() == 'x') { - return 0 - } - else { - return parseFloat($(x).val()); - } - } - return parseFloat(x); - } - - jQuery.fn.dataTableExt.oSort['cust-txt-asc'] = function (a, b) { - var x = getValue(a); - var y = getValue(b); - return ((x < y) ? -1 : ((x > y) ? 1 : 0)); - }; - - jQuery.fn.dataTableExt.oSort['cust-txt-desc'] = function (a, b) { - var x = getValue(a); - var y = getValue(b); - return ((x < y) ? 1 : ((x > y) ? -1 : 0)); - }; - - - $(document).ready( function () { - - /*num_columns = $('#trait_table').find('tr:first th').length; - - nul_cols = [] - for (i=0; i<num_columns - 1, i++) { - $('#trait_table > tbody > tr').each(function() { - if ($(this).find('td:eq(i)').html()){ - continue; - } - }); - nul_cols.push(i) - }*/ - - console.time("Creating table"); - console.timeEnd("Creating table"); - }); - - </script> - -{% endblock %} diff --git a/wqflask/wqflask/templates/gsearchact2.html b/wqflask/wqflask/templates/gsearchact2.html deleted file mode 100755 index 295ad2fd..00000000 --- a/wqflask/wqflask/templates/gsearchact2.html +++ /dev/null @@ -1,137 +0,0 @@ -{% extends "base.html" %} -{% block title %}Search Results{% endblock %} -{% block css %} - <link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/css/jquery.dataTables.css" /> - <link rel="stylesheet" type="text/css" href="/static/packages/DT_bootstrap/DT_bootstrap.css" /> - <link rel="stylesheet" type="text/css" href="/static/packages/TableTools/media/css/TableTools.css" /> -{% endblock %} -{% block content %} -<!-- Start of body --> - - <div class="container"> - - <p>To study a record, click on its ID below.<br />Check records below and click Add button to add to selection.</p> - - <div> - <br /> - <button class="btn btn-default" id="select_all"><span class="glyphicon glyphicon-ok"></span> Select All</button> - <button class="btn btn-default" id="deselect_all"><span class="glyphicon glyphicon-remove"></span> Deselect All</button> - <button class="btn btn-default" id="invert"><span class="glyphicon glyphicon-resize-vertical"></span> Invert</button> - <button class="btn btn-default" id="add"><span class="glyphicon glyphicon-plus-sign"></span> Add</button> - <button class="btn btn-primary pull-right"><span class="glyphicon glyphicon-download"></span> Download Table</button> - <br /> - <br /> - <table class="table table-hover table-striped" id="trait_table"> - <thead> - <tr> - <th></th> - <th>Index</th> - <th>Tissue</th> - <th>Dataset</th> - <th>Record</th> - <th>Symbol</th> - <th>Description</th> - <th>Chr</th> - <th>Mb</th> - <th>Mean</th> - <th>Max LRS</th> - <th>Locus</th> - <th>Pvalue</th> - <th>Additive</th> - </tr> - </thead> - - <tbody> - {% for this_trait in results %} - <TR> - <td><input type="checkbox"></td> - <td>{{ loop.index }}</td> - {% for item in this_trait[1:] %} - <TD>{{ item }}</TD> - {% endfor %} - </TR> - {% endfor %} - </tbody> - - </table> - </div> - </div> - -<!-- End of body --> - -{% endblock %} - -{% block js %} - <script type="text/javascript" src="/static/new/javascript/search_results.js"></script> - - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/jquery.dataTables.min.js"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/dataTables.naturalSort.js"></script> - <script language="javascript" type="text/javascript" src="/static/packages/DT_bootstrap/DT_bootstrap.js"></script> - <script language="javascript" type="text/javascript" src="/static/packages/TableTools/media/js/TableTools.min.js"></script> - <script type="text/javascript" charset="utf-8"> - function getValue(x) { - if (x.indexOf('input') >= 0) { - if ($(x).val() == 'x') { - return 0 - } - else { - return parseFloat($(x).val()); - } - } - return parseFloat(x); - } - - jQuery.fn.dataTableExt.oSort['cust-txt-asc'] = function (a, b) { - var x = getValue(a); - var y = getValue(b); - return ((x < y) ? -1 : ((x > y) ? 1 : 0)); - }; - - jQuery.fn.dataTableExt.oSort['cust-txt-desc'] = function (a, b) { - var x = getValue(a); - var y = getValue(b); - return ((x < y) ? 1 : ((x > y) ? -1 : 0)); - }; - - - $(document).ready( function () { - - $('#trait_table tr').click(function(event) { - if (event.target.type !== 'checkbox') { - $(':checkbox', this).trigger('click'); - } - }); - - console.time("Creating table"); - $('#trait_table').dataTable( { - "aoColumns": [ - { "bSortable": false }, - { "bSortable": true }, - { "sType": "natural" }, - { "sType": "natural" }, - { "sType": "natural", "sWidth": "35%" }, - { "sType": "natural", "sWidth": "15%" }, - { "sType": "cust-txt" }, - { "sType": "natural", "sWidth": "12%" }, - { "sType": "natural", "sWidth": "12%" }, - { "sType": "natural", "sWidth": "12%" }, - { "sType": "natural", "sWidth": "12%" }, - { "sType": "natural", "sWidth": "12%" }, - { "sType": "natural", "sWidth": "15%" }, - { "sType": "cust-txt" } - ], - - "sDom": "tir", - "iDisplayLength": -1, - "autoWidth": true, - "bLengthChange": true, - "bDeferRender": true, - "bSortClasses": false - } ); - - console.timeEnd("Creating table"); - }); - - </script> - -{% endblock %} diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index d188aea1..00c8d00d 100755 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -158,34 +158,11 @@ def search_page(): @app.route("/gsearch", methods=('GET',)) def gsearchact(): result = gsearch.GSearch(request.args).__dict__ - return render_template("gsearchact.html", **result) - -@app.route("/gsearch0", methods=('GET',)) -def gsearchreq0(): - return render_template("gsearch0.html") - -@app.route("/gsearchact0", methods=('GET',)) -def gsearchact0(): - result = gsearch.GSearch(request.args).__dict__ - return render_template("gsearchact0.html", **result) - -@app.route("/gsearch1", methods=('GET',)) -def gsearchreq1(): - return render_template("gsearch1.html") - -@app.route("/gsearchact1", methods=('GET',)) -def gsearchact1(): - result = gsearch.GSearch(request.args).__dict__ - return render_template("gsearchact1.html", **result) - -@app.route("/gsearch2", methods=('GET',)) -def gsearchreq2(): - return render_template("gsearch2.html") - -@app.route("/gsearchact2", methods=('GET',)) -def gsearchact2(): - result = gsearch.GSearch(request.args).__dict__ - return render_template("gsearchact2.html", **result) + type = request.args['type'] + if type == "gene": + return render_template("gsearch_gene.html", **result) + elif type == "phenotype": + return render_template("gsearch_pheno.html", **result) @app.route("/docedit") def docedit(): |