From e5ba48c06a76ac1d4d4725cf633de1cf3abfde2d Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Tue, 2 Oct 2012 14:52:40 -0500 Subject: Renamed trait_data_and_analysis.html to show_trait.html, DataEditingPage.py to show_trait.py, and trait_data_and_analysis.coffee to show_trait.coffee --- .../collection/ExportSelectionDetailInfoPage.py | 5 +- wqflask/wqflask/show_trait/DataEditingPage.py | 1557 -------------------- wqflask/wqflask/show_trait/show_trait.py | 1557 ++++++++++++++++++++ .../static/new/javascript/show_trait.coffee | 182 +++ .../new/javascript/trait_data_and_analysis.coffee | 182 --- .../new/javascript/trait_data_and_analysis.js | 207 --- wqflask/wqflask/templates/show_trait.html | 1346 +++++++++++++++++ .../wqflask/templates/trait_data_and_analysis.html | 1346 ----------------- wqflask/wqflask/views.py | 2 +- 9 files changed, 3090 insertions(+), 3294 deletions(-) delete mode 100755 wqflask/wqflask/show_trait/DataEditingPage.py create mode 100755 wqflask/wqflask/show_trait/show_trait.py create mode 100644 wqflask/wqflask/static/new/javascript/show_trait.coffee delete mode 100644 wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee delete mode 100644 wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js create mode 100644 wqflask/wqflask/templates/show_trait.html delete mode 100644 wqflask/wqflask/templates/trait_data_and_analysis.html diff --git a/web/webqtl/collection/ExportSelectionDetailInfoPage.py b/web/webqtl/collection/ExportSelectionDetailInfoPage.py index 69f293b2..a61b6f6e 100755 --- a/web/webqtl/collection/ExportSelectionDetailInfoPage.py +++ b/web/webqtl/collection/ExportSelectionDetailInfoPage.py @@ -128,7 +128,10 @@ class ExportSelectionDetailInfoPage(templatePage): count = count + 1 except: pass - mean = sum/count + if count = 0: + mean = 0 + else: + mean = sum/count text[-1].append(mean) text[-1] += testval if len(text[0]) < 255 or len(text) < 255: diff --git a/wqflask/wqflask/show_trait/DataEditingPage.py b/wqflask/wqflask/show_trait/DataEditingPage.py deleted file mode 100755 index 12e816f8..00000000 --- a/wqflask/wqflask/show_trait/DataEditingPage.py +++ /dev/null @@ -1,1557 +0,0 @@ -from __future__ import absolute_import, print_function, division - -import string -import os -import cPickle -#import pyXLWriter as xl - -from collections import OrderedDict - -from htmlgen import HTMLgen2 as HT - -from base import webqtlConfig -from base import webqtlCaseData -from wqflask.show_trait.SampleList import SampleList -from utility import webqtlUtil, Plot, Bunch -from base.webqtlTrait import webqtlTrait -from dbFunction import webqtlDatabaseFunction -from base.templatePage import templatePage -from basicStatistics import BasicStatisticsFunctions - -from pprint import pformat as pf - -############################################### -# -# Todo: Put in security to ensure that user has permission to access confidential data sets -# And add i.p.limiting as necessary -# -############################################## - - - -class DataEditingPage(templatePage): - - def __init__(self, fd): - self.fd = fd - - templatePage.__init__(self, fd) - assert self.openMysql(), "No datbase!" - - this_trait = self.get_this_trait() - - ##read genotype file - fd.RISet = this_trait.riset - fd.readGenotype() - - if not fd.genotype: - fd.readData(incf1=1) - - # determine data editing page format - variance_data_page = 0 - if fd.formID == 'varianceChoice': - variance_data_page = 1 - - if variance_data_page: - fmID='dataEditing' - else: - if fd.enablevariance: - fmID='pre_dataEditing' - else: - fmID='dataEditing' - - # Some fields, like method, are defaulted to None; otherwise in IE the field can't be changed using jquery - hddn = OrderedDict( - FormID = fmID, - RISet = fd.RISet, - submitID = '', - scale = 'physic', - additiveCheck = 'ON', - showSNP = 'ON', - showGenes = 'ON', - method = None, - parentsf14regression = 'OFF', - stats_method = '1', - chromosomes = '-1', - topten = '', - viewLegend = 'ON', - intervalAnalystCheck = 'ON', - valsHidden = 'OFF', - database = '', - criteria = None, - MDPChoice = None, - bootCheck = None, - permCheck = None, - applyVarianceSE = None, - sampleNames = '_', - sampleVals = '_', - sampleVars = '_', - otherStrainNames = '_', - otherStrainVals = '_', - otherStrainVars = '_', - extra_attributes = '_', - other_extra_attributes = '_' - ) - - if fd.enablevariance: - hddn['enablevariance']='ON' - if fd.incparentsf1: - hddn['incparentsf1']='ON' - - if this_trait: - hddn['fullname'] = str(this_trait) - try: - hddn['normalPlotTitle'] = this_trait.symbol - hddn['normalPlotTitle'] += ": " - hddn['normalPlotTitle'] += this_trait.name - except: - hddn['normalPlotTitle'] = str(this_trait.name) - hddn['fromDataEditingPage'] = 1 - if this_trait.db and this_trait.db.type and this_trait.db.type == 'ProbeSet': - hddn['trait_type'] = this_trait.db.type - if this_trait.cellid: - hddn['cellid'] = this_trait.cellid - else: - self.cursor.execute("SELECT h2 from ProbeSetXRef WHERE DataId = %d" % - this_trait.mysqlid) - heritability = self.cursor.fetchone() - hddn['heritability'] = heritability - - hddn['attribute_names'] = "" - - hddn['mappingMethodId'] = webqtlDatabaseFunction.getMappingMethod (cursor=self.cursor, - groupName=fd.RISet) - - if fd.identification: - hddn['identification'] = fd.identification - else: - hddn['identification'] = "Un-named trait" #If no identification, set identification to un-named - - self.dispTraitInformation(fd, "", hddn, this_trait) #Display trait information + function buttons - - if this_trait == None: - this_trait = webqtlTrait(data=fd.allTraitData, db=None) - - ## Variance submit page only - #if fd.enablevariance and not variance_data_page: - # pass - # #title2Body.append("Click the next button to go to the variance submission form.", - # # HT.Center(next,reset)) - #else: - # pass - # # We'll get this part working later - # print("Calling dispBasicStatistics") - # self.dispBasicStatistics(fd, this_trait) - - self.build_correlation_tools(fd, this_trait) - - - self.make_sample_lists(fd, variance_data_page, this_trait) - - if fd.allsamplelist: - hddn['allsamplelist'] = string.join(fd.allsamplelist, ' ') - - if fd.varianceDispName != 'Variance': - hddn['isSE'] = "yes" - - # We'll need access to this_trait and hddn in the Jinja2 Template, so we put it inside self - self.this_trait = this_trait - self.hddn = hddn - - self.sample_group_types = OrderedDict() - 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" - self.js_data = dict(sample_groups = self.sample_group_types) - - - def get_this_trait(self): - # When is traitInfos used? - #if traitInfos: - # database, ProbeSetID, CellID = traitInfos - #else: - database = self.fd['database'] - probe_set_id = self.fd['ProbeSetID'] - 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\ - &ProbeSetID=%s&RISet=%s&parentsf1=on' %(database, probe_set_id, self.fd['RISet']) - - if cell_id: - self.fd.identification = '%s/%s'%(self.fd.identification, cell_id) - this_trait.returnURL = '%s&CellID=%s' % (this_trait.returnURL, cell_id) - - 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. - addSelectionButton = "" - verifyButton = "" - rnaseqButton = "" - geneWikiButton = "" - probeButton = "" - similarButton = "" - snpBrowserButton = "" - updateButton = "" - - addSelectionText = "" - verifyText = "" - rnaseqText = "" - geneWikiText = "" - probeText = "" - similarText = "" - snpBrowserText = "" - updateText = "" - - if webqtlConfig.USERDICT[self.privilege] >= webqtlConfig.USERDICT['user']: - - if this_trait==None or this_trait.db.type=='Temp': - updateButton = HT.Href(url="#redirect", onClick="dataEditingFunc(document.getElementsByName('dataInput')[0],'addPublish');") - updateButton_img = HT.Image("/images/edit_icon.jpg", name="addnew", alt="Add To Publish", title="Add To Publish", style="border:none;") - updateButton.append(updateButton_img) - updateText = "Edit" - elif this_trait.db.type != 'Temp': - if this_trait.db.type == 'Publish' and this_trait.confidential: #XZ: confidential phenotype trait - if webqtlUtil.hasAccessToConfidentialPhenotypeTrait(privilege=self.privilege, userName=self.userName, authorized_users=this_trait.authorized_users): - updateButton = HT.Href(url="#redirect", onClick="dataEditingFunc(document.getElementsByName('dataInput')[0],'updateRecord');") - updateButton_img = HT.Image("/images/edit_icon.jpg", name="update", alt="Edit", title="Edit", style="border:none;") - updateButton.append(updateButton_img) - updateText = "Edit" - else: - updateButton = HT.Href(url="#redirect", onClick="dataEditingFunc(document.getElementsByName('dataInput')[0],'updateRecord');") - updateButton_img = HT.Image("/images/edit_icon.jpg", name="update", alt="Edit", title="Edit", style="border:none;") - updateButton.append(updateButton_img) - updateText = "Edit" - else: - pass - - self.cursor.execute('SELECT Name FROM InbredSet WHERE Name="%s"' % fd.RISet) - if this_trait: - addSelectionButton = HT.Href(url="#redirect", onClick="addRmvSelection('%s', document.getElementsByName('%s')[0], 'addToSelection');" % (fd.RISet, 'dataInput')) - addSelectionButton_img = HT.Image("/images/add_icon.jpg", name="addselect", alt="Add To Collection", title="Add To Collection", style="border:none;") - #addSelectionButton.append(addSelectionButton_img) - addSelectionText = "Add" - elif self.cursor.fetchall(): - addSelectionButton = HT.Href(url="#redirect", onClick="dataEditingFunc(document.getElementsByName('%s')[0], 'addRecord');" % ('dataInput')) - addSelectionButton_img = HT.Image("/images/add_icon.jpg", name="", alt="Add To Collection", title="Add To Collection", style="border:none;") - #addSelectionButton.append(addSelectionButton_img) - addSelectionText = "Add" - else: - pass - - - # Microarray database information to display - if this_trait and this_trait.db and this_trait.db.type == 'ProbeSet': #before, this line was only reached if this_trait != 0, but now we need to check - try: - hddn['GeneId'] = int(string.strip(this_trait.geneid)) - except: - pass - - #Info2Disp = HT.Paragraph() - - #XZ: Gene Symbol - if this_trait.symbol: - #XZ: Show SNP Browser only for mouse - if _Species == 'mouse': - self.cursor.execute("select geneSymbol from GeneList where geneSymbol = %s", this_trait.symbol) - geneName = self.cursor.fetchone() - if geneName: - snpurl = os.path.join(webqtlConfig.CGIDIR, "main.py?FormID=SnpBrowserResultPage&submitStatus=1&diffAlleles=True&customStrain=True") + "&geneName=%s" % geneName[0] - else: - if this_trait.chr and this_trait.mb: - snpurl = os.path.join(webqtlConfig.CGIDIR, "main.py?FormID=SnpBrowserResultPage&submitStatus=1&diffAlleles=True&customStrain=True") + \ - "&chr=%s&start=%2.6f&end=%2.6f" % (this_trait.chr, this_trait.mb-0.002, this_trait.mb+0.002) - else: - snpurl = "" - - if snpurl: - snpBrowserButton = HT.Href(url="#redirect", onClick="openNewWin('%s')" % snpurl) - snpBrowserButton_img = HT.Image("/images/snp_icon.jpg", name="snpbrowser", alt=" View SNPs and Indels ", title=" View SNPs and Indels ", style="border:none;") - #snpBrowserButton.append(snpBrowserButton_img) - snpBrowserText = "SNPs" - - #XZ: Show GeneWiki for all species - geneWikiButton = HT.Href(url="#redirect", onClick="openNewWin('%s')" % (os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE) + "?FormID=geneWiki&symbol=%s" % this_trait.symbol)) - geneWikiButton_img = HT.Image("/images/genewiki_icon.jpg", name="genewiki", alt=" Write or review comments about this gene ", title=" Write or review comments about this gene ", style="border:none;") - #geneWikiButton.append(geneWikiButton_img) - geneWikiText = 'GeneWiki' - - #XZ: display similar traits in other selected datasets - if this_trait and this_trait.db and this_trait.db.type=="ProbeSet" and this_trait.symbol: - if _Species in ("mouse", "rat", "human"): - similarUrl = "%s?cmd=sch&gene=%s&alias=1&species=%s" % (os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), this_trait.symbol, _Species) - similarButton = HT.Href(url="#redirect", onClick="openNewWin('%s')" % similarUrl) - similarButton_img = HT.Image("/images/find_icon.jpg", name="similar", alt=" Find similar expression data ", title=" Find similar expression data ", style="border:none;") - #similarButton.append(similarButton_img) - similarText = "Find" - else: - pass - #tbl.append(HT.TR( - #HT.TD('Gene Symbol: ', Class="fwb fs13", valign="top", nowrap="on", width=90), - #HT.TD(width=10, valign="top"), - #HT.TD(HT.Span('%s' % this_trait.symbol, valign="top", Class="fs13 fsI"), valign="top", width=740) - #)) - else: - tbl.append(HT.TR( - HT.TD('Gene Symbol: ', Class="fwb fs13", valign="top", nowrap="on"), - HT.TD(width=10, valign="top"), - HT.TD(HT.Span('Not available', Class="fs13 fsI"), valign="top") - )) - - - - ##display Verify Location button - try: - blatsequence = this_trait.blatseq - if not blatsequence: - #XZ, 06/03/2009: ProbeSet name is not unique among platforms. We should use ProbeSet Id instead. - self.cursor.execute("""SELECT Probe.Sequence, Probe.Name - FROM Probe, ProbeSet, ProbeSetFreeze, ProbeSetXRef - WHERE ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id AND - ProbeSetXRef.ProbeSetId = ProbeSet.Id AND - ProbeSetFreeze.Name = '%s' AND - ProbeSet.Name = '%s' AND - Probe.ProbeSetId = ProbeSet.Id order by Probe.SerialOrder""" % (this_trait.db.name, this_trait.name) ) - seqs = self.cursor.fetchall() - if not seqs: - raise ValueError - else: - blatsequence = '' - for seqt in seqs: - if int(seqt[1][-1]) % 2 == 1: - blatsequence += string.strip(seqt[0]) - - #--------Hongqiang add this part in order to not only blat ProbeSet, but also blat Probe - blatsequence = '%3E'+this_trait.name+'%0A'+blatsequence+'%0A' - #XZ, 06/03/2009: ProbeSet name is not unique among platforms. We should use ProbeSet Id instead. - self.cursor.execute("""SELECT Probe.Sequence, Probe.Name - FROM Probe, ProbeSet, ProbeSetFreeze, ProbeSetXRef - WHERE ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id AND - ProbeSetXRef.ProbeSetId = ProbeSet.Id AND - ProbeSetFreeze.Name = '%s' AND - ProbeSet.Name = '%s' AND - Probe.ProbeSetId = ProbeSet.Id order by Probe.SerialOrder""" % (this_trait.db.name, this_trait.name) ) - - seqs = self.cursor.fetchall() - for seqt in seqs: - if int(seqt[1][-1]) %2 == 1: - blatsequence += '%3EProbe_'+string.strip(seqt[1])+'%0A'+string.strip(seqt[0])+'%0A' - #-------- - #XZ, 07/16/2009: targetsequence is not used, so I comment out this block - #targetsequence = this_trait.targetseq - #if targetsequence==None: - # targetsequence = "" - - #XZ: Pay attention to the parameter of version (rn, mm, hg). They need to be changed if necessary. - if _Species == "rat": - UCSC_BLAT_URL = webqtlConfig.UCSC_BLAT % ('rat', 'rn3', blatsequence) - UTHSC_BLAT_URL = "" - elif _Species == "mouse": - UCSC_BLAT_URL = webqtlConfig.UCSC_BLAT % ('mouse', 'mm9', blatsequence) - UTHSC_BLAT_URL = webqtlConfig.UTHSC_BLAT % ('mouse', 'mm9', blatsequence) - elif _Species == "human": - UCSC_BLAT_URL = webqtlConfig.UCSC_BLAT % ('human', 'hg19', blatsequence) - UTHSC_BLAT_URL = "" - else: - UCSC_BLAT_URL = "" - UTHSC_BLAT_URL = "" - - if UCSC_BLAT_URL: - verifyButton = HT.Href(url="#", onClick="javascript:openNewWin('%s'); return false;" % UCSC_BLAT_URL) - verifyButtonImg = HT.Image("/images/verify_icon.jpg", name="verify", alt=" Check probe locations at UCSC ", - title=" Check probe locations at UCSC ", style="border:none;") - verifyButton.append(verifyButtonImg) - verifyText = 'Verify' - if UTHSC_BLAT_URL: - rnaseqButton = HT.Href(url="#", onClick="javascript:openNewWin('%s'); return false;" % UTHSC_BLAT_URL) - rnaseqButtonImg = HT.Image("/images/rnaseq_icon.jpg", name="rnaseq", alt=" View probes, SNPs, and RNA-seq at UTHSC ", - title=" View probes, SNPs, and RNA-seq at UTHSC ", style="border:none;") - rnaseqButton.append(rnaseqButtonImg) - rnaseqText = 'RNA-seq' - tSpan.append(HT.BR()) - except: - pass - - #Display probe information (if any) - if this_trait.db.name.find('Liver') >= 0 and this_trait.db.name.find('F2') < 0: - pass - else: - #query database for number of probes associated with trait; if count > 0, set probe tool button and text - self.cursor.execute("""SELECT count(*) - FROM Probe, ProbeSet - WHERE ProbeSet.Name = '%s' AND Probe.ProbeSetId = ProbeSet.Id""" % (this_trait.name)) - - probeResult = self.cursor.fetchone() - if probeResult[0] > 0: - probeurl = "%s?FormID=showProbeInfo&database=%s&ProbeSetID=%s&CellID=%s&RISet=%s&incparentsf1=ON" \ - % (os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), this_trait.db, this_trait.name, this_trait.cellid, fd.RISet) - probeButton = HT.Href(url="#", onClick="javascript:openNewWin('%s'); return false;" % probeurl) - probeButton_img = HT.Image("/images/probe_icon.jpg", name="probe", alt=" Check sequence of probes ", title=" Check sequence of probes ", style="border:none;") - #probeButton.append(probeButton_img) - probeText = "Probes" - - #tSpan = HT.Span(Class="fs13") - - #XZ: deal with blat score and blat specificity. - #if this_trait.probe_set_specificity or this_trait.probe_set_blat_score: - # if this_trait.probe_set_specificity: - # pass - # #tSpan.append(HT.Href(url="/blatInfo.html", target="_blank", title="Values higher than 2 for the specificity are good", text="BLAT specificity", Class="non_bold"),": %.1f" % float(this_trait.probe_set_specificity), " "*3) - # if this_trait.probe_set_blat_score: - # pass - # #tSpan.append("Score: %s" % int(this_trait.probe_set_blat_score), " "*2) - - #onClick="openNewWin('/blatInfo.html')" - - #tbl.append(HT.TR( - # HT.TD('Target Score: ', Class="fwb fs13", valign="top", nowrap="on"), - # HT.TD(width=10, valign="top"), - # HT.TD(tSpan, valign="top") - # )) - - #tSpan = HT.Span(Class="fs13") - #tSpan.append(str(_Species).capitalize(), ", ", fd.RISet) - # - #tbl.append(HT.TR( - # HT.TD('Species and Group: ', Class="fwb fs13", valign="top", nowrap="on"), - # HT.TD(width=10, valign="top"), - # HT.TD(tSpan, valign="top") - # )) - - #if this_trait.cellid: - # self.cursor.execute(""" - # select ProbeFreeze.Name from ProbeFreeze, ProbeSetFreeze - # where - # ProbeFreeze.Id = ProbeSetFreeze.ProbeFreezeId AND - # ProbeSetFreeze.Id = %d""" % this_trait.db.id) - # probeDBName = self.cursor.fetchone()[0] - # tbl.append(HT.TR( - # HT.TD('Database: ', Class="fs13 fwb", valign="top", nowrap="on"), - # HT.TD(width=10, valign="top"), - # HT.TD(HT.Span('%s' % probeDBName, Class="non_bold"), valign="top") - # )) - #else: - #tbl.append(HT.TR( - # HT.TD('Database: ', Class="fs13 fwb", valign="top", nowrap="on"), - # HT.TD(width=10, valign="top"), - # HT.TD(HT.Href(text=this_trait.db.fullname, url = webqtlConfig.INFOPAGEHREF % this_trait.db.name, - # target='_blank', Class="fs13 fwn non_bold"), valign="top") - # )) - #pass - - this_trait.species = _Species # We need this in the template, so we tuck it into this_trait - this_trait.database = this_trait.get_database() - - #XZ: ID links - if this_trait.genbankid or this_trait.geneid or this_trait.unigeneid or this_trait.omim or this_trait.homologeneid: - idStyle = "background:#dddddd;padding:2" - tSpan = HT.Span(Class="fs13") - if this_trait.geneid: - gurl = HT.Href(text= 'Gene', target='_blank',\ - url=webqtlConfig.NCBI_LOCUSID % this_trait.geneid, Class="fs14 fwn", title="Info from NCBI Entrez Gene") - #tSpan.append(HT.Span(gurl, style=idStyle), " "*2) - if this_trait.omim: - gurl = HT.Href(text= 'OMIM', target='_blank', \ - url= webqtlConfig.OMIM_ID % this_trait.omim,Class="fs14 fwn", title="Summary from On Mendelian Inheritance in Man") - #tSpan.append(HT.Span(gurl, style=idStyle), " "*2) - if this_trait.unigeneid: - try: - gurl = HT.Href(text= 'UniGene',target='_blank',\ - url= webqtlConfig.UNIGEN_ID % tuple(string.split(this_trait.unigeneid,'.')[:2]),Class="fs14 fwn", title="UniGene ID") - #tSpan.append(HT.Span(gurl, style=idStyle), " "*2) - except: - pass - if this_trait.genbankid: - this_trait.genbankid = '|'.join(this_trait.genbankid.split('|')[0:10]) - if this_trait.genbankid[-1]=='|': - this_trait.genbankid=this_trait.genbankid[0:-1] - gurl = HT.Href(text= 'GenBank', target='_blank', \ - url= webqtlConfig.GENBANK_ID % this_trait.genbankid,Class="fs14 fwn", title="Find the original GenBank sequence used to design the probes") - #tSpan.append(HT.Span(gurl, style=idStyle), " "*2) - if this_trait.homologeneid: - hurl = HT.Href(text= 'HomoloGene', target='_blank',\ - url=webqtlConfig.HOMOLOGENE_ID % this_trait.homologeneid, Class="fs14 fwn", title="Find similar genes in other species") - #tSpan.append(HT.Span(hurl, style=idStyle), " "*2) - - #tbl.append( - # HT.TR(HT.TD(colspan=3,height=6)), - # HT.TR( - # HT.TD('Resource Links: ', Class="fwb fs13", valign="top", nowrap="on"), - # HT.TD(width=10, valign="top"), - # HT.TD(tSpan, valign="top") - # )) - - #XZ: Resource Links: - if this_trait.symbol: - linkStyle = "background:#dddddd;padding:2" - tSpan = HT.Span(style="font-family:verdana,serif;font-size:13px") - - #XZ,12/26/2008: Gene symbol may contain single quotation mark. - #For example, Affymetrix, mouse430v2, 1440338_at, the symbol is 2'-Pde (geneid 211948) - #I debug this by using double quotation marks. - if _Species == "rat": - - #XZ, 7/16/2009: The url for SymAtlas (renamed as BioGPS) has changed. We don't need this any more - #symatlas_species = "Rattus norvegicus" - - #self.cursor.execute("SELECT kgID, chromosome,txStart,txEnd FROM GeneList_rn33 WHERE geneSymbol = '%s'" % this_trait.symbol) - self.cursor.execute('SELECT kgID, chromosome,txStart,txEnd FROM GeneList_rn33 WHERE geneSymbol = "%s"' % this_trait.symbol) - try: - kgId, chr, txst, txen = self.cursor.fetchall()[0] - if chr and txst and txen and kgId: - txst = int(txst*1000000) - txen = int(txen*1000000) - #tSpan.append(HT.Span(HT.Href(text= 'UCSC',target="mainFrame",\ - # title= 'Info from UCSC Genome Browser', url = webqtlConfig.UCSC_REFSEQ % ('rn3',kgId,chr,txst,txen),Class="fs14 fwn"), style=linkStyle) - # , " "*2) - except: - pass - if _Species == "mouse": - - #XZ, 7/16/2009: The url for SymAtlas (renamed as BioGPS) has changed. We don't need this any more - #symatlas_species = "Mus musculus" - - #self.cursor.execute("SELECT chromosome,txStart,txEnd FROM GeneList WHERE geneSymbol = '%s'" % this_trait.symbol) - self.cursor.execute('SELECT chromosome,txStart,txEnd FROM GeneList WHERE geneSymbol = "%s"' % this_trait.symbol) - try: - chr, txst, txen = self.cursor.fetchall()[0] - if chr and txst and txen and this_trait.refseq_transcriptid : - txst = int(txst*1000000) - txen = int(txen*1000000) - tSpan.append(HT.Span(HT.Href(text= 'UCSC',target="mainFrame",\ - title= 'Info from UCSC Genome Browser', url = webqtlConfig.UCSC_REFSEQ % ('mm9',this_trait.refseq_transcriptid,chr,txst,txen), - Class="fs14 fwn"), style=linkStyle) - , " "*2) - except: - pass - - #XZ, 7/16/2009: The url for SymAtlas (renamed as BioGPS) has changed. We don't need this any more - #tSpan.append(HT.Span(HT.Href(text= 'SymAtlas',target="mainFrame",\ - # url="http://symatlas.gnf.org/SymAtlas/bioentry?querytext=%s&query=14&species=%s&type=Expression" \ - # % (this_trait.symbol,symatlas_species),Class="fs14 fwn", \ - # title="Expression across many tissues and cell types"), style=linkStyle), " "*2) - if this_trait.geneid and (_Species == "mouse" or _Species == "rat" or _Species == "human"): - #tSpan.append(HT.Span(HT.Href(text= 'BioGPS',target="mainFrame",\ - # url="http://biogps.gnf.org/?org=%s#goto=genereport&id=%s" \ - # % (_Species, this_trait.geneid),Class="fs14 fwn", \ - # title="Expression across many tissues and cell types"), style=linkStyle), " "*2) - pass - #tSpan.append(HT.Span(HT.Href(text= 'STRING',target="mainFrame",\ - # url="http://string.embl.de/newstring_cgi/show_link_summary.pl?identifier=%s" \ - # % this_trait.symbol,Class="fs14 fwn", \ - # title="Protein interactions: known and inferred"), style=linkStyle), " "*2) - if this_trait.symbol: - #ZS: The "species scientific" converts the plain English species names we're using to their scientific names, which are needed for PANTHER's input - #We should probably use the scientific name along with the English name (if not instead of) elsewhere as well, given potential non-English speaking users - if _Species == "mouse": - species_scientific = "Mus%20musculus" - elif _Species == "rat": - species_scientific = "Rattus%20norvegicus" - elif _Species == "human": - species_scientific = "Homo%20sapiens" - elif _Species == "drosophila": - species_scientific = "Drosophila%20melanogaster" - else: - species_scientific = "all" - - species_scientific - #tSpan.append(HT.Span(HT.Href(text= 'PANTHER',target="mainFrame", \ - # url="http://www.pantherdb.org/genes/geneList.do?searchType=basic&fieldName=all&organism=%s&listType=1&fieldValue=%s" \ - # % (species_scientific, this_trait.symbol),Class="fs14 fwn", \ - # title="Gene and protein data resources from Celera-ABI"), style=linkStyle), " "*2) - else: - pass - #tSpan.append(HT.Span(HT.Href(text= 'BIND',target="mainFrame",\ - # url="http://bind.ca/?textquery=%s" \ - # % this_trait.symbol,Class="fs14 fwn", \ - # title="Protein interactions"), style=linkStyle), " "*2) - #if this_trait.geneid and (_Species == "mouse" or _Species == "rat" or _Species == "human"): - # tSpan.append(HT.Span(HT.Href(text= 'Gemma',target="mainFrame",\ - # url="http://www.chibi.ubc.ca/Gemma/gene/showGene.html?ncbiid=%s" \ - # % this_trait.geneid, Class="fs14 fwn", \ - # title="Meta-analysis of gene expression data"), style=linkStyle), " "*2) - #tSpan.append(HT.Span(HT.Href(text= 'SynDB',target="mainFrame",\ - # url="http://lily.uthsc.edu:8080/20091027_GNInterfaces/20091027_redirectSynDB.jsp?query=%s" \ - # % this_trait.symbol, Class="fs14 fwn", \ - # title="Brain synapse database"), style=linkStyle), " "*2) - #if _Species == "mouse": - # tSpan.append(HT.Span(HT.Href(text= 'ABA',target="mainFrame",\ - # url="http://mouse.brain-map.org/brain/%s.html" \ - # % this_trait.symbol, Class="fs14 fwn", \ - # title="Allen Brain Atlas"), style=linkStyle), " "*2) - - if this_trait.geneid: - #if _Species == "mouse": - # tSpan.append(HT.Span(HT.Href(text= 'ABA',target="mainFrame",\ - # url="http://www.brain-map.org/search.do?queryText=egeneid=%s" \ - # % this_trait.geneid, Class="fs14 fwn", \ - # title="Allen Brain Atlas"), style=linkStyle), " "*2) - if _Species == "human": - #tSpan.append(HT.Span(HT.Href(text= 'ABA',target="mainFrame",\ - # url="http://humancortex.alleninstitute.org/has/human/imageseries/search/1.html?searchSym=t&searchAlt=t&searchName=t&gene_term=&entrez_term=%s" \ - # % this_trait.geneid, Class="fs14 fwn", \ - # title="Allen Brain Atlas"), style=linkStyle), " "*2) - pass - - #tbl.append( - # HT.TR(HT.TD(colspan=3,height=6)), - # HT.TR( - # HT.TD(' '), - # HT.TD(width=10, valign="top"), - # HT.TD(tSpan, valign="top"))) - - #menuTable = HT.TableLite(cellpadding=2, Class="collap", width="620", id="target1") - #menuTable.append(HT.TR(HT.TD(addSelectionButton, align="center"),HT.TD(similarButton, align="center"),HT.TD(verifyButton, align="center"),HT.TD(geneWikiButton, align="center"),HT.TD(snpBrowserButton, align="center"),HT.TD(rnaseqButton, align="center"),HT.TD(probeButton, align="center"),HT.TD(updateButton, align="center"), colspan=3, height=50, style="vertical-align:bottom;")) - #menuTable.append(HT.TR(HT.TD(addSelectionText, align="center"),HT.TD(similarText, align="center"),HT.TD(verifyText, align="center"),HT.TD(geneWikiText, align="center"),HT.TD(snpBrowserText, align="center"),HT.TD(rnaseqText, align="center"),HT.TD(probeText, align="center"),HT.TD(updateText, align="center"), colspan=3, height=50, style="vertical-align:bottom;")) - - - #for zhou mi's cliques, need to be removed - #if self.database[:6] == 'BXDMic' and self.ProbeSetID in cliqueID: - # Info2Disp.append(HT.Strong('Clique Search: '),HT.Href(text='Search',\ - # url ="http://compbio1.utmem.edu/clique_go/results.php?pid=%s&pval_1=0&pval_2=0.001" \ - # % self.ProbeSetID,target='_blank',Class="normalsize"),HT.BR()) - - #linkTable.append(HT.TR(linkTD)) - #Info2Disp.append(linkTable) - #title1Body.append(tbl, HT.BR(), menuTable) - - elif this_trait and this_trait.db and this_trait.db.type =='Publish': #Check if trait is phenotype - - if this_trait.confidential: - pass - #tbl.append(HT.TR( - # HT.TD('Pre-publication Phenotype: ', Class="fs13 fwb", valign="top", nowrap="on", width=90), - # HT.TD(width=10, valign="top"), - # HT.TD(HT.Span(this_trait.pre_publication_description, Class="fs13"), valign="top", width=740) - # )) - if webqtlUtil.hasAccessToConfidentialPhenotypeTrait(privilege=self.privilege, userName=self.userName, authorized_users=this_trait.authorized_users): - #tbl.append(HT.TR( - # HT.TD('Post-publication Phenotype: ', Class="fs13 fwb", valign="top", nowrap="on", width=90), - # HT.TD(width=10, valign="top"), - # HT.TD(HT.Span(this_trait.post_publication_description, Class="fs13"), valign="top", width=740) - # )) - #tbl.append(HT.TR( - # HT.TD('Pre-publication Abbreviation: ', Class="fs13 fwb", valign="top", nowrap="on", width=90), - # HT.TD(width=10, valign="top"), - # HT.TD(HT.Span(this_trait.pre_publication_abbreviation, Class="fs13"), valign="top", width=740) - # )) - #tbl.append(HT.TR( - # HT.TD('Post-publication Abbreviation: ', Class="fs13 fwb", valign="top", nowrap="on", width=90), - # HT.TD(width=10, valign="top"), - # HT.TD(HT.Span(this_trait.post_publication_abbreviation, Class="fs13"), valign="top", width=740) - # )) - #tbl.append(HT.TR( - # HT.TD('Lab code: ', Class="fs13 fwb", valign="top", nowrap="on", width=90), - # HT.TD(width=10, valign="top"), - # HT.TD(HT.Span(this_trait.lab_code, Class="fs13"), valign="top", width=740) - # )) - pass - #tbl.append(HT.TR( - # HT.TD('Owner: ', Class="fs13 fwb", valign="top", nowrap="on", width=90), - # HT.TD(width=10, valign="top"), - # HT.TD(HT.Span(this_trait.owner, Class="fs13"), valign="top", width=740) - # )) - else: - pass - #tbl.append(HT.TR( - # HT.TD('Phenotype: ', Class="fs13 fwb", valign="top", nowrap="on", width=90), - # HT.TD(width=10, valign="top"), - # HT.TD(HT.Span(this_trait.post_publication_description, Class="fs13"), valign="top", width=740) - # )) - #tbl.append(HT.TR( - # HT.TD('Authors: ', Class="fs13 fwb", - # valign="top", nowrap="on", width=90), - # HT.TD(width=10, valign="top"), - # HT.TD(HT.Span(this_trait.authors, Class="fs13"), - # valign="top", width=740) - # )) - #tbl.append(HT.TR( - # HT.TD('Title: ', Class="fs13 fwb", - # valign="top", nowrap="on", width=90), - # HT.TD(width=10, valign="top"), - # HT.TD(HT.Span(this_trait.title, Class="fs13"), - # valign="top", width=740) - # )) - if this_trait.journal: - journal = this_trait.journal - if this_trait.year: - journal = this_trait.journal + " (%s)" % this_trait.year - # - #tbl.append(HT.TR( - # HT.TD('Journal: ', Class="fs13 fwb", - # valign="top", nowrap="on", width=90), - # HT.TD(width=10, valign="top"), - # HT.TD(HT.Span(journal, Class="fs13"), - # valign="top", width=740) - # )) - PubMedLink = "" - if this_trait.pubmed_id: - PubMedLink = webqtlConfig.PUBMEDLINK_URL % this_trait.pubmed_id - if PubMedLink: - #tbl.append(HT.TR( - # HT.TD('Link: ', Class="fs13 fwb", - # valign="top", nowrap="on", width=90), - # HT.TD(width=10, valign="top"), - # HT.TD(HT.Span(HT.Href(url=PubMedLink, text="PubMed",target='_blank',Class="fs14 fwn"), - # style = "background:#cddcff;padding:2"), valign="top", width=740) - # )) - pass - - menuTable = HT.TableLite(cellpadding=2, Class="collap", width="150", id="target1") - #menuTable.append(HT.TR(HT.TD(addSelectionButton, align="center"),HT.TD(updateButton, align="center"), colspan=3, height=50, style="vertical-align:bottom;")) - #menuTable.append(HT.TR(HT.TD(addSelectionText, align="center"),HT.TD(updateText, align="center"), colspan=3, height=50, style="vertical-align:bottom;")) - - #title1Body.append(tbl, HT.BR(), menuTable) - - elif this_trait and this_trait.db and this_trait.db.type == 'Geno': #Check if trait is genotype - - GenoInfo = HT.Paragraph() - if this_trait.chr and this_trait.mb: - location = ' Chr %s @ %s Mb' % (this_trait.chr,this_trait.mb) - else: - location = "not available" - - if this_trait.sequence and len(this_trait.sequence) > 100: - if _Species == "rat": - UCSC_BLAT_URL = webqtlConfig.UCSC_BLAT % ('rat', 'rn3', this_trait.sequence) - UTHSC_BLAT_URL = webqtlConfig.UTHSC_BLAT % ('rat', 'rn3', this_trait.sequence) - elif _Species == "mouse": - UCSC_BLAT_URL = webqtlConfig.UCSC_BLAT % ('mouse', 'mm9', this_trait.sequence) - UTHSC_BLAT_URL = webqtlConfig.UTHSC_BLAT % ('mouse', 'mm9', this_trait.sequence) - elif _Species == "human": - UCSC_BLAT_URL = webqtlConfig.UCSC_BLAT % ('human', 'hg19', blatsequence) - UTHSC_BLAT_URL = webqtlConfig.UTHSC_BLAT % ('human', 'hg19', this_trait.sequence) - else: - UCSC_BLAT_URL = "" - UTHSC_BLAT_URL = "" - if UCSC_BLAT_URL: - #verifyButton = HT.Href(url="#", onClick="openNewWin('%s')" % UCSC_BLAT_URL) - verifyButton = HT.Href(url="#") - verifyButtonImg = HT.Image("/images/verify_icon.jpg", name="verify", alt=" Check probe locations at UCSC ", title=" Check probe locations at UCSC ", style="border:none;") - verifyButton.append(verifyButtonImg) - verifyText = "Verify" - rnaseqButton = HT.Href(url="#", onClick="openNewWin('%s')" % UTHSC_BLAT_URL) - rnaseqButtonImg = HT.Image("/images/rnaseq_icon.jpg", name="rnaseq", alt=" View probes, SNPs, and RNA-seq at UTHSC ", title=" View probes, SNPs, and RNA-seq at UTHSC ", style="border:none;") - rnaseqButton.append(rnaseqButtonImg) - rnaseqText = "RNA-seq" - - #tbl.append(HT.TR( - # HT.TD('Location: ', Class="fs13 fwb", - # valign="top", nowrap="on", width=90), - # HT.TD(width=10, valign="top"), - # HT.TD(HT.Span(location, Class="fs13"), valign="top", width=740) - # ), - # HT.TR( - # HT.TD('SNP Search: ', Class="fs13 fwb", - # valign="top", nowrap="on", width=90), - # HT.TD(width=10, valign="top"), - # HT.TD(HT.Href("http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=snp&cmd=search&term=%s" % this_trait.name, 'NCBI',Class="fs13"), - # valign="top", width=740) - # )) - - menuTable = HT.TableLite(cellpadding=2, Class="collap", width="275", id="target1") - #menuTable.append(HT.TR(HT.TD(addSelectionButton, align="center"),HT.TD(verifyButton, align="center"),HT.TD(rnaseqButton, align="center"), HT.TD(updateButton, align="center"), colspan=3, height=50, style="vertical-align:bottom;")) - #menuTable.append(HT.TR(HT.TD(addSelectionText, align="center"),HT.TD(verifyText, align="center"),HT.TD(rnaseqText, align="center"), HT.TD(updateText, align="center"), colspan=3, height=50, style="vertical-align:bottom;")) - - #title1Body.append(tbl, HT.BR(), menuTable) - - elif (this_trait == None or this_trait.db.type == 'Temp'): #if temporary trait (user-submitted trait or PCA trait) - - #TempInfo = HT.Paragraph() - if this_trait != None: - if this_trait.description: - pass - #tbl.append(HT.TR(HT.TD(HT.Strong('Description: '),' %s ' % this_trait.description,HT.BR()), colspan=3, height=15)) - else: - tbl.append(HT.TR(HT.TD(HT.Strong('Description: '),'not available',HT.BR(),HT.BR()), colspan=3, height=15)) - - if (updateText == "Edit"): - menuTable = HT.TableLite(cellpadding=2, Class="collap", width="150", id="target1") - else: - menuTable = HT.TableLite(cellpadding=2, Class="collap", width="80", id="target1") - - #menuTable.append(HT.TR(HT.TD(addSelectionButton, align="right"),HT.TD(updateButton, align="right"), colspan=3, height=50, style="vertical-align:bottom;") ) - #menuTable.append(HT.TR(HT.TD(addSelectionText, align="center"),HT.TD(updateText, align="center"), colspan=3, height=50, style="vertical-align:bottom;")) - # - #title1Body.append(tbl, HT.BR(), menuTable) - - else: - pass - - - 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. - #stats_row = HT.TR() - #stats_cell = HT.TD() - - if fd.genotype.type == "riset": - samplelist = fd.f1list + fd.samplelist - else: - samplelist = fd.f1list + fd.parlist + fd.samplelist - - other_samples = [] #XZ: sample that is not of primary group - specialStrains = [] #XZ: This might be replaced by other_samples / ZS: It is just other samples without parent/f1 samples. - 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 - - for sample in this_trait.data.keys(): - sampleName = sample.replace("_2nd_", "") - if sample not in samplelist: - if this_trait.data[sampleName].value != None: - if sample.find('F1') < 0: - specialStrains.append(sample) - if (this_trait.data[sampleName].value != None) and (sample not in (fd.f1list + fd.parlist)): - 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)): - 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) - primary_samples.sort(key=webqtlUtil.natsort_key) - 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')) - - else: - if (len(other_samples) > 0) and (len(primary_samples) + len(other_samples) > 3): - print("ac2") - 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')) - all_samples = primary_samples - all_samples.sort(key=webqtlUtil.natsort_key) - 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) - all_samples = all_samples + other_samples - - if (len(other_samples)) > 0 and (len(primary_samples) + len(other_samples) > 4): - #One set of vals for all, selected sample only, and non-selected only - vals1 = [] - vals2 = [] - vals3 = [] - - #Using all samples/cases for values - #for sample_type in (all_samples, primary_samples, other_samples): - for sampleNameOrig in all_samples: - sampleName = sampleNameOrig.replace("_2nd_", "") - - #try: - print("* type of this_trait:", type(this_trait)) - print(" name:", this_trait.__class__.__name__) - print(" this_trait:", this_trait) - print(" type of this_trait.data[sampleName]:", type(this_trait.data[sampleName])) - print(" name:", this_trait.data[sampleName].__class__.__name__) - print(" this_trait.data[sampleName]:", this_trait.data[sampleName]) - thisval = this_trait.data[sampleName].value - print(" thisval:", thisval) - thisvar = this_trait.data[sampleName].variance - print(" thisvar:", thisvar) - thisValFull = [sampleName, thisval, thisvar] - print(" thisValFull:", thisValFull) - #except: - # 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: - sampleName = sampleNameOrig.replace("_2nd_", "") - - #try: - thisval = this_trait.data[sampleName].value - thisvar = this_trait.data[sampleName].variance - thisValFull = [sampleName,thisval,thisvar] - #except: - # continue - - vals2.append(thisValFull) - - #Using all non-RISet samples only - for sampleNameOrig in other_samples: - sampleName = sampleNameOrig.replace("_2nd_", "") - - #try: - thisval = this_trait.data[sampleName].value - thisvar = this_trait.data[sampleName].variance - thisValFull = [sampleName,thisval,thisvar] - #except: - # continue - - vals3.append(thisValFull) - - vals_set = [vals1,vals2,vals3] - - else: - vals = [] - - #Using all samples/cases for values - for sampleNameOrig in all_samples: - sampleName = sampleNameOrig.replace("_2nd_", "") - - #try: - thisval = this_trait.data[sampleName].value - thisvar = this_trait.data[sampleName].variance - thisValFull = [sampleName,thisval,thisvar] - #except: - # continue - - vals.append(thisValFull) - - vals_set = [vals] - - self.stats_data = [] - for i, vals in enumerate(vals_set): - 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_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."))) - 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();});""" - else: - #stats_container = HT.Div(id="stats_tabs%s" % i, Class="ui-tabs") - stats_script_text = """$(function() { $("#stats_tabs0").tabs(); $("#stats_tabs1").tabs(); $("#stats_tabs2").tabs();});""" - 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: - self.stats_data.append(BasicStatisticsFunctions.basicStatsTable(vals=vals, trait_type=this_trait.db.type, cellid=this_trait.cellid)) - else: - self.stats_data.append(BasicStatisticsFunctions.basicStatsTable(vals=vals, trait_type=this_trait.db.type)) - 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 += ": " - plotTitle += this_trait.name - except: - plotTitle = str(this_trait.name) - - #normalplot_img = BasicStatisticsFunctions.plotNormalProbability(vals=vals, RISet=fd.RISet, title=plotTitle, specialStrains=specialStrains) - #normalplot.append(HT.TR(HT.TD(normalplot_img))) - #normalplot.append(HT.TR(HT.TD(HT.BR(),HT.BR(),"This plot evaluates whether data are \ - #normally distributed. Different symbols represent different groups.",HT.BR(),HT.BR(), - #"More about ", HT.Href(url="http://en.wikipedia.org/wiki/Normal_probability_plot", - # target="_blank", text="Normal Probability Plots"), " and more about interpreting these plots from the ", HT.Href(url="/glossary.html#normal_probability", target="_blank", text="glossary")))) - #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%") - #boxplot_img, boxplot_link = BasicStatisticsFunctions.plotBoxPlot(vals) - #boxplot.append(HT.TR(HT.TD(boxplot_img, HT.P(), boxplot_link, align="left"))) - #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%") - #barName_img = BasicStatisticsFunctions.plotBarGraph(identification=fd.identification, RISet=fd.RISet, vals=vals, type="name") - #barName.append(HT.TR(HT.TD(barName_img))) - #barName_container.append(barName) - #barName_div.append(barName_container) - #stats_container.append(barName_div) - # - #barRank_div = HT.Div(id="statstabs-4") - #barRank_container = HT.Paragraph() - #barRank = HT.TableLite(cellspacing=0, cellpadding=0, width="100%") - #barRank_img = BasicStatisticsFunctions.plotBarGraph(identification=fd.identification, RISet=fd.RISet, vals=vals, type="rank") - #barRank.append(HT.TR(HT.TD(barRank_img))) - #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): - - #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)) - self.cursor.execute('''SELECT PublishFreeze.FullName,PublishFreeze.Name FROM - PublishFreeze,InbredSet WHERE PublishFreeze.InbredSetId = InbredSet.Id - and InbredSet.Name = %s and PublishFreeze.public > %s''', - (RISetgp, webqtlConfig.PUBLICTHRESH)) - for item in self.cursor.fetchall(): - dataset_menu.append(dict(tissue=None, - datasets=[item])) - - self.cursor.execute('''SELECT GenoFreeze.FullName,GenoFreeze.Name FROM GenoFreeze, - InbredSet WHERE GenoFreeze.InbredSetId = InbredSet.Id and InbredSet.Name = - %s and GenoFreeze.public > %s''', - (RISetgp, webqtlConfig.PUBLICTHRESH)) - for item in self.cursor.fetchall(): - dataset_menu.append(dict(tissue=None, - datasets=[item])) - - #03/09/2009: Xiaodong changed the SQL query to order by Name as requested by Rob. - 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, - return_results_menu_selected = return_results_menu_selected,) - - - def dispMappingTools(self, fd, title4Body, this_trait): - - _Species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, RISet=fd.RISet) - - RISetgp = fd.RISet - if RISetgp[:3] == 'BXD': - RISetgp = 'BXD' - - #check boxes - one for regular interval mapping, the other for composite - permCheck1= HT.Input(type='checkbox', Class='checkbox', name='permCheck1',checked="on") - bootCheck1= HT.Input(type='checkbox', Class='checkbox', name='bootCheck1',checked=0) - permCheck2= HT.Input(type='checkbox', Class='checkbox', name='permCheck2',checked="on") - bootCheck2= HT.Input(type='checkbox', Class='checkbox', name='bootCheck2',checked=0) - optionbox1 = HT.Input(type='checkbox', Class='checkbox', name='parentsf14regression1',checked=0) - optionbox2 = HT.Input(type='checkbox', Class='checkbox', name='parentsf14regression2',checked=0) - optionbox3 = HT.Input(type='checkbox', Class='checkbox', name='parentsf14regression3',checked=0) - applyVariance1 = HT.Input(name='applyVarianceSE1',type='checkbox', Class='checkbox') - applyVariance2 = HT.Input(name='applyVarianceSE2',type='checkbox', Class='checkbox') - - IntervalMappingButton=HT.Input(type='button' ,name='interval',value=' Compute ', Class="button") - CompositeMappingButton=HT.Input(type='button' ,name='composite',value=' Compute ', Class="button") - MarkerRegressionButton=HT.Input(type='button',name='marker', value=' Compute ', Class="button") - - chrText = HT.Span("Chromosome:", Class="ffl fwb fs12") - - # updated by NL 5-28-2010 - # Interval Mapping - chrMenu = HT.Select(name='chromosomes1') - chrMenu.append(("All",-1)) - for i in range(len(fd.genotype)): - if len(fd.genotype[i]) > 1: - chrMenu.append((fd.genotype[i].name, i)) - - #Menu for Composite Interval Mapping - chrMenu2 = HT.Select(name='chromosomes2') - chrMenu2.append(("All",-1)) - for i in range(len(fd.genotype)): - if len(fd.genotype[i]) > 1: - chrMenu2.append((fd.genotype[i].name, i)) - - if fd.genotype.Mbmap: - scaleText = HT.Span("Mapping Scale:", Class="ffl fwb fs12") - scaleMenu1 = HT.Select(name='scale1', - onChange="checkUncheck(window.document.dataInput.scale1.value, window.document.dataInput.permCheck1, window.document.dataInput.bootCheck1)") - scaleMenu1.append(("Megabase",'physic')) - scaleMenu1.append(("Centimorgan",'morgan')) - scaleMenu2 = HT.Select(name='scale2', - onChange="checkUncheck(window.document.dataInput.scale2.value, window.document.dataInput.permCheck2, window.document.dataInput.bootCheck2)") - scaleMenu2.append(("Megabase",'physic')) - scaleMenu2.append(("Centimorgan",'morgan')) - - controlText = HT.Span("Control Locus:", Class="ffl fwb fs12") - controlMenu = HT.Input(type="text", name="controlLocus", Class="controlLocus") - - if fd.genotype.Mbmap: - intMappingMenu = HT.TableLite( - HT.TR(HT.TD(chrText), HT.TD(chrMenu, colspan="3")), - HT.TR(HT.TD(scaleText), HT.TD(scaleMenu1)), - cellspacing=0, width="263px", cellpadding=2) - compMappingMenu = HT.TableLite( - HT.TR(HT.TD(chrText), HT.TD(chrMenu2, colspan="3")), - HT.TR(HT.TD(scaleText), HT.TD(scaleMenu2)), - HT.TR(HT.TD(controlText), HT.TD(controlMenu)), - cellspacing=0, width="325px", cellpadding=2) - else: - intMappingMenu = HT.TableLite( - HT.TR(HT.TD(chrText), HT.TD(chrMenu, colspan="3")), - cellspacing=0, width="263px", cellpadding=2) - compMappingMenu = HT.TableLite( - HT.TR(HT.TD(chrText), HT.TD(chrMenu2, colspan="3")), - HT.TR(HT.TD(controlText), HT.TD(controlMenu)), - cellspacing=0, width="325px", cellpadding=2) - - directPlotButton = "" - directPlotButton = HT.Input(type='button',name='', value=' Compute ',\ - onClick="dataEditingFunc(this.form,'directPlot');",Class="button") - directPlotSortText = HT.Span(HT.Bold("Sort by: "), Class="ffl fwb fs12") - directPlotSortMenu = HT.Select(name='graphSort') - directPlotSortMenu.append(('LRS Full',0)) - directPlotSortMenu.append(('LRS Interact',1)) - directPlotPermuText = HT.Span("Permutation Test (n=500)", Class="ffl fs12") - directPlotPermu = HT.Input(type='checkbox', Class='checkbox',name='directPermuCheckbox', checked="on") - pairScanReturnText = HT.Span(HT.Bold("Return: "), Class="ffl fwb fs12") - pairScanReturnMenu = HT.Select(name='pairScanReturn') - pairScanReturnMenu.append(('top 50','50')) - pairScanReturnMenu.append(('top 100','100')) - pairScanReturnMenu.append(('top 200','200')) - pairScanReturnMenu.append(('top 500','500')) - - pairScanMenus = HT.TableLite( - HT.TR(HT.TD(directPlotSortText), HT.TD(directPlotSortMenu)), - HT.TR(HT.TD(pairScanReturnText), HT.TD(pairScanReturnMenu)), - cellspacing=0, width="232px", cellpadding=2) - - markerSuggestiveText = HT.Span(HT.Bold("Display LRS greater than:"), Class="ffl fwb fs12") - markerSuggestive = HT.Input(name='suggestive', size=5, maxlength=8) - displayAllText = HT.Span(" Display all LRS ", Class="ffl fs12") - displayAll = HT.Input(name='displayAllLRS', type="checkbox", Class='checkbox') - useParentsText = HT.Span(" Use Parents ", Class="ffl fs12") - useParents = optionbox2 - applyVarianceText = HT.Span(" Use Weighted ", Class="ffl fs12") - - markerMenu = HT.TableLite( - HT.TR(HT.TD(markerSuggestiveText), HT.TD(markerSuggestive)), - HT.TR(HT.TD(displayAll,displayAllText)), - HT.TR(HT.TD(useParents,useParentsText)), - HT.TR(HT.TD(applyVariance2,applyVarianceText)), - cellspacing=0, width="263px", cellpadding=2) - - - mapping_row = HT.TR() - mapping_container = HT.Div(id="mapping_tabs", Class="ui-tabs") - - mapping_tab_list = [HT.Href(text="Interval", url="#mappingtabs-1"), HT.Href(text="Marker Regression", url="#mappingtabs-2"), HT.Href(text="Composite", url="#mappingtabs-3"), HT.Href(text="Pair-Scan", url="#mappingtabs-4")] - mapping_tabs = HT.List(mapping_tab_list) - mapping_container.append(mapping_tabs) - - interval_div = HT.Div(id="mappingtabs-1") - interval_container = HT.Span() - - intervalTable = HT.TableLite(cellspacing=0, cellpadding=0, width="100%") - intTD = HT.TD(valign="top",NOWRAP='ON', Class="fs12 fwn") - intTD.append(intMappingMenu,HT.BR()) - - intTD.append(permCheck1,'Permutation Test (n=2000)',HT.BR(), - bootCheck1,'Bootstrap Test (n=2000)', HT.BR(), optionbox1, 'Use Parents', HT.BR(), - applyVariance1,'Use Weighted', HT.BR(), HT.BR(),IntervalMappingButton, HT.BR(), HT.BR()) - intervalTable.append(HT.TR(intTD), HT.TR(HT.TD(HT.Span(HT.Href(url='/glossary.html#intmap', target='_blank', text='Interval Mapping'), - ' computes linkage maps for the entire genome or single',HT.BR(),' chromosomes.', - ' The ',HT.Href(url='/glossary.html#permutation', target='_blank', text='Permutation Test'),' estimates suggestive and significant ',HT.BR(),' linkage scores. \ - The ',HT.Href(url='/glossary.html#bootstrap', target='_blank', text='Bootstrap Test'), ' estimates the precision of the QTL location.' - ,Class="fs12"), HT.BR(), valign="top"))) - - interval_container.append(intervalTable) - interval_div.append(interval_container) - mapping_container.append(interval_div) - - # Marker Regression - - marker_div = HT.Div(id="mappingtabs-2") - marker_container = HT.Span() - - markerTable = HT.TableLite(cellspacing=0, cellpadding=0, width="100%") - markerTD = HT.TD(valign="top",NOWRAP='ON', Class="fs12 fwn") - markerTD.append(markerMenu,HT.BR()) - - markerTD.append(MarkerRegressionButton,HT.BR(),HT.BR()) - - markerTable.append(HT.TR(markerTD),HT.TR(HT.TD(HT.Span(HT.Href(url='/glossary.html#',target='_blank',text='Marker regression'), - ' computes and displays LRS values for individual markers.',HT.BR(), - 'This function also lists additive effects (phenotype units per allele) and', HT.BR(), - 'dominance deviations for some datasets.', HT.BR(),Class="fs12"), HT.BR(), valign="top"))) - - marker_container.append(markerTable) - marker_div.append(marker_container) - mapping_container.append(marker_div) - - # Composite interval mapping - composite_div = HT.Div(id="mappingtabs-3") - composite_container = HT.Span() - - compositeTable = HT.TableLite(cellspacing=0, cellpadding=3, width="100%") - compTD = HT.TD(valign="top",NOWRAP='ON', Class="fs12 fwn") - compTD.append(compMappingMenu,HT.BR()) - - compTD.append(permCheck2, 'Permutation Test (n=2000)',HT.BR(), - bootCheck2,'Bootstrap Test (n=2000)', HT.BR(), - optionbox3, 'Use Parents', HT.BR(), HT.BR(), CompositeMappingButton, HT.BR(), HT.BR()) - compositeTable.append(HT.TR(compTD), HT.TR(HT.TD(HT.Span(HT.Href(url='/glossary.html#Composite',target='_blank',text='Composite Interval Mapping'), - " allows you to control for a single marker as",HT.BR()," a cofactor. ", - "To find a control marker, run the ",HT.Bold("Marker Regression")," function."), - HT.BR(), valign="top"))) - - composite_container.append(compositeTable) - composite_div.append(composite_container) - mapping_container.append(composite_div) - - # Pair Scan - - pairscan_div = HT.Div(id="mappingtabs-4") - pairscan_container = HT.Span() - - pairScanTable = HT.TableLite(cellspacing=0, cellpadding=0, width="100%") - pairScanTD = HT.TD(NOWRAP='ON', Class="fs12 fwn") - pairScanTD.append(pairScanMenus,HT.BR()) - pairScanTD.append(directPlotPermu, directPlotPermuText, HT.BR(), HT.BR(), - directPlotButton,HT.BR(),HT.BR()) - pairScanTable.append(HT.TR(pairScanTD), HT.TR(HT.TD(HT.Span(HT.Href(url='/glossary.html#Pair_Scan', target="_blank", text='Pair-Scan'), - ' searches for pairs of chromosomal regions that are',HT.BR(), - 'involved in two-locus epistatic interactions.'), HT.BR(), valign="top"))) - - pairscan_container.append(pairScanTable) - pairscan_div.append(pairscan_container) - mapping_container.append(pairscan_div) - - mapping_row.append(HT.TD(mapping_container)) - - # Treat Interval Mapping and Marker Regression and Pair Scan as a group for displaying - #disable Interval Mapping and Marker Regression and Pair Scan for human and the dataset doesn't have genotype file - mappingMethodId = webqtlDatabaseFunction.getMappingMethod(cursor=self.cursor, groupName=RISetgp) - - mapping_script = HT.Script(language="Javascript") - mapping_script_text = """$(function() { $("#mapping_tabs").tabs(); });""" - mapping_script.append(mapping_script_text) - - submitTable = HT.TableLite(cellspacing=0, cellpadding=0, width="100%", Class="target2") - - if not mappingMethodId: - if int(mappingMethodId) == 1: - submitTable.append(mapping_row) - submitTable.append(mapping_script) - elif int(mappingMethodId) == 4: - # NL; 09-26-2011 testing for Human Genome Association function - mapping_row=HT.TR() - mapping_container = HT.Div(id="mapping_tabs", Class="ui-tabs") - - mapping_tab_list = [HT.Href(text="Genome Association", url="#mappingtabs-1")] - mapping_tabs = HT.List(mapping_tab_list) - mapping_container.append(mapping_tabs) - - # Genome Association - markerSuggestiveText = HT.Span(HT.Bold("P Value:"), Class="ffl fwb fs12") - - markerSuggestive = HT.Input(name='pValue', value='0.001', size=10, maxlength=20,onClick="this.value='';",onBlur="if(this.value==''){this.value='0.001'};") - markerMenu = HT.TableLite(HT.TR(HT.TD(markerSuggestiveText), HT.TD(markerSuggestive),HT.TD(HT.Italic('   (e.g. 0.001 or 1e-3 or 1E-3 or 3)'))),cellspacing=0, width="400px", cellpadding=2) - MarkerRegressionButton=HT.Input(type='button',name='computePlink', value='  Compute Using PLINK  ', onClick= "validatePvalue(this.form);", Class="button") - - marker_div = HT.Div(id="mappingtabs-1") - marker_container = HT.Span() - markerTable = HT.TableLite(cellspacing=0, cellpadding=0, width="100%") - markerTD = HT.TD(valign="top",NOWRAP='ON', Class="fs12 fwn") - markerTD.append(markerMenu,HT.BR()) - markerTD.append(MarkerRegressionButton,HT.BR(),HT.BR()) - markerTable.append(HT.TR(markerTD)) - - marker_container.append(markerTable) - marker_div.append(marker_container) - - mapping_container.append(marker_div) - mapping_row.append(HT.TD(mapping_container)) - submitTable.append(mapping_row) - submitTable.append(mapping_script) - else: - submitTable.append(HT.TR(HT.TD(HT.Div(HT.Italic("mappingMethodId %s has not been implemented for this dataset yet." % mappingMethodId), id="mapping_tabs", Class="ui-tabs")))) - submitTable.append(mapping_script) - - else: - submitTable.append(HT.TR(HT.TD(HT.Div(HT.Italic("Mapping options are disabled for data not matched with genotypes."), id="mapping_tabs", Class="ui-tabs")))) - submitTable.append(mapping_script) - - title4Body.append(submitTable) - - - def make_sample_lists(self, fd, variance_data_page, this_trait): - if fd.genotype.type == "riset": - all_samples_ordered = fd.f1list + fd.samplelist - else: - all_samples_ordered = fd.parlist + fd.f1list + fd.samplelist - - this_trait_samples = set(this_trait.data.keys()) - - primary_sample_names = all_samples_ordered - - print("-*- primary_samplelist is:", pf(primary_sample_names)) - - primary_samples = SampleList(self.cursor, - fd=fd, - variance_data_page=variance_data_page, - sample_names=primary_sample_names, - this_trait=this_trait, - sample_group_type='primary', - header="%s Only" % (fd.RISet)) - - print("primary_samples.attributes:", pf(primary_samples.attributes)) - - other_sample_names = [] - for sample in this_trait.data.keys(): - print("hjk - sample is:", sample) - if sample not in all_samples_ordered: - all_samples_ordered.append(sample) - other_sample_names.append(sample) - - if other_sample_names: - unappended_par_f1 = fd.f1list + fd.parlist - par_f1_samples = ["_2nd_" + sample for sample in unappended_par_f1] - - other_sample_names.sort() #Sort other samples - other_sample_names = par_f1_samples + other_sample_names - - other_samples = SampleList(self.cursor, - fd=fd, - variance_data_page=variance_data_page, - sample_names=other_sample_names, - 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,) - - #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/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py new file mode 100755 index 00000000..743e4ad6 --- /dev/null +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -0,0 +1,1557 @@ +from __future__ import absolute_import, print_function, division + +import string +import os +import cPickle +#import pyXLWriter as xl + +from collections import OrderedDict + +from htmlgen import HTMLgen2 as HT + +from base import webqtlConfig +from base import webqtlCaseData +from wqflask.show_trait.SampleList import SampleList +from utility import webqtlUtil, Plot, Bunch +from base.webqtlTrait import webqtlTrait +from dbFunction import webqtlDatabaseFunction +from base.templatePage import templatePage +from basicStatistics import BasicStatisticsFunctions + +from pprint import pformat as pf + +############################################### +# +# Todo: Put in security to ensure that user has permission to access confidential data sets +# And add i.p.limiting as necessary +# +############################################## + + + +class ShowTrait(templatePage): + + def __init__(self, fd): + self.fd = fd + + templatePage.__init__(self, fd) + assert self.openMysql(), "No datbase!" + + this_trait = self.get_this_trait() + + ##read genotype file + fd.RISet = this_trait.riset + fd.readGenotype() + + if not fd.genotype: + fd.readData(incf1=1) + + # determine data editing page format + variance_data_page = 0 + if fd.formID == 'varianceChoice': + variance_data_page = 1 + + if variance_data_page: + fmID='dataEditing' + else: + if fd.enablevariance: + fmID='pre_dataEditing' + else: + fmID='dataEditing' + + # Some fields, like method, are defaulted to None; otherwise in IE the field can't be changed using jquery + hddn = OrderedDict( + FormID = fmID, + RISet = fd.RISet, + submitID = '', + scale = 'physic', + additiveCheck = 'ON', + showSNP = 'ON', + showGenes = 'ON', + method = None, + parentsf14regression = 'OFF', + stats_method = '1', + chromosomes = '-1', + topten = '', + viewLegend = 'ON', + intervalAnalystCheck = 'ON', + valsHidden = 'OFF', + database = '', + criteria = None, + MDPChoice = None, + bootCheck = None, + permCheck = None, + applyVarianceSE = None, + sampleNames = '_', + sampleVals = '_', + sampleVars = '_', + otherStrainNames = '_', + otherStrainVals = '_', + otherStrainVars = '_', + extra_attributes = '_', + other_extra_attributes = '_' + ) + + if fd.enablevariance: + hddn['enablevariance']='ON' + if fd.incparentsf1: + hddn['incparentsf1']='ON' + + if this_trait: + hddn['fullname'] = str(this_trait) + try: + hddn['normalPlotTitle'] = this_trait.symbol + hddn['normalPlotTitle'] += ": " + hddn['normalPlotTitle'] += this_trait.name + except: + hddn['normalPlotTitle'] = str(this_trait.name) + hddn['fromDataEditingPage'] = 1 + if this_trait.db and this_trait.db.type and this_trait.db.type == 'ProbeSet': + hddn['trait_type'] = this_trait.db.type + if this_trait.cellid: + hddn['cellid'] = this_trait.cellid + else: + self.cursor.execute("SELECT h2 from ProbeSetXRef WHERE DataId = %d" % + this_trait.mysqlid) + heritability = self.cursor.fetchone() + hddn['heritability'] = heritability + + hddn['attribute_names'] = "" + + hddn['mappingMethodId'] = webqtlDatabaseFunction.getMappingMethod (cursor=self.cursor, + groupName=fd.RISet) + + if fd.identification: + hddn['identification'] = fd.identification + else: + hddn['identification'] = "Un-named trait" #If no identification, set identification to un-named + + self.dispTraitInformation(fd, "", hddn, this_trait) #Display trait information + function buttons + + if this_trait == None: + this_trait = webqtlTrait(data=fd.allTraitData, db=None) + + ## Variance submit page only + #if fd.enablevariance and not variance_data_page: + # pass + # #title2Body.append("Click the next button to go to the variance submission form.", + # # HT.Center(next,reset)) + #else: + # pass + # # We'll get this part working later + # print("Calling dispBasicStatistics") + # self.dispBasicStatistics(fd, this_trait) + + self.build_correlation_tools(fd, this_trait) + + + self.make_sample_lists(fd, variance_data_page, this_trait) + + if fd.allsamplelist: + hddn['allsamplelist'] = string.join(fd.allsamplelist, ' ') + + if fd.varianceDispName != 'Variance': + hddn['isSE'] = "yes" + + # We'll need access to this_trait and hddn in the Jinja2 Template, so we put it inside self + self.this_trait = this_trait + self.hddn = hddn + + self.sample_group_types = OrderedDict() + 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" + self.js_data = dict(sample_groups = self.sample_group_types) + + + def get_this_trait(self): + # When is traitInfos used? + #if traitInfos: + # database, ProbeSetID, CellID = traitInfos + #else: + database = self.fd['database'] + probe_set_id = self.fd['ProbeSetID'] + 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\ + &ProbeSetID=%s&RISet=%s&parentsf1=on' %(database, probe_set_id, self.fd['RISet']) + + if cell_id: + self.fd.identification = '%s/%s'%(self.fd.identification, cell_id) + this_trait.returnURL = '%s&CellID=%s' % (this_trait.returnURL, cell_id) + + 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. + addSelectionButton = "" + verifyButton = "" + rnaseqButton = "" + geneWikiButton = "" + probeButton = "" + similarButton = "" + snpBrowserButton = "" + updateButton = "" + + addSelectionText = "" + verifyText = "" + rnaseqText = "" + geneWikiText = "" + probeText = "" + similarText = "" + snpBrowserText = "" + updateText = "" + + if webqtlConfig.USERDICT[self.privilege] >= webqtlConfig.USERDICT['user']: + + if this_trait==None or this_trait.db.type=='Temp': + updateButton = HT.Href(url="#redirect", onClick="dataEditingFunc(document.getElementsByName('dataInput')[0],'addPublish');") + updateButton_img = HT.Image("/images/edit_icon.jpg", name="addnew", alt="Add To Publish", title="Add To Publish", style="border:none;") + updateButton.append(updateButton_img) + updateText = "Edit" + elif this_trait.db.type != 'Temp': + if this_trait.db.type == 'Publish' and this_trait.confidential: #XZ: confidential phenotype trait + if webqtlUtil.hasAccessToConfidentialPhenotypeTrait(privilege=self.privilege, userName=self.userName, authorized_users=this_trait.authorized_users): + updateButton = HT.Href(url="#redirect", onClick="dataEditingFunc(document.getElementsByName('dataInput')[0],'updateRecord');") + updateButton_img = HT.Image("/images/edit_icon.jpg", name="update", alt="Edit", title="Edit", style="border:none;") + updateButton.append(updateButton_img) + updateText = "Edit" + else: + updateButton = HT.Href(url="#redirect", onClick="dataEditingFunc(document.getElementsByName('dataInput')[0],'updateRecord');") + updateButton_img = HT.Image("/images/edit_icon.jpg", name="update", alt="Edit", title="Edit", style="border:none;") + updateButton.append(updateButton_img) + updateText = "Edit" + else: + pass + + self.cursor.execute('SELECT Name FROM InbredSet WHERE Name="%s"' % fd.RISet) + if this_trait: + addSelectionButton = HT.Href(url="#redirect", onClick="addRmvSelection('%s', document.getElementsByName('%s')[0], 'addToSelection');" % (fd.RISet, 'dataInput')) + addSelectionButton_img = HT.Image("/images/add_icon.jpg", name="addselect", alt="Add To Collection", title="Add To Collection", style="border:none;") + #addSelectionButton.append(addSelectionButton_img) + addSelectionText = "Add" + elif self.cursor.fetchall(): + addSelectionButton = HT.Href(url="#redirect", onClick="dataEditingFunc(document.getElementsByName('%s')[0], 'addRecord');" % ('dataInput')) + addSelectionButton_img = HT.Image("/images/add_icon.jpg", name="", alt="Add To Collection", title="Add To Collection", style="border:none;") + #addSelectionButton.append(addSelectionButton_img) + addSelectionText = "Add" + else: + pass + + + # Microarray database information to display + if this_trait and this_trait.db and this_trait.db.type == 'ProbeSet': #before, this line was only reached if this_trait != 0, but now we need to check + try: + hddn['GeneId'] = int(string.strip(this_trait.geneid)) + except: + pass + + #Info2Disp = HT.Paragraph() + + #XZ: Gene Symbol + if this_trait.symbol: + #XZ: Show SNP Browser only for mouse + if _Species == 'mouse': + self.cursor.execute("select geneSymbol from GeneList where geneSymbol = %s", this_trait.symbol) + geneName = self.cursor.fetchone() + if geneName: + snpurl = os.path.join(webqtlConfig.CGIDIR, "main.py?FormID=SnpBrowserResultPage&submitStatus=1&diffAlleles=True&customStrain=True") + "&geneName=%s" % geneName[0] + else: + if this_trait.chr and this_trait.mb: + snpurl = os.path.join(webqtlConfig.CGIDIR, "main.py?FormID=SnpBrowserResultPage&submitStatus=1&diffAlleles=True&customStrain=True") + \ + "&chr=%s&start=%2.6f&end=%2.6f" % (this_trait.chr, this_trait.mb-0.002, this_trait.mb+0.002) + else: + snpurl = "" + + if snpurl: + snpBrowserButton = HT.Href(url="#redirect", onClick="openNewWin('%s')" % snpurl) + snpBrowserButton_img = HT.Image("/images/snp_icon.jpg", name="snpbrowser", alt=" View SNPs and Indels ", title=" View SNPs and Indels ", style="border:none;") + #snpBrowserButton.append(snpBrowserButton_img) + snpBrowserText = "SNPs" + + #XZ: Show GeneWiki for all species + geneWikiButton = HT.Href(url="#redirect", onClick="openNewWin('%s')" % (os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE) + "?FormID=geneWiki&symbol=%s" % this_trait.symbol)) + geneWikiButton_img = HT.Image("/images/genewiki_icon.jpg", name="genewiki", alt=" Write or review comments about this gene ", title=" Write or review comments about this gene ", style="border:none;") + #geneWikiButton.append(geneWikiButton_img) + geneWikiText = 'GeneWiki' + + #XZ: display similar traits in other selected datasets + if this_trait and this_trait.db and this_trait.db.type=="ProbeSet" and this_trait.symbol: + if _Species in ("mouse", "rat", "human"): + similarUrl = "%s?cmd=sch&gene=%s&alias=1&species=%s" % (os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), this_trait.symbol, _Species) + similarButton = HT.Href(url="#redirect", onClick="openNewWin('%s')" % similarUrl) + similarButton_img = HT.Image("/images/find_icon.jpg", name="similar", alt=" Find similar expression data ", title=" Find similar expression data ", style="border:none;") + #similarButton.append(similarButton_img) + similarText = "Find" + else: + pass + #tbl.append(HT.TR( + #HT.TD('Gene Symbol: ', Class="fwb fs13", valign="top", nowrap="on", width=90), + #HT.TD(width=10, valign="top"), + #HT.TD(HT.Span('%s' % this_trait.symbol, valign="top", Class="fs13 fsI"), valign="top", width=740) + #)) + else: + tbl.append(HT.TR( + HT.TD('Gene Symbol: ', Class="fwb fs13", valign="top", nowrap="on"), + HT.TD(width=10, valign="top"), + HT.TD(HT.Span('Not available', Class="fs13 fsI"), valign="top") + )) + + + + ##display Verify Location button + try: + blatsequence = this_trait.blatseq + if not blatsequence: + #XZ, 06/03/2009: ProbeSet name is not unique among platforms. We should use ProbeSet Id instead. + self.cursor.execute("""SELECT Probe.Sequence, Probe.Name + FROM Probe, ProbeSet, ProbeSetFreeze, ProbeSetXRef + WHERE ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id AND + ProbeSetXRef.ProbeSetId = ProbeSet.Id AND + ProbeSetFreeze.Name = '%s' AND + ProbeSet.Name = '%s' AND + Probe.ProbeSetId = ProbeSet.Id order by Probe.SerialOrder""" % (this_trait.db.name, this_trait.name) ) + seqs = self.cursor.fetchall() + if not seqs: + raise ValueError + else: + blatsequence = '' + for seqt in seqs: + if int(seqt[1][-1]) % 2 == 1: + blatsequence += string.strip(seqt[0]) + + #--------Hongqiang add this part in order to not only blat ProbeSet, but also blat Probe + blatsequence = '%3E'+this_trait.name+'%0A'+blatsequence+'%0A' + #XZ, 06/03/2009: ProbeSet name is not unique among platforms. We should use ProbeSet Id instead. + self.cursor.execute("""SELECT Probe.Sequence, Probe.Name + FROM Probe, ProbeSet, ProbeSetFreeze, ProbeSetXRef + WHERE ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id AND + ProbeSetXRef.ProbeSetId = ProbeSet.Id AND + ProbeSetFreeze.Name = '%s' AND + ProbeSet.Name = '%s' AND + Probe.ProbeSetId = ProbeSet.Id order by Probe.SerialOrder""" % (this_trait.db.name, this_trait.name) ) + + seqs = self.cursor.fetchall() + for seqt in seqs: + if int(seqt[1][-1]) %2 == 1: + blatsequence += '%3EProbe_'+string.strip(seqt[1])+'%0A'+string.strip(seqt[0])+'%0A' + #-------- + #XZ, 07/16/2009: targetsequence is not used, so I comment out this block + #targetsequence = this_trait.targetseq + #if targetsequence==None: + # targetsequence = "" + + #XZ: Pay attention to the parameter of version (rn, mm, hg). They need to be changed if necessary. + if _Species == "rat": + UCSC_BLAT_URL = webqtlConfig.UCSC_BLAT % ('rat', 'rn3', blatsequence) + UTHSC_BLAT_URL = "" + elif _Species == "mouse": + UCSC_BLAT_URL = webqtlConfig.UCSC_BLAT % ('mouse', 'mm9', blatsequence) + UTHSC_BLAT_URL = webqtlConfig.UTHSC_BLAT % ('mouse', 'mm9', blatsequence) + elif _Species == "human": + UCSC_BLAT_URL = webqtlConfig.UCSC_BLAT % ('human', 'hg19', blatsequence) + UTHSC_BLAT_URL = "" + else: + UCSC_BLAT_URL = "" + UTHSC_BLAT_URL = "" + + if UCSC_BLAT_URL: + verifyButton = HT.Href(url="#", onClick="javascript:openNewWin('%s'); return false;" % UCSC_BLAT_URL) + verifyButtonImg = HT.Image("/images/verify_icon.jpg", name="verify", alt=" Check probe locations at UCSC ", + title=" Check probe locations at UCSC ", style="border:none;") + verifyButton.append(verifyButtonImg) + verifyText = 'Verify' + if UTHSC_BLAT_URL: + rnaseqButton = HT.Href(url="#", onClick="javascript:openNewWin('%s'); return false;" % UTHSC_BLAT_URL) + rnaseqButtonImg = HT.Image("/images/rnaseq_icon.jpg", name="rnaseq", alt=" View probes, SNPs, and RNA-seq at UTHSC ", + title=" View probes, SNPs, and RNA-seq at UTHSC ", style="border:none;") + rnaseqButton.append(rnaseqButtonImg) + rnaseqText = 'RNA-seq' + tSpan.append(HT.BR()) + except: + pass + + #Display probe information (if any) + if this_trait.db.name.find('Liver') >= 0 and this_trait.db.name.find('F2') < 0: + pass + else: + #query database for number of probes associated with trait; if count > 0, set probe tool button and text + self.cursor.execute("""SELECT count(*) + FROM Probe, ProbeSet + WHERE ProbeSet.Name = '%s' AND Probe.ProbeSetId = ProbeSet.Id""" % (this_trait.name)) + + probeResult = self.cursor.fetchone() + if probeResult[0] > 0: + probeurl = "%s?FormID=showProbeInfo&database=%s&ProbeSetID=%s&CellID=%s&RISet=%s&incparentsf1=ON" \ + % (os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), this_trait.db, this_trait.name, this_trait.cellid, fd.RISet) + probeButton = HT.Href(url="#", onClick="javascript:openNewWin('%s'); return false;" % probeurl) + probeButton_img = HT.Image("/images/probe_icon.jpg", name="probe", alt=" Check sequence of probes ", title=" Check sequence of probes ", style="border:none;") + #probeButton.append(probeButton_img) + probeText = "Probes" + + #tSpan = HT.Span(Class="fs13") + + #XZ: deal with blat score and blat specificity. + #if this_trait.probe_set_specificity or this_trait.probe_set_blat_score: + # if this_trait.probe_set_specificity: + # pass + # #tSpan.append(HT.Href(url="/blatInfo.html", target="_blank", title="Values higher than 2 for the specificity are good", text="BLAT specificity", Class="non_bold"),": %.1f" % float(this_trait.probe_set_specificity), " "*3) + # if this_trait.probe_set_blat_score: + # pass + # #tSpan.append("Score: %s" % int(this_trait.probe_set_blat_score), " "*2) + + #onClick="openNewWin('/blatInfo.html')" + + #tbl.append(HT.TR( + # HT.TD('Target Score: ', Class="fwb fs13", valign="top", nowrap="on"), + # HT.TD(width=10, valign="top"), + # HT.TD(tSpan, valign="top") + # )) + + #tSpan = HT.Span(Class="fs13") + #tSpan.append(str(_Species).capitalize(), ", ", fd.RISet) + # + #tbl.append(HT.TR( + # HT.TD('Species and Group: ', Class="fwb fs13", valign="top", nowrap="on"), + # HT.TD(width=10, valign="top"), + # HT.TD(tSpan, valign="top") + # )) + + #if this_trait.cellid: + # self.cursor.execute(""" + # select ProbeFreeze.Name from ProbeFreeze, ProbeSetFreeze + # where + # ProbeFreeze.Id = ProbeSetFreeze.ProbeFreezeId AND + # ProbeSetFreeze.Id = %d""" % this_trait.db.id) + # probeDBName = self.cursor.fetchone()[0] + # tbl.append(HT.TR( + # HT.TD('Database: ', Class="fs13 fwb", valign="top", nowrap="on"), + # HT.TD(width=10, valign="top"), + # HT.TD(HT.Span('%s' % probeDBName, Class="non_bold"), valign="top") + # )) + #else: + #tbl.append(HT.TR( + # HT.TD('Database: ', Class="fs13 fwb", valign="top", nowrap="on"), + # HT.TD(width=10, valign="top"), + # HT.TD(HT.Href(text=this_trait.db.fullname, url = webqtlConfig.INFOPAGEHREF % this_trait.db.name, + # target='_blank', Class="fs13 fwn non_bold"), valign="top") + # )) + #pass + + this_trait.species = _Species # We need this in the template, so we tuck it into this_trait + this_trait.database = this_trait.get_database() + + #XZ: ID links + if this_trait.genbankid or this_trait.geneid or this_trait.unigeneid or this_trait.omim or this_trait.homologeneid: + idStyle = "background:#dddddd;padding:2" + tSpan = HT.Span(Class="fs13") + if this_trait.geneid: + gurl = HT.Href(text= 'Gene', target='_blank',\ + url=webqtlConfig.NCBI_LOCUSID % this_trait.geneid, Class="fs14 fwn", title="Info from NCBI Entrez Gene") + #tSpan.append(HT.Span(gurl, style=idStyle), " "*2) + if this_trait.omim: + gurl = HT.Href(text= 'OMIM', target='_blank', \ + url= webqtlConfig.OMIM_ID % this_trait.omim,Class="fs14 fwn", title="Summary from On Mendelian Inheritance in Man") + #tSpan.append(HT.Span(gurl, style=idStyle), " "*2) + if this_trait.unigeneid: + try: + gurl = HT.Href(text= 'UniGene',target='_blank',\ + url= webqtlConfig.UNIGEN_ID % tuple(string.split(this_trait.unigeneid,'.')[:2]),Class="fs14 fwn", title="UniGene ID") + #tSpan.append(HT.Span(gurl, style=idStyle), " "*2) + except: + pass + if this_trait.genbankid: + this_trait.genbankid = '|'.join(this_trait.genbankid.split('|')[0:10]) + if this_trait.genbankid[-1]=='|': + this_trait.genbankid=this_trait.genbankid[0:-1] + gurl = HT.Href(text= 'GenBank', target='_blank', \ + url= webqtlConfig.GENBANK_ID % this_trait.genbankid,Class="fs14 fwn", title="Find the original GenBank sequence used to design the probes") + #tSpan.append(HT.Span(gurl, style=idStyle), " "*2) + if this_trait.homologeneid: + hurl = HT.Href(text= 'HomoloGene', target='_blank',\ + url=webqtlConfig.HOMOLOGENE_ID % this_trait.homologeneid, Class="fs14 fwn", title="Find similar genes in other species") + #tSpan.append(HT.Span(hurl, style=idStyle), " "*2) + + #tbl.append( + # HT.TR(HT.TD(colspan=3,height=6)), + # HT.TR( + # HT.TD('Resource Links: ', Class="fwb fs13", valign="top", nowrap="on"), + # HT.TD(width=10, valign="top"), + # HT.TD(tSpan, valign="top") + # )) + + #XZ: Resource Links: + if this_trait.symbol: + linkStyle = "background:#dddddd;padding:2" + tSpan = HT.Span(style="font-family:verdana,serif;font-size:13px") + + #XZ,12/26/2008: Gene symbol may contain single quotation mark. + #For example, Affymetrix, mouse430v2, 1440338_at, the symbol is 2'-Pde (geneid 211948) + #I debug this by using double quotation marks. + if _Species == "rat": + + #XZ, 7/16/2009: The url for SymAtlas (renamed as BioGPS) has changed. We don't need this any more + #symatlas_species = "Rattus norvegicus" + + #self.cursor.execute("SELECT kgID, chromosome,txStart,txEnd FROM GeneList_rn33 WHERE geneSymbol = '%s'" % this_trait.symbol) + self.cursor.execute('SELECT kgID, chromosome,txStart,txEnd FROM GeneList_rn33 WHERE geneSymbol = "%s"' % this_trait.symbol) + try: + kgId, chr, txst, txen = self.cursor.fetchall()[0] + if chr and txst and txen and kgId: + txst = int(txst*1000000) + txen = int(txen*1000000) + #tSpan.append(HT.Span(HT.Href(text= 'UCSC',target="mainFrame",\ + # title= 'Info from UCSC Genome Browser', url = webqtlConfig.UCSC_REFSEQ % ('rn3',kgId,chr,txst,txen),Class="fs14 fwn"), style=linkStyle) + # , " "*2) + except: + pass + if _Species == "mouse": + + #XZ, 7/16/2009: The url for SymAtlas (renamed as BioGPS) has changed. We don't need this any more + #symatlas_species = "Mus musculus" + + #self.cursor.execute("SELECT chromosome,txStart,txEnd FROM GeneList WHERE geneSymbol = '%s'" % this_trait.symbol) + self.cursor.execute('SELECT chromosome,txStart,txEnd FROM GeneList WHERE geneSymbol = "%s"' % this_trait.symbol) + try: + chr, txst, txen = self.cursor.fetchall()[0] + if chr and txst and txen and this_trait.refseq_transcriptid : + txst = int(txst*1000000) + txen = int(txen*1000000) + tSpan.append(HT.Span(HT.Href(text= 'UCSC',target="mainFrame",\ + title= 'Info from UCSC Genome Browser', url = webqtlConfig.UCSC_REFSEQ % ('mm9',this_trait.refseq_transcriptid,chr,txst,txen), + Class="fs14 fwn"), style=linkStyle) + , " "*2) + except: + pass + + #XZ, 7/16/2009: The url for SymAtlas (renamed as BioGPS) has changed. We don't need this any more + #tSpan.append(HT.Span(HT.Href(text= 'SymAtlas',target="mainFrame",\ + # url="http://symatlas.gnf.org/SymAtlas/bioentry?querytext=%s&query=14&species=%s&type=Expression" \ + # % (this_trait.symbol,symatlas_species),Class="fs14 fwn", \ + # title="Expression across many tissues and cell types"), style=linkStyle), " "*2) + if this_trait.geneid and (_Species == "mouse" or _Species == "rat" or _Species == "human"): + #tSpan.append(HT.Span(HT.Href(text= 'BioGPS',target="mainFrame",\ + # url="http://biogps.gnf.org/?org=%s#goto=genereport&id=%s" \ + # % (_Species, this_trait.geneid),Class="fs14 fwn", \ + # title="Expression across many tissues and cell types"), style=linkStyle), " "*2) + pass + #tSpan.append(HT.Span(HT.Href(text= 'STRING',target="mainFrame",\ + # url="http://string.embl.de/newstring_cgi/show_link_summary.pl?identifier=%s" \ + # % this_trait.symbol,Class="fs14 fwn", \ + # title="Protein interactions: known and inferred"), style=linkStyle), " "*2) + if this_trait.symbol: + #ZS: The "species scientific" converts the plain English species names we're using to their scientific names, which are needed for PANTHER's input + #We should probably use the scientific name along with the English name (if not instead of) elsewhere as well, given potential non-English speaking users + if _Species == "mouse": + species_scientific = "Mus%20musculus" + elif _Species == "rat": + species_scientific = "Rattus%20norvegicus" + elif _Species == "human": + species_scientific = "Homo%20sapiens" + elif _Species == "drosophila": + species_scientific = "Drosophila%20melanogaster" + else: + species_scientific = "all" + + species_scientific + #tSpan.append(HT.Span(HT.Href(text= 'PANTHER',target="mainFrame", \ + # url="http://www.pantherdb.org/genes/geneList.do?searchType=basic&fieldName=all&organism=%s&listType=1&fieldValue=%s" \ + # % (species_scientific, this_trait.symbol),Class="fs14 fwn", \ + # title="Gene and protein data resources from Celera-ABI"), style=linkStyle), " "*2) + else: + pass + #tSpan.append(HT.Span(HT.Href(text= 'BIND',target="mainFrame",\ + # url="http://bind.ca/?textquery=%s" \ + # % this_trait.symbol,Class="fs14 fwn", \ + # title="Protein interactions"), style=linkStyle), " "*2) + #if this_trait.geneid and (_Species == "mouse" or _Species == "rat" or _Species == "human"): + # tSpan.append(HT.Span(HT.Href(text= 'Gemma',target="mainFrame",\ + # url="http://www.chibi.ubc.ca/Gemma/gene/showGene.html?ncbiid=%s" \ + # % this_trait.geneid, Class="fs14 fwn", \ + # title="Meta-analysis of gene expression data"), style=linkStyle), " "*2) + #tSpan.append(HT.Span(HT.Href(text= 'SynDB',target="mainFrame",\ + # url="http://lily.uthsc.edu:8080/20091027_GNInterfaces/20091027_redirectSynDB.jsp?query=%s" \ + # % this_trait.symbol, Class="fs14 fwn", \ + # title="Brain synapse database"), style=linkStyle), " "*2) + #if _Species == "mouse": + # tSpan.append(HT.Span(HT.Href(text= 'ABA',target="mainFrame",\ + # url="http://mouse.brain-map.org/brain/%s.html" \ + # % this_trait.symbol, Class="fs14 fwn", \ + # title="Allen Brain Atlas"), style=linkStyle), " "*2) + + if this_trait.geneid: + #if _Species == "mouse": + # tSpan.append(HT.Span(HT.Href(text= 'ABA',target="mainFrame",\ + # url="http://www.brain-map.org/search.do?queryText=egeneid=%s" \ + # % this_trait.geneid, Class="fs14 fwn", \ + # title="Allen Brain Atlas"), style=linkStyle), " "*2) + if _Species == "human": + #tSpan.append(HT.Span(HT.Href(text= 'ABA',target="mainFrame",\ + # url="http://humancortex.alleninstitute.org/has/human/imageseries/search/1.html?searchSym=t&searchAlt=t&searchName=t&gene_term=&entrez_term=%s" \ + # % this_trait.geneid, Class="fs14 fwn", \ + # title="Allen Brain Atlas"), style=linkStyle), " "*2) + pass + + #tbl.append( + # HT.TR(HT.TD(colspan=3,height=6)), + # HT.TR( + # HT.TD(' '), + # HT.TD(width=10, valign="top"), + # HT.TD(tSpan, valign="top"))) + + #menuTable = HT.TableLite(cellpadding=2, Class="collap", width="620", id="target1") + #menuTable.append(HT.TR(HT.TD(addSelectionButton, align="center"),HT.TD(similarButton, align="center"),HT.TD(verifyButton, align="center"),HT.TD(geneWikiButton, align="center"),HT.TD(snpBrowserButton, align="center"),HT.TD(rnaseqButton, align="center"),HT.TD(probeButton, align="center"),HT.TD(updateButton, align="center"), colspan=3, height=50, style="vertical-align:bottom;")) + #menuTable.append(HT.TR(HT.TD(addSelectionText, align="center"),HT.TD(similarText, align="center"),HT.TD(verifyText, align="center"),HT.TD(geneWikiText, align="center"),HT.TD(snpBrowserText, align="center"),HT.TD(rnaseqText, align="center"),HT.TD(probeText, align="center"),HT.TD(updateText, align="center"), colspan=3, height=50, style="vertical-align:bottom;")) + + + #for zhou mi's cliques, need to be removed + #if self.database[:6] == 'BXDMic' and self.ProbeSetID in cliqueID: + # Info2Disp.append(HT.Strong('Clique Search: '),HT.Href(text='Search',\ + # url ="http://compbio1.utmem.edu/clique_go/results.php?pid=%s&pval_1=0&pval_2=0.001" \ + # % self.ProbeSetID,target='_blank',Class="normalsize"),HT.BR()) + + #linkTable.append(HT.TR(linkTD)) + #Info2Disp.append(linkTable) + #title1Body.append(tbl, HT.BR(), menuTable) + + elif this_trait and this_trait.db and this_trait.db.type =='Publish': #Check if trait is phenotype + + if this_trait.confidential: + pass + #tbl.append(HT.TR( + # HT.TD('Pre-publication Phenotype: ', Class="fs13 fwb", valign="top", nowrap="on", width=90), + # HT.TD(width=10, valign="top"), + # HT.TD(HT.Span(this_trait.pre_publication_description, Class="fs13"), valign="top", width=740) + # )) + if webqtlUtil.hasAccessToConfidentialPhenotypeTrait(privilege=self.privilege, userName=self.userName, authorized_users=this_trait.authorized_users): + #tbl.append(HT.TR( + # HT.TD('Post-publication Phenotype: ', Class="fs13 fwb", valign="top", nowrap="on", width=90), + # HT.TD(width=10, valign="top"), + # HT.TD(HT.Span(this_trait.post_publication_description, Class="fs13"), valign="top", width=740) + # )) + #tbl.append(HT.TR( + # HT.TD('Pre-publication Abbreviation: ', Class="fs13 fwb", valign="top", nowrap="on", width=90), + # HT.TD(width=10, valign="top"), + # HT.TD(HT.Span(this_trait.pre_publication_abbreviation, Class="fs13"), valign="top", width=740) + # )) + #tbl.append(HT.TR( + # HT.TD('Post-publication Abbreviation: ', Class="fs13 fwb", valign="top", nowrap="on", width=90), + # HT.TD(width=10, valign="top"), + # HT.TD(HT.Span(this_trait.post_publication_abbreviation, Class="fs13"), valign="top", width=740) + # )) + #tbl.append(HT.TR( + # HT.TD('Lab code: ', Class="fs13 fwb", valign="top", nowrap="on", width=90), + # HT.TD(width=10, valign="top"), + # HT.TD(HT.Span(this_trait.lab_code, Class="fs13"), valign="top", width=740) + # )) + pass + #tbl.append(HT.TR( + # HT.TD('Owner: ', Class="fs13 fwb", valign="top", nowrap="on", width=90), + # HT.TD(width=10, valign="top"), + # HT.TD(HT.Span(this_trait.owner, Class="fs13"), valign="top", width=740) + # )) + else: + pass + #tbl.append(HT.TR( + # HT.TD('Phenotype: ', Class="fs13 fwb", valign="top", nowrap="on", width=90), + # HT.TD(width=10, valign="top"), + # HT.TD(HT.Span(this_trait.post_publication_description, Class="fs13"), valign="top", width=740) + # )) + #tbl.append(HT.TR( + # HT.TD('Authors: ', Class="fs13 fwb", + # valign="top", nowrap="on", width=90), + # HT.TD(width=10, valign="top"), + # HT.TD(HT.Span(this_trait.authors, Class="fs13"), + # valign="top", width=740) + # )) + #tbl.append(HT.TR( + # HT.TD('Title: ', Class="fs13 fwb", + # valign="top", nowrap="on", width=90), + # HT.TD(width=10, valign="top"), + # HT.TD(HT.Span(this_trait.title, Class="fs13"), + # valign="top", width=740) + # )) + if this_trait.journal: + journal = this_trait.journal + if this_trait.year: + journal = this_trait.journal + " (%s)" % this_trait.year + # + #tbl.append(HT.TR( + # HT.TD('Journal: ', Class="fs13 fwb", + # valign="top", nowrap="on", width=90), + # HT.TD(width=10, valign="top"), + # HT.TD(HT.Span(journal, Class="fs13"), + # valign="top", width=740) + # )) + PubMedLink = "" + if this_trait.pubmed_id: + PubMedLink = webqtlConfig.PUBMEDLINK_URL % this_trait.pubmed_id + if PubMedLink: + #tbl.append(HT.TR( + # HT.TD('Link: ', Class="fs13 fwb", + # valign="top", nowrap="on", width=90), + # HT.TD(width=10, valign="top"), + # HT.TD(HT.Span(HT.Href(url=PubMedLink, text="PubMed",target='_blank',Class="fs14 fwn"), + # style = "background:#cddcff;padding:2"), valign="top", width=740) + # )) + pass + + menuTable = HT.TableLite(cellpadding=2, Class="collap", width="150", id="target1") + #menuTable.append(HT.TR(HT.TD(addSelectionButton, align="center"),HT.TD(updateButton, align="center"), colspan=3, height=50, style="vertical-align:bottom;")) + #menuTable.append(HT.TR(HT.TD(addSelectionText, align="center"),HT.TD(updateText, align="center"), colspan=3, height=50, style="vertical-align:bottom;")) + + #title1Body.append(tbl, HT.BR(), menuTable) + + elif this_trait and this_trait.db and this_trait.db.type == 'Geno': #Check if trait is genotype + + GenoInfo = HT.Paragraph() + if this_trait.chr and this_trait.mb: + location = ' Chr %s @ %s Mb' % (this_trait.chr,this_trait.mb) + else: + location = "not available" + + if this_trait.sequence and len(this_trait.sequence) > 100: + if _Species == "rat": + UCSC_BLAT_URL = webqtlConfig.UCSC_BLAT % ('rat', 'rn3', this_trait.sequence) + UTHSC_BLAT_URL = webqtlConfig.UTHSC_BLAT % ('rat', 'rn3', this_trait.sequence) + elif _Species == "mouse": + UCSC_BLAT_URL = webqtlConfig.UCSC_BLAT % ('mouse', 'mm9', this_trait.sequence) + UTHSC_BLAT_URL = webqtlConfig.UTHSC_BLAT % ('mouse', 'mm9', this_trait.sequence) + elif _Species == "human": + UCSC_BLAT_URL = webqtlConfig.UCSC_BLAT % ('human', 'hg19', blatsequence) + UTHSC_BLAT_URL = webqtlConfig.UTHSC_BLAT % ('human', 'hg19', this_trait.sequence) + else: + UCSC_BLAT_URL = "" + UTHSC_BLAT_URL = "" + if UCSC_BLAT_URL: + #verifyButton = HT.Href(url="#", onClick="openNewWin('%s')" % UCSC_BLAT_URL) + verifyButton = HT.Href(url="#") + verifyButtonImg = HT.Image("/images/verify_icon.jpg", name="verify", alt=" Check probe locations at UCSC ", title=" Check probe locations at UCSC ", style="border:none;") + verifyButton.append(verifyButtonImg) + verifyText = "Verify" + rnaseqButton = HT.Href(url="#", onClick="openNewWin('%s')" % UTHSC_BLAT_URL) + rnaseqButtonImg = HT.Image("/images/rnaseq_icon.jpg", name="rnaseq", alt=" View probes, SNPs, and RNA-seq at UTHSC ", title=" View probes, SNPs, and RNA-seq at UTHSC ", style="border:none;") + rnaseqButton.append(rnaseqButtonImg) + rnaseqText = "RNA-seq" + + #tbl.append(HT.TR( + # HT.TD('Location: ', Class="fs13 fwb", + # valign="top", nowrap="on", width=90), + # HT.TD(width=10, valign="top"), + # HT.TD(HT.Span(location, Class="fs13"), valign="top", width=740) + # ), + # HT.TR( + # HT.TD('SNP Search: ', Class="fs13 fwb", + # valign="top", nowrap="on", width=90), + # HT.TD(width=10, valign="top"), + # HT.TD(HT.Href("http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=snp&cmd=search&term=%s" % this_trait.name, 'NCBI',Class="fs13"), + # valign="top", width=740) + # )) + + menuTable = HT.TableLite(cellpadding=2, Class="collap", width="275", id="target1") + #menuTable.append(HT.TR(HT.TD(addSelectionButton, align="center"),HT.TD(verifyButton, align="center"),HT.TD(rnaseqButton, align="center"), HT.TD(updateButton, align="center"), colspan=3, height=50, style="vertical-align:bottom;")) + #menuTable.append(HT.TR(HT.TD(addSelectionText, align="center"),HT.TD(verifyText, align="center"),HT.TD(rnaseqText, align="center"), HT.TD(updateText, align="center"), colspan=3, height=50, style="vertical-align:bottom;")) + + #title1Body.append(tbl, HT.BR(), menuTable) + + elif (this_trait == None or this_trait.db.type == 'Temp'): #if temporary trait (user-submitted trait or PCA trait) + + #TempInfo = HT.Paragraph() + if this_trait != None: + if this_trait.description: + pass + #tbl.append(HT.TR(HT.TD(HT.Strong('Description: '),' %s ' % this_trait.description,HT.BR()), colspan=3, height=15)) + else: + tbl.append(HT.TR(HT.TD(HT.Strong('Description: '),'not available',HT.BR(),HT.BR()), colspan=3, height=15)) + + if (updateText == "Edit"): + menuTable = HT.TableLite(cellpadding=2, Class="collap", width="150", id="target1") + else: + menuTable = HT.TableLite(cellpadding=2, Class="collap", width="80", id="target1") + + #menuTable.append(HT.TR(HT.TD(addSelectionButton, align="right"),HT.TD(updateButton, align="right"), colspan=3, height=50, style="vertical-align:bottom;") ) + #menuTable.append(HT.TR(HT.TD(addSelectionText, align="center"),HT.TD(updateText, align="center"), colspan=3, height=50, style="vertical-align:bottom;")) + # + #title1Body.append(tbl, HT.BR(), menuTable) + + else: + pass + + + 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. + #stats_row = HT.TR() + #stats_cell = HT.TD() + + if fd.genotype.type == "riset": + samplelist = fd.f1list + fd.samplelist + else: + samplelist = fd.f1list + fd.parlist + fd.samplelist + + other_samples = [] #XZ: sample that is not of primary group + specialStrains = [] #XZ: This might be replaced by other_samples / ZS: It is just other samples without parent/f1 samples. + 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 + + for sample in this_trait.data.keys(): + sampleName = sample.replace("_2nd_", "") + if sample not in samplelist: + if this_trait.data[sampleName].value != None: + if sample.find('F1') < 0: + specialStrains.append(sample) + if (this_trait.data[sampleName].value != None) and (sample not in (fd.f1list + fd.parlist)): + 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)): + 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) + primary_samples.sort(key=webqtlUtil.natsort_key) + 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')) + + else: + if (len(other_samples) > 0) and (len(primary_samples) + len(other_samples) > 3): + print("ac2") + 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')) + all_samples = primary_samples + all_samples.sort(key=webqtlUtil.natsort_key) + 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) + all_samples = all_samples + other_samples + + if (len(other_samples)) > 0 and (len(primary_samples) + len(other_samples) > 4): + #One set of vals for all, selected sample only, and non-selected only + vals1 = [] + vals2 = [] + vals3 = [] + + #Using all samples/cases for values + #for sample_type in (all_samples, primary_samples, other_samples): + for sampleNameOrig in all_samples: + sampleName = sampleNameOrig.replace("_2nd_", "") + + #try: + print("* type of this_trait:", type(this_trait)) + print(" name:", this_trait.__class__.__name__) + print(" this_trait:", this_trait) + print(" type of this_trait.data[sampleName]:", type(this_trait.data[sampleName])) + print(" name:", this_trait.data[sampleName].__class__.__name__) + print(" this_trait.data[sampleName]:", this_trait.data[sampleName]) + thisval = this_trait.data[sampleName].value + print(" thisval:", thisval) + thisvar = this_trait.data[sampleName].variance + print(" thisvar:", thisvar) + thisValFull = [sampleName, thisval, thisvar] + print(" thisValFull:", thisValFull) + #except: + # 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: + sampleName = sampleNameOrig.replace("_2nd_", "") + + #try: + thisval = this_trait.data[sampleName].value + thisvar = this_trait.data[sampleName].variance + thisValFull = [sampleName,thisval,thisvar] + #except: + # continue + + vals2.append(thisValFull) + + #Using all non-RISet samples only + for sampleNameOrig in other_samples: + sampleName = sampleNameOrig.replace("_2nd_", "") + + #try: + thisval = this_trait.data[sampleName].value + thisvar = this_trait.data[sampleName].variance + thisValFull = [sampleName,thisval,thisvar] + #except: + # continue + + vals3.append(thisValFull) + + vals_set = [vals1,vals2,vals3] + + else: + vals = [] + + #Using all samples/cases for values + for sampleNameOrig in all_samples: + sampleName = sampleNameOrig.replace("_2nd_", "") + + #try: + thisval = this_trait.data[sampleName].value + thisvar = this_trait.data[sampleName].variance + thisValFull = [sampleName,thisval,thisvar] + #except: + # continue + + vals.append(thisValFull) + + vals_set = [vals] + + self.stats_data = [] + for i, vals in enumerate(vals_set): + 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_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."))) + 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();});""" + else: + #stats_container = HT.Div(id="stats_tabs%s" % i, Class="ui-tabs") + stats_script_text = """$(function() { $("#stats_tabs0").tabs(); $("#stats_tabs1").tabs(); $("#stats_tabs2").tabs();});""" + 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: + self.stats_data.append(BasicStatisticsFunctions.basicStatsTable(vals=vals, trait_type=this_trait.db.type, cellid=this_trait.cellid)) + else: + self.stats_data.append(BasicStatisticsFunctions.basicStatsTable(vals=vals, trait_type=this_trait.db.type)) + 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 += ": " + plotTitle += this_trait.name + except: + plotTitle = str(this_trait.name) + + #normalplot_img = BasicStatisticsFunctions.plotNormalProbability(vals=vals, RISet=fd.RISet, title=plotTitle, specialStrains=specialStrains) + #normalplot.append(HT.TR(HT.TD(normalplot_img))) + #normalplot.append(HT.TR(HT.TD(HT.BR(),HT.BR(),"This plot evaluates whether data are \ + #normally distributed. Different symbols represent different groups.",HT.BR(),HT.BR(), + #"More about ", HT.Href(url="http://en.wikipedia.org/wiki/Normal_probability_plot", + # target="_blank", text="Normal Probability Plots"), " and more about interpreting these plots from the ", HT.Href(url="/glossary.html#normal_probability", target="_blank", text="glossary")))) + #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%") + #boxplot_img, boxplot_link = BasicStatisticsFunctions.plotBoxPlot(vals) + #boxplot.append(HT.TR(HT.TD(boxplot_img, HT.P(), boxplot_link, align="left"))) + #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%") + #barName_img = BasicStatisticsFunctions.plotBarGraph(identification=fd.identification, RISet=fd.RISet, vals=vals, type="name") + #barName.append(HT.TR(HT.TD(barName_img))) + #barName_container.append(barName) + #barName_div.append(barName_container) + #stats_container.append(barName_div) + # + #barRank_div = HT.Div(id="statstabs-4") + #barRank_container = HT.Paragraph() + #barRank = HT.TableLite(cellspacing=0, cellpadding=0, width="100%") + #barRank_img = BasicStatisticsFunctions.plotBarGraph(identification=fd.identification, RISet=fd.RISet, vals=vals, type="rank") + #barRank.append(HT.TR(HT.TD(barRank_img))) + #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): + + #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)) + self.cursor.execute('''SELECT PublishFreeze.FullName,PublishFreeze.Name FROM + PublishFreeze,InbredSet WHERE PublishFreeze.InbredSetId = InbredSet.Id + and InbredSet.Name = %s and PublishFreeze.public > %s''', + (RISetgp, webqtlConfig.PUBLICTHRESH)) + for item in self.cursor.fetchall(): + dataset_menu.append(dict(tissue=None, + datasets=[item])) + + self.cursor.execute('''SELECT GenoFreeze.FullName,GenoFreeze.Name FROM GenoFreeze, + InbredSet WHERE GenoFreeze.InbredSetId = InbredSet.Id and InbredSet.Name = + %s and GenoFreeze.public > %s''', + (RISetgp, webqtlConfig.PUBLICTHRESH)) + for item in self.cursor.fetchall(): + dataset_menu.append(dict(tissue=None, + datasets=[item])) + + #03/09/2009: Xiaodong changed the SQL query to order by Name as requested by Rob. + 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, + return_results_menu_selected = return_results_menu_selected,) + + + def dispMappingTools(self, fd, title4Body, this_trait): + + _Species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, RISet=fd.RISet) + + RISetgp = fd.RISet + if RISetgp[:3] == 'BXD': + RISetgp = 'BXD' + + #check boxes - one for regular interval mapping, the other for composite + permCheck1= HT.Input(type='checkbox', Class='checkbox', name='permCheck1',checked="on") + bootCheck1= HT.Input(type='checkbox', Class='checkbox', name='bootCheck1',checked=0) + permCheck2= HT.Input(type='checkbox', Class='checkbox', name='permCheck2',checked="on") + bootCheck2= HT.Input(type='checkbox', Class='checkbox', name='bootCheck2',checked=0) + optionbox1 = HT.Input(type='checkbox', Class='checkbox', name='parentsf14regression1',checked=0) + optionbox2 = HT.Input(type='checkbox', Class='checkbox', name='parentsf14regression2',checked=0) + optionbox3 = HT.Input(type='checkbox', Class='checkbox', name='parentsf14regression3',checked=0) + applyVariance1 = HT.Input(name='applyVarianceSE1',type='checkbox', Class='checkbox') + applyVariance2 = HT.Input(name='applyVarianceSE2',type='checkbox', Class='checkbox') + + IntervalMappingButton=HT.Input(type='button' ,name='interval',value=' Compute ', Class="button") + CompositeMappingButton=HT.Input(type='button' ,name='composite',value=' Compute ', Class="button") + MarkerRegressionButton=HT.Input(type='button',name='marker', value=' Compute ', Class="button") + + chrText = HT.Span("Chromosome:", Class="ffl fwb fs12") + + # updated by NL 5-28-2010 + # Interval Mapping + chrMenu = HT.Select(name='chromosomes1') + chrMenu.append(("All",-1)) + for i in range(len(fd.genotype)): + if len(fd.genotype[i]) > 1: + chrMenu.append((fd.genotype[i].name, i)) + + #Menu for Composite Interval Mapping + chrMenu2 = HT.Select(name='chromosomes2') + chrMenu2.append(("All",-1)) + for i in range(len(fd.genotype)): + if len(fd.genotype[i]) > 1: + chrMenu2.append((fd.genotype[i].name, i)) + + if fd.genotype.Mbmap: + scaleText = HT.Span("Mapping Scale:", Class="ffl fwb fs12") + scaleMenu1 = HT.Select(name='scale1', + onChange="checkUncheck(window.document.dataInput.scale1.value, window.document.dataInput.permCheck1, window.document.dataInput.bootCheck1)") + scaleMenu1.append(("Megabase",'physic')) + scaleMenu1.append(("Centimorgan",'morgan')) + scaleMenu2 = HT.Select(name='scale2', + onChange="checkUncheck(window.document.dataInput.scale2.value, window.document.dataInput.permCheck2, window.document.dataInput.bootCheck2)") + scaleMenu2.append(("Megabase",'physic')) + scaleMenu2.append(("Centimorgan",'morgan')) + + controlText = HT.Span("Control Locus:", Class="ffl fwb fs12") + controlMenu = HT.Input(type="text", name="controlLocus", Class="controlLocus") + + if fd.genotype.Mbmap: + intMappingMenu = HT.TableLite( + HT.TR(HT.TD(chrText), HT.TD(chrMenu, colspan="3")), + HT.TR(HT.TD(scaleText), HT.TD(scaleMenu1)), + cellspacing=0, width="263px", cellpadding=2) + compMappingMenu = HT.TableLite( + HT.TR(HT.TD(chrText), HT.TD(chrMenu2, colspan="3")), + HT.TR(HT.TD(scaleText), HT.TD(scaleMenu2)), + HT.TR(HT.TD(controlText), HT.TD(controlMenu)), + cellspacing=0, width="325px", cellpadding=2) + else: + intMappingMenu = HT.TableLite( + HT.TR(HT.TD(chrText), HT.TD(chrMenu, colspan="3")), + cellspacing=0, width="263px", cellpadding=2) + compMappingMenu = HT.TableLite( + HT.TR(HT.TD(chrText), HT.TD(chrMenu2, colspan="3")), + HT.TR(HT.TD(controlText), HT.TD(controlMenu)), + cellspacing=0, width="325px", cellpadding=2) + + directPlotButton = "" + directPlotButton = HT.Input(type='button',name='', value=' Compute ',\ + onClick="dataEditingFunc(this.form,'directPlot');",Class="button") + directPlotSortText = HT.Span(HT.Bold("Sort by: "), Class="ffl fwb fs12") + directPlotSortMenu = HT.Select(name='graphSort') + directPlotSortMenu.append(('LRS Full',0)) + directPlotSortMenu.append(('LRS Interact',1)) + directPlotPermuText = HT.Span("Permutation Test (n=500)", Class="ffl fs12") + directPlotPermu = HT.Input(type='checkbox', Class='checkbox',name='directPermuCheckbox', checked="on") + pairScanReturnText = HT.Span(HT.Bold("Return: "), Class="ffl fwb fs12") + pairScanReturnMenu = HT.Select(name='pairScanReturn') + pairScanReturnMenu.append(('top 50','50')) + pairScanReturnMenu.append(('top 100','100')) + pairScanReturnMenu.append(('top 200','200')) + pairScanReturnMenu.append(('top 500','500')) + + pairScanMenus = HT.TableLite( + HT.TR(HT.TD(directPlotSortText), HT.TD(directPlotSortMenu)), + HT.TR(HT.TD(pairScanReturnText), HT.TD(pairScanReturnMenu)), + cellspacing=0, width="232px", cellpadding=2) + + markerSuggestiveText = HT.Span(HT.Bold("Display LRS greater than:"), Class="ffl fwb fs12") + markerSuggestive = HT.Input(name='suggestive', size=5, maxlength=8) + displayAllText = HT.Span(" Display all LRS ", Class="ffl fs12") + displayAll = HT.Input(name='displayAllLRS', type="checkbox", Class='checkbox') + useParentsText = HT.Span(" Use Parents ", Class="ffl fs12") + useParents = optionbox2 + applyVarianceText = HT.Span(" Use Weighted ", Class="ffl fs12") + + markerMenu = HT.TableLite( + HT.TR(HT.TD(markerSuggestiveText), HT.TD(markerSuggestive)), + HT.TR(HT.TD(displayAll,displayAllText)), + HT.TR(HT.TD(useParents,useParentsText)), + HT.TR(HT.TD(applyVariance2,applyVarianceText)), + cellspacing=0, width="263px", cellpadding=2) + + + mapping_row = HT.TR() + mapping_container = HT.Div(id="mapping_tabs", Class="ui-tabs") + + mapping_tab_list = [HT.Href(text="Interval", url="#mappingtabs-1"), HT.Href(text="Marker Regression", url="#mappingtabs-2"), HT.Href(text="Composite", url="#mappingtabs-3"), HT.Href(text="Pair-Scan", url="#mappingtabs-4")] + mapping_tabs = HT.List(mapping_tab_list) + mapping_container.append(mapping_tabs) + + interval_div = HT.Div(id="mappingtabs-1") + interval_container = HT.Span() + + intervalTable = HT.TableLite(cellspacing=0, cellpadding=0, width="100%") + intTD = HT.TD(valign="top",NOWRAP='ON', Class="fs12 fwn") + intTD.append(intMappingMenu,HT.BR()) + + intTD.append(permCheck1,'Permutation Test (n=2000)',HT.BR(), + bootCheck1,'Bootstrap Test (n=2000)', HT.BR(), optionbox1, 'Use Parents', HT.BR(), + applyVariance1,'Use Weighted', HT.BR(), HT.BR(),IntervalMappingButton, HT.BR(), HT.BR()) + intervalTable.append(HT.TR(intTD), HT.TR(HT.TD(HT.Span(HT.Href(url='/glossary.html#intmap', target='_blank', text='Interval Mapping'), + ' computes linkage maps for the entire genome or single',HT.BR(),' chromosomes.', + ' The ',HT.Href(url='/glossary.html#permutation', target='_blank', text='Permutation Test'),' estimates suggestive and significant ',HT.BR(),' linkage scores. \ + The ',HT.Href(url='/glossary.html#bootstrap', target='_blank', text='Bootstrap Test'), ' estimates the precision of the QTL location.' + ,Class="fs12"), HT.BR(), valign="top"))) + + interval_container.append(intervalTable) + interval_div.append(interval_container) + mapping_container.append(interval_div) + + # Marker Regression + + marker_div = HT.Div(id="mappingtabs-2") + marker_container = HT.Span() + + markerTable = HT.TableLite(cellspacing=0, cellpadding=0, width="100%") + markerTD = HT.TD(valign="top",NOWRAP='ON', Class="fs12 fwn") + markerTD.append(markerMenu,HT.BR()) + + markerTD.append(MarkerRegressionButton,HT.BR(),HT.BR()) + + markerTable.append(HT.TR(markerTD),HT.TR(HT.TD(HT.Span(HT.Href(url='/glossary.html#',target='_blank',text='Marker regression'), + ' computes and displays LRS values for individual markers.',HT.BR(), + 'This function also lists additive effects (phenotype units per allele) and', HT.BR(), + 'dominance deviations for some datasets.', HT.BR(),Class="fs12"), HT.BR(), valign="top"))) + + marker_container.append(markerTable) + marker_div.append(marker_container) + mapping_container.append(marker_div) + + # Composite interval mapping + composite_div = HT.Div(id="mappingtabs-3") + composite_container = HT.Span() + + compositeTable = HT.TableLite(cellspacing=0, cellpadding=3, width="100%") + compTD = HT.TD(valign="top",NOWRAP='ON', Class="fs12 fwn") + compTD.append(compMappingMenu,HT.BR()) + + compTD.append(permCheck2, 'Permutation Test (n=2000)',HT.BR(), + bootCheck2,'Bootstrap Test (n=2000)', HT.BR(), + optionbox3, 'Use Parents', HT.BR(), HT.BR(), CompositeMappingButton, HT.BR(), HT.BR()) + compositeTable.append(HT.TR(compTD), HT.TR(HT.TD(HT.Span(HT.Href(url='/glossary.html#Composite',target='_blank',text='Composite Interval Mapping'), + " allows you to control for a single marker as",HT.BR()," a cofactor. ", + "To find a control marker, run the ",HT.Bold("Marker Regression")," function."), + HT.BR(), valign="top"))) + + composite_container.append(compositeTable) + composite_div.append(composite_container) + mapping_container.append(composite_div) + + # Pair Scan + + pairscan_div = HT.Div(id="mappingtabs-4") + pairscan_container = HT.Span() + + pairScanTable = HT.TableLite(cellspacing=0, cellpadding=0, width="100%") + pairScanTD = HT.TD(NOWRAP='ON', Class="fs12 fwn") + pairScanTD.append(pairScanMenus,HT.BR()) + pairScanTD.append(directPlotPermu, directPlotPermuText, HT.BR(), HT.BR(), + directPlotButton,HT.BR(),HT.BR()) + pairScanTable.append(HT.TR(pairScanTD), HT.TR(HT.TD(HT.Span(HT.Href(url='/glossary.html#Pair_Scan', target="_blank", text='Pair-Scan'), + ' searches for pairs of chromosomal regions that are',HT.BR(), + 'involved in two-locus epistatic interactions.'), HT.BR(), valign="top"))) + + pairscan_container.append(pairScanTable) + pairscan_div.append(pairscan_container) + mapping_container.append(pairscan_div) + + mapping_row.append(HT.TD(mapping_container)) + + # Treat Interval Mapping and Marker Regression and Pair Scan as a group for displaying + #disable Interval Mapping and Marker Regression and Pair Scan for human and the dataset doesn't have genotype file + mappingMethodId = webqtlDatabaseFunction.getMappingMethod(cursor=self.cursor, groupName=RISetgp) + + mapping_script = HT.Script(language="Javascript") + mapping_script_text = """$(function() { $("#mapping_tabs").tabs(); });""" + mapping_script.append(mapping_script_text) + + submitTable = HT.TableLite(cellspacing=0, cellpadding=0, width="100%", Class="target2") + + if not mappingMethodId: + if int(mappingMethodId) == 1: + submitTable.append(mapping_row) + submitTable.append(mapping_script) + elif int(mappingMethodId) == 4: + # NL; 09-26-2011 testing for Human Genome Association function + mapping_row=HT.TR() + mapping_container = HT.Div(id="mapping_tabs", Class="ui-tabs") + + mapping_tab_list = [HT.Href(text="Genome Association", url="#mappingtabs-1")] + mapping_tabs = HT.List(mapping_tab_list) + mapping_container.append(mapping_tabs) + + # Genome Association + markerSuggestiveText = HT.Span(HT.Bold("P Value:"), Class="ffl fwb fs12") + + markerSuggestive = HT.Input(name='pValue', value='0.001', size=10, maxlength=20,onClick="this.value='';",onBlur="if(this.value==''){this.value='0.001'};") + markerMenu = HT.TableLite(HT.TR(HT.TD(markerSuggestiveText), HT.TD(markerSuggestive),HT.TD(HT.Italic('   (e.g. 0.001 or 1e-3 or 1E-3 or 3)'))),cellspacing=0, width="400px", cellpadding=2) + MarkerRegressionButton=HT.Input(type='button',name='computePlink', value='  Compute Using PLINK  ', onClick= "validatePvalue(this.form);", Class="button") + + marker_div = HT.Div(id="mappingtabs-1") + marker_container = HT.Span() + markerTable = HT.TableLite(cellspacing=0, cellpadding=0, width="100%") + markerTD = HT.TD(valign="top",NOWRAP='ON', Class="fs12 fwn") + markerTD.append(markerMenu,HT.BR()) + markerTD.append(MarkerRegressionButton,HT.BR(),HT.BR()) + markerTable.append(HT.TR(markerTD)) + + marker_container.append(markerTable) + marker_div.append(marker_container) + + mapping_container.append(marker_div) + mapping_row.append(HT.TD(mapping_container)) + submitTable.append(mapping_row) + submitTable.append(mapping_script) + else: + submitTable.append(HT.TR(HT.TD(HT.Div(HT.Italic("mappingMethodId %s has not been implemented for this dataset yet." % mappingMethodId), id="mapping_tabs", Class="ui-tabs")))) + submitTable.append(mapping_script) + + else: + submitTable.append(HT.TR(HT.TD(HT.Div(HT.Italic("Mapping options are disabled for data not matched with genotypes."), id="mapping_tabs", Class="ui-tabs")))) + submitTable.append(mapping_script) + + title4Body.append(submitTable) + + + def make_sample_lists(self, fd, variance_data_page, this_trait): + if fd.genotype.type == "riset": + all_samples_ordered = fd.f1list + fd.samplelist + else: + all_samples_ordered = fd.parlist + fd.f1list + fd.samplelist + + this_trait_samples = set(this_trait.data.keys()) + + primary_sample_names = all_samples_ordered + + print("-*- primary_samplelist is:", pf(primary_sample_names)) + + primary_samples = SampleList(self.cursor, + fd=fd, + variance_data_page=variance_data_page, + sample_names=primary_sample_names, + this_trait=this_trait, + sample_group_type='primary', + header="%s Only" % (fd.RISet)) + + print("primary_samples.attributes:", pf(primary_samples.attributes)) + + other_sample_names = [] + for sample in this_trait.data.keys(): + print("hjk - sample is:", sample) + if sample not in all_samples_ordered: + all_samples_ordered.append(sample) + other_sample_names.append(sample) + + if other_sample_names: + unappended_par_f1 = fd.f1list + fd.parlist + par_f1_samples = ["_2nd_" + sample for sample in unappended_par_f1] + + other_sample_names.sort() #Sort other samples + other_sample_names = par_f1_samples + other_sample_names + + other_samples = SampleList(self.cursor, + fd=fd, + variance_data_page=variance_data_page, + sample_names=other_sample_names, + 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,) + + #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 new file mode 100644 index 00000000..803045d5 --- /dev/null +++ b/wqflask/wqflask/static/new/javascript/show_trait.coffee @@ -0,0 +1,182 @@ +console.log("start_b") + +# this is our isNumber, do not confuse with the underscore.js one +is_number = (o) -> + return ! isNaN (o-0) && o != null + +$ -> + hide_tabs = (start) -> + for x in [start..10] + $("#stats_tabs" + x).hide() + + hide_tabs(1) + + # Changes stats table between all, bxd only and non-bxd, etc. + stats_mdp_change = -> + selected = $(this).val() + hide_tabs(0) + $("#stats_tabs" + selected).show() + + $(".stats_mdp").change(stats_mdp_change) + + change_stats_value = (sample_sets, category, value_type, decimal_places)-> + id = "#" + process_id(category, value_type) + console.log("the_id:", id) + in_box = $(id).html + + current_value = parseFloat($(in_box)).toFixed(decimal_places) + + the_value = sample_sets[category][value_type]() + if decimal_places > 0 + the_value = the_value.toFixed(decimal_places) + + if the_value != current_value + $(id).html(the_value).effect("highlight") + + update_stat_values = (sample_sets)-> + for category in ['primary_only', 'other_only', 'all_cases'] + change_stats_value(sample_sets, category, "n_of_samples", 0) + for stat in ["mean", "median", "std_dev", "std_error"] + change_stats_value(sample_sets, category, stat, 2) + + edit_data_change = -> + sample_sets = + primary_only: new Stats([]) + other_only: new Stats([]) + all_cases: new Stats([]) + + console.log("at beginning:", sample_sets) + values = $('#value_table').find(".edit_sample_value") + + for value in values + real_value = $(value).val() + row = $(value).closest("tr") + category = row[0].id + checkbox = $(row).find(".edit_sample_checkbox") + checked = $(checkbox).attr('checked') + + if checked and is_number(real_value) and real_value != "" + real_value = parseFloat(real_value) + if _(category).startsWith("Primary") + sample_sets.primary_only.add_value(real_value) + else if _(category).startsWith("Other") + sample_sets.other_only.add_value(real_value) + sample_sets.all_cases.add_value(real_value) + console.log("towards end:", sample_sets) + update_stat_values(sample_sets) + + + make_table = -> + header = " " + console.log("js_data.sample_groups:", js_data.sample_groups) + for key, value of js_data.sample_groups + console.log("aa key:", key) + console.log("aa value:", value) + the_id = process_id("column", key) + header += """#{ value }""" + header += "" + console.log("windex header is:", header) + + rows = [ + { + vn: "n_of_samples" + pretty: "N of Samples" + }, + { + vn: "mean" + pretty: "Mean" + }, + { + vn: "median" + pretty: "Median" + }, + { + vn: "std_error" + pretty: "Standard Error (SE)" + }, + { + vn: "std_dev" + pretty: "Standard Deviation (SD)" + } + ] + + console.log("rows are:", rows) + the_rows = "" + console.log("length of rows:", rows.length) + for row in rows + console.log("rowing") + row_line = """""" + row_line += """#{ row.pretty }""" + console.log("box - js_data.sample_groups:", js_data.sample_groups) + for key, value of js_data.sample_groups + console.log("apple key:", key) + the_id = process_id(key, row.vn) + console.log("the_id:", the_id) + row_line += """foo""" + row_line += """""" + console.log("row line:", row_line) + the_rows += row_line + the_rows += "" + table = header + the_rows + console.log("table is:", table) + $("#stats_table").append(table) + + + + process_id = (values...) -> + ### Make an id or a class valid javascript by, for example, eliminating spaces ### + processed = "" + for value in values + console.log("value:", value) + value = value.replace(" ", "_") + if processed.length + processed += "-" + processed += value + return processed + + + show_hide_outliers = -> + console.log("FOOBAR in beginning of show_hide_outliers") + label = $('#show_hide_outliers').val() + console.log("lable is:", label) + if label == "Hide Outliers" + $('#show_hide_outliers').val("Show Outliers") + else if label == "Show Outliers" + console.log("Found Show Outliers") + $('#show_hide_outliers').val("Hide Outliers") + console.log("Should be now Hide Outliers") + + + #Calculate Correlations Code + + + on_corr_method_change = -> + console.log("in beginning of on_corr_method_change") + corr_method = $('select[name=corr_method]').val() + console.log("corr_method is:", corr_method) + $('.correlation_desc').hide() + $('#' + corr_method + "_r_desc").show().effect("highlight") + if corr_method == "lit" + $("#corr_sample_method_options").hide() + else + $("#corr_sample_method_options").show() + + $('select[name=corr_method]').change(on_corr_method_change) + + + #End Calculate Correlations Code + + + console.log("before registering show_hide_outliers") + $('#show_hide_outliers').click(show_hide_outliers) + console.log("after registering show_hide_outliers") + + _.mixin(_.str.exports()); # Add string fuctions directly to underscore + $('#value_table').change(edit_data_change) + console.log("loaded") + #console.log("basic_table is:", basic_table) + # Add back following two lines later + make_table() + edit_data_change() # Set the values at the beginning + #$("#all-mean").html('foobar8') + console.log("end") diff --git a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee deleted file mode 100644 index 803045d5..00000000 --- a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee +++ /dev/null @@ -1,182 +0,0 @@ -console.log("start_b") - -# this is our isNumber, do not confuse with the underscore.js one -is_number = (o) -> - return ! isNaN (o-0) && o != null - -$ -> - hide_tabs = (start) -> - for x in [start..10] - $("#stats_tabs" + x).hide() - - hide_tabs(1) - - # Changes stats table between all, bxd only and non-bxd, etc. - stats_mdp_change = -> - selected = $(this).val() - hide_tabs(0) - $("#stats_tabs" + selected).show() - - $(".stats_mdp").change(stats_mdp_change) - - change_stats_value = (sample_sets, category, value_type, decimal_places)-> - id = "#" + process_id(category, value_type) - console.log("the_id:", id) - in_box = $(id).html - - current_value = parseFloat($(in_box)).toFixed(decimal_places) - - the_value = sample_sets[category][value_type]() - if decimal_places > 0 - the_value = the_value.toFixed(decimal_places) - - if the_value != current_value - $(id).html(the_value).effect("highlight") - - update_stat_values = (sample_sets)-> - for category in ['primary_only', 'other_only', 'all_cases'] - change_stats_value(sample_sets, category, "n_of_samples", 0) - for stat in ["mean", "median", "std_dev", "std_error"] - change_stats_value(sample_sets, category, stat, 2) - - edit_data_change = -> - sample_sets = - primary_only: new Stats([]) - other_only: new Stats([]) - all_cases: new Stats([]) - - console.log("at beginning:", sample_sets) - values = $('#value_table').find(".edit_sample_value") - - for value in values - real_value = $(value).val() - row = $(value).closest("tr") - category = row[0].id - checkbox = $(row).find(".edit_sample_checkbox") - checked = $(checkbox).attr('checked') - - if checked and is_number(real_value) and real_value != "" - real_value = parseFloat(real_value) - if _(category).startsWith("Primary") - sample_sets.primary_only.add_value(real_value) - else if _(category).startsWith("Other") - sample_sets.other_only.add_value(real_value) - sample_sets.all_cases.add_value(real_value) - console.log("towards end:", sample_sets) - update_stat_values(sample_sets) - - - make_table = -> - header = " " - console.log("js_data.sample_groups:", js_data.sample_groups) - for key, value of js_data.sample_groups - console.log("aa key:", key) - console.log("aa value:", value) - the_id = process_id("column", key) - header += """#{ value }""" - header += "" - console.log("windex header is:", header) - - rows = [ - { - vn: "n_of_samples" - pretty: "N of Samples" - }, - { - vn: "mean" - pretty: "Mean" - }, - { - vn: "median" - pretty: "Median" - }, - { - vn: "std_error" - pretty: "Standard Error (SE)" - }, - { - vn: "std_dev" - pretty: "Standard Deviation (SD)" - } - ] - - console.log("rows are:", rows) - the_rows = "" - console.log("length of rows:", rows.length) - for row in rows - console.log("rowing") - row_line = """""" - row_line += """#{ row.pretty }""" - console.log("box - js_data.sample_groups:", js_data.sample_groups) - for key, value of js_data.sample_groups - console.log("apple key:", key) - the_id = process_id(key, row.vn) - console.log("the_id:", the_id) - row_line += """foo""" - row_line += """""" - console.log("row line:", row_line) - the_rows += row_line - the_rows += "" - table = header + the_rows - console.log("table is:", table) - $("#stats_table").append(table) - - - - process_id = (values...) -> - ### Make an id or a class valid javascript by, for example, eliminating spaces ### - processed = "" - for value in values - console.log("value:", value) - value = value.replace(" ", "_") - if processed.length - processed += "-" - processed += value - return processed - - - show_hide_outliers = -> - console.log("FOOBAR in beginning of show_hide_outliers") - label = $('#show_hide_outliers').val() - console.log("lable is:", label) - if label == "Hide Outliers" - $('#show_hide_outliers').val("Show Outliers") - else if label == "Show Outliers" - console.log("Found Show Outliers") - $('#show_hide_outliers').val("Hide Outliers") - console.log("Should be now Hide Outliers") - - - #Calculate Correlations Code - - - on_corr_method_change = -> - console.log("in beginning of on_corr_method_change") - corr_method = $('select[name=corr_method]').val() - console.log("corr_method is:", corr_method) - $('.correlation_desc').hide() - $('#' + corr_method + "_r_desc").show().effect("highlight") - if corr_method == "lit" - $("#corr_sample_method_options").hide() - else - $("#corr_sample_method_options").show() - - $('select[name=corr_method]').change(on_corr_method_change) - - - #End Calculate Correlations Code - - - console.log("before registering show_hide_outliers") - $('#show_hide_outliers').click(show_hide_outliers) - console.log("after registering show_hide_outliers") - - _.mixin(_.str.exports()); # Add string fuctions directly to underscore - $('#value_table').change(edit_data_change) - console.log("loaded") - #console.log("basic_table is:", basic_table) - # Add back following two lines later - make_table() - edit_data_change() # Set the values at the beginning - #$("#all-mean").html('foobar8') - console.log("end") diff --git a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js deleted file mode 100644 index 55bc1302..00000000 --- a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js +++ /dev/null @@ -1,207 +0,0 @@ -// Generated by CoffeeScript 1.3.3 -(function() { - var is_number, - __slice = [].slice; - - console.log("start_b"); - - is_number = function(o) { - return !isNaN((o - 0) && o !== null); - }; - - $(function() { - var change_stats_value, edit_data_change, hide_tabs, make_table, on_corr_method_change, process_id, show_hide_outliers, stats_mdp_change, update_stat_values; - hide_tabs = function(start) { - var x, _i, _results; - _results = []; - for (x = _i = start; start <= 10 ? _i <= 10 : _i >= 10; x = start <= 10 ? ++_i : --_i) { - _results.push($("#stats_tabs" + x).hide()); - } - return _results; - }; - hide_tabs(1); - stats_mdp_change = function() { - var selected; - selected = $(this).val(); - hide_tabs(0); - return $("#stats_tabs" + selected).show(); - }; - $(".stats_mdp").change(stats_mdp_change); - change_stats_value = function(sample_sets, category, value_type, decimal_places) { - var current_value, id, in_box, the_value; - id = "#" + process_id(category, value_type); - console.log("the_id:", id); - in_box = $(id).html; - current_value = parseFloat($(in_box)).toFixed(decimal_places); - the_value = sample_sets[category][value_type](); - if (decimal_places > 0) { - the_value = the_value.toFixed(decimal_places); - } - if (the_value !== current_value) { - return $(id).html(the_value).effect("highlight"); - } - }; - update_stat_values = function(sample_sets) { - var category, stat, _i, _len, _ref, _results; - _ref = ['primary_only', 'other_only', 'all_cases']; - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - category = _ref[_i]; - change_stats_value(sample_sets, category, "n_of_samples", 0); - _results.push((function() { - var _j, _len1, _ref1, _results1; - _ref1 = ["mean", "median", "std_dev", "std_error"]; - _results1 = []; - for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { - stat = _ref1[_j]; - _results1.push(change_stats_value(sample_sets, category, stat, 2)); - } - return _results1; - })()); - } - return _results; - }; - edit_data_change = function() { - var category, checkbox, checked, real_value, row, sample_sets, value, values, _i, _len; - sample_sets = { - primary_only: new Stats([]), - other_only: new Stats([]), - all_cases: new Stats([]) - }; - console.log("at beginning:", sample_sets); - values = $('#value_table').find(".edit_sample_value"); - for (_i = 0, _len = values.length; _i < _len; _i++) { - value = values[_i]; - real_value = $(value).val(); - row = $(value).closest("tr"); - category = row[0].id; - checkbox = $(row).find(".edit_sample_checkbox"); - checked = $(checkbox).attr('checked'); - if (checked && is_number(real_value) && real_value !== "") { - real_value = parseFloat(real_value); - if (_(category).startsWith("Primary")) { - sample_sets.primary_only.add_value(real_value); - } else if (_(category).startsWith("Other")) { - sample_sets.other_only.add_value(real_value); - } - sample_sets.all_cases.add_value(real_value); - } - } - console.log("towards end:", sample_sets); - return update_stat_values(sample_sets); - }; - make_table = function() { - var header, key, row, row_line, rows, table, the_id, the_rows, value, _i, _len, _ref, _ref1; - header = " "; - console.log("js_data.sample_groups:", js_data.sample_groups); - _ref = js_data.sample_groups; - for (key in _ref) { - value = _ref[key]; - console.log("aa key:", key); - console.log("aa value:", value); - the_id = process_id("column", key); - header += "" + value + ""; - } - header += ""; - console.log("windex header is:", header); - rows = [ - { - vn: "n_of_samples", - pretty: "N of Samples" - }, { - vn: "mean", - pretty: "Mean" - }, { - vn: "median", - pretty: "Median" - }, { - vn: "std_error", - pretty: "Standard Error (SE)" - }, { - vn: "std_dev", - pretty: "Standard Deviation (SD)" - } - ]; - console.log("rows are:", rows); - the_rows = ""; - console.log("length of rows:", rows.length); - for (_i = 0, _len = rows.length; _i < _len; _i++) { - row = rows[_i]; - console.log("rowing"); - row_line = ""; - row_line += "" + row.pretty + ""; - console.log("box - js_data.sample_groups:", js_data.sample_groups); - _ref1 = js_data.sample_groups; - for (key in _ref1) { - value = _ref1[key]; - console.log("apple key:", key); - the_id = process_id(key, row.vn); - console.log("the_id:", the_id); - row_line += "foo"; - } - row_line += ""; - console.log("row line:", row_line); - the_rows += row_line; - } - the_rows += ""; - table = header + the_rows; - console.log("table is:", table); - return $("#stats_table").append(table); - }; - process_id = function() { - var processed, value, values, _i, _len; - values = 1 <= arguments.length ? __slice.call(arguments, 0) : []; - /* Make an id or a class valid javascript by, for example, eliminating spaces - */ - - processed = ""; - for (_i = 0, _len = values.length; _i < _len; _i++) { - value = values[_i]; - console.log("value:", value); - value = value.replace(" ", "_"); - if (processed.length) { - processed += "-"; - } - processed += value; - } - return processed; - }; - show_hide_outliers = function() { - var label; - console.log("FOOBAR in beginning of show_hide_outliers"); - label = $('#show_hide_outliers').val(); - console.log("lable is:", label); - if (label === "Hide Outliers") { - return $('#show_hide_outliers').val("Show Outliers"); - } else if (label === "Show Outliers") { - console.log("Found Show Outliers"); - $('#show_hide_outliers').val("Hide Outliers"); - return console.log("Should be now Hide Outliers"); - } - }; - on_corr_method_change = function() { - var corr_method; - console.log("in beginning of on_corr_method_change"); - corr_method = $('select[name=corr_method]').val(); - console.log("corr_method is:", corr_method); - $('.correlation_desc').hide(); - $('#' + corr_method + "_r_desc").show().effect("highlight"); - if (corr_method === "lit") { - return $("#corr_sample_method_options").hide(); - } else { - return $("#corr_sample_method_options").show(); - } - }; - $('select[name=corr_method]').change(on_corr_method_change); - console.log("before registering show_hide_outliers"); - $('#show_hide_outliers').click(show_hide_outliers); - console.log("after registering show_hide_outliers"); - _.mixin(_.str.exports()); - $('#value_table').change(edit_data_change); - console.log("loaded"); - make_table(); - edit_data_change(); - return console.log("end"); - }); - -}).call(this); diff --git a/wqflask/wqflask/templates/show_trait.html b/wqflask/wqflask/templates/show_trait.html new file mode 100644 index 00000000..7d0e671f --- /dev/null +++ b/wqflask/wqflask/templates/show_trait.html @@ -0,0 +1,1346 @@ + + {% extends "base.html" %} + {% block title %}Trait Data and Analysis{% endblock %} + {% block content %} + + + + + + + +
+
+ {# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #} + {% for key in hddn %} + + {% endfor %} +
+
+ Trait Data and Analysis  for Record ID 1441186_at +
+
+ +

  Details and Links

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Gene Symbol:{{ this_trait.symbol }}
Aliases:{{ this_trait.alias_fmt }}
Description:{{ this_trait.description_fmt }}
Location:{{ this_trait.location_fmt }}
Target Score: + + + BLAT specificity + : {{ "%.1f" % (this_trait.probe_set_specificity) }}    + Score: {{ "%i" % (this_trait.probe_set_blat_score) }}   + +
Species and Group:{{ this_trait.species.capitalize() }}, {{fd.RISet}}
Database: + {{ this_trait.database.name }} +
Resource Links: + + + + Gene + + +   UniGene  GenBank  HomoloGene  
UCSC  BioGPS  STRING  PANTHER  Gemma  SynDB  ABA  

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
++ +  Check probe locations at UCSC  Write or review comments about this gene +  View SNPs and Indels +  View probes, SNPs, and RNA-seq at UTHSC +  Check sequence of probes
AddFindVerifyGeneWikiSNPsRNA-seqProbes
+ +

  Basic Statistics

+ + +

Include: +
+
+
+
+ + +
+ + + + + +
+ {% for sd in stats_data %} +
+ + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StatisticValue
N of Samples{{ sd.N }}
Mean{{ "%2.3f" % sd.traitmean }}
Median{{ "%2.3f" % sd.traitmedian }}
Standard Error (SE){{ "%2.3f" % sd.traitsem }}
Standard Deviation (SD){{ "%2.3f" % sd.traitstdev }}
Minimum{{ "%2.3f" % sd.min }}
Maximum{{ "%2.3f" % sd.max }}
Range (log2){{ "%2.3f" % sd.range_log2 }}
Range (fold){{ "%2.3f" % sd.range_fold }}
Interquartile Range{{ "%2.3f" % sd.interquartile }}
+
+
+ +
+ + + + + + + + +
nP_OE9u7BSx.gif

+
+ This plot evaluates whether data are normally distributed. Different symbols represent different groups.
+
+ More about Normal Probability Plots and more + about interpreting these plots from the glossary
+
+ +
+ + + + +
+ Box_gUFtEOVI.gif + +

More about Box Plots

+
+
+ +
+ + + + +
Bar_y7L2rYlL.gif
+
+ +
+ + + + +
Bar_1Z4GjYFq.gif
+
+
+ {% endfor %} + {# Not used now - Todo: Delete after we're sure this is right. +
+ + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StatisticValue
N of Samples71
Mean6.109
Median6.084
Standard Error (SE)0.022
Standard Deviation (SD)0.187
Minimum5.782
Maximum6.579
Range (log2)0.797
Range (fold)1.74
Interquartile Range1.13
+
+
+ +
+ + + + + + + + +
nP_eSYO7ZQg.gif

+
+ This plot evaluates whether data are normally distributed. Different symbols represent different groups.
+
+ More about Normal Probability Plots and more + about interpreting these plots from the glossary
+
+ +
+ + + + +
+ Box_PWNWQMfj.gif + +

More about Box Plots

+
+
+ +
+ + + + +
Bar_VuPqYbR6.gif
+
+ +
+ + + + +
Bar_9PbdvXZ9.gif
+
+
+ +
+ + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StatisticValue
N of Samples32
Mean6.176
Median6.170
Standard Error (SE)0.027
Standard Deviation (SD)0.150
Minimum5.906
Maximum6.485
Range (log2)0.579
Range (fold)1.49
Interquartile Range1.15
+
+
+ +
+ + + + + + + + +
nP_swDAFlJy.gif

+
+ This plot evaluates whether data are normally distributed. Different symbols represent different groups.
+
+ More about Normal Probability Plots and more + about interpreting these plots from the glossary
+
+ +
+ + + + +
+ Box_6sQJ8xhK.gif + +

More about Box Plots

+
+
+ +
+ + + + +
Bar_QMWE2VEp.gif
+
+ +
+ + + + +
Bar_X07QmgsX.gif
+
+
+
+ #} + +

  Calculate Correlations

+ +

+ + + + + +
+
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Method: + +
Database: + +
Return:
Samples: + +
+
+
+ Pearson +     + Spearman Rank +
+
+ +

+ + + The Sample Correlation + is computed + between trait data and any
+ other traits in the sample database selected above. Use + Spearman + Rank
+ when the sample size is small (<20) or when there are influential outliers. +
+ + + +
+
+
+
+
+ +

  Mapping Tools

+ +

+ + + + + +
+
+ + +
+ + + + + + + + +
+ + + + + + + + + + + + +
Chromosome:
Mapping Scale:

+ Permutation Test (n=2000)
+ Bootstrap Test (n=2000)
+ Use Parents
+ Use Weighted
+
+
+
+
Interval Mapping computes linkage maps + for the entire genome or single
+ chromosomes. The Permutation Test estimates suggestive and + significant
+ linkage scores. The Bootstrap Test estimates the precision of the QTL + location.

+
+ +
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
Display LRS greater than:
Display all LRS
Use Parents
Use Weighted

+
+
+
Marker regression computes and displays LRS + values for individual markers.
+ This function also lists additive effects (phenotype units per allele) and
+ dominance deviations for some datasets.

+
+ +
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
Chromosome:
Mapping Scale:
Control Locus:

+ Permutation Test (n=2000)
+ Bootstrap Test (n=2000)
+ Use Parents
+
+
+
+
Composite Interval Mapping allows you to control + for a single marker as
+ a cofactor. To find a control marker, run the Marker Regression function.

+
+ +
+ + + + + + + + +
+ + + + + + + + + + + + +
Sort by:
Return:

+ Permutation Test + (n=500)
+
+
+
+
Pair-Scan searches for pairs of chromosomal regions + that are
+ involved in two-locus epistatic interactions.

+
+
+
+ +

  Review and Edit Data

+ + + +

+ +
+ + + +
+
+

Edit or delete values in the Trait Data boxes, and use the Reset option as + needed.

+ +
+   Block samples by index:     +         + +
+   Options: +       + +       + +       + +       + +
+
+
+   Outliers highlighted in  yellow  can be hidden using + the Hide Outliers button,
+   and samples with no value (x) can be hidden by clicking Hide No Value .

+

+ +
+ {% for sample_type in sample_groups %} +
+

{{ sample_type.header }}

+ +
+ + + + + + + + {% if sample_type.se_exists() %} + + + + {% endif %} + + {% for attribute in sample_type.attributes|sort() %} + + {% endfor %} + + + {% for sample in sample_type.sample_list %} + + + + + + {# Todo: Add IDs #} + + + {% if sample_type.se_exists() %} + + + {# Todo: Add IDs #} + + {% endif %} + + {# Loop through each attribute type and input value #} + {% for attribute in sample_type.attributes|sort() %} + + {% endfor %} + + {% endfor %} + +
IndexSampleValue SE{{ sample_type.attributes[attribute].name }}
+ {{ loop.index }} + + + {{ sample.name }} + + + + ± + + + + {{ sample.extra_attributes[sample_type.attributes[attribute].name] }} +
+
+
+ {% endfor %} +
+
+
+ +
+
+ + + + + + --> + + + + + + + + + + + + {% endblock %} diff --git a/wqflask/wqflask/templates/trait_data_and_analysis.html b/wqflask/wqflask/templates/trait_data_and_analysis.html deleted file mode 100644 index 7d0e671f..00000000 --- a/wqflask/wqflask/templates/trait_data_and_analysis.html +++ /dev/null @@ -1,1346 +0,0 @@ - - {% extends "base.html" %} - {% block title %}Trait Data and Analysis{% endblock %} - {% block content %} - - - - - - - -
-
- {# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #} - {% for key in hddn %} - - {% endfor %} -
-
- Trait Data and Analysis  for Record ID 1441186_at -
-
- -

  Details and Links

- -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Gene Symbol:{{ this_trait.symbol }}
Aliases:{{ this_trait.alias_fmt }}
Description:{{ this_trait.description_fmt }}
Location:{{ this_trait.location_fmt }}
Target Score: - - - BLAT specificity - : {{ "%.1f" % (this_trait.probe_set_specificity) }}    - Score: {{ "%i" % (this_trait.probe_set_blat_score) }}   - -
Species and Group:{{ this_trait.species.capitalize() }}, {{fd.RISet}}
Database: - {{ this_trait.database.name }} -
Resource Links: - - - - Gene - - -   UniGene  GenBank  HomoloGene  
UCSC  BioGPS  STRING  PANTHER  Gemma  SynDB  ABA  

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-- -  Check probe locations at UCSC  Write or review comments about this gene -  View SNPs and Indels -  View probes, SNPs, and RNA-seq at UTHSC -  Check sequence of probes
AddFindVerifyGeneWikiSNPsRNA-seqProbes
- -

  Basic Statistics

- - -

Include: -
-
-
-
- - -
- - - - - -
- {% for sd in stats_data %} -
- - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
StatisticValue
N of Samples{{ sd.N }}
Mean{{ "%2.3f" % sd.traitmean }}
Median{{ "%2.3f" % sd.traitmedian }}
Standard Error (SE){{ "%2.3f" % sd.traitsem }}
Standard Deviation (SD){{ "%2.3f" % sd.traitstdev }}
Minimum{{ "%2.3f" % sd.min }}
Maximum{{ "%2.3f" % sd.max }}
Range (log2){{ "%2.3f" % sd.range_log2 }}
Range (fold){{ "%2.3f" % sd.range_fold }}
Interquartile Range{{ "%2.3f" % sd.interquartile }}
-
-
- -
- - - - - - - - -
nP_OE9u7BSx.gif

-
- This plot evaluates whether data are normally distributed. Different symbols represent different groups.
-
- More about Normal Probability Plots and more - about interpreting these plots from the glossary
-
- -
- - - - -
- Box_gUFtEOVI.gif - -

More about Box Plots

-
-
- -
- - - - -
Bar_y7L2rYlL.gif
-
- -
- - - - -
Bar_1Z4GjYFq.gif
-
-
- {% endfor %} - {# Not used now - Todo: Delete after we're sure this is right. -
- - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
StatisticValue
N of Samples71
Mean6.109
Median6.084
Standard Error (SE)0.022
Standard Deviation (SD)0.187
Minimum5.782
Maximum6.579
Range (log2)0.797
Range (fold)1.74
Interquartile Range1.13
-
-
- -
- - - - - - - - -
nP_eSYO7ZQg.gif

-
- This plot evaluates whether data are normally distributed. Different symbols represent different groups.
-
- More about Normal Probability Plots and more - about interpreting these plots from the glossary
-
- -
- - - - -
- Box_PWNWQMfj.gif - -

More about Box Plots

-
-
- -
- - - - -
Bar_VuPqYbR6.gif
-
- -
- - - - -
Bar_9PbdvXZ9.gif
-
-
- -
- - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
StatisticValue
N of Samples32
Mean6.176
Median6.170
Standard Error (SE)0.027
Standard Deviation (SD)0.150
Minimum5.906
Maximum6.485
Range (log2)0.579
Range (fold)1.49
Interquartile Range1.15
-
-
- -
- - - - - - - - -
nP_swDAFlJy.gif

-
- This plot evaluates whether data are normally distributed. Different symbols represent different groups.
-
- More about Normal Probability Plots and more - about interpreting these plots from the glossary
-
- -
- - - - -
- Box_6sQJ8xhK.gif - -

More about Box Plots

-
-
- -
- - - - -
Bar_QMWE2VEp.gif
-
- -
- - - - -
Bar_X07QmgsX.gif
-
-
-
- #} - -

  Calculate Correlations

- -

- - - - - -
-
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
Method: - -
Database: - -
Return:
Samples: - -
-
-
- Pearson -     - Spearman Rank -
-
- -

- - - The Sample Correlation - is computed - between trait data and any
- other traits in the sample database selected above. Use - Spearman - Rank
- when the sample size is small (<20) or when there are influential outliers. -
- - - -
-
-
-
-
- -

  Mapping Tools

- -

- - - - - -
-
- - -
- - - - - - - - -
- - - - - - - - - - - - -
Chromosome:
Mapping Scale:

- Permutation Test (n=2000)
- Bootstrap Test (n=2000)
- Use Parents
- Use Weighted
-
-
-
-
Interval Mapping computes linkage maps - for the entire genome or single
- chromosomes. The Permutation Test estimates suggestive and - significant
- linkage scores. The Bootstrap Test estimates the precision of the QTL - location.

-
- -
- - - - - - - - -
- - - - - - - - - - - - - - - - - - -
Display LRS greater than:
Display all LRS
Use Parents
Use Weighted

-
-
-
Marker regression computes and displays LRS - values for individual markers.
- This function also lists additive effects (phenotype units per allele) and
- dominance deviations for some datasets.

-
- -
- - - - - - - - -
- - - - - - - - - - - - - - - - - - -
Chromosome:
Mapping Scale:
Control Locus:

- Permutation Test (n=2000)
- Bootstrap Test (n=2000)
- Use Parents
-
-
-
-
Composite Interval Mapping allows you to control - for a single marker as
- a cofactor. To find a control marker, run the Marker Regression function.

-
- -
- - - - - - - - -
- - - - - - - - - - - - -
Sort by:
Return:

- Permutation Test - (n=500)
-
-
-
-
Pair-Scan searches for pairs of chromosomal regions - that are
- involved in two-locus epistatic interactions.

-
-
-
- -

  Review and Edit Data

- - - -

- -
- - - -
-
-

Edit or delete values in the Trait Data boxes, and use the Reset option as - needed.

- -
-   Block samples by index:     -         - -
-   Options: -       - -       - -       - -       - -
-
-
-   Outliers highlighted in  yellow  can be hidden using - the Hide Outliers button,
-   and samples with no value (x) can be hidden by clicking Hide No Value .

-

- -
- {% for sample_type in sample_groups %} -
-

{{ sample_type.header }}

- -
- - - - - - - - {% if sample_type.se_exists() %} - - - - {% endif %} - - {% for attribute in sample_type.attributes|sort() %} - - {% endfor %} - - - {% for sample in sample_type.sample_list %} - - - - - - {# Todo: Add IDs #} - - - {% if sample_type.se_exists() %} - - - {# Todo: Add IDs #} - - {% endif %} - - {# Loop through each attribute type and input value #} - {% for attribute in sample_type.attributes|sort() %} - - {% endfor %} - - {% endfor %} - -
IndexSampleValue SE{{ sample_type.attributes[attribute].name }}
- {{ loop.index }} - - - {{ sample.name }} - - - - ± - - - - {{ sample.extra_attributes[sample_type.attributes[attribute].name] }} -
-
-
- {% endfor %} -
-
-
- -
-
- - - - - - --> - - - - - - - - - - - - {% endblock %} diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index bc80a1e6..4da1082f 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -76,7 +76,7 @@ def show_trait(): # Here it's currently too complicated not to use an fd that is a webqtlFormData fd = webqtlFormData.webqtlFormData(request.args) #template_vars = show_trait_page.ShowTraitPage(fd) - template_vars = DataEditingPage.DataEditingPage(fd) + template_vars = show_trait.show_trait(fd) template_vars.js_data = json.dumps(template_vars.js_data) print("show_trait template_vars:", pf(template_vars.__dict__)) -- cgit v1.2.3