From 8f5a9ab89a77890ee620bed882fcecff63594392 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Thu, 11 Oct 2012 16:56:01 -0500 Subject: Got sample table data from the trait page sent to the export python code --- wqflask/wqflask/show_trait/export_trait_data.py | 15 + wqflask/wqflask/show_trait/show_trait.py | 243 +++- .../static/new/javascript/show_trait.coffee | 51 +- .../wqflask/static/new/javascript/show_trait.js | 49 +- wqflask/wqflask/static/new/js_external/json2.js | 1298 ++++++++++++++++++++ wqflask/wqflask/templates/new_index_page.html | 85 ++ wqflask/wqflask/templates/show_trait.html | 1 + wqflask/wqflask/views.py | 14 + 8 files changed, 1719 insertions(+), 37 deletions(-) create mode 100644 wqflask/wqflask/show_trait/export_trait_data.py create mode 100644 wqflask/wqflask/static/new/js_external/json2.js create mode 100644 wqflask/wqflask/templates/new_index_page.html diff --git a/wqflask/wqflask/show_trait/export_trait_data.py b/wqflask/wqflask/show_trait/export_trait_data.py new file mode 100644 index 00000000..7c77f1c1 --- /dev/null +++ b/wqflask/wqflask/show_trait/export_trait_data.py @@ -0,0 +1,15 @@ +from __future__ import print_function, division + +import simplejson as json + +#import xlwt +from pprint import pformat as pf + +def export_sample_table(targs): + #print("* keys0 args is:", targs[0].keys()) + + for key, item in targs.iteritems(): + print("[arrow] key is:", key) + + sample_data = json.loads(targs['json_data']) + print("sample_data is:", pf(sample_data)) \ No newline at end of file diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index 9b47f658..942ce336 100755 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -146,7 +146,7 @@ class ShowTrait(templatePage): self.make_sample_lists(fd, variance_data_page, this_trait) - + if fd.allsamplelist: hddn['allsamplelist'] = string.join(fd.allsamplelist, ' ') @@ -161,9 +161,7 @@ class ShowTrait(templatePage): self.sample_group_types['primary_only'] = fd.RISet + " Only" self.sample_group_types['other_only'] = "Non-" + fd.RISet self.sample_group_types['all_cases'] = "All Cases" - sample_lists = [] - for group in self.sample_groups: - sample_lists.append(group.sample_list) + sample_lists = [group.sample_list for group in self.sample_groups] print("sample_lists is:", pf(sample_lists)) js_data = dict(sample_group_types = self.sample_group_types, sample_lists = sample_lists, @@ -182,7 +180,7 @@ class ShowTrait(templatePage): cell_id = self.fd.get('CellID') this_trait = webqtlTrait(db=database, name=probe_set_id, cellid=cell_id, cursor=self.cursor) - + ##identification, etc. self.fd.identification = '%s : %s' % (this_trait.db.shortname, probe_set_id) this_trait.returnURL = webqtlConfig.CGIDIR + webqtlConfig.SCRIPTFILE + '?FormID=showDatabase&database=%s\ @@ -195,12 +193,14 @@ class ShowTrait(templatePage): this_trait.retrieveInfo() this_trait.retrieveData() return this_trait - + def dispTraitInformation(self, fd, title1Body, hddn, this_trait): _Species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, RISet=fd.RISet) + #tbl = HT.TableLite(cellpadding=2, Class="collap", style="margin-left:20px;", width="840", valign="top", id="target1") + #reset=HT.Input(type='Reset',name='',value=' Reset ',Class="button") #XZ, August 02, 2011: The display of icons is decided by the trait type (if trait exists), along with user log-in status. Note that the new submitted trait might not be trait object. @@ -800,12 +800,9 @@ class ShowTrait(templatePage): def dispBasicStatistics(self, fd, this_trait): - #XZ, June 22, 2011: The definition and usage of primary_samples, other_samples, - #specialStrains, all_samples are not clear and hard to understand. But since they are - #only used in this function for draw graph purpose, they will not hurt the business logic - #outside. As of June 21, 2011, this function seems work fine, so no hurry to clean up. - #These parameters and code in this function should be cleaned along with fd.f1list, - #fd.parlist, fd.samplelist later. + #XZ, June 22, 2011: The definition and usage of primary_samples, other_samples, specialStrains, all_samples are not clear and hard to understand. But since they are only used in this function for draw graph purpose, they will not hurt the business logic outside. As of June 21, 2011, this function seems work fine, so no hurry to clean up. These parameters and code in this function should be cleaned along with fd.f1list, fd.parlist, fd.samplelist later. + #stats_row = HT.TR() + #stats_cell = HT.TD() if fd.genotype.type == "riset": samplelist = fd.f1list + fd.samplelist @@ -817,6 +814,7 @@ class ShowTrait(templatePage): all_samples = [] primary_samples = [] #XZ: sample of primary group, e.g., BXD, LXS + #self.MDP_menu = HT.Select(name='stats_mdp', Class='stats_mdp') self.MDP_menu = [] # We're going to use the same named data structure as in the old version # but repurpose it for Jinja2 as an array @@ -827,15 +825,10 @@ class ShowTrait(templatePage): if sample.find('F1') < 0: specialStrains.append(sample) if (this_trait.data[sampleName].value != None) and (sample not in (fd.f1list + fd.parlist)): - #XZ: at current stage, other_samples doesn't include parent samples and - #F1 samples of primary group - other_samples.append(sample) + other_samples.append(sample) #XZ: at current stage, other_samples doesn't include parent samples and F1 samples of primary group else: if (this_trait.data[sampleName].value != None) and (sample not in (fd.f1list + fd.parlist)): - #XZ: at current stage, the primary_samples is the same as fd.samplelist - #ZS: I tried defining primary_samples as fd.samplelist instead, but in some - #cases it ended up including the parent samples (1436869_at BXD) - primary_samples.append(sample) + primary_samples.append(sample) #XZ: at current stage, the primary_samples is the same as fd.samplelist / ZS: I tried defining primary_samples as fd.samplelist instead, but in some cases it ended up including the parent samples (1436869_at BXD) if len(other_samples) > 3: other_samples.sort(key=webqtlUtil.natsort_key) @@ -843,6 +836,7 @@ class ShowTrait(templatePage): primary_samples = map(lambda X:"_2nd_"+X, fd.f1list + fd.parlist) + primary_samples #XZ: note that fd.f1list and fd.parlist are added. all_samples = primary_samples + other_samples other_samples = map(lambda X:"_2nd_"+X, fd.f1list + fd.parlist) + other_samples #XZ: note that fd.f1list and fd.parlist are added. + print("ac1") # This is the one used for first sall3 self.MDP_menu.append(('All Cases','0')) self.MDP_menu.append(('%s Only' % fd.RISet, '1')) self.MDP_menu.append(('Non-%s Only' % fd.RISet, '2')) @@ -858,6 +852,7 @@ class ShowTrait(templatePage): all_samples = map(lambda X:"_2nd_"+X, fd.f1list + fd.parlist) + all_samples primary_samples = map(lambda X:"_2nd_"+X, fd.f1list + fd.parlist) + primary_samples else: + print("ac3") all_samples = samplelist other_samples.sort(key=webqtlUtil.natsort_key) @@ -891,6 +886,13 @@ class ShowTrait(templatePage): # continue vals1.append(thisValFull) + + + #vals1 = [[sampleNameOrig.replace("_2nd_", ""), + # this_trait.data[sampleName].val, + # this_trait.data[sampleName].var] + # for sampleNameOrig in all_samples]] + # #Using just the RISet sample for sampleNameOrig in primary_samples: @@ -943,21 +945,29 @@ class ShowTrait(templatePage): if i == 0 and len(vals) < 4: stats_container = HT.Div(id="stats_tabs", style="padding:10px;", Class="ui-tabs") #Needed for tabs; notice the "stats_script_text" below referring to this element stats_container.append(HT.Div(HT.Italic("Fewer than 4 case data were entered. No statistical analysis has been attempted."))) - stats_script_text = """$(function() { $("#stats_tabs").tabs();});""" + #stats_script_text = """$(function() { $("#stats_tabs").tabs();});""" + #stats_cell.append(stats_container) break elif (i == 1 and len(primary_samples) < 4): stats_container = HT.Div(id="stats_tabs%s" % i, Class="ui-tabs") - stats_container.append(HT.Div(HT.Italic("Fewer than 4 " + fd.RISet + " case data were entered. No statistical analysis has been attempted."))) + #stats_container.append(HT.Div(HT.Italic("Fewer than 4 " + fd.RISet + " case data were entered. No statistical analysis has been attempted."))) elif (i == 2 and len(other_samples) < 4): stats_container = HT.Div(id="stats_tabs%s" % i, Class="ui-tabs") stats_container.append(HT.Div(HT.Italic("Fewer than 4 non-" + fd.RISet + " case data were entered. No statistical analysis has been attempted."))) - stats_script_text = """$(function() { $("#stats_tabs0").tabs(); $("#stats_tabs1").tabs(); $("#stats_tabs2").tabs();});""" + #stats_script_text = """$(function() { $("#stats_tabs0").tabs(); $("#stats_tabs1").tabs(); $("#stats_tabs2").tabs();});""" else: - stats_script_text = """$(function() { $("#stats_tabs0").tabs(); $("#stats_tabs1").tabs(); $("#stats_tabs2").tabs();});""" + continue if len(vals) > 4: stats_tab_list = [HT.Href(text="Basic Table", url="#statstabs-1", Class="stats_tab"),HT.Href(text="Probability Plot", url="#statstabs-5", Class="stats_tab"), HT.Href(text="Bar Graph (by name)", url="#statstabs-3", Class="stats_tab"), HT.Href(text="Bar Graph (by rank)", url="#statstabs-4", Class="stats_tab"), HT.Href(text="Box Plot", url="#statstabs-2", Class="stats_tab")] + #stats_tabs = HT.List(stats_tab_list) + #stats_container.append(stats_tabs) + # + #table_div = HT.Div(id="statstabs-1") + #table_container = HT.Paragraph() + # + #statsTable = HT.TableLite(cellspacing=0, cellpadding=0, width="100%") if this_trait.db: if this_trait.cellid: @@ -967,6 +977,16 @@ class ShowTrait(templatePage): else: self.stats_data.append(BasicStatisticsFunctions.basicStatsTable(vals=vals)) + #statsTable.append(HT.TR(HT.TD(statsTableCell))) + + #table_container.append(statsTable) + #table_div.append(table_container) + #stats_container.append(table_div) + # + #normalplot_div = HT.Div(id="statstabs-5") + #normalplot_container = HT.Paragraph() + #normalplot = HT.TableLite(cellspacing=0, cellpadding=0, width="100%") + try: plotTitle = this_trait.symbol plotTitle += ": " @@ -983,7 +1003,7 @@ class ShowTrait(templatePage): #normalplot_container.append(normalplot) #normalplot_div.append(normalplot_container) #stats_container.append(normalplot_div) - + #boxplot_div = HT.Div(id="statstabs-2") #boxplot_container = HT.Paragraph() #boxplot = HT.TableLite(cellspacing=0, cellpadding=0, width="100%") @@ -992,8 +1012,8 @@ class ShowTrait(templatePage): #boxplot_container.append(boxplot) #boxplot_div.append(boxplot_container) #stats_container.append(boxplot_div) - - + + #barName_div = HT.Div(id="statstabs-3") #barName_container = HT.Paragraph() #barName = HT.TableLite(cellspacing=0, cellpadding=0, width="100%") @@ -1011,6 +1031,18 @@ class ShowTrait(templatePage): #barRank_container.append(barRank) #barRank_div.append(barRank_container) #stats_container.append(barRank_div) + + # stats_cell.append(stats_container) + # + #stats_script.append(stats_script_text) + # + #submitTable = HT.TableLite(cellspacing=0, cellpadding=0, width="100%", Class="target2") + #stats_row.append(stats_cell) + + #submitTable.append(stats_row) + #submitTable.append(stats_script) + + #title2Body.append(submitTable) def build_correlation_tools(self, fd, this_trait): @@ -1018,13 +1050,23 @@ class ShowTrait(templatePage): #species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, RISet=fd.RISet) RISetgp = fd.RISet - + # We're checking a string here! assert isinstance(RISetgp, basestring), "We need a string type thing here" if RISetgp[:3] == 'BXD': RISetgp = 'BXD' if RISetgp: + #sample_correlation = HT.Input(type='button',name='sample_corr', value=' Compute ', Class="button sample_corr") + #lit_correlation = HT.Input(type='button',name='lit_corr', value=' Compute ', Class="button lit_corr") + #tissue_correlation = HT.Input(type='button',name='tiss_corr', value=' Compute ', Class="button tiss_corr") + #methodText = HT.Span("Calculate:", Class="ffl fwb fs12") + # + #databaseText = HT.Span("Database:", Class="ffl fwb fs12") + #databaseMenu1 = HT.Select(name='database1') + #databaseMenu2 = HT.Select(name='database2') + #databaseMenu3 = HT.Select(name='database3') + dataset_menu = [] print("[tape4] webqtlConfig.PUBLICTHRESH:", webqtlConfig.PUBLICTHRESH) print("[tape4] type webqtlConfig.PUBLICTHRESH:", type(webqtlConfig.PUBLICTHRESH)) @@ -1048,24 +1090,164 @@ class ShowTrait(templatePage): self.cursor.execute('SELECT Id, Name FROM Tissue order by Name') for item in self.cursor.fetchall(): tissue_id, tissue_name = item + #databaseMenuSub = HT.Optgroup(label = '%s ------' % tissue_name) + #dataset_sub_menu = [] + print("phun9") self.cursor.execute('''SELECT ProbeSetFreeze.FullName,ProbeSetFreeze.Name FROM ProbeSetFreeze, ProbeFreeze, InbredSet WHERE ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id and ProbeFreeze.TissueId = %s and ProbeSetFreeze.public > %s and ProbeFreeze.InbredSetId = InbredSet.Id and InbredSet.Name like %s order by ProbeSetFreeze.CreateTime desc, ProbeSetFreeze.AvgId ''', (tissue_id, webqtlConfig.PUBLICTHRESH, "%" + RISetgp + "%")) + print("phun8") dataset_sub_menu = [item for item in self.cursor.fetchall() if item] + #for item2 in self.cursor.fetchall(): + # dataset_sub_menu.append(item2) if dataset_sub_menu: dataset_menu.append(dict(tissue=tissue_name, datasets=dataset_sub_menu)) - + # ("**heading**", tissue_name)) + #dataset_menu.append(dataset_sub_menu) + dataset_menu_selected = None if len(dataset_menu): if this_trait and this_trait.db: dataset_menu_selected = this_trait.db.name + #criteriaText = HT.Span("Return:", Class="ffl fwb fs12") + + #criteriaMenu1 = HT.Select(name='criteria1', selected='500', onMouseOver="if (NS4 || IE4) activateEl('criterias', event);") + return_results_menu = (100, 200, 500, 1000, 2000, 5000, 10000, 15000, 20000) return_results_menu_selected = 500 + + #criteriaMenu1.append(('top 100','100')) + #criteriaMenu1.append(('top 200','200')) + #criteriaMenu1.append(('top 500','500')) + #criteriaMenu1.append(('top 1000','1000')) + #criteriaMenu1.append(('top 2000','2000')) + #criteriaMenu1.append(('top 5000','5000')) + #criteriaMenu1.append(('top 10000','10000')) + #criteriaMenu1.append(('top 15000','15000')) + #criteriaMenu1.append(('top 20000','20000')) + + #self.MDPRow1 = HT.TR(Class='mdp1') + #self.MDPRow2 = HT.TR(Class='mdp2') + #self.MDPRow3 = HT.TR(Class='mdp3') + + # correlationMenus1 = HT.TableLite( + # HT.TR(HT.TD(databaseText), HT.TD(databaseMenu1, colspan="3")), + # HT.TR(HT.TD(criteriaText), HT.TD(criteriaMenu1)), + # self.MDPRow1, cellspacing=0, width="619px", cellpadding=2) + # correlationMenus1.append(HT.Input(name='orderBy', value='2', type='hidden')) # to replace the orderBy menu + # correlationMenus2 = HT.TableLite( + # HT.TR(HT.TD(databaseText), HT.TD(databaseMenu2, colspan="3")), + # HT.TR(HT.TD(criteriaText), HT.TD(criteriaMenu2)), + # self.MDPRow2, cellspacing=0, width="619px", cellpadding=2) + # correlationMenus2.append(HT.Input(name='orderBy', value='2', type='hidden')) + # correlationMenus3 = HT.TableLite( + # HT.TR(HT.TD(databaseText), HT.TD(databaseMenu3, colspan="3")), + # HT.TR(HT.TD(criteriaText), HT.TD(criteriaMenu3)), + # self.MDPRow3, cellspacing=0, width="619px", cellpadding=2) + # correlationMenus3.append(HT.Input(name='orderBy', value='2', type='hidden')) + # + #else: + # correlationMenus = "" + + #corr_row = HT.TR() + #corr_container = HT.Div(id="corr_tabs", Class="ui-tabs") + # + #if (this_trait.db != None and this_trait.db.type =='ProbeSet'): + # corr_tab_list = [HT.Href(text='Sample r', url="#corrtabs-1"), + # HT.Href(text='Literature r', url="#corrtabs-2"), + # HT.Href(text='Tissue r', url="#corrtabs-3")] + #else: + # corr_tab_list = [HT.Href(text='Sample r', url="#corrtabs-1")] + # + #corr_tabs = HT.List(corr_tab_list) + #corr_container.append(corr_tabs) + + #if correlationMenus1 or correlationMenus2 or correlationMenus3: + #sample_div = HT.Div(id="corrtabs-1") + #sample_container = HT.Span() + # + #sample_type = HT.Input(type="radio", name="sample_method", value="1", checked="checked") + #sample_type2 = HT.Input(type="radio", name="sample_method", value="2") + # + #sampleTable = HT.TableLite(cellspacing=0, cellpadding=0, width="100%") + #sampleTD = HT.TD(correlationMenus1, HT.BR(), + # "Pearson", sample_type, " "*3, "Spearman Rank", sample_type2, HT.BR(), HT.BR(), + # sample_correlation, HT.BR(), HT.BR()) + # + #sampleTD.append(HT.Span("The ", + # HT.Href(url="/correlationAnnotation.html#sample_r", target="_blank", + # text="Sample Correlation")," is computed between trait data and", + # " any ",HT.BR()," other traits in the sample database selected above. Use ", + # HT.Href(url="/glossary.html#Correlations", target="_blank", text="Spearman Rank"), + # HT.BR(),"when the sample size is small (<20) or when there are influential \ + # outliers.", HT.BR(),Class="fs12")) + + #sampleTable.append(sampleTD) + + #sample_container.append(sampleTable) + #sample_div.append(sample_container) + #corr_container.append(sample_div) + # + #literature_div = HT.Div(id="corrtabs-2") + #literature_container = HT.Span() + + #literatureTable = HT.TableLite(cellspacing=0, cellpadding=0, width="100%") + #literatureTD = HT.TD(correlationMenus2,HT.BR(),lit_correlation, HT.BR(), HT.BR()) + #literatureTD.append(HT.Span("The ", HT.Href(url="/correlationAnnotation.html", target="_blank",text="Literature Correlation"), " (Lit r) between this gene and all other genes is computed",HT.BR(), + # "using the ", HT.Href(url="https://grits.eecs.utk.edu/sgo/sgo.html", target="_blank", text="Semantic Gene Organizer"), + # " and human, rat, and mouse data from PubMed. ", HT.BR(),"Values are ranked by Lit r, \ + # but Sample r and Tissue r are also displayed.", HT.BR(), HT.BR(), + # HT.Href(url="/glossary.html#Literature", target="_blank", text="More on using Lit r"), Class="fs12")) + #literatureTable.append(literatureTD) + # + #literature_container.append(literatureTable) + #literature_div.append(literature_container) + # + #if this_trait.db != None: + # if (this_trait.db.type =='ProbeSet'): + # corr_container.append(literature_div) + # + #tissue_div = HT.Div(id="corrtabs-3") + #tissue_container = HT.Span() + # + #tissue_type = HT.Input(type="radio", name="tissue_method", value="4", checked="checked") + #tissue_type2 = HT.Input(type="radio", name="tissue_method", value="5") + # + #tissueTable = HT.TableLite(cellspacing=0, cellpadding=0, width="100%") + #tissueTD = HT.TD(correlationMenus3,HT.BR(), + # "Pearson", tissue_type, " "*3, "Spearman Rank", tissue_type2, HT.BR(), HT.BR(), + # tissue_correlation, HT.BR(), HT.BR()) + #tissueTD.append(HT.Span("The ", HT.Href(url="/webqtl/main.py?FormID=tissueCorrelation", target="_blank", text="Tissue Correlation"), + #" (Tissue r) estimates the similarity of expression of two genes",HT.BR()," or \ + #transcripts across different cells, tissues, or organs (",HT.Href(url="/correlationAnnotation.html#tissue_r", target="_blank", text="glossary"),"). \ + #Tissue correlations",HT.BR()," are generated by analyzing expression in multiple samples usually taken from \ + #single cases.",HT.BR(),HT.Bold("Pearson")," and ",HT.Bold("Spearman Rank")," correlations have been computed for all pairs \ + #of genes",HT.BR()," using data from mouse samples.", + #HT.BR(), Class="fs12")) + #tissueTable.append(tissueTD) + # + #tissue_container.append(tissueTable) + #tissue_div.append(tissue_container) + #if this_trait.db != None: + # if (this_trait.db.type =='ProbeSet'): + # corr_container.append(tissue_div) + # + #corr_row.append(HT.TD(corr_container)) + # + #corr_script = HT.Script(language="Javascript") + #corr_script_text = """$(function() { $("#corr_tabs").tabs(); });""" + #corr_script.append(corr_script_text) + # + #submitTable = HT.TableLite(cellspacing=0, cellpadding=0, width="100%", Class="target4") + #submitTable.append(corr_row) + #submitTable.append(corr_script) + # + #title3Body.append(submitTable) self.corr_tools = dict(dataset_menu = dataset_menu, dataset_menu_selected = dataset_menu_selected, return_results_menu = return_results_menu, @@ -1344,7 +1526,7 @@ class ShowTrait(templatePage): this_trait=this_trait, sample_group_type='primary', header="%s Only" % (fd.RISet)) - + print("primary_samples.attributes:", pf(primary_samples.attributes)) other_sample_names = [] @@ -1368,7 +1550,7 @@ class ShowTrait(templatePage): this_trait=this_trait, sample_group_type='other', header="Non-%s" % (fd.RISet)) - + self.sample_groups = (primary_samples, other_samples) else: self.sample_groups = (primary_samples,) @@ -1376,4 +1558,5 @@ class ShowTrait(templatePage): #TODO: Figure out why this if statement is written this way - Zach #if (other_sample_names or (fd.f1list and this_trait.data.has_key(fd.f1list[0])) # or (fd.f1list and this_trait.data.has_key(fd.f1list[1]))): + # print("hjs") fd.allsamplelist = all_samples_ordered diff --git a/wqflask/wqflask/static/new/javascript/show_trait.coffee b/wqflask/wqflask/static/new/javascript/show_trait.coffee index a22a3beb..a89b29af 100644 --- a/wqflask/wqflask/static/new/javascript/show_trait.coffee +++ b/wqflask/wqflask/static/new/javascript/show_trait.coffee @@ -244,7 +244,7 @@ $ -> ##Hide Sample Rows With No Value (value of 'x') Code hide_no_value = -> - $('.value_se').each (index, element) => + $('.value_se').each (_index, element) => if $(element).find('.trait_value_input').val() == 'x' $(element).hide() @@ -254,7 +254,7 @@ $ -> ##Block Outliers Code block_outliers = -> - $('.outlier').each (index, element) => + $('.outlier').each (_index, element) => $(element).find('.trait_value_input').val('x') $('#block_outliers').click(block_outliers) @@ -263,7 +263,7 @@ $ -> ##Reset Table Values Code reset_samples_table = -> - $('.trait_value_input').each (index, element) => + $('.trait_value_input').each (_index, element) => console.log("value is:", $(element).val()) $(element).val($(element).data('value')) console.log("data-value is:", $(element).data('value')) @@ -272,6 +272,51 @@ $ -> $('#reset').click(reset_samples_table) ##End Reset Table Values Code + + ##Get Sample Data From Table Code + + get_sample_table_data = -> + samples = {} + primary_samples = [] + other_samples = [] + $('#sortable1').find('.value_se').each (_index, element) => + row_data = {} + row_data.name = $.trim($(element).find('.column_name-Sample').text()) + row_data.value = $(element).find('.edit_sample_value').val() + if $(element).find('.edit_sample_se').length != -1 + row_data.se = $(element).find('.edit_sample_se').val() + for own key, attribute_info of js_data.attribute_names + row_data[attribute_info.name] = $.trim($(element).find( + '.column_name-'+attribute_info.name.replace(" ", "_")).text()) + console.log("row_data is:", row_data) + primary_samples.push(row_data) + console.log("primary_samples is:", primary_samples) + samples.primary_samples = primary_samples + samples.other_samples = other_samples + return samples + + + export_sample_table_data = -> + sample_data = get_sample_table_data() + console.log("sample_data is:", sample_data) + json_sample_data = JSON.stringify(sample_data) + console.log("json_sample_data is:", json_sample_data) + $.ajax( + url: '/export_trait_data' + type: 'POST' + data: "json_data=" + json_sample_data + ) + + $('#export').click(export_sample_table_data) + + + + ##End Get Sample Data from Table Code + + ##Export Sample Table Data Code + + ##End Export Sample Table Data Code + console.log("before registering block_outliers") $('#block_outliers').click(block_outliers) diff --git a/wqflask/wqflask/static/new/javascript/show_trait.js b/wqflask/wqflask/static/new/javascript/show_trait.js index d6c5226f..e4f477f3 100644 --- a/wqflask/wqflask/static/new/javascript/show_trait.js +++ b/wqflask/wqflask/static/new/javascript/show_trait.js @@ -11,7 +11,7 @@ }; $(function() { - var block_by_attribute_value, block_by_index, block_outliers, change_stats_value, create_value_dropdown, edit_data_change, hide_no_value, hide_tabs, make_table, on_corr_method_change, populate_sample_attributes_values_dropdown, process_id, reset_samples_table, show_hide_outliers, stats_mdp_change, update_stat_values; + var block_by_attribute_value, block_by_index, block_outliers, change_stats_value, create_value_dropdown, edit_data_change, export_sample_table_data, get_sample_table_data, hide_no_value, hide_tabs, make_table, on_corr_method_change, populate_sample_attributes_values_dropdown, process_id, reset_samples_table, show_hide_outliers, stats_mdp_change, update_stat_values; hide_tabs = function(start) { var x, _i, _results; _results = []; @@ -281,7 +281,7 @@ $('#block_by_index').click(block_by_index); hide_no_value = function() { var _this = this; - return $('.value_se').each(function(index, element) { + return $('.value_se').each(function(_index, element) { if ($(element).find('.trait_value_input').val() === 'x') { return $(element).hide(); } @@ -290,14 +290,14 @@ $('#hide_no_value').click(hide_no_value); block_outliers = function() { var _this = this; - return $('.outlier').each(function(index, element) { + return $('.outlier').each(function(_index, element) { return $(element).find('.trait_value_input').val('x'); }); }; $('#block_outliers').click(block_outliers); reset_samples_table = function() { var _this = this; - return $('.trait_value_input').each(function(index, element) { + return $('.trait_value_input').each(function(_index, element) { console.log("value is:", $(element).val()); $(element).val($(element).data('value')); console.log("data-value is:", $(element).data('value')); @@ -305,6 +305,47 @@ }); }; $('#reset').click(reset_samples_table); + get_sample_table_data = function() { + var other_samples, primary_samples, samples, + _this = this; + samples = {}; + primary_samples = []; + other_samples = []; + $('#sortable1').find('.value_se').each(function(_index, element) { + var attribute_info, key, row_data, _ref; + row_data = {}; + row_data.name = $.trim($(element).find('.column_name-Sample').text()); + row_data.value = $(element).find('.edit_sample_value').val(); + if ($(element).find('.edit_sample_se').length !== -1) { + row_data.se = $(element).find('.edit_sample_se').val(); + } + _ref = js_data.attribute_names; + for (key in _ref) { + if (!__hasProp.call(_ref, key)) continue; + attribute_info = _ref[key]; + row_data[attribute_info.name] = $.trim($(element).find('.column_name-' + attribute_info.name.replace(" ", "_")).text()); + } + console.log("row_data is:", row_data); + return primary_samples.push(row_data); + }); + console.log("primary_samples is:", primary_samples); + samples.primary_samples = primary_samples; + samples.other_samples = other_samples; + return samples; + }; + export_sample_table_data = function() { + var json_sample_data, sample_data; + sample_data = get_sample_table_data(); + console.log("sample_data is:", sample_data); + json_sample_data = JSON.stringify(sample_data); + console.log("json_sample_data is:", json_sample_data); + return $.ajax({ + url: '/export_trait_data', + type: 'POST', + data: "json_data=" + json_sample_data + }); + }; + $('#export').click(export_sample_table_data); console.log("before registering block_outliers"); $('#block_outliers').click(block_outliers); console.log("after registering block_outliers"); diff --git a/wqflask/wqflask/static/new/js_external/json2.js b/wqflask/wqflask/static/new/js_external/json2.js new file mode 100644 index 00000000..2373c74d --- /dev/null +++ b/wqflask/wqflask/static/new/js_external/json2.js @@ -0,0 +1,1298 @@ + + + + + +
+ + +
+ 1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 ++ |
+
+ |
+
Headers
++# This is an <h1> tag +## This is an <h2> tag +###### This is an <h6> tag+
Text styles
++*This text will be italic* +_This will also be italic_ +**This text will be bold** +__This will also be bold__ + +*You **can** combine them* ++
Unordered
++* Item 1 +* Item 2 + * Item 2a + * Item 2b+
Ordered
++1. Item 1 +2. Item 2 +3. Item 3 + * Item 3a + * Item 3b+
Images
++ +Format:  ++
Links
++http://github.com - automatic! +[GitHub](http://github.com)+
Blockquotes
++As Kanye West said: + +> We're living the future so +> the present is our past. ++
Syntax highlighting with GFM
+
+```javascript
+function fancyAlert(arg) {
+ if(arg) {
+ $.facebox({div:'#foo'})
+ }
+}
+```
+ Or, indent your code 4 spaces
++Here is a Python code example +without syntax highlighting: + + def foo: + if not bar: + return true+
Inline code for comments
++I think you should use an +`<addr>` element here instead.+