From 717677b0c09f6ba08268db12d4889503cc2606d9 Mon Sep 17 00:00:00 2001 From: zsloan Date: Wed, 2 Nov 2016 20:00:04 +0000 Subject: Added Scroller functionality to regular (but not global) search, which increases table load speed In order to implement Scroller (and make table look nicer), all rows are the same height and excess description/authors text is shown in a tooltip Increased table width for non-Geno DBs Fixed issue where Genotype traits did not fetch their location_repr (text for displaying location), causing that column to be blank in searches Fixed issue causing Correlation Matrix cells to not be colored corresponding with their correlation and also increased cell font a little Fixed issue where dataset link in the Correlation Page did not correctly point to corresponding GN1 page --- wqflask/base/trait.py | 103 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 91 insertions(+), 12 deletions(-) (limited to 'wqflask/base/trait.py') diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py index 276c624a..8788d983 100644 --- a/wqflask/base/trait.py +++ b/wqflask/base/trait.py @@ -91,16 +91,27 @@ class GeneralTrait(object): additive=self.additive ) elif self.dataset.type == "Publish": - return dict(name=self.name, - dataset=self.dataset.name, - description=self.description_display, - authors=self.authors, - pubmed_text=self.pubmed_text, - pubmed_link=self.pubmed_link, - lrs_score=self.LRS_score_repr, - lrs_location=self.LRS_location_repr, - additive=self.additive - ) + if self.pubmed_id: + return dict(name=self.name, + dataset=self.dataset.name, + description=self.description_display, + authors=self.authors, + pubmed_text=self.pubmed_text, + pubmed_link=self.pubmed_link, + lrs_score=self.LRS_score_repr, + lrs_location=self.LRS_location_repr, + additive=self.additive + ) + else: + return dict(name=self.name, + dataset=self.dataset.name, + description=self.description_display, + authors=self.authors, + pubmed_text=self.pubmed_text, + lrs_score=self.LRS_score_repr, + lrs_location=self.LRS_location_repr, + additive=self.additive + ) elif self.dataset.type == "Geno": return dict(name=self.name, dataset=self.dataset.name, @@ -109,6 +120,62 @@ class GeneralTrait(object): else: return dict() + def jsonable_table_row(self, index, search_type): + """Return a list suitable for json and intended to be displayed in a table + + Actual turning into json doesn't happen here though""" + + if self.dataset.type == "ProbeSet": + if self.mean == "": + mean = "N/A" + else: + mean = "%.3f" % round(float(self.additive), 2) + if self.additive == "": + additive = "N/A" + else: + additive = "%.3f" % round(float(self.additive), 2) + return ['', + index, + ''+str(self.name)+'', + self.symbol, + self.description_display, + self.location_repr, + mean, + self.LRS_score_repr, + self.LRS_location_repr, + additive] + elif self.dataset.type == "Publish": + if self.additive == "": + additive = "N/A" + else: + additive = "%.2f" % round(float(self.additive), 2) + if self.pubmed_id: + return ['', + index, + ''+str(self.name)+'', + self.description_display, + self.authors, + '' + self.pubmed_text + '', + self.LRS_score_repr, + self.LRS_location_repr, + additive] + else: + return ['', + index, + ''+str(self.name)+'', + self.description_display, + self.authors, + self.pubmed_text, + self.LRS_score_repr, + self.LRS_location_repr, + additive] + elif self.dataset.type == "Geno": + return ['', + index, + ''+str(self.name)+'', + self.location_repr] + else: + return dict() def get_name(self): stringy = "" @@ -418,7 +485,7 @@ class GeneralTrait(object): self.description_display = description_display #XZ: trait_location_value is used for sorting - trait_location_repr = 'N/A' + self.location_repr = 'N/A' trait_location_value = 1000000 if self.chr and self.mb: @@ -438,6 +505,18 @@ class GeneralTrait(object): self.location_repr = 'Chr%s: %.6f' % (self.chr, float(self.mb)) self.location_value = trait_location_value + elif self.dataset.type == "Geno": + self.location_repr = 'N/A' + trait_location_value = 1000000 + + if self.chr and self.mb: + #Checks if the chromosome number can be cast to an int (i.e. isn't "X" or "Y") + #This is so we can convert the location to a number used for sorting + trait_location_value = convert_location_to_value(self.chr, self.mb) + + #ZS: Put this in function currently called "convert_location_to_value" + self.location_repr = 'Chr%s: %.6f' % (self.chr, float(self.mb)) + self.location_value = trait_location_value if get_qtl_info: #LRS and its location @@ -459,7 +538,7 @@ class GeneralTrait(object): logger.sql(query) trait_qtl = g.db.execute(query).fetchone() if trait_qtl: - self.locus, self.lrs, self.pvalue, self.mean, self.additive= trait_qtl + self.locus, self.lrs, self.pvalue, self.mean, self.additive = trait_qtl if self.locus: query = """ select Geno.Chr, Geno.Mb from Geno, Species -- cgit v1.2.3 From de58be0b8620032261f1f4699856994a4ee164d7 Mon Sep 17 00:00:00 2001 From: zsloan Date: Wed, 2 Nov 2016 21:54:41 +0000 Subject: Added toggleable short and long labels to correlation matrix Fixed issue where I forgot to remove a parameter from jsonable_table_row in trait.py --- wqflask/base/trait.py | 2 +- .../static/new/javascript/create_corr_matrix.js | 22 ++++++++++++++++++ wqflask/wqflask/templates/correlation_matrix.html | 26 ++++++++++++++++++---- 3 files changed, 45 insertions(+), 5 deletions(-) (limited to 'wqflask/base/trait.py') diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py index 8788d983..11a91d1d 100644 --- a/wqflask/base/trait.py +++ b/wqflask/base/trait.py @@ -120,7 +120,7 @@ class GeneralTrait(object): else: return dict() - def jsonable_table_row(self, index, search_type): + def jsonable_table_row(self, index): """Return a list suitable for json and intended to be displayed in a table Actual turning into json doesn't happen here though""" diff --git a/wqflask/wqflask/static/new/javascript/create_corr_matrix.js b/wqflask/wqflask/static/new/javascript/create_corr_matrix.js index a34fc408..44ed3c81 100644 --- a/wqflask/wqflask/static/new/javascript/create_corr_matrix.js +++ b/wqflask/wqflask/static/new/javascript/create_corr_matrix.js @@ -56,4 +56,26 @@ $('.corr_cell').each( function () { else { $(this).css('background-color', 'white') } +}); + +$('#short_labels').click( function (){ + $('.shortName').each( function() { + if ($(this).css("display") == "none"){ + $(this).css("display", "block"); + } + else { + $(this).css("display", "none"); + } + }); +}); + +$('#long_labels').click( function (){ + $('.verboseName').each( function() { + if ($(this).css("display") == "none"){ + $(this).css("display", "block"); + } + else { + $(this).css("display", "none"); + } + }); }); \ No newline at end of file diff --git a/wqflask/wqflask/templates/correlation_matrix.html b/wqflask/wqflask/templates/correlation_matrix.html index d847614a..cd2aa35e 100644 --- a/wqflask/wqflask/templates/correlation_matrix.html +++ b/wqflask/wqflask/templates/correlation_matrix.html @@ -12,11 +12,12 @@ {{ header("Correlation Matrix") }} +
@@ -26,12 +27,26 @@ | P e a r s o n r | {% for trait in traits %} - | Trait{{ loop.index }} | ++ Trait{{ loop.index }} + | {% endfor %}
Trait {{ loop.index }}: {{ trait.dataset.name }}::{{ trait.name }} | ++ Trait {{ loop.index }}: {{ trait.dataset.name }}::{{ trait.name }} + + + | {% for result in corr_results[loop.index-1] %} {% if result[0].name == trait.name %}n {{ result[2] }} |
@@ -43,7 +58,9 @@
{% endfor %}
@@ -122,7 +122,7 @@ {% endblock %} {% block js %} - + @@ -144,10 +144,45 @@ } }); + function change_buttons() { + buttons = ["#add", "#remove"]; + num_checked = $('.trait_checkbox:checked').length; + if (num_checked === 0) { + for (_i = 0, _len = buttons.length; _i < _len; _i++) { + button = buttons[_i]; + $(button).prop("disabled", true); + } + } else { + for (_j = 0, _len2 = buttons.length; _j < _len2; _j++) { + button = buttons[_j]; + $(button).prop("disabled", false); + } + } + //}); + if ($(this).is(":checked")) { + if (!$(this).closest('tr').hasClass('selected')) { + $(this).closest('tr').addClass('selected') + } + } + else { + if ($(this).closest('tr').hasClass('selected')) { + $(this).closest('tr').removeClass('selected') + } + } + } + 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) { + if (event.target.type !== 'checkbox') { + $(':checkbox', this).trigger('click'); + } + }); + $('.trait_checkbox:checkbox').on("change", change_buttons); + }, "createdRow": function ( row, data, index ) { $('td', row).eq(1).attr('align', 'right'); $('td', row).eq(1).attr('data-export', index+1); @@ -187,7 +222,7 @@ "iDisplayLength": -1, "deferRender": true, "bSortClasses": false, - "scrollY": "700px", + "scrollY": true, "scrollCollapse": false, "scroller": true, "paging": false @@ -195,6 +230,14 @@ {% elif dataset.type == 'Publish' %} $('#trait_table').DataTable( { + "drawCallback": function( settings ) { + $('#trait_table tr').click(function(event) { + if (event.target.type !== 'checkbox') { + $(':checkbox', this).trigger('click'); + } + }); + $('.trait_checkbox:checkbox').on("change", change_buttons); + }, "createdRow": function ( row, data, index ) { $('td', row).eq(1).attr('align', 'right'); $('td', row).eq(1).attr('data-export', index+1); @@ -234,13 +277,21 @@ "autoWidth": false, "deferRender": true, "bSortClasses": false, - "scrollY": "700px", + "scrollY": true, "scrollCollapse": true, "scroller": true, "paging": false } ); {% elif dataset.type == 'Geno' %} $('#trait_table').DataTable( { + "drawCallback": function( settings ) { + $('#trait_table tr').click(function(event) { + if (event.target.type !== 'checkbox') { + $(':checkbox', this).trigger('click'); + } + }); + $('.trait_checkbox:checkbox').on("change", change_buttons); + }, "createdRow": function ( row, data, index ) { $('td', row).eq(1).attr('align', 'right'); $('td', row).eq(1).attr('data-export', index+1); @@ -260,7 +311,7 @@ "autoWidth": false, "deferRender": true, "bSortClasses": false, - "scrollY": "700px", + "scrollY": true, "scrollCollapse": true, "scroller": true, "paging": false -- cgit v1.2.3 From 8e8cb3540565edb3d221ef08fe3863449c29c21d Mon Sep 17 00:00:00 2001 From: zsloan Date: Tue, 15 Nov 2016 19:27:36 +0000 Subject: Fixed issue where sample values of 0 would sometimes be displayed as 'x', which would result in wrong correlation results Fixed issue where the mean would sometimes be displayed into of the additive effect --- wqflask/base/trait.py | 2 +- wqflask/base/webqtlCaseData.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'wqflask/base/trait.py') diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py index c8c503e2..295502b3 100644 --- a/wqflask/base/trait.py +++ b/wqflask/base/trait.py @@ -131,7 +131,7 @@ class GeneralTrait(object): if self.mean == "": mean = "N/A" else: - mean = "%.3f" % round(float(self.additive), 2) + mean = "%.3f" % round(float(self.mean), 2) if self.additive == "": additive = "N/A" else: diff --git a/wqflask/base/webqtlCaseData.py b/wqflask/base/webqtlCaseData.py index 2f88f778..627b2f6c 100644 --- a/wqflask/base/webqtlCaseData.py +++ b/wqflask/base/webqtlCaseData.py @@ -66,7 +66,7 @@ class webqtlCaseData(object): @property def display_value(self): - if self.value: + if self.value != None: return "%2.3f" % self.value else: return "x" -- cgit v1.2.3 From 3d710be17bedbd6f798cc783ac2f402465c79096 Mon Sep 17 00:00:00 2001 From: zsloan Date: Mon, 12 Dec 2016 22:17:08 +0000 Subject: Moved a bunch of functions out of the GeneralTrait class that didn't need to be there and changed the code that calls them accordingly Improved loadings plot on the correlation matrix page to look like GN1's figure (though it's vector and GN1's was static) Removed some unused code from show_trait.py changed appearance of table headers some, though needs a little more work Updated dataset_menu_structure.json --- wqflask/base/trait.py | 1020 +++++++++----------- wqflask/base/webqtlCaseData.py | 12 +- wqflask/maintenance/gen_select_dataset.py | 33 +- wqflask/wqflask/collect.py | 10 +- wqflask/wqflask/ctl/ctl_analysis.py | 2 +- wqflask/wqflask/gsearch.py | 1 + wqflask/wqflask/search_results.py | 6 +- wqflask/wqflask/show_trait/show_trait.py | 463 +-------- .../new/javascript/dataset_menu_structure.json | 321 +++--- .../wqflask/static/new/javascript/loadings_plot.js | 19 +- .../packages/DataTables/css/jquery.dataTables.css | 10 +- .../static/packages/bootstrap/css/bootstrap.css | 2 +- wqflask/wqflask/templates/gsearch_gene.html | 4 +- wqflask/wqflask/templates/search_result_page.html | 14 +- 14 files changed, 685 insertions(+), 1232 deletions(-) (limited to 'wqflask/base/trait.py') diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py index 295502b3..ab0e6b82 100644 --- a/wqflask/base/trait.py +++ b/wqflask/base/trait.py @@ -57,6 +57,7 @@ class GeneralTrait(object): self.lrs = None self.pvalue = None self.mean = None + self.additive = None self.num_overlap = None self.strand_probe = None self.symbol = None @@ -71,114 +72,11 @@ 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_info(get_qtl_info=get_qtl_info) + self = retrieve_trait_info(self, self.dataset, get_qtl_info=get_qtl_info) if get_sample_info != False: - self.retrieve_sample_data() + self = retrieve_sample_data(self, self.dataset) - def jsonable(self): - """Return a dict suitable for using as json - - Actual turning into json doesn't happen here though""" - - if self.dataset.type == "ProbeSet": - return dict(name=self.name, - symbol=self.symbol, - dataset=self.dataset.name, - description=self.description_display, - mean=self.mean, - location=self.location_repr, - lrs_score=self.LRS_score_repr, - lrs_location=self.LRS_location_repr, - additive=self.additive - ) - elif self.dataset.type == "Publish": - if self.pubmed_id: - return dict(name=self.name, - dataset=self.dataset.name, - description=self.description_display, - authors=self.authors, - pubmed_text=self.pubmed_text, - pubmed_link=self.pubmed_link, - lrs_score=self.LRS_score_repr, - lrs_location=self.LRS_location_repr, - additive=self.additive - ) - else: - return dict(name=self.name, - dataset=self.dataset.name, - description=self.description_display, - authors=self.authors, - pubmed_text=self.pubmed_text, - lrs_score=self.LRS_score_repr, - lrs_location=self.LRS_location_repr, - additive=self.additive - ) - elif self.dataset.type == "Geno": - return dict(name=self.name, - dataset=self.dataset.name, - location=self.location_repr - ) - else: - return dict() - - def jsonable_table_row(self, index): - """Return a list suitable for json and intended to be displayed in a table - - Actual turning into json doesn't happen here though""" - - if self.dataset.type == "ProbeSet": - if self.mean == "": - mean = "N/A" - else: - mean = "%.3f" % round(float(self.mean), 2) - if self.additive == "": - additive = "N/A" - else: - additive = "%.3f" % round(float(self.additive), 2) - return ['', - index, - ''+str(self.name)+'', - self.symbol, - self.description_display, - self.location_repr, - mean, - self.LRS_score_repr, - self.LRS_location_repr, - additive] - elif self.dataset.type == "Publish": - if self.additive == "": - additive = "N/A" - else: - additive = "%.2f" % round(float(self.additive), 2) - if self.pubmed_id: - return ['', - index, - ''+str(self.name)+'', - self.description_display, - self.authors, - '' + self.pubmed_text + '', - self.LRS_score_repr, - self.LRS_location_repr, - additive] - else: - return ['', - index, - ''+str(self.name)+'', - self.description_display, - self.authors, - self.pubmed_text, - self.LRS_score_repr, - self.LRS_location_repr, - additive] - elif self.dataset.type == "Geno": - return ['', - index, - ''+str(self.name)+'', - self.location_repr] - else: - return dict() - def get_name(self): stringy = "" if self.dataset and self.name: @@ -282,422 +180,6 @@ class GeneralTrait(object): return samples, vals, the_vars, sample_aliases - # - # In ProbeSet, there are maybe several annotations match one sequence - # so we need use sequence(BlatSeq) as the identification, when we update - # one annotation, we update the others who match the sequence also. - # - # Hongqiang Li, 3/3/2008 - # - #def getSequence(self): - # assert self.cursor - # if self.dataset.type == 'ProbeSet': - # self.cursor.execute(''' - # SELECT - # ProbeSet.BlatSeq - # FROM - # ProbeSet, ProbeSetFreeze, ProbeSetXRef - # WHERE - # ProbeSet.Id=ProbeSetXRef.ProbeSetId and - # ProbeSetFreeze.Id = ProbeSetXRef.ProbSetFreezeId and - # ProbeSet.Name = %s - # ProbeSetFreeze.Name = %s - # ''', self.name, self.dataset.name) - # #self.cursor.execute(query) - # results = self.fetchone() - # - # return results[0] - - - - def retrieve_sample_data(self, samplelist=None): - if samplelist == None: - samplelist = [] - - results = self.dataset.retrieve_sample_data(self.name) - - # Todo: is this necessary? If not remove - self.data.clear() - - all_samples_ordered = self.dataset.group.all_samples_ordered() - - if results: - for item in results: - name, value, variance, num_cases, name2 = item - if not samplelist or (samplelist and name in samplelist): - self.data[name] = webqtlCaseData(*item) #name, value, variance, num_cases) - - def retrieve_info(self, get_qtl_info=False): - assert self.dataset, "Dataset doesn't exist" - if self.dataset.type == 'Publish': - query = """ - SELECT - PublishXRef.Id, Publication.PubMed_ID, - Phenotype.Pre_publication_description, Phenotype.Post_publication_description, Phenotype.Original_description, - Phenotype.Pre_publication_abbreviation, Phenotype.Post_publication_abbreviation, - Phenotype.Lab_code, Phenotype.Submitter, Phenotype.Owner, Phenotype.Authorized_Users, - Publication.Authors, Publication.Title, Publication.Abstract, - Publication.Journal, Publication.Volume, Publication.Pages, - Publication.Month, Publication.Year, PublishXRef.Sequence, - Phenotype.Units, PublishXRef.comments - FROM - PublishXRef, Publication, Phenotype, PublishFreeze - WHERE - PublishXRef.Id = %s AND - Phenotype.Id = PublishXRef.PhenotypeId AND - Publication.Id = PublishXRef.PublicationId AND - PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND - PublishFreeze.Id = %s - """ % (self.name, self.dataset.id) - - logger.sql(query) - trait_info = g.db.execute(query).fetchone() - - - #XZ, 05/08/2009: Xiaodong add this block to use ProbeSet.Id to find the probeset instead of just using ProbeSet.Name - #XZ, 05/08/2009: to avoid the problem of same probeset name from different platforms. - elif self.dataset.type == 'ProbeSet': - display_fields_string = ', ProbeSet.'.join(self.dataset.display_fields) - display_fields_string = 'ProbeSet.' + display_fields_string - query = """ - SELECT %s - FROM ProbeSet, ProbeSetFreeze, ProbeSetXRef - WHERE - ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id AND - ProbeSetXRef.ProbeSetId = ProbeSet.Id AND - ProbeSetFreeze.Name = '%s' AND - ProbeSet.Name = '%s' - """ % (escape(display_fields_string), - escape(self.dataset.name), - escape(str(self.name))) - logger.sql(query) - trait_info = g.db.execute(query).fetchone() - #XZ, 05/08/2009: We also should use Geno.Id to find marker instead of just using Geno.Name - # to avoid the problem of same marker name from different species. - elif self.dataset.type == 'Geno': - display_fields_string = string.join(self.dataset.display_fields,',Geno.') - display_fields_string = 'Geno.' + display_fields_string - query = """ - SELECT %s - FROM Geno, GenoFreeze, GenoXRef - WHERE - GenoXRef.GenoFreezeId = GenoFreeze.Id AND - GenoXRef.GenoId = Geno.Id AND - GenoFreeze.Name = '%s' AND - Geno.Name = '%s' - """ % (escape(display_fields_string), - escape(self.dataset.name), - escape(self.name)) - logger.sql(query) - trait_info = g.db.execute(query).fetchone() - else: #Temp type - query = """SELECT %s FROM %s WHERE Name = %s""" - logger.sql(query) - trait_info = g.db.execute(query, - (string.join(self.dataset.display_fields,','), - self.dataset.type, self.name)).fetchone() - if trait_info: - self.haveinfo = True - - #XZ: assign SQL query result to trait attributes. - for i, field in enumerate(self.dataset.display_fields): - holder = trait_info[i] - if isinstance(trait_info[i], basestring): - holder = unicode(trait_info[i], "utf8", "ignore") - setattr(self, field, holder) - - if self.dataset.type == 'Publish': - self.confidential = 0 - if self.pre_publication_description and not self.pubmed_id: - self.confidential = 1 - - description = self.post_publication_description - - #If the dataset is confidential and the user has access to confidential - #phenotype traits, then display the pre-publication description instead - #of the post-publication description - if self.confidential: - self.description_display = self.pre_publication_description - - #if not webqtlUtil.hasAccessToConfidentialPhenotypeTrait( - # privilege=self.dataset.privilege, - # userName=self.dataset.userName, - # authorized_users=self.authorized_users): - # - # description = self.pre_publication_description - else: - if description: - self.description_display = description.strip() - else: - self.description_display = "" - - if not self.year.isdigit(): - self.pubmed_text = "N/A" - else: - self.pubmed_text = self.year - - if self.pubmed_id: - self.pubmed_link = webqtlConfig.PUBMEDLINK_URL % self.pubmed_id - - - self.homologeneid = None - if self.dataset.type == 'ProbeSet' and self.dataset.group: - if self.geneid: - #XZ, 05/26/2010: From time to time, this query get error message because some geneid values in database are not number. - #XZ: So I have to test if geneid is number before execute the query. - #XZ: The geneid values in database should be cleaned up. - #try: - # float(self.geneid) - # geneidIsNumber = True - #except ValueError: - # geneidIsNumber = False - #if geneidIsNumber: - query = """ - SELECT - HomologeneId - FROM - Homologene, Species, InbredSet - WHERE - Homologene.GeneId ='%s' AND - InbredSet.Name = '%s' AND - InbredSet.SpeciesId = Species.Id AND - Species.TaxonomyId = Homologene.TaxonomyId - """ % (escape(str(self.geneid)), escape(self.dataset.group.name)) - logger.sql(query) - result = g.db.execute(query).fetchone() - #else: - # result = None - - if result: - self.homologeneid = result[0] - - description_string = unicode(str(self.description).strip(codecs.BOM_UTF8), 'utf-8') - target_string = unicode(str(self.probe_target_description).strip(codecs.BOM_UTF8), 'utf-8') - - if len(description_string) > 1 and description_string != 'None': - description_display = description_string - else: - description_display = self.symbol - - if (len(description_display) > 1 and description_display != 'N/A' and - len(target_string) > 1 and target_string != 'None'): - description_display = description_display + '; ' + target_string.strip() - - # Save it for the jinja2 template - self.description_display = description_display - - #XZ: trait_location_value is used for sorting - self.location_repr = 'N/A' - self.location_value = 1000000 - - if self.chr and self.mb: - #Checks if the chromosome number can be cast to an int (i.e. isn't "X" or "Y") - #This is so we can convert the location to a number used for sorting - trait_location_value = convert_location_to_value(self.chr, self.mb) - #try: - # trait_location_value = int(self.chr)*1000 + self.mb - #except ValueError: - # if self.chr.upper() == 'X': - # trait_location_value = 20*1000 + self.mb - # else: - # trait_location_value = (ord(str(self.chr).upper()[0])*1000 + - # self.mb) - - #ZS: Put this in function currently called "convert_location_to_value" - self.location_repr = 'Chr%s: %.6f' % (self.chr, float(self.mb)) - self.location_value = trait_location_value - - elif self.dataset.type == "Geno": - self.location_repr = 'N/A' - self.location_value = 1000000 - - if self.chr and self.mb: - #Checks if the chromosome number can be cast to an int (i.e. isn't "X" or "Y") - #This is so we can convert the location to a number used for sorting - trait_location_value = convert_location_to_value(self.chr, self.mb) - - #ZS: Put this in function currently called "convert_location_to_value" - self.location_repr = 'Chr%s: %.6f' % (self.chr, float(self.mb)) - self.location_value = trait_location_value - - if get_qtl_info: - #LRS and its location - self.LRS_score_repr = "N/A" - self.LRS_score_value = 0 - self.LRS_location_repr = "N/A" - self.LRS_location_value = 1000000 - if self.dataset.type == 'ProbeSet' and not self.cellid: - query = """ - SELECT - ProbeSetXRef.Locus, ProbeSetXRef.LRS, ProbeSetXRef.pValue, ProbeSetXRef.mean, ProbeSetXRef.additive - FROM - ProbeSetXRef, ProbeSet - WHERE - ProbeSetXRef.ProbeSetId = ProbeSet.Id AND - ProbeSet.Name = "{}" AND - ProbeSetXRef.ProbeSetFreezeId ={} - """.format(self.name, self.dataset.id) - logger.sql(query) - trait_qtl = g.db.execute(query).fetchone() - if trait_qtl: - self.locus, self.lrs, self.pvalue, self.mean, self.additive = trait_qtl - if self.locus: - query = """ - select Geno.Chr, Geno.Mb from Geno, Species - where Species.Name = '{}' and - Geno.Name = '{}' and - Geno.SpeciesId = Species.Id - """.format(self.dataset.group.species, self.locus) - logger.sql(query) - result = g.db.execute(query).fetchone() - if result: - self.locus_chr = result[0] - self.locus_mb = result[1] - else: - self.locus = self.locus_chr = self.locus_mb = self.additive = "" - else: - self.locus = self.locus_chr = self.locus_mb = self.additive = "" - else: - self.locus = self.locus_chr = self.locus_mb = self.lrs = self.pvalue = self.mean = self.additive = "" - - - if self.dataset.type == 'Publish': - query = """ - SELECT - PublishXRef.Locus, PublishXRef.LRS, PublishXRef.additive - FROM - PublishXRef, PublishFreeze - WHERE - PublishXRef.Id = %s AND - PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND - PublishFreeze.Id =%s - """ % (self.name, self.dataset.id) - logger.sql(query) - trait_qtl = g.db.execute(query).fetchone() - if trait_qtl: - self.locus, self.lrs, self.additive = trait_qtl - if self.locus: - query = """ - select Geno.Chr, Geno.Mb from Geno, Species - where Species.Name = '{}' and - Geno.Name = '{}' and - Geno.SpeciesId = Species.Id - """.format(self.dataset.group.species, self.locus) - logger.sql(query) - result = g.db.execute(query).fetchone() - if result: - self.locus_chr = result[0] - self.locus_mb = result[1] - else: - self.locus = self.locus_chr = self.locus_mb = self.additive = "" - else: - self.locus = self.locus_chr = self.locus_mb = self.additive = "" - else: - self.locus = self.lrs = self.additive = "" - - if (self.dataset.type == 'Publish' or self.dataset.type == "ProbeSet") and self.locus_chr != "" and self.locus_mb != "": - #XZ: LRS_location_value is used for sorting - try: - LRS_location_value = int(self.locus_chr)*1000 + float(self.locus_mb) - except: - if self.locus_chr.upper() == 'X': - LRS_location_value = 20*1000 + float(self.locus_mb) - else: - LRS_location_value = ord(str(self.locus_chr).upper()[0])*1000 + float(self.locus_mb) - - self.LRS_location_repr = LRS_location_repr = 'Chr%s: %.6f' % (self.locus_chr, float(self.locus_mb)) - if self.lrs != "": - self.LRS_score_repr = LRS_score_repr = '%3.1f' % self.lrs - self.LRS_score_value = LRS_score_value = self.lrs - else: - raise KeyError, `self.name`+' information is not found in the database.' - - def genHTML(self, formName = "", dispFromDatabase=0, privilege="guest", userName="Guest", authorized_users=""): - if not self.haveinfo: - self.retrieveInfo() - - if self.dataset.type == 'Publish': - PubMedLink = "" - if self.pubmed_id: - PubMedLink = HT.Href(text="PubMed %d : " % self.pubmed_id, - target = "_blank", url = webqtlConfig.PUBMEDLINK_URL % self.pubmed_id) - else: - PubMedLink = HT.Span("Unpublished : ", Class="fs15") - - if formName: - setDescription2 = HT.Href(url="javascript:showDatabase3('%s','%s','%s','')" % - (formName, self.dataset.name, self.name), Class = "fs14") - else: - setDescription2 = HT.Href(url="javascript:showDatabase2('%s','%s','')" % - (self.dataset.name,self.name), Class = "fs14") - - if self.confidential and not webqtlUtil.hasAccessToConfidentialPhenotypeTrait(privilege=privilege, userName=userName, authorized_users=authorized_users): - setDescription2.append('RecordID/%s - %s' % (self.name, self.pre_publication_description)) - else: - setDescription2.append('RecordID/%s - %s' % (self.name, self.post_publication_description)) - - #XZ 03/26/2011: Xiaodong comment out the following two lins as Rob asked. Need to check with Rob why in PublishXRef table, there are few row whose Sequence > 1. - #if self.sequence > 1: - # setDescription2.append(' btach %d' % self.sequence) - if self.authors: - a1 = string.split(self.authors,',')[0] - while a1[0] == '"' or a1[0] == "'" : - a1 = a1[1:] - setDescription2.append(' by ') - setDescription2.append(HT.Italic('%s, and colleagues' % a1)) - setDescription = HT.Span(PubMedLink, setDescription2) - - elif self.dataset.type == 'Temp': - setDescription = HT.Href(text="%s" % (self.description),url="javascript:showDatabase2\ - ('%s','%s','')" % (self.dataset.name,self.name), Class = "fs14") - setDescription = HT.Span(setDescription) - - elif self.dataset.type == 'Geno': # Genome DB only available for single search - if formName: - setDescription = HT.Href(text="Locus %s [Chr %s @ %s Mb]" % (self.name,self.chr,\ - '%2.3f' % self.mb),url="javascript:showDatabase3('%s','%s','%s','')" % \ - (formName, self.dataset.name, self.name), Class = "fs14") - else: - setDescription = HT.Href(text="Locus %s [Chr %s @ %s Mb]" % (self.name,self.chr,\ - '%2.3f' % self.mb),url="javascript:showDatabase2('%s','%s','')" % \ - (self.dataset.name,self.name), Class = "fs14") - - setDescription = HT.Span(setDescription) - - else: - if self.cellid: - if formName: - setDescription = HT.Href(text="ProbeSet/%s/%s" % (self.name, self.cellid),url=\ - "javascript:showDatabase3('%s','%s','%s','%s')" % (formName, self.dataset.name,self.name,self.cellid), \ - Class = "fs14") - else: - setDescription = HT.Href(text="ProbeSet/%s/%s" % (self.name,self.cellid),url=\ - "javascript:showDatabase2('%s','%s','%s')" % (self.dataset.name,self.name,self.cellid), \ - Class = "fs14") - else: - if formName: - setDescription = HT.Href(text="ProbeSet/%s" % self.name, url=\ - "javascript:showDatabase3('%s','%s','%s','')" % (formName, self.dataset.name,self.name), \ - Class = "fs14") - else: - setDescription = HT.Href(text="ProbeSet/%s" % self.name, url=\ - "javascript:showDatabase2('%s','%s','')" % (self.dataset.name,self.name), \ - Class = "fs14") - if self.symbol and self.chr and self.mb: - setDescription.append(' [') - setDescription.append(HT.Italic('%s' % self.symbol,Class="cdg fwb")) - setDescription.append(' on Chr %s @ %s Mb]' % (self.chr,self.mb)) - if self.description: - setDescription.append(': %s' % self.description) - if self.probe_target_description: - setDescription.append('; %s' % self.probe_target_description) - setDescription = HT.Span(setDescription) - - if self.dataset.type != 'Temp' and dispFromDatabase: - setDescription.append( ' --- FROM : ') - setDescription.append(self.dataset.genHTML(Class='cori')) - return setDescription - @property def name_header_fmt(self): '''Return a human-readable name for use in page header''' @@ -763,62 +245,51 @@ class GeneralTrait(object): return fmt - - def get_database(self): - """ - Returns the database, and the url referring to the database if it exists - - We're going to to return two values here, and we don't want to have to call this twice from - the template. So it's not a property called from the template, but instead is called from the view - - """ - if self.cellid: - query = """ select ProbeFreeze.Name from ProbeFreeze, ProbeSetFreeze where - ProbeFreeze.Id = - ProbeSetFreeze.ProbeFreezeId AND - ProbeSetFreeze.Id = %d""" % thisTrait.dataset.id - logger.sql(query) - probeDBName = g.db.execute(query).fetchone()[0] - return dict(name = probeDBName, - url = None) - else: - return dict(name = self.dataset.fullname, - url = webqtlConfig.INFOPAGEHREF % self.dataset.name) - - def calculate_correlation(self, values, method): - """Calculate the correlation value and p value according to the method specified""" - - #ZS: This takes the list of values of the trait our selected trait is being correlated against and removes the values of the samples our trait has no value for - #There's probably a better way of dealing with this, but I'll have to ask Christian - updated_raw_values = [] - updated_values = [] - for i in range(len(values)): - if values[i] != "None": - updated_raw_values.append(self.raw_values[i]) - updated_values.append(values[i]) - - self.raw_values = updated_raw_values - values = updated_values - - if method == METHOD_SAMPLE_PEARSON or method == METHOD_LIT or method == METHOD_TISSUE_PEARSON: - corr, nOverlap = webqtlUtil.calCorrelation(self.raw_values, values, len(values)) - else: - corr, nOverlap = webqtlUtil.calCorrelationRank(self.raw_values, values, len(values)) - - self.correlation = corr - self.overlap = nOverlap - - if self.overlap < 3: - self.p_value = 1.0 - else: - #ZS - This is probably the wrong way to deal with this. Correlation values of 1.0 definitely exist (the trait correlated against itself), so zero division needs to br prevented. - if abs(self.correlation) >= 1.0: - self.p_value = 0.0 - else: - ZValue = 0.5*log((1.0+self.correlation)/(1.0-self.correlation)) - ZValue = ZValue*sqrt(self.overlap-3) - self.p_value = 2.0*(1.0 - reaper.normp(abs(ZValue))) - +# In ProbeSet, there are maybe several annotations match one sequence +# so we need use sequence(BlatSeq) as the identification, when we update +# one annotation, we update the others who match the sequence also. +# +# Hongqiang Li, 3/3/2008 +def getSequence(trait, dataset_name): + dataset = create_dataset(dataset_name) + + if dataset.type == 'ProbeSet': + results = g.db.execute(''' + SELECT + ProbeSet.BlatSeq + FROM + ProbeSet, ProbeSetFreeze, ProbeSetXRef + WHERE + ProbeSet.Id=ProbeSetXRef.ProbeSetId and + ProbeSetFreeze.Id = ProbeSetXRef.ProbSetFreezeId and + ProbeSet.Name = %s + ProbeSetFreeze.Name = %s + ''', trait.name, dataset.name).fetchone() + + return results[0] + +def retrieve_sample_data(trait, dataset_name, samplelist=None): + + dataset = create_dataset(dataset_name) + + if samplelist == None: + samplelist = [] + + results = dataset.retrieve_sample_data(trait.name) + + # Todo: is this necessary? If not remove + trait.data.clear() + + all_samples_ordered = dataset.group.all_samples_ordered() + + if results: + for item in results: + name, value, variance, num_cases, name2 = item + if not samplelist or (samplelist and name in samplelist): + trait.data[name] = webqtlCaseData(*item) #name, value, variance, num_cases) + + return trait + def convert_location_to_value(chromosome, mb): try: location_value = int(chromosome)*1000 + float(mb) @@ -846,3 +317,398 @@ def get_sample_data(): # jsonable_sample_data[sample] = trait_ob.data[sample].value # #return jsonable_sample_data + +def jsonable(trait, dataset_name): + """Return a dict suitable for using as json + + Actual turning into json doesn't happen here though""" + + dataset = create_dataset(dataset_name) + + if dataset.type == "ProbeSet": + return dict(name=trait.name, + symbol=trait.symbol, + dataset=dataset.name, + description=trait.description_display, + mean=trait.mean, + location=trait.location_repr, + lrs_score=trait.LRS_score_repr, + lrs_location=trait.LRS_location_repr, + additive=trait.additive + ) + elif dataset.type == "Publish": + if trait.pubmed_id: + return dict(name=trait.name, + dataset=dataset.name, + description=trait.description_display, + authors=trait.authors, + pubmed_text=trait.pubmed_text, + pubmed_link=trait.pubmed_link, + lrs_score=trait.LRS_score_repr, + lrs_location=trait.LRS_location_repr, + additive=trait.additive + ) + else: + return dict(name=trait.name, + dataset=dataset.name, + description=trait.description_display, + authors=trait.authors, + pubmed_text=trait.pubmed_text, + lrs_score=trait.LRS_score_repr, + lrs_location=trait.LRS_location_repr, + additive=trait.additive + ) + elif dataset.type == "Geno": + return dict(name=trait.name, + dataset=dataset.name, + location=trait.location_repr + ) + else: + return dict() + +def jsonable_table_row(trait, dataset_name, index): + """Return a list suitable for json and intended to be displayed in a table + + Actual turning into json doesn't happen here though""" + + dataset = create_dataset(dataset_name) + + if dataset.type == "ProbeSet": + if trait.mean == "": + mean = "N/A" + else: + mean = "%.3f" % round(float(trait.mean), 2) + if trait.additive == "": + additive = "N/A" + else: + additive = "%.3f" % round(float(trait.additive), 2) + return ['', + index, + ''+str(trait.name)+'', + trait.symbol, + trait.description_display, + trait.location_repr, + mean, + trait.LRS_score_repr, + trait.LRS_location_repr, + additive] + elif dataset.type == "Publish": + if trait.additive == "": + additive = "N/A" + else: + additive = "%.2f" % round(float(trait.additive), 2) + if trait.pubmed_id: + return ['', + index, + ''+str(trait.name)+'', + trait.description_display, + trait.authors, + '' + trait.pubmed_text + '', + trait.LRS_score_repr, + trait.LRS_location_repr, + additive] + else: + return ['', + index, + ''+str(trait.name)+'', + trait.description_display, + trait.authors, + trait.pubmed_text, + trait.LRS_score_repr, + trait.LRS_location_repr, + additive] + elif dataset.type == "Geno": + return ['', + index, + ''+str(trait.name)+'', + trait.location_repr] + else: + return dict() + +def retrieve_trait_info(trait, dataset, get_qtl_info=False): + assert dataset, "Dataset doesn't exist" + + if dataset.type == 'Publish': + query = """ + SELECT + PublishXRef.Id, Publication.PubMed_ID, + Phenotype.Pre_publication_description, Phenotype.Post_publication_description, Phenotype.Original_description, + Phenotype.Pre_publication_abbreviation, Phenotype.Post_publication_abbreviation, + Phenotype.Lab_code, Phenotype.Submitter, Phenotype.Owner, Phenotype.Authorized_Users, + Publication.Authors, Publication.Title, Publication.Abstract, + Publication.Journal, Publication.Volume, Publication.Pages, + Publication.Month, Publication.Year, PublishXRef.Sequence, + Phenotype.Units, PublishXRef.comments + FROM + PublishXRef, Publication, Phenotype, PublishFreeze + WHERE + PublishXRef.Id = %s AND + Phenotype.Id = PublishXRef.PhenotypeId AND + Publication.Id = PublishXRef.PublicationId AND + PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND + PublishFreeze.Id = %s + """ % (trait.name, dataset.id) + + logger.sql(query) + trait_info = g.db.execute(query).fetchone() + + + #XZ, 05/08/2009: Xiaodong add this block to use ProbeSet.Id to find the probeset instead of just using ProbeSet.Name + #XZ, 05/08/2009: to avoid the problem of same probeset name from different platforms. + elif dataset.type == 'ProbeSet': + display_fields_string = ', ProbeSet.'.join(dataset.display_fields) + display_fields_string = 'ProbeSet.' + display_fields_string + query = """ + SELECT %s + FROM ProbeSet, ProbeSetFreeze, ProbeSetXRef + WHERE + ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id AND + ProbeSetXRef.ProbeSetId = ProbeSet.Id AND + ProbeSetFreeze.Name = '%s' AND + ProbeSet.Name = '%s' + """ % (escape(display_fields_string), + escape(dataset.name), + escape(str(trait.name))) + logger.sql(query) + trait_info = g.db.execute(query).fetchone() + #XZ, 05/08/2009: We also should use Geno.Id to find marker instead of just using Geno.Name + # to avoid the problem of same marker name from different species. + elif dataset.type == 'Geno': + display_fields_string = string.join(dataset.display_fields,',Geno.') + display_fields_string = 'Geno.' + display_fields_string + query = """ + SELECT %s + FROM Geno, GenoFreeze, GenoXRef + WHERE + GenoXRef.GenoFreezeId = GenoFreeze.Id AND + GenoXRef.GenoId = Geno.Id AND + GenoFreeze.Name = '%s' AND + Geno.Name = '%s' + """ % (escape(display_fields_string), + escape(dataset.name), + escape(trait.name)) + logger.sql(query) + trait_info = g.db.execute(query).fetchone() + else: #Temp type + query = """SELECT %s FROM %s WHERE Name = %s""" + logger.sql(query) + trait_info = g.db.execute(query, + (string.join(dataset.display_fields,','), + dataset.type, trait.name)).fetchone() + if trait_info: + trait.haveinfo = True + + #XZ: assign SQL query result to trait attributes. + for i, field in enumerate(dataset.display_fields): + holder = trait_info[i] + if isinstance(trait_info[i], basestring): + holder = unicode(trait_info[i], "utf8", "ignore") + setattr(trait, field, holder) + + if dataset.type == 'Publish': + trait.confidential = 0 + if trait.pre_publication_description and not trait.pubmed_id: + trait.confidential = 1 + + description = trait.post_publication_description + + #If the dataset is confidential and the user has access to confidential + #phenotype traits, then display the pre-publication description instead + #of the post-publication description + if trait.confidential: + trait.description_display = trait.pre_publication_description + + #if not webqtlUtil.hasAccessToConfidentialPhenotypeTrait( + # privilege=self.dataset.privilege, + # userName=self.dataset.userName, + # authorized_users=self.authorized_users): + # + # description = self.pre_publication_description + else: + if description: + trait.description_display = description.strip() + else: + trait.description_display = "" + + if not trait.year.isdigit(): + trait.pubmed_text = "N/A" + else: + trait.pubmed_text = trait.year + + if trait.pubmed_id: + trait.pubmed_link = webqtlConfig.PUBMEDLINK_URL % trait.pubmed_id + + + trait.homologeneid = None + if dataset.type == 'ProbeSet' and dataset.group: + if trait.geneid: + #XZ, 05/26/2010: From time to time, this query get error message because some geneid values in database are not number. + #XZ: So I have to test if geneid is number before execute the query. + #XZ: The geneid values in database should be cleaned up. + #try: + # float(self.geneid) + # geneidIsNumber = True + #except ValueError: + # geneidIsNumber = False + #if geneidIsNumber: + query = """ + SELECT + HomologeneId + FROM + Homologene, Species, InbredSet + WHERE + Homologene.GeneId ='%s' AND + InbredSet.Name = '%s' AND + InbredSet.SpeciesId = Species.Id AND + Species.TaxonomyId = Homologene.TaxonomyId + """ % (escape(str(trait.geneid)), escape(dataset.group.name)) + logger.sql(query) + result = g.db.execute(query).fetchone() + #else: + # result = None + + if result: + trait.homologeneid = result[0] + + description_string = unicode(str(trait.description).strip(codecs.BOM_UTF8), 'utf-8') + target_string = unicode(str(trait.probe_target_description).strip(codecs.BOM_UTF8), 'utf-8') + + if len(description_string) > 1 and description_string != 'None': + description_display = description_string + else: + description_display = trait.symbol + + if (len(description_display) > 1 and description_display != 'N/A' and + len(target_string) > 1 and target_string != 'None'): + description_display = description_display + '; ' + target_string.strip() + + # Save it for the jinja2 template + trait.description_display = description_display + + #XZ: trait_location_value is used for sorting + trait.location_repr = 'N/A' + trait.location_value = 1000000 + + if trait.chr and trait.mb: + #Checks if the chromosome number can be cast to an int (i.e. isn't "X" or "Y") + #This is so we can convert the location to a number used for sorting + trait_location_value = convert_location_to_value(trait.chr, trait.mb) + #try: + # trait_location_value = int(self.chr)*1000 + self.mb + #except ValueError: + # if self.chr.upper() == 'X': + # trait_location_value = 20*1000 + self.mb + # else: + # trait_location_value = (ord(str(self.chr).upper()[0])*1000 + + # self.mb) + + #ZS: Put this in function currently called "convert_location_to_value" + trait.location_repr = 'Chr%s: %.6f' % (trait.chr, float(trait.mb)) + trait.location_value = trait_location_value + + elif dataset.type == "Geno": + trait.location_repr = 'N/A' + trait.location_value = 1000000 + + if trait.chr and trait.mb: + #Checks if the chromosome number can be cast to an int (i.e. isn't "X" or "Y") + #This is so we can convert the location to a number used for sorting + trait_location_value = convert_location_to_value(trait.chr, trait.mb) + + #ZS: Put this in function currently called "convert_location_to_value" + trait.location_repr = 'Chr%s: %.6f' % (trait.chr, float(trait.mb)) + trait.location_value = trait_location_value + + if get_qtl_info: + #LRS and its location + trait.LRS_score_repr = "N/A" + trait.LRS_score_value = 0 + trait.LRS_location_repr = "N/A" + trait.LRS_location_value = 1000000 + if dataset.type == 'ProbeSet' and not trait.cellid: + query = """ + SELECT + ProbeSetXRef.Locus, ProbeSetXRef.LRS, ProbeSetXRef.pValue, ProbeSetXRef.mean, ProbeSetXRef.additive + FROM + ProbeSetXRef, ProbeSet + WHERE + ProbeSetXRef.ProbeSetId = ProbeSet.Id AND + ProbeSet.Name = "{}" AND + ProbeSetXRef.ProbeSetFreezeId ={} + """.format(trait.name, dataset.id) + logger.sql(query) + trait_qtl = g.db.execute(query).fetchone() + if trait_qtl: + trait.locus, trait.lrs, trait.pvalue, trait.mean, trait.additive = trait_qtl + if trait.locus: + query = """ + select Geno.Chr, Geno.Mb from Geno, Species + where Species.Name = '{}' and + Geno.Name = '{}' and + Geno.SpeciesId = Species.Id + """.format(dataset.group.species, trait.locus) + logger.sql(query) + result = g.db.execute(query).fetchone() + if result: + trait.locus_chr = result[0] + trait.locus_mb = result[1] + else: + trait.locus = trait.locus_chr = trait.locus_mb = trait.additive = "" + else: + trait.locus = trait.locus_chr = trait.locus_mb = trait.additive = "" + else: + trait.locus = trait.locus_chr = trait.locus_mb = trait.lrs = trait.pvalue = trait.mean = trait.additive = "" + + + if dataset.type == 'Publish': + query = """ + SELECT + PublishXRef.Locus, PublishXRef.LRS, PublishXRef.additive + FROM + PublishXRef, PublishFreeze + WHERE + PublishXRef.Id = %s AND + PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND + PublishFreeze.Id =%s + """ % (trait.name, dataset.id) + logger.sql(query) + trait_qtl = g.db.execute(query).fetchone() + if trait_qtl: + trait.locus, trait.lrs, trait.additive = trait_qtl + if trait.locus: + query = """ + select Geno.Chr, Geno.Mb from Geno, Species + where Species.Name = '{}' and + Geno.Name = '{}' and + Geno.SpeciesId = Species.Id + """.format(dataset.group.species, trait.locus) + logger.sql(query) + result = g.db.execute(query).fetchone() + if result: + trait.locus_chr = result[0] + trait.locus_mb = result[1] + else: + trait.locus = trait.locus_chr = trait.locus_mb = trait.additive = "" + else: + trait.locus = trait.locus_chr = trait.locus_mb = trait.additive = "" + else: + trait.locus = trait.lrs = trait.additive = "" + + if (dataset.type == 'Publish' or dataset.type == "ProbeSet") and trait.locus_chr != "" and trait.locus_mb != "": + #XZ: LRS_location_value is used for sorting + try: + LRS_location_value = int(trait.locus_chr)*1000 + float(trait.locus_mb) + except: + if trait.locus_chr.upper() == 'X': + LRS_location_value = 20*1000 + float(trait.locus_mb) + else: + LRS_location_value = ord(str(trait.locus_chr).upper()[0])*1000 + float(trait.locus_mb) + + trait.LRS_location_repr = LRS_location_repr = 'Chr%s: %.6f' % (trait.locus_chr, float(trait.locus_mb)) + if trait.lrs != "": + trait.LRS_score_repr = LRS_score_repr = '%3.1f' % trait.lrs + trait.LRS_score_value = LRS_score_value = trait.lrs + else: + raise KeyError, `trait.name`+' information is not found in the database.' + + return trait \ No newline at end of file diff --git a/wqflask/base/webqtlCaseData.py b/wqflask/base/webqtlCaseData.py index 627b2f6c..845a7224 100644 --- a/wqflask/base/webqtlCaseData.py +++ b/wqflask/base/webqtlCaseData.py @@ -44,15 +44,15 @@ class webqtlCaseData(object): def __repr__(self): str = " | Description | Location | Mean | -Max LRS ? |
+ Max LRS ? | Max LRS Location | -Additive Effect ? |
+ Additive Effect ? | {% for header in header_fields %} {% if header == 'Max LRS' %} - | Max LRS |
+ Max LRS | {% elif header == 'Additive Effect' %} -Additive Effect ? |
+ Additive Effect ? | {% else %}{{header}} | {% endif %} @@ -222,7 +220,7 @@ "iDisplayLength": -1, "deferRender": true, "bSortClasses": false, - "scrollY": true, + "scrollY": "600px", "scrollCollapse": false, "scroller": true, "paging": false @@ -277,7 +275,7 @@ "autoWidth": false, "deferRender": true, "bSortClasses": false, - "scrollY": true, + "scrollY": "600px", "scrollCollapse": true, "scroller": true, "paging": false @@ -311,7 +309,7 @@ "autoWidth": false, "deferRender": true, "bSortClasses": false, - "scrollY": true, + "scrollY": "600px", "scrollCollapse": true, "scroller": true, "paging": false -- cgit v1.2.3 From 6a3f964240d9ff28238b2aaeb90d47f8fa244870 Mon Sep 17 00:00:00 2001 From: zsloan Date: Tue, 13 Dec 2016 19:58:23 +0000 Subject: Fixed a problem related to the last commit that caused a problem when loading a collection or doing ctl analysis --- wqflask/base/trait.py | 5 +---- wqflask/wqflask/ctl/ctl_analysis.py | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'wqflask/base/trait.py') diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py index ab0e6b82..eb5b91c3 100644 --- a/wqflask/base/trait.py +++ b/wqflask/base/trait.py @@ -268,10 +268,7 @@ def getSequence(trait, dataset_name): return results[0] -def retrieve_sample_data(trait, dataset_name, samplelist=None): - - dataset = create_dataset(dataset_name) - +def retrieve_sample_data(trait, dataset, samplelist=None): if samplelist == None: samplelist = [] diff --git a/wqflask/wqflask/ctl/ctl_analysis.py b/wqflask/wqflask/ctl/ctl_analysis.py index c6b59ed7..1b1d7155 100644 --- a/wqflask/wqflask/ctl/ctl_analysis.py +++ b/wqflask/wqflask/ctl/ctl_analysis.py @@ -120,7 +120,7 @@ class CTL(object): if trait != "": ts = trait.split(':') gt = TRAIT.GeneralTrait(name = ts[0], dataset_name = ts[1]) - gt = TRAIT.retrieve_sample_data(gt, dataset.name, individuals) + gt = TRAIT.retrieve_sample_data(gt, dataset, individuals) for ind in individuals: if ind in gt.data.keys(): traits.append(gt.data[ind].value) -- cgit v1.2.3 From e63c4014e7bc34b440707be19af3779b72102fdb Mon Sep 17 00:00:00 2001 From: zsloan Date: Thu, 26 Jan 2017 16:26:16 +0000 Subject: GEMMA now works with CFW data (had to update where it looks for the input files and how it writes the phenotype file) Y-axis for GEMMA now says -log(p) Updated the style of the trait sample data table in the trait page Updated dataset_select_menu_orig.js to also build just the Species and Group drop-downs for the trait input page (as opposed to all 4 drop-downs) Updated dataset menu json file Added option to show and hide columns to regular search page using colVis Changed regular and global search result table styles/column widths Began work on user trait submission code (not working yet though) Began work on static loading page for mapping results --- wqflask/base/data_set.py | 22 ++- wqflask/base/trait.py | 12 +- wqflask/utility/tools.py | 1 + wqflask/wqflask/marker_regression/gemma_mapping.py | 51 +++-- .../wqflask/marker_regression/marker_regression.py | 37 +--- .../marker_regression/marker_regression_gn1.py | 5 +- wqflask/wqflask/show_trait/show_trait.py | 7 +- wqflask/wqflask/static/new/css/main.css | 7 + .../new/javascript/dataset_menu_structure.json | 207 ++++++++++++++------- .../static/new/javascript/dataset_select_menu.js | 12 +- .../new/javascript/dataset_select_menu_orig.js | 15 +- .../packages/DataTables/css/jquery.dataTables.css | 2 +- .../DataTables/extensions/buttons.colVis.min.js | 5 + .../extensions/dataTables.buttons.min.js | 35 ++++ .../extensions/scroller.dataTables.min.css | 1 + wqflask/wqflask/submit_trait.py | 24 +++ wqflask/wqflask/templates/gsearch_gene.html | 90 +++++---- wqflask/wqflask/templates/loading.html | 14 ++ wqflask/wqflask/templates/search_result_page.html | 75 +++++--- .../wqflask/templates/show_trait_edit_data.html | 2 + .../templates/show_trait_mapping_tools.html | 27 ++- wqflask/wqflask/templates/submit_trait.html | 101 ++++++++++ wqflask/wqflask/views.py | 57 ++++++ 23 files changed, 594 insertions(+), 215 deletions(-) create mode 100644 wqflask/wqflask/static/new/packages/DataTables/extensions/buttons.colVis.min.js create mode 100644 wqflask/wqflask/static/new/packages/DataTables/extensions/dataTables.buttons.min.js create mode 100644 wqflask/wqflask/static/new/packages/DataTables/extensions/scroller.dataTables.min.css create mode 100644 wqflask/wqflask/submit_trait.py create mode 100644 wqflask/wqflask/templates/loading.html create mode 100644 wqflask/wqflask/templates/submit_trait.html (limited to 'wqflask/base/trait.py') diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 06e02b02..94b38e13 100644 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -44,7 +44,7 @@ from db import webqtlDatabaseFunction from utility import webqtlUtil from utility.benchmark import Bench from utility import chunks -from utility.tools import locate, locate_ignore_error +from utility.tools import locate, locate_ignore_error, flat_files from maintenance import get_group_samplelists @@ -53,7 +53,7 @@ from pprint import pformat as pf from db.gn_server import menu_main from db.call import fetchall,fetchone,fetch1 -from utility.tools import USE_GN_SERVER, USE_REDIS +from utility.tools import USE_GN_SERVER, USE_REDIS, flat_files, flat_file_exists from utility.logger import getLogger logger = getLogger(__name__ ) @@ -226,7 +226,7 @@ class Markers(object): class HumanMarkers(Markers): def __init__(self, name, specified_markers = []): - marker_data_fh = open(locate('genotype') + '/' + name + '.bim') + marker_data_fh = open(flat_files('mapping') + '/' + name + '.bim') self.markers = [] for line in marker_data_fh: splat = line.strip().split() @@ -299,11 +299,21 @@ class DatasetGroup(object): self.markers = HumanMarkers(self.name, markers) def get_markers(self): - #logger.debug("self.species is:", self.species) - if self.species == "human": + logger.debug("self.species is:", self.species) + + 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"))): + return True + return False + + if check_plink_gemma(): marker_class = HumanMarkers else: - marker_class = Markers + marker_class = Markers self.markers = marker_class(self.name) diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py index eb5b91c3..bf87e879 100644 --- a/wqflask/base/trait.py +++ b/wqflask/base/trait.py @@ -207,7 +207,7 @@ class GeneralTrait(object): formatted = self.post_publication_description else: formatted = "Not available" - return formatted.capitalize() + return formatted @property def alias_fmt(self): @@ -379,7 +379,7 @@ def jsonable_table_row(trait, dataset_name, index): additive = "N/A" else: additive = "%.3f" % round(float(trait.additive), 2) - return ['', + return ['', index, ''+str(trait.name)+'', trait.symbol, @@ -395,7 +395,7 @@ def jsonable_table_row(trait, dataset_name, index): else: additive = "%.2f" % round(float(trait.additive), 2) if trait.pubmed_id: - return ['', + return ['', index, ''+str(trait.name)+'', trait.description_display, @@ -405,7 +405,7 @@ def jsonable_table_row(trait, dataset_name, index): trait.LRS_location_repr, additive] else: - return ['', + return ['', index, ''+str(trait.name)+'', trait.description_display, @@ -415,7 +415,7 @@ def jsonable_table_row(trait, dataset_name, index): trait.LRS_location_repr, additive] elif dataset.type == "Geno": - return ['', + return ['', index, ''+str(trait.name)+'', trait.location_repr] @@ -499,7 +499,7 @@ def retrieve_trait_info(trait, dataset, get_qtl_info=False): for i, field in enumerate(dataset.display_fields): holder = trait_info[i] if isinstance(trait_info[i], basestring): - holder = unicode(trait_info[i], "utf8", "ignore") + holder = unicode(trait_info[i], "utf-8", "ignore") setattr(trait, field, holder) if dataset.type == 'Publish': diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py index df032e48..8db9ac6e 100644 --- a/wqflask/utility/tools.py +++ b/wqflask/utility/tools.py @@ -215,6 +215,7 @@ GENENETWORK_FILES = get_setting('GENENETWORK_FILES') PYLMM_COMMAND = pylmm_command() GEMMA_COMMAND = gemma_command() +GEMMA_RESULTS_PATH = get_setting('GEMMA_RESULTS_PATH') PLINK_COMMAND = plink_command() TEMPDIR = tempdir() # defaults to UNIX TMPDIR diff --git a/wqflask/wqflask/marker_regression/gemma_mapping.py b/wqflask/wqflask/marker_regression/gemma_mapping.py index a56362ec..66bed5a2 100644 --- a/wqflask/wqflask/marker_regression/gemma_mapping.py +++ b/wqflask/wqflask/marker_regression/gemma_mapping.py @@ -1,7 +1,7 @@ -import os +import os, math from base import webqtlConfig -from utility.tools import GEMMA_COMMAND +from utility.tools import flat_files, GEMMA_COMMAND, GEMMA_RESULTS_PATH def run_gemma(this_dataset, samples, vals): """Generates p-values for each marker using GEMMA""" @@ -10,41 +10,62 @@ def run_gemma(this_dataset, samples, vals): gen_pheno_txt_file(this_dataset, samples, vals) - # Don't do this! - # os.chdir("{}gemma".format(webqtlConfig.GENODIR)) - # use GEMMA_RUN in the next one, create a unique temp file - gemma_command = GEMMA_COMMAND + ' -bfile %s/%s -k %s/output/%s.cXX.txt -lmm 1 -o %s_output' % (GEMMA_PATH, + gemma_command = GEMMA_COMMAND + ' -bfile %s/%s -k %s/%s.sXX.txt -lmm 1 -outdir %s/output -o %s_output' % (flat_files('mapping'), this_dataset.group.name, - GEMMA_PATH, + flat_files('mapping'), this_dataset.group.name, + GEMMA_RESULTS_PATH, this_dataset.group.name) print("gemma_command:" + gemma_command) os.system(gemma_command) - included_markers, p_values = parse_gemma_output(this_dataset) + marker_obs = parse_gemma_output(this_dataset) - return included_markers, p_values + return marker_obs def gen_pheno_txt_file(this_dataset, samples, vals): """Generates phenotype file for GEMMA""" - with open("{}/{}.fam".format(GEMMA_PATH, this_dataset.group.name), "w") as outfile: - for i, sample in enumerate(samples): - outfile.write(str(sample) + " " + str(sample) + " 0 0 0 " + str(vals[i]) + "\n") + current_file_data = [] + with open("{}/{}.fam".format(flat_files('mapping'), this_dataset.group.name), "r") as outfile: + for i, line in enumerate(outfile): + split_line = line.split() + current_file_data.append(split_line) + + with open("{}/{}.fam".format(flat_files('mapping'), this_dataset.group.name), "w") as outfile: + for i, line in enumerate(current_file_data): + if vals[i] == "x": + this_val = -9 + else: + this_val = vals[i] + outfile.write(line[0] + " " + line[1] + " " + line[2] + " " + line[3] + " " + line[4] + " " + str(this_val) + "\n") def parse_gemma_output(this_dataset): included_markers = [] p_values = [] - with open("{}/output/{}_output.assoc.txt".format(GEMMA_PATH, this_dataset.group.name)) as output_file: + marker_obs = [] + with open("{}/output/{}_output.assoc.txt".format(GEMMA_RESULTS_PATH, this_dataset.group.name)) as output_file: for line in output_file: if line.startswith("chr"): continue else: + marker = {} + marker['name'] = line.split("\t")[1] + marker['chr'] = int(line.split("\t")[0]) + marker['Mb'] = float(line.split("\t")[2]) / 1000000 + marker['p_value'] = float(line.split("\t")[10]) + if math.isnan(marker['p_value']) or (marker['p_value'] <= 0): + marker['lod_score'] = 0 + #marker['lrs_value'] = 0 + else: + marker['lod_score'] = -math.log10(marker['p_value']) + #marker['lrs_value'] = -math.log10(marker['p_value']) * 4.61 + marker_obs.append(marker) + included_markers.append(line.split("\t")[1]) p_values.append(float(line.split("\t")[10])) - #print("p_values: ", p_values) - return included_markers, p_values + return marker_obs diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py index d9dbd0da..b1d2f811 100644 --- a/wqflask/wqflask/marker_regression/marker_regression.py +++ b/wqflask/wqflask/marker_regression/marker_regression.py @@ -37,7 +37,7 @@ from utility import temp_data from utility.benchmark import Bench from wqflask.marker_regression import gemma_mapping, rqtl_mapping, qtlreaper_mapping, plink_mapping -from utility.tools import locate, locate_ignore_error, PYLMM_COMMAND, GEMMA_COMMAND, PLINK_COMMAND, TEMPDIR +from utility.tools import locate, locate_ignore_error, PYLMM_COMMAND, GEMMA_COMMAND, GEMMA_RESULTS_PATH, PLINK_COMMAND, TEMPDIR from utility.external import shell from base.webqtlConfig import TMPDIR, GENERATED_TEXT_DIR @@ -140,7 +140,6 @@ class MarkerRegression(object): except: self.num_perm = 0 - self.LRSCheck = self.score_type if self.num_perm > 0: self.permCheck = "ON" else: @@ -151,12 +150,10 @@ class MarkerRegression(object): self.dataset.group.get_markers() if self.mapping_method == "gemma": - self.score_type = "LOD" + self.score_type = "-log(p)" self.manhattan_plot = True with Bench("Running GEMMA"): - included_markers, p_values = gemma_mapping.run_gemma(self.dataset, self.samples, self.vals) - with Bench("Getting markers from csv"): - marker_obs = get_markers_from_csv(included_markers, p_values, self.dataset.group.name) + marker_obs = gemma_mapping.run_gemma(self.dataset, self.samples, self.vals) results = marker_obs elif self.mapping_method == "rqtl_plink": results = self.run_rqtl_plink() @@ -511,8 +508,7 @@ class MarkerRegression(object): logger.debug("Before creating the command") - command = PYLMM_COMMAND+' --key {} --species {}'.format(key, - "human") + command = PYLMM_COMMAND+' --key {} --species {}'.format(key, "human") logger.debug("command is:", command) @@ -610,30 +606,5 @@ def trim_markers_for_table(markers): return sorted_markers -def get_markers_from_csv(included_markers, p_values, group_name): - marker_data_fh = open(os.path.join(webqtlConfig.PYLMM_PATH + group_name + '_markers.csv')) - markers = [] - for marker_name, p_value in itertools.izip(included_markers, p_values): - if not p_value or len(included_markers) < 1: - continue - for line in marker_data_fh: - splat = line.strip().split() - if splat[0] == marker_name: - marker = {} - marker['name'] = splat[0] - marker['chr'] = int(splat[1]) - marker['Mb'] = float(splat[2]) - marker['p_value'] = p_value - if math.isnan(marker['p_value']) or (marker['p_value'] <= 0): - marker['lod_score'] = 0 - marker['lrs_value'] = 0 - else: - marker['lod_score'] = -math.log10(marker['p_value']) - marker['lrs_value'] = -math.log10(marker['p_value']) * 4.61 - markers.append(marker) - break - - return markers - if __name__ == '__main__': import cPickle as pickle diff --git a/wqflask/wqflask/marker_regression/marker_regression_gn1.py b/wqflask/wqflask/marker_regression/marker_regression_gn1.py index bc147f75..9ff431a2 100644 --- a/wqflask/wqflask/marker_regression/marker_regression_gn1.py +++ b/wqflask/wqflask/marker_regression/marker_regression_gn1.py @@ -292,7 +292,10 @@ class MarkerRegression(object): self.graphHeight = self.GRAPH_DEFAULT_HEIGHT self.dominanceChecked = False - self.LRS_LOD = start_vars['LRSCheck'] + if 'LRSCheck' in start_vars.keys(): + self.LRS_LOD = start_vars['LRSCheck'] + else: + self.LRS_LOD = start_vars['score_type'] self.cutoff = start_vars['cutoff'] self.intervalAnalystChecked = True self.draw2X = False diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index 091db50f..13ae933f 100644 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -167,7 +167,8 @@ class ShowTrait(object): if flat_file_exists("mapping"): MAPPING_PATH = flat_files("mapping")+"/" if (os.path.isfile(MAPPING_PATH+self.dataset.group.name+".bed") and - os.path.isfile(MAPPING_PATH+self.dataset.group.name+".map")): + (os.path.isfile(MAPPING_PATH+self.dataset.group.name+".map") or + os.path.isfile(MAPPING_PATH+self.dataset.group.name+".bim"))): return True return False @@ -729,7 +730,7 @@ class ShowTrait(object): def make_sample_lists(self, this_trait): all_samples_ordered = self.dataset.group.all_samples_ordered() - + primary_sample_names = list(all_samples_ordered) other_sample_names = [] @@ -813,7 +814,7 @@ def get_genofiles(this_trait): return jsondata['genofile'] def get_trait_table_width(sample_groups): - table_width = 35 + table_width = 30 if sample_groups[0].se_exists(): table_width += 10 if (table_width + len(sample_groups[0].attributes)*10) > 100: diff --git a/wqflask/wqflask/static/new/css/main.css b/wqflask/wqflask/static/new/css/main.css index 017bbdb8..880395a7 100644 --- a/wqflask/wqflask/static/new/css/main.css +++ b/wqflask/wqflask/static/new/css/main.css @@ -2,3 +2,10 @@ padding-left: 30px; padding-right: 30px; } + +ol { + font-family: Arial; + font-weight: bold; + font-size: 16px; + color: #000082 +} \ No newline at end of file diff --git a/wqflask/wqflask/static/new/javascript/dataset_menu_structure.json b/wqflask/wqflask/static/new/javascript/dataset_menu_structure.json index 2f332a4a..06586372 100644 --- a/wqflask/wqflask/static/new/javascript/dataset_menu_structure.json +++ b/wqflask/wqflask/static/new/javascript/dataset_menu_structure.json @@ -1339,15 +1339,15 @@ "HLC_0311", "GSE9588 Human Liver Normal (Mar11) Both Sexes" ], - [ - "384", - "HLCF_0311", - "GSE9588 Human Liver Normal (Mar11) Females" - ], [ "383", "HLCM_0311", "GSE9588 Human Liver Normal (Mar11) Males" + ], + [ + "384", + "HLCF_0311", + "GSE9588 Human Liver Normal (Mar11) Females" ] ], "Phenotypes": [ @@ -1620,11 +1620,6 @@ }, "B6D2F2": { "Brain mRNA": [ - [ - "77", - "BRF2_M_0805_R", - "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) RMA" - ], [ "76", "BRF2_M_0805_M", @@ -1635,6 +1630,11 @@ "BRF2_M_0805_P", "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) PDNN" ], + [ + "77", + "BRF2_M_0805_R", + "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) RMA" + ], [ "33", "BRF2_M_0304_P", @@ -1726,11 +1726,6 @@ ] ], "Striatum mRNA": [ - [ - "85", - "SA_M2_0905_P", - "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) PDNN" - ], [ "84", "SA_M2_0905_R", @@ -1740,21 +1735,26 @@ "83", "SA_M2_0905_M", "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) MAS5" + ], + [ + "85", + "SA_M2_0905_P", + "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) PDNN" ] ] }, "BHF2": { "Adipose mRNA": [ - [ - "197", - "UCLA_BHF2_ADIPOSE_FEMALE", - "UCLA BHF2 Adipose Female mlratio" - ], [ "196", "UCLA_BHF2_ADIPOSE_MALE", "UCLA BHF2 Adipose Male mlratio" ], + [ + "197", + "UCLA_BHF2_ADIPOSE_FEMALE", + "UCLA BHF2 Adipose Female mlratio" + ], [ "165", "UCLA_BHF2_ADIPOSE_0605", @@ -1762,16 +1762,16 @@ ] ], "Brain mRNA": [ - [ - "199", - "UCLA_BHF2_BRAIN_FEMALE", - "UCLA BHF2 Brain Female mlratio" - ], [ "198", "UCLA_BHF2_BRAIN_MALE", "UCLA BHF2 Brain Male mlratio" ], + [ + "199", + "UCLA_BHF2_BRAIN_FEMALE", + "UCLA BHF2 Brain Female mlratio" + ], [ "166", "UCLA_BHF2_BRAIN_0605", @@ -1786,16 +1786,16 @@ ] ], "Liver mRNA": [ - [ - "201", - "UCLA_BHF2_LIVER_FEMALE", - "UCLA BHF2 Liver Female mlratio" - ], [ "200", "UCLA_BHF2_LIVER_MALE", "UCLA BHF2 Liver Male mlratio" ], + [ + "201", + "UCLA_BHF2_LIVER_FEMALE", + "UCLA BHF2 Liver Female mlratio" + ], [ "167", "UCLA_BHF2_LIVER_0605", @@ -1999,11 +1999,6 @@ "BR_U_1105_P", "UTHSC Brain mRNA U74Av2 (Nov05) PDNN" ], - [ - "81", - "BR_U_0805_P", - "UTHSC Brain mRNA U74Av2 (Aug05) PDNN" - ], [ "80", "BR_U_0805_M", @@ -2014,6 +2009,11 @@ "BR_U_0805_R", "UTHSC Brain mRNA U74Av2 (Aug05) RMA" ], + [ + "81", + "BR_U_0805_P", + "UTHSC Brain mRNA U74Av2 (Aug05) PDNN" + ], [ "42", "CB_M_0204_P", @@ -2080,11 +2080,6 @@ "Eye_M2_0908_R_ND", "Eye M430v2 WT Gpnmb (Sep08) RMA" ], - [ - "279", - "Eye_M2_0908_R_WT", - "Eye M430v2 WT Tyrp1 (Sep08) RMA" - ], [ "278", "Eye_M2_0908_R_MT", @@ -2095,6 +2090,11 @@ "Eye_M2_0908_WTWT", "Eye M430v2 WT WT (Sep08) RMA" ], + [ + "279", + "Eye_M2_0908_R_WT", + "Eye M430v2 WT Tyrp1 (Sep08) RMA" + ], [ "400", "DBA2J-ONH-1212", @@ -2331,16 +2331,16 @@ ] ], "Kidney mRNA": [ - [ - "239", - "MA_M2F_0706_R", - "Mouse kidney M430v2 Female (Aug06) RMA" - ], [ "240", "MA_M2M_0706_R", "Mouse kidney M430v2 Male (Aug06) RMA" ], + [ + "239", + "MA_M2F_0706_R", + "Mouse kidney M430v2 Female (Aug06) RMA" + ], [ "118", "MA_M2_0806_R", @@ -2545,15 +2545,15 @@ "HQFNeoc_0208_RankInv", "HQF BXD Neocortex ILM6v1.1 (Feb08) RankInv" ], - [ - "275", - "DevNeocortex_ILM6.2P14RInv_1110", - "BIDMC/UTHSC Dev Neocortex P14 ILMv6.2 (Nov10) RankInv" - ], [ "274", "DevNeocortex_ILM6.2P3RInv_1110", "BIDMC/UTHSC Dev Neocortex P3 ILMv6.2 (Nov10) RankInv" + ], + [ + "275", + "DevNeocortex_ILM6.2P14RInv_1110", + "BIDMC/UTHSC Dev Neocortex P14 ILMv6.2 (Nov10) RankInv" ] ], "Nucleus Accumbens mRNA": [ @@ -2760,11 +2760,6 @@ ] ], "Ventral Tegmental Area mRNA": [ - [ - "230", - "VCUEtvsSal_0609_R", - "VCU BXD VTA Et vs Sal M430 2.0 (Jun09) RMA" - ], [ "229", "VCUEtOH_0609_R", @@ -2774,6 +2769,11 @@ "228", "VCUSal_0609_R", "VCU BXD VTA Sal M430 2.0 (Jun09) RMA" + ], + [ + "230", + "VCUEtvsSal_0609_R", + "VCU BXD VTA Et vs Sal M430 2.0 (Jun09) RMA" ] ] }, @@ -2849,6 +2849,36 @@ ] ] }, + "CFW": { + "Hippocampus mRNA": [ + [ + "808", + "UCSD_CFW_HIP_RNA-Seq_0117", + "UCSD CFW Hippocampus (Jan17) RNA-Seq" + ] + ], + "Phenotypes": [ + [ + "None", + "CFWPublish", + "CFW Published Phenotypes" + ] + ], + "Prefrontal Cortex mRNA": [ + [ + "810", + "UCSD_CFW_PFC_RNA-Seq_0117", + "UCSD CFW Prefrontal Cortex (Jan17) RNA-Seq" + ] + ], + "Striatum mRNA": [ + [ + "809", + "UCSD_CFW_SPL_RNA-Seq_0117", + "UCSD CFW Striatum (Jan17) RNA-Seq" + ] + ] + }, "CIE-INIA": { "LCM Brain Regions mRNA": [ [ @@ -3051,11 +3081,6 @@ ] ], "Hippocampus mRNA": [ - [ - "213", - "Illum_LXS_Hipp_NOS_1008", - "Hippocampus Illumina NOS (Oct08) RankInv beta" - ], [ "219", "Illum_LXS_Hipp_NON_1008", @@ -3076,6 +3101,11 @@ "Illum_LXS_Hipp_RSS_1008", "Hippocampus Illumina RSS (Oct08) RankInv beta" ], + [ + "213", + "Illum_LXS_Hipp_NOS_1008", + "Hippocampus Illumina NOS (Oct08) RankInv beta" + ], [ "143", "Illum_LXS_Hipp_loess0807", @@ -3246,6 +3276,17 @@ }, "Scripps-2013": {} }, + "poplar": { + "Poplar": { + "Phenotypes": [ + [ + "649", + "PoplarPublish", + "Poplar Published Phenotypes" + ] + ] + } + }, "rat": { "HSNIH-Palmer": { "Phenotypes": [ @@ -3554,6 +3595,10 @@ "C57BL-6JxC57BL-6NJF2", "Reduced Complexity Cross (B6JxB6N F2)" ], + [ + "CFW", + "CFW Outbred GWAS" + ], [ "CIE-INIA", "Chronic Intermittent Ethanol" @@ -3603,6 +3648,12 @@ "SOTNOT-OHSU" ] ], + "poplar": [ + [ + "Poplar", + "Poplar" + ] + ], "rat": [ [ "HSNIH-Palmer", @@ -3641,15 +3692,15 @@ "species": [ [ "human", - "Human" + "Human (hg19)" ], [ "mouse", - "Mouse" + "Mouse (mm10)" ], [ "rat", - "Rat" + "Rat (rn3)" ], [ "drosophila", @@ -3663,6 +3714,10 @@ "barley", "Barley" ], + [ + "poplar", + "Poplar" + ], [ "soybean", "Soybean" @@ -4682,6 +4737,24 @@ "Genotypes" ] ], + "CFW": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Hippocampus mRNA", + "Hippocampus mRNA" + ], + [ + "Prefrontal Cortex mRNA", + "Prefrontal Cortex mRNA" + ], + [ + "Striatum mRNA", + "Striatum mRNA" + ] + ], "CIE-INIA": [ [ "Phenotypes", @@ -4842,6 +4915,14 @@ ], "Scripps-2013": [] }, + "poplar": { + "Poplar": [ + [ + "Phenotypes", + "Phenotypes" + ] + ] + }, "rat": { "HSNIH-Palmer": [ [ diff --git a/wqflask/wqflask/static/new/javascript/dataset_select_menu.js b/wqflask/wqflask/static/new/javascript/dataset_select_menu.js index 43b0960c..9ad38102 100644 --- a/wqflask/wqflask/static/new/javascript/dataset_select_menu.js +++ b/wqflask/wqflask/static/new/javascript/dataset_select_menu.js @@ -1,10 +1,10 @@ $(function() { - var gndata; // loaded once for all to use - process_json = function(data) { - populate_species(); - return apply_default(); - }; - $.getJSON(gn_server_url+"/int/menu/main.json", + var gndata; // loaded once for all to use + process_json = function(data) { + populate_species(); + return apply_default(); + }; + $.getJSON(gn_server_url+"int/menu/main.json", function(data) { gndata = data; console.log("***** GOT DATA from GN_SERVER ****"); diff --git a/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js b/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js index 1fe4cf75..fd96eb78 100644 --- a/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js +++ b/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js @@ -4,7 +4,9 @@ $(function() { process_json = function(data) { window.jdata = data; populate_species(); - return apply_default(); + if ($('#type').length > 0) { //This is to determine if it's the index page or the submit_trait page (which only has species and group selection and no make default option) + return apply_default(); + } }; $.ajax('/static/new/javascript/dataset_menu_structure.json', { dataType: 'json', @@ -23,7 +25,9 @@ $(function() { species = $('#species').val(); group_list = this.jdata.groups[species]; redo_dropdown($('#group'), group_list); - return populate_type(); + if ($('#type').length > 0) { //This is to determine if it's the index page or the submit_trait page (which only has species and group selection and no make default option) + return populate_type(); + } }; window.populate_group = populate_group; populate_type = function() { @@ -70,7 +74,12 @@ $(function() { })(this)); $('#group').change((function(_this) { return function() { - return populate_type(); + if ($('#type').length > 0) { //This is to determine if it's the index page or the submit_trait page (which only has species and group selection and no make default option) + return populate_type(); + } + else { + return false + } }; })(this)); $('#type').change((function(_this) { 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 6e0e7348..87f602dc 100644 --- a/wqflask/wqflask/static/new/packages/DataTables/css/jquery.dataTables.css +++ b/wqflask/wqflask/static/new/packages/DataTables/css/jquery.dataTables.css @@ -81,7 +81,7 @@ table.dataTable tbody tr.selected { table.dataTable tbody th, table.dataTable tbody td { font: 12px Arial, Sans-serif; - padding: 4px 5px; + padding: 4px 5px 4px 0px; } 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/static/new/packages/DataTables/extensions/buttons.colVis.min.js b/wqflask/wqflask/static/new/packages/DataTables/extensions/buttons.colVis.min.js new file mode 100644 index 00000000..072d6c9a --- /dev/null +++ b/wqflask/wqflask/static/new/packages/DataTables/extensions/buttons.colVis.min.js @@ -0,0 +1,5 @@ +(function(g){"function"===typeof define&&define.amd?define(["jquery","datatables.net","datatables.net-buttons"],function(d){return g(d,window,document)}):"object"===typeof exports?module.exports=function(d,e){d||(d=window);if(!e||!e.fn.dataTable)e=require("datatables.net")(d,e).$;e.fn.dataTable.Buttons||require("datatables.net-buttons")(d,e);return g(e,d,d.document)}:g(jQuery,window,document)})(function(g,d,e,h){d=g.fn.dataTable;g.extend(d.ext.buttons,{colvis:function(a,b){return{extend:"collection", +text:function(a){return a.i18n("buttons.colvis","Column visibility")},className:"buttons-colvis",buttons:[{extend:"columnsToggle",columns:b.columns}]}},columnsToggle:function(a,b){return a.columns(b.columns).indexes().map(function(a){return{extend:"columnToggle",columns:a}}).toArray()},columnToggle:function(a,b){return{extend:"columnVisibility",columns:b.columns}},columnsVisibility:function(a,b){return a.columns(b.columns).indexes().map(function(a){return{extend:"columnVisibility",columns:a,visibility:b.visibility}}).toArray()}, +columnVisibility:{columns:h,text:function(a,b,c){return c._columnText(a,c.columns)},className:"buttons-columnVisibility",action:function(a,b,c,f){a=b.columns(f.columns);b=a.visible();a.visible(f.visibility!==h?f.visibility:!(b.length&&b[0]))},init:function(a,b,c){var f=this;a.on("column-visibility.dt"+c.namespace,function(b,d){d.bDestroying||f.active(a.column(c.columns).visible())}).on("column-reorder.dt"+c.namespace,function(b,d,e){1===a.columns(c.columns).count()&&("number"===typeof c.columns&& +(c.columns=e.mapping[c.columns]),b=a.column(c.columns),f.text(c._columnText(a,c.columns)),f.active(b.visible()))});this.active(a.column(c.columns).visible())},destroy:function(a,b,c){a.off("column-visibility.dt"+c.namespace).off("column-reorder.dt"+c.namespace)},_columnText:function(a,b){var c=a.column(b).index();return a.settings()[0].aoColumns[c].sTitle.replace(/\n/g," ").replace(/<.*?>/g,"").replace(/^\s+|\s+$/g,"")}},colvisRestore:{className:"buttons-colvisRestore",text:function(a){return a.i18n("buttons.colvisRestore", +"Restore visibility")},init:function(a,b,c){c._visOriginal=a.columns().indexes().map(function(b){return a.column(b).visible()}).toArray()},action:function(a,b,c,d){b.columns().every(function(a){a=b.colReorder&&b.colReorder.transpose?b.colReorder.transpose(a,"toOriginal"):a;this.visible(d._visOriginal[a])})}},colvisGroup:{className:"buttons-colvisGroup",action:function(a,b,c,d){b.columns(d.show).visible(!0,!1);b.columns(d.hide).visible(!1,!1);b.columns.adjust()},show:[],hide:[]}});return d.Buttons}); \ No newline at end of file diff --git a/wqflask/wqflask/static/new/packages/DataTables/extensions/dataTables.buttons.min.js b/wqflask/wqflask/static/new/packages/DataTables/extensions/dataTables.buttons.min.js new file mode 100644 index 00000000..ae3fb9c8 --- /dev/null +++ b/wqflask/wqflask/static/new/packages/DataTables/extensions/dataTables.buttons.min.js @@ -0,0 +1,35 @@ +/*! + Buttons for DataTables 1.2.4 + 2016 SpryMedia Ltd - datatables.net/license +*/ +(function(d){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(n){return d(n,window,document)}):"object"===typeof exports?module.exports=function(n,o){n||(n=window);if(!o||!o.fn.dataTable)o=require("datatables.net")(n,o).$;return d(o,n,n.document)}:d(jQuery,window,document)})(function(d,n,o,m){var i=d.fn.dataTable,u=0,v=0,j=i.ext.buttons,l=function(a,b){!0===b&&(b={});d.isArray(b)&&(b={buttons:b});this.c=d.extend(!0,{},l.defaults,b);b.buttons&&(this.c.buttons=b.buttons); +this.s={dt:new i.Api(a),buttons:[],listenKeys:"",namespace:"dtb"+u++};this.dom={container:d("<"+this.c.dom.container.tag+"/>").addClass(this.c.dom.container.className)};this._constructor()};d.extend(l.prototype,{action:function(a,b){var c=this._nodeToButton(a);if(b===m)return c.conf.action;c.conf.action=b;return this},active:function(a,b){var c=this._nodeToButton(a),e=this.c.dom.button.active,c=d(c.node);if(b===m)return c.hasClass(e);c.toggleClass(e,b===m?!0:b);return this},add:function(a,b){var c= +this.s.buttons;if("string"===typeof b){for(var e=b.split("-"),c=this.s,d=0,h=e.length-1;d
---|
- | Index | -Species | -Group | -Tissue | -Dataset | -Record | -Symbol | -Description | -Location | -Mean | -Max LRS ? | -Max LRS Location | -Additive Effect ? | ++ | Index | +Record ID | +Species | +Group | +Tissue | +Dataset | +Symbol | +Description | +Location | +Mean | +Max LRS ? | +Max LRS Location | +Additive Effect ? |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+ | {{ loop.index }} | +{{ this_trait.name }} | {{ this_trait.dataset.group.species }} | {{ this_trait.dataset.group.name }} | {{ this_trait.dataset.tissue }} | {{ this_trait.dataset.name }} | -{{ this_trait.name }} | {{ this_trait.symbol }} | {{ this_trait.description_display }} | {{ this_trait.location_repr }} | @@ -69,20 +69,20 @@|||||||||||||||||
- | Index | -Species | -Group | -Tissue | -Dataset | -Record | -Symbol | -Description | -Location | -Mean | -Max LRS ? |
- Max LRS Location | -Additive Effect ? |
+ + | Index | +Record ID | +Species | +Group | +Tissue | +Dataset | +Symbol | +Description | +Location | +Mean | +Max LRS ? | +Max LRS Location | +Additive Effect ? |