From 0408cc61181eaeda95bd1f60f76dc5798e315663 Mon Sep 17 00:00:00 2001 From: zsloan Date: Wed, 5 Apr 2017 15:37:29 +0000 Subject: - Temporary traits can be created, viewed, and added to collections - Correct PCA trait data is created but can't be saved yet - Added inner margins by increasing xDomain and yDomain of probability plot on trait page - Increased X/Y-axis label font size - Turned "processes" to 0 on runserver.py for PROD setting, since it doesn't work with threading - Improved appearance of correlation page table - Added links to github to index page - Removed js_data from GEMMA/PLINK mapping results, since it isn't used for those - Removed "Tissue" from trait page for phenotype traits --- wqflask/base/data_set.py | 35 +++++++++++++++++++++-------------- wqflask/base/trait.py | 16 +++++++++++----- wqflask/base/webqtlConfig.py | 2 +- 3 files changed, 33 insertions(+), 20 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 54dd3c4b..7f08135f 100644 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -61,14 +61,17 @@ logger = getLogger(__name__ ) # Each subclass will add to this DS_NAME_MAP = {} -def create_dataset(dataset_name, dataset_type = None, get_samplelist = True): +def create_dataset(dataset_name, dataset_type = None, get_samplelist = True, group_name = None): if not dataset_type: dataset_type = Dataset_Getter(dataset_name) logger.debug("dataset_type", dataset_type) dataset_ob = DS_NAME_MAP[dataset_type] dataset_class = globals()[dataset_ob] - return dataset_class(dataset_name, get_samplelist) + if dataset_type == "Temp": + return dataset_class(dataset_name, get_samplelist, group_name) + else: + return dataset_class(dataset_name, get_samplelist) class Dataset_Types(object): @@ -261,10 +264,13 @@ class DatasetGroup(object): has multiple datasets associated with it. """ - def __init__(self, dataset): + def __init__(self, dataset, name=None): """This sets self.group and self.group_id""" #logger.debug("DATASET NAME2:", dataset.name) - self.name, self.id, self.genetic_type = fetchone(dataset.query_for_group) + if name == None: + self.name, self.id, self.genetic_type = fetchone(dataset.query_for_group) + else: + self.name, self.id, self.genetic_type = fetchone("SELECT InbredSet.Name, InbredSet.Id, InbredSet.GeneticType FROM InbredSet where Name='%s'" % name) if self.name == 'BXD300': self.name = "BXD" @@ -304,7 +310,7 @@ class DatasetGroup(object): elif mapping_id == "2": mapping_names = ["GEMMA"] elif mapping_id == "4": - mapping_names = ["PLINK"] + mapping_names = ["GEMMA", "PLINK"] else: mapping_names = [] @@ -319,9 +325,7 @@ class DatasetGroup(object): def check_plink_gemma(): if flat_file_exists("mapping"): MAPPING_PATH = flat_files("mapping")+"/" - if (os.path.isfile(MAPPING_PATH+self.name+".bed") and - (os.path.isfile(MAPPING_PATH+self.name+".map") or - os.path.isfile(MAPPING_PATH+self.name+".bim"))): + if os.path.isfile(MAPPING_PATH+self.name+".bed"): return True return False @@ -481,7 +485,7 @@ class DataSet(object): """ - def __init__(self, name, get_samplelist = True): + def __init__(self, name, get_samplelist = True, group_name = None): assert name, "Need a name" self.name = name @@ -493,11 +497,12 @@ class DataSet(object): self.setup() - self.check_confidentiality() - - self.retrieve_other_names() - - self.group = DatasetGroup(self) # sets self.group and self.group_id and gets genotype + if self.type == "Temp": #Need to supply group name as input if temp trait + self.group = DatasetGroup(self, group_name) # sets self.group and self.group_id and gets genotype + else: + self.check_confidentiality() + self.retrieve_other_names() + self.group = DatasetGroup(self) # sets self.group and self.group_id and gets genotype if get_samplelist == True: self.group.get_samplelist() self.species = species.TheSpecies(self) @@ -1156,6 +1161,8 @@ class MrnaAssayDataSet(DataSet): class TempDataSet(DataSet): '''Temporary user-generated data set''' + DS_NAME_MAP['Temp'] = 'TempDataSet' + def setup(self): self.search_fields = ['name', 'description'] diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py index bf87e879..e22a51e4 100644 --- a/wqflask/base/trait.py +++ b/wqflask/base/trait.py @@ -62,6 +62,11 @@ class GeneralTrait(object): self.strand_probe = None self.symbol = None + self.LRS_score_repr = "N/A" + self.LRS_score_value = 0 + self.LRS_location_repr = "N/A" + self.LRS_location_value = 1000000 + if kw.get('fullname'): name2 = value.split("::") if len(name2) == 2: @@ -72,9 +77,10 @@ class GeneralTrait(object): # Todo: These two lines are necessary most of the time, but perhaps not all of the time # So we could add a simple if statement to short-circuit this if necessary - self = retrieve_trait_info(self, self.dataset, get_qtl_info=get_qtl_info) - if get_sample_info != False: - self = retrieve_sample_data(self, self.dataset) + if self.dataset.type != "Temp": + self = retrieve_trait_info(self, self.dataset, get_qtl_info=get_qtl_info) + if get_sample_info != False: + self = retrieve_sample_data(self, self.dataset) def get_name(self): @@ -315,12 +321,12 @@ def get_sample_data(): # #return jsonable_sample_data -def jsonable(trait, dataset_name): +def jsonable(trait): """Return a dict suitable for using as json Actual turning into json doesn't happen here though""" - dataset = create_dataset(dataset_name) + dataset = create_dataset(dataset_name = trait.dataset.name, dataset_type = trait.dataset.type, group_name = trait.dataset.group.name) if dataset.type == "ProbeSet": return dict(name=trait.name, diff --git a/wqflask/base/webqtlConfig.py b/wqflask/base/webqtlConfig.py index e5f10edf..1e47e183 100644 --- a/wqflask/base/webqtlConfig.py +++ b/wqflask/base/webqtlConfig.py @@ -65,7 +65,7 @@ ENSEMBLETRANSCRIPT_URL="http://useast.ensembl.org/Mus_musculus/Lucene/Details?sp # want to reach this base dir assert_writable_dir(TEMPDIR) -TMPDIR = mk_dir(TEMPDIR+'/gn2/') +TMPDIR = mk_dir(TEMPDIR+'gn2') assert_writable_dir(TMPDIR) CACHEDIR = mk_dir(TMPDIR+'/cache/') -- cgit v1.2.3 From 2c94097c49eedff1def1fb7d53572f290b8fe7d1 Mon Sep 17 00:00:00 2001 From: zsloan Date: Mon, 17 Apr 2017 22:24:40 +0000 Subject: Added option to remove collections from collection list page Improved appearance of search result and collection tables --- wqflask/base/data_set.py | 2 +- wqflask/wqflask/collect.py | 19 +++-- .../packages/DataTables/css/jquery.dataTables.css | 15 ++-- wqflask/wqflask/templates/collections/list.html | 60 +++++++++++---- wqflask/wqflask/templates/collections/view.html | 86 ++++++++++++---------- wqflask/wqflask/templates/search_result_page.html | 27 +++---- 6 files changed, 130 insertions(+), 79 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 7f08135f..4959457a 100644 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -893,7 +893,7 @@ class GenotypeDataSet(DataSet): def retrieve_sample_data(self, trait): query = """ SELECT - Strain.Name, GenoData.value, GenoSE.error, GenoData.Id, Sample.Name2 + Strain.Name, GenoData.value, GenoSE.error, GenoData.Id, Strain.Name2 FROM (GenoData, GenoFreeze, Strain, Geno, GenoXRef) left join GenoSE on diff --git a/wqflask/wqflask/collect.py b/wqflask/wqflask/collect.py index 478dbcaa..2f6c3a96 100644 --- a/wqflask/wqflask/collect.py +++ b/wqflask/wqflask/collect.py @@ -335,12 +335,19 @@ def delete_collection(): print("params:", params) if g.user_session.logged_in: uc_id = params['uc_id'] - uc = model.UserCollection.query.get(uc_id) - # Todo: For now having the id is good enough since it's so unique - # But might want to check ownership in the future - collection_name = uc.name - db_session.delete(uc) - db_session.commit() + if len(uc_id.split(":")) > 1: + for this_uc_id in uc_id.split(":"): + uc = model.UserCollection.query.get(this_uc_id) + collection_name = uc.name + db_session.delete(uc) + db_session.commit() + else: + uc = model.UserCollection.query.get(uc_id) + # Todo: For now having the id is good enough since it's so unique + # But might want to check ownership in the future + collection_name = uc.name + db_session.delete(uc) + db_session.commit() else: collection_name = params['collection_name'] user_manager.AnonUser().delete_collection(collection_name) diff --git a/wqflask/wqflask/static/new/packages/DataTables/css/jquery.dataTables.css b/wqflask/wqflask/static/new/packages/DataTables/css/jquery.dataTables.css index 40e58ac8..ab7420a6 100644 --- a/wqflask/wqflask/static/new/packages/DataTables/css/jquery.dataTables.css +++ b/wqflask/wqflask/static/new/packages/DataTables/css/jquery.dataTables.css @@ -14,6 +14,9 @@ table.dataTable { * Body styles */ } +td.highlight { + background-color: whitesmoke !important; +} table.dataTable thead th, table.dataTable tfoot th { font-weight: bold; @@ -25,8 +28,8 @@ table.dataTable thead td { background-color: #ffffff; border-collapse: collapse; border-bottom: #cccccc 2px solid; - padding: 0; - //padding: 10px 18px 10px 0px; + //padding: 0; + padding: 10px 18px 4px 10px; //border-bottom: 1px solid #111; } table.dataTable thead th:active, @@ -39,8 +42,8 @@ table.dataTable tfoot td { color: #000000; background-color: #ffffff; border-collapse: collapse; - padding: 0; - //padding: 10px 18px 6px 18px; + //padding: 0; + padding: 10px 18px 6px 18px; //border-top: 1px solid #111; } table.dataTable thead .sorting, @@ -76,12 +79,12 @@ table.dataTable tbody tr { background-color: #ffffff; } table.dataTable tbody tr.selected { - background-color: #ffff99; + background-color: #abb9d3; } table.dataTable tbody th, table.dataTable tbody td { font: 12px Arial, Sans-serif; - padding: 4px 16px 4px 0px; + padding: 8px 20px 6px 10px; } table.dataTable.row-border tbody th, table.dataTable.row-border tbody td, table.dataTable.display tbody th, table.dataTable.display tbody td { border-top: 1px solid #ddd; diff --git a/wqflask/wqflask/templates/collections/list.html b/wqflask/wqflask/templates/collections/list.html index 6dc52c4d..5a30c98c 100644 --- a/wqflask/wqflask/templates/collections/list.html +++ b/wqflask/wqflask/templates/collections/list.html @@ -25,11 +25,21 @@

Your Collections

{% endif %} - +
+
+ +
+ + + + +
+
- +
+ @@ -41,7 +51,8 @@ {% for uc in collections %} - + {% else %} @@ -64,6 +75,7 @@ {% block js %} + @@ -72,24 +84,24 @@ - - {% if "color_by_trait" in params %} {% endif %} {% endblock %} diff --git a/wqflask/wqflask/templates/collections/view.html b/wqflask/wqflask/templates/collections/view.html index 9d03e6d7..094bc273 100644 --- a/wqflask/wqflask/templates/collections/view.html +++ b/wqflask/wqflask/templates/collections/view.html @@ -2,8 +2,7 @@ {% block title %}View Collection{% endblock %} {% block css %} - - + {% endblock %} {% block content %} @@ -29,42 +28,40 @@ {% for this_trait in trait_obs %} {{ this_trait.name }}:{{ this_trait.dataset.name }}, {% endfor %}" > -
+ -
-
+ + -
-
+ + -
-
+ + -
-
+ + -
-
+ + -
+
-
-

@@ -80,7 +77,7 @@
-
Index Name Created
{{ loop.index }} + {{ loop.index }} {% if g.user_session.user_ob %} {{ uc.name }}
+
@@ -90,9 +87,9 @@ - + - + @@ -141,8 +138,8 @@ - - + + - - + + - + @@ -172,6 +172,7 @@ console.time("Creating table"); {% if dataset.type == 'ProbeSet' %} //ZS: Need to make sort by symbol, also need to make sure blank symbol fields at the bottom and symbols starting with numbers below letters + $('#trait_table').DataTable( { "drawCallback": function( settings ) { $('#trait_table tr').click(function(event) { @@ -182,8 +183,7 @@ $('.trait_checkbox:checkbox').on("change", change_buttons); }, "createdRow": function ( row, data, index ) { - $('td', row).eq(0).attr('style', 'padding-right: 0px;'); - $('td', row).eq(0).attr('align', 'center'); + $('td', row).eq(0).attr('style', 'padding-left: 8px; padding-right: 0px; padding-top: 4px; align: center;'); $('td', row).eq(1).attr('align', 'right'); $('td', row).eq(1).attr('data-export', index+1); $('td', row).eq(2).attr('data-export', $('td', row).eq(2).text()); @@ -207,15 +207,15 @@ "data": json_trait_list, "columns": [ { "type": "natural", "width": "2%" }, - { "type": "natural", "width": "4%" }, + { "type": "natural", "width": "5%" }, { "type": "natural", "width": "12%" }, { "type": "natural", "width": "12%" }, - { "type": "natural", "width": "25%" }, + { "type": "natural" }, { "type": "natural", "width": "11%" }, + { "type": "natural", "width": "4%" }, { "type": "natural", "width": "5%" }, - { "type": "natural", "width": "6%" }, { "type": "natural", "width": "11%" }, - { "type": "natural", "width": "6%" } + { "type": "natural", "width": "5%" } ], "columnDefs": [ { "targets": 0, @@ -224,8 +224,7 @@ "order": [[1, "asc" ]], buttons: [ { - extend: 'colvis', - text: 'Show or Hide Columns', + extend: 'columnsToggle', columns: ':not(:first-child)', postfixButtons: [ 'colvisRestore' ] } @@ -238,7 +237,8 @@ "scrollY": "600px", "scrollCollapse": false, "scroller": true, - "paging": false + "paging": false, + "orderClasses": true } ); {% elif dataset.type == 'Publish' %} @@ -358,6 +358,7 @@ "paging": false } ); {% endif %} + console.timeEnd("Creating table"); var table = $('#trait_table').DataTable(); -- cgit v1.2.3
Description Location MeanMax LRS ?Max LRS Max LRS LocationAdditive Effect ?Additive Effect