From 527bb0459cf488e5021696e326dc10d28ecdd74c Mon Sep 17 00:00:00 2001 From: Sam Ockman Date: Thu, 24 May 2012 02:18:20 -0400 Subject: Trying to get stuff working under new structure --- wqflask/base/GeneralObject.py | 71 +++++ wqflask/base/JinjaPage.py | 28 ++ wqflask/base/__init__.py | 0 wqflask/base/admin.py | 88 ++++++ wqflask/base/cgiData.py | 70 +++++ wqflask/base/cookieData.py | 52 ++++ wqflask/base/footer.py | 6 + wqflask/base/header.py | 6 + wqflask/base/indexBody.py | 290 +++++++++++++++++++ wqflask/base/myCookie.py | 55 ++++ wqflask/base/sessionData.py | 53 ++++ wqflask/base/template.py | 123 ++++++++ wqflask/base/templatePage.py | 222 +++++++++++++++ wqflask/base/webqtlCaseData.py | 54 ++++ wqflask/base/webqtlConfig.py | 73 +++++ wqflask/base/webqtlConfigLocal.py | 19 ++ wqflask/base/webqtlDataset.py | 160 +++++++++++ wqflask/base/webqtlFormData.py | 289 +++++++++++++++++++ wqflask/base/webqtlTrait.py | 581 ++++++++++++++++++++++++++++++++++++++ 19 files changed, 2240 insertions(+) create mode 100755 wqflask/base/GeneralObject.py create mode 100644 wqflask/base/JinjaPage.py create mode 100755 wqflask/base/__init__.py create mode 100755 wqflask/base/admin.py create mode 100755 wqflask/base/cgiData.py create mode 100755 wqflask/base/cookieData.py create mode 100755 wqflask/base/footer.py create mode 100755 wqflask/base/header.py create mode 100755 wqflask/base/indexBody.py create mode 100755 wqflask/base/myCookie.py create mode 100755 wqflask/base/sessionData.py create mode 100755 wqflask/base/template.py create mode 100755 wqflask/base/templatePage.py create mode 100755 wqflask/base/webqtlCaseData.py create mode 100755 wqflask/base/webqtlConfig.py create mode 100755 wqflask/base/webqtlConfigLocal.py create mode 100755 wqflask/base/webqtlDataset.py create mode 100755 wqflask/base/webqtlFormData.py create mode 100755 wqflask/base/webqtlTrait.py (limited to 'wqflask/base') diff --git a/wqflask/base/GeneralObject.py b/wqflask/base/GeneralObject.py new file mode 100755 index 00000000..311c9e22 --- /dev/null +++ b/wqflask/base/GeneralObject.py @@ -0,0 +1,71 @@ +# Copyright (C) University of Tennessee Health Science Center, Memphis, TN. +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Affero General Public License for more details. +# +# This program is available from Source Forge: at GeneNetwork Project +# (sourceforge.net/projects/genenetwork/). +# +# Contact Drs. Robert W. Williams and Xiaodong Zhou (2010) +# at rwilliams@uthsc.edu and xzhou15@uthsc.edu +# +# +# +# This module is used by GeneNetwork project (www.genenetwork.org) +# +# Created by GeneNetwork Core Team 2010/08/10 +# +# Last updated by GeneNetwork Core Team 2010/10/20 + +class GeneralObject: + """ + Base class to define an Object. + a = [Spam(1, 4), Spam(9, 3), Spam(4,6)] + a.sort(lambda x, y: cmp(x.eggs, y.eggs)) + """ + + def __init__(self, *args, **kw): + self.contents = list(args) + for name, value in kw.items(): + setattr(self, name, value) + + def __setitem__(self, key, value): + setattr(self, key, value) + + def __getitem__(self, key): + return getattr(self, key) + + def __getattr__(self, key): + if key in self.__dict__.keys(): + return self.__dict__[key] + else: + return eval("self.__dict__.%s" % key) + + def __len__(self): + return len(self.__dict__) - 1 + + def __str__(self): + s = '' + for key in self.__dict__.keys(): + if key != 'contents': + s += '%s = %s\n' % (key,self.__dict__[key]) + return s + + def __repr__(self): + s = '' + for key in self.__dict__.keys(): + s += '%s = %s\n' % (key,self.__dict__[key]) + return s + + def __cmp__(self,other): + return len(self.__dict__.keys()).__cmp__(len(other.__dict__.keys())) + + + diff --git a/wqflask/base/JinjaPage.py b/wqflask/base/JinjaPage.py new file mode 100644 index 00000000..07e485b1 --- /dev/null +++ b/wqflask/base/JinjaPage.py @@ -0,0 +1,28 @@ +import logging +logging.basicConfig(filename="/tmp/gn_log", level=logging.INFO) +_log = logging.getLogger("search") + +from pprint import pformat as pf + +import templatePage + +from utility import formatting + +import jinja2 +JinjaEnv = jinja2.Environment(loader=jinja2.FileSystemLoader('/gnshare/gn/web/webqtl/templates')) +JinjaEnv.globals['numify'] = formatting.numify + + +class JinjaPage(templatePage.templatePage): + """Class derived from our regular templatePage, but uses Jinja2 instead. + + When converting pages from Python generated templates, change the base class from templatePage + to JinjaPage + + """ + + + def write(self): + """We override the base template write so we can use Jinja2.""" + _log.info(pf(self.__dict__)) + return self.jtemplate.render(**self.__dict__) diff --git a/wqflask/base/__init__.py b/wqflask/base/__init__.py new file mode 100755 index 00000000..e69de29b diff --git a/wqflask/base/admin.py b/wqflask/base/admin.py new file mode 100755 index 00000000..a04df2da --- /dev/null +++ b/wqflask/base/admin.py @@ -0,0 +1,88 @@ +# Copyright (C) University of Tennessee Health Science Center, Memphis, TN. +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Affero General Public License for more details. +# +# This program is available from Source Forge: at GeneNetwork Project +# (sourceforge.net/projects/genenetwork/). +# +# Contact Drs. Robert W. Williams and Xiaodong Zhou (2010) +# at rwilliams@uthsc.edu and xzhou15@uthsc.edu +# +# +# +# This module is used by GeneNetwork project (www.genenetwork.org) +# +# Created by GeneNetwork Core Team 2010/08/10 +# +# Last updated by GeneNetwork Core Team 2010/10/20 + + + + + +#XZ, 04/02/2009: we should put this into database. + + +###LIST of databases used into gene name query + + +ADMIN_search_dbs = { + 'rat': {'PERITONEAL FAT': ['FT_2A_0605_Rz'], + 'KIDNEY': ['KI_2A_0405_Rz'], + 'ADRENAL GLAND': ['HXB_Adrenal_1208'], + 'HEART': ['HXB_Heart_1208'] + }, + 'mouse': {'CEREBELLUM': ['CB_M_0305_R'], + 'STRIATUM': ['SA_M2_0905_R', 'SA_M2_0405_RC', 'UTHSC_1107_RankInv', 'Striatum_Exon_0209'], + 'HIPPOCAMPUS': ['HC_M2_0606_R', 'UMUTAffyExon_0209_RMA'], + 'WHOLE BRAIN': ['BR_M2_1106_R', 'IBR_M_0106_R', 'BRF2_M_0805_R', 'UCLA_BHF2_BRAIN_0605'], + 'LIVER': ['LV_G_0106_B', 'UCLA_BHF2_LIVER_0605'], + 'EYE': ['Eye_M2_0908_R'], + 'HEMATOPOIETIC STEM CELLS': ['HC_U_0304_R'], + 'KIDNEY': ['MA_M2_0806_R'], + 'MAMMARY TUMORS': ['MA_M_0704_R', 'NCI_Agil_Mam_Tum_RMA_0409'], + 'PREFRONTAL CORTEX': ['VCUSal_1206_R'], + 'SPLEEN': ['IoP_SPL_RMA_0509'], + 'NUCLEUS ACCUMBENS': ['VCUSalo_1007_R'], + 'NEOCORTEX': ['HQFNeoc_0208_RankInv'], + 'ADIPOSE': ['UCLA_BHF2_ADIPOSE_0605'], + 'RETINA': ['Illum_Retina_BXD_RankInv0410'] + }, + 'human': { + 'LYMPHOBLAST B CELL': ['Human_1008', 'UT_CEPH_RankInv0909'], + 'WHOLE BRAIN': ['GSE5281_F_RMA0709', 'GSE15222_F_RI_0409'] + } + } + + +###LIST of tissue alias + +ADMIN_tissue_alias = {'CEREBELLUM': ['Cb'], + 'STRIATUM': ['Str'], + 'HIPPOCAMPUS': ['Hip'], + 'WHOLE BRAIN': ['Brn'], + 'LIVER': ['Liv'], + 'EYE': ['Eye'], + 'PERITONEAL FAT': ['Fat'], + 'HEMATOPOIETIC STEM CELLS': ['Hsc'], + 'KIDNEY': ['Kid'], + 'ADRENAL GLAND': ['Adr'], + 'HEART': ['Hea'], + 'MAMMARY TUMORS': ['Mam'], + 'PREFRONTAL CORTEX': ['Pfc'], + 'SPLEEN': ['Spl'], + 'NUCLEUS ACCUMBENS': ['Nac'], + 'NEOCORTEX': ['Ctx'], + 'ADIPOSE': ['Wfat'], + 'RETINA': ['Ret'] + } + + diff --git a/wqflask/base/cgiData.py b/wqflask/base/cgiData.py new file mode 100755 index 00000000..57416060 --- /dev/null +++ b/wqflask/base/cgiData.py @@ -0,0 +1,70 @@ +# Copyright (C) University of Tennessee Health Science Center, Memphis, TN. +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Affero General Public License for more details. +# +# This program is available from Source Forge: at GeneNetwork Project +# (sourceforge.net/projects/genenetwork/). +# +# Contact Drs. Robert W. Williams and Xiaodong Zhou (2010) +# at rwilliams@uthsc.edu and xzhou15@uthsc.edu +# +# +# +# This module is used by GeneNetwork project (www.genenetwork.org) +# +# Created by GeneNetwork Core Team 2010/08/10 +# +# Last updated by GeneNetwork Core Team 2010/10/20 + +######################################### +#convert Field storage object to Dict object +#in order to be able to saved into a session file +######################################### + +class cgiData(dict): + '''convert Field storage object to Dict object + Filed storage object cannot be properly dumped + ''' + + def __init__(self, field_storage=None): + + if not field_storage: + field_storage={} + + for key in field_storage.keys(): + temp = field_storage.getlist(key) + if len(temp) > 1: + temp = map(self.toValue, temp) + elif len(temp) == 1: + temp = self.toValue(temp[0]) + else: + temp = None + self[key]= temp + + def toValue(self, obj): + '''fieldstorge returns different type of objects, \ + need to convert to string or None''' + try: + return obj.value + except: + return "" + + def getvalue(self, k, default= None): + try: + return self[k] + except: + return default + + getfirst = getvalue + + + + diff --git a/wqflask/base/cookieData.py b/wqflask/base/cookieData.py new file mode 100755 index 00000000..4b7c9046 --- /dev/null +++ b/wqflask/base/cookieData.py @@ -0,0 +1,52 @@ +# Copyright (C) University of Tennessee Health Science Center, Memphis, TN. +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Affero General Public License for more details. +# +# This program is available from Source Forge: at GeneNetwork Project +# (sourceforge.net/projects/genenetwork/). +# +# Contact Drs. Robert W. Williams and Xiaodong Zhou (2010) +# at rwilliams@uthsc.edu and xzhou15@uthsc.edu +# +# +# +# This module is used by GeneNetwork project (www.genenetwork.org) +# +# Created by GeneNetwork Core Team 2010/08/10 +# +# Last updated by GeneNetwork Core Team 2010/10/20 + +######################################### +#convert mod_python object to Dict object +#in order to be able to be pickled +######################################### + +class cookieData(dict): + 'convert mod python Cookie object to Dict object' + + def __init__(self, cookies=None): + + if not cookies: + cookies={} + + for key in cookies.keys(): + self[key.lower()]= cookies[key].value + + def getvalue(self, k, default= None): + try: + return self[k.lower()] + except: + return default + + getfirst = getvalue + + + diff --git a/wqflask/base/footer.py b/wqflask/base/footer.py new file mode 100755 index 00000000..6f92fdf8 --- /dev/null +++ b/wqflask/base/footer.py @@ -0,0 +1,6 @@ +import webqtlConfig + +footer_html = open(webqtlConfig.HTMLPATH + 'footer.html', 'r').read() +footer = footer_html.replace('%"','%%"') + +footer_string = footer.replace('', '%s') diff --git a/wqflask/base/header.py b/wqflask/base/header.py new file mode 100755 index 00000000..b6136b51 --- /dev/null +++ b/wqflask/base/header.py @@ -0,0 +1,6 @@ +import webqtlConfig + +header_string = open(webqtlConfig.HTMLPATH + 'header.html', 'r').read() +header_string = header_string.replace("\\'", "'") +header_string = header_string.replace('%"','%%"') +header_string = header_string.replace('', '%s') \ No newline at end of file diff --git a/wqflask/base/indexBody.py b/wqflask/base/indexBody.py new file mode 100755 index 00000000..aa67dffa --- /dev/null +++ b/wqflask/base/indexBody.py @@ -0,0 +1,290 @@ +index_body_string = """ + +

Select and Search +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Species: + + + +
+ Group: + + + +
+ Type: + + + +
+ Database: + + + + +
+ + +

    Databases marked with ** suffix are not public yet. +
    Access requires user login.

+
+ Get Any: + + + + +
+ + + +

    Enter terms, genes, ID numbers in the Get Any field. +
    Use * or ? wildcards (Cyp*a?, synap*). +
    Use Combined for terms such as tyrosine kinase.

+ +
+ Combined: + + + + +
+ + +      +      + + +
+ + + +
+ + + + + + + + +

 ______________________________________________________ + +

  + +Quick HELP Examples and + + User's Guide

+ + +  You can also use advanced commands. Copy these simple examples +
  into the Get Any or Combined search fields: + + + + + + + + +

Websites Affiliated with GeneNetwork

+

+

+

+

____________________________ + +

Getting Started   

+
    +
  1. Select Species (or select All) +
  2. Select Group (a specific sample) +
  3. Select Type of data: + +
  4. Select a Database +
  5. Enter search terms in the Get Any or Combined field: words, genes, ID numbers, probes, advanced search commands +
  6. Click on the Search button +
  7. Optional: Use the Make Default button to save your preferences +
+ +

____________________________ + +

How to Use GeneNetwork + +

+

Take a 20-40 minute GeneNetwork Tour that includes screen shots and typical steps in the analysis.

+
+
+

For information about resources and methods, select the INFO buttons.

+ + + +

Try the Workstation site to explore data and features that are being implemented.

+ + +

Review the Conditions and Contacts pages for information on the status of data sets and advice on their use and citation.

+ + +
+ + + +

Mirror and Development Sites

+ + + + +

History and Archive + +

+

GeneNetwork's Time Machine links to earlier versions that correspond to specific publication dates.

+ +
+ + +

+ +""" diff --git a/wqflask/base/myCookie.py b/wqflask/base/myCookie.py new file mode 100755 index 00000000..db5320df --- /dev/null +++ b/wqflask/base/myCookie.py @@ -0,0 +1,55 @@ +# Copyright (C) University of Tennessee Health Science Center, Memphis, TN. +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Affero General Public License for more details. +# +# This program is available from Source Forge: at GeneNetwork Project +# (sourceforge.net/projects/genenetwork/). +# +# Contact Drs. Robert W. Williams and Xiaodong Zhou (2010) +# at rwilliams@uthsc.edu and xzhou15@uthsc.edu +# +# +# +# This module is used by GeneNetwork project (www.genenetwork.org) +# +# Created by GeneNetwork Core Team 2010/08/10 +# +# Last updated by GeneNetwork Core Team 2010/10/20 + +######################################### +## python cookie and mod python cookie are +## not compatible +######################################### + +class myCookie(dict): + 'define my own cookie' + + def __init__(self, name="", value="", expire = None, path="/"): + self['name']= name + self['value']= value + self['expire']= expire + self['path']= path + + def __getattr__(self, key): + if key in self.keys(): + return self[key] + else: + return None + + def __nonzero__ (self): + if self['name']: + return 1 + else: + return 0 + + + + diff --git a/wqflask/base/sessionData.py b/wqflask/base/sessionData.py new file mode 100755 index 00000000..01555f87 --- /dev/null +++ b/wqflask/base/sessionData.py @@ -0,0 +1,53 @@ +# Copyright (C) University of Tennessee Health Science Center, Memphis, TN. +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Affero General Public License for more details. +# +# This program is available from Source Forge: at GeneNetwork Project +# (sourceforge.net/projects/genenetwork/). +# +# Contact Drs. Robert W. Williams and Xiaodong Zhou (2010) +# at rwilliams@uthsc.edu and xzhou15@uthsc.edu +# +# +# +# This module is used by GeneNetwork project (www.genenetwork.org) +# +# Created by GeneNetwork Core Team 2010/08/10 +# +# Last updated by GeneNetwork Core Team 2010/10/20 + +######################################### +#convert mod_python object to Dict object +#in order to be able to be pickled +######################################### + +class sessionData(dict): + 'convert mod python Session object to Dict object' + + def __init__(self, mod_python_session=None): + + if not mod_python_session: + mod_python_session = {} + + for key in mod_python_session.keys(): + self[key]= mod_python_session[key] + + + def getvalue(self, k, default= None): + try: + return self[k] + except: + return default + + getfirst = getvalue + + + diff --git a/wqflask/base/template.py b/wqflask/base/template.py new file mode 100755 index 00000000..85bd86df --- /dev/null +++ b/wqflask/base/template.py @@ -0,0 +1,123 @@ +# Copyright (C) University of Tennessee Health Science Center, Memphis, TN. +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Affero General Public License for more details. +# +# This program is available from Source Forge: at GeneNetwork Project +# (sourceforge.net/projects/genenetwork/). +# +# Contact Drs. Robert W. Williams and Xiaodong Zhou (2010) +# at rwilliams@uthsc.edu and xzhou15@uthsc.edu +# +# +# +# This module is used by GeneNetwork project (www.genenetwork.org) +# +# Created by GeneNetwork Core Team 2010/08/10 +# +# Last updated by GeneNetwork Core Team 2010/10/20 + +template = """ + + + + +%s + + + + + + + +%s + + + + + + + + + + + + + + +%s + + + + +%s + + + + + %s + + + + + + + + + + + + + + +
+ + + %s + +
+
+ %s
+
+ + + + + + + + + + +""" diff --git a/wqflask/base/templatePage.py b/wqflask/base/templatePage.py new file mode 100755 index 00000000..4dece24a --- /dev/null +++ b/wqflask/base/templatePage.py @@ -0,0 +1,222 @@ +# Copyright (C) University of Tennessee Health Science Center, Memphis, TN. +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Affero General Public License for more details. +# +# This program is available from Source Forge: at GeneNetwork Project +# (sourceforge.net/projects/genenetwork/). +# +# Contact Drs. Robert W. Williams and Xiaodong Zhou (2010) +# at rwilliams@uthsc.edu and xzhou15@uthsc.edu +# +# +# +# This module is used by GeneNetwork project (www.genenetwork.org) +# +# Created by GeneNetwork Core Team 2010/08/10 +# +# Last updated by GeneNetwork Core Team 2010/10/20 + +#templatePage.py +# +#--Genenetwork generates a lot of pages; this file is the generic version of them, defining routines they all use. +# +#Classes: +#templatePage +# +#Functions (of templatePage): +#__init__(...) -- class constructor, allows a more specific template to be used in addition to templatePage +#__str__(self) -- returns the object's elements as a tuple +#__del__(self) -- closes the current connection to MySQL, if there is one +#write -- explained below +#writefile -- explained below +#openMysql(self) -- opens a MySQL connection and stores the resulting cursor in the object's cursor variable +#updMysql(self) -- same as openMysql +#error -- explained below +#session -- explained below + + +import socket +import time +import shutil +import MySQLdb +import os + +from htmlgen import HTMLgen2 as HT + +import template +import webqtlConfig +import header +import footer +from utility import webqtlUtil + + + +class templatePage: + + contents = ['title','basehref','js1','js2', 'layer', 'header', 'body', 'footer'] + + # you can pass in another template here if you want + def __init__(self, fd=None, template=template.template): + + # initiate dictionary + self.starttime = time.time() + self.dict = {} + self.template = template + + for item in self.contents: + self.dict[item] = "" + + self.dict['basehref'] = "" #webqtlConfig.BASEHREF + self.cursor = None + + self.cookie = [] #XZ: list to hold cookies (myCookie object) being changed + self.content_type = 'text/html' + self.content_disposition = '' + self.redirection = '' + self.debug = '' + self.attachment = '' + + #XZ: Holding data (new data or existing data being changed) that should be saved to session. The data must be picklable!!! + self.session_data_changed = {} + + self.userName = 'Guest' + self.privilege = 'guest' + if fd.input_session_data.has_key('user'): + self.userName = fd.input_session_data['user'] + if fd.input_session_data.has_key('privilege'): + self.privilege = fd.input_session_data['privilege'] + + def __str__(self): + + #XZ: default setting + thisUserName = self.userName + thisPrivilege = self.privilege + #XZ: user may just go through login or logoff page + if self.session_data_changed.has_key('user'): + thisUserName = self.session_data_changed['user'] + if self.session_data_changed.has_key('privilege'): + thisPrivilege = self.session_data_changed['privilege'] + + if thisUserName == 'Guest': + userInfo = 'Welcome! Login' + else: + userInfo = 'Hi, %s! Logout' % thisUserName + + reload(header) + self.dict['header'] = header.header_string % userInfo + + serverInfo = "It took %2.3f second(s) for %s to generate this page" % (time.time()-self.starttime, socket.getfqdn()) + reload(footer) + self.dict['footer'] = footer.footer_string % serverInfo + + slist = [] + for item in self.contents: + slist.append(self.dict[item]) + return self.template % tuple(slist) + + + def __del__(self): + if self.cursor: + self.cursor.close() + + def write(self): + 'return string representation of this object' + + if self.cursor: + self.cursor.close() + + return str(self) + + def writeFile(self, filename): + 'save string representation of this object into a file' + if self.cursor: + self.cursor.close() + + try: + 'it could take a long time to generate the file, save to .tmp first' + fp = open(os.path.join(webqtlConfig.TMPDIR, filename+'.tmp'), 'wb') + fp.write(str(self)) + fp.close() + path_tmp = os.path.join(webqtlConfig.TMPDIR, filename+'.tmp') + path_html = os.path.join(webqtlConfig.TMPDIR, filename) + shutil.move(path_tmp,path_html) + except: + pass + + def openMysql(self): + try: + self.con = MySQLdb.Connect(db=webqtlConfig.DB_NAME,host=webqtlConfig.MYSQL_SERVER, \ + user=webqtlConfig.DB_USER,passwd=webqtlConfig.DB_PASSWD) + self.cursor = self.con.cursor() + return 1 + except: + heading = "Connect MySQL Server" + detail = ["Can't connect to MySQL server on '"+ webqtlConfig.MYSQL_SERVER+"':100061. \ + The server may be down at this time"] + self.error(heading=heading,detail=detail,error="Error 2003") + return 0 + + def updMysql(self): + try: + self.con = MySQLdb.Connect(db=webqtlConfig.DB_UPDNAME,host=webqtlConfig.MYSQL_UPDSERVER, \ + user=webqtlConfig.DB_UPDUSER,passwd=webqtlConfig.DB_UPDPASSWD) + self.cursor = self.con.cursor() + return 1 + except: + heading = "Connect MySQL Server" + detail = ["update: Can't connect to MySQL server on '"+ webqtlConfig.MYSQL_UPDSERVER+"':100061. \ + The server may be down at this time "] + self.error(heading=heading,detail=detail,error="Error 2003") + return 0 + + def error(self,heading="",intro=[],detail=[],title="Error",error="Error"): + 'generating a WebQTL style error page' + Heading = HT.Paragraph(heading) + Heading.__setattr__("class","title") + + Intro = HT.Blockquote() + if intro: + for item in intro: + Intro.append(item) + else: + Intro.append(HT.Strong('Sorry!'),' Error occurred while processing\ + your request.', HT.P(),'The nature of the error generated is as\ + follows:') + + Detail = HT.Blockquote() + Detail.append(HT.Span("%s : " % error,Class="fwb cr")) + if detail: + Detail2 = HT.Blockquote() + for item in detail: + Detail2.append(item) + Detail.append(HT.Italic(Detail2)) + + #Detail.__setattr__("class","subtitle") + TD_LR = HT.TD(height=200,width="100%",bgColor='#eeeeee',valign="top") + TD_LR.append(Heading,Intro,Detail) + self.dict['body'] = str(TD_LR) + self.dict['title'] = title + + def session(self,mytitle="",myHeading=""): + 'generate a auto-refreshing temporary html file(waiting page)' + self.filename = webqtlUtil.generate_session() + self.dict['title'] = mytitle + self.dict['basehref'] = webqtlConfig.REFRESHSTR % (webqtlConfig.CGIDIR, self.filename) + "" #webqtlConfig.BASEHREF + + TD_LR = HT.TD(align="center", valign="middle", height=200,width="100%", bgColor='#eeeeee') + Heading = HT.Paragraph(myHeading, Class="fwb fs16 cr") + # NL, 07/27/2010. variable 'PROGRESSBAR' has been moved from templatePage.py to webqtlUtil.py; + TD_LR.append(Heading, HT.BR(), webqtlUtil.PROGRESSBAR) + self.dict['body'] = TD_LR + self.writeFile(self.filename + '.html') + return self.filename + + diff --git a/wqflask/base/webqtlCaseData.py b/wqflask/base/webqtlCaseData.py new file mode 100755 index 00000000..4df32ca4 --- /dev/null +++ b/wqflask/base/webqtlCaseData.py @@ -0,0 +1,54 @@ +# Copyright (C) University of Tennessee Health Science Center, Memphis, TN. +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Affero General Public License for more details. +# +# This program is available from Source Forge: at GeneNetwork Project +# (sourceforge.net/projects/genenetwork/). +# +# Contact Drs. Robert W. Williams and Xiaodong Zhou (2010) +# at rwilliams@uthsc.edu and xzhou15@uthsc.edu +# +# +# +# This module is used by GeneNetwork project (www.genenetwork.org) +# +# Created by GeneNetwork Core Team 2010/08/10 +# +# Last updated by GeneNetwork Core Team 2010/10/20 + +class webqtlCaseData: + """ + one case data in one trait + """ + + val = None #Trait Value + var = None #Trait Variance + N = None #Number of individuals + + def __init__(self, val=val, var=var, N=N): + self.val = val + self.var = var + self.N = N + + def __str__(self): + str = "" + if self.val != None: + str += "value=%2.3f" % self.val + if self.var != None: + str += " variance=%2.3f" % self.var + if self.N != None: + str += " ndata=%d" % self.N + return str + + __repr__ = __str__ + + + diff --git a/wqflask/base/webqtlConfig.py b/wqflask/base/webqtlConfig.py new file mode 100755 index 00000000..755595e0 --- /dev/null +++ b/wqflask/base/webqtlConfig.py @@ -0,0 +1,73 @@ +from webqtlConfigLocal import * +#########################################' +# Environment Variables - public +######################################### + +#Debug Level +#1 for debug, mod python will reload import each time +DEBUG = 1 + +#USER privilege +USERDICT = {'guest':1,'user':2, 'admin':3, 'root':4} + +#minimum number of informative strains +KMININFORMATIVE = 5 + +#maximum number of traits for interval mapping +MULTIPLEMAPPINGLIMIT = 11 + +#maximum number of traits for correlation +MAXCORR = 100 + +#Daily download limit from one IP +DAILYMAXIMUM = 1000 + +#maximum LRS value +MAXLRS = 460.0 + +#temporary data life span +MAXLIFE = 86400 + +#MINIMUM Database public value +PUBLICTHRESH = 0 + +#NBCI address +NCBI_LOCUSID = "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=gene&cmd=Retrieve&dopt=Graphics&list_uids=%s" +UCSC_REFSEQ = "http://genome.cse.ucsc.edu/cgi-bin/hgGene?db=%s&hgg_gene=%s&hgg_chrom=chr%s&hgg_start=%s&hgg_end=%s" +GENBANK_ID = "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=Nucleotide&cmd=search&doptcmdl=DocSum&term=%s" +OMIM_ID = "http://www.ncbi.nlm.nih.gov/omim/%s" +UNIGEN_ID = "http://www.ncbi.nlm.nih.gov/UniGene/clust.cgi?ORG=%s&CID=%s" +HOMOLOGENE_ID = "http://www.ncbi.nlm.nih.gov/sites/entrez?Db=homologene&Cmd=DetailsSearch&Term=%s" +PUBMEDLINK_URL = "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=%s&dopt=Abstract" +UCSC_POS = "http://genome.ucsc.edu/cgi-bin/hgTracks?clade=mammal&org=%s&db=%s&position=chr%s:%s-%s&pix=800&Submit=submit" +UCSC_BLAT = 'http://genome.ucsc.edu/cgi-bin/hgBlat?org=%s&db=%s&type=0&sort=0&output=0&userSeq=%s' +UTHSC_BLAT = 'http://ucscbrowser.genenetwork.org/cgi-bin/hgBlat?org=%s&db=%s&type=0&sort=0&output=0&userSeq=%s' +UCSC_GENOME = "http://genome.ucsc.edu/cgi-bin/hgTracks?db=%s&position=chr%s:%d-%d&hgt.customText=http://web2qtl.utmem.edu:88/snp/chr%s" +ENSEMBLE_BLAT = 'http://www.ensembl.org/Mus_musculus/featureview?type=AffyProbe&id=%s' +DBSNP = 'http://www.ncbi.nlm.nih.gov/SNP/snp_ref.cgi?type=rs&rs=%s' +UCSC_RUDI_TRACK_URL = " http://genome.cse.ucsc.edu/cgi-bin/hgTracks?org=%s&db=%s&hgt.customText=http://gbic.biol.rug.nl/~ralberts/tracks/%s/%s" +GENOMEBROWSER_URL="http://ucscbrowser.genenetwork.org/cgi-bin/hgTracks?clade=mammal&org=Mouse&db=mm9&position=%s&hgt.suggest=&pix=800&Submit=submit" +ENSEMBLETRANSCRIPT_URL="http://useast.ensembl.org/Mus_musculus/Lucene/Details?species=Mus_musculus;idx=Transcript;end=1;q=%s" + +SECUREDIR = GNROOT + 'secure/' +COMMON_LIB = GNROOT + 'support/admin' +HTMLPATH = GNROOT + 'web/' +IMGDIR = HTMLPATH +'image/' +IMAGESPATH = HTMLPATH + 'images/' +UPLOADPATH = IMAGESPATH + 'upload/' +TMPDIR = '/tmp/' +GENODIR = HTMLPATH + 'genotypes/' +GENO_ARCHIVE_DIR = GENODIR + 'archive/' +TEXTDIR = HTMLPATH + 'ProbeSetFreeze_DataMatrix/' +CMDLINEDIR = HTMLPATH + 'webqtl/cmdLine/' +ChangableHtmlPath = GNROOT + 'web/' + +SITENAME = 'GN' +PORTADDR = "http://132.192.47.32" +BASEHREF = '' +INFOPAGEHREF = '/dbdoc/%s.html' +GLOSSARYFILE = "/glossary.html" +CGIDIR = '/webqtl/' #XZ: The variable name 'CGIDIR' should be changed to 'PYTHONDIR' +SCRIPTFILE = 'main.py' +REFRESHSTR = '' +REFRESHDIR = '%s' + SCRIPTFILE +'?sid=%s' diff --git a/wqflask/base/webqtlConfigLocal.py b/wqflask/base/webqtlConfigLocal.py new file mode 100755 index 00000000..35da73c2 --- /dev/null +++ b/wqflask/base/webqtlConfigLocal.py @@ -0,0 +1,19 @@ +#########################################' +# Environment Variables - private +######################################### + +MYSQL_SERVER = 'localhost' +DB_NAME = 'db_webqtl' +DB_USER = 'webqtlupd' +DB_PASSWD = 'zhou&yan@ut' + +MYSQL_UPDSERVER = 'localhost' +DB_UPDNAME = 'db_webqtl' +DB_UPDUSER = 'webqtlupd' +DB_UPDPASSWD = 'zhou&yan@ut' + +GNROOT = '/gnshare/gn/' +PythonPath = '/usr/bin/python' +PIDDLE_FONT_PATH = '/usr/lib/python2.4/site-packages/piddle/truetypefonts/' + +TEXTUI=1 # XZ: This is to protect GN production server. If set to 0, no text UI is allowed. diff --git a/wqflask/base/webqtlDataset.py b/wqflask/base/webqtlDataset.py new file mode 100755 index 00000000..da1b8601 --- /dev/null +++ b/wqflask/base/webqtlDataset.py @@ -0,0 +1,160 @@ +# Copyright (C) University of Tennessee Health Science Center, Memphis, TN. +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Affero General Public License for more details. +# +# This program is available from Source Forge: at GeneNetwork Project +# (sourceforge.net/projects/genenetwork/). +# +# Contact Drs. Robert W. Williams and Xiaodong Zhou (2010) +# at rwilliams@uthsc.edu and xzhou15@uthsc.edu +# +# +# +# This module is used by GeneNetwork project (www.genenetwork.org) +# +# Created by GeneNetwork Core Team 2010/08/10 +# +# Last updated by GeneNetwork Core Team 2010/10/20 + +from htmlgen import HTMLgen2 as HT + +import webqtlConfig + + + +class webqtlDataset: + """ + Database class defines a database in webqtl, can be either Microarray, + Published phenotype, genotype, or user input database(temp) + """ + + def __init__(self, dbName, cursor=None): + + assert dbName + self.id = 0 + self.name = '' + self.type = '' + self.riset = '' + self.cursor = cursor + + #temporary storage + if dbName.find('Temp') >= 0: + self.searchfield = ['name','description'] + self.disfield = ['name','description'] + self.type = 'Temp' + self.id = 1 + self.fullname = 'Temporary Storage' + self.shortname = 'Temp' + elif dbName.find('Publish') >= 0: + self.searchfield = ['name','post_publication_description','abstract','title','authors'] + self.disfield = ['name','pubmed_id', + 'pre_publication_description', 'post_publication_description', 'original_description', + 'pre_publication_abbreviation', 'post_publication_abbreviation', + 'lab_code', 'submitter', 'owner', 'authorized_users', + 'authors','title','abstract', 'journal','volume','pages','month', + 'year','sequence', 'units', 'comments'] + self.type = 'Publish' + elif dbName.find('Geno') >= 0: + self.searchfield = ['name','chr'] + self.disfield = ['name','chr','mb', 'source2', 'sequence'] + self.type = 'Geno' + else: #ProbeSet + self.searchfield = ['name','description','probe_target_description', + 'symbol','alias','genbankid','unigeneid','omim', + 'refseq_transcriptid','probe_set_specificity', 'probe_set_blat_score'] + self.disfield = ['name','symbol','description','probe_target_description', + 'chr','mb','alias','geneid','genbankid', 'unigeneid', 'omim', + 'refseq_transcriptid','blatseq','targetseq','chipid', 'comments', + 'strand_probe','strand_gene','probe_set_target_region', + 'probe_set_specificity', 'probe_set_blat_score','probe_set_blat_mb_start', + 'probe_set_blat_mb_end', 'probe_set_strand', + 'probe_set_note_by_rw', 'flag'] + self.type = 'ProbeSet' + self.name = dbName + if self.cursor and self.id == 0: + self.retrieveName() + + def __str__(self): + return self.name + + __repr__ = __str__ + + + def getRISet(self): + assert self.cursor + if self.type == 'Publish': + query = ''' + SELECT + InbredSet.Name, InbredSet.Id + FROM + InbredSet, PublishFreeze + WHERE + PublishFreeze.InbredSetId = InbredSet.Id AND + PublishFreeze.Name = "%s" + ''' % self.name + elif self.type == 'Geno': + query = ''' + SELECT + InbredSet.Name, InbredSet.Id + FROM + InbredSet, GenoFreeze + WHERE + GenoFreeze.InbredSetId = InbredSet.Id AND + GenoFreeze.Name = "%s" + ''' % self.name + elif self.type == 'ProbeSet': + query = ''' + SELECT + InbredSet.Name, InbredSet.Id + FROM + InbredSet, ProbeSetFreeze, ProbeFreeze + WHERE + ProbeFreeze.InbredSetId = InbredSet.Id AND + ProbeFreeze.Id = ProbeSetFreeze.ProbeFreezeId AND + ProbeSetFreeze.Name = "%s" + ''' % self.name + else: + return "" + self.cursor.execute(query) + RISet, RIID = self.cursor.fetchone() + if RISet == 'BXD300': + RISet = "BXD" + self.riset = RISet + self.risetid = RIID + return RISet + + + def retrieveName(self): + assert self.id == 0 and self.cursor + query = ''' + SELECT + Id, Name, FullName, ShortName + FROM + %sFreeze + WHERE + public > %d AND + (Name = "%s" OR FullName = "%s" OR ShortName = "%s") + '''% (self.type, webqtlConfig.PUBLICTHRESH, self.name, self.name, self.name) + try: + self.cursor.execute(query) + self.id,self.name,self.fullname,self.shortname=self.cursor.fetchone() + except: + raise KeyError, `self.name`+' doesn\'t exist.' + + + def genHTML(self, Class='c0dd'): + return HT.Href(text = HT.Span('%s Database' % self.fullname, Class= "fwb " + Class), + url= webqtlConfig.INFOPAGEHREF % self.name,target="_blank") + + + + + diff --git a/wqflask/base/webqtlFormData.py b/wqflask/base/webqtlFormData.py new file mode 100755 index 00000000..84e41cae --- /dev/null +++ b/wqflask/base/webqtlFormData.py @@ -0,0 +1,289 @@ +# Copyright (C) University of Tennessee Health Science Center, Memphis, TN. +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Affero General Public License for more details. +# +# This program is available from Source Forge: at GeneNetwork Project +# (sourceforge.net/projects/genenetwork/). +# +# Contact Drs. Robert W. Williams and Xiaodong Zhou (2010) +# at rwilliams@uthsc.edu and xzhou15@uthsc.edu +# +# +# +# This module is used by GeneNetwork project (www.genenetwork.org) +# +# Created by GeneNetwork Core Team 2010/08/10 +# +# Last updated by GeneNetwork Core Team 2010/10/20 + +from mod_python import Cookie +import string +import os + +import reaper + +import webqtlConfig +import cookieData +import sessionData +from cgiData import cgiData +from webqtlCaseData import webqtlCaseData +from utility import webqtlUtil + + + +class webqtlFormData: + 'Represents data from a WebQTL form page, needed to generate the next page' + attrs = ('formID','RISet','genotype','strainlist','allstrainlist', + 'suggestive','significance','submitID','identification', 'enablevariance', + 'nperm','nboot','email','incparentsf1','genotype_1','genotype_2','traitInfo') + + #XZ: Attention! All attribute values must be picklable! + + def __init__(self, req = None, mod_python_session=None, FieldStorage_formdata=None): + + for item in self.attrs: + setattr(self,item, None) + + try: + self.remote_ip = req.connection.remote_ip + except: + self.remote_ip = '1.2.3.4' + + if req and req.headers_in.has_key('referer'): + self.refURL = req.headers_in['referer'] + else: + self.refURL = None + + + self.cookies = cookieData.cookieData(Cookie.get_cookies(req)) #XZ: dictionary type. To hold values transfered from mod_python Cookie. + + #XZ: dictionary type. To hold values transfered from mod_python Session object. We assume that it is always picklable. + self.input_session_data = sessionData.sessionData( mod_python_session ) + + #XZ: FieldStorage_formdata may contain item that can't be pickled. Must convert to picklable data. + self.formdata = cgiData( FieldStorage_formdata ) + + #get Form ID + self.formID = self.formdata.getfirst('FormID') + + #get rest of the attributes + if self.formID: + for item in self.attrs: + value = self.formdata.getfirst(item) + if value != None: + setattr(self,item,string.strip(value)) + + self.ppolar = "" + self.mpolar = "" + if self.RISet: + try: + # NL, 07/27/2010. ParInfo has been moved from webqtlForm.py to webqtlUtil.py; + f1, f12, self.mpolar, self.ppolar = webqtlUtil.ParInfo[self.RISet] + except: + f1 = f12 = self.mpolar = self.ppolar = None + + try: + self.nperm = int(self.nperm) + self.nboot = int(self.nboot) + except: + self.nperm = 2000 #XZ: Rob asked to change the default value to 2000 + self.nboot = 2000 #XZ: Rob asked to change the default value to 2000 + + if self.allstrainlist: + self.allstrainlist = map(string.strip, string.split(self.allstrainlist)) + #self.readGenotype() + #self.readData() + + if self.RISet == 'BXD300': + self.RISet = 'BXD' + else: + pass + + def __str__(self): + rstr = '' + for item in self.attrs: + if item != 'genotype': + rstr += '%s:%s\n' % (item,str(getattr(self,item))) + return rstr + + + def readGenotype(self): + 'read genotype from .geno file' + if self.RISet == 'BXD300': + self.RISet = 'BXD' + else: + pass + assert self.RISet + #genotype_1 is Dataset Object without parents and f1 + #genotype_2 is Dataset Object with parents and f1 (not for intercross) + self.genotype_1 = reaper.Dataset() + self.genotype_1.read(os.path.join(webqtlConfig.GENODIR, self.RISet + '.geno')) + try: + # NL, 07/27/2010. ParInfo has been moved from webqtlForm.py to webqtlUtil.py; + _f1, _f12, _mat, _pat = webqtlUtil.ParInfo[self.RISet] + except: + _f1 = _f12 = _mat = _pat = None + + self.genotype_2 =self.genotype_1 + if self.genotype_1.type == "riset" and _mat and _pat: + self.genotype_2 = self.genotype_1.add(Mat=_mat, Pat=_pat) #, F1=_f1) + + #determine default genotype object + if self.incparentsf1 and self.genotype_1.type != "intercross": + self.genotype = self.genotype_2 + else: + self.incparentsf1 = 0 + self.genotype = self.genotype_1 + self.strainlist = list(self.genotype.prgy) + self.f1list = self.parlist = [] + if _f1 and _f12: + self.f1list = [_f1, _f12] + if _mat and _pat: + self.parlist = [_mat, _pat] + + def readData(self, strainlst=[], incf1=[]): + 'read user input data or from trait data and analysis form' + + if not self.genotype: + self.readGenotype() + if not strainlst: + if incf1: + strainlst = self.f1list + self.strainlist + else: + strainlst = self.strainlist + + + traitfiledata = self.formdata.getfirst('traitfile') + traitpastedata = self.formdata.getfirst('traitpaste') + variancefiledata = self.formdata.getfirst('variancefile') + variancepastedata = self.formdata.getfirst('variancepaste') + Nfiledata = self.formdata.getfirst('Nfile') + + + if traitfiledata: + tt = string.split(traitfiledata) + vals = map(webqtlUtil.StringAsFloat, tt) + elif traitpastedata: + tt = string.split(traitpastedata) + vals = map(webqtlUtil.StringAsFloat, tt) + else: + vals = map(self.FormDataAsFloat, strainlst) + + if len(vals) < len(strainlst): + vals += [None]*(len(strainlst) - len(vals)) + elif len(vals) > len(strainlst): + vals = vals[:len(strainlst)] + else: + pass + + + if variancefiledata: + tt = string.split(variancefiledata) + vars = map(webqtlUtil.StringAsFloat, tt) + elif variancepastedata: + tt = string.split(variancepastedata) + vars = map(webqtlUtil.StringAsFloat, tt) + else: + vars = map(self.FormVarianceAsFloat, strainlst) + + if len(vars) < len(strainlst): + vars += [None]*(len(strainlst) - len(vars)) + elif len(vars) > len(strainlst): + vars = vars[:len(strainlst)] + else: + pass + + if Nfiledata: + tt = string.split(Nfiledata) + nstrains = map(webqtlUtil.IntAsFloat, tt) + if len(nstrains) < len(strainlst): + nstrains += [None]*(len(strainlst) - len(nstrains)) + else: + nstrains = map(self.FormNAsFloat, strainlst) + + ##vals, vars, nstrains is obsolete + self.allTraitData = {} + for i, _strain in enumerate(strainlst): + if vals[i] != None: + self.allTraitData[_strain] = webqtlCaseData(vals[i], vars[i], nstrains[i]) + + + + def informativeStrains(self, strainlst=[], incVars = 0): + '''if readData was called, use this to output the informative strains + (strain with values)''' + if not strainlst: + strainlst = self.strainlist + strains = [] + vals = [] + vars = [] + for _strain in strainlst: + if self.allTraitData.has_key(_strain): + _val, _var = self.allTraitData[_strain].val, self.allTraitData[_strain].var + if _val != None: + if incVars: + if _var != None: + strains.append(_strain) + vals.append(_val) + vars.append(_var) + else: + strains.append(_strain) + vals.append(_val) + vars.append(None) + return strains, vals, vars, len(strains) + + + + def FormDataAsFloat(self, key): + try: + return float(self.formdata.getfirst(key)) + except: + return None + + + def FormVarianceAsFloat(self, key): + try: + return float(self.formdata.getfirst('V' + key)) + except: + return None + + def FormNAsFloat(self, key): + try: + return int(self.formdata.getfirst('N' + key)) + except: + return None + + def Sample(self): + 'Create some dummy data for testing' + self.RISet = 'BXD' + self.incparentsf1 = 'on' + #self.display = 9.2 + #self.significance = 16.1 + self.readGenotype() + self.identification = 'BXD : Coat color example by Lu Lu, et al' + #self.readGenotype() + #self.genotype.ReadMM('AXBXAforQTL') + #self.strainlist = map((lambda x, y='': '%s%s' % (y,x)), self.genotype.prgy) + #self.strainlist.sort() + self.allTraitData = {'BXD29': webqtlCaseData(3), 'BXD28': webqtlCaseData(2), + 'BXD25': webqtlCaseData(2), 'BXD24': webqtlCaseData(2), 'BXD27': webqtlCaseData(2), + 'BXD21': webqtlCaseData(1), 'BXD20': webqtlCaseData(4), 'BXD23': webqtlCaseData(4), + 'BXD22': webqtlCaseData(3), 'BXD14': webqtlCaseData(4), 'BXD15': webqtlCaseData(2), + 'BXD16': webqtlCaseData(3), 'BXD11': webqtlCaseData(4), 'BXD12': webqtlCaseData(3), + 'BXD13': webqtlCaseData(2), 'BXD18': webqtlCaseData(3), 'BXD19': webqtlCaseData(3), + 'BXD38': webqtlCaseData(3), 'BXD39': webqtlCaseData(3), 'BXD36': webqtlCaseData(2), + 'BXD34': webqtlCaseData(4), 'BXD35': webqtlCaseData(4), 'BXD32': webqtlCaseData(4), + 'BXD33': webqtlCaseData(3), 'BXD30': webqtlCaseData(1), 'BXD31': webqtlCaseData(4), + 'DBA/2J': webqtlCaseData(1), 'BXD8': webqtlCaseData(3), 'BXD9': webqtlCaseData(1), + 'BXD6': webqtlCaseData(3), 'BXD5': webqtlCaseData(3), 'BXD2': webqtlCaseData(4), + 'BXD1': webqtlCaseData(1), 'C57BL/6J': webqtlCaseData(4), 'B6D2F1': webqtlCaseData(4), + 'BXD42': webqtlCaseData(4), 'BXD40': webqtlCaseData(3)} + diff --git a/wqflask/base/webqtlTrait.py b/wqflask/base/webqtlTrait.py new file mode 100755 index 00000000..f5051e45 --- /dev/null +++ b/wqflask/base/webqtlTrait.py @@ -0,0 +1,581 @@ +import string + +from htmlgen import HTMLgen2 as HT + +import webqtlConfig +from webqtlCaseData import webqtlCaseData +from webqtlDataset import webqtlDataset +from dbFunction import webqtlDatabaseFunction +from utility import webqtlUtil + + +class webqtlTrait: + """ + Trait class defines a trait in webqtl, can be either Microarray, + Published phenotype, genotype, or user input trait + """ + + def __init__(self, cursor = None, **kw): + self.cursor = cursor + self.db = None # database object + self.name = '' # Trait ID, ProbeSet ID, Published ID, etc. + self.cellid = '' + self.identification = 'un-named trait' + self.riset = '' + self.haveinfo = 0 + self.sequence = '' # Blat sequence, available for ProbeSet + self.data = {} + for name, value in kw.items(): + if self.__dict__.has_key(name): + setattr(self, name, value) + elif name == 'fullname': + name2 = value.split("::") + if len(name2) == 2: + self.db, self.name = name2 + elif len(name2) == 3: + self.db, self.name, self.cellid = name2 + else: + raise KeyError, `value` + ' parameter format error.' + else: + raise KeyError, `name`+' not a valid parameter for this class.' + + if self.db and type(self.db) == type("1"): + assert self.cursor + self.db = webqtlDataset(self.db, self.cursor) + + #if self.db == None, not from a database + if self.db: + if self.db.type == "Temp": + self.cursor.execute(''' + SELECT + InbredSet.Name + FROM + InbredSet, Temp + WHERE + Temp.InbredSetId = InbredSet.Id AND + Temp.Name = "%s" + ''' % self.name) + self.riset = self.cursor.fetchone()[0] + else: + self.riset = self.db.getRISet() + + # + # In ProbeSet, there are maybe several annotations match one sequence + # so we need use sequence(BlatSeq) as the identification, when we update + # one annotation, we update the others who match the sequence also. + # + # Hongqiang Li, 3/3/2008 + # + + #XZ, 05/08/2009: This block is not neccessary. We can add 'BlatSeq' into disfield. + # The variable self.sequence should be changed to self.BlatSeq + # It also should be changed in other places where it are used. + + if self.db: + if self.db.type == 'ProbeSet': + query = ''' + SELECT + ProbeSet.BlatSeq + FROM + ProbeSet, ProbeSetFreeze, ProbeSetXRef + WHERE + ProbeSet.Id=ProbeSetXRef.ProbeSetId and + ProbeSetFreeze.Id = ProbeSetXRef.ProbeSetFreezeId and + ProbeSet.Name = "%s" and + ProbeSetFreeze.Name = "%s" + ''' % (self.name, self.db.name) + self.cursor.execute(query) + self.sequence = self.cursor.fetchone()[0] + + + def getName(self): + str = "" + if self.db and self.name: + str = "%s::%s" % (self.db, self.name) + if self.cellid: + str += "::" + self.cellid + else: + str = self.description + return str + + # + # when user enter a trait or GN generate a trait, user want show the name + # not the name that generated by GN randomly, the two follow function are + # used to give the real name and the database. displayName() will show the + # database also, getGivenName() just show the name. + # For other trait, displayName() as same as getName(), getGivenName() as + # same as self.name + # + # Hongqiang 11/29/07 + # + def getGivenName(self): + str = self.name + if self.db and self.name: + if self.db.type=='Temp': + self.cursor.execute('SELECT description FROM Temp WHERE Name=%s',self.name) + desc = self.cursor.fetchone()[0] + if desc.__contains__('PCA'): + desc = desc[desc.rindex(':')+1:].strip() + else: + desc = desc[:desc.index('entered')].strip() + str = desc + return str + + def displayName(self): + str = "" + if self.db and self.name: + if self.db.type=='Temp': + desc = self.description + if desc.__contains__('PCA'): + desc = desc[desc.rindex(':')+1:].strip() + else: + desc = desc[:desc.index('entered')].strip() + str = "%s::%s" % (self.db, desc) + else: + str = "%s::%s" % (self.db, self.name) + if self.cellid: + str += "::" + self.cellid + else: + str = self.description + + return str + + + #def __str__(self): + # #return "%s %s" % (self.getName(), self.riset) + # return self.getName() + __str__ = getName + __repr__ = __str__ + + def exportData(self, strainlist, type="val"): + """ + export data according to strainlist + mostly used in calculating correlation + """ + result = [] + for strain in strainlist: + if self.data.has_key(strain): + if type=='val': + result.append(self.data[strain].val) + elif type=='var': + result.append(self.data[strain].var) + elif type=='N': + result.append(self.data[strain].N) + else: + raise KeyError, `type`+' type is incorrect.' + else: + result.append(None) + return result + + def exportInformative(self, incVar=0): + """ + export informative strain + mostly used in qtl regression + """ + strains = [] + vals = [] + vars = [] + for strain, value in self.data.items(): + if value.val != None: + if not incVar or value.var != None: + strains.append(strain) + vals.append(value.val) + vars.append(value.var) + return strains, vals, vars + + + # + # In ProbeSet, there are maybe several annotations match one sequence + # so we need use sequence(BlatSeq) as the identification, when we update + # one annotation, we update the others who match the sequence also. + # + # Hongqiang Li, 3/3/2008 + # + def getSequence(self): + assert self.cursor + if self.db.type == 'ProbeSet': + query = ''' + SELECT + ProbeSet.BlatSeq + FROM + ProbeSet, ProbeSetFreeze, ProbeSetXRef + WHERE + ProbeSet.Id=ProbeSetXRef.ProbeSetId and + ProbeSetFreeze.Id = ProbeSetXRef.ProbSetFreezeId and + ProbeSet.Name = %s + ProbeSetFreeze.Name = %s + ''' , (self.name, self.db.name) + self.cursor.execute(query) + results = self.fetchone() + + return results[0] + + + + def retrieveData(self, strainlist=[]): + assert self.db and self.cursor + + if self.db.type == 'Temp': + query = ''' + SELECT + Strain.Name, TempData.value, TempData.SE, TempData.NStrain, TempData.Id + FROM + TempData, Temp, Strain + WHERE + TempData.StrainId = Strain.Id AND + TempData.Id = Temp.DataId AND + Temp.name = '%s' + Order BY + Strain.Name + ''' % self.name + #XZ, 03/02/2009: Xiaodong changed Data to PublishData, SE to PublishSE + elif self.db.type == 'Publish': + query = ''' + SELECT + Strain.Name, PublishData.value, PublishSE.error, NStrain.count, PublishData.Id + FROM + (PublishData, Strain, PublishXRef, PublishFreeze) + left join PublishSE on + (PublishSE.DataId = PublishData.Id AND PublishSE.StrainId = PublishData.StrainId) + left join NStrain on + (NStrain.DataId = PublishData.Id AND + NStrain.StrainId = PublishData.StrainId) + WHERE + PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND + PublishData.Id = PublishXRef.DataId AND PublishXRef.Id = %s AND + PublishFreeze.Id = %d AND PublishData.StrainId = Strain.Id + Order BY + Strain.Name + ''' % (self.name, self.db.id) + + #XZ, 03/02/2009: Xiaodong changed Data to ProbeData, SE to ProbeSE + elif self.cellid: + #Probe Data + query = ''' + SELECT + Strain.Name, ProbeData.value, ProbeSE.error, ProbeData.Id + FROM + (ProbeData, ProbeFreeze, ProbeSetFreeze, ProbeXRef, + Strain, Probe, ProbeSet) + left join ProbeSE on + (ProbeSE.DataId = ProbeData.Id AND ProbeSE.StrainId = ProbeData.StrainId) + WHERE + Probe.Name = '%s' AND ProbeSet.Name = '%s' AND + Probe.ProbeSetId = ProbeSet.Id AND + ProbeXRef.ProbeId = Probe.Id AND + ProbeXRef.ProbeFreezeId = ProbeFreeze.Id AND + ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id AND + ProbeSetFreeze.Name = '%s' AND + ProbeXRef.DataId = ProbeData.Id AND + ProbeData.StrainId = Strain.Id + Order BY + Strain.Name + ''' % (self.cellid, self.name, self.db.name) + #XZ, 03/02/2009: Xiaodong added this block for ProbeSetData and ProbeSetSE + elif self.db.type == 'ProbeSet': + #ProbeSet Data + query = ''' + SELECT + Strain.Name, ProbeSetData.value, ProbeSetSE.error, ProbeSetData.Id + FROM + (ProbeSetData, ProbeSetFreeze, Strain, ProbeSet, ProbeSetXRef) + left join ProbeSetSE on + (ProbeSetSE.DataId = ProbeSetData.Id AND ProbeSetSE.StrainId = ProbeSetData.StrainId) + WHERE + ProbeSet.Name = '%s' AND ProbeSetXRef.ProbeSetId = ProbeSet.Id AND + ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id AND + ProbeSetFreeze.Name = '%s' AND + ProbeSetXRef.DataId = ProbeSetData.Id AND + ProbeSetData.StrainId = Strain.Id + Order BY + Strain.Name + ''' % (self.name, self.db.name) + #XZ, 03/02/2009: Xiaodong changeded Data to GenoData, SE to GenoSE + else: + #Geno Data + #XZ: The SpeciesId is not necessary, but it's nice to keep it to speed up database search. + query = ''' + SELECT + Strain.Name, GenoData.value, GenoSE.error, GenoData.Id + FROM + (GenoData, GenoFreeze, Strain, Geno, GenoXRef) + left join GenoSE on + (GenoSE.DataId = GenoData.Id AND GenoSE.StrainId = GenoData.StrainId) + WHERE + Geno.SpeciesId = %s AND Geno.Name = '%s' AND GenoXRef.GenoId = Geno.Id AND + GenoXRef.GenoFreezeId = GenoFreeze.Id AND + GenoFreeze.Name = '%s' AND + GenoXRef.DataId = GenoData.Id AND + GenoData.StrainId = Strain.Id + Order BY + Strain.Name + ''' % (webqtlDatabaseFunction.retrieveSpeciesId(self.cursor, self.db.riset), self.name, self.db.name) + + + self.cursor.execute(query) + results = self.cursor.fetchall() + self.data.clear() + if results: + self.mysqlid = results[0][-1] + if strainlist: + for item in results: + if item[0] in strainlist: + val = item[1] + if val != None: + var = item[2] + ndata = None + if self.db.type in ('Publish', 'Temp'): + ndata = item[3] + self.data[item[0]] = webqtlCaseData(val, var, ndata) + #end for + else: + for item in results: + val = item[1] + if val != None: + var = item[2] + ndata = None + if self.db.type in ('Publish', 'Temp'): + ndata = item[3] + self.data[item[0]] = webqtlCaseData(val, var, ndata) + #end for + #end if + else: + pass + + def keys(self): + return self.__dict__.keys() + + def has_key(self, key): + return self.__dict__.has_key(key) + + def items(self): + return self.__dict__.items() + + def retrieveInfo(self, QTL = None): + assert self.db and self.cursor + if self.db.type == 'Publish': + #self.db.DisField = ['Name','PubMed_ID','Phenotype','Abbreviation','Authors','Title',\ + # 'Abstract', 'Journal','Volume','Pages','Month','Year','Sequence',\ + # 'Units', 'comments'] + query = ''' + SELECT + PublishXRef.Id, Publication.PubMed_ID, + Phenotype.Pre_publication_description, Phenotype.Post_publication_description, Phenotype.Original_description, + Phenotype.Pre_publication_abbreviation, Phenotype.Post_publication_abbreviation, + Phenotype.Lab_code, Phenotype.Submitter, Phenotype.Owner, Phenotype.Authorized_Users, + Publication.Authors, Publication.Title, Publication.Abstract, + Publication.Journal, Publication.Volume, Publication.Pages, + Publication.Month, Publication.Year, PublishXRef.Sequence, + Phenotype.Units, PublishXRef.comments + FROM + PublishXRef, Publication, Phenotype, PublishFreeze + WHERE + PublishXRef.Id = %s AND + Phenotype.Id = PublishXRef.PhenotypeId AND + Publication.Id = PublishXRef.PublicationId AND + PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND + PublishFreeze.Id =%s + ''' % (self.name, self.db.id) + #XZ, 05/08/2009: Xiaodong add this block to use ProbeSet.Id to find the probeset instead of just using ProbeSet.Name + #XZ, 05/08/2009: to avoid the problem of same probeset name from different platforms. + elif self.db.type == 'ProbeSet': + disfieldString = string.join(self.db.disfield,',ProbeSet.') + disfieldString = 'ProbeSet.' + disfieldString + query = """ + SELECT %s + FROM ProbeSet, ProbeSetFreeze, ProbeSetXRef + WHERE + ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id AND + ProbeSetXRef.ProbeSetId = ProbeSet.Id AND + ProbeSetFreeze.Name = '%s' AND + ProbeSet.Name = '%s' + """ % (disfieldString, self.db.name, self.name) + #XZ, 05/08/2009: We also should use Geno.Id to find marker instead of just using Geno.Name + # to avoid the problem of same marker name from different species. + elif self.db.type == 'Geno': + disfieldString = string.join(self.db.disfield,',Geno.') + disfieldString = 'Geno.' + disfieldString + query = """ + SELECT %s + FROM Geno, GenoFreeze, GenoXRef + WHERE + GenoXRef.GenoFreezeId = GenoFreeze.Id AND + GenoXRef.GenoId = Geno.Id AND + GenoFreeze.Name = '%s' AND + Geno.Name = '%s' + """ % (disfieldString, self.db.name, self.name) + else: #Temp type + query = 'SELECT %s FROM %s WHERE Name = "%s"' % \ + (string.join(self.db.disfield,','), self.db.type, self.name) + + + self.cursor.execute(query) + traitInfo = self.cursor.fetchone() + if traitInfo: + self.haveinfo = 1 + + #XZ: assign SQL query result to trait attributes. + for i, field in enumerate(self.db.disfield): + setattr(self, field, traitInfo[i]) + + if self.db.type == 'Publish': + self.confidential = 0 + if self.pre_publication_description and not self.pubmed_id: + self.confidential = 1 + + self.homologeneid = None + if self.db.type == 'ProbeSet' and self.riset and self.geneid: + #XZ, 05/26/2010: From time to time, this query get error message because some geneid values in database are not number. + #XZ: So I have to test if geneid is number before execute the query. + #XZ: The geneid values in database should be cleaned up. + try: + junk = float(self.geneid) + geneidIsNumber = 1 + except: + geneidIsNumber = 0 + + if geneidIsNumber: + query = """ + SELECT + HomologeneId + FROM + Homologene, Species, InbredSet + WHERE + Homologene.GeneId =%s AND + InbredSet.Name = '%s' AND + InbredSet.SpeciesId = Species.Id AND + Species.TaxonomyId = Homologene.TaxonomyId + """ % (self.geneid, self.riset) + self.cursor.execute(query) + result = self.cursor.fetchone() + else: + result = None + + if result: + self.homologeneid = result[0] + + if QTL: + if self.db.type == 'ProbeSet' and not self.cellid: + query = ''' + SELECT + ProbeSetXRef.Locus, ProbeSetXRef.LRS, ProbeSetXRef.pValue, ProbeSetXRef.mean + FROM + ProbeSetXRef, ProbeSet + WHERE + ProbeSetXRef.ProbeSetId = ProbeSet.Id AND + ProbeSet.Name = "%s" AND + ProbeSetXRef.ProbeSetFreezeId =%s + ''' % (self.name, self.db.id) + self.cursor.execute(query) + traitQTL = self.cursor.fetchone() + if traitQTL: + self.locus, self.lrs, self.pvalue, self.mean = traitQTL + else: + self.locus = self.lrs = self.pvalue = self.mean = "" + if self.db.type == 'Publish': + query = ''' + SELECT + PublishXRef.Locus, PublishXRef.LRS + FROM + PublishXRef, PublishFreeze + WHERE + PublishXRef.Id = %s AND + PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND + PublishFreeze.Id =%s + ''' % (self.name, self.db.id) + self.cursor.execute(query) + traitQTL = self.cursor.fetchone() + if traitQTL: + self.locus, self.lrs = traitQTL + else: + self.locus = self.lrs = "" + else: + raise KeyError, `self.name`+' information is not found in the database.' + + def genHTML(self, formName = "", dispFromDatabase=0, privilege="guest", userName="Guest", authorized_users=""): + if not self.haveinfo: + self.retrieveInfo() + + if self.db.type == 'Publish': + PubMedLink = "" + if self.pubmed_id: + PubMedLink = HT.Href(text="PubMed %d : " % self.pubmed_id, + target = "_blank", url = webqtlConfig.PUBMEDLINK_URL % self.pubmed_id) + else: + PubMedLink = HT.Span("Unpublished : ", Class="fs15") + + if formName: + setDescription2 = HT.Href(url="javascript:showDatabase3('%s','%s','%s','')" % + (formName, self.db.name, self.name), Class = "fs14") + else: + setDescription2 = HT.Href(url="javascript:showDatabase2('%s','%s','')" % + (self.db.name,self.name), Class = "fs14") + + if self.confidential and not webqtlUtil.hasAccessToConfidentialPhenotypeTrait(privilege=privilege, userName=userName, authorized_users=authorized_users): + setDescription2.append('RecordID/%s - %s' % (self.name, self.pre_publication_description)) + else: + setDescription2.append('RecordID/%s - %s' % (self.name, self.post_publication_description)) + + #XZ 03/26/2011: Xiaodong comment out the following two lins as Rob asked. Need to check with Rob why in PublishXRef table, there are few row whose Sequence > 1. + #if self.sequence > 1: + # setDescription2.append(' btach %d' % self.sequence) + if self.authors: + a1 = string.split(self.authors,',')[0] + while a1[0] == '"' or a1[0] == "'" : + a1 = a1[1:] + setDescription2.append(' by ') + setDescription2.append(HT.Italic('%s, and colleagues' % a1)) + setDescription = HT.Span(PubMedLink, setDescription2) + + elif self.db.type == 'Temp': + setDescription = HT.Href(text="%s" % (self.description),url="javascript:showDatabase2\ + ('%s','%s','')" % (self.db.name,self.name), Class = "fs14") + setDescription = HT.Span(setDescription) + + elif self.db.type == 'Geno': # Genome DB only available for single search + if formName: + setDescription = HT.Href(text="Locus %s [Chr %s @ %s Mb]" % (self.name,self.chr,\ + '%2.3f' % self.mb),url="javascript:showDatabase3('%s','%s','%s','')" % \ + (formName, self.db.name, self.name), Class = "fs14") + else: + setDescription = HT.Href(text="Locus %s [Chr %s @ %s Mb]" % (self.name,self.chr,\ + '%2.3f' % self.mb),url="javascript:showDatabase2('%s','%s','')" % \ + (self.db.name,self.name), Class = "fs14") + + setDescription = HT.Span(setDescription) + + else: + if self.cellid: + if formName: + setDescription = HT.Href(text="ProbeSet/%s/%s" % (self.name, self.cellid),url=\ + "javascript:showDatabase3('%s','%s','%s','%s')" % (formName, self.db.name,self.name,self.cellid), \ + Class = "fs14") + else: + setDescription = HT.Href(text="ProbeSet/%s/%s" % (self.name,self.cellid),url=\ + "javascript:showDatabase2('%s','%s','%s')" % (self.db.name,self.name,self.cellid), \ + Class = "fs14") + else: + if formName: + setDescription = HT.Href(text="ProbeSet/%s" % self.name, url=\ + "javascript:showDatabase3('%s','%s','%s','')" % (formName, self.db.name,self.name), \ + Class = "fs14") + else: + setDescription = HT.Href(text="ProbeSet/%s" % self.name, url=\ + "javascript:showDatabase2('%s','%s','')" % (self.db.name,self.name), \ + Class = "fs14") + if self.symbol and self.chr and self.mb: + setDescription.append(' [') + setDescription.append(HT.Italic('%s' % self.symbol,Class="cdg fwb")) + setDescription.append(' on Chr %s @ %s Mb]' % (self.chr,self.mb)) + if self.description: + setDescription.append(': %s' % self.description) + if self.probe_target_description: + setDescription.append('; %s' % self.probe_target_description) + setDescription = HT.Span(setDescription) + + if self.db.type != 'Temp' and dispFromDatabase: + setDescription.append( ' --- FROM : ') + setDescription.append(self.db.genHTML(Class='cori')) + return setDescription + + -- cgit v1.2.3 From c1432f41d243047e767a4ec1dc423b9fd0055e0f Mon Sep 17 00:00:00 2001 From: Sam Ockman Date: Sun, 3 Jun 2012 04:08:15 -0400 Subject: Cleaning up trait stuff in flask --- wqflask/base/webqtlTrait.py | 228 ++++++++++++++------------ wqflask/wqflask/show_trait/show_trait_page.py | 42 +++-- 2 files changed, 145 insertions(+), 125 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/webqtlTrait.py b/wqflask/base/webqtlTrait.py index f5051e45..c3c0cded 100755 --- a/wqflask/base/webqtlTrait.py +++ b/wqflask/base/webqtlTrait.py @@ -1,3 +1,5 @@ +from __future__ import division, print_function + import string from htmlgen import HTMLgen2 as HT @@ -8,14 +10,18 @@ from webqtlDataset import webqtlDataset from dbFunction import webqtlDatabaseFunction from utility import webqtlUtil +from pprint import pformat as pf + class webqtlTrait: """ - Trait class defines a trait in webqtl, can be either Microarray, + Trait class defines a trait in webqtl, can be either Microarray, Published phenotype, genotype, or user input trait + """ def __init__(self, cursor = None, **kw): + print("in webqtlTrait") self.cursor = cursor self.db = None # database object self.name = '' # Trait ID, ProbeSet ID, Published ID, etc. @@ -25,6 +31,9 @@ class webqtlTrait: self.haveinfo = 0 self.sequence = '' # Blat sequence, available for ProbeSet self.data = {} + print("foo") + print("kw in webqtlTrait are:", pf(kw)) + print("printed\n\n") for name, value in kw.items(): if self.__dict__.has_key(name): setattr(self, name, value) @@ -35,28 +44,29 @@ class webqtlTrait: elif len(name2) == 3: self.db, self.name, self.cellid = name2 else: - raise KeyError, `value` + ' parameter format error.' + raise KeyError, repr(value) + ' parameter format error.' else: - raise KeyError, `name`+' not a valid parameter for this class.' - - if self.db and type(self.db) == type("1"): - assert self.cursor + raise KeyError, repr(name) + ' not a valid parameter for this class.' + + if self.db and isinstance(self.db, basestring): + assert self.cursor, "Don't have a cursor" self.db = webqtlDataset(self.db, self.cursor) #if self.db == None, not from a database + print("self.db is:", self.db, type(self.db)) if self.db: if self.db.type == "Temp": self.cursor.execute(''' - SELECT - InbredSet.Name - FROM - InbredSet, Temp - WHERE - Temp.InbredSetId = InbredSet.Id AND + SELECT + InbredSet.Name + FROM + InbredSet, Temp + WHERE + Temp.InbredSetId = InbredSet.Id AND Temp.Name = "%s" - ''' % self.name) + ''', self.name) self.riset = self.cursor.fetchone()[0] - else: + else: self.riset = self.db.getRISet() # @@ -73,8 +83,9 @@ class webqtlTrait: if self.db: if self.db.type == 'ProbeSet': + print("Doing ProbeSet Query") query = ''' - SELECT + SELECT ProbeSet.BlatSeq FROM ProbeSet, ProbeSetFreeze, ProbeSetXRef @@ -84,10 +95,11 @@ class webqtlTrait: ProbeSet.Name = "%s" and ProbeSetFreeze.Name = "%s" ''' % (self.name, self.db.name) + print("query is:", query) self.cursor.execute(query) self.sequence = self.cursor.fetchone()[0] - + def getName(self): str = "" if self.db and self.name: @@ -98,12 +110,12 @@ class webqtlTrait: str = self.description return str - # + # # when user enter a trait or GN generate a trait, user want show the name # not the name that generated by GN randomly, the two follow function are - # used to give the real name and the database. displayName() will show the - # database also, getGivenName() just show the name. - # For other trait, displayName() as same as getName(), getGivenName() as + # used to give the real name and the database. displayName() will show the + # database also, getGivenName() just show the name. + # For other trait, displayName() as same as getName(), getGivenName() as # same as self.name # # Hongqiang 11/29/07 @@ -137,10 +149,10 @@ class webqtlTrait: str += "::" + self.cellid else: str = self.description - + return str - + #def __str__(self): # #return "%s %s" % (self.getName(), self.riset) # return self.getName() @@ -166,7 +178,7 @@ class webqtlTrait: else: result.append(None) return result - + def exportInformative(self, incVar=0): """ export informative strain @@ -195,7 +207,7 @@ class webqtlTrait: assert self.cursor if self.db.type == 'ProbeSet': query = ''' - SELECT + SELECT ProbeSet.BlatSeq FROM ProbeSet, ProbeSetFreeze, ProbeSetXRef @@ -209,40 +221,40 @@ class webqtlTrait: results = self.fetchone() return results[0] - - - + + + def retrieveData(self, strainlist=[]): assert self.db and self.cursor if self.db.type == 'Temp': query = ''' - SELECT - Strain.Name, TempData.value, TempData.SE, TempData.NStrain, TempData.Id - FROM - TempData, Temp, Strain - WHERE - TempData.StrainId = Strain.Id AND - TempData.Id = Temp.DataId AND + SELECT + Strain.Name, TempData.value, TempData.SE, TempData.NStrain, TempData.Id + FROM + TempData, Temp, Strain + WHERE + TempData.StrainId = Strain.Id AND + TempData.Id = Temp.DataId AND Temp.name = '%s' Order BY Strain.Name ''' % self.name #XZ, 03/02/2009: Xiaodong changed Data to PublishData, SE to PublishSE - elif self.db.type == 'Publish': + elif self.db.type == 'Publish': query = ''' - SELECT - Strain.Name, PublishData.value, PublishSE.error, NStrain.count, PublishData.Id - FROM + SELECT + Strain.Name, PublishData.value, PublishSE.error, NStrain.count, PublishData.Id + FROM (PublishData, Strain, PublishXRef, PublishFreeze) - left join PublishSE on + left join PublishSE on (PublishSE.DataId = PublishData.Id AND PublishSE.StrainId = PublishData.StrainId) - left join NStrain on - (NStrain.DataId = PublishData.Id AND - NStrain.StrainId = PublishData.StrainId) - WHERE - PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND - PublishData.Id = PublishXRef.DataId AND PublishXRef.Id = %s AND + left join NStrain on + (NStrain.DataId = PublishData.Id AND + NStrain.StrainId = PublishData.StrainId) + WHERE + PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND + PublishData.Id = PublishXRef.DataId AND PublishXRef.Id = %s AND PublishFreeze.Id = %d AND PublishData.StrainId = Strain.Id Order BY Strain.Name @@ -252,21 +264,21 @@ class webqtlTrait: elif self.cellid: #Probe Data query = ''' - SELECT - Strain.Name, ProbeData.value, ProbeSE.error, ProbeData.Id - FROM - (ProbeData, ProbeFreeze, ProbeSetFreeze, ProbeXRef, + SELECT + Strain.Name, ProbeData.value, ProbeSE.error, ProbeData.Id + FROM + (ProbeData, ProbeFreeze, ProbeSetFreeze, ProbeXRef, Strain, Probe, ProbeSet) - left join ProbeSE on + left join ProbeSE on (ProbeSE.DataId = ProbeData.Id AND ProbeSE.StrainId = ProbeData.StrainId) - WHERE - Probe.Name = '%s' AND ProbeSet.Name = '%s' AND - Probe.ProbeSetId = ProbeSet.Id AND - ProbeXRef.ProbeId = Probe.Id AND - ProbeXRef.ProbeFreezeId = ProbeFreeze.Id AND - ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id AND - ProbeSetFreeze.Name = '%s' AND - ProbeXRef.DataId = ProbeData.Id AND + WHERE + Probe.Name = '%s' AND ProbeSet.Name = '%s' AND + Probe.ProbeSetId = ProbeSet.Id AND + ProbeXRef.ProbeId = Probe.Id AND + ProbeXRef.ProbeFreezeId = ProbeFreeze.Id AND + ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id AND + ProbeSetFreeze.Name = '%s' AND + ProbeXRef.DataId = ProbeData.Id AND ProbeData.StrainId = Strain.Id Order BY Strain.Name @@ -295,23 +307,23 @@ class webqtlTrait: #Geno Data #XZ: The SpeciesId is not necessary, but it's nice to keep it to speed up database search. query = ''' - SELECT - Strain.Name, GenoData.value, GenoSE.error, GenoData.Id - FROM + SELECT + Strain.Name, GenoData.value, GenoSE.error, GenoData.Id + FROM (GenoData, GenoFreeze, Strain, Geno, GenoXRef) left join GenoSE on (GenoSE.DataId = GenoData.Id AND GenoSE.StrainId = GenoData.StrainId) - WHERE + WHERE Geno.SpeciesId = %s AND Geno.Name = '%s' AND GenoXRef.GenoId = Geno.Id AND - GenoXRef.GenoFreezeId = GenoFreeze.Id AND - GenoFreeze.Name = '%s' AND - GenoXRef.DataId = GenoData.Id AND + GenoXRef.GenoFreezeId = GenoFreeze.Id AND + GenoFreeze.Name = '%s' AND + GenoXRef.DataId = GenoData.Id AND GenoData.StrainId = Strain.Id Order BY Strain.Name ''' % (webqtlDatabaseFunction.retrieveSpeciesId(self.cursor, self.db.riset), self.name, self.db.name) - + self.cursor.execute(query) results = self.cursor.fetchall() self.data.clear() @@ -328,7 +340,7 @@ class webqtlTrait: ndata = item[3] self.data[item[0]] = webqtlCaseData(val, var, ndata) #end for - else: + else: for item in results: val = item[1] if val != None: @@ -341,16 +353,16 @@ class webqtlTrait: #end if else: pass - + def keys(self): return self.__dict__.keys() - + def has_key(self, key): return self.__dict__.has_key(key) - + def items(self): return self.__dict__.items() - + def retrieveInfo(self, QTL = None): assert self.db and self.cursor if self.db.type == 'Publish': @@ -358,22 +370,22 @@ class webqtlTrait: # 'Abstract', 'Journal','Volume','Pages','Month','Year','Sequence',\ # 'Units', 'comments'] query = ''' - SELECT - PublishXRef.Id, Publication.PubMed_ID, - Phenotype.Pre_publication_description, Phenotype.Post_publication_description, Phenotype.Original_description, - Phenotype.Pre_publication_abbreviation, Phenotype.Post_publication_abbreviation, + SELECT + PublishXRef.Id, Publication.PubMed_ID, + Phenotype.Pre_publication_description, Phenotype.Post_publication_description, Phenotype.Original_description, + Phenotype.Pre_publication_abbreviation, Phenotype.Post_publication_abbreviation, Phenotype.Lab_code, Phenotype.Submitter, Phenotype.Owner, Phenotype.Authorized_Users, - Publication.Authors, Publication.Title, Publication.Abstract, - Publication.Journal, Publication.Volume, Publication.Pages, - Publication.Month, Publication.Year, PublishXRef.Sequence, - Phenotype.Units, PublishXRef.comments - FROM - PublishXRef, Publication, Phenotype, PublishFreeze - WHERE - PublishXRef.Id = %s AND - Phenotype.Id = PublishXRef.PhenotypeId AND - Publication.Id = PublishXRef.PublicationId AND - PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND + Publication.Authors, Publication.Title, Publication.Abstract, + Publication.Journal, Publication.Volume, Publication.Pages, + Publication.Month, Publication.Year, PublishXRef.Sequence, + Phenotype.Units, PublishXRef.comments + FROM + PublishXRef, Publication, Phenotype, PublishFreeze + WHERE + PublishXRef.Id = %s AND + Phenotype.Id = PublishXRef.PhenotypeId AND + Publication.Id = PublishXRef.PublicationId AND + PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND PublishFreeze.Id =%s ''' % (self.name, self.db.id) #XZ, 05/08/2009: Xiaodong add this block to use ProbeSet.Id to find the probeset instead of just using ProbeSet.Name @@ -382,7 +394,7 @@ class webqtlTrait: disfieldString = string.join(self.db.disfield,',ProbeSet.') disfieldString = 'ProbeSet.' + disfieldString query = """ - SELECT %s + SELECT %s FROM ProbeSet, ProbeSetFreeze, ProbeSetXRef WHERE ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id AND @@ -396,7 +408,7 @@ class webqtlTrait: disfieldString = string.join(self.db.disfield,',Geno.') disfieldString = 'Geno.' + disfieldString query = """ - SELECT %s + SELECT %s FROM Geno, GenoFreeze, GenoXRef WHERE GenoXRef.GenoFreezeId = GenoFreeze.Id AND @@ -408,7 +420,7 @@ class webqtlTrait: query = 'SELECT %s FROM %s WHERE Name = "%s"' % \ (string.join(self.db.disfield,','), self.db.type, self.name) - + self.cursor.execute(query) traitInfo = self.cursor.fetchone() if traitInfo: @@ -457,12 +469,12 @@ class webqtlTrait: if QTL: if self.db.type == 'ProbeSet' and not self.cellid: query = ''' - SELECT - ProbeSetXRef.Locus, ProbeSetXRef.LRS, ProbeSetXRef.pValue, ProbeSetXRef.mean - FROM + SELECT + ProbeSetXRef.Locus, ProbeSetXRef.LRS, ProbeSetXRef.pValue, ProbeSetXRef.mean + FROM ProbeSetXRef, ProbeSet - WHERE - ProbeSetXRef.ProbeSetId = ProbeSet.Id AND + WHERE + ProbeSetXRef.ProbeSetId = ProbeSet.Id AND ProbeSet.Name = "%s" AND ProbeSetXRef.ProbeSetFreezeId =%s ''' % (self.name, self.db.id) @@ -491,11 +503,11 @@ class webqtlTrait: self.locus = self.lrs = "" else: raise KeyError, `self.name`+' information is not found in the database.' - + def genHTML(self, formName = "", dispFromDatabase=0, privilege="guest", userName="Guest", authorized_users=""): if not self.haveinfo: self.retrieveInfo() - + if self.db.type == 'Publish': PubMedLink = "" if self.pubmed_id: @@ -503,14 +515,14 @@ class webqtlTrait: target = "_blank", url = webqtlConfig.PUBMEDLINK_URL % self.pubmed_id) else: PubMedLink = HT.Span("Unpublished : ", Class="fs15") - + if formName: - setDescription2 = HT.Href(url="javascript:showDatabase3('%s','%s','%s','')" % + setDescription2 = HT.Href(url="javascript:showDatabase3('%s','%s','%s','')" % (formName, self.db.name, self.name), Class = "fs14") else: - setDescription2 = HT.Href(url="javascript:showDatabase2('%s','%s','')" % + setDescription2 = HT.Href(url="javascript:showDatabase2('%s','%s','')" % (self.db.name,self.name), Class = "fs14") - + if self.confidential and not webqtlUtil.hasAccessToConfidentialPhenotypeTrait(privilege=privilege, userName=userName, authorized_users=authorized_users): setDescription2.append('RecordID/%s - %s' % (self.name, self.pre_publication_description)) else: @@ -526,12 +538,12 @@ class webqtlTrait: setDescription2.append(' by ') setDescription2.append(HT.Italic('%s, and colleagues' % a1)) setDescription = HT.Span(PubMedLink, setDescription2) - + elif self.db.type == 'Temp': setDescription = HT.Href(text="%s" % (self.description),url="javascript:showDatabase2\ ('%s','%s','')" % (self.db.name,self.name), Class = "fs14") setDescription = HT.Span(setDescription) - + elif self.db.type == 'Geno': # Genome DB only available for single search if formName: setDescription = HT.Href(text="Locus %s [Chr %s @ %s Mb]" % (self.name,self.chr,\ @@ -541,16 +553,16 @@ class webqtlTrait: setDescription = HT.Href(text="Locus %s [Chr %s @ %s Mb]" % (self.name,self.chr,\ '%2.3f' % self.mb),url="javascript:showDatabase2('%s','%s','')" % \ (self.db.name,self.name), Class = "fs14") - + setDescription = HT.Span(setDescription) - + else: if self.cellid: - if formName: + if formName: setDescription = HT.Href(text="ProbeSet/%s/%s" % (self.name, self.cellid),url=\ "javascript:showDatabase3('%s','%s','%s','%s')" % (formName, self.db.name,self.name,self.cellid), \ Class = "fs14") - else: + else: setDescription = HT.Href(text="ProbeSet/%s/%s" % (self.name,self.cellid),url=\ "javascript:showDatabase2('%s','%s','%s')" % (self.db.name,self.name,self.cellid), \ Class = "fs14") @@ -572,10 +584,8 @@ class webqtlTrait: if self.probe_target_description: setDescription.append('; %s' % self.probe_target_description) setDescription = HT.Span(setDescription) - + if self.db.type != 'Temp' and dispFromDatabase: setDescription.append( ' --- FROM : ') setDescription.append(self.db.genHTML(Class='cori')) return setDescription - - diff --git a/wqflask/wqflask/show_trait/show_trait_page.py b/wqflask/wqflask/show_trait/show_trait_page.py index 03f8b9b3..c7d6618e 100644 --- a/wqflask/wqflask/show_trait/show_trait_page.py +++ b/wqflask/wqflask/show_trait/show_trait_page.py @@ -36,29 +36,39 @@ from DataEditingPage import DataEditingPage class ShowTraitPage(DataEditingPage): - def __init__(self, fd, traitInfos = []): + def __init__(self, fd, traitInfos = None): - templatePage.__init__(self, fd) + #templatePage.__init__(self, fd) if not self.openMysql(): return - TD_LR = HT.TD(height=200,width="100%",bgColor='#eeeeee') - + #TD_LR = HT.TD(height=200,width="100%",bgColor='#eeeeee') + print("j2") + # When is traitInfos used? if traitInfos: - database,ProbeSetID,CellID = traitInfos + print("j2.2") + database, ProbeSetID, CellID = traitInfos else: - database = fd.formdata.getfirst('database') - ProbeSetID = fd.formdata.getfirst('ProbeSetID') - CellID = fd.formdata.getfirst('CellID') - try: - thisTrait = webqtlTrait(db=database, name=ProbeSetID, cellid= CellID, cursor=self.cursor) - except: - heading = "Trait Data and Analysis Form" - detail = ["The trait isn't available currently."] - self.error(heading=heading,detail=detail,error="Error") - return - + print("j2.3") + print("fd is:", fd) + database = fd['database'] + ProbeSetID = fd['ProbeSetID'] + print("j2.4") + CellID = fd.get('CellID') + print("j2.6") + + # We're no longer wrapping this in an exception. If we fail, let's fail hard + # Log it and fix it + #try: + print("j3") + thisTrait = webqtlTrait(db=database, name=ProbeSetID, cellid= CellID, cursor=self.cursor) + #except: + # heading = "Trait Data and Analysis Form" + # detail = ["The trait isn't available currently."] + # self.error(heading=heading,detail=detail,error="Error") + # return + print("j4") if thisTrait.db.type == "ProbeSet": self.cursor.execute('''SELECT Id, Name, FullName, confidentiality, AuthorisedUsers -- cgit v1.2.3 From 3d6be932e5185e4dd7170b3ea740591de01341a0 Mon Sep 17 00:00:00 2001 From: Sam Ockman Date: Sun, 3 Jun 2012 05:47:07 -0400 Subject: Before changing fd for trait analysis into a webQTLFormData object --- wqflask/base/webqtlTrait.py | 17 +++++++++-------- wqflask/wqflask/show_trait/show_trait_page.py | 21 +++++++++++++++------ 2 files changed, 24 insertions(+), 14 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/webqtlTrait.py b/wqflask/base/webqtlTrait.py index c3c0cded..88226894 100755 --- a/wqflask/base/webqtlTrait.py +++ b/wqflask/base/webqtlTrait.py @@ -92,12 +92,13 @@ class webqtlTrait: WHERE ProbeSet.Id=ProbeSetXRef.ProbeSetId and ProbeSetFreeze.Id = ProbeSetXRef.ProbeSetFreezeId and - ProbeSet.Name = "%s" and - ProbeSetFreeze.Name = "%s" - ''' % (self.name, self.db.name) + ProbeSet.Name = %s and + ProbeSetFreeze.Name = %s + ''', (self.name, self.db.name) print("query is:", query) - self.cursor.execute(query) + self.cursor.execute(*query) self.sequence = self.cursor.fetchone()[0] + print("self.sequence is:", self.sequence) def getName(self): @@ -124,7 +125,7 @@ class webqtlTrait: str = self.name if self.db and self.name: if self.db.type=='Temp': - self.cursor.execute('SELECT description FROM Temp WHERE Name=%s',self.name) + self.cursor.execute('SELECT description FROM Temp WHERE Name=%s', self.name) desc = self.cursor.fetchone()[0] if desc.__contains__('PCA'): desc = desc[desc.rindex(':')+1:].strip() @@ -206,7 +207,7 @@ class webqtlTrait: def getSequence(self): assert self.cursor if self.db.type == 'ProbeSet': - query = ''' + self.cursor.execute(''' SELECT ProbeSet.BlatSeq FROM @@ -216,8 +217,8 @@ class webqtlTrait: ProbeSetFreeze.Id = ProbeSetXRef.ProbSetFreezeId and ProbeSet.Name = %s ProbeSetFreeze.Name = %s - ''' , (self.name, self.db.name) - self.cursor.execute(query) + ''', self.name, self.db.name) + #self.cursor.execute(query) results = self.fetchone() return results[0] diff --git a/wqflask/wqflask/show_trait/show_trait_page.py b/wqflask/wqflask/show_trait/show_trait_page.py index c7d6618e..a34c20cf 100644 --- a/wqflask/wqflask/show_trait/show_trait_page.py +++ b/wqflask/wqflask/show_trait/show_trait_page.py @@ -24,6 +24,10 @@ # # Last updated by GeneNetwork Core Team 2010/10/20 +from __future__ import division, print_function + +from flask import request + from htmlgen import HTMLgen2 as HT from base import webqtlConfig @@ -96,8 +100,12 @@ class ShowTraitPage(DataEditingPage): at this time, please go back and select other database." % indFullName] self.error(heading=heading,detail=detail,error="Confidential Database") return + print("environ:", request.environ) - user_ip = fd.remote_ip + # Becuase of proxying remote_addr is probably localhost, so we first try for + # HTTP_X_FORWARDED_FOR + user_ip = request.environ.get('HTTP_X_FORWARDED_FOR') or request.remote_addr # in old app was fd.remote_ip + print("user_ip is:", user_ip) query = "SELECT count(id) FROM AccessLog WHERE ip_address = %s and \ UNIX_TIMESTAMP()-UNIX_TIMESTAMP(accesstime)<86400" self.cursor.execute(query,user_ip) @@ -143,9 +151,9 @@ class ShowTraitPage(DataEditingPage): """ ##identification, etc. - fd.identification = '%s : %s'%(thisTrait.db.shortname,ProbeSetID) + fd.identification = '%s : %s' % (thisTrait.db.shortname,ProbeSetID) thisTrait.returnURL = webqtlConfig.CGIDIR + webqtlConfig.SCRIPTFILE + '?FormID=showDatabase&database=%s\ - &ProbeSetID=%s&RISet=%s&parentsf1=on' %(database,ProbeSetID,fd.RISet) + &ProbeSetID=%s&RISet=%s&parentsf1=on' %(database, ProbeSetID, fd['RISet']) if CellID: fd.identification = '%s/%s'%(fd.identification, CellID) @@ -156,12 +164,13 @@ class ShowTraitPage(DataEditingPage): thisTrait.retrieveInfo() thisTrait.retrieveData() self.updMysql() - self.cursor.execute("insert into AccessLog(accesstime,ip_address) values(Now(),%s)" ,user_ip) + self.cursor.execute("insert into AccessLog(accesstime,ip_address) values(Now(),%s)", user_ip) self.openMysql() - except: + except Exception as why: + print("Got an exception:", why) heading = "Retrieve Data" detail = ["The information you requested is not avaiable at this time."] - self.error(heading=heading,detail=detail) + self.error(heading=heading, detail=detail) return ##read genotype file -- cgit v1.2.3 From b2240d137c4d81110994bc8e2e9004bd7a01fe5b Mon Sep 17 00:00:00 2001 From: Sam Ockman Date: Sun, 3 Jun 2012 06:20:36 -0400 Subject: Now using modified webqtlformdata for trait analysis --- wqflask/base/webqtlFormData.py | 119 ++++++++++++++------------ wqflask/wqflask/show_trait/show_trait_page.py | 4 +- wqflask/wqflask/views.py | 6 +- 3 files changed, 72 insertions(+), 57 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/webqtlFormData.py b/wqflask/base/webqtlFormData.py index 84e41cae..c94dbe53 100755 --- a/wqflask/base/webqtlFormData.py +++ b/wqflask/base/webqtlFormData.py @@ -24,7 +24,7 @@ # # Last updated by GeneNetwork Core Team 2010/10/20 -from mod_python import Cookie +#from mod_python import Cookie import string import os @@ -47,7 +47,9 @@ class webqtlFormData: #XZ: Attention! All attribute values must be picklable! - def __init__(self, req = None, mod_python_session=None, FieldStorage_formdata=None): + def __init__(self, start_vars = None, req = None, mod_python_session=None, FieldStorage_formdata=None): + + self.__dict__.update(start_vars) for item in self.attrs: setattr(self,item, None) @@ -62,34 +64,35 @@ class webqtlFormData: else: self.refURL = None + # For now let's just comment all this out - Sam - self.cookies = cookieData.cookieData(Cookie.get_cookies(req)) #XZ: dictionary type. To hold values transfered from mod_python Cookie. - - #XZ: dictionary type. To hold values transfered from mod_python Session object. We assume that it is always picklable. - self.input_session_data = sessionData.sessionData( mod_python_session ) - - #XZ: FieldStorage_formdata may contain item that can't be pickled. Must convert to picklable data. - self.formdata = cgiData( FieldStorage_formdata ) - - #get Form ID - self.formID = self.formdata.getfirst('FormID') + #self.cookies = cookieData.cookieData(Cookie.get_cookies(req)) #XZ: dictionary type. To hold values transfered from mod_python Cookie. + # + ##XZ: dictionary type. To hold values transfered from mod_python Session object. We assume that it is always picklable. + #self.input_session_data = sessionData.sessionData( mod_python_session ) + # + ##XZ: FieldStorage_formdata may contain item that can't be pickled. Must convert to picklable data. + #self.formdata = cgiData( FieldStorage_formdata ) + # + ##get Form ID + #self.formID = self.formdata.getfirst('FormID') + # + ##get rest of the attributes + #if self.formID: + # for item in self.attrs: + # value = self.formdata.getfirst(item) + # if value != None: + # setattr(self,item,string.strip(value)) - #get rest of the attributes - if self.formID: - for item in self.attrs: - value = self.formdata.getfirst(item) - if value != None: - setattr(self,item,string.strip(value)) - self.ppolar = "" self.mpolar = "" if self.RISet: try: - # NL, 07/27/2010. ParInfo has been moved from webqtlForm.py to webqtlUtil.py; + # NL, 07/27/2010. ParInfo has been moved from webqtlForm.py to webqtlUtil.py; f1, f12, self.mpolar, self.ppolar = webqtlUtil.ParInfo[self.RISet] except: f1 = f12 = self.mpolar = self.ppolar = None - + try: self.nperm = int(self.nperm) self.nboot = int(self.nboot) @@ -101,12 +104,21 @@ class webqtlFormData: self.allstrainlist = map(string.strip, string.split(self.allstrainlist)) #self.readGenotype() #self.readData() - + if self.RISet == 'BXD300': self.RISet = 'BXD' else: pass - + + def __getitem__(self, key): + return self.__dict__[key] + + def get(self, key, default=None): + if key in self.__dict__: + return self.__dict__[key] + else: + return default + def __str__(self): rstr = '' for item in self.attrs: @@ -114,7 +126,7 @@ class webqtlFormData: rstr += '%s:%s\n' % (item,str(getattr(self,item))) return rstr - + def readGenotype(self): 'read genotype from .geno file' if self.RISet == 'BXD300': @@ -127,15 +139,15 @@ class webqtlFormData: self.genotype_1 = reaper.Dataset() self.genotype_1.read(os.path.join(webqtlConfig.GENODIR, self.RISet + '.geno')) try: - # NL, 07/27/2010. ParInfo has been moved from webqtlForm.py to webqtlUtil.py; + # NL, 07/27/2010. ParInfo has been moved from webqtlForm.py to webqtlUtil.py; _f1, _f12, _mat, _pat = webqtlUtil.ParInfo[self.RISet] except: _f1 = _f12 = _mat = _pat = None - + self.genotype_2 =self.genotype_1 if self.genotype_1.type == "riset" and _mat and _pat: self.genotype_2 = self.genotype_1.add(Mat=_mat, Pat=_pat) #, F1=_f1) - + #determine default genotype object if self.incparentsf1 and self.genotype_1.type != "intercross": self.genotype = self.genotype_2 @@ -148,7 +160,7 @@ class webqtlFormData: self.f1list = [_f1, _f12] if _mat and _pat: self.parlist = [_mat, _pat] - + def readData(self, strainlst=[], incf1=[]): 'read user input data or from trait data and analysis form' @@ -158,16 +170,16 @@ class webqtlFormData: if incf1: strainlst = self.f1list + self.strainlist else: - strainlst = self.strainlist - - + strainlst = self.strainlist + + traitfiledata = self.formdata.getfirst('traitfile') traitpastedata = self.formdata.getfirst('traitpaste') variancefiledata = self.formdata.getfirst('variancefile') variancepastedata = self.formdata.getfirst('variancepaste') Nfiledata = self.formdata.getfirst('Nfile') - + if traitfiledata: tt = string.split(traitfiledata) vals = map(webqtlUtil.StringAsFloat, tt) @@ -183,8 +195,8 @@ class webqtlFormData: vals = vals[:len(strainlst)] else: pass - - + + if variancefiledata: tt = string.split(variancefiledata) vars = map(webqtlUtil.StringAsFloat, tt) @@ -200,7 +212,7 @@ class webqtlFormData: vars = vars[:len(strainlst)] else: pass - + if Nfiledata: tt = string.split(Nfiledata) nstrains = map(webqtlUtil.IntAsFloat, tt) @@ -208,14 +220,14 @@ class webqtlFormData: nstrains += [None]*(len(strainlst) - len(nstrains)) else: nstrains = map(self.FormNAsFloat, strainlst) - + ##vals, vars, nstrains is obsolete self.allTraitData = {} for i, _strain in enumerate(strainlst): if vals[i] != None: self.allTraitData[_strain] = webqtlCaseData(vals[i], vars[i], nstrains[i]) - + def informativeStrains(self, strainlst=[], incVars = 0): '''if readData was called, use this to output the informative strains @@ -241,26 +253,26 @@ class webqtlFormData: return strains, vals, vars, len(strains) - + def FormDataAsFloat(self, key): try: return float(self.formdata.getfirst(key)) except: return None - + def FormVarianceAsFloat(self, key): try: return float(self.formdata.getfirst('V' + key)) except: return None - + def FormNAsFloat(self, key): try: return int(self.formdata.getfirst('N' + key)) except: return None - + def Sample(self): 'Create some dummy data for testing' self.RISet = 'BXD' @@ -273,17 +285,16 @@ class webqtlFormData: #self.genotype.ReadMM('AXBXAforQTL') #self.strainlist = map((lambda x, y='': '%s%s' % (y,x)), self.genotype.prgy) #self.strainlist.sort() - self.allTraitData = {'BXD29': webqtlCaseData(3), 'BXD28': webqtlCaseData(2), - 'BXD25': webqtlCaseData(2), 'BXD24': webqtlCaseData(2), 'BXD27': webqtlCaseData(2), - 'BXD21': webqtlCaseData(1), 'BXD20': webqtlCaseData(4), 'BXD23': webqtlCaseData(4), - 'BXD22': webqtlCaseData(3), 'BXD14': webqtlCaseData(4), 'BXD15': webqtlCaseData(2), - 'BXD16': webqtlCaseData(3), 'BXD11': webqtlCaseData(4), 'BXD12': webqtlCaseData(3), - 'BXD13': webqtlCaseData(2), 'BXD18': webqtlCaseData(3), 'BXD19': webqtlCaseData(3), - 'BXD38': webqtlCaseData(3), 'BXD39': webqtlCaseData(3), 'BXD36': webqtlCaseData(2), - 'BXD34': webqtlCaseData(4), 'BXD35': webqtlCaseData(4), 'BXD32': webqtlCaseData(4), - 'BXD33': webqtlCaseData(3), 'BXD30': webqtlCaseData(1), 'BXD31': webqtlCaseData(4), - 'DBA/2J': webqtlCaseData(1), 'BXD8': webqtlCaseData(3), 'BXD9': webqtlCaseData(1), - 'BXD6': webqtlCaseData(3), 'BXD5': webqtlCaseData(3), 'BXD2': webqtlCaseData(4), - 'BXD1': webqtlCaseData(1), 'C57BL/6J': webqtlCaseData(4), 'B6D2F1': webqtlCaseData(4), + self.allTraitData = {'BXD29': webqtlCaseData(3), 'BXD28': webqtlCaseData(2), + 'BXD25': webqtlCaseData(2), 'BXD24': webqtlCaseData(2), 'BXD27': webqtlCaseData(2), + 'BXD21': webqtlCaseData(1), 'BXD20': webqtlCaseData(4), 'BXD23': webqtlCaseData(4), + 'BXD22': webqtlCaseData(3), 'BXD14': webqtlCaseData(4), 'BXD15': webqtlCaseData(2), + 'BXD16': webqtlCaseData(3), 'BXD11': webqtlCaseData(4), 'BXD12': webqtlCaseData(3), + 'BXD13': webqtlCaseData(2), 'BXD18': webqtlCaseData(3), 'BXD19': webqtlCaseData(3), + 'BXD38': webqtlCaseData(3), 'BXD39': webqtlCaseData(3), 'BXD36': webqtlCaseData(2), + 'BXD34': webqtlCaseData(4), 'BXD35': webqtlCaseData(4), 'BXD32': webqtlCaseData(4), + 'BXD33': webqtlCaseData(3), 'BXD30': webqtlCaseData(1), 'BXD31': webqtlCaseData(4), + 'DBA/2J': webqtlCaseData(1), 'BXD8': webqtlCaseData(3), 'BXD9': webqtlCaseData(1), + 'BXD6': webqtlCaseData(3), 'BXD5': webqtlCaseData(3), 'BXD2': webqtlCaseData(4), + 'BXD1': webqtlCaseData(1), 'C57BL/6J': webqtlCaseData(4), 'B6D2F1': webqtlCaseData(4), 'BXD42': webqtlCaseData(4), 'BXD40': webqtlCaseData(3)} - diff --git a/wqflask/wqflask/show_trait/show_trait_page.py b/wqflask/wqflask/show_trait/show_trait_page.py index a34c20cf..d4019fd5 100644 --- a/wqflask/wqflask/show_trait/show_trait_page.py +++ b/wqflask/wqflask/show_trait/show_trait_page.py @@ -56,8 +56,8 @@ class ShowTraitPage(DataEditingPage): else: print("j2.3") print("fd is:", fd) - database = fd['database'] - ProbeSetID = fd['ProbeSetID'] + database = fd['database'][0] + ProbeSetID = fd['ProbeSetID'][0] print("j2.4") CellID = fd.get('CellID') print("j2.6") diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 611cc05b..3457f0ff 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -7,6 +7,8 @@ from flask import render_template, request from wqflask import search_results from wqflask.show_trait import show_trait_page +from base import webqtlFormData + from pprint import pformat as pf @app.route("/") @@ -21,5 +23,7 @@ def search(): @app.route("/showDatabaseBXD") def showDatabaseBXD(): - template_vars = show_trait_page.ShowTraitPage(request.args) + # 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) return render_template("trait_data_and_analysis.html") -- cgit v1.2.3 From cad0bdf26b325c7d5fa1757e44db8721a9d86cca Mon Sep 17 00:00:00 2001 From: Sam Ockman Date: Mon, 4 Jun 2012 22:45:24 -0400 Subject: Checkpoint along modifying for data trait and analysis --- wqflask/base/templatePage.py | 44 ++++++++-------- wqflask/wqflask/show_trait/DataEditingPage.py | 73 ++++++++++++++++++--------- wqflask/wqflask/show_trait/show_trait_page.py | 4 +- 3 files changed, 74 insertions(+), 47 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/templatePage.py b/wqflask/base/templatePage.py index 4dece24a..821c6181 100755 --- a/wqflask/base/templatePage.py +++ b/wqflask/base/templatePage.py @@ -70,13 +70,13 @@ class templatePage: self.starttime = time.time() self.dict = {} self.template = template - + for item in self.contents: self.dict[item] = "" - + self.dict['basehref'] = "" #webqtlConfig.BASEHREF self.cursor = None - + self.cookie = [] #XZ: list to hold cookies (myCookie object) being changed self.content_type = 'text/html' self.content_disposition = '' @@ -89,11 +89,13 @@ class templatePage: self.userName = 'Guest' self.privilege = 'guest' - if fd.input_session_data.has_key('user'): - self.userName = fd.input_session_data['user'] - if fd.input_session_data.has_key('privilege'): - self.privilege = fd.input_session_data['privilege'] - + + # Commenting this out for flask - we'll have to reimplement later - Sam + #if fd.input_session_data.has_key('user'): + # self.userName = fd.input_session_data['user'] + #if fd.input_session_data.has_key('privilege'): + # self.privilege = fd.input_session_data['privilege'] + def __str__(self): #XZ: default setting @@ -126,20 +128,20 @@ class templatePage: def __del__(self): if self.cursor: self.cursor.close() - + def write(self): 'return string representation of this object' if self.cursor: self.cursor.close() - return str(self) - + return str(self) + def writeFile(self, filename): 'save string representation of this object into a file' if self.cursor: self.cursor.close() - + try: 'it could take a long time to generate the file, save to .tmp first' fp = open(os.path.join(webqtlConfig.TMPDIR, filename+'.tmp'), 'wb') @@ -147,9 +149,9 @@ class templatePage: fp.close() path_tmp = os.path.join(webqtlConfig.TMPDIR, filename+'.tmp') path_html = os.path.join(webqtlConfig.TMPDIR, filename) - shutil.move(path_tmp,path_html) + shutil.move(path_tmp,path_html) except: - pass + pass def openMysql(self): try: @@ -176,12 +178,12 @@ class templatePage: The server may be down at this time "] self.error(heading=heading,detail=detail,error="Error 2003") return 0 - + def error(self,heading="",intro=[],detail=[],title="Error",error="Error"): 'generating a WebQTL style error page' Heading = HT.Paragraph(heading) Heading.__setattr__("class","title") - + Intro = HT.Blockquote() if intro: for item in intro: @@ -190,7 +192,7 @@ class templatePage: Intro.append(HT.Strong('Sorry!'),' Error occurred while processing\ your request.', HT.P(),'The nature of the error generated is as\ follows:') - + Detail = HT.Blockquote() Detail.append(HT.Span("%s : " % error,Class="fwb cr")) if detail: @@ -198,7 +200,7 @@ class templatePage: for item in detail: Detail2.append(item) Detail.append(HT.Italic(Detail2)) - + #Detail.__setattr__("class","subtitle") TD_LR = HT.TD(height=200,width="100%",bgColor='#eeeeee',valign="top") TD_LR.append(Heading,Intro,Detail) @@ -210,13 +212,11 @@ class templatePage: self.filename = webqtlUtil.generate_session() self.dict['title'] = mytitle self.dict['basehref'] = webqtlConfig.REFRESHSTR % (webqtlConfig.CGIDIR, self.filename) + "" #webqtlConfig.BASEHREF - + TD_LR = HT.TD(align="center", valign="middle", height=200,width="100%", bgColor='#eeeeee') Heading = HT.Paragraph(myHeading, Class="fwb fs16 cr") - # NL, 07/27/2010. variable 'PROGRESSBAR' has been moved from templatePage.py to webqtlUtil.py; + # NL, 07/27/2010. variable 'PROGRESSBAR' has been moved from templatePage.py to webqtlUtil.py; TD_LR.append(Heading, HT.BR(), webqtlUtil.PROGRESSBAR) self.dict['body'] = TD_LR self.writeFile(self.filename + '.html') return self.filename - - diff --git a/wqflask/wqflask/show_trait/DataEditingPage.py b/wqflask/wqflask/show_trait/DataEditingPage.py index c2e1c37f..1186fa03 100755 --- a/wqflask/wqflask/show_trait/DataEditingPage.py +++ b/wqflask/wqflask/show_trait/DataEditingPage.py @@ -52,35 +52,62 @@ class DataEditingPage(templatePage): ## titles, etc. ############################# - titleTop = HT.Div() - - title1 = HT.Paragraph("  Details and Links", style="border-radius: 5px;", Id="title1", Class="sectionheader") - title1Body = HT.Paragraph(Id="sectionbody1") - - if fd.enablevariance and not varianceDataPage: - title2 = HT.Paragraph("  Submit Variance", style="border-radius: 5px;", Id="title2", Class="sectionheader") - else: - title2 = HT.Paragraph("  Basic Statistics", style="border-radius: 5px;", Id="title2", Class="sectionheader") - title2Body = HT.Paragraph(Id="sectionbody2") - - title3 = HT.Paragraph("  Calculate Correlations", style="border-radius: 5px;", Id="title3", Class="sectionheader") - title3Body = HT.Paragraph(Id="sectionbody3") - - title4 = HT.Paragraph("  Mapping Tools", style="border-radius: 5px;", Id="title4", Class="sectionheader") - title4Body = HT.Paragraph(Id="sectionbody4") - - title5 = HT.Paragraph("  Review and Edit Data", style="border-radius: 5px;", Id="title5", Class="sectionheader") - title5Body = HT.Paragraph(Id="sectionbody5") + #titleTop = HT.Div() + # + #title1 = HT.Paragraph("  Details and Links", style="border-radius: 5px;", Id="title1", Class="sectionheader") + #title1Body = HT.Paragraph(Id="sectionbody1") + # + #if fd.enablevariance and not varianceDataPage: + # title2 = HT.Paragraph("  Submit Variance", style="border-radius: 5px;", Id="title2", Class="sectionheader") + #else: + # title2 = HT.Paragraph("  Basic Statistics", style="border-radius: 5px;", Id="title2", Class="sectionheader") + #title2Body = HT.Paragraph(Id="sectionbody2") + # + #title3 = HT.Paragraph("  Calculate Correlations", style="border-radius: 5px;", Id="title3", Class="sectionheader") + #title3Body = HT.Paragraph(Id="sectionbody3") + # + #title4 = HT.Paragraph("  Mapping Tools", style="border-radius: 5px;", Id="title4", Class="sectionheader") + #title4Body = HT.Paragraph(Id="sectionbody4") + # + #title5 = HT.Paragraph("  Review and Edit Data", style="border-radius: 5px;", Id="title5", Class="sectionheader") + #title5Body = HT.Paragraph(Id="sectionbody5") ############################# ## Hidden field ############################# # Some fields, like method, are defaulted to None; otherwise in IE the field can't be changed using jquery - hddn = {'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, 'strainNames':'_', 'strainVals':'_',\ - 'strainVars':'_', 'otherStrainNames':'_', 'otherStrainVals':'_', 'otherStrainVars':'_', 'extra_attributes':'_', 'other_extra_attributes':'_'} + hddn = { + '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, + 'strainNames':'_', + 'strainVals':'_', + 'strainVars':'_', + 'otherStrainNames':'_', + 'otherStrainVals':'_', + 'otherStrainVars':'_', + 'extra_attributes':'_', + 'other_extra_attributes':'_' + } if fd.enablevariance: hddn['enablevariance']='ON' diff --git a/wqflask/wqflask/show_trait/show_trait_page.py b/wqflask/wqflask/show_trait/show_trait_page.py index d4019fd5..a63071c3 100644 --- a/wqflask/wqflask/show_trait/show_trait_page.py +++ b/wqflask/wqflask/show_trait/show_trait_page.py @@ -182,6 +182,6 @@ class ShowTraitPage(DataEditingPage): fd.varianceDispName = 'SE' fd.formID = 'varianceChoice' - self.dict['body']= thisTrait + #self.dict['body']= thisTrait DataEditingPage.__init__(self, fd, thisTrait) - self.dict['title'] = '%s: Display Trait' % fd.identification + #self.dict['title'] = '%s: Display Trait' % fd.identification -- cgit v1.2.3 From 8ac39ead1014953c634e85d0ce340497ecfe2934 Mon Sep 17 00:00:00 2001 From: Sam Ockman Date: Tue, 5 Jun 2012 00:24:44 -0400 Subject: Ran reindent.py recursively on wqflask directory --- .gitignore | 2 + wqflask/base/GeneralObject.py | 77 +- wqflask/base/admin.py | 32 +- wqflask/base/cgiData.py | 60 +- wqflask/base/cookieData.py | 27 +- wqflask/base/header.py | 2 +- wqflask/base/indexBody.py | 414 +-- wqflask/base/myCookie.py | 38 +- wqflask/base/sessionData.py | 27 +- wqflask/base/template.py | 74 +- wqflask/base/templatePage.py | 318 +- wqflask/base/webqtlCaseData.py | 43 +- wqflask/base/webqtlDataset.py | 249 +- wqflask/base/webqtlFormData.py | 516 +-- wqflask/base/webqtlTrait.py | 1152 +++--- .../basicStatistics/BasicStatisticsFunctions.py | 280 +- .../basicStatistics/BasicStatisticsPage_alpha.py | 602 ++-- .../basicStatistics/updatedBasicStatisticsPage.py | 284 +- wqflask/dbFunction/webqtlDatabaseFunction.py | 293 +- wqflask/utility/AJAX_table.py | 224 +- wqflask/utility/Plot.py | 2304 ++++++------ wqflask/utility/TDCell.py | 15 +- wqflask/utility/THCell.py | 16 +- wqflask/utility/svg.py | 133 +- wqflask/utility/webqtlUtil.py | 1459 ++++---- wqflask/wqflask/show_trait/DataEditingPage.py | 3810 ++++++++++---------- wqflask/wqflask/show_trait/show_trait_page.py | 290 +- 27 files changed, 6353 insertions(+), 6388 deletions(-) (limited to 'wqflask/base') diff --git a/.gitignore b/.gitignore index 8bc78454..fc051245 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ # gitignore *.pyc *.orig +*.bak *~ + diff --git a/wqflask/base/GeneralObject.py b/wqflask/base/GeneralObject.py index 311c9e22..53d1357b 100755 --- a/wqflask/base/GeneralObject.py +++ b/wqflask/base/GeneralObject.py @@ -25,47 +25,44 @@ # Last updated by GeneNetwork Core Team 2010/10/20 class GeneralObject: - """ - Base class to define an Object. - a = [Spam(1, 4), Spam(9, 3), Spam(4,6)] - a.sort(lambda x, y: cmp(x.eggs, y.eggs)) - """ + """ + Base class to define an Object. + a = [Spam(1, 4), Spam(9, 3), Spam(4,6)] + a.sort(lambda x, y: cmp(x.eggs, y.eggs)) + """ - def __init__(self, *args, **kw): - self.contents = list(args) - for name, value in kw.items(): - setattr(self, name, value) - - def __setitem__(self, key, value): - setattr(self, key, value) - - def __getitem__(self, key): - return getattr(self, key) - - def __getattr__(self, key): - if key in self.__dict__.keys(): - return self.__dict__[key] - else: - return eval("self.__dict__.%s" % key) - - def __len__(self): - return len(self.__dict__) - 1 - - def __str__(self): - s = '' - for key in self.__dict__.keys(): - if key != 'contents': - s += '%s = %s\n' % (key,self.__dict__[key]) - return s - - def __repr__(self): - s = '' - for key in self.__dict__.keys(): - s += '%s = %s\n' % (key,self.__dict__[key]) - return s - - def __cmp__(self,other): - return len(self.__dict__.keys()).__cmp__(len(other.__dict__.keys())) + def __init__(self, *args, **kw): + self.contents = list(args) + for name, value in kw.items(): + setattr(self, name, value) + def __setitem__(self, key, value): + setattr(self, key, value) + def __getitem__(self, key): + return getattr(self, key) + def __getattr__(self, key): + if key in self.__dict__.keys(): + return self.__dict__[key] + else: + return eval("self.__dict__.%s" % key) + + def __len__(self): + return len(self.__dict__) - 1 + + def __str__(self): + s = '' + for key in self.__dict__.keys(): + if key != 'contents': + s += '%s = %s\n' % (key,self.__dict__[key]) + return s + + def __repr__(self): + s = '' + for key in self.__dict__.keys(): + s += '%s = %s\n' % (key,self.__dict__[key]) + return s + + def __cmp__(self,other): + return len(self.__dict__.keys()).__cmp__(len(other.__dict__.keys())) diff --git a/wqflask/base/admin.py b/wqflask/base/admin.py index a04df2da..1ba75117 100755 --- a/wqflask/base/admin.py +++ b/wqflask/base/admin.py @@ -35,18 +35,18 @@ ADMIN_search_dbs = { - 'rat': {'PERITONEAL FAT': ['FT_2A_0605_Rz'], + 'rat': {'PERITONEAL FAT': ['FT_2A_0605_Rz'], 'KIDNEY': ['KI_2A_0405_Rz'], 'ADRENAL GLAND': ['HXB_Adrenal_1208'], 'HEART': ['HXB_Heart_1208'] }, - 'mouse': {'CEREBELLUM': ['CB_M_0305_R'], + 'mouse': {'CEREBELLUM': ['CB_M_0305_R'], 'STRIATUM': ['SA_M2_0905_R', 'SA_M2_0405_RC', 'UTHSC_1107_RankInv', 'Striatum_Exon_0209'], - 'HIPPOCAMPUS': ['HC_M2_0606_R', 'UMUTAffyExon_0209_RMA'], - 'WHOLE BRAIN': ['BR_M2_1106_R', 'IBR_M_0106_R', 'BRF2_M_0805_R', 'UCLA_BHF2_BRAIN_0605'], - 'LIVER': ['LV_G_0106_B', 'UCLA_BHF2_LIVER_0605'], - 'EYE': ['Eye_M2_0908_R'], - 'HEMATOPOIETIC STEM CELLS': ['HC_U_0304_R'], + 'HIPPOCAMPUS': ['HC_M2_0606_R', 'UMUTAffyExon_0209_RMA'], + 'WHOLE BRAIN': ['BR_M2_1106_R', 'IBR_M_0106_R', 'BRF2_M_0805_R', 'UCLA_BHF2_BRAIN_0605'], + 'LIVER': ['LV_G_0106_B', 'UCLA_BHF2_LIVER_0605'], + 'EYE': ['Eye_M2_0908_R'], + 'HEMATOPOIETIC STEM CELLS': ['HC_U_0304_R'], 'KIDNEY': ['MA_M2_0806_R'], 'MAMMARY TUMORS': ['MA_M_0704_R', 'NCI_Agil_Mam_Tum_RMA_0409'], 'PREFRONTAL CORTEX': ['VCUSal_1206_R'], @@ -65,14 +65,14 @@ ADMIN_search_dbs = { ###LIST of tissue alias -ADMIN_tissue_alias = {'CEREBELLUM': ['Cb'], - 'STRIATUM': ['Str'], - 'HIPPOCAMPUS': ['Hip'], - 'WHOLE BRAIN': ['Brn'], - 'LIVER': ['Liv'], - 'EYE': ['Eye'], - 'PERITONEAL FAT': ['Fat'], - 'HEMATOPOIETIC STEM CELLS': ['Hsc'], +ADMIN_tissue_alias = {'CEREBELLUM': ['Cb'], + 'STRIATUM': ['Str'], + 'HIPPOCAMPUS': ['Hip'], + 'WHOLE BRAIN': ['Brn'], + 'LIVER': ['Liv'], + 'EYE': ['Eye'], + 'PERITONEAL FAT': ['Fat'], + 'HEMATOPOIETIC STEM CELLS': ['Hsc'], 'KIDNEY': ['Kid'], 'ADRENAL GLAND': ['Adr'], 'HEART': ['Hea'], @@ -84,5 +84,3 @@ ADMIN_tissue_alias = {'CEREBELLUM': ['Cb'], 'ADIPOSE': ['Wfat'], 'RETINA': ['Ret'] } - - diff --git a/wqflask/base/cgiData.py b/wqflask/base/cgiData.py index 57416060..155b3ec3 100755 --- a/wqflask/base/cgiData.py +++ b/wqflask/base/cgiData.py @@ -30,41 +30,37 @@ ######################################### class cgiData(dict): - '''convert Field storage object to Dict object - Filed storage object cannot be properly dumped - ''' + '''convert Field storage object to Dict object + Filed storage object cannot be properly dumped + ''' - def __init__(self, field_storage=None): + def __init__(self, field_storage=None): - if not field_storage: - field_storage={} - - for key in field_storage.keys(): - temp = field_storage.getlist(key) - if len(temp) > 1: - temp = map(self.toValue, temp) - elif len(temp) == 1: - temp = self.toValue(temp[0]) - else: - temp = None - self[key]= temp - - def toValue(self, obj): - '''fieldstorge returns different type of objects, \ - need to convert to string or None''' - try: - return obj.value - except: - return "" - - def getvalue(self, k, default= None): - try: - return self[k] - except: - return default - - getfirst = getvalue + if not field_storage: + field_storage={} + for key in field_storage.keys(): + temp = field_storage.getlist(key) + if len(temp) > 1: + temp = map(self.toValue, temp) + elif len(temp) == 1: + temp = self.toValue(temp[0]) + else: + temp = None + self[key]= temp + def toValue(self, obj): + '''fieldstorge returns different type of objects, \ + need to convert to string or None''' + try: + return obj.value + except: + return "" + def getvalue(self, k, default= None): + try: + return self[k] + except: + return default + getfirst = getvalue diff --git a/wqflask/base/cookieData.py b/wqflask/base/cookieData.py index 4b7c9046..eeb7c0cf 100755 --- a/wqflask/base/cookieData.py +++ b/wqflask/base/cookieData.py @@ -30,23 +30,20 @@ ######################################### class cookieData(dict): - 'convert mod python Cookie object to Dict object' + 'convert mod python Cookie object to Dict object' - def __init__(self, cookies=None): + def __init__(self, cookies=None): - if not cookies: - cookies={} - - for key in cookies.keys(): - self[key.lower()]= cookies[key].value - - def getvalue(self, k, default= None): - try: - return self[k.lower()] - except: - return default - - getfirst = getvalue + if not cookies: + cookies={} + for key in cookies.keys(): + self[key.lower()]= cookies[key].value + def getvalue(self, k, default= None): + try: + return self[k.lower()] + except: + return default + getfirst = getvalue diff --git a/wqflask/base/header.py b/wqflask/base/header.py index b6136b51..ec15e174 100755 --- a/wqflask/base/header.py +++ b/wqflask/base/header.py @@ -3,4 +3,4 @@ import webqtlConfig header_string = open(webqtlConfig.HTMLPATH + 'header.html', 'r').read() header_string = header_string.replace("\\'", "'") header_string = header_string.replace('%"','%%"') -header_string = header_string.replace('', '%s') \ No newline at end of file +header_string = header_string.replace('', '%s') diff --git a/wqflask/base/indexBody.py b/wqflask/base/indexBody.py index aa67dffa..a5bc4c17 100755 --- a/wqflask/base/indexBody.py +++ b/wqflask/base/indexBody.py @@ -1,174 +1,174 @@ index_body_string = """ -

Select and Search -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +

Select and Search + + +

- Species: - - - -
- Group: - - - -
- Type: - - - -
- Database: - - - - -
- - -

    Databases marked with ** suffix are not public yet. -
    Access requires user login.

-
- Get Any: - - - - -
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + - + - + + - - + + - + - - + + - - - - + + + - -
+ Species: + + + +
+ Group: + + + +
+ Type: + + + +
+ Database: + + + + +
+ + +

    Databases marked with ** suffix are not public yet. +
    Access requires user login.

+
+ Get Any: + + + + +
- +
+ - -

    Enter terms, genes, ID numbers in the Get Any field. -
    Use * or ? wildcards (Cyp*a?, synap*). -
    Use Combined for terms such as tyrosine kinase.

+
+

    Enter terms, genes, ID numbers in the Get Any field. +
    Use * or ? wildcards (Cyp*a?, synap*). +
    Use Combined for terms such as tyrosine kinase.

-
- Combined: -
+ Combined: + - + - - -
+ + +
- - -      -      - +
+ + +      +      + -
- - - -
- + + + + + + + + @@ -185,7 +185,7 @@ Quick HELP Examples and User's Guide

-  You can also use advanced commands. Copy these simple examples +  You can also use advanced commands. Copy these simple examples
  into the Get Any or Combined search fields: + - + -

Websites Affiliated with GeneNetwork

-

-

-

-

____________________________ - -

Getting Started   

-
    -
  1. Select Species (or select All) -
  2. Select Group (a specific sample) -
  3. Select Type of data: - -
  4. Select a Database -
  5. Enter search terms in the Get Any or Combined field: words, genes, ID numbers, probes, advanced search commands -
  6. Click on the Search button -
  7. Optional: Use the Make Default button to save your preferences -
- -

____________________________ +

Websites Affiliated with GeneNetwork

+

+

+

+

____________________________ + +

Getting Started   

+
    +
  1. Select Species (or select All) +
  2. Select Group (a specific sample) +
  3. Select Type of data: + +
  4. Select a Database +
  5. Enter search terms in the Get Any or Combined field: words, genes, ID numbers, probes, advanced search commands +
  6. Click on the Search button +
  7. Optional: Use the Make Default button to save your preferences +
+ +

____________________________

How to Use GeneNetwork -

-

Take a 20-40 minute GeneNetwork Tour that includes screen shots and typical steps in the analysis.

-
-
-

For information about resources and methods, select the INFO buttons.

+
+

Take a 20-40 minute GeneNetwork Tour that includes screen shots and typical steps in the analysis.

+
+
+

For information about resources and methods, select the INFO buttons.

+ + - -

Try the Workstation site to explore data and features that are being implemented.

-

Review the Conditions and Contacts pages for information on the status of data sets and advice on their use and citation.

+

Review the Conditions and Contacts pages for information on the status of data sets and advice on their use and citation.

+ +
-
- -

Mirror and Development Sites

+

Mirror and Development Sites

- + -

History and Archive +

History and Archive -

-

GeneNetwork's Time Machine links to earlier versions that correspond to specific publication dates.

+
+

GeneNetwork's Time Machine links to earlier versions that correspond to specific publication dates.

-
+

- + """ diff --git a/wqflask/base/myCookie.py b/wqflask/base/myCookie.py index db5320df..add7e6ea 100755 --- a/wqflask/base/myCookie.py +++ b/wqflask/base/myCookie.py @@ -25,31 +25,27 @@ # Last updated by GeneNetwork Core Team 2010/10/20 ######################################### -## python cookie and mod python cookie are +## python cookie and mod python cookie are ## not compatible ######################################### class myCookie(dict): - 'define my own cookie' - - def __init__(self, name="", value="", expire = None, path="/"): - self['name']= name - self['value']= value - self['expire']= expire - self['path']= path - - def __getattr__(self, key): - if key in self.keys(): - return self[key] - else: - return None - - def __nonzero__ (self): - if self['name']: - return 1 - else: - return 0 - + 'define my own cookie' + def __init__(self, name="", value="", expire = None, path="/"): + self['name']= name + self['value']= value + self['expire']= expire + self['path']= path + def __getattr__(self, key): + if key in self.keys(): + return self[key] + else: + return None + def __nonzero__ (self): + if self['name']: + return 1 + else: + return 0 diff --git a/wqflask/base/sessionData.py b/wqflask/base/sessionData.py index 01555f87..4b23060f 100755 --- a/wqflask/base/sessionData.py +++ b/wqflask/base/sessionData.py @@ -30,24 +30,21 @@ ######################################### class sessionData(dict): - 'convert mod python Session object to Dict object' + 'convert mod python Session object to Dict object' - def __init__(self, mod_python_session=None): - - if not mod_python_session: - mod_python_session = {} + def __init__(self, mod_python_session=None): - for key in mod_python_session.keys(): - self[key]= mod_python_session[key] - - - def getvalue(self, k, default= None): - try: - return self[k] - except: - return default + if not mod_python_session: + mod_python_session = {} - getfirst = getvalue + for key in mod_python_session.keys(): + self[key]= mod_python_session[key] + def getvalue(self, k, default= None): + try: + return self[k] + except: + return default + getfirst = getvalue diff --git a/wqflask/base/template.py b/wqflask/base/template.py index 85bd86df..aa8f90dc 100755 --- a/wqflask/base/template.py +++ b/wqflask/base/template.py @@ -68,32 +68,32 @@ template = """ %s - - - - %s - - + + + + %s + + - - - - - + + + + + - - - - + + + +
- - - %s - -
-
+ + + %s + +
+
- %s
-
+ %s
+
@@ -103,20 +103,20 @@ template = """ diff --git a/wqflask/base/templatePage.py b/wqflask/base/templatePage.py index 821c6181..7ef58a72 100755 --- a/wqflask/base/templatePage.py +++ b/wqflask/base/templatePage.py @@ -61,162 +61,162 @@ from utility import webqtlUtil class templatePage: - contents = ['title','basehref','js1','js2', 'layer', 'header', 'body', 'footer'] - - # you can pass in another template here if you want - def __init__(self, fd=None, template=template.template): - - # initiate dictionary - self.starttime = time.time() - self.dict = {} - self.template = template - - for item in self.contents: - self.dict[item] = "" - - self.dict['basehref'] = "" #webqtlConfig.BASEHREF - self.cursor = None - - self.cookie = [] #XZ: list to hold cookies (myCookie object) being changed - self.content_type = 'text/html' - self.content_disposition = '' - self.redirection = '' - self.debug = '' - self.attachment = '' - - #XZ: Holding data (new data or existing data being changed) that should be saved to session. The data must be picklable!!! - self.session_data_changed = {} - - self.userName = 'Guest' - self.privilege = 'guest' - - # Commenting this out for flask - we'll have to reimplement later - Sam - #if fd.input_session_data.has_key('user'): - # self.userName = fd.input_session_data['user'] - #if fd.input_session_data.has_key('privilege'): - # self.privilege = fd.input_session_data['privilege'] - - def __str__(self): - - #XZ: default setting - thisUserName = self.userName - thisPrivilege = self.privilege - #XZ: user may just go through login or logoff page - if self.session_data_changed.has_key('user'): - thisUserName = self.session_data_changed['user'] - if self.session_data_changed.has_key('privilege'): - thisPrivilege = self.session_data_changed['privilege'] - - if thisUserName == 'Guest': - userInfo = 'Welcome! Login' - else: - userInfo = 'Hi, %s! Logout' % thisUserName - - reload(header) - self.dict['header'] = header.header_string % userInfo - - serverInfo = "It took %2.3f second(s) for %s to generate this page" % (time.time()-self.starttime, socket.getfqdn()) - reload(footer) - self.dict['footer'] = footer.footer_string % serverInfo - - slist = [] - for item in self.contents: - slist.append(self.dict[item]) - return self.template % tuple(slist) - - - def __del__(self): - if self.cursor: - self.cursor.close() - - def write(self): - 'return string representation of this object' - - if self.cursor: - self.cursor.close() - - return str(self) - - def writeFile(self, filename): - 'save string representation of this object into a file' - if self.cursor: - self.cursor.close() - - try: - 'it could take a long time to generate the file, save to .tmp first' - fp = open(os.path.join(webqtlConfig.TMPDIR, filename+'.tmp'), 'wb') - fp.write(str(self)) - fp.close() - path_tmp = os.path.join(webqtlConfig.TMPDIR, filename+'.tmp') - path_html = os.path.join(webqtlConfig.TMPDIR, filename) - shutil.move(path_tmp,path_html) - except: - pass - - def openMysql(self): - try: - self.con = MySQLdb.Connect(db=webqtlConfig.DB_NAME,host=webqtlConfig.MYSQL_SERVER, \ - user=webqtlConfig.DB_USER,passwd=webqtlConfig.DB_PASSWD) - self.cursor = self.con.cursor() - return 1 - except: - heading = "Connect MySQL Server" - detail = ["Can't connect to MySQL server on '"+ webqtlConfig.MYSQL_SERVER+"':100061. \ - The server may be down at this time"] - self.error(heading=heading,detail=detail,error="Error 2003") - return 0 - - def updMysql(self): - try: - self.con = MySQLdb.Connect(db=webqtlConfig.DB_UPDNAME,host=webqtlConfig.MYSQL_UPDSERVER, \ - user=webqtlConfig.DB_UPDUSER,passwd=webqtlConfig.DB_UPDPASSWD) - self.cursor = self.con.cursor() - return 1 - except: - heading = "Connect MySQL Server" - detail = ["update: Can't connect to MySQL server on '"+ webqtlConfig.MYSQL_UPDSERVER+"':100061. \ - The server may be down at this time "] - self.error(heading=heading,detail=detail,error="Error 2003") - return 0 - - def error(self,heading="",intro=[],detail=[],title="Error",error="Error"): - 'generating a WebQTL style error page' - Heading = HT.Paragraph(heading) - Heading.__setattr__("class","title") - - Intro = HT.Blockquote() - if intro: - for item in intro: - Intro.append(item) - else: - Intro.append(HT.Strong('Sorry!'),' Error occurred while processing\ - your request.', HT.P(),'The nature of the error generated is as\ - follows:') - - Detail = HT.Blockquote() - Detail.append(HT.Span("%s : " % error,Class="fwb cr")) - if detail: - Detail2 = HT.Blockquote() - for item in detail: - Detail2.append(item) - Detail.append(HT.Italic(Detail2)) - - #Detail.__setattr__("class","subtitle") - TD_LR = HT.TD(height=200,width="100%",bgColor='#eeeeee',valign="top") - TD_LR.append(Heading,Intro,Detail) - self.dict['body'] = str(TD_LR) - self.dict['title'] = title - - def session(self,mytitle="",myHeading=""): - 'generate a auto-refreshing temporary html file(waiting page)' - self.filename = webqtlUtil.generate_session() - self.dict['title'] = mytitle - self.dict['basehref'] = webqtlConfig.REFRESHSTR % (webqtlConfig.CGIDIR, self.filename) + "" #webqtlConfig.BASEHREF - - TD_LR = HT.TD(align="center", valign="middle", height=200,width="100%", bgColor='#eeeeee') - Heading = HT.Paragraph(myHeading, Class="fwb fs16 cr") - # NL, 07/27/2010. variable 'PROGRESSBAR' has been moved from templatePage.py to webqtlUtil.py; - TD_LR.append(Heading, HT.BR(), webqtlUtil.PROGRESSBAR) - self.dict['body'] = TD_LR - self.writeFile(self.filename + '.html') - return self.filename + contents = ['title','basehref','js1','js2', 'layer', 'header', 'body', 'footer'] + + # you can pass in another template here if you want + def __init__(self, fd=None, template=template.template): + + # initiate dictionary + self.starttime = time.time() + self.dict = {} + self.template = template + + for item in self.contents: + self.dict[item] = "" + + self.dict['basehref'] = "" #webqtlConfig.BASEHREF + self.cursor = None + + self.cookie = [] #XZ: list to hold cookies (myCookie object) being changed + self.content_type = 'text/html' + self.content_disposition = '' + self.redirection = '' + self.debug = '' + self.attachment = '' + + #XZ: Holding data (new data or existing data being changed) that should be saved to session. The data must be picklable!!! + self.session_data_changed = {} + + self.userName = 'Guest' + self.privilege = 'guest' + + # Commenting this out for flask - we'll have to reimplement later - Sam + #if fd.input_session_data.has_key('user'): + # self.userName = fd.input_session_data['user'] + #if fd.input_session_data.has_key('privilege'): + # self.privilege = fd.input_session_data['privilege'] + + def __str__(self): + + #XZ: default setting + thisUserName = self.userName + thisPrivilege = self.privilege + #XZ: user may just go through login or logoff page + if self.session_data_changed.has_key('user'): + thisUserName = self.session_data_changed['user'] + if self.session_data_changed.has_key('privilege'): + thisPrivilege = self.session_data_changed['privilege'] + + if thisUserName == 'Guest': + userInfo = 'Welcome! Login' + else: + userInfo = 'Hi, %s! Logout' % thisUserName + + reload(header) + self.dict['header'] = header.header_string % userInfo + + serverInfo = "It took %2.3f second(s) for %s to generate this page" % (time.time()-self.starttime, socket.getfqdn()) + reload(footer) + self.dict['footer'] = footer.footer_string % serverInfo + + slist = [] + for item in self.contents: + slist.append(self.dict[item]) + return self.template % tuple(slist) + + + def __del__(self): + if self.cursor: + self.cursor.close() + + def write(self): + 'return string representation of this object' + + if self.cursor: + self.cursor.close() + + return str(self) + + def writeFile(self, filename): + 'save string representation of this object into a file' + if self.cursor: + self.cursor.close() + + try: + 'it could take a long time to generate the file, save to .tmp first' + fp = open(os.path.join(webqtlConfig.TMPDIR, filename+'.tmp'), 'wb') + fp.write(str(self)) + fp.close() + path_tmp = os.path.join(webqtlConfig.TMPDIR, filename+'.tmp') + path_html = os.path.join(webqtlConfig.TMPDIR, filename) + shutil.move(path_tmp,path_html) + except: + pass + + def openMysql(self): + try: + self.con = MySQLdb.Connect(db=webqtlConfig.DB_NAME,host=webqtlConfig.MYSQL_SERVER, \ + user=webqtlConfig.DB_USER,passwd=webqtlConfig.DB_PASSWD) + self.cursor = self.con.cursor() + return 1 + except: + heading = "Connect MySQL Server" + detail = ["Can't connect to MySQL server on '"+ webqtlConfig.MYSQL_SERVER+"':100061. \ + The server may be down at this time"] + self.error(heading=heading,detail=detail,error="Error 2003") + return 0 + + def updMysql(self): + try: + self.con = MySQLdb.Connect(db=webqtlConfig.DB_UPDNAME,host=webqtlConfig.MYSQL_UPDSERVER, \ + user=webqtlConfig.DB_UPDUSER,passwd=webqtlConfig.DB_UPDPASSWD) + self.cursor = self.con.cursor() + return 1 + except: + heading = "Connect MySQL Server" + detail = ["update: Can't connect to MySQL server on '"+ webqtlConfig.MYSQL_UPDSERVER+"':100061. \ + The server may be down at this time "] + self.error(heading=heading,detail=detail,error="Error 2003") + return 0 + + def error(self,heading="",intro=[],detail=[],title="Error",error="Error"): + 'generating a WebQTL style error page' + Heading = HT.Paragraph(heading) + Heading.__setattr__("class","title") + + Intro = HT.Blockquote() + if intro: + for item in intro: + Intro.append(item) + else: + Intro.append(HT.Strong('Sorry!'),' Error occurred while processing\ + your request.', HT.P(),'The nature of the error generated is as\ + follows:') + + Detail = HT.Blockquote() + Detail.append(HT.Span("%s : " % error,Class="fwb cr")) + if detail: + Detail2 = HT.Blockquote() + for item in detail: + Detail2.append(item) + Detail.append(HT.Italic(Detail2)) + + #Detail.__setattr__("class","subtitle") + TD_LR = HT.TD(height=200,width="100%",bgColor='#eeeeee',valign="top") + TD_LR.append(Heading,Intro,Detail) + self.dict['body'] = str(TD_LR) + self.dict['title'] = title + + def session(self,mytitle="",myHeading=""): + 'generate a auto-refreshing temporary html file(waiting page)' + self.filename = webqtlUtil.generate_session() + self.dict['title'] = mytitle + self.dict['basehref'] = webqtlConfig.REFRESHSTR % (webqtlConfig.CGIDIR, self.filename) + "" #webqtlConfig.BASEHREF + + TD_LR = HT.TD(align="center", valign="middle", height=200,width="100%", bgColor='#eeeeee') + Heading = HT.Paragraph(myHeading, Class="fwb fs16 cr") + # NL, 07/27/2010. variable 'PROGRESSBAR' has been moved from templatePage.py to webqtlUtil.py; + TD_LR.append(Heading, HT.BR(), webqtlUtil.PROGRESSBAR) + self.dict['body'] = TD_LR + self.writeFile(self.filename + '.html') + return self.filename diff --git a/wqflask/base/webqtlCaseData.py b/wqflask/base/webqtlCaseData.py index 4df32ca4..f68354be 100755 --- a/wqflask/base/webqtlCaseData.py +++ b/wqflask/base/webqtlCaseData.py @@ -25,30 +25,27 @@ # Last updated by GeneNetwork Core Team 2010/10/20 class webqtlCaseData: - """ - one case data in one trait - """ + """ + one case data in one trait + """ - val = None #Trait Value - var = None #Trait Variance - N = None #Number of individuals - - def __init__(self, val=val, var=var, N=N): - self.val = val - self.var = var - self.N = N - - def __str__(self): - str = "" - if self.val != None: - str += "value=%2.3f" % self.val - if self.var != None: - str += " variance=%2.3f" % self.var - if self.N != None: - str += " ndata=%d" % self.N - return str - - __repr__ = __str__ + val = None #Trait Value + var = None #Trait Variance + N = None #Number of individuals + def __init__(self, val=val, var=var, N=N): + self.val = val + self.var = var + self.N = N + def __str__(self): + str = "" + if self.val != None: + str += "value=%2.3f" % self.val + if self.var != None: + str += " variance=%2.3f" % self.var + if self.N != None: + str += " ndata=%d" % self.N + return str + __repr__ = __str__ diff --git a/wqflask/base/webqtlDataset.py b/wqflask/base/webqtlDataset.py index da1b8601..f8491bb1 100755 --- a/wqflask/base/webqtlDataset.py +++ b/wqflask/base/webqtlDataset.py @@ -31,130 +31,125 @@ import webqtlConfig class webqtlDataset: - """ - Database class defines a database in webqtl, can be either Microarray, - Published phenotype, genotype, or user input database(temp) - """ - - def __init__(self, dbName, cursor=None): - - assert dbName - self.id = 0 - self.name = '' - self.type = '' - self.riset = '' - self.cursor = cursor - - #temporary storage - if dbName.find('Temp') >= 0: - self.searchfield = ['name','description'] - self.disfield = ['name','description'] - self.type = 'Temp' - self.id = 1 - self.fullname = 'Temporary Storage' - self.shortname = 'Temp' - elif dbName.find('Publish') >= 0: - self.searchfield = ['name','post_publication_description','abstract','title','authors'] - self.disfield = ['name','pubmed_id', - 'pre_publication_description', 'post_publication_description', 'original_description', - 'pre_publication_abbreviation', 'post_publication_abbreviation', - 'lab_code', 'submitter', 'owner', 'authorized_users', - 'authors','title','abstract', 'journal','volume','pages','month', - 'year','sequence', 'units', 'comments'] - self.type = 'Publish' - elif dbName.find('Geno') >= 0: - self.searchfield = ['name','chr'] - self.disfield = ['name','chr','mb', 'source2', 'sequence'] - self.type = 'Geno' - else: #ProbeSet - self.searchfield = ['name','description','probe_target_description', - 'symbol','alias','genbankid','unigeneid','omim', - 'refseq_transcriptid','probe_set_specificity', 'probe_set_blat_score'] - self.disfield = ['name','symbol','description','probe_target_description', - 'chr','mb','alias','geneid','genbankid', 'unigeneid', 'omim', - 'refseq_transcriptid','blatseq','targetseq','chipid', 'comments', - 'strand_probe','strand_gene','probe_set_target_region', - 'probe_set_specificity', 'probe_set_blat_score','probe_set_blat_mb_start', - 'probe_set_blat_mb_end', 'probe_set_strand', - 'probe_set_note_by_rw', 'flag'] - self.type = 'ProbeSet' - self.name = dbName - if self.cursor and self.id == 0: - self.retrieveName() - - def __str__(self): - return self.name - - __repr__ = __str__ - - - def getRISet(self): - assert self.cursor - if self.type == 'Publish': - query = ''' - SELECT - InbredSet.Name, InbredSet.Id - FROM - InbredSet, PublishFreeze - WHERE - PublishFreeze.InbredSetId = InbredSet.Id AND - PublishFreeze.Name = "%s" - ''' % self.name - elif self.type == 'Geno': - query = ''' - SELECT - InbredSet.Name, InbredSet.Id - FROM - InbredSet, GenoFreeze - WHERE - GenoFreeze.InbredSetId = InbredSet.Id AND - GenoFreeze.Name = "%s" - ''' % self.name - elif self.type == 'ProbeSet': - query = ''' - SELECT - InbredSet.Name, InbredSet.Id - FROM - InbredSet, ProbeSetFreeze, ProbeFreeze - WHERE - ProbeFreeze.InbredSetId = InbredSet.Id AND - ProbeFreeze.Id = ProbeSetFreeze.ProbeFreezeId AND - ProbeSetFreeze.Name = "%s" - ''' % self.name - else: - return "" - self.cursor.execute(query) - RISet, RIID = self.cursor.fetchone() - if RISet == 'BXD300': - RISet = "BXD" - self.riset = RISet - self.risetid = RIID - return RISet - - - def retrieveName(self): - assert self.id == 0 and self.cursor - query = ''' - SELECT - Id, Name, FullName, ShortName - FROM - %sFreeze - WHERE - public > %d AND - (Name = "%s" OR FullName = "%s" OR ShortName = "%s") - '''% (self.type, webqtlConfig.PUBLICTHRESH, self.name, self.name, self.name) - try: - self.cursor.execute(query) - self.id,self.name,self.fullname,self.shortname=self.cursor.fetchone() - except: - raise KeyError, `self.name`+' doesn\'t exist.' - - - def genHTML(self, Class='c0dd'): - return HT.Href(text = HT.Span('%s Database' % self.fullname, Class= "fwb " + Class), - url= webqtlConfig.INFOPAGEHREF % self.name,target="_blank") - - - - - + """ + Database class defines a database in webqtl, can be either Microarray, + Published phenotype, genotype, or user input database(temp) + """ + + def __init__(self, dbName, cursor=None): + + assert dbName + self.id = 0 + self.name = '' + self.type = '' + self.riset = '' + self.cursor = cursor + + #temporary storage + if dbName.find('Temp') >= 0: + self.searchfield = ['name','description'] + self.disfield = ['name','description'] + self.type = 'Temp' + self.id = 1 + self.fullname = 'Temporary Storage' + self.shortname = 'Temp' + elif dbName.find('Publish') >= 0: + self.searchfield = ['name','post_publication_description','abstract','title','authors'] + self.disfield = ['name','pubmed_id', + 'pre_publication_description', 'post_publication_description', 'original_description', + 'pre_publication_abbreviation', 'post_publication_abbreviation', + 'lab_code', 'submitter', 'owner', 'authorized_users', + 'authors','title','abstract', 'journal','volume','pages','month', + 'year','sequence', 'units', 'comments'] + self.type = 'Publish' + elif dbName.find('Geno') >= 0: + self.searchfield = ['name','chr'] + self.disfield = ['name','chr','mb', 'source2', 'sequence'] + self.type = 'Geno' + else: #ProbeSet + self.searchfield = ['name','description','probe_target_description', + 'symbol','alias','genbankid','unigeneid','omim', + 'refseq_transcriptid','probe_set_specificity', 'probe_set_blat_score'] + self.disfield = ['name','symbol','description','probe_target_description', + 'chr','mb','alias','geneid','genbankid', 'unigeneid', 'omim', + 'refseq_transcriptid','blatseq','targetseq','chipid', 'comments', + 'strand_probe','strand_gene','probe_set_target_region', + 'probe_set_specificity', 'probe_set_blat_score','probe_set_blat_mb_start', + 'probe_set_blat_mb_end', 'probe_set_strand', + 'probe_set_note_by_rw', 'flag'] + self.type = 'ProbeSet' + self.name = dbName + if self.cursor and self.id == 0: + self.retrieveName() + + def __str__(self): + return self.name + + __repr__ = __str__ + + + def getRISet(self): + assert self.cursor + if self.type == 'Publish': + query = ''' + SELECT + InbredSet.Name, InbredSet.Id + FROM + InbredSet, PublishFreeze + WHERE + PublishFreeze.InbredSetId = InbredSet.Id AND + PublishFreeze.Name = "%s" + ''' % self.name + elif self.type == 'Geno': + query = ''' + SELECT + InbredSet.Name, InbredSet.Id + FROM + InbredSet, GenoFreeze + WHERE + GenoFreeze.InbredSetId = InbredSet.Id AND + GenoFreeze.Name = "%s" + ''' % self.name + elif self.type == 'ProbeSet': + query = ''' + SELECT + InbredSet.Name, InbredSet.Id + FROM + InbredSet, ProbeSetFreeze, ProbeFreeze + WHERE + ProbeFreeze.InbredSetId = InbredSet.Id AND + ProbeFreeze.Id = ProbeSetFreeze.ProbeFreezeId AND + ProbeSetFreeze.Name = "%s" + ''' % self.name + else: + return "" + self.cursor.execute(query) + RISet, RIID = self.cursor.fetchone() + if RISet == 'BXD300': + RISet = "BXD" + self.riset = RISet + self.risetid = RIID + return RISet + + + def retrieveName(self): + assert self.id == 0 and self.cursor + query = ''' + SELECT + Id, Name, FullName, ShortName + FROM + %sFreeze + WHERE + public > %d AND + (Name = "%s" OR FullName = "%s" OR ShortName = "%s") + '''% (self.type, webqtlConfig.PUBLICTHRESH, self.name, self.name, self.name) + try: + self.cursor.execute(query) + self.id,self.name,self.fullname,self.shortname=self.cursor.fetchone() + except: + raise KeyError, `self.name`+' doesn\'t exist.' + + + def genHTML(self, Class='c0dd'): + return HT.Href(text = HT.Span('%s Database' % self.fullname, Class= "fwb " + Class), + url= webqtlConfig.INFOPAGEHREF % self.name,target="_blank") diff --git a/wqflask/base/webqtlFormData.py b/wqflask/base/webqtlFormData.py index c94dbe53..06faacc0 100755 --- a/wqflask/base/webqtlFormData.py +++ b/wqflask/base/webqtlFormData.py @@ -40,261 +40,261 @@ from utility import webqtlUtil class webqtlFormData: - 'Represents data from a WebQTL form page, needed to generate the next page' - attrs = ('formID','RISet','genotype','strainlist','allstrainlist', - 'suggestive','significance','submitID','identification', 'enablevariance', - 'nperm','nboot','email','incparentsf1','genotype_1','genotype_2','traitInfo') - - #XZ: Attention! All attribute values must be picklable! - - def __init__(self, start_vars = None, req = None, mod_python_session=None, FieldStorage_formdata=None): - - self.__dict__.update(start_vars) - - for item in self.attrs: - setattr(self,item, None) - - try: - self.remote_ip = req.connection.remote_ip - except: - self.remote_ip = '1.2.3.4' - - if req and req.headers_in.has_key('referer'): - self.refURL = req.headers_in['referer'] - else: - self.refURL = None - - # For now let's just comment all this out - Sam - - #self.cookies = cookieData.cookieData(Cookie.get_cookies(req)) #XZ: dictionary type. To hold values transfered from mod_python Cookie. - # - ##XZ: dictionary type. To hold values transfered from mod_python Session object. We assume that it is always picklable. - #self.input_session_data = sessionData.sessionData( mod_python_session ) - # - ##XZ: FieldStorage_formdata may contain item that can't be pickled. Must convert to picklable data. - #self.formdata = cgiData( FieldStorage_formdata ) - # - ##get Form ID - #self.formID = self.formdata.getfirst('FormID') - # - ##get rest of the attributes - #if self.formID: - # for item in self.attrs: - # value = self.formdata.getfirst(item) - # if value != None: - # setattr(self,item,string.strip(value)) - - self.ppolar = "" - self.mpolar = "" - if self.RISet: - try: - # NL, 07/27/2010. ParInfo has been moved from webqtlForm.py to webqtlUtil.py; - f1, f12, self.mpolar, self.ppolar = webqtlUtil.ParInfo[self.RISet] - except: - f1 = f12 = self.mpolar = self.ppolar = None - - try: - self.nperm = int(self.nperm) - self.nboot = int(self.nboot) - except: - self.nperm = 2000 #XZ: Rob asked to change the default value to 2000 - self.nboot = 2000 #XZ: Rob asked to change the default value to 2000 - - if self.allstrainlist: - self.allstrainlist = map(string.strip, string.split(self.allstrainlist)) - #self.readGenotype() - #self.readData() - - if self.RISet == 'BXD300': - self.RISet = 'BXD' - else: - pass - - def __getitem__(self, key): - return self.__dict__[key] - - def get(self, key, default=None): - if key in self.__dict__: - return self.__dict__[key] - else: - return default - - def __str__(self): - rstr = '' - for item in self.attrs: - if item != 'genotype': - rstr += '%s:%s\n' % (item,str(getattr(self,item))) - return rstr - - - def readGenotype(self): - 'read genotype from .geno file' - if self.RISet == 'BXD300': - self.RISet = 'BXD' - else: - pass - assert self.RISet - #genotype_1 is Dataset Object without parents and f1 - #genotype_2 is Dataset Object with parents and f1 (not for intercross) - self.genotype_1 = reaper.Dataset() - self.genotype_1.read(os.path.join(webqtlConfig.GENODIR, self.RISet + '.geno')) - try: - # NL, 07/27/2010. ParInfo has been moved from webqtlForm.py to webqtlUtil.py; - _f1, _f12, _mat, _pat = webqtlUtil.ParInfo[self.RISet] - except: - _f1 = _f12 = _mat = _pat = None - - self.genotype_2 =self.genotype_1 - if self.genotype_1.type == "riset" and _mat and _pat: - self.genotype_2 = self.genotype_1.add(Mat=_mat, Pat=_pat) #, F1=_f1) - - #determine default genotype object - if self.incparentsf1 and self.genotype_1.type != "intercross": - self.genotype = self.genotype_2 - else: - self.incparentsf1 = 0 - self.genotype = self.genotype_1 - self.strainlist = list(self.genotype.prgy) - self.f1list = self.parlist = [] - if _f1 and _f12: - self.f1list = [_f1, _f12] - if _mat and _pat: - self.parlist = [_mat, _pat] - - def readData(self, strainlst=[], incf1=[]): - 'read user input data or from trait data and analysis form' - - if not self.genotype: - self.readGenotype() - if not strainlst: - if incf1: - strainlst = self.f1list + self.strainlist - else: - strainlst = self.strainlist - - - traitfiledata = self.formdata.getfirst('traitfile') - traitpastedata = self.formdata.getfirst('traitpaste') - variancefiledata = self.formdata.getfirst('variancefile') - variancepastedata = self.formdata.getfirst('variancepaste') - Nfiledata = self.formdata.getfirst('Nfile') - - - if traitfiledata: - tt = string.split(traitfiledata) - vals = map(webqtlUtil.StringAsFloat, tt) - elif traitpastedata: - tt = string.split(traitpastedata) - vals = map(webqtlUtil.StringAsFloat, tt) - else: - vals = map(self.FormDataAsFloat, strainlst) - - if len(vals) < len(strainlst): - vals += [None]*(len(strainlst) - len(vals)) - elif len(vals) > len(strainlst): - vals = vals[:len(strainlst)] - else: - pass - - - if variancefiledata: - tt = string.split(variancefiledata) - vars = map(webqtlUtil.StringAsFloat, tt) - elif variancepastedata: - tt = string.split(variancepastedata) - vars = map(webqtlUtil.StringAsFloat, tt) - else: - vars = map(self.FormVarianceAsFloat, strainlst) - - if len(vars) < len(strainlst): - vars += [None]*(len(strainlst) - len(vars)) - elif len(vars) > len(strainlst): - vars = vars[:len(strainlst)] - else: - pass - - if Nfiledata: - tt = string.split(Nfiledata) - nstrains = map(webqtlUtil.IntAsFloat, tt) - if len(nstrains) < len(strainlst): - nstrains += [None]*(len(strainlst) - len(nstrains)) - else: - nstrains = map(self.FormNAsFloat, strainlst) - - ##vals, vars, nstrains is obsolete - self.allTraitData = {} - for i, _strain in enumerate(strainlst): - if vals[i] != None: - self.allTraitData[_strain] = webqtlCaseData(vals[i], vars[i], nstrains[i]) - - - - def informativeStrains(self, strainlst=[], incVars = 0): - '''if readData was called, use this to output the informative strains - (strain with values)''' - if not strainlst: - strainlst = self.strainlist - strains = [] - vals = [] - vars = [] - for _strain in strainlst: - if self.allTraitData.has_key(_strain): - _val, _var = self.allTraitData[_strain].val, self.allTraitData[_strain].var - if _val != None: - if incVars: - if _var != None: - strains.append(_strain) - vals.append(_val) - vars.append(_var) - else: - strains.append(_strain) - vals.append(_val) - vars.append(None) - return strains, vals, vars, len(strains) - - - - def FormDataAsFloat(self, key): - try: - return float(self.formdata.getfirst(key)) - except: - return None - - - def FormVarianceAsFloat(self, key): - try: - return float(self.formdata.getfirst('V' + key)) - except: - return None - - def FormNAsFloat(self, key): - try: - return int(self.formdata.getfirst('N' + key)) - except: - return None - - def Sample(self): - 'Create some dummy data for testing' - self.RISet = 'BXD' - self.incparentsf1 = 'on' - #self.display = 9.2 - #self.significance = 16.1 - self.readGenotype() - self.identification = 'BXD : Coat color example by Lu Lu, et al' - #self.readGenotype() - #self.genotype.ReadMM('AXBXAforQTL') - #self.strainlist = map((lambda x, y='': '%s%s' % (y,x)), self.genotype.prgy) - #self.strainlist.sort() - self.allTraitData = {'BXD29': webqtlCaseData(3), 'BXD28': webqtlCaseData(2), - 'BXD25': webqtlCaseData(2), 'BXD24': webqtlCaseData(2), 'BXD27': webqtlCaseData(2), - 'BXD21': webqtlCaseData(1), 'BXD20': webqtlCaseData(4), 'BXD23': webqtlCaseData(4), - 'BXD22': webqtlCaseData(3), 'BXD14': webqtlCaseData(4), 'BXD15': webqtlCaseData(2), - 'BXD16': webqtlCaseData(3), 'BXD11': webqtlCaseData(4), 'BXD12': webqtlCaseData(3), - 'BXD13': webqtlCaseData(2), 'BXD18': webqtlCaseData(3), 'BXD19': webqtlCaseData(3), - 'BXD38': webqtlCaseData(3), 'BXD39': webqtlCaseData(3), 'BXD36': webqtlCaseData(2), - 'BXD34': webqtlCaseData(4), 'BXD35': webqtlCaseData(4), 'BXD32': webqtlCaseData(4), - 'BXD33': webqtlCaseData(3), 'BXD30': webqtlCaseData(1), 'BXD31': webqtlCaseData(4), - 'DBA/2J': webqtlCaseData(1), 'BXD8': webqtlCaseData(3), 'BXD9': webqtlCaseData(1), - 'BXD6': webqtlCaseData(3), 'BXD5': webqtlCaseData(3), 'BXD2': webqtlCaseData(4), - 'BXD1': webqtlCaseData(1), 'C57BL/6J': webqtlCaseData(4), 'B6D2F1': webqtlCaseData(4), - 'BXD42': webqtlCaseData(4), 'BXD40': webqtlCaseData(3)} + 'Represents data from a WebQTL form page, needed to generate the next page' + attrs = ('formID','RISet','genotype','strainlist','allstrainlist', + 'suggestive','significance','submitID','identification', 'enablevariance', + 'nperm','nboot','email','incparentsf1','genotype_1','genotype_2','traitInfo') + + #XZ: Attention! All attribute values must be picklable! + + def __init__(self, start_vars = None, req = None, mod_python_session=None, FieldStorage_formdata=None): + + self.__dict__.update(start_vars) + + for item in self.attrs: + setattr(self,item, None) + + try: + self.remote_ip = req.connection.remote_ip + except: + self.remote_ip = '1.2.3.4' + + if req and req.headers_in.has_key('referer'): + self.refURL = req.headers_in['referer'] + else: + self.refURL = None + + # For now let's just comment all this out - Sam + + #self.cookies = cookieData.cookieData(Cookie.get_cookies(req)) #XZ: dictionary type. To hold values transfered from mod_python Cookie. + # + ##XZ: dictionary type. To hold values transfered from mod_python Session object. We assume that it is always picklable. + #self.input_session_data = sessionData.sessionData( mod_python_session ) + # + ##XZ: FieldStorage_formdata may contain item that can't be pickled. Must convert to picklable data. + #self.formdata = cgiData( FieldStorage_formdata ) + # + ##get Form ID + #self.formID = self.formdata.getfirst('FormID') + # + ##get rest of the attributes + #if self.formID: + # for item in self.attrs: + # value = self.formdata.getfirst(item) + # if value != None: + # setattr(self,item,string.strip(value)) + + self.ppolar = "" + self.mpolar = "" + if self.RISet: + try: + # NL, 07/27/2010. ParInfo has been moved from webqtlForm.py to webqtlUtil.py; + f1, f12, self.mpolar, self.ppolar = webqtlUtil.ParInfo[self.RISet] + except: + f1 = f12 = self.mpolar = self.ppolar = None + + try: + self.nperm = int(self.nperm) + self.nboot = int(self.nboot) + except: + self.nperm = 2000 #XZ: Rob asked to change the default value to 2000 + self.nboot = 2000 #XZ: Rob asked to change the default value to 2000 + + if self.allstrainlist: + self.allstrainlist = map(string.strip, string.split(self.allstrainlist)) + #self.readGenotype() + #self.readData() + + if self.RISet == 'BXD300': + self.RISet = 'BXD' + else: + pass + + def __getitem__(self, key): + return self.__dict__[key] + + def get(self, key, default=None): + if key in self.__dict__: + return self.__dict__[key] + else: + return default + + def __str__(self): + rstr = '' + for item in self.attrs: + if item != 'genotype': + rstr += '%s:%s\n' % (item,str(getattr(self,item))) + return rstr + + + def readGenotype(self): + 'read genotype from .geno file' + if self.RISet == 'BXD300': + self.RISet = 'BXD' + else: + pass + assert self.RISet + #genotype_1 is Dataset Object without parents and f1 + #genotype_2 is Dataset Object with parents and f1 (not for intercross) + self.genotype_1 = reaper.Dataset() + self.genotype_1.read(os.path.join(webqtlConfig.GENODIR, self.RISet + '.geno')) + try: + # NL, 07/27/2010. ParInfo has been moved from webqtlForm.py to webqtlUtil.py; + _f1, _f12, _mat, _pat = webqtlUtil.ParInfo[self.RISet] + except: + _f1 = _f12 = _mat = _pat = None + + self.genotype_2 =self.genotype_1 + if self.genotype_1.type == "riset" and _mat and _pat: + self.genotype_2 = self.genotype_1.add(Mat=_mat, Pat=_pat) #, F1=_f1) + + #determine default genotype object + if self.incparentsf1 and self.genotype_1.type != "intercross": + self.genotype = self.genotype_2 + else: + self.incparentsf1 = 0 + self.genotype = self.genotype_1 + self.strainlist = list(self.genotype.prgy) + self.f1list = self.parlist = [] + if _f1 and _f12: + self.f1list = [_f1, _f12] + if _mat and _pat: + self.parlist = [_mat, _pat] + + def readData(self, strainlst=[], incf1=[]): + 'read user input data or from trait data and analysis form' + + if not self.genotype: + self.readGenotype() + if not strainlst: + if incf1: + strainlst = self.f1list + self.strainlist + else: + strainlst = self.strainlist + + + traitfiledata = self.formdata.getfirst('traitfile') + traitpastedata = self.formdata.getfirst('traitpaste') + variancefiledata = self.formdata.getfirst('variancefile') + variancepastedata = self.formdata.getfirst('variancepaste') + Nfiledata = self.formdata.getfirst('Nfile') + + + if traitfiledata: + tt = string.split(traitfiledata) + vals = map(webqtlUtil.StringAsFloat, tt) + elif traitpastedata: + tt = string.split(traitpastedata) + vals = map(webqtlUtil.StringAsFloat, tt) + else: + vals = map(self.FormDataAsFloat, strainlst) + + if len(vals) < len(strainlst): + vals += [None]*(len(strainlst) - len(vals)) + elif len(vals) > len(strainlst): + vals = vals[:len(strainlst)] + else: + pass + + + if variancefiledata: + tt = string.split(variancefiledata) + vars = map(webqtlUtil.StringAsFloat, tt) + elif variancepastedata: + tt = string.split(variancepastedata) + vars = map(webqtlUtil.StringAsFloat, tt) + else: + vars = map(self.FormVarianceAsFloat, strainlst) + + if len(vars) < len(strainlst): + vars += [None]*(len(strainlst) - len(vars)) + elif len(vars) > len(strainlst): + vars = vars[:len(strainlst)] + else: + pass + + if Nfiledata: + tt = string.split(Nfiledata) + nstrains = map(webqtlUtil.IntAsFloat, tt) + if len(nstrains) < len(strainlst): + nstrains += [None]*(len(strainlst) - len(nstrains)) + else: + nstrains = map(self.FormNAsFloat, strainlst) + + ##vals, vars, nstrains is obsolete + self.allTraitData = {} + for i, _strain in enumerate(strainlst): + if vals[i] != None: + self.allTraitData[_strain] = webqtlCaseData(vals[i], vars[i], nstrains[i]) + + + + def informativeStrains(self, strainlst=[], incVars = 0): + '''if readData was called, use this to output the informative strains + (strain with values)''' + if not strainlst: + strainlst = self.strainlist + strains = [] + vals = [] + vars = [] + for _strain in strainlst: + if self.allTraitData.has_key(_strain): + _val, _var = self.allTraitData[_strain].val, self.allTraitData[_strain].var + if _val != None: + if incVars: + if _var != None: + strains.append(_strain) + vals.append(_val) + vars.append(_var) + else: + strains.append(_strain) + vals.append(_val) + vars.append(None) + return strains, vals, vars, len(strains) + + + + def FormDataAsFloat(self, key): + try: + return float(self.formdata.getfirst(key)) + except: + return None + + + def FormVarianceAsFloat(self, key): + try: + return float(self.formdata.getfirst('V' + key)) + except: + return None + + def FormNAsFloat(self, key): + try: + return int(self.formdata.getfirst('N' + key)) + except: + return None + + def Sample(self): + 'Create some dummy data for testing' + self.RISet = 'BXD' + self.incparentsf1 = 'on' + #self.display = 9.2 + #self.significance = 16.1 + self.readGenotype() + self.identification = 'BXD : Coat color example by Lu Lu, et al' + #self.readGenotype() + #self.genotype.ReadMM('AXBXAforQTL') + #self.strainlist = map((lambda x, y='': '%s%s' % (y,x)), self.genotype.prgy) + #self.strainlist.sort() + self.allTraitData = {'BXD29': webqtlCaseData(3), 'BXD28': webqtlCaseData(2), + 'BXD25': webqtlCaseData(2), 'BXD24': webqtlCaseData(2), 'BXD27': webqtlCaseData(2), + 'BXD21': webqtlCaseData(1), 'BXD20': webqtlCaseData(4), 'BXD23': webqtlCaseData(4), + 'BXD22': webqtlCaseData(3), 'BXD14': webqtlCaseData(4), 'BXD15': webqtlCaseData(2), + 'BXD16': webqtlCaseData(3), 'BXD11': webqtlCaseData(4), 'BXD12': webqtlCaseData(3), + 'BXD13': webqtlCaseData(2), 'BXD18': webqtlCaseData(3), 'BXD19': webqtlCaseData(3), + 'BXD38': webqtlCaseData(3), 'BXD39': webqtlCaseData(3), 'BXD36': webqtlCaseData(2), + 'BXD34': webqtlCaseData(4), 'BXD35': webqtlCaseData(4), 'BXD32': webqtlCaseData(4), + 'BXD33': webqtlCaseData(3), 'BXD30': webqtlCaseData(1), 'BXD31': webqtlCaseData(4), + 'DBA/2J': webqtlCaseData(1), 'BXD8': webqtlCaseData(3), 'BXD9': webqtlCaseData(1), + 'BXD6': webqtlCaseData(3), 'BXD5': webqtlCaseData(3), 'BXD2': webqtlCaseData(4), + 'BXD1': webqtlCaseData(1), 'C57BL/6J': webqtlCaseData(4), 'B6D2F1': webqtlCaseData(4), + 'BXD42': webqtlCaseData(4), 'BXD40': webqtlCaseData(3)} diff --git a/wqflask/base/webqtlTrait.py b/wqflask/base/webqtlTrait.py index 88226894..812d112a 100755 --- a/wqflask/base/webqtlTrait.py +++ b/wqflask/base/webqtlTrait.py @@ -14,579 +14,579 @@ from pprint import pformat as pf class webqtlTrait: - """ - Trait class defines a trait in webqtl, can be either Microarray, - Published phenotype, genotype, or user input trait - - """ - - def __init__(self, cursor = None, **kw): - print("in webqtlTrait") - self.cursor = cursor - self.db = None # database object - self.name = '' # Trait ID, ProbeSet ID, Published ID, etc. - self.cellid = '' - self.identification = 'un-named trait' - self.riset = '' - self.haveinfo = 0 - self.sequence = '' # Blat sequence, available for ProbeSet - self.data = {} - print("foo") - print("kw in webqtlTrait are:", pf(kw)) - print("printed\n\n") - for name, value in kw.items(): - if self.__dict__.has_key(name): - setattr(self, name, value) - elif name == 'fullname': - name2 = value.split("::") - if len(name2) == 2: - self.db, self.name = name2 - elif len(name2) == 3: - self.db, self.name, self.cellid = name2 - else: - raise KeyError, repr(value) + ' parameter format error.' - else: - raise KeyError, repr(name) + ' not a valid parameter for this class.' - - if self.db and isinstance(self.db, basestring): - assert self.cursor, "Don't have a cursor" - self.db = webqtlDataset(self.db, self.cursor) - - #if self.db == None, not from a database - print("self.db is:", self.db, type(self.db)) - if self.db: - if self.db.type == "Temp": - self.cursor.execute(''' - SELECT - InbredSet.Name - FROM - InbredSet, Temp - WHERE - Temp.InbredSetId = InbredSet.Id AND - Temp.Name = "%s" - ''', self.name) - self.riset = self.cursor.fetchone()[0] - else: - self.riset = self.db.getRISet() - - # - # In ProbeSet, there are maybe several annotations match one sequence - # so we need use sequence(BlatSeq) as the identification, when we update - # one annotation, we update the others who match the sequence also. - # - # Hongqiang Li, 3/3/2008 - # - - #XZ, 05/08/2009: This block is not neccessary. We can add 'BlatSeq' into disfield. - # The variable self.sequence should be changed to self.BlatSeq - # It also should be changed in other places where it are used. - - if self.db: - if self.db.type == 'ProbeSet': - print("Doing ProbeSet Query") - query = ''' - SELECT - ProbeSet.BlatSeq - FROM - ProbeSet, ProbeSetFreeze, ProbeSetXRef - WHERE - ProbeSet.Id=ProbeSetXRef.ProbeSetId and - ProbeSetFreeze.Id = ProbeSetXRef.ProbeSetFreezeId and - ProbeSet.Name = %s and - ProbeSetFreeze.Name = %s - ''', (self.name, self.db.name) - print("query is:", query) - self.cursor.execute(*query) - self.sequence = self.cursor.fetchone()[0] - print("self.sequence is:", self.sequence) - - - def getName(self): - str = "" - if self.db and self.name: - str = "%s::%s" % (self.db, self.name) - if self.cellid: - str += "::" + self.cellid - else: - str = self.description - return str - - # - # when user enter a trait or GN generate a trait, user want show the name - # not the name that generated by GN randomly, the two follow function are - # used to give the real name and the database. displayName() will show the - # database also, getGivenName() just show the name. - # For other trait, displayName() as same as getName(), getGivenName() as - # same as self.name - # - # Hongqiang 11/29/07 - # - def getGivenName(self): - str = self.name - if self.db and self.name: - if self.db.type=='Temp': - self.cursor.execute('SELECT description FROM Temp WHERE Name=%s', self.name) - desc = self.cursor.fetchone()[0] - if desc.__contains__('PCA'): - desc = desc[desc.rindex(':')+1:].strip() - else: - desc = desc[:desc.index('entered')].strip() - str = desc - return str - - def displayName(self): - str = "" - if self.db and self.name: - if self.db.type=='Temp': - desc = self.description - if desc.__contains__('PCA'): - desc = desc[desc.rindex(':')+1:].strip() - else: - desc = desc[:desc.index('entered')].strip() - str = "%s::%s" % (self.db, desc) - else: - str = "%s::%s" % (self.db, self.name) - if self.cellid: - str += "::" + self.cellid - else: - str = self.description - - return str - - - #def __str__(self): - # #return "%s %s" % (self.getName(), self.riset) - # return self.getName() - __str__ = getName - __repr__ = __str__ - - def exportData(self, strainlist, type="val"): - """ - export data according to strainlist - mostly used in calculating correlation - """ - result = [] - for strain in strainlist: - if self.data.has_key(strain): - if type=='val': - result.append(self.data[strain].val) - elif type=='var': - result.append(self.data[strain].var) - elif type=='N': - result.append(self.data[strain].N) - else: - raise KeyError, `type`+' type is incorrect.' - else: - result.append(None) - return result - - def exportInformative(self, incVar=0): - """ - export informative strain - mostly used in qtl regression - """ - strains = [] - vals = [] - vars = [] - for strain, value in self.data.items(): - if value.val != None: - if not incVar or value.var != None: - strains.append(strain) - vals.append(value.val) - vars.append(value.var) - return strains, vals, vars - - - # - # In ProbeSet, there are maybe several annotations match one sequence - # so we need use sequence(BlatSeq) as the identification, when we update - # one annotation, we update the others who match the sequence also. - # - # Hongqiang Li, 3/3/2008 - # - def getSequence(self): - assert self.cursor - if self.db.type == 'ProbeSet': - self.cursor.execute(''' - SELECT - ProbeSet.BlatSeq - FROM - ProbeSet, ProbeSetFreeze, ProbeSetXRef - WHERE - ProbeSet.Id=ProbeSetXRef.ProbeSetId and - ProbeSetFreeze.Id = ProbeSetXRef.ProbSetFreezeId and - ProbeSet.Name = %s - ProbeSetFreeze.Name = %s - ''', self.name, self.db.name) - #self.cursor.execute(query) - results = self.fetchone() - - return results[0] - - - - def retrieveData(self, strainlist=[]): - assert self.db and self.cursor - - if self.db.type == 'Temp': - query = ''' - SELECT - Strain.Name, TempData.value, TempData.SE, TempData.NStrain, TempData.Id - FROM - TempData, Temp, Strain - WHERE - TempData.StrainId = Strain.Id AND - TempData.Id = Temp.DataId AND - Temp.name = '%s' - Order BY - Strain.Name - ''' % self.name - #XZ, 03/02/2009: Xiaodong changed Data to PublishData, SE to PublishSE - elif self.db.type == 'Publish': - query = ''' - SELECT - Strain.Name, PublishData.value, PublishSE.error, NStrain.count, PublishData.Id - FROM - (PublishData, Strain, PublishXRef, PublishFreeze) - left join PublishSE on - (PublishSE.DataId = PublishData.Id AND PublishSE.StrainId = PublishData.StrainId) - left join NStrain on - (NStrain.DataId = PublishData.Id AND - NStrain.StrainId = PublishData.StrainId) - WHERE - PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND - PublishData.Id = PublishXRef.DataId AND PublishXRef.Id = %s AND - PublishFreeze.Id = %d AND PublishData.StrainId = Strain.Id - Order BY - Strain.Name - ''' % (self.name, self.db.id) - - #XZ, 03/02/2009: Xiaodong changed Data to ProbeData, SE to ProbeSE - elif self.cellid: - #Probe Data - query = ''' - SELECT - Strain.Name, ProbeData.value, ProbeSE.error, ProbeData.Id - FROM - (ProbeData, ProbeFreeze, ProbeSetFreeze, ProbeXRef, - Strain, Probe, ProbeSet) - left join ProbeSE on - (ProbeSE.DataId = ProbeData.Id AND ProbeSE.StrainId = ProbeData.StrainId) - WHERE - Probe.Name = '%s' AND ProbeSet.Name = '%s' AND - Probe.ProbeSetId = ProbeSet.Id AND - ProbeXRef.ProbeId = Probe.Id AND - ProbeXRef.ProbeFreezeId = ProbeFreeze.Id AND - ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id AND - ProbeSetFreeze.Name = '%s' AND - ProbeXRef.DataId = ProbeData.Id AND - ProbeData.StrainId = Strain.Id - Order BY - Strain.Name - ''' % (self.cellid, self.name, self.db.name) - #XZ, 03/02/2009: Xiaodong added this block for ProbeSetData and ProbeSetSE - elif self.db.type == 'ProbeSet': - #ProbeSet Data - query = ''' - SELECT - Strain.Name, ProbeSetData.value, ProbeSetSE.error, ProbeSetData.Id - FROM - (ProbeSetData, ProbeSetFreeze, Strain, ProbeSet, ProbeSetXRef) - left join ProbeSetSE on - (ProbeSetSE.DataId = ProbeSetData.Id AND ProbeSetSE.StrainId = ProbeSetData.StrainId) - WHERE - ProbeSet.Name = '%s' AND ProbeSetXRef.ProbeSetId = ProbeSet.Id AND - ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id AND - ProbeSetFreeze.Name = '%s' AND - ProbeSetXRef.DataId = ProbeSetData.Id AND - ProbeSetData.StrainId = Strain.Id - Order BY - Strain.Name - ''' % (self.name, self.db.name) - #XZ, 03/02/2009: Xiaodong changeded Data to GenoData, SE to GenoSE - else: - #Geno Data - #XZ: The SpeciesId is not necessary, but it's nice to keep it to speed up database search. - query = ''' - SELECT - Strain.Name, GenoData.value, GenoSE.error, GenoData.Id - FROM - (GenoData, GenoFreeze, Strain, Geno, GenoXRef) - left join GenoSE on - (GenoSE.DataId = GenoData.Id AND GenoSE.StrainId = GenoData.StrainId) - WHERE - Geno.SpeciesId = %s AND Geno.Name = '%s' AND GenoXRef.GenoId = Geno.Id AND - GenoXRef.GenoFreezeId = GenoFreeze.Id AND - GenoFreeze.Name = '%s' AND - GenoXRef.DataId = GenoData.Id AND - GenoData.StrainId = Strain.Id - Order BY - Strain.Name - ''' % (webqtlDatabaseFunction.retrieveSpeciesId(self.cursor, self.db.riset), self.name, self.db.name) - - - self.cursor.execute(query) - results = self.cursor.fetchall() - self.data.clear() - if results: - self.mysqlid = results[0][-1] - if strainlist: - for item in results: - if item[0] in strainlist: - val = item[1] - if val != None: - var = item[2] - ndata = None - if self.db.type in ('Publish', 'Temp'): - ndata = item[3] - self.data[item[0]] = webqtlCaseData(val, var, ndata) - #end for - else: - for item in results: - val = item[1] - if val != None: - var = item[2] - ndata = None - if self.db.type in ('Publish', 'Temp'): - ndata = item[3] - self.data[item[0]] = webqtlCaseData(val, var, ndata) - #end for - #end if - else: - pass - - def keys(self): - return self.__dict__.keys() - - def has_key(self, key): - return self.__dict__.has_key(key) - - def items(self): - return self.__dict__.items() - - def retrieveInfo(self, QTL = None): - assert self.db and self.cursor - if self.db.type == 'Publish': - #self.db.DisField = ['Name','PubMed_ID','Phenotype','Abbreviation','Authors','Title',\ - # 'Abstract', 'Journal','Volume','Pages','Month','Year','Sequence',\ - # 'Units', 'comments'] - query = ''' - SELECT - PublishXRef.Id, Publication.PubMed_ID, - Phenotype.Pre_publication_description, Phenotype.Post_publication_description, Phenotype.Original_description, - Phenotype.Pre_publication_abbreviation, Phenotype.Post_publication_abbreviation, - Phenotype.Lab_code, Phenotype.Submitter, Phenotype.Owner, Phenotype.Authorized_Users, - Publication.Authors, Publication.Title, Publication.Abstract, - Publication.Journal, Publication.Volume, Publication.Pages, - Publication.Month, Publication.Year, PublishXRef.Sequence, - Phenotype.Units, PublishXRef.comments - FROM - PublishXRef, Publication, Phenotype, PublishFreeze - WHERE - PublishXRef.Id = %s AND - Phenotype.Id = PublishXRef.PhenotypeId AND - Publication.Id = PublishXRef.PublicationId AND - PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND - PublishFreeze.Id =%s - ''' % (self.name, self.db.id) - #XZ, 05/08/2009: Xiaodong add this block to use ProbeSet.Id to find the probeset instead of just using ProbeSet.Name - #XZ, 05/08/2009: to avoid the problem of same probeset name from different platforms. - elif self.db.type == 'ProbeSet': - disfieldString = string.join(self.db.disfield,',ProbeSet.') - disfieldString = 'ProbeSet.' + disfieldString - query = """ - SELECT %s - FROM ProbeSet, ProbeSetFreeze, ProbeSetXRef - WHERE - ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id AND - ProbeSetXRef.ProbeSetId = ProbeSet.Id AND - ProbeSetFreeze.Name = '%s' AND - ProbeSet.Name = '%s' - """ % (disfieldString, self.db.name, self.name) - #XZ, 05/08/2009: We also should use Geno.Id to find marker instead of just using Geno.Name - # to avoid the problem of same marker name from different species. - elif self.db.type == 'Geno': - disfieldString = string.join(self.db.disfield,',Geno.') - disfieldString = 'Geno.' + disfieldString - query = """ - SELECT %s - FROM Geno, GenoFreeze, GenoXRef - WHERE - GenoXRef.GenoFreezeId = GenoFreeze.Id AND - GenoXRef.GenoId = Geno.Id AND - GenoFreeze.Name = '%s' AND - Geno.Name = '%s' - """ % (disfieldString, self.db.name, self.name) - else: #Temp type - query = 'SELECT %s FROM %s WHERE Name = "%s"' % \ - (string.join(self.db.disfield,','), self.db.type, self.name) - - - self.cursor.execute(query) - traitInfo = self.cursor.fetchone() - if traitInfo: - self.haveinfo = 1 - - #XZ: assign SQL query result to trait attributes. - for i, field in enumerate(self.db.disfield): - setattr(self, field, traitInfo[i]) - - if self.db.type == 'Publish': - self.confidential = 0 - if self.pre_publication_description and not self.pubmed_id: - self.confidential = 1 - - self.homologeneid = None - if self.db.type == 'ProbeSet' and self.riset and self.geneid: - #XZ, 05/26/2010: From time to time, this query get error message because some geneid values in database are not number. - #XZ: So I have to test if geneid is number before execute the query. - #XZ: The geneid values in database should be cleaned up. - try: - junk = float(self.geneid) - geneidIsNumber = 1 - except: - geneidIsNumber = 0 - - if geneidIsNumber: - query = """ - SELECT - HomologeneId - FROM - Homologene, Species, InbredSet - WHERE - Homologene.GeneId =%s AND - InbredSet.Name = '%s' AND - InbredSet.SpeciesId = Species.Id AND - Species.TaxonomyId = Homologene.TaxonomyId - """ % (self.geneid, self.riset) - self.cursor.execute(query) - result = self.cursor.fetchone() - else: - result = None - - if result: - self.homologeneid = result[0] - - if QTL: - if self.db.type == 'ProbeSet' and not self.cellid: - query = ''' - SELECT - ProbeSetXRef.Locus, ProbeSetXRef.LRS, ProbeSetXRef.pValue, ProbeSetXRef.mean - FROM - ProbeSetXRef, ProbeSet - WHERE - ProbeSetXRef.ProbeSetId = ProbeSet.Id AND - ProbeSet.Name = "%s" AND - ProbeSetXRef.ProbeSetFreezeId =%s - ''' % (self.name, self.db.id) - self.cursor.execute(query) - traitQTL = self.cursor.fetchone() - if traitQTL: - self.locus, self.lrs, self.pvalue, self.mean = traitQTL - else: - self.locus = self.lrs = self.pvalue = self.mean = "" - if self.db.type == 'Publish': - query = ''' - SELECT - PublishXRef.Locus, PublishXRef.LRS - FROM - PublishXRef, PublishFreeze - WHERE - PublishXRef.Id = %s AND - PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND - PublishFreeze.Id =%s - ''' % (self.name, self.db.id) - self.cursor.execute(query) - traitQTL = self.cursor.fetchone() - if traitQTL: - self.locus, self.lrs = traitQTL - else: - self.locus = self.lrs = "" - else: - raise KeyError, `self.name`+' information is not found in the database.' - - def genHTML(self, formName = "", dispFromDatabase=0, privilege="guest", userName="Guest", authorized_users=""): - if not self.haveinfo: - self.retrieveInfo() - - if self.db.type == 'Publish': - PubMedLink = "" - if self.pubmed_id: - PubMedLink = HT.Href(text="PubMed %d : " % self.pubmed_id, - target = "_blank", url = webqtlConfig.PUBMEDLINK_URL % self.pubmed_id) - else: - PubMedLink = HT.Span("Unpublished : ", Class="fs15") - - if formName: - setDescription2 = HT.Href(url="javascript:showDatabase3('%s','%s','%s','')" % - (formName, self.db.name, self.name), Class = "fs14") - else: - setDescription2 = HT.Href(url="javascript:showDatabase2('%s','%s','')" % - (self.db.name,self.name), Class = "fs14") - - if self.confidential and not webqtlUtil.hasAccessToConfidentialPhenotypeTrait(privilege=privilege, userName=userName, authorized_users=authorized_users): - setDescription2.append('RecordID/%s - %s' % (self.name, self.pre_publication_description)) - else: - setDescription2.append('RecordID/%s - %s' % (self.name, self.post_publication_description)) - - #XZ 03/26/2011: Xiaodong comment out the following two lins as Rob asked. Need to check with Rob why in PublishXRef table, there are few row whose Sequence > 1. - #if self.sequence > 1: - # setDescription2.append(' btach %d' % self.sequence) - if self.authors: - a1 = string.split(self.authors,',')[0] - while a1[0] == '"' or a1[0] == "'" : - a1 = a1[1:] - setDescription2.append(' by ') - setDescription2.append(HT.Italic('%s, and colleagues' % a1)) - setDescription = HT.Span(PubMedLink, setDescription2) - - elif self.db.type == 'Temp': - setDescription = HT.Href(text="%s" % (self.description),url="javascript:showDatabase2\ - ('%s','%s','')" % (self.db.name,self.name), Class = "fs14") - setDescription = HT.Span(setDescription) - - elif self.db.type == 'Geno': # Genome DB only available for single search - if formName: - setDescription = HT.Href(text="Locus %s [Chr %s @ %s Mb]" % (self.name,self.chr,\ - '%2.3f' % self.mb),url="javascript:showDatabase3('%s','%s','%s','')" % \ - (formName, self.db.name, self.name), Class = "fs14") - else: - setDescription = HT.Href(text="Locus %s [Chr %s @ %s Mb]" % (self.name,self.chr,\ - '%2.3f' % self.mb),url="javascript:showDatabase2('%s','%s','')" % \ - (self.db.name,self.name), Class = "fs14") - - setDescription = HT.Span(setDescription) - - else: - if self.cellid: - if formName: - setDescription = HT.Href(text="ProbeSet/%s/%s" % (self.name, self.cellid),url=\ - "javascript:showDatabase3('%s','%s','%s','%s')" % (formName, self.db.name,self.name,self.cellid), \ - Class = "fs14") - else: - setDescription = HT.Href(text="ProbeSet/%s/%s" % (self.name,self.cellid),url=\ - "javascript:showDatabase2('%s','%s','%s')" % (self.db.name,self.name,self.cellid), \ - Class = "fs14") - else: - if formName: - setDescription = HT.Href(text="ProbeSet/%s" % self.name, url=\ - "javascript:showDatabase3('%s','%s','%s','')" % (formName, self.db.name,self.name), \ - Class = "fs14") - else: - setDescription = HT.Href(text="ProbeSet/%s" % self.name, url=\ - "javascript:showDatabase2('%s','%s','')" % (self.db.name,self.name), \ - Class = "fs14") - if self.symbol and self.chr and self.mb: - setDescription.append(' [') - setDescription.append(HT.Italic('%s' % self.symbol,Class="cdg fwb")) - setDescription.append(' on Chr %s @ %s Mb]' % (self.chr,self.mb)) - if self.description: - setDescription.append(': %s' % self.description) - if self.probe_target_description: - setDescription.append('; %s' % self.probe_target_description) - setDescription = HT.Span(setDescription) - - if self.db.type != 'Temp' and dispFromDatabase: - setDescription.append( ' --- FROM : ') - setDescription.append(self.db.genHTML(Class='cori')) - return setDescription + """ + Trait class defines a trait in webqtl, can be either Microarray, + Published phenotype, genotype, or user input trait + + """ + + def __init__(self, cursor = None, **kw): + print("in webqtlTrait") + self.cursor = cursor + self.db = None # database object + self.name = '' # Trait ID, ProbeSet ID, Published ID, etc. + self.cellid = '' + self.identification = 'un-named trait' + self.riset = '' + self.haveinfo = 0 + self.sequence = '' # Blat sequence, available for ProbeSet + self.data = {} + print("foo") + print("kw in webqtlTrait are:", pf(kw)) + print("printed\n\n") + for name, value in kw.items(): + if self.__dict__.has_key(name): + setattr(self, name, value) + elif name == 'fullname': + name2 = value.split("::") + if len(name2) == 2: + self.db, self.name = name2 + elif len(name2) == 3: + self.db, self.name, self.cellid = name2 + else: + raise KeyError, repr(value) + ' parameter format error.' + else: + raise KeyError, repr(name) + ' not a valid parameter for this class.' + + if self.db and isinstance(self.db, basestring): + assert self.cursor, "Don't have a cursor" + self.db = webqtlDataset(self.db, self.cursor) + + #if self.db == None, not from a database + print("self.db is:", self.db, type(self.db)) + if self.db: + if self.db.type == "Temp": + self.cursor.execute(''' + SELECT + InbredSet.Name + FROM + InbredSet, Temp + WHERE + Temp.InbredSetId = InbredSet.Id AND + Temp.Name = "%s" + ''', self.name) + self.riset = self.cursor.fetchone()[0] + else: + self.riset = self.db.getRISet() + + # + # In ProbeSet, there are maybe several annotations match one sequence + # so we need use sequence(BlatSeq) as the identification, when we update + # one annotation, we update the others who match the sequence also. + # + # Hongqiang Li, 3/3/2008 + # + + #XZ, 05/08/2009: This block is not neccessary. We can add 'BlatSeq' into disfield. + # The variable self.sequence should be changed to self.BlatSeq + # It also should be changed in other places where it are used. + + if self.db: + if self.db.type == 'ProbeSet': + print("Doing ProbeSet Query") + query = ''' + SELECT + ProbeSet.BlatSeq + FROM + ProbeSet, ProbeSetFreeze, ProbeSetXRef + WHERE + ProbeSet.Id=ProbeSetXRef.ProbeSetId and + ProbeSetFreeze.Id = ProbeSetXRef.ProbeSetFreezeId and + ProbeSet.Name = %s and + ProbeSetFreeze.Name = %s + ''', (self.name, self.db.name) + print("query is:", query) + self.cursor.execute(*query) + self.sequence = self.cursor.fetchone()[0] + print("self.sequence is:", self.sequence) + + + def getName(self): + str = "" + if self.db and self.name: + str = "%s::%s" % (self.db, self.name) + if self.cellid: + str += "::" + self.cellid + else: + str = self.description + return str + + # + # when user enter a trait or GN generate a trait, user want show the name + # not the name that generated by GN randomly, the two follow function are + # used to give the real name and the database. displayName() will show the + # database also, getGivenName() just show the name. + # For other trait, displayName() as same as getName(), getGivenName() as + # same as self.name + # + # Hongqiang 11/29/07 + # + def getGivenName(self): + str = self.name + if self.db and self.name: + if self.db.type=='Temp': + self.cursor.execute('SELECT description FROM Temp WHERE Name=%s', self.name) + desc = self.cursor.fetchone()[0] + if desc.__contains__('PCA'): + desc = desc[desc.rindex(':')+1:].strip() + else: + desc = desc[:desc.index('entered')].strip() + str = desc + return str + + def displayName(self): + str = "" + if self.db and self.name: + if self.db.type=='Temp': + desc = self.description + if desc.__contains__('PCA'): + desc = desc[desc.rindex(':')+1:].strip() + else: + desc = desc[:desc.index('entered')].strip() + str = "%s::%s" % (self.db, desc) + else: + str = "%s::%s" % (self.db, self.name) + if self.cellid: + str += "::" + self.cellid + else: + str = self.description + + return str + + + #def __str__(self): + # #return "%s %s" % (self.getName(), self.riset) + # return self.getName() + __str__ = getName + __repr__ = __str__ + + def exportData(self, strainlist, type="val"): + """ + export data according to strainlist + mostly used in calculating correlation + """ + result = [] + for strain in strainlist: + if self.data.has_key(strain): + if type=='val': + result.append(self.data[strain].val) + elif type=='var': + result.append(self.data[strain].var) + elif type=='N': + result.append(self.data[strain].N) + else: + raise KeyError, `type`+' type is incorrect.' + else: + result.append(None) + return result + + def exportInformative(self, incVar=0): + """ + export informative strain + mostly used in qtl regression + """ + strains = [] + vals = [] + vars = [] + for strain, value in self.data.items(): + if value.val != None: + if not incVar or value.var != None: + strains.append(strain) + vals.append(value.val) + vars.append(value.var) + return strains, vals, vars + + + # + # In ProbeSet, there are maybe several annotations match one sequence + # so we need use sequence(BlatSeq) as the identification, when we update + # one annotation, we update the others who match the sequence also. + # + # Hongqiang Li, 3/3/2008 + # + def getSequence(self): + assert self.cursor + if self.db.type == 'ProbeSet': + self.cursor.execute(''' + SELECT + ProbeSet.BlatSeq + FROM + ProbeSet, ProbeSetFreeze, ProbeSetXRef + WHERE + ProbeSet.Id=ProbeSetXRef.ProbeSetId and + ProbeSetFreeze.Id = ProbeSetXRef.ProbSetFreezeId and + ProbeSet.Name = %s + ProbeSetFreeze.Name = %s + ''', self.name, self.db.name) + #self.cursor.execute(query) + results = self.fetchone() + + return results[0] + + + + def retrieveData(self, strainlist=[]): + assert self.db and self.cursor + + if self.db.type == 'Temp': + query = ''' + SELECT + Strain.Name, TempData.value, TempData.SE, TempData.NStrain, TempData.Id + FROM + TempData, Temp, Strain + WHERE + TempData.StrainId = Strain.Id AND + TempData.Id = Temp.DataId AND + Temp.name = '%s' + Order BY + Strain.Name + ''' % self.name + #XZ, 03/02/2009: Xiaodong changed Data to PublishData, SE to PublishSE + elif self.db.type == 'Publish': + query = ''' + SELECT + Strain.Name, PublishData.value, PublishSE.error, NStrain.count, PublishData.Id + FROM + (PublishData, Strain, PublishXRef, PublishFreeze) + left join PublishSE on + (PublishSE.DataId = PublishData.Id AND PublishSE.StrainId = PublishData.StrainId) + left join NStrain on + (NStrain.DataId = PublishData.Id AND + NStrain.StrainId = PublishData.StrainId) + WHERE + PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND + PublishData.Id = PublishXRef.DataId AND PublishXRef.Id = %s AND + PublishFreeze.Id = %d AND PublishData.StrainId = Strain.Id + Order BY + Strain.Name + ''' % (self.name, self.db.id) + + #XZ, 03/02/2009: Xiaodong changed Data to ProbeData, SE to ProbeSE + elif self.cellid: + #Probe Data + query = ''' + SELECT + Strain.Name, ProbeData.value, ProbeSE.error, ProbeData.Id + FROM + (ProbeData, ProbeFreeze, ProbeSetFreeze, ProbeXRef, + Strain, Probe, ProbeSet) + left join ProbeSE on + (ProbeSE.DataId = ProbeData.Id AND ProbeSE.StrainId = ProbeData.StrainId) + WHERE + Probe.Name = '%s' AND ProbeSet.Name = '%s' AND + Probe.ProbeSetId = ProbeSet.Id AND + ProbeXRef.ProbeId = Probe.Id AND + ProbeXRef.ProbeFreezeId = ProbeFreeze.Id AND + ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id AND + ProbeSetFreeze.Name = '%s' AND + ProbeXRef.DataId = ProbeData.Id AND + ProbeData.StrainId = Strain.Id + Order BY + Strain.Name + ''' % (self.cellid, self.name, self.db.name) + #XZ, 03/02/2009: Xiaodong added this block for ProbeSetData and ProbeSetSE + elif self.db.type == 'ProbeSet': + #ProbeSet Data + query = ''' + SELECT + Strain.Name, ProbeSetData.value, ProbeSetSE.error, ProbeSetData.Id + FROM + (ProbeSetData, ProbeSetFreeze, Strain, ProbeSet, ProbeSetXRef) + left join ProbeSetSE on + (ProbeSetSE.DataId = ProbeSetData.Id AND ProbeSetSE.StrainId = ProbeSetData.StrainId) + WHERE + ProbeSet.Name = '%s' AND ProbeSetXRef.ProbeSetId = ProbeSet.Id AND + ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id AND + ProbeSetFreeze.Name = '%s' AND + ProbeSetXRef.DataId = ProbeSetData.Id AND + ProbeSetData.StrainId = Strain.Id + Order BY + Strain.Name + ''' % (self.name, self.db.name) + #XZ, 03/02/2009: Xiaodong changeded Data to GenoData, SE to GenoSE + else: + #Geno Data + #XZ: The SpeciesId is not necessary, but it's nice to keep it to speed up database search. + query = ''' + SELECT + Strain.Name, GenoData.value, GenoSE.error, GenoData.Id + FROM + (GenoData, GenoFreeze, Strain, Geno, GenoXRef) + left join GenoSE on + (GenoSE.DataId = GenoData.Id AND GenoSE.StrainId = GenoData.StrainId) + WHERE + Geno.SpeciesId = %s AND Geno.Name = '%s' AND GenoXRef.GenoId = Geno.Id AND + GenoXRef.GenoFreezeId = GenoFreeze.Id AND + GenoFreeze.Name = '%s' AND + GenoXRef.DataId = GenoData.Id AND + GenoData.StrainId = Strain.Id + Order BY + Strain.Name + ''' % (webqtlDatabaseFunction.retrieveSpeciesId(self.cursor, self.db.riset), self.name, self.db.name) + + + self.cursor.execute(query) + results = self.cursor.fetchall() + self.data.clear() + if results: + self.mysqlid = results[0][-1] + if strainlist: + for item in results: + if item[0] in strainlist: + val = item[1] + if val != None: + var = item[2] + ndata = None + if self.db.type in ('Publish', 'Temp'): + ndata = item[3] + self.data[item[0]] = webqtlCaseData(val, var, ndata) + #end for + else: + for item in results: + val = item[1] + if val != None: + var = item[2] + ndata = None + if self.db.type in ('Publish', 'Temp'): + ndata = item[3] + self.data[item[0]] = webqtlCaseData(val, var, ndata) + #end for + #end if + else: + pass + + def keys(self): + return self.__dict__.keys() + + def has_key(self, key): + return self.__dict__.has_key(key) + + def items(self): + return self.__dict__.items() + + def retrieveInfo(self, QTL = None): + assert self.db and self.cursor + if self.db.type == 'Publish': + #self.db.DisField = ['Name','PubMed_ID','Phenotype','Abbreviation','Authors','Title',\ + # 'Abstract', 'Journal','Volume','Pages','Month','Year','Sequence',\ + # 'Units', 'comments'] + query = ''' + SELECT + PublishXRef.Id, Publication.PubMed_ID, + Phenotype.Pre_publication_description, Phenotype.Post_publication_description, Phenotype.Original_description, + Phenotype.Pre_publication_abbreviation, Phenotype.Post_publication_abbreviation, + Phenotype.Lab_code, Phenotype.Submitter, Phenotype.Owner, Phenotype.Authorized_Users, + Publication.Authors, Publication.Title, Publication.Abstract, + Publication.Journal, Publication.Volume, Publication.Pages, + Publication.Month, Publication.Year, PublishXRef.Sequence, + Phenotype.Units, PublishXRef.comments + FROM + PublishXRef, Publication, Phenotype, PublishFreeze + WHERE + PublishXRef.Id = %s AND + Phenotype.Id = PublishXRef.PhenotypeId AND + Publication.Id = PublishXRef.PublicationId AND + PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND + PublishFreeze.Id =%s + ''' % (self.name, self.db.id) + #XZ, 05/08/2009: Xiaodong add this block to use ProbeSet.Id to find the probeset instead of just using ProbeSet.Name + #XZ, 05/08/2009: to avoid the problem of same probeset name from different platforms. + elif self.db.type == 'ProbeSet': + disfieldString = string.join(self.db.disfield,',ProbeSet.') + disfieldString = 'ProbeSet.' + disfieldString + query = """ + SELECT %s + FROM ProbeSet, ProbeSetFreeze, ProbeSetXRef + WHERE + ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id AND + ProbeSetXRef.ProbeSetId = ProbeSet.Id AND + ProbeSetFreeze.Name = '%s' AND + ProbeSet.Name = '%s' + """ % (disfieldString, self.db.name, self.name) + #XZ, 05/08/2009: We also should use Geno.Id to find marker instead of just using Geno.Name + # to avoid the problem of same marker name from different species. + elif self.db.type == 'Geno': + disfieldString = string.join(self.db.disfield,',Geno.') + disfieldString = 'Geno.' + disfieldString + query = """ + SELECT %s + FROM Geno, GenoFreeze, GenoXRef + WHERE + GenoXRef.GenoFreezeId = GenoFreeze.Id AND + GenoXRef.GenoId = Geno.Id AND + GenoFreeze.Name = '%s' AND + Geno.Name = '%s' + """ % (disfieldString, self.db.name, self.name) + else: #Temp type + query = 'SELECT %s FROM %s WHERE Name = "%s"' % \ + (string.join(self.db.disfield,','), self.db.type, self.name) + + + self.cursor.execute(query) + traitInfo = self.cursor.fetchone() + if traitInfo: + self.haveinfo = 1 + + #XZ: assign SQL query result to trait attributes. + for i, field in enumerate(self.db.disfield): + setattr(self, field, traitInfo[i]) + + if self.db.type == 'Publish': + self.confidential = 0 + if self.pre_publication_description and not self.pubmed_id: + self.confidential = 1 + + self.homologeneid = None + if self.db.type == 'ProbeSet' and self.riset and self.geneid: + #XZ, 05/26/2010: From time to time, this query get error message because some geneid values in database are not number. + #XZ: So I have to test if geneid is number before execute the query. + #XZ: The geneid values in database should be cleaned up. + try: + junk = float(self.geneid) + geneidIsNumber = 1 + except: + geneidIsNumber = 0 + + if geneidIsNumber: + query = """ + SELECT + HomologeneId + FROM + Homologene, Species, InbredSet + WHERE + Homologene.GeneId =%s AND + InbredSet.Name = '%s' AND + InbredSet.SpeciesId = Species.Id AND + Species.TaxonomyId = Homologene.TaxonomyId + """ % (self.geneid, self.riset) + self.cursor.execute(query) + result = self.cursor.fetchone() + else: + result = None + + if result: + self.homologeneid = result[0] + + if QTL: + if self.db.type == 'ProbeSet' and not self.cellid: + query = ''' + SELECT + ProbeSetXRef.Locus, ProbeSetXRef.LRS, ProbeSetXRef.pValue, ProbeSetXRef.mean + FROM + ProbeSetXRef, ProbeSet + WHERE + ProbeSetXRef.ProbeSetId = ProbeSet.Id AND + ProbeSet.Name = "%s" AND + ProbeSetXRef.ProbeSetFreezeId =%s + ''' % (self.name, self.db.id) + self.cursor.execute(query) + traitQTL = self.cursor.fetchone() + if traitQTL: + self.locus, self.lrs, self.pvalue, self.mean = traitQTL + else: + self.locus = self.lrs = self.pvalue = self.mean = "" + if self.db.type == 'Publish': + query = ''' + SELECT + PublishXRef.Locus, PublishXRef.LRS + FROM + PublishXRef, PublishFreeze + WHERE + PublishXRef.Id = %s AND + PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND + PublishFreeze.Id =%s + ''' % (self.name, self.db.id) + self.cursor.execute(query) + traitQTL = self.cursor.fetchone() + if traitQTL: + self.locus, self.lrs = traitQTL + else: + self.locus = self.lrs = "" + else: + raise KeyError, `self.name`+' information is not found in the database.' + + def genHTML(self, formName = "", dispFromDatabase=0, privilege="guest", userName="Guest", authorized_users=""): + if not self.haveinfo: + self.retrieveInfo() + + if self.db.type == 'Publish': + PubMedLink = "" + if self.pubmed_id: + PubMedLink = HT.Href(text="PubMed %d : " % self.pubmed_id, + target = "_blank", url = webqtlConfig.PUBMEDLINK_URL % self.pubmed_id) + else: + PubMedLink = HT.Span("Unpublished : ", Class="fs15") + + if formName: + setDescription2 = HT.Href(url="javascript:showDatabase3('%s','%s','%s','')" % + (formName, self.db.name, self.name), Class = "fs14") + else: + setDescription2 = HT.Href(url="javascript:showDatabase2('%s','%s','')" % + (self.db.name,self.name), Class = "fs14") + + if self.confidential and not webqtlUtil.hasAccessToConfidentialPhenotypeTrait(privilege=privilege, userName=userName, authorized_users=authorized_users): + setDescription2.append('RecordID/%s - %s' % (self.name, self.pre_publication_description)) + else: + setDescription2.append('RecordID/%s - %s' % (self.name, self.post_publication_description)) + + #XZ 03/26/2011: Xiaodong comment out the following two lins as Rob asked. Need to check with Rob why in PublishXRef table, there are few row whose Sequence > 1. + #if self.sequence > 1: + # setDescription2.append(' btach %d' % self.sequence) + if self.authors: + a1 = string.split(self.authors,',')[0] + while a1[0] == '"' or a1[0] == "'" : + a1 = a1[1:] + setDescription2.append(' by ') + setDescription2.append(HT.Italic('%s, and colleagues' % a1)) + setDescription = HT.Span(PubMedLink, setDescription2) + + elif self.db.type == 'Temp': + setDescription = HT.Href(text="%s" % (self.description),url="javascript:showDatabase2\ + ('%s','%s','')" % (self.db.name,self.name), Class = "fs14") + setDescription = HT.Span(setDescription) + + elif self.db.type == 'Geno': # Genome DB only available for single search + if formName: + setDescription = HT.Href(text="Locus %s [Chr %s @ %s Mb]" % (self.name,self.chr,\ + '%2.3f' % self.mb),url="javascript:showDatabase3('%s','%s','%s','')" % \ + (formName, self.db.name, self.name), Class = "fs14") + else: + setDescription = HT.Href(text="Locus %s [Chr %s @ %s Mb]" % (self.name,self.chr,\ + '%2.3f' % self.mb),url="javascript:showDatabase2('%s','%s','')" % \ + (self.db.name,self.name), Class = "fs14") + + setDescription = HT.Span(setDescription) + + else: + if self.cellid: + if formName: + setDescription = HT.Href(text="ProbeSet/%s/%s" % (self.name, self.cellid),url=\ + "javascript:showDatabase3('%s','%s','%s','%s')" % (formName, self.db.name,self.name,self.cellid), \ + Class = "fs14") + else: + setDescription = HT.Href(text="ProbeSet/%s/%s" % (self.name,self.cellid),url=\ + "javascript:showDatabase2('%s','%s','%s')" % (self.db.name,self.name,self.cellid), \ + Class = "fs14") + else: + if formName: + setDescription = HT.Href(text="ProbeSet/%s" % self.name, url=\ + "javascript:showDatabase3('%s','%s','%s','')" % (formName, self.db.name,self.name), \ + Class = "fs14") + else: + setDescription = HT.Href(text="ProbeSet/%s" % self.name, url=\ + "javascript:showDatabase2('%s','%s','')" % (self.db.name,self.name), \ + Class = "fs14") + if self.symbol and self.chr and self.mb: + setDescription.append(' [') + setDescription.append(HT.Italic('%s' % self.symbol,Class="cdg fwb")) + setDescription.append(' on Chr %s @ %s Mb]' % (self.chr,self.mb)) + if self.description: + setDescription.append(': %s' % self.description) + if self.probe_target_description: + setDescription.append('; %s' % self.probe_target_description) + setDescription = HT.Span(setDescription) + + if self.db.type != 'Temp' and dispFromDatabase: + setDescription.append( ' --- FROM : ') + setDescription.append(self.db.genHTML(Class='cori')) + return setDescription diff --git a/wqflask/basicStatistics/BasicStatisticsFunctions.py b/wqflask/basicStatistics/BasicStatisticsFunctions.py index 5cbbb145..285addae 100755 --- a/wqflask/basicStatistics/BasicStatisticsFunctions.py +++ b/wqflask/basicStatistics/BasicStatisticsFunctions.py @@ -13,162 +13,162 @@ from dbFunction import webqtlDatabaseFunction def basicStatsTable(vals, trait_type=None, cellid=None, heritability=None): - valsOnly = [] - dataXZ = vals[:] - for i in range(len(dataXZ)): - valsOnly.append(dataXZ[i][1]) - - traitmean, traitmedian, traitvar, traitstdev, traitsem, N = reaper.anova(valsOnly) #ZS: Should convert this from reaper to R in the future - - tbl = HT.TableLite(cellpadding=20, cellspacing=0) - dataXZ = vals[:] - dataXZ.sort(webqtlUtil.cmpOrder) - tbl.append(HT.TR(HT.TD("Statistic",align="left", Class="fs14 fwb ffl b1 cw cbrb", width = 180), - HT.TD("Value", align="right", Class="fs14 fwb ffl b1 cw cbrb", width = 60))) - tbl.append(HT.TR(HT.TD("N of Samples",align="left", Class="fs13 b1 cbw c222"), - HT.TD(N,nowrap="yes", Class="fs13 b1 cbw c222"), align="right")) - tbl.append(HT.TR(HT.TD("Mean",align="left", Class="fs13 b1 cbw c222",nowrap="yes"), - HT.TD("%2.3f" % traitmean,nowrap="yes", Class="fs13 b1 cbw c222"), align="right")) - tbl.append(HT.TR(HT.TD("Median",align="left", Class="fs13 b1 cbw c222",nowrap="yes"), - HT.TD("%2.3f" % traitmedian,nowrap="yes", Class="fs13 b1 cbw c222"), align="right")) - #tbl.append(HT.TR(HT.TD("Variance",align="left", Class="fs13 b1 cbw c222",nowrap="yes"), - # HT.TD("%2.3f" % traitvar,nowrap="yes",align="left", Class="fs13 b1 cbw c222"))) - tbl.append(HT.TR(HT.TD("Standard Error (SE)",align="left", Class="fs13 b1 cbw c222",nowrap="yes"), - HT.TD("%2.3f" % traitsem,nowrap="yes", Class="fs13 b1 cbw c222"), align="right")) - tbl.append(HT.TR(HT.TD("Standard Deviation (SD)", align="left", Class="fs13 b1 cbw c222",nowrap="yes"), - HT.TD("%2.3f" % traitstdev,nowrap="yes", Class="fs13 b1 cbw c222"), align="right")) - tbl.append(HT.TR(HT.TD("Minimum", align="left", Class="fs13 b1 cbw c222",nowrap="yes"), - HT.TD("%s" % dataXZ[0][1],nowrap="yes", Class="fs13 b1 cbw c222"), align="right")) - tbl.append(HT.TR(HT.TD("Maximum", align="left", Class="fs13 b1 cbw c222",nowrap="yes"), - HT.TD("%s" % dataXZ[-1][1],nowrap="yes", Class="fs13 b1 cbw c222"), align="right")) - if (trait_type != None and trait_type == 'ProbeSet'): - #IRQuest = HT.Href(text="Interquartile Range", url=webqtlConfig.glossaryfile +"#Interquartile",target="_blank", Class="fs14") - #IRQuest.append(HT.BR()) - #IRQuest.append(" (fold difference)") - tbl.append(HT.TR(HT.TD("Range (log2)",align="left", Class="fs13 b1 cbw c222",nowrap="yes"), - HT.TD("%2.3f" % (dataXZ[-1][1]-dataXZ[0][1]),nowrap="yes", Class="fs13 b1 cbw c222"), align="right")) - tbl.append(HT.TR(HT.TD(HT.Span("Range (fold)"),align="left", Class="fs13 b1 cbw c222",nowrap="yes"), - HT.TD("%2.2f" % pow(2.0,(dataXZ[-1][1]-dataXZ[0][1])), nowrap="yes", Class="fs13 b1 cbw c222"), align="right")) - tbl.append(HT.TR(HT.TD(HT.Span(HT.Href(url="/glossary.html#Interquartile", target="_blank", text="Interquartile Range", Class="non_bold")), align="left", Class="fs13 b1 cbw c222",nowrap="yes"), - HT.TD("%2.2f" % pow(2.0,(dataXZ[int((N-1)*3.0/4.0)][1]-dataXZ[int((N-1)/4.0)][1])), nowrap="yes", Class="fs13 b1 cbw c222"), align="right")) - - #XZ, 04/01/2009: don't try to get H2 value for probe. - if cellid: - pass - else: - if heritability: - tbl.append(HT.TR(HT.TD(HT.Span("Heritability"),align="center", Class="fs13 b1 cbw c222",nowrap="yes"),HT.TD("%s" % heritability, nowrap="yes",align="center", Class="fs13 b1 cbw c222"))) - else: - pass - # Lei Yan - # 2008/12/19 - - return tbl + valsOnly = [] + dataXZ = vals[:] + for i in range(len(dataXZ)): + valsOnly.append(dataXZ[i][1]) + + traitmean, traitmedian, traitvar, traitstdev, traitsem, N = reaper.anova(valsOnly) #ZS: Should convert this from reaper to R in the future + + tbl = HT.TableLite(cellpadding=20, cellspacing=0) + dataXZ = vals[:] + dataXZ.sort(webqtlUtil.cmpOrder) + tbl.append(HT.TR(HT.TD("Statistic",align="left", Class="fs14 fwb ffl b1 cw cbrb", width = 180), + HT.TD("Value", align="right", Class="fs14 fwb ffl b1 cw cbrb", width = 60))) + tbl.append(HT.TR(HT.TD("N of Samples",align="left", Class="fs13 b1 cbw c222"), + HT.TD(N,nowrap="yes", Class="fs13 b1 cbw c222"), align="right")) + tbl.append(HT.TR(HT.TD("Mean",align="left", Class="fs13 b1 cbw c222",nowrap="yes"), + HT.TD("%2.3f" % traitmean,nowrap="yes", Class="fs13 b1 cbw c222"), align="right")) + tbl.append(HT.TR(HT.TD("Median",align="left", Class="fs13 b1 cbw c222",nowrap="yes"), + HT.TD("%2.3f" % traitmedian,nowrap="yes", Class="fs13 b1 cbw c222"), align="right")) + #tbl.append(HT.TR(HT.TD("Variance",align="left", Class="fs13 b1 cbw c222",nowrap="yes"), + # HT.TD("%2.3f" % traitvar,nowrap="yes",align="left", Class="fs13 b1 cbw c222"))) + tbl.append(HT.TR(HT.TD("Standard Error (SE)",align="left", Class="fs13 b1 cbw c222",nowrap="yes"), + HT.TD("%2.3f" % traitsem,nowrap="yes", Class="fs13 b1 cbw c222"), align="right")) + tbl.append(HT.TR(HT.TD("Standard Deviation (SD)", align="left", Class="fs13 b1 cbw c222",nowrap="yes"), + HT.TD("%2.3f" % traitstdev,nowrap="yes", Class="fs13 b1 cbw c222"), align="right")) + tbl.append(HT.TR(HT.TD("Minimum", align="left", Class="fs13 b1 cbw c222",nowrap="yes"), + HT.TD("%s" % dataXZ[0][1],nowrap="yes", Class="fs13 b1 cbw c222"), align="right")) + tbl.append(HT.TR(HT.TD("Maximum", align="left", Class="fs13 b1 cbw c222",nowrap="yes"), + HT.TD("%s" % dataXZ[-1][1],nowrap="yes", Class="fs13 b1 cbw c222"), align="right")) + if (trait_type != None and trait_type == 'ProbeSet'): + #IRQuest = HT.Href(text="Interquartile Range", url=webqtlConfig.glossaryfile +"#Interquartile",target="_blank", Class="fs14") + #IRQuest.append(HT.BR()) + #IRQuest.append(" (fold difference)") + tbl.append(HT.TR(HT.TD("Range (log2)",align="left", Class="fs13 b1 cbw c222",nowrap="yes"), + HT.TD("%2.3f" % (dataXZ[-1][1]-dataXZ[0][1]),nowrap="yes", Class="fs13 b1 cbw c222"), align="right")) + tbl.append(HT.TR(HT.TD(HT.Span("Range (fold)"),align="left", Class="fs13 b1 cbw c222",nowrap="yes"), + HT.TD("%2.2f" % pow(2.0,(dataXZ[-1][1]-dataXZ[0][1])), nowrap="yes", Class="fs13 b1 cbw c222"), align="right")) + tbl.append(HT.TR(HT.TD(HT.Span(HT.Href(url="/glossary.html#Interquartile", target="_blank", text="Interquartile Range", Class="non_bold")), align="left", Class="fs13 b1 cbw c222",nowrap="yes"), + HT.TD("%2.2f" % pow(2.0,(dataXZ[int((N-1)*3.0/4.0)][1]-dataXZ[int((N-1)/4.0)][1])), nowrap="yes", Class="fs13 b1 cbw c222"), align="right")) + + #XZ, 04/01/2009: don't try to get H2 value for probe. + if cellid: + pass + else: + if heritability: + tbl.append(HT.TR(HT.TD(HT.Span("Heritability"),align="center", Class="fs13 b1 cbw c222",nowrap="yes"),HT.TD("%s" % heritability, nowrap="yes",align="center", Class="fs13 b1 cbw c222"))) + else: + pass + # Lei Yan + # 2008/12/19 + + return tbl def plotNormalProbability(vals=None, RISet='', title=None, showstrains=0, specialStrains=[None], size=(750,500)): - dataXZ = vals[:] - dataXZ.sort(webqtlUtil.cmpOrder) - dataLabel = [] - dataX = map(lambda X: X[1], dataXZ) + dataXZ = vals[:] + dataXZ.sort(webqtlUtil.cmpOrder) + dataLabel = [] + dataX = map(lambda X: X[1], dataXZ) - showLabel = showstrains - if len(dataXZ) > 50: - showLabel = 0 - for item in dataXZ: - strainName = webqtlUtil.genShortStrainName(RISet=RISet, input_strainName=item[0]) - dataLabel.append(strainName) + showLabel = showstrains + if len(dataXZ) > 50: + showLabel = 0 + for item in dataXZ: + strainName = webqtlUtil.genShortStrainName(RISet=RISet, input_strainName=item[0]) + dataLabel.append(strainName) - dataY=Plot.U(len(dataX)) - dataZ=map(Plot.inverseCumul,dataY) - c = pid.PILCanvas(size=(750,500)) - Plot.plotXY(c, dataZ, dataX, dataLabel = dataLabel, XLabel='Expected Z score', connectdot=0, YLabel='Trait value', title=title, specialCases=specialStrains, showLabel = showLabel) + dataY=Plot.U(len(dataX)) + dataZ=map(Plot.inverseCumul,dataY) + c = pid.PILCanvas(size=(750,500)) + Plot.plotXY(c, dataZ, dataX, dataLabel = dataLabel, XLabel='Expected Z score', connectdot=0, YLabel='Trait value', title=title, specialCases=specialStrains, showLabel = showLabel) - filename= webqtlUtil.genRandStr("nP_") - c.save(webqtlConfig.IMGDIR+filename, format='gif') + filename= webqtlUtil.genRandStr("nP_") + c.save(webqtlConfig.IMGDIR+filename, format='gif') - img=HT.Image('/image/'+filename+'.gif',border=0) + img=HT.Image('/image/'+filename+'.gif',border=0) - return img + return img def plotBoxPlot(vals): - valsOnly = [] - dataXZ = vals[:] - for i in range(len(dataXZ)): - valsOnly.append(dataXZ[i][1]) + valsOnly = [] + dataXZ = vals[:] + for i in range(len(dataXZ)): + valsOnly.append(dataXZ[i][1]) - plotHeight = 320 - plotWidth = 220 - xLeftOffset = 60 - xRightOffset = 40 - yTopOffset = 40 - yBottomOffset = 60 + plotHeight = 320 + plotWidth = 220 + xLeftOffset = 60 + xRightOffset = 40 + yTopOffset = 40 + yBottomOffset = 60 - canvasHeight = plotHeight + yTopOffset + yBottomOffset - canvasWidth = plotWidth + xLeftOffset + xRightOffset - canvas = pid.PILCanvas(size=(canvasWidth,canvasHeight)) - XXX = [('', valsOnly[:])] + canvasHeight = plotHeight + yTopOffset + yBottomOffset + canvasWidth = plotWidth + xLeftOffset + xRightOffset + canvas = pid.PILCanvas(size=(canvasWidth,canvasHeight)) + XXX = [('', valsOnly[:])] - Plot.plotBoxPlot(canvas, XXX, offset=(xLeftOffset, xRightOffset, yTopOffset, yBottomOffset), XLabel= "Trait") - filename= webqtlUtil.genRandStr("Box_") - canvas.save(webqtlConfig.IMGDIR+filename, format='gif') - img=HT.Image('/image/'+filename+'.gif',border=0) + Plot.plotBoxPlot(canvas, XXX, offset=(xLeftOffset, xRightOffset, yTopOffset, yBottomOffset), XLabel= "Trait") + filename= webqtlUtil.genRandStr("Box_") + canvas.save(webqtlConfig.IMGDIR+filename, format='gif') + img=HT.Image('/image/'+filename+'.gif',border=0) - plotLink = HT.Span("More about ", HT.Href(text="Box Plots", url="http://davidmlane.com/hyperstat/A37797.html", target="_blank", Class="fs13")) + plotLink = HT.Span("More about ", HT.Href(text="Box Plots", url="http://davidmlane.com/hyperstat/A37797.html", target="_blank", Class="fs13")) - return img, plotLink + return img, plotLink def plotBarGraph(identification='', RISet='', vals=None, type="name"): - this_identification = "unnamed trait" - if identification: - this_identification = identification - - if type=="rank": - dataXZ = vals[:] - dataXZ.sort(webqtlUtil.cmpOrder) - title='%s' % this_identification - else: - dataXZ = vals[:] - title='%s' % this_identification - - tvals = [] - tnames = [] - tvars = [] - for i in range(len(dataXZ)): - tvals.append(dataXZ[i][1]) - tnames.append(webqtlUtil.genShortStrainName(RISet=RISet, input_strainName=dataXZ[i][0])) - tvars.append(dataXZ[i][2]) - nnStrain = len(tnames) - - sLabel = 1 - - ###determine bar width and space width - if nnStrain < 20: - sw = 4 - elif nnStrain < 40: - sw = 3 - else: - sw = 2 - - ### 700 is the default plot width minus Xoffsets for 40 strains - defaultWidth = 650 - if nnStrain > 40: - defaultWidth += (nnStrain-40)*10 - defaultOffset = 100 - bw = int(0.5+(defaultWidth - (nnStrain-1.0)*sw)/nnStrain) - if bw < 10: - bw = 10 - - plotWidth = (nnStrain-1)*sw + nnStrain*bw + defaultOffset - plotHeight = 500 - #print [plotWidth, plotHeight, bw, sw, nnStrain] - c = pid.PILCanvas(size=(plotWidth,plotHeight)) - Plot.plotBarText(c, tvals, tnames, variance=tvars, YLabel='Value', title=title, sLabel = sLabel, barSpace = sw) - - filename= webqtlUtil.genRandStr("Bar_") - c.save(webqtlConfig.IMGDIR+filename, format='gif') - img=HT.Image('/image/'+filename+'.gif',border=0) - - return img + this_identification = "unnamed trait" + if identification: + this_identification = identification + + if type=="rank": + dataXZ = vals[:] + dataXZ.sort(webqtlUtil.cmpOrder) + title='%s' % this_identification + else: + dataXZ = vals[:] + title='%s' % this_identification + + tvals = [] + tnames = [] + tvars = [] + for i in range(len(dataXZ)): + tvals.append(dataXZ[i][1]) + tnames.append(webqtlUtil.genShortStrainName(RISet=RISet, input_strainName=dataXZ[i][0])) + tvars.append(dataXZ[i][2]) + nnStrain = len(tnames) + + sLabel = 1 + + ###determine bar width and space width + if nnStrain < 20: + sw = 4 + elif nnStrain < 40: + sw = 3 + else: + sw = 2 + + ### 700 is the default plot width minus Xoffsets for 40 strains + defaultWidth = 650 + if nnStrain > 40: + defaultWidth += (nnStrain-40)*10 + defaultOffset = 100 + bw = int(0.5+(defaultWidth - (nnStrain-1.0)*sw)/nnStrain) + if bw < 10: + bw = 10 + + plotWidth = (nnStrain-1)*sw + nnStrain*bw + defaultOffset + plotHeight = 500 + #print [plotWidth, plotHeight, bw, sw, nnStrain] + c = pid.PILCanvas(size=(plotWidth,plotHeight)) + Plot.plotBarText(c, tvals, tnames, variance=tvars, YLabel='Value', title=title, sLabel = sLabel, barSpace = sw) + + filename= webqtlUtil.genRandStr("Bar_") + c.save(webqtlConfig.IMGDIR+filename, format='gif') + img=HT.Image('/image/'+filename+'.gif',border=0) + + return img diff --git a/wqflask/basicStatistics/BasicStatisticsPage_alpha.py b/wqflask/basicStatistics/BasicStatisticsPage_alpha.py index 4ba9d54a..365143db 100755 --- a/wqflask/basicStatistics/BasicStatisticsPage_alpha.py +++ b/wqflask/basicStatistics/BasicStatisticsPage_alpha.py @@ -43,306 +43,302 @@ from dbFunction import webqtlDatabaseFunction class BasicStatisticsPage_alpha(templatePage): - plotMinInformative = 4 - - def __init__(self, fd): - - templatePage.__init__(self, fd) - - if not fd.genotype: - fd.readGenotype() - strainlist2 = fd.strainlist - - if fd.allstrainlist: - strainlist2 = fd.allstrainlist - - fd.readData(strainlist2) - - specialStrains = [] - setStrains = [] - for item in strainlist2: - if item not in fd.strainlist and item.find('F1') < 0: - specialStrains.append(item) - else: - setStrains.append(item) - specialStrains.sort() - #So called MDP Panel - if specialStrains: - specialStrains = fd.f1list+fd.parlist+specialStrains - - self.plotType = fd.formdata.getvalue('ptype', '0') - plotStrains = strainlist2 - if specialStrains: - if self.plotType == '1': - plotStrains = setStrains - if self.plotType == '2': - plotStrains = specialStrains - - self.dict['title'] = 'Basic Statistics' - if not self.openMysql(): - return - - self.showstrains = 1 - self.identification = "unnamed trait" - - self.fullname = fd.formdata.getvalue('fullname', '') - if self.fullname: - self.Trait = webqtlTrait(fullname=self.fullname, cursor=self.cursor) - self.Trait.retrieveInfo() - else: - self.Trait = None - - if fd.identification: - self.identification = fd.identification - self.dict['title'] = self.identification + ' / '+self.dict['title'] - TD_LR = HT.TD(height=200,width="100%",bgColor='#eeeeee') - - ##should not display Variance, but cannot convert Variance to SE - #print plotStrains, fd.allTraitData.keys() - if len(fd.allTraitData) > 0: - vals=[] - InformData = [] - for _strain in plotStrains: - if fd.allTraitData.has_key(_strain): - _val, _var = fd.allTraitData[_strain].val, fd.allTraitData[_strain].var - if _val != None: - vals.append([_strain, _val, _var]) - InformData.append(_val) - - if len(vals) >= self.plotMinInformative: - supertable2 = HT.TableLite(border=0, cellspacing=0, cellpadding=5,width="800") - - staIntro1 = HT.Paragraph("The table and plots below list the basic statistical analysis result of trait",HT.Strong(" %s" % self.identification)) - - ##### - #anova - ##### - traitmean, traitmedian, traitvar, traitstdev, traitsem, N = reaper.anova(InformData) - TDStatis = HT.TD(width="360", valign="top") - tbl2 = HT.TableLite(cellpadding=5, cellspacing=0, Class="collap") - dataXZ = vals[:] - dataXZ.sort(self.cmpValue) - tbl2.append(HT.TR(HT.TD("Statistic",align="center", Class="fs14 fwb ffl b1 cw cbrb", width = 200), - HT.TD("Value", align="center", Class="fs14 fwb ffl b1 cw cbrb", width = 140))) - tbl2.append(HT.TR(HT.TD("N of Cases",align="center", Class="fs13 b1 cbw c222"), - HT.TD(N,nowrap="yes",align="center", Class="fs13 b1 cbw c222"))) - tbl2.append(HT.TR(HT.TD("Mean",align="center", Class="fs13 b1 cbw c222",nowrap="yes"), - HT.TD("%2.3f" % traitmean,nowrap="yes",align="center", Class="fs13 b1 cbw c222"))) - tbl2.append(HT.TR(HT.TD("Median",align="center", Class="fs13 b1 cbw c222",nowrap="yes"), - HT.TD("%2.3f" % traitmedian,nowrap="yes",align="center", Class="fs13 b1 cbw c222"))) - #tbl2.append(HT.TR(HT.TD("Variance",align="center", Class="fs13 b1 cbw c222",nowrap="yes"), - # HT.TD("%2.3f" % traitvar,nowrap="yes",align="center", Class="fs13 b1 cbw c222"))) - tbl2.append(HT.TR(HT.TD("SEM",align="center", Class="fs13 b1 cbw c222",nowrap="yes"), - HT.TD("%2.3f" % traitsem,nowrap="yes",align="center", Class="fs13 b1 cbw c222"))) - tbl2.append(HT.TR(HT.TD("SD",align="center", Class="fs13 b1 cbw c222",nowrap="yes"), - HT.TD("%2.3f" % traitstdev,nowrap="yes",align="center", Class="fs13 b1 cbw c222"))) - tbl2.append(HT.TR(HT.TD("Minimum",align="center", Class="fs13 b1 cbw c222",nowrap="yes"), - HT.TD("%s" % dataXZ[0][1],nowrap="yes",align="center", Class="fs13 b1 cbw c222"))) - tbl2.append(HT.TR(HT.TD("Maximum",align="center", Class="fs13 b1 cbw c222",nowrap="yes"), - HT.TD("%s" % dataXZ[-1][1],nowrap="yes",align="center", Class="fs13 b1 cbw c222"))) - if self.Trait and self.Trait.db.type == 'ProbeSet': - #IRQuest = HT.Href(text="Interquartile Range", url=webqtlConfig.glossaryfile +"#Interquartile",target="_blank", Class="fs14") - #IRQuest.append(HT.BR()) - #IRQuest.append(" (fold difference)") - tbl2.append(HT.TR(HT.TD("Range (log2)",align="center", Class="fs13 b1 cbw c222",nowrap="yes"), - HT.TD("%2.3f" % (dataXZ[-1][1]-dataXZ[0][1]),nowrap="yes",align="center", Class="fs13 b1 cbw c222"))) - tbl2.append(HT.TR(HT.TD(HT.Span("Range (fold)"),align="center", Class="fs13 b1 cbw c222",nowrap="yes"), - HT.TD("%2.2f" % pow(2.0,(dataXZ[-1][1]-dataXZ[0][1])), nowrap="yes",align="center", Class="fs13 b1 cbw c222"))) - tbl2.append(HT.TR(HT.TD(HT.Span("Quartile Range",HT.BR()," (fold difference)"),align="center", Class="fs13 b1 cbw c222",nowrap="yes"), - HT.TD("%2.2f" % pow(2.0,(dataXZ[int((N-1)*3.0/4.0)][1]-dataXZ[int((N-1)/4.0)][1])), nowrap="yes",align="center", Class="fs13 b1 cbw c222"))) - - # (Lei Yan) - # 2008/12/19 - self.Trait.retrieveData() - #XZ, 04/01/2009: don't try to get H2 value for probe. - if self.Trait.cellid: - pass - else: - self.cursor.execute("SELECT DataId, h2 from ProbeSetXRef WHERE DataId = %d" % self.Trait.mysqlid) - dataid, heritability = self.cursor.fetchone() - if heritability: - tbl2.append(HT.TR(HT.TD(HT.Span("Heritability"),align="center", Class="fs13 b1 cbw c222",nowrap="yes"),HT.TD("%s" % heritability, nowrap="yes",align="center", Class="fs13 b1 cbw c222"))) - else: - tbl2.append(HT.TR(HT.TD(HT.Span("Heritability"),align="center", Class="fs13 b1 cbw c222",nowrap="yes"),HT.TD("NaN", nowrap="yes",align="center", Class="fs13 b1 cbw c222"))) - - # Lei Yan - # 2008/12/19 - - TDStatis.append(tbl2) - - plotHeight = 220 - plotWidth = 120 - xLeftOffset = 60 - xRightOffset = 25 - yTopOffset = 20 - yBottomOffset = 53 - - canvasHeight = plotHeight + yTopOffset + yBottomOffset - canvasWidth = plotWidth + xLeftOffset + xRightOffset - canvas = pid.PILCanvas(size=(canvasWidth,canvasHeight)) - XXX = [('', InformData[:])] - - Plot.plotBoxPlot(canvas, XXX, offset=(xLeftOffset, xRightOffset, yTopOffset, yBottomOffset), XLabel= "Trait") - filename= webqtlUtil.genRandStr("Box_") - canvas.save(webqtlConfig.IMGDIR+filename, format='gif') - img=HT.Image('/image/'+filename+'.gif',border=0) - - #supertable2.append(HT.TR(HT.TD(staIntro1, colspan=3 ))) - tb = HT.TableLite(border=0, cellspacing=0, cellpadding=0) - tb.append(HT.TR(HT.TD(img, align="left", style="border: 1px solid #999999; padding:0px;"))) - supertable2.append(HT.TR(TDStatis, HT.TD(tb))) - - dataXZ = vals[:] - tvals = [] - tnames = [] - tvars = [] - for i in range(len(dataXZ)): - tvals.append(dataXZ[i][1]) - tnames.append(webqtlUtil.genShortStrainName(fd, dataXZ[i][0])) - tvars.append(dataXZ[i][2]) - nnStrain = len(tnames) - - sLabel = 1 - - ###determine bar width and space width - if nnStrain < 20: - sw = 4 - elif nnStrain < 40: - sw = 3 - else: - sw = 2 - - ### 700 is the default plot width minus Xoffsets for 40 strains - defaultWidth = 650 - if nnStrain > 40: - defaultWidth += (nnStrain-40)*10 - defaultOffset = 100 - bw = int(0.5+(defaultWidth - (nnStrain-1.0)*sw)/nnStrain) - if bw < 10: - bw = 10 - - plotWidth = (nnStrain-1)*sw + nnStrain*bw + defaultOffset - plotHeight = 500 - #print [plotWidth, plotHeight, bw, sw, nnStrain] - c = pid.PILCanvas(size=(plotWidth,plotHeight)) - Plot.plotBarText(c, tvals, tnames, variance=tvars, YLabel='Value', title='%s by Case (sorted by name)' % self.identification, sLabel = sLabel, barSpace = sw) - - filename= webqtlUtil.genRandStr("Bar_") - c.save(webqtlConfig.IMGDIR+filename, format='gif') - img0=HT.Image('/image/'+filename+'.gif',border=0) - - dataXZ = vals[:] - dataXZ.sort(self.cmpValue) - tvals = [] - tnames = [] - tvars = [] - for i in range(len(dataXZ)): - tvals.append(dataXZ[i][1]) - tnames.append(webqtlUtil.genShortStrainName(fd, dataXZ[i][0])) - tvars.append(dataXZ[i][2]) - - c = pid.PILCanvas(size=(plotWidth,plotHeight)) - Plot.plotBarText(c, tvals, tnames, variance=tvars, YLabel='Value', title='%s by Case (ranked)' % self.identification, sLabel = sLabel, barSpace = sw) - - filename= webqtlUtil.genRandStr("Bar_") - c.save(webqtlConfig.IMGDIR+filename, format='gif') - img1=HT.Image('/image/'+filename+'.gif',border=0) - - # Lei Yan - # 05/18/2009 - # report - - title = HT.Paragraph('REPORT on the variation of Shh (or PCA Composite Trait XXXX) (sonic hedgehog) in the (insert Data set name) of (insert Species informal name, e.g., Mouse, Rat, Human, Barley, Arabidopsis)', Class="title") - header = HT.Paragraph('''This report was generated by GeneNetwork on May 11, 2009, at 11.20 AM using the Basic Statistics module (v 1.0) and data from the Hippocampus Consortium M430v2 (Jun06) PDNN data set. For more details and updates on this data set please link to URL:get Basic Statistics''') - hr = HT.HR() - p1 = HT.Paragraph('''Trait values for Shh were taken from the (insert Database name, Hippocampus Consortium M430v2 (Jun06) PDNN). GeneNetwork contains data for NN (e.g., 99) cases. In general, data are averages for each case. A summary of mean, median, and the range of these data are provided in Table 1 and in the box plot (Figure 1). Data for individual cases are provided in Figure 2A and 2B, often with error bars (SEM). ''') - p2 = HT.Paragraph('''Trait values for Shh range 5.1-fold: from a low of 8.2 (please round value) in 129S1/SvImJ to a high of 10.6 (please round value) in BXD9. The interquartile range (the difference between values closest to the 25% and 75% levels) is a more modest 1.8-fold. The mean value is XX. ''') - t1 = HT.Paragraph('''Table 1. Summary of Shh data from the Hippocampus Consortium M430v2 (june06) PDNN data set''') - f1 = HT.Paragraph('''Figure 1. ''') - f1.append(HT.Href(text="Box plot", url="http://davidmlane.com/hyperstat/A37797.html", target="_blank", Class="fs14")) - f1.append(HT.Text(''' of Shh data from the Hippocampus Consortium M430v2 (june06) PDNN data set''')) - f2A = HT.Paragraph('''Figure 2A: Bar chart of Shh data ordered by case from the Hippocampus Consortium M430v2 (june06) PDNN data set''') - f2B = HT.Paragraph('''Figure 2B: Bar chart of Shh values ordered by from the Hippocampus Consortium M430v2 (june06) PDNN data set''') - TD_LR.append(HT.Blockquote(title, HT.P(), header, hr, p1, HT.P(), p2, HT.P(), supertable2, t1, f1, HT.P(), img0, f2A, HT.P(), img1, f2B)) - self.dict['body'] = str(TD_LR) - else: - heading = "Basic Statistics" - detail = ['Fewer than %d case data were entered for %s data set. No statitical analysis has been attempted.' % (self.plotMinInformative, fd.RISet)] - self.error(heading=heading,detail=detail) - return - else: - heading = "Basic Statistics" - detail = ['Empty data set, please check your data.'] - self.error(heading=heading,detail=detail) - return - - def traitInfo(self, fd, specialStrains = None): - species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, RISet=fd.RISet) - heading2 = HT.Paragraph(HT.Strong('Population: '), "%s %s" % (species.title(), fd.RISet) , HT.BR()) - if self.Trait: - trait_url = HT.Href(text=self.Trait.name, url = os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE) + \ - "?FormID=showDatabase&incparentsf1=1&database=%s&ProbeSetID=%s" % (self.Trait.db.name, self.Trait.name), \ - target='_blank', Class="fs13 fwn") - heading2.append(HT.Strong("Database: "), - HT.Href(text=self.Trait.db.fullname, url = webqtlConfig.INFOPAGEHREF % self.Trait.db.name , - target='_blank',Class="fs13 fwn"),HT.BR()) - if self.Trait.db.type == 'ProbeSet': - heading2.append(HT.Strong('Trait ID: '), trait_url, HT.BR(), - HT.Strong("Gene Symbol: "), HT.Italic('%s' % self.Trait.symbol,id="green"),HT.BR()) - if self.Trait.chr and self.Trait.mb: - heading2.append(HT.Strong("Location: "), 'Chr %s @ %s Mb' % (self.Trait.chr, self.Trait.mb)) - elif self.Trait.db.type == 'Geno': - heading2.append(HT.Strong('Locus : '), trait_url, HT.BR()) - #heading2.append(HT.Strong("Gene Symbol: "), HT.Italic('%s' % self.Trait.Symbol,id="green"),HT.BR()) - if self.Trait.chr and self.Trait.mb: - heading2.append(HT.Strong("Location: "), 'Chr %s @ %s Mb' % (self.Trait.chr, self.Trait.mb)) - elif self.Trait.db.type == 'Publish': - heading2.append(HT.Strong('Record ID: '), trait_url, HT.BR()) - heading2.append(HT.Strong('Phenotype: '), self.Trait.phenotype, HT.BR()) - heading2.append(HT.Strong('Author: '), self.Trait.authors, HT.BR()) - elif self.Trait.db.type == 'Temp': - heading2.append(HT.Strong('Description: '), self.Trait.description, HT.BR()) - #heading2.append(HT.Strong('Author: '), self.Trait.authors, HT.BR()) - else: - pass - else: - heading2.append(HT.Strong("Trait Name: "), fd.identification) - - if specialStrains: - mdpform = HT.Form(cgi= os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), name='MDP_Form',submit=HT.Input(type='hidden')) - mdphddn = {'FormID':'dataEditing', 'submitID':'basicStatistics','RISet':fd.RISet, "allstrainlist":string.join(fd.allstrainlist, " "), "ptype":self.plotType, 'identification':fd.identification, "incparentsf1":1} - if self.fullname: mdphddn['fullname'] = self.fullname - webqtlUtil.exportData(mdphddn, fd.allTraitData) - for key in mdphddn.keys(): - mdpform.append(HT.Input(name=key, value=mdphddn[key], type='hidden')) - btn0 = HT.Input(type='button' ,name='',value='All Cases',onClick="this.form.ptype.value=0;submit();", Class="button") - btn1 = HT.Input(type='button' ,name='',value='%s Only' % fd.RISet,onClick="this.form.ptype.value=1;submit();", Class="button") - btn2 = HT.Input(type='button' ,name='',value='MDP Only', onClick="this.form.ptype.value=2;submit();", Class="button") - mdpform.append(btn0) - mdpform.append(btn1) - mdpform.append(btn2) - heading2.append(HT.P(), mdpform) - - return HT.Span(heading2) - - def calSD(self,var): - try: - return sqrt(abs(var)) - except: - return None - - - def cmpValue(self,A,B): - try: - if A[1] < B[1]: - return -1 - elif A[1] == B[1]: - return 0 - else: - return 1 - except: - return 0 - - - - + plotMinInformative = 4 + + def __init__(self, fd): + + templatePage.__init__(self, fd) + + if not fd.genotype: + fd.readGenotype() + strainlist2 = fd.strainlist + + if fd.allstrainlist: + strainlist2 = fd.allstrainlist + + fd.readData(strainlist2) + + specialStrains = [] + setStrains = [] + for item in strainlist2: + if item not in fd.strainlist and item.find('F1') < 0: + specialStrains.append(item) + else: + setStrains.append(item) + specialStrains.sort() + #So called MDP Panel + if specialStrains: + specialStrains = fd.f1list+fd.parlist+specialStrains + + self.plotType = fd.formdata.getvalue('ptype', '0') + plotStrains = strainlist2 + if specialStrains: + if self.plotType == '1': + plotStrains = setStrains + if self.plotType == '2': + plotStrains = specialStrains + + self.dict['title'] = 'Basic Statistics' + if not self.openMysql(): + return + + self.showstrains = 1 + self.identification = "unnamed trait" + + self.fullname = fd.formdata.getvalue('fullname', '') + if self.fullname: + self.Trait = webqtlTrait(fullname=self.fullname, cursor=self.cursor) + self.Trait.retrieveInfo() + else: + self.Trait = None + + if fd.identification: + self.identification = fd.identification + self.dict['title'] = self.identification + ' / '+self.dict['title'] + TD_LR = HT.TD(height=200,width="100%",bgColor='#eeeeee') + + ##should not display Variance, but cannot convert Variance to SE + #print plotStrains, fd.allTraitData.keys() + if len(fd.allTraitData) > 0: + vals=[] + InformData = [] + for _strain in plotStrains: + if fd.allTraitData.has_key(_strain): + _val, _var = fd.allTraitData[_strain].val, fd.allTraitData[_strain].var + if _val != None: + vals.append([_strain, _val, _var]) + InformData.append(_val) + + if len(vals) >= self.plotMinInformative: + supertable2 = HT.TableLite(border=0, cellspacing=0, cellpadding=5,width="800") + + staIntro1 = HT.Paragraph("The table and plots below list the basic statistical analysis result of trait",HT.Strong(" %s" % self.identification)) + + ##### + #anova + ##### + traitmean, traitmedian, traitvar, traitstdev, traitsem, N = reaper.anova(InformData) + TDStatis = HT.TD(width="360", valign="top") + tbl2 = HT.TableLite(cellpadding=5, cellspacing=0, Class="collap") + dataXZ = vals[:] + dataXZ.sort(self.cmpValue) + tbl2.append(HT.TR(HT.TD("Statistic",align="center", Class="fs14 fwb ffl b1 cw cbrb", width = 200), + HT.TD("Value", align="center", Class="fs14 fwb ffl b1 cw cbrb", width = 140))) + tbl2.append(HT.TR(HT.TD("N of Cases",align="center", Class="fs13 b1 cbw c222"), + HT.TD(N,nowrap="yes",align="center", Class="fs13 b1 cbw c222"))) + tbl2.append(HT.TR(HT.TD("Mean",align="center", Class="fs13 b1 cbw c222",nowrap="yes"), + HT.TD("%2.3f" % traitmean,nowrap="yes",align="center", Class="fs13 b1 cbw c222"))) + tbl2.append(HT.TR(HT.TD("Median",align="center", Class="fs13 b1 cbw c222",nowrap="yes"), + HT.TD("%2.3f" % traitmedian,nowrap="yes",align="center", Class="fs13 b1 cbw c222"))) + #tbl2.append(HT.TR(HT.TD("Variance",align="center", Class="fs13 b1 cbw c222",nowrap="yes"), + # HT.TD("%2.3f" % traitvar,nowrap="yes",align="center", Class="fs13 b1 cbw c222"))) + tbl2.append(HT.TR(HT.TD("SEM",align="center", Class="fs13 b1 cbw c222",nowrap="yes"), + HT.TD("%2.3f" % traitsem,nowrap="yes",align="center", Class="fs13 b1 cbw c222"))) + tbl2.append(HT.TR(HT.TD("SD",align="center", Class="fs13 b1 cbw c222",nowrap="yes"), + HT.TD("%2.3f" % traitstdev,nowrap="yes",align="center", Class="fs13 b1 cbw c222"))) + tbl2.append(HT.TR(HT.TD("Minimum",align="center", Class="fs13 b1 cbw c222",nowrap="yes"), + HT.TD("%s" % dataXZ[0][1],nowrap="yes",align="center", Class="fs13 b1 cbw c222"))) + tbl2.append(HT.TR(HT.TD("Maximum",align="center", Class="fs13 b1 cbw c222",nowrap="yes"), + HT.TD("%s" % dataXZ[-1][1],nowrap="yes",align="center", Class="fs13 b1 cbw c222"))) + if self.Trait and self.Trait.db.type == 'ProbeSet': + #IRQuest = HT.Href(text="Interquartile Range", url=webqtlConfig.glossaryfile +"#Interquartile",target="_blank", Class="fs14") + #IRQuest.append(HT.BR()) + #IRQuest.append(" (fold difference)") + tbl2.append(HT.TR(HT.TD("Range (log2)",align="center", Class="fs13 b1 cbw c222",nowrap="yes"), + HT.TD("%2.3f" % (dataXZ[-1][1]-dataXZ[0][1]),nowrap="yes",align="center", Class="fs13 b1 cbw c222"))) + tbl2.append(HT.TR(HT.TD(HT.Span("Range (fold)"),align="center", Class="fs13 b1 cbw c222",nowrap="yes"), + HT.TD("%2.2f" % pow(2.0,(dataXZ[-1][1]-dataXZ[0][1])), nowrap="yes",align="center", Class="fs13 b1 cbw c222"))) + tbl2.append(HT.TR(HT.TD(HT.Span("Quartile Range",HT.BR()," (fold difference)"),align="center", Class="fs13 b1 cbw c222",nowrap="yes"), + HT.TD("%2.2f" % pow(2.0,(dataXZ[int((N-1)*3.0/4.0)][1]-dataXZ[int((N-1)/4.0)][1])), nowrap="yes",align="center", Class="fs13 b1 cbw c222"))) + + # (Lei Yan) + # 2008/12/19 + self.Trait.retrieveData() + #XZ, 04/01/2009: don't try to get H2 value for probe. + if self.Trait.cellid: + pass + else: + self.cursor.execute("SELECT DataId, h2 from ProbeSetXRef WHERE DataId = %d" % self.Trait.mysqlid) + dataid, heritability = self.cursor.fetchone() + if heritability: + tbl2.append(HT.TR(HT.TD(HT.Span("Heritability"),align="center", Class="fs13 b1 cbw c222",nowrap="yes"),HT.TD("%s" % heritability, nowrap="yes",align="center", Class="fs13 b1 cbw c222"))) + else: + tbl2.append(HT.TR(HT.TD(HT.Span("Heritability"),align="center", Class="fs13 b1 cbw c222",nowrap="yes"),HT.TD("NaN", nowrap="yes",align="center", Class="fs13 b1 cbw c222"))) + + # Lei Yan + # 2008/12/19 + + TDStatis.append(tbl2) + + plotHeight = 220 + plotWidth = 120 + xLeftOffset = 60 + xRightOffset = 25 + yTopOffset = 20 + yBottomOffset = 53 + + canvasHeight = plotHeight + yTopOffset + yBottomOffset + canvasWidth = plotWidth + xLeftOffset + xRightOffset + canvas = pid.PILCanvas(size=(canvasWidth,canvasHeight)) + XXX = [('', InformData[:])] + + Plot.plotBoxPlot(canvas, XXX, offset=(xLeftOffset, xRightOffset, yTopOffset, yBottomOffset), XLabel= "Trait") + filename= webqtlUtil.genRandStr("Box_") + canvas.save(webqtlConfig.IMGDIR+filename, format='gif') + img=HT.Image('/image/'+filename+'.gif',border=0) + + #supertable2.append(HT.TR(HT.TD(staIntro1, colspan=3 ))) + tb = HT.TableLite(border=0, cellspacing=0, cellpadding=0) + tb.append(HT.TR(HT.TD(img, align="left", style="border: 1px solid #999999; padding:0px;"))) + supertable2.append(HT.TR(TDStatis, HT.TD(tb))) + + dataXZ = vals[:] + tvals = [] + tnames = [] + tvars = [] + for i in range(len(dataXZ)): + tvals.append(dataXZ[i][1]) + tnames.append(webqtlUtil.genShortStrainName(fd, dataXZ[i][0])) + tvars.append(dataXZ[i][2]) + nnStrain = len(tnames) + + sLabel = 1 + + ###determine bar width and space width + if nnStrain < 20: + sw = 4 + elif nnStrain < 40: + sw = 3 + else: + sw = 2 + + ### 700 is the default plot width minus Xoffsets for 40 strains + defaultWidth = 650 + if nnStrain > 40: + defaultWidth += (nnStrain-40)*10 + defaultOffset = 100 + bw = int(0.5+(defaultWidth - (nnStrain-1.0)*sw)/nnStrain) + if bw < 10: + bw = 10 + + plotWidth = (nnStrain-1)*sw + nnStrain*bw + defaultOffset + plotHeight = 500 + #print [plotWidth, plotHeight, bw, sw, nnStrain] + c = pid.PILCanvas(size=(plotWidth,plotHeight)) + Plot.plotBarText(c, tvals, tnames, variance=tvars, YLabel='Value', title='%s by Case (sorted by name)' % self.identification, sLabel = sLabel, barSpace = sw) + + filename= webqtlUtil.genRandStr("Bar_") + c.save(webqtlConfig.IMGDIR+filename, format='gif') + img0=HT.Image('/image/'+filename+'.gif',border=0) + + dataXZ = vals[:] + dataXZ.sort(self.cmpValue) + tvals = [] + tnames = [] + tvars = [] + for i in range(len(dataXZ)): + tvals.append(dataXZ[i][1]) + tnames.append(webqtlUtil.genShortStrainName(fd, dataXZ[i][0])) + tvars.append(dataXZ[i][2]) + + c = pid.PILCanvas(size=(plotWidth,plotHeight)) + Plot.plotBarText(c, tvals, tnames, variance=tvars, YLabel='Value', title='%s by Case (ranked)' % self.identification, sLabel = sLabel, barSpace = sw) + + filename= webqtlUtil.genRandStr("Bar_") + c.save(webqtlConfig.IMGDIR+filename, format='gif') + img1=HT.Image('/image/'+filename+'.gif',border=0) + + # Lei Yan + # 05/18/2009 + # report + + title = HT.Paragraph('REPORT on the variation of Shh (or PCA Composite Trait XXXX) (sonic hedgehog) in the (insert Data set name) of (insert Species informal name, e.g., Mouse, Rat, Human, Barley, Arabidopsis)', Class="title") + header = HT.Paragraph('''This report was generated by GeneNetwork on May 11, 2009, at 11.20 AM using the Basic Statistics module (v 1.0) and data from the Hippocampus Consortium M430v2 (Jun06) PDNN data set. For more details and updates on this data set please link to URL:get Basic Statistics''') + hr = HT.HR() + p1 = HT.Paragraph('''Trait values for Shh were taken from the (insert Database name, Hippocampus Consortium M430v2 (Jun06) PDNN). GeneNetwork contains data for NN (e.g., 99) cases. In general, data are averages for each case. A summary of mean, median, and the range of these data are provided in Table 1 and in the box plot (Figure 1). Data for individual cases are provided in Figure 2A and 2B, often with error bars (SEM). ''') + p2 = HT.Paragraph('''Trait values for Shh range 5.1-fold: from a low of 8.2 (please round value) in 129S1/SvImJ to a high of 10.6 (please round value) in BXD9. The interquartile range (the difference between values closest to the 25% and 75% levels) is a more modest 1.8-fold. The mean value is XX. ''') + t1 = HT.Paragraph('''Table 1. Summary of Shh data from the Hippocampus Consortium M430v2 (june06) PDNN data set''') + f1 = HT.Paragraph('''Figure 1. ''') + f1.append(HT.Href(text="Box plot", url="http://davidmlane.com/hyperstat/A37797.html", target="_blank", Class="fs14")) + f1.append(HT.Text(''' of Shh data from the Hippocampus Consortium M430v2 (june06) PDNN data set''')) + f2A = HT.Paragraph('''Figure 2A: Bar chart of Shh data ordered by case from the Hippocampus Consortium M430v2 (june06) PDNN data set''') + f2B = HT.Paragraph('''Figure 2B: Bar chart of Shh values ordered by from the Hippocampus Consortium M430v2 (june06) PDNN data set''') + TD_LR.append(HT.Blockquote(title, HT.P(), header, hr, p1, HT.P(), p2, HT.P(), supertable2, t1, f1, HT.P(), img0, f2A, HT.P(), img1, f2B)) + self.dict['body'] = str(TD_LR) + else: + heading = "Basic Statistics" + detail = ['Fewer than %d case data were entered for %s data set. No statitical analysis has been attempted.' % (self.plotMinInformative, fd.RISet)] + self.error(heading=heading,detail=detail) + return + else: + heading = "Basic Statistics" + detail = ['Empty data set, please check your data.'] + self.error(heading=heading,detail=detail) + return + + def traitInfo(self, fd, specialStrains = None): + species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, RISet=fd.RISet) + heading2 = HT.Paragraph(HT.Strong('Population: '), "%s %s" % (species.title(), fd.RISet) , HT.BR()) + if self.Trait: + trait_url = HT.Href(text=self.Trait.name, url = os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE) + \ + "?FormID=showDatabase&incparentsf1=1&database=%s&ProbeSetID=%s" % (self.Trait.db.name, self.Trait.name), \ + target='_blank', Class="fs13 fwn") + heading2.append(HT.Strong("Database: "), + HT.Href(text=self.Trait.db.fullname, url = webqtlConfig.INFOPAGEHREF % self.Trait.db.name , + target='_blank',Class="fs13 fwn"),HT.BR()) + if self.Trait.db.type == 'ProbeSet': + heading2.append(HT.Strong('Trait ID: '), trait_url, HT.BR(), + HT.Strong("Gene Symbol: "), HT.Italic('%s' % self.Trait.symbol,id="green"),HT.BR()) + if self.Trait.chr and self.Trait.mb: + heading2.append(HT.Strong("Location: "), 'Chr %s @ %s Mb' % (self.Trait.chr, self.Trait.mb)) + elif self.Trait.db.type == 'Geno': + heading2.append(HT.Strong('Locus : '), trait_url, HT.BR()) + #heading2.append(HT.Strong("Gene Symbol: "), HT.Italic('%s' % self.Trait.Symbol,id="green"),HT.BR()) + if self.Trait.chr and self.Trait.mb: + heading2.append(HT.Strong("Location: "), 'Chr %s @ %s Mb' % (self.Trait.chr, self.Trait.mb)) + elif self.Trait.db.type == 'Publish': + heading2.append(HT.Strong('Record ID: '), trait_url, HT.BR()) + heading2.append(HT.Strong('Phenotype: '), self.Trait.phenotype, HT.BR()) + heading2.append(HT.Strong('Author: '), self.Trait.authors, HT.BR()) + elif self.Trait.db.type == 'Temp': + heading2.append(HT.Strong('Description: '), self.Trait.description, HT.BR()) + #heading2.append(HT.Strong('Author: '), self.Trait.authors, HT.BR()) + else: + pass + else: + heading2.append(HT.Strong("Trait Name: "), fd.identification) + + if specialStrains: + mdpform = HT.Form(cgi= os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), name='MDP_Form',submit=HT.Input(type='hidden')) + mdphddn = {'FormID':'dataEditing', 'submitID':'basicStatistics','RISet':fd.RISet, "allstrainlist":string.join(fd.allstrainlist, " "), "ptype":self.plotType, 'identification':fd.identification, "incparentsf1":1} + if self.fullname: mdphddn['fullname'] = self.fullname + webqtlUtil.exportData(mdphddn, fd.allTraitData) + for key in mdphddn.keys(): + mdpform.append(HT.Input(name=key, value=mdphddn[key], type='hidden')) + btn0 = HT.Input(type='button' ,name='',value='All Cases',onClick="this.form.ptype.value=0;submit();", Class="button") + btn1 = HT.Input(type='button' ,name='',value='%s Only' % fd.RISet,onClick="this.form.ptype.value=1;submit();", Class="button") + btn2 = HT.Input(type='button' ,name='',value='MDP Only', onClick="this.form.ptype.value=2;submit();", Class="button") + mdpform.append(btn0) + mdpform.append(btn1) + mdpform.append(btn2) + heading2.append(HT.P(), mdpform) + + return HT.Span(heading2) + + def calSD(self,var): + try: + return sqrt(abs(var)) + except: + return None + + + def cmpValue(self,A,B): + try: + if A[1] < B[1]: + return -1 + elif A[1] == B[1]: + return 0 + else: + return 1 + except: + return 0 diff --git a/wqflask/basicStatistics/updatedBasicStatisticsPage.py b/wqflask/basicStatistics/updatedBasicStatisticsPage.py index ab7ed07d..3f30619d 100755 --- a/wqflask/basicStatistics/updatedBasicStatisticsPage.py +++ b/wqflask/basicStatistics/updatedBasicStatisticsPage.py @@ -6,145 +6,145 @@ import BasicStatisticsFunctions #Window generated from the Trait Data and Analysis page (DataEditingPage.py) with updated stats figures; takes the page's values that can bed edited by the user class updatedBasicStatisticsPage(templatePage): - - plotMinInformative = 4 - - def __init__(self, fd): - - templatePage.__init__(self, fd) - - if not fd.genotype: - fd.readGenotype() - this_strainlist = fd.strainlist - - if fd.allstrainlist: - this_strainlist = fd.allstrainlist - - fd.readData(this_strainlist) - - specialStrains = [] #This appears to be the "other/non-RISet strainlist" without parents/f1 strains; not sure what to name it - setStrains = [] - for item in this_strainlist: - if item not in fd.strainlist and item.find('F1') < 0: - specialStrains.append(item) - else: - continue - - specialStrains.sort() - if specialStrains: - specialStrains = fd.f1list+fd.parlist+specialStrains - - self.dict['title'] = 'Basic Statistics' - TD_LR = HT.TD(valign="top",width="100%",bgcolor="#fafafa") - - stats_row = HT.TR() - stats_cell = HT.TD() - stats_script = HT.Script(language="Javascript") - - #Get strain names, values, and variances - strain_names = fd.formdata.getvalue('strainNames').split(',') - strain_vals = fd.formdata.getvalue('strainVals').split(',') - strain_vars = fd.formdata.getvalue('strainVars').split(',') - - vals = [] - if (len(strain_names) > 0): - if (len(strain_names) > 3): - #Need to create "vals" object - for i in range(len(strain_names)): - try: - this_strain_val = float(strain_vals[i]) - except: - continue - try: - this_strain_var = float(strain_vars[i]) - except: - this_strain_var = None - - thisValFull = [strain_names[i], this_strain_val, this_strain_var] - vals.append(thisValFull) - - stats_tab_list = [HT.Href(text="Basic Table", url="#statstabs-1", Class="stats_tab"),HT.Href(text="Probability Plot", url="#statstabs-2", 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-5", Class="stats_tab")] - stats_tabs = HT.List(stats_tab_list) - - stats_container = HT.Div(id="stats_tabs", Class="ui-tabs") - stats_container.append(stats_tabs) - - stats_script_text = """$(function() { $("#stats_tabs").tabs();});""" #Javascript enabling tabs - - table_div = HT.Div(id="statstabs-1", style="height:320px;width:740px;overflow:scroll;") - table_container = HT.Paragraph() - - statsTable = HT.TableLite(cellspacing=0, cellpadding=0, width="100%") - this_trait_type = fd.formdata.getvalue('trait_type', None) - this_cellid = fd.formdata.getvalue('cellid', None) - statsTableCell = BasicStatisticsFunctions.basicStatsTable(vals=vals, trait_type=this_trait_type, cellid=this_cellid) - 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-2", style="height:540px;width:740px;overflow:scroll;") - normalplot_container = HT.Paragraph() - normalplot = HT.TableLite(cellspacing=0, cellpadding=0, width="100%") - plotTitle = fd.formdata.getvalue("normalPlotTitle","") - 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) - - barName_div = HT.Div(id="statstabs-3", style="height:540px;width:740px;overflow:scroll;") - 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", style="height:540px;width:740px;overflow:scroll;") - 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) - - boxplot_div = HT.Div(id="statstabs-5", style="height:540px;width:740px;overflow:scroll;") - 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) - - stats_cell.append(stats_container) - stats_script.append(stats_script_text) - - submitTable = HT.TableLite(cellspacing=0, cellpadding=0, width="100%") - stats_row.append(stats_cell) - - submitTable.append(stats_row) - submitTable.append(stats_script) - - TD_LR.append(submitTable) - self.dict['body'] = str(TD_LR) - else: - heading = "Basic Statistics" - detail = ['Fewer than %d case data were entered for %s data set. No statitical analysis has been attempted.' % (self.plotMinInformative, fd.RISet)] - self.error(heading=heading,detail=detail) - return - else: - heading = "Basic Statistics" - detail = ['Empty data set, please check your data.'] - self.error(heading=heading,detail=detail) - return \ No newline at end of file + + plotMinInformative = 4 + + def __init__(self, fd): + + templatePage.__init__(self, fd) + + if not fd.genotype: + fd.readGenotype() + this_strainlist = fd.strainlist + + if fd.allstrainlist: + this_strainlist = fd.allstrainlist + + fd.readData(this_strainlist) + + specialStrains = [] #This appears to be the "other/non-RISet strainlist" without parents/f1 strains; not sure what to name it + setStrains = [] + for item in this_strainlist: + if item not in fd.strainlist and item.find('F1') < 0: + specialStrains.append(item) + else: + continue + + specialStrains.sort() + if specialStrains: + specialStrains = fd.f1list+fd.parlist+specialStrains + + self.dict['title'] = 'Basic Statistics' + TD_LR = HT.TD(valign="top",width="100%",bgcolor="#fafafa") + + stats_row = HT.TR() + stats_cell = HT.TD() + stats_script = HT.Script(language="Javascript") + + #Get strain names, values, and variances + strain_names = fd.formdata.getvalue('strainNames').split(',') + strain_vals = fd.formdata.getvalue('strainVals').split(',') + strain_vars = fd.formdata.getvalue('strainVars').split(',') + + vals = [] + if (len(strain_names) > 0): + if (len(strain_names) > 3): + #Need to create "vals" object + for i in range(len(strain_names)): + try: + this_strain_val = float(strain_vals[i]) + except: + continue + try: + this_strain_var = float(strain_vars[i]) + except: + this_strain_var = None + + thisValFull = [strain_names[i], this_strain_val, this_strain_var] + vals.append(thisValFull) + + stats_tab_list = [HT.Href(text="Basic Table", url="#statstabs-1", Class="stats_tab"),HT.Href(text="Probability Plot", url="#statstabs-2", 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-5", Class="stats_tab")] + stats_tabs = HT.List(stats_tab_list) + + stats_container = HT.Div(id="stats_tabs", Class="ui-tabs") + stats_container.append(stats_tabs) + + stats_script_text = """$(function() { $("#stats_tabs").tabs();});""" #Javascript enabling tabs + + table_div = HT.Div(id="statstabs-1", style="height:320px;width:740px;overflow:scroll;") + table_container = HT.Paragraph() + + statsTable = HT.TableLite(cellspacing=0, cellpadding=0, width="100%") + this_trait_type = fd.formdata.getvalue('trait_type', None) + this_cellid = fd.formdata.getvalue('cellid', None) + statsTableCell = BasicStatisticsFunctions.basicStatsTable(vals=vals, trait_type=this_trait_type, cellid=this_cellid) + 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-2", style="height:540px;width:740px;overflow:scroll;") + normalplot_container = HT.Paragraph() + normalplot = HT.TableLite(cellspacing=0, cellpadding=0, width="100%") + plotTitle = fd.formdata.getvalue("normalPlotTitle","") + 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) + + barName_div = HT.Div(id="statstabs-3", style="height:540px;width:740px;overflow:scroll;") + 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", style="height:540px;width:740px;overflow:scroll;") + 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) + + boxplot_div = HT.Div(id="statstabs-5", style="height:540px;width:740px;overflow:scroll;") + 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) + + stats_cell.append(stats_container) + stats_script.append(stats_script_text) + + submitTable = HT.TableLite(cellspacing=0, cellpadding=0, width="100%") + stats_row.append(stats_cell) + + submitTable.append(stats_row) + submitTable.append(stats_script) + + TD_LR.append(submitTable) + self.dict['body'] = str(TD_LR) + else: + heading = "Basic Statistics" + detail = ['Fewer than %d case data were entered for %s data set. No statitical analysis has been attempted.' % (self.plotMinInformative, fd.RISet)] + self.error(heading=heading,detail=detail) + return + else: + heading = "Basic Statistics" + detail = ['Empty data set, please check your data.'] + self.error(heading=heading,detail=detail) + return diff --git a/wqflask/dbFunction/webqtlDatabaseFunction.py b/wqflask/dbFunction/webqtlDatabaseFunction.py index 772e0526..7e33da3f 100755 --- a/wqflask/dbFunction/webqtlDatabaseFunction.py +++ b/wqflask/dbFunction/webqtlDatabaseFunction.py @@ -26,7 +26,7 @@ #webqtlDatabaseFunction.py # -#This file consists of various database related functions; the names are generally self-explanatory. +#This file consists of various database related functions; the names are generally self-explanatory. import MySQLdb import string @@ -49,63 +49,63 @@ def getCursor(): ########################################################################### #input: cursor, groupName (string) #output: mappingMethodId (int) info, value will be Null or else -#function: retrieve mappingMethodId info from InbredSet table -########################################################################### +#function: retrieve mappingMethodId info from InbredSet table +########################################################################### def getMappingMethod(cursor=None, groupName=None): - cursor.execute("select MappingMethodId from InbredSet where Name= '%s'" % groupName) - mappingMethodId = cursor.fetchone()[0] - return mappingMethodId + cursor.execute("select MappingMethodId from InbredSet where Name= '%s'" % groupName) + mappingMethodId = cursor.fetchone()[0] + return mappingMethodId ########################################################################### #input: cursor, inbredSetId (int), strainId (int) -#output: isMappingId (bull) info, value will be 0,1,2 or else, 0 or Null means -# "can not do mapping", >0 means "can do mapping", >1 means "there exsists +#output: isMappingId (bull) info, value will be 0,1,2 or else, 0 or Null means +# "can not do mapping", >0 means "can do mapping", >1 means "there exsists # redundant data, user needs to choose one to do mapping function" -#function: retrieve isMappingId info from StrainXRef table -########################################################################### - -def isMapping(cursor=None, inbredSetId=None, strainId=None): - cursor.execute("select IsMapping from StrainXRef where InbredSetId='%d' and StrainId = '%d'" %(inbredSetId, strainId)) - isMappingId = cursor.fetchone()[0] - return isMappingId +#function: retrieve isMappingId info from StrainXRef table +########################################################################### + +def isMapping(cursor=None, inbredSetId=None, strainId=None): + cursor.execute("select IsMapping from StrainXRef where InbredSetId='%d' and StrainId = '%d'" %(inbredSetId, strainId)) + isMappingId = cursor.fetchone()[0] + return isMappingId ########################################################################### #input: cursor, groupName (string) #output: all species data info (array), value will be Null or else -#function: retrieve all species info from Species table -########################################################################### +#function: retrieve all species info from Species table +########################################################################### def getAllSpecies(cursor=None): - cursor.execute("select Id, Name, MenuName, FullName, TaxonomyId,OrderId from Species Order by OrderId") - allSpecies = cursor.fetchall() - return allSpecies + cursor.execute("select Id, Name, MenuName, FullName, TaxonomyId,OrderId from Species Order by OrderId") + allSpecies = cursor.fetchall() + return allSpecies ########################################################################### #input: cursor, RISet (string) #output: specie's name (string), value will be None or else -#function: retrieve specie's name info based on RISet -########################################################################### +#function: retrieve specie's name info based on RISet +########################################################################### def retrieveSpecies(cursor=None, RISet=None): - try: - cursor.execute("select Species.Name from Species, InbredSet where InbredSet.Name = '%s' and InbredSet.SpeciesId = Species.Id" % RISet) - return cursor.fetchone()[0] - except: - return None + try: + cursor.execute("select Species.Name from Species, InbredSet where InbredSet.Name = '%s' and InbredSet.SpeciesId = Species.Id" % RISet) + return cursor.fetchone()[0] + except: + return None ########################################################################### #input: cursor, RISet (string) #output: specie's Id (string), value will be None or else -#function: retrieve specie's Id info based on RISet -########################################################################### - +#function: retrieve specie's Id info based on RISet +########################################################################### + def retrieveSpeciesId(cursor=None, RISet=None): - try: - cursor.execute("select SpeciesId from InbredSet where Name = '%s'" % RISet) - return cursor.fetchone()[0] - except: - return None + try: + cursor.execute("select SpeciesId from InbredSet where Name = '%s'" % RISet) + return cursor.fetchone()[0] + except: + return None ########################################################################### # input: cursor @@ -118,24 +118,24 @@ def retrieveSpeciesId(cursor=None, RISet=None): ########################################################################### def getTissueDataSet(cursor=None): - tissProbeSetFreezeIdList=[] - nameList =[] - fullNameList = [] - - query = "select Id,Name,FullName from TissueProbeSetFreeze; " - try: - cursor.execute(query) - result = cursor.fetchall() - - for row in result: - tissProbeSetFreezeIdList.append(row[0]) - nameList.append(row[1]) - fullNameList.append(row[2]) - except: - return None - - return tissProbeSetFreezeIdList,nameList,fullNameList - + tissProbeSetFreezeIdList=[] + nameList =[] + fullNameList = [] + + query = "select Id,Name,FullName from TissueProbeSetFreeze; " + try: + cursor.execute(query) + result = cursor.fetchall() + + for row in result: + tissProbeSetFreezeIdList.append(row[0]) + nameList.append(row[1]) + fullNameList.append(row[2]) + except: + return None + + return tissProbeSetFreezeIdList,nameList,fullNameList + ########################################################################### # input: cursor,GeneSymbol (string), and TissueProbeSetFreezeId (string) # output: geneId (string), dataId (string) @@ -143,42 +143,42 @@ def getTissueDataSet(cursor=None): ########################################################################### def getGeneIdDataIdForTissueBySymbol(cursor=None, GeneSymbol=None, TissueProbeSetFreezeId= 0): - query ="select GeneId, DataId from TissueProbeSetXRef where Symbol = '%s' and TissueProbeSetFreezeId=%s order by Mean desc" %(GeneSymbol,TissueProbeSetFreezeId) - try: - cursor.execute(query) - result = cursor.fetchone() - geneId = result[0] - dataId = result[1] - except: - geneId = 0 - dataId = 0 - - return geneId,dataId + query ="select GeneId, DataId from TissueProbeSetXRef where Symbol = '%s' and TissueProbeSetFreezeId=%s order by Mean desc" %(GeneSymbol,TissueProbeSetFreezeId) + try: + cursor.execute(query) + result = cursor.fetchone() + geneId = result[0] + dataId = result[1] + except: + geneId = 0 + dataId = 0 + + return geneId,dataId ########################################################################### # input: cursor, TissueProbeSetFreezeId (int) # output: chipId (int) -# function: retrieve chipId from TissueProbeFreeze table +# function: retrieve chipId from TissueProbeFreeze table ########################################################################### def getChipIdByTissueProbeSetFreezeId(cursor=None, TissueProbeSetFreezeId=None): - query = "select TissueProbeFreezeId from TissueProbeSetFreeze where Id =%s" % TissueProbeSetFreezeId - try: - cursor.execute(query) - result = cursor.fetchone() - TissueProbeFreezeId = result[0] - except: - TissueProbeFreezeId =0 - - query1 = "select ChipId from TissueProbeFreeze where Id =%s" % TissueProbeFreezeId - try: - cursor.execute(query1) - result1 = cursor.fetchone() - chipId = result1[0] - except: - chipId =0 - - return chipId + query = "select TissueProbeFreezeId from TissueProbeSetFreeze where Id =%s" % TissueProbeSetFreezeId + try: + cursor.execute(query) + result = cursor.fetchone() + TissueProbeFreezeId = result[0] + except: + TissueProbeFreezeId =0 + + query1 = "select ChipId from TissueProbeFreeze where Id =%s" % TissueProbeFreezeId + try: + cursor.execute(query1) + result1 = cursor.fetchone() + chipId = result1[0] + except: + chipId =0 + + return chipId ########################################################################### # input: cursor, TissueProbeSetFreezeId (int) @@ -186,80 +186,79 @@ def getChipIdByTissueProbeSetFreezeId(cursor=None, TissueProbeSetFreezeId=None): # function: retrieve how many tissue used in the specific dataset based on TissueProbeSetFreezeId ########################################################################### def getTissueCountByTissueProbeSetFreezeId(cursor=None, TissueProbeSetFreezeId=None): - query1 ="select DataId from TissueProbeSetXRef where TissueProbeSetFreezeId =%s limit 1" % TissueProbeSetFreezeId - try: - cursor.execute(query1) - result1 = cursor.fetchone() - DataId = result1[0] - - query2 =" select count(*) from TissueProbeSetData where Id=%s" % DataId - try: - cursor.execute(query2) - result2 = cursor.fetchone() - TissueCount = result2[0] - except: - TissueCount =0 - except: - TissueCount =0 - - return TissueCount - + query1 ="select DataId from TissueProbeSetXRef where TissueProbeSetFreezeId =%s limit 1" % TissueProbeSetFreezeId + try: + cursor.execute(query1) + result1 = cursor.fetchone() + DataId = result1[0] + + query2 =" select count(*) from TissueProbeSetData where Id=%s" % DataId + try: + cursor.execute(query2) + result2 = cursor.fetchone() + TissueCount = result2[0] + except: + TissueCount =0 + except: + TissueCount =0 + + return TissueCount + ########################################################################### # input: cursor, TissueProbeSetFreezeId (int) # output: DatasetName(string),DatasetFullName(string) # function: retrieve DatasetName, DatasetFullName based on TissueProbeSetFreezeId ########################################################################### def getDatasetNamesByTissueProbeSetFreezeId(cursor=None, TissueProbeSetFreezeId=None): - query ="select Name, FullName from TissueProbeSetFreeze where Id=%s" % TissueProbeSetFreezeId - try: - cursor.execute(query) - result = cursor.fetchone() - DatasetName = result[0] - DatasetFullName =result[1] - except: - DatasetName =None - DatasetFullName =None - - return DatasetName, DatasetFullName - + query ="select Name, FullName from TissueProbeSetFreeze where Id=%s" % TissueProbeSetFreezeId + try: + cursor.execute(query) + result = cursor.fetchone() + DatasetName = result[0] + DatasetFullName =result[1] + except: + DatasetName =None + DatasetFullName =None + + return DatasetName, DatasetFullName + ########################################################################### # input: cursor, geneIdLst (list) # output: geneIdSymbolPair(dict),key is geneId, value is geneSymbol # function: retrieve GeneId, GeneSymbol based on geneId List -########################################################################### +########################################################################### def getGeneIdSymbolPairByGeneId(cursor=None, geneIdLst =None): - geneIdSymbolPair={} - for geneId in geneIdLst: - geneIdSymbolPair[geneId]=None - - query ="select GeneId,GeneSymbol from GeneList where GeneId in (%s)" % string.join(geneIdLst, ", ") - try: - cursor.execute(query) - results = cursor.fetchall() - for item in results: - geneId =item[0] - geneSymbol =item[1] - geneIdSymbolPair[geneId]=geneSymbol - except: - geneIdSymbolPair=None - - return geneIdSymbolPair - - + geneIdSymbolPair={} + for geneId in geneIdLst: + geneIdSymbolPair[geneId]=None + + query ="select GeneId,GeneSymbol from GeneList where GeneId in (%s)" % string.join(geneIdLst, ", ") + try: + cursor.execute(query) + results = cursor.fetchall() + for item in results: + geneId =item[0] + geneSymbol =item[1] + geneIdSymbolPair[geneId]=geneSymbol + except: + geneIdSymbolPair=None + + return geneIdSymbolPair + + def updateTissueProbesetXRefByProbesetId(cursor=None, probesetId=None): - query ="select Symbol,GeneId,Chr,Mb,description, Probe_Target_Description from ProbeSet where Id =%s"%probesetId - try: - cursor.execute(query) - result =cursor.fetchone() - - updateQuery =''' - Update TissueProbeSetXRef - Set Symbol='%s',GeneId='%s', Chr='%s', Mb='%s', description ='%s',Probe_Target_Description='%s' - where ProbesetId=%s - '''%(result[0],result[1],result[2],result[3],result[4],result[5],probesetId) - - cursor.execute(updateQuery) - - except: - return None - \ No newline at end of file + query ="select Symbol,GeneId,Chr,Mb,description, Probe_Target_Description from ProbeSet where Id =%s"%probesetId + try: + cursor.execute(query) + result =cursor.fetchone() + + updateQuery =''' + Update TissueProbeSetXRef + Set Symbol='%s',GeneId='%s', Chr='%s', Mb='%s', description ='%s',Probe_Target_Description='%s' + where ProbesetId=%s + '''%(result[0],result[1],result[2],result[3],result[4],result[5],probesetId) + + cursor.execute(updateQuery) + + except: + return None diff --git a/wqflask/utility/AJAX_table.py b/wqflask/utility/AJAX_table.py index 963a530e..083d1c0d 100755 --- a/wqflask/utility/AJAX_table.py +++ b/wqflask/utility/AJAX_table.py @@ -39,115 +39,115 @@ import webqtlUtil class AJAX_table: - def __init__(self, fd): - file = fd.formdata.getfirst("file", "") - sort = fd.formdata.getfirst("sort", "") - order = fd.formdata.getfirst("order", "up") - cmd = fd.formdata.getfirst("cmd", "") - tableID = fd.formdata.getfirst("tableID", "") - addIndex = fd.formdata.getfirst("addIndex", "1") - hiddenColumnsString = fd.formdata.getfirst("hiddenColumns", "") - hiddenColumns = hiddenColumnsString.split(',') - - try: - fp = open(os.path.join(webqtlConfig.TMPDIR, file + '.obj'), 'rb') - tblobj = cPickle.load(fp) - fp.close() - - if cmd == 'addCorr': - dbId = int(fd.formdata.getfirst("db")) - dbFullName = fd.formdata.getfirst("dbname") - trait = fd.formdata.getfirst("trait") - form = fd.formdata.getfirst("form") - ids = fd.formdata.getfirst("ids") - vals = fd.formdata.getfirst("vals") - ids = eval(ids) - nnCorr = len(ids) - vals = eval(vals) - - workbook = xl.Writer('%s.xls' % (webqtlConfig.TMPDIR+file)) - worksheet = workbook.add_worksheet() - - con = MySQLdb.Connect(db=webqtlConfig.DB_NAME,host=webqtlConfig.MYSQL_SERVER, user=webqtlConfig.DB_USER,passwd=webqtlConfig.DB_PASSWD) - cursor = con.cursor() - - cursor.execute("Select name, ShortName from ProbeSetFreeze where Id = %s", dbId) - dbName, dbShortName = cursor.fetchone() - - tblobj['header'][0].append( - THCell(HT.TD(dbShortName, Class="fs11 ffl b1 cw cbrb"), - text="%s" % dbShortName, idx=tblobj['header'][0][-1].idx + 1), - ) - - headingStyle = workbook.add_format(align = 'center', bold = 1, border = 1, size=13, fg_color = 0x1E, color="white") - for i, item in enumerate(tblobj['header'][0]): - if (i > 0): - worksheet.write([8, i-1], item.text, headingStyle) - worksheet.set_column([i-1, i-1], 2*len(item.text)) - - for i, row in enumerate(tblobj['body']): - ProbeSetId = row[1].text - #XZ, 03/02/2009: Xiaodong changed Data to ProbeSetData - cursor.execute(""" - Select ProbeSetData.StrainId, ProbeSetData.Value - From ProbeSetData, ProbeSetXRef, ProbeSet - where ProbeSetXRef.ProbeSetFreezeId = %d AND - ProbeSetXRef.DataId = ProbeSetData.Id AND - ProbeSetXRef.ProbeSetId = ProbeSet.Id AND - ProbeSet.Name = '%s' - """ % (dbId, ProbeSetId)) - results = cursor.fetchall() - vdict = {} - for item in results: - vdict[item[0]] = item[1] - newvals = [] - for id in ids: - if vdict.has_key(id): - newvals.append(vdict[id]) - else: - newvals.append(None) - corr,nOverlap= webqtlUtil.calCorrelation(newvals,vals,nnCorr) - repr = '%0.4f' % corr - row.append( - TDCell(HT.TD(HT.Href(text=repr, url="javascript:showCorrPlotThird('%s', '%s', '%s')" % (form, dbName, ProbeSetId), Class="fs11 fwn ffl"), " / ", nOverlap, Class="fs11 fwn ffl b1 c222", align="middle"),repr,abs(corr)) - ) - - last_row=0 - for j, item in enumerate(tblobj['body'][i]): - if (j > 0): - worksheet.write([9+i, j-1], item.text) - last_row = 9+i - last_row += 1 - - titleStyle = workbook.add_format(align = 'left', bold = 0, size=14, border = 1, border_color="gray") - ##Write title Info - # Modified by Hongqiang Li - worksheet.write([0, 0], "Citations: Please see %s/reference.html" % webqtlConfig.PORTADDR, titleStyle) - worksheet.write([1, 0], "Trait : %s" % trait, titleStyle) - worksheet.write([2, 0], "Database : %s" % dbFullName, titleStyle) - worksheet.write([3, 0], "Date : %s" % time.strftime("%B %d, %Y", time.gmtime()), titleStyle) - worksheet.write([4, 0], "Time : %s GMT" % time.strftime("%H:%M ", time.gmtime()), titleStyle) - worksheet.write([5, 0], "Status of data ownership: Possibly unpublished data; please see %s/statusandContact.html for details on sources, ownership, and usage of these data." % webqtlConfig.PORTADDR, titleStyle) - #Write footer info - worksheet.write([1 + last_row, 0], "Funding for The GeneNetwork: NIAAA (U01AA13499, U24AA13513), NIDA, NIMH, and NIAAA (P20-DA21131), NCI MMHCC (U01CA105417), and NCRR (U01NR 105417)", titleStyle) - worksheet.write([2 + last_row, 0], "PLEASE RETAIN DATA SOURCE INFORMATION WHENEVER POSSIBLE", titleStyle) - - cursor.close() - workbook.close() - - objfile = open(os.path.join(webqtlConfig.TMPDIR, file + '.obj'), 'wb') - cPickle.dump(tblobj, objfile) - objfile.close() - else: - pass - - self.value = str(webqtlUtil.genTableObj(tblobj=tblobj, file=file, sortby=(sort, order), tableID = tableID, addIndex = addIndex, hiddenColumns = hiddenColumns)) - - except: - self.value = "The table is no longer available on this server" - - def __str__(self): - return self.value - - def write(self): - return str(self) + def __init__(self, fd): + file = fd.formdata.getfirst("file", "") + sort = fd.formdata.getfirst("sort", "") + order = fd.formdata.getfirst("order", "up") + cmd = fd.formdata.getfirst("cmd", "") + tableID = fd.formdata.getfirst("tableID", "") + addIndex = fd.formdata.getfirst("addIndex", "1") + hiddenColumnsString = fd.formdata.getfirst("hiddenColumns", "") + hiddenColumns = hiddenColumnsString.split(',') + + try: + fp = open(os.path.join(webqtlConfig.TMPDIR, file + '.obj'), 'rb') + tblobj = cPickle.load(fp) + fp.close() + + if cmd == 'addCorr': + dbId = int(fd.formdata.getfirst("db")) + dbFullName = fd.formdata.getfirst("dbname") + trait = fd.formdata.getfirst("trait") + form = fd.formdata.getfirst("form") + ids = fd.formdata.getfirst("ids") + vals = fd.formdata.getfirst("vals") + ids = eval(ids) + nnCorr = len(ids) + vals = eval(vals) + + workbook = xl.Writer('%s.xls' % (webqtlConfig.TMPDIR+file)) + worksheet = workbook.add_worksheet() + + con = MySQLdb.Connect(db=webqtlConfig.DB_NAME,host=webqtlConfig.MYSQL_SERVER, user=webqtlConfig.DB_USER,passwd=webqtlConfig.DB_PASSWD) + cursor = con.cursor() + + cursor.execute("Select name, ShortName from ProbeSetFreeze where Id = %s", dbId) + dbName, dbShortName = cursor.fetchone() + + tblobj['header'][0].append( + THCell(HT.TD(dbShortName, Class="fs11 ffl b1 cw cbrb"), + text="%s" % dbShortName, idx=tblobj['header'][0][-1].idx + 1), + ) + + headingStyle = workbook.add_format(align = 'center', bold = 1, border = 1, size=13, fg_color = 0x1E, color="white") + for i, item in enumerate(tblobj['header'][0]): + if (i > 0): + worksheet.write([8, i-1], item.text, headingStyle) + worksheet.set_column([i-1, i-1], 2*len(item.text)) + + for i, row in enumerate(tblobj['body']): + ProbeSetId = row[1].text + #XZ, 03/02/2009: Xiaodong changed Data to ProbeSetData + cursor.execute(""" + Select ProbeSetData.StrainId, ProbeSetData.Value + From ProbeSetData, ProbeSetXRef, ProbeSet + where ProbeSetXRef.ProbeSetFreezeId = %d AND + ProbeSetXRef.DataId = ProbeSetData.Id AND + ProbeSetXRef.ProbeSetId = ProbeSet.Id AND + ProbeSet.Name = '%s' + """ % (dbId, ProbeSetId)) + results = cursor.fetchall() + vdict = {} + for item in results: + vdict[item[0]] = item[1] + newvals = [] + for id in ids: + if vdict.has_key(id): + newvals.append(vdict[id]) + else: + newvals.append(None) + corr,nOverlap= webqtlUtil.calCorrelation(newvals,vals,nnCorr) + repr = '%0.4f' % corr + row.append( + TDCell(HT.TD(HT.Href(text=repr, url="javascript:showCorrPlotThird('%s', '%s', '%s')" % (form, dbName, ProbeSetId), Class="fs11 fwn ffl"), " / ", nOverlap, Class="fs11 fwn ffl b1 c222", align="middle"),repr,abs(corr)) + ) + + last_row=0 + for j, item in enumerate(tblobj['body'][i]): + if (j > 0): + worksheet.write([9+i, j-1], item.text) + last_row = 9+i + last_row += 1 + + titleStyle = workbook.add_format(align = 'left', bold = 0, size=14, border = 1, border_color="gray") + ##Write title Info + # Modified by Hongqiang Li + worksheet.write([0, 0], "Citations: Please see %s/reference.html" % webqtlConfig.PORTADDR, titleStyle) + worksheet.write([1, 0], "Trait : %s" % trait, titleStyle) + worksheet.write([2, 0], "Database : %s" % dbFullName, titleStyle) + worksheet.write([3, 0], "Date : %s" % time.strftime("%B %d, %Y", time.gmtime()), titleStyle) + worksheet.write([4, 0], "Time : %s GMT" % time.strftime("%H:%M ", time.gmtime()), titleStyle) + worksheet.write([5, 0], "Status of data ownership: Possibly unpublished data; please see %s/statusandContact.html for details on sources, ownership, and usage of these data." % webqtlConfig.PORTADDR, titleStyle) + #Write footer info + worksheet.write([1 + last_row, 0], "Funding for The GeneNetwork: NIAAA (U01AA13499, U24AA13513), NIDA, NIMH, and NIAAA (P20-DA21131), NCI MMHCC (U01CA105417), and NCRR (U01NR 105417)", titleStyle) + worksheet.write([2 + last_row, 0], "PLEASE RETAIN DATA SOURCE INFORMATION WHENEVER POSSIBLE", titleStyle) + + cursor.close() + workbook.close() + + objfile = open(os.path.join(webqtlConfig.TMPDIR, file + '.obj'), 'wb') + cPickle.dump(tblobj, objfile) + objfile.close() + else: + pass + + self.value = str(webqtlUtil.genTableObj(tblobj=tblobj, file=file, sortby=(sort, order), tableID = tableID, addIndex = addIndex, hiddenColumns = hiddenColumns)) + + except: + self.value = "The table is no longer available on this server" + + def __str__(self): + return self.value + + def write(self): + return str(self) diff --git a/wqflask/utility/Plot.py b/wqflask/utility/Plot.py index e00b8e9e..04fe85bf 100755 --- a/wqflask/utility/Plot.py +++ b/wqflask/utility/Plot.py @@ -39,1245 +39,1245 @@ from base import webqtlConfig def cformat(d, rank=0): - 'custom string format' - strD = "%2.6f" % d - - if rank == 0: - while strD[-1] in ('0','.'): - if strD[-1] == '0' and strD[-2] == '.' and len(strD) <= 4: - break - elif strD[-1] == '.': - strD = strD[:-1] - break - else: - strD = strD[:-1] - - else: - strD = strD.split(".")[0] - - if strD == '-0.0': - strD = '0.0' - return strD + 'custom string format' + strD = "%2.6f" % d + + if rank == 0: + while strD[-1] in ('0','.'): + if strD[-1] == '0' and strD[-2] == '.' and len(strD) <= 4: + break + elif strD[-1] == '.': + strD = strD[:-1] + break + else: + strD = strD[:-1] + + else: + strD = strD.split(".")[0] + + if strD == '-0.0': + strD = '0.0' + return strD def frange(start, end=None, inc=1.0): - "A faster range-like function that does accept float increments..." - if end == None: - end = start + 0.0 - start = 0.0 - else: - start += 0.0 # force it to be a float - count = int((end - start) / inc) - if start + count * inc != end: - # Need to adjust the count. AFAICT, it always comes up one short. - count += 1 - L = [start] * count - for i in xrange(1, count): - L[i] = start + i * inc - return L + "A faster range-like function that does accept float increments..." + if end == None: + end = start + 0.0 + start = 0.0 + else: + start += 0.0 # force it to be a float + count = int((end - start) / inc) + if start + count * inc != end: + # Need to adjust the count. AFAICT, it always comes up one short. + count += 1 + L = [start] * count + for i in xrange(1, count): + L[i] = start + i * inc + return L def gammln(xx): - cof=[76.18009173,-86.50532033,24.01409822,-1.231739516,0.120858003e-2,-0.536382e-5] - x=xx-1.0 - tmp=x+5.5 - tmp -=(x+0.5)*log(tmp) - ser=1.0 - for item in cof: - x+=1.0 - ser+=item/x + cof=[76.18009173,-86.50532033,24.01409822,-1.231739516,0.120858003e-2,-0.536382e-5] + x=xx-1.0 + tmp=x+5.5 + tmp -=(x+0.5)*log(tmp) + ser=1.0 + for item in cof: + x+=1.0 + ser+=item/x - return -tmp+log(2.50662827465*ser) + return -tmp+log(2.50662827465*ser) def gser(a,x): - gln=gammln(a) - ITMAX=100 - EPS=3.0e-7 - - if x<=0.0: - gamser=0.0 - return [gamser,gln] - else: - ap=a - sum=1.0/a - dele=sum - for i in range(1,ITMAX+1): - ap+=1.0 - dele*=x/ap - sum+=dele - if abs(dele)=0.0: - return ans - else: - return 2.0-ans + z=abs(x) + t=1.0/(1.0+0.5*z) + ans=t*exp(-z*z-1.26551223+t*(1.00002368+t*(0.37409196+t*(0.09678418+t*(-0.18628806+t*(0.27886807+t*(-1.13520398+t*(1.48851587+t*(-0.82215223+t*0.17087277))))))))) + if x>=0.0: + return ans + else: + return 2.0-ans def calMeanVar(data): - n=len(data) - if n<2: - return None - else: - sum=reduce(lambda x,y:x+y,data,0.0) - mean=sum/n - z=data[:] - for i in range(n): - z[i]=z[i]-mean - variance=reduce(lambda x,y:x+y*y,z,0.0) - variance /= n-1 - variance =sqrt(variance) - for i in range(n): - z[i]=z[i]/variance - return z + n=len(data) + if n<2: + return None + else: + sum=reduce(lambda x,y:x+y,data,0.0) + mean=sum/n + z=data[:] + for i in range(n): + z[i]=z[i]-mean + variance=reduce(lambda x,y:x+y*y,z,0.0) + variance /= n-1 + variance =sqrt(variance) + for i in range(n): + z[i]=z[i]/variance + return z def inverseCumul(p): - #Coefficients in rational approximations. - a = [-3.969683028665376e+01,2.209460984245205e+02,-2.759285104469687e+02,1.383577518672690e+02,-3.066479806614716e+01,2.506628277459239e+00] + #Coefficients in rational approximations. + a = [-3.969683028665376e+01,2.209460984245205e+02,-2.759285104469687e+02,1.383577518672690e+02,-3.066479806614716e+01,2.506628277459239e+00] - b = [-5.447609879822406e+01,1.615858368580409e+02,-1.556989798598866e+02,6.680131188771972e+01,-1.328068155288572e+01] + b = [-5.447609879822406e+01,1.615858368580409e+02,-1.556989798598866e+02,6.680131188771972e+01,-1.328068155288572e+01] - c = [-7.784894002430293e-03,-3.223964580411365e-01,-2.400758277161838e+00,-2.549732539343734e+00,4.374664141464968e+00,2.938163982698783e+00] + c = [-7.784894002430293e-03,-3.223964580411365e-01,-2.400758277161838e+00,-2.549732539343734e+00,4.374664141464968e+00,2.938163982698783e+00] - d = [7.784695709041462e-03,3.224671290700398e-01,2.445134137142996e+00,3.754408661907416e+00] + d = [7.784695709041462e-03,3.224671290700398e-01,2.445134137142996e+00,3.754408661907416e+00] - #Define break-points. + #Define break-points. - p_low = 0.02425 - p_high = 1 - p_low + p_low = 0.02425 + p_high = 1 - p_low - #Rational approximation for lower region. + #Rational approximation for lower region. - if p > 0 and p < p_low: - q = sqrt(-2*log(p)) - x = (((((c[0]*q+c[1])*q+c[2])*q+c[3])*q+c[4])*q+c[5]) / ((((d[0]*q+d[1])*q+d[2])*q+d[3])*q+1) + if p > 0 and p < p_low: + q = sqrt(-2*log(p)) + x = (((((c[0]*q+c[1])*q+c[2])*q+c[3])*q+c[4])*q+c[5]) / ((((d[0]*q+d[1])*q+d[2])*q+d[3])*q+1) - #Rational approximation for central region. + #Rational approximation for central region. - elif p>= p_low and p <= p_high: - q = p - 0.5 - r = q*q - x = (((((a[0]*r+a[1])*r+a[2])*r+a[3])*r+a[4])*r+a[5])*q /(((((b[0]*r+b[1])*r+b[2])*r+b[3])*r+b[4])*r+1) + elif p>= p_low and p <= p_high: + q = p - 0.5 + r = q*q + x = (((((a[0]*r+a[1])*r+a[2])*r+a[3])*r+a[4])*r+a[5])*q /(((((b[0]*r+b[1])*r+b[2])*r+b[3])*r+b[4])*r+1) - #Rational approximation for upper region. + #Rational approximation for upper region. - elif p>p_high and p < 1: - q = sqrt(-2*log(1-p)) - x = -(((((c[0]*q+c[1])*q+c[2])*q+c[3])*q+c[4])*q+c[5]) /((((d[0]*q+d[1])*q+d[2])*q+d[3])*q+1) + elif p>p_high and p < 1: + q = sqrt(-2*log(1-p)) + x = -(((((c[0]*q+c[1])*q+c[2])*q+c[3])*q+c[4])*q+c[5]) /((((d[0]*q+d[1])*q+d[2])*q+d[3])*q+1) - else: - return None + else: + return None - if p>0 and p < 1: - e = 0.5 * erfcc(-x/sqrt(2)) - p - u = e * sqrt(2*pi) * exp(x*x/2) - x = x - u/(1 + x*u/2) - return x - else: - return None + if p>0 and p < 1: + e = 0.5 * erfcc(-x/sqrt(2)) - p + u = e * sqrt(2*pi) * exp(x*x/2) + x = x - u/(1 + x*u/2) + return x + else: + return None def gmean(lst): - N = len(lst) - if N == 0: - return 0 - else: - return (reduce(lambda x,y: x+y, lst, 0.0))/N + N = len(lst) + if N == 0: + return 0 + else: + return (reduce(lambda x,y: x+y, lst, 0.0))/N def gmedian(lst2): - lst = lst2[:] - N = len(lst) - if N == 0: - return 0 - else: - lst.sort() - if N % 2 == 0: - return (lst[N/2]+lst[(N-2)/2])/2.0 - else: - return lst[(N-1)/2] + lst = lst2[:] + N = len(lst) + if N == 0: + return 0 + else: + lst.sort() + if N % 2 == 0: + return (lst[N/2]+lst[(N-2)/2])/2.0 + else: + return lst[(N-1)/2] def gpercentile(lst2, np): - lst = lst2[:] - N = len(lst) - if N == 0 or np > 100 or np < 0: - return None - else: - lst.sort() - pNadd1 = (np/100.0)*N - k = int(pNadd1) - d = pNadd1 - k - if k == 0: - return lst[0] - elif k >= N-1: - return lst[N-1] - else: - return lst[k-1] + d*(lst[k] - lst[k-1]) + lst = lst2[:] + N = len(lst) + if N == 0 or np > 100 or np < 0: + return None + else: + lst.sort() + pNadd1 = (np/100.0)*N + k = int(pNadd1) + d = pNadd1 - k + if k == 0: + return lst[0] + elif k >= N-1: + return lst[N-1] + else: + return lst[k-1] + d*(lst[k] - lst[k-1]) def findOutliers(vals): - valsOnly = [] - dataXZ = vals[:] - for i in range(len(dataXZ)): - valsOnly.append(dataXZ[i][1]) - - data = [('', valsOnly[:])] - - for item in data: - itemvalue = item[1] - nValue = len(itemvalue) - catValue = [] - - for item2 in itemvalue: - try: - tstrain, tvalue = item2 - except: - tvalue = item2 - if nValue <= 4: - continue - else: - catValue.append(tvalue) - - if catValue != []: - lowHinge = gpercentile(catValue, 25) - upHinge = gpercentile(catValue, 75) - Hstep = 1.5*(upHinge - lowHinge) - - outlier = [] - extreme = [] - - upperBound = upHinge + Hstep - lowerBound = lowHinge - Hstep - - for item in catValue: - if item >= upHinge + 2*Hstep: - extreme.append(item) - elif item >= upHinge + Hstep: - outlier.append(item) - else: - pass - - for item in catValue: - if item <= lowHinge - 2*Hstep: - extreme.append(item) - elif item <= lowHinge - Hstep: - outlier.append(item) - else: - pass - else: - upperBound = 1000 - lowerBound = -1000 - - return upperBound, lowerBound + valsOnly = [] + dataXZ = vals[:] + for i in range(len(dataXZ)): + valsOnly.append(dataXZ[i][1]) + + data = [('', valsOnly[:])] + + for item in data: + itemvalue = item[1] + nValue = len(itemvalue) + catValue = [] + + for item2 in itemvalue: + try: + tstrain, tvalue = item2 + except: + tvalue = item2 + if nValue <= 4: + continue + else: + catValue.append(tvalue) + + if catValue != []: + lowHinge = gpercentile(catValue, 25) + upHinge = gpercentile(catValue, 75) + Hstep = 1.5*(upHinge - lowHinge) + + outlier = [] + extreme = [] + + upperBound = upHinge + Hstep + lowerBound = lowHinge - Hstep + + for item in catValue: + if item >= upHinge + 2*Hstep: + extreme.append(item) + elif item >= upHinge + Hstep: + outlier.append(item) + else: + pass + + for item in catValue: + if item <= lowHinge - 2*Hstep: + extreme.append(item) + elif item <= lowHinge - Hstep: + outlier.append(item) + else: + pass + else: + upperBound = 1000 + lowerBound = -1000 + + return upperBound, lowerBound def plotBoxPlot(canvas, data, offset= (40, 40, 40, 40), XLabel="Category", YLabel="Value"): - xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset - plotWidth = canvas.size[0] - xLeftOffset - xRightOffset - plotHeight = canvas.size[1] - yTopOffset - yBottomOffset - iValues = [] - for item in data: - for item2 in item[1]: - try: - iValues.append(item2[1]) - except: - iValues.append(item2) - - #draw frame - max_Y = max(iValues) - min_Y = min(iValues) - scaleY = detScale(min_Y, max_Y) - Yll = scaleY[0] - Yur = scaleY[1] - nStep = scaleY[2] - stepY = (Yur - Yll)/nStep - stepYPixel = plotHeight/(nStep) - canvas.drawRect(plotWidth+xLeftOffset, plotHeight + yTopOffset, xLeftOffset, yTopOffset) - - ##draw Y Scale - YYY = Yll - YCoord = plotHeight + yTopOffset - scaleFont=pid.Font(ttf="cour",size=11,bold=1) - for i in range(nStep+1): - strY = cformat(d=YYY, rank=0) - YCoord = max(YCoord, yTopOffset) - canvas.drawLine(xLeftOffset,YCoord,xLeftOffset-5,YCoord) - canvas.drawString(strY, xLeftOffset -30,YCoord +5,font=scaleFont) - YYY += stepY - YCoord -= stepYPixel - - ##draw X Scale - stepX = plotWidth/len(data) - XCoord = xLeftOffset + 0.5*stepX - YCoord = plotHeight + yTopOffset - scaleFont = pid.Font(ttf="tahoma",size=12,bold=0) - labelFont = pid.Font(ttf="tahoma",size=13,bold=0) - for item in data: - itemname, itemvalue = item - canvas.drawLine(XCoord, YCoord,XCoord, YCoord+5, color=pid.black) - canvas.drawString(itemname, XCoord - canvas.stringWidth(itemname,font=labelFont)/2.0,\ - YCoord +20,font=labelFont) - - nValue = len(itemvalue) - catValue = [] - for item2 in itemvalue: - try: - tstrain, tvalue = item2 - except: - tvalue = item2 - if nValue <= 4: - canvas.drawCross(XCoord, plotHeight + yTopOffset - (tvalue-Yll)*plotHeight/(Yur - Yll), color=pid.red,size=5) - else: - catValue.append(tvalue) - if catValue != []: - catMean = gmean(catValue) - catMedian = gmedian(catValue) - lowHinge = gpercentile(catValue, 25) - upHinge = gpercentile(catValue, 75) - Hstep = 1.5*(upHinge - lowHinge) - - outlier = [] - extrem = [] - - upperAdj = None - for item in catValue: - if item >= upHinge + 2*Hstep: - extrem.append(item) - elif item >= upHinge + Hstep: - outlier.append(item) - elif item > upHinge and item < upHinge + Hstep: - if upperAdj == None or item > upperAdj: - upperAdj = item - else: - pass - lowerAdj = None - for item in catValue: - if item <= lowHinge - 2*Hstep: - extrem.append(item) - elif item <= lowHinge - Hstep: - outlier.append(item) - if item < lowHinge and item > lowHinge - Hstep: - if lowerAdj == None or item < lowerAdj: - lowerAdj = item - else: - pass - canvas.drawRect(XCoord-20, plotHeight + yTopOffset - (lowHinge-Yll)*plotHeight/(Yur - Yll), \ - XCoord+20, plotHeight + yTopOffset - (upHinge-Yll)*plotHeight/(Yur - Yll)) - canvas.drawLine(XCoord-20, plotHeight + yTopOffset - (catMedian-Yll)*plotHeight/(Yur - Yll), \ - XCoord+20, plotHeight + yTopOffset - (catMedian-Yll)*plotHeight/(Yur - Yll)) - if upperAdj != None: - canvas.drawLine(XCoord, plotHeight + yTopOffset - (upHinge-Yll)*plotHeight/(Yur - Yll), \ - XCoord, plotHeight + yTopOffset - (upperAdj-Yll)*plotHeight/(Yur - Yll)) - canvas.drawLine(XCoord-20, plotHeight + yTopOffset - (upperAdj-Yll)*plotHeight/(Yur - Yll), \ - XCoord+20, plotHeight + yTopOffset - (upperAdj-Yll)*plotHeight/(Yur - Yll)) - if lowerAdj != None: - canvas.drawLine(XCoord, plotHeight + yTopOffset - (lowHinge-Yll)*plotHeight/(Yur - Yll), \ - XCoord, plotHeight + yTopOffset - (lowerAdj-Yll)*plotHeight/(Yur - Yll)) - canvas.drawLine(XCoord-20, plotHeight + yTopOffset - (lowerAdj-Yll)*plotHeight/(Yur - Yll), \ - XCoord+20, plotHeight + yTopOffset - (lowerAdj-Yll)*plotHeight/(Yur - Yll)) - - outlierFont = pid.Font(ttf="cour",size=12,bold=0) - if outlier != []: - for item in outlier: - yc = plotHeight + yTopOffset - (item-Yll)*plotHeight/(Yur - Yll) - #canvas.drawEllipse(XCoord-3, yc-3, XCoord+3, yc+3) - canvas.drawString('o', XCoord-3, yc+5, font=outlierFont, color=pid.orange) - if extrem != []: - for item in extrem: - yc = plotHeight + yTopOffset - (item-Yll)*plotHeight/(Yur - Yll) - #canvas.drawEllipse(XCoord-3, yc-3, XCoord+3, yc+3) - canvas.drawString('*', XCoord-3, yc+6, font=outlierFont, color=pid.red) - - canvas.drawCross(XCoord, plotHeight + yTopOffset - (catMean-Yll)*plotHeight/(Yur - Yll), \ - color=pid.blue,size=3) - #print (catMean, catMedian, cat25per, cat75per) - pass - - XCoord += stepX - - labelFont=pid.Font(ttf="verdana",size=18,bold=0) - canvas.drawString(XLabel, xLeftOffset + (plotWidth -canvas.stringWidth(XLabel,font=labelFont))/2.0, \ - YCoord +40, font=labelFont) - canvas.drawString(YLabel,xLeftOffset-40, YCoord-(plotHeight -canvas.stringWidth(YLabel,font=labelFont))/2.0,\ - font=labelFont, angle =90) + xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset + plotWidth = canvas.size[0] - xLeftOffset - xRightOffset + plotHeight = canvas.size[1] - yTopOffset - yBottomOffset + iValues = [] + for item in data: + for item2 in item[1]: + try: + iValues.append(item2[1]) + except: + iValues.append(item2) + + #draw frame + max_Y = max(iValues) + min_Y = min(iValues) + scaleY = detScale(min_Y, max_Y) + Yll = scaleY[0] + Yur = scaleY[1] + nStep = scaleY[2] + stepY = (Yur - Yll)/nStep + stepYPixel = plotHeight/(nStep) + canvas.drawRect(plotWidth+xLeftOffset, plotHeight + yTopOffset, xLeftOffset, yTopOffset) + + ##draw Y Scale + YYY = Yll + YCoord = plotHeight + yTopOffset + scaleFont=pid.Font(ttf="cour",size=11,bold=1) + for i in range(nStep+1): + strY = cformat(d=YYY, rank=0) + YCoord = max(YCoord, yTopOffset) + canvas.drawLine(xLeftOffset,YCoord,xLeftOffset-5,YCoord) + canvas.drawString(strY, xLeftOffset -30,YCoord +5,font=scaleFont) + YYY += stepY + YCoord -= stepYPixel + + ##draw X Scale + stepX = plotWidth/len(data) + XCoord = xLeftOffset + 0.5*stepX + YCoord = plotHeight + yTopOffset + scaleFont = pid.Font(ttf="tahoma",size=12,bold=0) + labelFont = pid.Font(ttf="tahoma",size=13,bold=0) + for item in data: + itemname, itemvalue = item + canvas.drawLine(XCoord, YCoord,XCoord, YCoord+5, color=pid.black) + canvas.drawString(itemname, XCoord - canvas.stringWidth(itemname,font=labelFont)/2.0,\ + YCoord +20,font=labelFont) + + nValue = len(itemvalue) + catValue = [] + for item2 in itemvalue: + try: + tstrain, tvalue = item2 + except: + tvalue = item2 + if nValue <= 4: + canvas.drawCross(XCoord, plotHeight + yTopOffset - (tvalue-Yll)*plotHeight/(Yur - Yll), color=pid.red,size=5) + else: + catValue.append(tvalue) + if catValue != []: + catMean = gmean(catValue) + catMedian = gmedian(catValue) + lowHinge = gpercentile(catValue, 25) + upHinge = gpercentile(catValue, 75) + Hstep = 1.5*(upHinge - lowHinge) + + outlier = [] + extrem = [] + + upperAdj = None + for item in catValue: + if item >= upHinge + 2*Hstep: + extrem.append(item) + elif item >= upHinge + Hstep: + outlier.append(item) + elif item > upHinge and item < upHinge + Hstep: + if upperAdj == None or item > upperAdj: + upperAdj = item + else: + pass + lowerAdj = None + for item in catValue: + if item <= lowHinge - 2*Hstep: + extrem.append(item) + elif item <= lowHinge - Hstep: + outlier.append(item) + if item < lowHinge and item > lowHinge - Hstep: + if lowerAdj == None or item < lowerAdj: + lowerAdj = item + else: + pass + canvas.drawRect(XCoord-20, plotHeight + yTopOffset - (lowHinge-Yll)*plotHeight/(Yur - Yll), \ + XCoord+20, plotHeight + yTopOffset - (upHinge-Yll)*plotHeight/(Yur - Yll)) + canvas.drawLine(XCoord-20, plotHeight + yTopOffset - (catMedian-Yll)*plotHeight/(Yur - Yll), \ + XCoord+20, plotHeight + yTopOffset - (catMedian-Yll)*plotHeight/(Yur - Yll)) + if upperAdj != None: + canvas.drawLine(XCoord, plotHeight + yTopOffset - (upHinge-Yll)*plotHeight/(Yur - Yll), \ + XCoord, plotHeight + yTopOffset - (upperAdj-Yll)*plotHeight/(Yur - Yll)) + canvas.drawLine(XCoord-20, plotHeight + yTopOffset - (upperAdj-Yll)*plotHeight/(Yur - Yll), \ + XCoord+20, plotHeight + yTopOffset - (upperAdj-Yll)*plotHeight/(Yur - Yll)) + if lowerAdj != None: + canvas.drawLine(XCoord, plotHeight + yTopOffset - (lowHinge-Yll)*plotHeight/(Yur - Yll), \ + XCoord, plotHeight + yTopOffset - (lowerAdj-Yll)*plotHeight/(Yur - Yll)) + canvas.drawLine(XCoord-20, plotHeight + yTopOffset - (lowerAdj-Yll)*plotHeight/(Yur - Yll), \ + XCoord+20, plotHeight + yTopOffset - (lowerAdj-Yll)*plotHeight/(Yur - Yll)) + + outlierFont = pid.Font(ttf="cour",size=12,bold=0) + if outlier != []: + for item in outlier: + yc = plotHeight + yTopOffset - (item-Yll)*plotHeight/(Yur - Yll) + #canvas.drawEllipse(XCoord-3, yc-3, XCoord+3, yc+3) + canvas.drawString('o', XCoord-3, yc+5, font=outlierFont, color=pid.orange) + if extrem != []: + for item in extrem: + yc = plotHeight + yTopOffset - (item-Yll)*plotHeight/(Yur - Yll) + #canvas.drawEllipse(XCoord-3, yc-3, XCoord+3, yc+3) + canvas.drawString('*', XCoord-3, yc+6, font=outlierFont, color=pid.red) + + canvas.drawCross(XCoord, plotHeight + yTopOffset - (catMean-Yll)*plotHeight/(Yur - Yll), \ + color=pid.blue,size=3) + #print (catMean, catMedian, cat25per, cat75per) + pass + + XCoord += stepX + + labelFont=pid.Font(ttf="verdana",size=18,bold=0) + canvas.drawString(XLabel, xLeftOffset + (plotWidth -canvas.stringWidth(XLabel,font=labelFont))/2.0, \ + YCoord +40, font=labelFont) + canvas.drawString(YLabel,xLeftOffset-40, YCoord-(plotHeight -canvas.stringWidth(YLabel,font=labelFont))/2.0,\ + font=labelFont, angle =90) def plotSecurity(canvas, text="12345"): - if not text: - return - - plotWidth = canvas.size[0] - plotHeight = canvas.size[1] - if plotHeight<=0 or plotWidth<=0: - return - - bgColor = pid.Color(0.6+0.4*random.random(), 0.6+0.4*random.random(), 0.6+0.4*random.random()) - canvas.drawRect(0,0,plotWidth,plotHeight, edgeColor=bgColor, fillColor=bgColor) - - for i in range(30): - randomColor = pid.Color(0.6+0.4*random.random(), 0.6+0.4*random.random(), 0.6+0.4*random.random()) - scaleFont=pid.Font(ttf="cour",size=random.choice(range(20, 50))) - canvas.drawString(random.choice('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), - int(random.random()*plotWidth), int(random.random()*plotHeight), font=scaleFont, - color=randomColor, angle=random.choice(range(-45, 50))) - - step = (plotWidth-20)/len(text) - startX = 20 - for item in text: - randomColor = pid.Color(0.6*random.random(),0.6*random.random(), 0.6*random.random()) - scaleFont=pid.Font(ttf="verdana",size=random.choice(range(50, 60)),bold=1) - canvas.drawString(item, startX, plotHeight/2-10, font=scaleFont, - color=randomColor, angle=random.choice(range(-45, 50))) - startX += step + if not text: + return + + plotWidth = canvas.size[0] + plotHeight = canvas.size[1] + if plotHeight<=0 or plotWidth<=0: + return + + bgColor = pid.Color(0.6+0.4*random.random(), 0.6+0.4*random.random(), 0.6+0.4*random.random()) + canvas.drawRect(0,0,plotWidth,plotHeight, edgeColor=bgColor, fillColor=bgColor) + + for i in range(30): + randomColor = pid.Color(0.6+0.4*random.random(), 0.6+0.4*random.random(), 0.6+0.4*random.random()) + scaleFont=pid.Font(ttf="cour",size=random.choice(range(20, 50))) + canvas.drawString(random.choice('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), + int(random.random()*plotWidth), int(random.random()*plotHeight), font=scaleFont, + color=randomColor, angle=random.choice(range(-45, 50))) + + step = (plotWidth-20)/len(text) + startX = 20 + for item in text: + randomColor = pid.Color(0.6*random.random(),0.6*random.random(), 0.6*random.random()) + scaleFont=pid.Font(ttf="verdana",size=random.choice(range(50, 60)),bold=1) + canvas.drawString(item, startX, plotHeight/2-10, font=scaleFont, + color=randomColor, angle=random.choice(range(-45, 50))) + startX += step # parameter: data is either object returned by reaper permutation function (called by MarkerRegressionPage.py) # or the first object returned by direct (pair-scan) permu function (called by DirectPlotPage.py) def plotBar(canvas, data, barColor=pid.blue, axesColor=pid.black, labelColor=pid.black, XLabel=None, YLabel=None, title=None, offset= (60, 20, 40, 40), zoom = 1): - xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset - - plotWidth = canvas.size[0] - xLeftOffset - xRightOffset - plotHeight = canvas.size[1] - yTopOffset - yBottomOffset - if plotHeight<=0 or plotWidth<=0: - return - - if len(data) < 2: - return - - max_D = max(data) - min_D = min(data) - #add by NL 06-20-2011: fix the error: when max_D is infinite, log function in detScale will go wrong - if max_D == float('inf') or max_D>webqtlConfig.MAXLRS: - max_D=webqtlConfig.MAXLRS #maximum LRS value - - xLow, xTop, stepX = detScale(min_D, max_D) - - #reduce data - step = ceil((xTop-xLow)/50.0) - j = xLow - dataXY = [] - Count = [] - while j <= xTop: - dataXY.append(j) - Count.append(0) - j += step - - for i, item in enumerate(data): - if item == float('inf') or item>webqtlConfig.MAXLRS: - item = webqtlConfig.MAXLRS #maximum LRS value - j = int((item-xLow)/step) - Count[j] += 1 - - yLow, yTop, stepY=detScale(0,max(Count)) - - #draw data - xScale = plotWidth/(xTop-xLow) - yScale = plotHeight/(yTop-yLow) - barWidth = xScale*step - - for i, count in enumerate(Count): - if count: - xc = (dataXY[i]-xLow)*xScale+xLeftOffset - yc =-(count-yLow)*yScale+yTopOffset+plotHeight - canvas.drawRect(xc+2,yc,xc+barWidth-2,yTopOffset+plotHeight,edgeColor=barColor,fillColor=barColor) - - #draw drawing region - canvas.drawRect(xLeftOffset, yTopOffset, xLeftOffset+plotWidth, yTopOffset+plotHeight) - - #draw scale - scaleFont=pid.Font(ttf="cour",size=11,bold=1) - x=xLow - for i in range(stepX+1): - xc=xLeftOffset+(x-xLow)*xScale - canvas.drawLine(xc,yTopOffset+plotHeight,xc,yTopOffset+plotHeight+5, color=axesColor) - strX = cformat(d=x, rank=0) - canvas.drawString(strX,xc-canvas.stringWidth(strX,font=scaleFont)/2,yTopOffset+plotHeight+14,font=scaleFont) - x+= (xTop - xLow)/stepX - - y=yLow - for i in range(stepY+1): - yc=yTopOffset+plotHeight-(y-yLow)*yScale - canvas.drawLine(xLeftOffset,yc,xLeftOffset-5,yc, color=axesColor) - strY = "%d" %y - canvas.drawString(strY,xLeftOffset-canvas.stringWidth(strY,font=scaleFont)-6,yc+5,font=scaleFont) - y+= (yTop - yLow)/stepY - - #draw label - labelFont=pid.Font(ttf="tahoma",size=17,bold=0) - if XLabel: - canvas.drawString(XLabel,xLeftOffset+(plotWidth-canvas.stringWidth(XLabel,font=labelFont))/2.0, - yTopOffset+plotHeight+yBottomOffset-10,font=labelFont,color=labelColor) - - if YLabel: - canvas.drawString(YLabel, 19, yTopOffset+plotHeight-(plotHeight-canvas.stringWidth(YLabel,font=labelFont))/2.0, - font=labelFont,color=labelColor,angle=90) - - labelFont=pid.Font(ttf="verdana",size=16,bold=0) - if title: - canvas.drawString(title,xLeftOffset+(plotWidth-canvas.stringWidth(title,font=labelFont))/2.0, - 20,font=labelFont,color=labelColor) + xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset + + plotWidth = canvas.size[0] - xLeftOffset - xRightOffset + plotHeight = canvas.size[1] - yTopOffset - yBottomOffset + if plotHeight<=0 or plotWidth<=0: + return + + if len(data) < 2: + return + + max_D = max(data) + min_D = min(data) + #add by NL 06-20-2011: fix the error: when max_D is infinite, log function in detScale will go wrong + if max_D == float('inf') or max_D>webqtlConfig.MAXLRS: + max_D=webqtlConfig.MAXLRS #maximum LRS value + + xLow, xTop, stepX = detScale(min_D, max_D) + + #reduce data + step = ceil((xTop-xLow)/50.0) + j = xLow + dataXY = [] + Count = [] + while j <= xTop: + dataXY.append(j) + Count.append(0) + j += step + + for i, item in enumerate(data): + if item == float('inf') or item>webqtlConfig.MAXLRS: + item = webqtlConfig.MAXLRS #maximum LRS value + j = int((item-xLow)/step) + Count[j] += 1 + + yLow, yTop, stepY=detScale(0,max(Count)) + + #draw data + xScale = plotWidth/(xTop-xLow) + yScale = plotHeight/(yTop-yLow) + barWidth = xScale*step + + for i, count in enumerate(Count): + if count: + xc = (dataXY[i]-xLow)*xScale+xLeftOffset + yc =-(count-yLow)*yScale+yTopOffset+plotHeight + canvas.drawRect(xc+2,yc,xc+barWidth-2,yTopOffset+plotHeight,edgeColor=barColor,fillColor=barColor) + + #draw drawing region + canvas.drawRect(xLeftOffset, yTopOffset, xLeftOffset+plotWidth, yTopOffset+plotHeight) + + #draw scale + scaleFont=pid.Font(ttf="cour",size=11,bold=1) + x=xLow + for i in range(stepX+1): + xc=xLeftOffset+(x-xLow)*xScale + canvas.drawLine(xc,yTopOffset+plotHeight,xc,yTopOffset+plotHeight+5, color=axesColor) + strX = cformat(d=x, rank=0) + canvas.drawString(strX,xc-canvas.stringWidth(strX,font=scaleFont)/2,yTopOffset+plotHeight+14,font=scaleFont) + x+= (xTop - xLow)/stepX + + y=yLow + for i in range(stepY+1): + yc=yTopOffset+plotHeight-(y-yLow)*yScale + canvas.drawLine(xLeftOffset,yc,xLeftOffset-5,yc, color=axesColor) + strY = "%d" %y + canvas.drawString(strY,xLeftOffset-canvas.stringWidth(strY,font=scaleFont)-6,yc+5,font=scaleFont) + y+= (yTop - yLow)/stepY + + #draw label + labelFont=pid.Font(ttf="tahoma",size=17,bold=0) + if XLabel: + canvas.drawString(XLabel,xLeftOffset+(plotWidth-canvas.stringWidth(XLabel,font=labelFont))/2.0, + yTopOffset+plotHeight+yBottomOffset-10,font=labelFont,color=labelColor) + + if YLabel: + canvas.drawString(YLabel, 19, yTopOffset+plotHeight-(plotHeight-canvas.stringWidth(YLabel,font=labelFont))/2.0, + font=labelFont,color=labelColor,angle=90) + + labelFont=pid.Font(ttf="verdana",size=16,bold=0) + if title: + canvas.drawString(title,xLeftOffset+(plotWidth-canvas.stringWidth(title,font=labelFont))/2.0, + 20,font=labelFont,color=labelColor) def plotBarText(canvas, data, label, variance=None, barColor=pid.blue, axesColor=pid.black, labelColor=pid.black, XLabel=None, YLabel=None, title=None, sLabel = None, offset= (80, 20, 40, 100), barSpace = 2, zoom = 1): - xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset - plotWidth = canvas.size[0] - xLeftOffset - xRightOffset - plotHeight = canvas.size[1] - yTopOffset - yBottomOffset - if plotHeight<=0 or plotWidth<=0: - return - - NNN = len(data) - if NNN < 2 or NNN != len(label): - return - if variance and len(variance)!=NNN: - variance = [] - - Y2 = data[:] - if variance: - for i in range(NNN): - if variance[i]: - Y2 += [data[i]-variance[i]] - - #Y axis - YLow, YTop, stepY = detScale(min(Y2), max(Y2)) - YScale = plotHeight/(YTop - YLow) - - if YLow < 0 and YTop > 0: - drawZero = 1 - else: - drawZero = 0 - - #X axis - X = range(NNN) - Xll= 0 - Xur= NNN-1 - - - if drawZero: - YZero = yTopOffset+plotHeight-YScale*(0-YLow) - canvas.drawLine(xLeftOffset, YZero, xLeftOffset+plotWidth, YZero) - else: - YZero = yTopOffset+plotHeight - #draw data - spaceWidth = barSpace - if spaceWidth < 1: - spaceWidth = 1 - barWidth = int((plotWidth - (NNN-1.0)*spaceWidth)/NNN) - - xc= xLeftOffset - scaleFont=pid.Font(ttf="verdana",size=11,bold=0) - for i in range(NNN): - yc = yTopOffset+plotHeight-(data[i]-YLow)*YScale - canvas.drawRect(xc,YZero,xc+barWidth-1, yc, edgeColor=barColor,fillColor=barColor) - if variance and variance[i]: - varlen = variance[i]*YScale - if yc-varlen < yTopOffset: - topYd = yTopOffset - else: - topYd = yc-varlen - canvas.drawLine(xc+barWidth/2-2,yc-varlen,xc+barWidth/2+2,yc-varlen,color=pid.red) - canvas.drawLine(xc+barWidth/2,yc+varlen,xc+barWidth/2,topYd,color=pid.red) - canvas.drawLine(xc+barWidth/2-2,yc+varlen,xc+barWidth/2+2,yc+varlen,color=pid.red) - strX = label[i] - canvas.drawString(strX,xc+barWidth/2.0+2,yTopOffset+plotHeight+2+canvas.stringWidth(strX,font=scaleFont),font=scaleFont,angle=90) - xc += barWidth + spaceWidth - - #draw drawing region - canvas.drawRect(xLeftOffset, yTopOffset, xLeftOffset+plotWidth, yTopOffset+plotHeight) - - #draw Y scale - scaleFont=pid.Font(ttf="cour",size=16,bold=1) - y=YLow - for i in range(stepY+1): - yc=yTopOffset+plotHeight-(y-YLow)*YScale - canvas.drawLine(xLeftOffset,yc,xLeftOffset-5,yc, color=axesColor) - strY = cformat(d=y, rank=0) - canvas.drawString(strY,xLeftOffset-canvas.stringWidth(strY,font=scaleFont)-6,yc+5,font=scaleFont) - y+= (YTop - YLow)/stepY - - #draw label - labelFont=pid.Font(ttf="verdana",size=17,bold=0) - if XLabel: - canvas.drawString(XLabel,xLeftOffset+(plotWidth-canvas.stringWidth(XLabel,font=labelFont))/2.0,yTopOffset+plotHeight+65,font=labelFont,color=labelColor) - - if YLabel: - canvas.drawString(YLabel,xLeftOffset-50, yTopOffset+plotHeight-(plotHeight-canvas.stringWidth(YLabel,font=labelFont))/2.0,font=labelFont,color=labelColor,angle=90) - - labelFont=pid.Font(ttf="verdana",size=18,bold=0) - if title: - canvas.drawString(title,xLeftOffset,yTopOffset-15,font=labelFont,color=labelColor) - - return + xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset + plotWidth = canvas.size[0] - xLeftOffset - xRightOffset + plotHeight = canvas.size[1] - yTopOffset - yBottomOffset + if plotHeight<=0 or plotWidth<=0: + return + + NNN = len(data) + if NNN < 2 or NNN != len(label): + return + if variance and len(variance)!=NNN: + variance = [] + + Y2 = data[:] + if variance: + for i in range(NNN): + if variance[i]: + Y2 += [data[i]-variance[i]] + + #Y axis + YLow, YTop, stepY = detScale(min(Y2), max(Y2)) + YScale = plotHeight/(YTop - YLow) + + if YLow < 0 and YTop > 0: + drawZero = 1 + else: + drawZero = 0 + + #X axis + X = range(NNN) + Xll= 0 + Xur= NNN-1 + + + if drawZero: + YZero = yTopOffset+plotHeight-YScale*(0-YLow) + canvas.drawLine(xLeftOffset, YZero, xLeftOffset+plotWidth, YZero) + else: + YZero = yTopOffset+plotHeight + #draw data + spaceWidth = barSpace + if spaceWidth < 1: + spaceWidth = 1 + barWidth = int((plotWidth - (NNN-1.0)*spaceWidth)/NNN) + + xc= xLeftOffset + scaleFont=pid.Font(ttf="verdana",size=11,bold=0) + for i in range(NNN): + yc = yTopOffset+plotHeight-(data[i]-YLow)*YScale + canvas.drawRect(xc,YZero,xc+barWidth-1, yc, edgeColor=barColor,fillColor=barColor) + if variance and variance[i]: + varlen = variance[i]*YScale + if yc-varlen < yTopOffset: + topYd = yTopOffset + else: + topYd = yc-varlen + canvas.drawLine(xc+barWidth/2-2,yc-varlen,xc+barWidth/2+2,yc-varlen,color=pid.red) + canvas.drawLine(xc+barWidth/2,yc+varlen,xc+barWidth/2,topYd,color=pid.red) + canvas.drawLine(xc+barWidth/2-2,yc+varlen,xc+barWidth/2+2,yc+varlen,color=pid.red) + strX = label[i] + canvas.drawString(strX,xc+barWidth/2.0+2,yTopOffset+plotHeight+2+canvas.stringWidth(strX,font=scaleFont),font=scaleFont,angle=90) + xc += barWidth + spaceWidth + + #draw drawing region + canvas.drawRect(xLeftOffset, yTopOffset, xLeftOffset+plotWidth, yTopOffset+plotHeight) + + #draw Y scale + scaleFont=pid.Font(ttf="cour",size=16,bold=1) + y=YLow + for i in range(stepY+1): + yc=yTopOffset+plotHeight-(y-YLow)*YScale + canvas.drawLine(xLeftOffset,yc,xLeftOffset-5,yc, color=axesColor) + strY = cformat(d=y, rank=0) + canvas.drawString(strY,xLeftOffset-canvas.stringWidth(strY,font=scaleFont)-6,yc+5,font=scaleFont) + y+= (YTop - YLow)/stepY + + #draw label + labelFont=pid.Font(ttf="verdana",size=17,bold=0) + if XLabel: + canvas.drawString(XLabel,xLeftOffset+(plotWidth-canvas.stringWidth(XLabel,font=labelFont))/2.0,yTopOffset+plotHeight+65,font=labelFont,color=labelColor) + + if YLabel: + canvas.drawString(YLabel,xLeftOffset-50, yTopOffset+plotHeight-(plotHeight-canvas.stringWidth(YLabel,font=labelFont))/2.0,font=labelFont,color=labelColor,angle=90) + + labelFont=pid.Font(ttf="verdana",size=18,bold=0) + if title: + canvas.drawString(title,xLeftOffset,yTopOffset-15,font=labelFont,color=labelColor) + + return def plotXY(canvas, dataX, dataY, rank=0, dataLabel=[], plotColor = pid.black, axesColor=pid.black, labelColor=pid.black, lineSize="thin", lineColor=pid.grey, idFont="arial", idColor=pid.blue, idSize="14", symbolColor=pid.black, symbolType="circle", filled="yes", symbolSize="tiny", XLabel=None, YLabel=None, title=None, fitcurve=None, connectdot=1, displayR=None, loadingPlot = 0, offset= (80, 20, 40, 60), zoom = 1, specialCases=[], showLabel = 1, bufferSpace = 15): - 'displayR : correlation scatter plot, loadings : loading plot' - - dataXRanked, dataYRanked = webqtlUtil.calRank(dataX, dataY, len(dataX)) - - #get ID font size - idFontSize = int(idSize) - - #If filled is yes, set fill color - if filled == "yes": - fillColor = symbolColor - else: - fillColor = None - - if symbolSize == "large": - sizeModifier = 7 - fontModifier = 12 - elif symbolSize == "medium": - sizeModifier = 5 - fontModifier = 8 - elif symbolSize == "small": - sizeModifier = 3 - fontModifier = 3 - else: - sizeModifier = 1 - fontModifier = -1 - - if rank == 0: # Pearson correlation - bufferSpace = 0 - dataXPrimary = dataX - dataYPrimary = dataY - dataXAlt = dataXRanked #Values used just for printing the other corr type to the graph image - dataYAlt = dataYRanked #Values used just for printing the other corr type to the graph image - else: # Spearman correlation: Switching Ranked and Unranked X and Y values - dataXPrimary = dataXRanked - dataYPrimary = dataYRanked - dataXAlt = dataX #Values used just for printing the other corr type to the graph image - dataYAlt = dataY #Values used just for printing the other corr type to the graph image - - xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset - plotWidth = canvas.size[0] - xLeftOffset - xRightOffset - plotHeight = canvas.size[1] - yTopOffset - yBottomOffset - if plotHeight<=0 or plotWidth<=0: - return - if len(dataXPrimary) < 1 or len(dataXPrimary) != len(dataYPrimary) or (dataLabel and len(dataXPrimary) != len(dataLabel)): - return - - max_X=max(dataXPrimary) - min_X=min(dataXPrimary) - max_Y=max(dataYPrimary) - min_Y=min(dataYPrimary) - - #for some reason I forgot why I need to do this - if loadingPlot: - min_X = min(-0.1,min_X) - max_X = max(0.1,max_X) - min_Y = min(-0.1,min_Y) - max_Y = max(0.1,max_Y) - - xLow, xTop, stepX=detScale(min_X,max_X) - yLow, yTop, stepY=detScale(min_Y,max_Y) - xScale = plotWidth/(xTop-xLow) - yScale = plotHeight/(yTop-yLow) - - #draw drawing region - canvas.drawRect(xLeftOffset-bufferSpace, yTopOffset, xLeftOffset+plotWidth, yTopOffset+plotHeight+bufferSpace) - canvas.drawRect(xLeftOffset-bufferSpace+1, yTopOffset, xLeftOffset+plotWidth, yTopOffset+plotHeight+bufferSpace-1) - - #calculate data points - data = map(lambda X, Y: (X, Y), dataXPrimary, dataYPrimary) - xCoord = map(lambda X, Y: ((X-xLow)*xScale + xLeftOffset, yTopOffset+plotHeight-(Y-yLow)*yScale), dataXPrimary, dataYPrimary) - - labelFont=pid.Font(ttf=idFont,size=idFontSize,bold=0) - - if loadingPlot: - xZero = -xLow*xScale+xLeftOffset - yZero = yTopOffset+plotHeight+yLow*yScale - for point in xCoord: - canvas.drawLine(xZero,yZero,point[0],point[1],color=pid.red) - else: - if connectdot: - canvas.drawPolygon(xCoord,edgeColor=plotColor,closed=0) - else: - pass - - symbolFont = pid.Font(ttf="fnt_bs", size=12+fontModifier,bold=0) - - for i, item in enumerate(xCoord): - if dataLabel and dataLabel[i] in specialCases: - canvas.drawRect(item[0]-3, item[1]-3, item[0]+3, item[1]+3, edgeColor=pid.green) - #canvas.drawCross(item[0],item[1],color=pid.blue,size=5) - else: - if symbolType == "vertRect": - canvas.drawRect(x1=item[0]-sizeModifier+2,y1=item[1]-sizeModifier-2, x2=item[0]+sizeModifier-1,y2=item[1]+sizeModifier+2, edgeColor=symbolColor, edgeWidth=1, fillColor=fillColor) - elif (symbolType == "circle" and filled != "yes"): - canvas.drawString(":", item[0]-canvas.stringWidth(":",font=symbolFont)/2+1,item[1]+2,color=symbolColor, font=symbolFont) - elif (symbolType == "circle" and filled == "yes"): - canvas.drawString("5", item[0]-canvas.stringWidth("5",font=symbolFont)/2+1,item[1]+2,color=symbolColor, font=symbolFont) - elif symbolType == "horiRect": - canvas.drawRect(x1=item[0]-sizeModifier-1,y1=item[1]-sizeModifier+3, x2=item[0]+sizeModifier+3,y2=item[1]+sizeModifier-2, edgeColor=symbolColor, edgeWidth=1, fillColor=fillColor) - elif (symbolType == "square"): - canvas.drawRect(x1=item[0]-sizeModifier+1,y1=item[1]-sizeModifier-4, x2=item[0]+sizeModifier+2,y2=item[1]+sizeModifier-3, edgeColor=symbolColor, edgeWidth=1, fillColor=fillColor) - elif (symbolType == "diamond" and filled != "yes"): - canvas.drawString(",", item[0]-canvas.stringWidth(",",font=symbolFont)/2+2, item[1]+6, font=symbolFont, color=symbolColor) - elif (symbolType == "diamond" and filled == "yes"): - canvas.drawString("D", item[0]-canvas.stringWidth("D",font=symbolFont)/2+2, item[1]+6, font=symbolFont, color=symbolColor) - elif symbolType == "4-star": - canvas.drawString("l", item[0]-canvas.stringWidth("l",font=symbolFont)/2+1, item[1]+3, font=symbolFont, color=symbolColor) - elif symbolType == "3-star": - canvas.drawString("k", item[0]-canvas.stringWidth("k",font=symbolFont)/2+1, item[1]+3, font=symbolFont, color=symbolColor) - else: - canvas.drawCross(item[0],item[1]-2,color=symbolColor, size=sizeModifier+2) - - if showLabel and dataLabel: - if (symbolType == "vertRect" or symbolType == "diamond"): - labelGap = 15 - elif (symbolType == "4-star" or symbolType == "3-star"): - labelGap = 12 - else: - labelGap = 11 - canvas.drawString(dataLabel[i], item[0]- canvas.stringWidth(dataLabel[i], - font=labelFont)/2 + 1, item[1]+(labelGap+sizeModifier+(idFontSize-12)), font=labelFont, color=idColor) - - #draw scale - scaleFont=pid.Font(ttf="cour",size=16,bold=1) - - - x=xLow - for i in range(stepX+1): - xc=xLeftOffset+(x-xLow)*xScale - if ((x == 0) & (rank == 1)): - pass - else: - canvas.drawLine(xc,yTopOffset+plotHeight + bufferSpace,xc,yTopOffset+plotHeight+5 + bufferSpace, color=axesColor) - strX = cformat(d=x, rank=rank) - if ((strX == "0") & (rank == 1)): - pass - else: - canvas.drawString(strX,xc-canvas.stringWidth(strX,font=scaleFont)/2,yTopOffset+plotHeight+20 + bufferSpace,font=scaleFont) - x+= (xTop - xLow)/stepX - - y=yLow - for i in range(stepY+1): - yc=yTopOffset+plotHeight-(y-yLow)*yScale - if ((y == 0) & (rank == 1)): - pass - else: - canvas.drawLine(xLeftOffset - bufferSpace,yc,xLeftOffset-5 - bufferSpace,yc, color=axesColor) - strY = cformat(d=y, rank=rank) - if ((strY == "0") & (rank == 1)): - pass - else: - canvas.drawString(strY,xLeftOffset-canvas.stringWidth(strY,font=scaleFont)- 10 - bufferSpace,yc+4,font=scaleFont) - y+= (yTop - yLow)/stepY - - #draw label - - labelFont=pid.Font(ttf="verdana",size=canvas.size[0]/45,bold=0) - titleFont=pid.Font(ttf="verdana",size=canvas.size[0]/40,bold=0) - - if (rank == 1 and not title): - canvas.drawString("Spearman Rank Correlation", xLeftOffset-canvas.size[0]*.025+(plotWidth-canvas.stringWidth("Spearman Rank Correlation",font=titleFont))/2.0, - 25,font=titleFont,color=labelColor) - elif (rank == 0 and not title): - canvas.drawString("Pearson Correlation", xLeftOffset-canvas.size[0]*.025+(plotWidth-canvas.stringWidth("Pearson Correlation",font=titleFont))/2.0, - 25,font=titleFont,color=labelColor) - - if XLabel: - canvas.drawString(XLabel,xLeftOffset+(plotWidth-canvas.stringWidth(XLabel,font=labelFont))/2.0, - yTopOffset+plotHeight+yBottomOffset-25,font=labelFont,color=labelColor) - - if YLabel: - canvas.drawString(YLabel, xLeftOffset-65, yTopOffset+plotHeight- (plotHeight-canvas.stringWidth(YLabel,font=labelFont))/2.0, - font=labelFont,color=labelColor,angle=90) - - labelFont=pid.Font(ttf="verdana",size=20,bold=0) - if title: - canvas.drawString(title,xLeftOffset+(plotWidth-canvas.stringWidth(title,font=labelFont))/2.0, - 20,font=labelFont,color=labelColor) - - if fitcurve: - import sys - sys.argv = [ "mod_python" ] - #from numarray import linear_algebra as la - #from numarray import ones, array, dot, swapaxes - fitYY = array(dataYPrimary) - fitXX = array([ones(len(dataXPrimary)),dataXPrimary]) - AA = dot(fitXX,swapaxes(fitXX,0,1)) - BB = dot(fitXX,fitYY) - bb = la.linear_least_squares(AA,BB)[0] - - xc1 = xLeftOffset - yc1 = yTopOffset+plotHeight-(bb[0]+bb[1]*xLow-yLow)*yScale - if yc1 > yTopOffset+plotHeight: - yc1 = yTopOffset+plotHeight - xc1 = (yLow-bb[0])/bb[1] - xc1=(xc1-xLow)*xScale+xLeftOffset - elif yc1 < yTopOffset: - yc1 = yTopOffset - xc1 = (yTop-bb[0])/bb[1] - xc1=(xc1-xLow)*xScale+xLeftOffset - else: - pass - - xc2 = xLeftOffset + plotWidth - yc2 = yTopOffset+plotHeight-(bb[0]+bb[1]*xTop-yLow)*yScale - if yc2 > yTopOffset+plotHeight: - yc2 = yTopOffset+plotHeight - xc2 = (yLow-bb[0])/bb[1] - xc2=(xc2-xLow)*xScale+xLeftOffset - elif yc2 < yTopOffset: - yc2 = yTopOffset - xc2 = (yTop-bb[0])/bb[1] - xc2=(xc2-xLow)*xScale+xLeftOffset - else: - pass - - canvas.drawLine(xc1 - bufferSpace,yc1 + bufferSpace,xc2,yc2,color=lineColor) - if lineSize == "medium": - canvas.drawLine(xc1 - bufferSpace,yc1 + bufferSpace+1,xc2,yc2+1,color=lineColor) - if lineSize == "thick": - canvas.drawLine(xc1 - bufferSpace,yc1 + bufferSpace+1,xc2,yc2+1,color=lineColor) - canvas.drawLine(xc1 - bufferSpace,yc1 + bufferSpace-1,xc2,yc2-1,color=lineColor) - - - if displayR: - labelFont=pid.Font(ttf="trebuc",size=canvas.size[0]/60,bold=0) - NNN = len(dataX) - corr = webqtlUtil.calCorrelation(dataXPrimary,dataYPrimary,NNN)[0] - - if NNN < 3: - corrPValue = 1.0 - else: - if abs(corr) >= 1.0: - corrPValue = 0.0 - else: - ZValue = 0.5*log((1.0+corr)/(1.0-corr)) - ZValue = ZValue*sqrt(NNN-3) - corrPValue = 2.0*(1.0 - reaper.normp(abs(ZValue))) - - NStr = "N = %d" % NNN - strLenN = canvas.stringWidth(NStr,font=labelFont) - - if rank == 1: - if corrPValue < 0.0000000000000001: - corrStr = "Rho = %1.3f P < 1.00 E-16" % (corr) - else: - corrStr = "Rho = %1.3f P = %3.2E" % (corr, corrPValue) - else: - if corrPValue < 0.0000000000000001: - corrStr = "r = %1.3f P < 1.00 E-16" % (corr) - else: - corrStr = "r = %1.3f P = %3.2E" % (corr, corrPValue) - strLen = canvas.stringWidth(corrStr,font=labelFont) - - canvas.drawString(NStr,xLeftOffset,yTopOffset-10,font=labelFont,color=labelColor) - canvas.drawString(corrStr,xLeftOffset+plotWidth-strLen,yTopOffset-10,font=labelFont,color=labelColor) - - return xCoord + 'displayR : correlation scatter plot, loadings : loading plot' + + dataXRanked, dataYRanked = webqtlUtil.calRank(dataX, dataY, len(dataX)) + + #get ID font size + idFontSize = int(idSize) + + #If filled is yes, set fill color + if filled == "yes": + fillColor = symbolColor + else: + fillColor = None + + if symbolSize == "large": + sizeModifier = 7 + fontModifier = 12 + elif symbolSize == "medium": + sizeModifier = 5 + fontModifier = 8 + elif symbolSize == "small": + sizeModifier = 3 + fontModifier = 3 + else: + sizeModifier = 1 + fontModifier = -1 + + if rank == 0: # Pearson correlation + bufferSpace = 0 + dataXPrimary = dataX + dataYPrimary = dataY + dataXAlt = dataXRanked #Values used just for printing the other corr type to the graph image + dataYAlt = dataYRanked #Values used just for printing the other corr type to the graph image + else: # Spearman correlation: Switching Ranked and Unranked X and Y values + dataXPrimary = dataXRanked + dataYPrimary = dataYRanked + dataXAlt = dataX #Values used just for printing the other corr type to the graph image + dataYAlt = dataY #Values used just for printing the other corr type to the graph image + + xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset + plotWidth = canvas.size[0] - xLeftOffset - xRightOffset + plotHeight = canvas.size[1] - yTopOffset - yBottomOffset + if plotHeight<=0 or plotWidth<=0: + return + if len(dataXPrimary) < 1 or len(dataXPrimary) != len(dataYPrimary) or (dataLabel and len(dataXPrimary) != len(dataLabel)): + return + + max_X=max(dataXPrimary) + min_X=min(dataXPrimary) + max_Y=max(dataYPrimary) + min_Y=min(dataYPrimary) + + #for some reason I forgot why I need to do this + if loadingPlot: + min_X = min(-0.1,min_X) + max_X = max(0.1,max_X) + min_Y = min(-0.1,min_Y) + max_Y = max(0.1,max_Y) + + xLow, xTop, stepX=detScale(min_X,max_X) + yLow, yTop, stepY=detScale(min_Y,max_Y) + xScale = plotWidth/(xTop-xLow) + yScale = plotHeight/(yTop-yLow) + + #draw drawing region + canvas.drawRect(xLeftOffset-bufferSpace, yTopOffset, xLeftOffset+plotWidth, yTopOffset+plotHeight+bufferSpace) + canvas.drawRect(xLeftOffset-bufferSpace+1, yTopOffset, xLeftOffset+plotWidth, yTopOffset+plotHeight+bufferSpace-1) + + #calculate data points + data = map(lambda X, Y: (X, Y), dataXPrimary, dataYPrimary) + xCoord = map(lambda X, Y: ((X-xLow)*xScale + xLeftOffset, yTopOffset+plotHeight-(Y-yLow)*yScale), dataXPrimary, dataYPrimary) + + labelFont=pid.Font(ttf=idFont,size=idFontSize,bold=0) + + if loadingPlot: + xZero = -xLow*xScale+xLeftOffset + yZero = yTopOffset+plotHeight+yLow*yScale + for point in xCoord: + canvas.drawLine(xZero,yZero,point[0],point[1],color=pid.red) + else: + if connectdot: + canvas.drawPolygon(xCoord,edgeColor=plotColor,closed=0) + else: + pass + + symbolFont = pid.Font(ttf="fnt_bs", size=12+fontModifier,bold=0) + + for i, item in enumerate(xCoord): + if dataLabel and dataLabel[i] in specialCases: + canvas.drawRect(item[0]-3, item[1]-3, item[0]+3, item[1]+3, edgeColor=pid.green) + #canvas.drawCross(item[0],item[1],color=pid.blue,size=5) + else: + if symbolType == "vertRect": + canvas.drawRect(x1=item[0]-sizeModifier+2,y1=item[1]-sizeModifier-2, x2=item[0]+sizeModifier-1,y2=item[1]+sizeModifier+2, edgeColor=symbolColor, edgeWidth=1, fillColor=fillColor) + elif (symbolType == "circle" and filled != "yes"): + canvas.drawString(":", item[0]-canvas.stringWidth(":",font=symbolFont)/2+1,item[1]+2,color=symbolColor, font=symbolFont) + elif (symbolType == "circle" and filled == "yes"): + canvas.drawString("5", item[0]-canvas.stringWidth("5",font=symbolFont)/2+1,item[1]+2,color=symbolColor, font=symbolFont) + elif symbolType == "horiRect": + canvas.drawRect(x1=item[0]-sizeModifier-1,y1=item[1]-sizeModifier+3, x2=item[0]+sizeModifier+3,y2=item[1]+sizeModifier-2, edgeColor=symbolColor, edgeWidth=1, fillColor=fillColor) + elif (symbolType == "square"): + canvas.drawRect(x1=item[0]-sizeModifier+1,y1=item[1]-sizeModifier-4, x2=item[0]+sizeModifier+2,y2=item[1]+sizeModifier-3, edgeColor=symbolColor, edgeWidth=1, fillColor=fillColor) + elif (symbolType == "diamond" and filled != "yes"): + canvas.drawString(",", item[0]-canvas.stringWidth(",",font=symbolFont)/2+2, item[1]+6, font=symbolFont, color=symbolColor) + elif (symbolType == "diamond" and filled == "yes"): + canvas.drawString("D", item[0]-canvas.stringWidth("D",font=symbolFont)/2+2, item[1]+6, font=symbolFont, color=symbolColor) + elif symbolType == "4-star": + canvas.drawString("l", item[0]-canvas.stringWidth("l",font=symbolFont)/2+1, item[1]+3, font=symbolFont, color=symbolColor) + elif symbolType == "3-star": + canvas.drawString("k", item[0]-canvas.stringWidth("k",font=symbolFont)/2+1, item[1]+3, font=symbolFont, color=symbolColor) + else: + canvas.drawCross(item[0],item[1]-2,color=symbolColor, size=sizeModifier+2) + + if showLabel and dataLabel: + if (symbolType == "vertRect" or symbolType == "diamond"): + labelGap = 15 + elif (symbolType == "4-star" or symbolType == "3-star"): + labelGap = 12 + else: + labelGap = 11 + canvas.drawString(dataLabel[i], item[0]- canvas.stringWidth(dataLabel[i], + font=labelFont)/2 + 1, item[1]+(labelGap+sizeModifier+(idFontSize-12)), font=labelFont, color=idColor) + + #draw scale + scaleFont=pid.Font(ttf="cour",size=16,bold=1) + + + x=xLow + for i in range(stepX+1): + xc=xLeftOffset+(x-xLow)*xScale + if ((x == 0) & (rank == 1)): + pass + else: + canvas.drawLine(xc,yTopOffset+plotHeight + bufferSpace,xc,yTopOffset+plotHeight+5 + bufferSpace, color=axesColor) + strX = cformat(d=x, rank=rank) + if ((strX == "0") & (rank == 1)): + pass + else: + canvas.drawString(strX,xc-canvas.stringWidth(strX,font=scaleFont)/2,yTopOffset+plotHeight+20 + bufferSpace,font=scaleFont) + x+= (xTop - xLow)/stepX + + y=yLow + for i in range(stepY+1): + yc=yTopOffset+plotHeight-(y-yLow)*yScale + if ((y == 0) & (rank == 1)): + pass + else: + canvas.drawLine(xLeftOffset - bufferSpace,yc,xLeftOffset-5 - bufferSpace,yc, color=axesColor) + strY = cformat(d=y, rank=rank) + if ((strY == "0") & (rank == 1)): + pass + else: + canvas.drawString(strY,xLeftOffset-canvas.stringWidth(strY,font=scaleFont)- 10 - bufferSpace,yc+4,font=scaleFont) + y+= (yTop - yLow)/stepY + + #draw label + + labelFont=pid.Font(ttf="verdana",size=canvas.size[0]/45,bold=0) + titleFont=pid.Font(ttf="verdana",size=canvas.size[0]/40,bold=0) + + if (rank == 1 and not title): + canvas.drawString("Spearman Rank Correlation", xLeftOffset-canvas.size[0]*.025+(plotWidth-canvas.stringWidth("Spearman Rank Correlation",font=titleFont))/2.0, + 25,font=titleFont,color=labelColor) + elif (rank == 0 and not title): + canvas.drawString("Pearson Correlation", xLeftOffset-canvas.size[0]*.025+(plotWidth-canvas.stringWidth("Pearson Correlation",font=titleFont))/2.0, + 25,font=titleFont,color=labelColor) + + if XLabel: + canvas.drawString(XLabel,xLeftOffset+(plotWidth-canvas.stringWidth(XLabel,font=labelFont))/2.0, + yTopOffset+plotHeight+yBottomOffset-25,font=labelFont,color=labelColor) + + if YLabel: + canvas.drawString(YLabel, xLeftOffset-65, yTopOffset+plotHeight- (plotHeight-canvas.stringWidth(YLabel,font=labelFont))/2.0, + font=labelFont,color=labelColor,angle=90) + + labelFont=pid.Font(ttf="verdana",size=20,bold=0) + if title: + canvas.drawString(title,xLeftOffset+(plotWidth-canvas.stringWidth(title,font=labelFont))/2.0, + 20,font=labelFont,color=labelColor) + + if fitcurve: + import sys + sys.argv = [ "mod_python" ] + #from numarray import linear_algebra as la + #from numarray import ones, array, dot, swapaxes + fitYY = array(dataYPrimary) + fitXX = array([ones(len(dataXPrimary)),dataXPrimary]) + AA = dot(fitXX,swapaxes(fitXX,0,1)) + BB = dot(fitXX,fitYY) + bb = la.linear_least_squares(AA,BB)[0] + + xc1 = xLeftOffset + yc1 = yTopOffset+plotHeight-(bb[0]+bb[1]*xLow-yLow)*yScale + if yc1 > yTopOffset+plotHeight: + yc1 = yTopOffset+plotHeight + xc1 = (yLow-bb[0])/bb[1] + xc1=(xc1-xLow)*xScale+xLeftOffset + elif yc1 < yTopOffset: + yc1 = yTopOffset + xc1 = (yTop-bb[0])/bb[1] + xc1=(xc1-xLow)*xScale+xLeftOffset + else: + pass + + xc2 = xLeftOffset + plotWidth + yc2 = yTopOffset+plotHeight-(bb[0]+bb[1]*xTop-yLow)*yScale + if yc2 > yTopOffset+plotHeight: + yc2 = yTopOffset+plotHeight + xc2 = (yLow-bb[0])/bb[1] + xc2=(xc2-xLow)*xScale+xLeftOffset + elif yc2 < yTopOffset: + yc2 = yTopOffset + xc2 = (yTop-bb[0])/bb[1] + xc2=(xc2-xLow)*xScale+xLeftOffset + else: + pass + + canvas.drawLine(xc1 - bufferSpace,yc1 + bufferSpace,xc2,yc2,color=lineColor) + if lineSize == "medium": + canvas.drawLine(xc1 - bufferSpace,yc1 + bufferSpace+1,xc2,yc2+1,color=lineColor) + if lineSize == "thick": + canvas.drawLine(xc1 - bufferSpace,yc1 + bufferSpace+1,xc2,yc2+1,color=lineColor) + canvas.drawLine(xc1 - bufferSpace,yc1 + bufferSpace-1,xc2,yc2-1,color=lineColor) + + + if displayR: + labelFont=pid.Font(ttf="trebuc",size=canvas.size[0]/60,bold=0) + NNN = len(dataX) + corr = webqtlUtil.calCorrelation(dataXPrimary,dataYPrimary,NNN)[0] + + if NNN < 3: + corrPValue = 1.0 + else: + if abs(corr) >= 1.0: + corrPValue = 0.0 + else: + ZValue = 0.5*log((1.0+corr)/(1.0-corr)) + ZValue = ZValue*sqrt(NNN-3) + corrPValue = 2.0*(1.0 - reaper.normp(abs(ZValue))) + + NStr = "N = %d" % NNN + strLenN = canvas.stringWidth(NStr,font=labelFont) + + if rank == 1: + if corrPValue < 0.0000000000000001: + corrStr = "Rho = %1.3f P < 1.00 E-16" % (corr) + else: + corrStr = "Rho = %1.3f P = %3.2E" % (corr, corrPValue) + else: + if corrPValue < 0.0000000000000001: + corrStr = "r = %1.3f P < 1.00 E-16" % (corr) + else: + corrStr = "r = %1.3f P = %3.2E" % (corr, corrPValue) + strLen = canvas.stringWidth(corrStr,font=labelFont) + + canvas.drawString(NStr,xLeftOffset,yTopOffset-10,font=labelFont,color=labelColor) + canvas.drawString(corrStr,xLeftOffset+plotWidth-strLen,yTopOffset-10,font=labelFont,color=labelColor) + + return xCoord def plotXYSVG(drawSpace, dataX, dataY, rank=0, dataLabel=[], plotColor = "black", axesColor="black", labelColor="black", symbolColor="red", XLabel=None, YLabel=None, title=None, fitcurve=None, connectdot=1, displayR=None, loadingPlot = 0, offset= (80, 20, 40, 60), zoom = 1, specialCases=[], showLabel = 1): - 'displayR : correlation scatter plot, loadings : loading plot' - - dataXRanked, dataYRanked = webqtlUtil.calRank(dataX, dataY, len(dataX)) - - # Switching Ranked and Unranked X and Y values if a Spearman Rank Correlation - if rank == 0: - dataXPrimary = dataX - dataYPrimary = dataY - dataXAlt = dataXRanked - dataYAlt = dataYRanked - - else: - dataXPrimary = dataXRanked - dataYPrimary = dataYRanked - dataXAlt = dataX - dataYAlt = dataY - - - - xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset - plotWidth = drawSpace.attributes['width'] - xLeftOffset - xRightOffset - plotHeight = drawSpace.attributes['height'] - yTopOffset - yBottomOffset - if plotHeight<=0 or plotWidth<=0: - return - if len(dataXPrimary) < 1 or len(dataXPrimary) != len(dataYPrimary) or (dataLabel and len(dataXPrimary) != len(dataLabel)): - return - - max_X=max(dataXPrimary) - min_X=min(dataXPrimary) - max_Y=max(dataYPrimary) - min_Y=min(dataYPrimary) - - #for some reason I forgot why I need to do this - if loadingPlot: - min_X = min(-0.1,min_X) - max_X = max(0.1,max_X) - min_Y = min(-0.1,min_Y) - max_Y = max(0.1,max_Y) - - xLow, xTop, stepX=detScale(min_X,max_X) - yLow, yTop, stepY=detScale(min_Y,max_Y) - xScale = plotWidth/(xTop-xLow) - yScale = plotHeight/(yTop-yLow) - - #draw drawing region - r = svg.rect(xLeftOffset, yTopOffset, plotWidth, plotHeight, 'none', axesColor, 1) - drawSpace.addElement(r) - - #calculate data points - data = map(lambda X, Y: (X, Y), dataXPrimary, dataYPrimary) - xCoord = map(lambda X, Y: ((X-xLow)*xScale + xLeftOffset, yTopOffset+plotHeight-(Y-yLow)*yScale), dataXPrimary, dataYPrimary) - labelFontF = "verdana" - labelFontS = 11 - - if loadingPlot: - xZero = -xLow*xScale+xLeftOffset - yZero = yTopOffset+plotHeight+yLow*yScale - for point in xCoord: - drawSpace.addElement(svg.line(xZero,yZero,point[0],point[1], "red", 1)) - else: - if connectdot: - pass - #drawSpace.drawPolygon(xCoord,edgeColor=plotColor,closed=0) - else: - pass - - for i, item in enumerate(xCoord): - if dataLabel and dataLabel[i] in specialCases: - drawSpace.addElement(svg.rect(item[0]-3, item[1]-3, 6, 6, "none", "green", 0.5)) - #drawSpace.drawCross(item[0],item[1],color=pid.blue,size=5) - else: - drawSpace.addElement(svg.line(item[0],item[1]+5,item[0],item[1]-5,symbolColor,1)) - drawSpace.addElement(svg.line(item[0]+5,item[1],item[0]-5,item[1],symbolColor,1)) - if showLabel and dataLabel: - pass - drawSpace.addElement(svg.text(item[0], item[1]+14, dataLabel[i], labelFontS, - labelFontF, text_anchor="middle", style="stroke:blue;stroke-width:0.5;")) - #canvas.drawString(, item[0]- canvas.stringWidth(dataLabel[i], - # font=labelFont)/2, item[1]+14, font=labelFont, color=pid.blue) - - #draw scale - #scaleFont=pid.Font(ttf="cour",size=14,bold=1) - x=xLow - for i in range(stepX+1): - xc=xLeftOffset+(x-xLow)*xScale - drawSpace.addElement(svg.line(xc,yTopOffset+plotHeight,xc,yTopOffset+plotHeight+5, axesColor, 1)) - strX = cformat(d=x, rank=rank) - drawSpace.addElement(svg.text(xc,yTopOffset+plotHeight+20,strX,13, "courier", text_anchor="middle")) - x+= (xTop - xLow)/stepX - - y=yLow - for i in range(stepY+1): - yc=yTopOffset+plotHeight-(y-yLow)*yScale - drawSpace.addElement(svg.line(xLeftOffset,yc,xLeftOffset-5,yc, axesColor, 1)) - strY = cformat(d=y, rank=rank) - drawSpace.addElement(svg.text(xLeftOffset-10,yc+5,strY,13, "courier", text_anchor="end")) - y+= (yTop - yLow)/stepY - - #draw label - labelFontF = "verdana" - labelFontS = 17 - if XLabel: - drawSpace.addElement(svg.text(xLeftOffset+plotWidth/2.0, - yTopOffset+plotHeight+yBottomOffset-10,XLabel, - labelFontS, labelFontF, text_anchor="middle")) - - if YLabel: - drawSpace.addElement(svg.text(xLeftOffset-50, - yTopOffset+plotHeight/2,YLabel, - labelFontS, labelFontF, text_anchor="middle", style="writing-mode:tb-rl", transform="rotate(270 %d %d)" % (xLeftOffset-50, yTopOffset+plotHeight/2))) - #drawSpace.drawString(YLabel, xLeftOffset-50, yTopOffset+plotHeight- (plotHeight-drawSpace.stringWidth(YLabel,font=labelFont))/2.0, - # font=labelFont,color=labelColor,angle=90) - - - if fitcurve: - sys.argv = [ "mod_python" ] - #from numarray import linear_algebra as la - #from numarray import ones, array, dot, swapaxes - fitYY = array(dataYPrimary) - fitXX = array([ones(len(dataXPrimary)),dataXPrimary]) - AA = dot(fitXX,swapaxes(fitXX,0,1)) - BB = dot(fitXX,fitYY) - bb = la.linear_least_squares(AA,BB)[0] - - xc1 = xLeftOffset - yc1 = yTopOffset+plotHeight-(bb[0]+bb[1]*xLow-yLow)*yScale - if yc1 > yTopOffset+plotHeight: - yc1 = yTopOffset+plotHeight - xc1 = (yLow-bb[0])/bb[1] - xc1=(xc1-xLow)*xScale+xLeftOffset - elif yc1 < yTopOffset: - yc1 = yTopOffset - xc1 = (yTop-bb[0])/bb[1] - xc1=(xc1-xLow)*xScale+xLeftOffset - else: - pass - - xc2 = xLeftOffset + plotWidth - yc2 = yTopOffset+plotHeight-(bb[0]+bb[1]*xTop-yLow)*yScale - if yc2 > yTopOffset+plotHeight: - yc2 = yTopOffset+plotHeight - xc2 = (yLow-bb[0])/bb[1] - xc2=(xc2-xLow)*xScale+xLeftOffset - elif yc2 < yTopOffset: - yc2 = yTopOffset - xc2 = (yTop-bb[0])/bb[1] - xc2=(xc2-xLow)*xScale+xLeftOffset - else: - pass - - drawSpace.addElement(svg.line(xc1,yc1,xc2,yc2,"green", 1)) - - if displayR: - labelFontF = "trebuc" - labelFontS = 14 - NNN = len(dataX) - - corr = webqtlUtil.calCorrelation(dataXPrimary,dataYPrimary,NNN)[0] - - if NNN < 3: - corrPValue = 1.0 - else: - if abs(corr) >= 1.0: - corrPValue = 0.0 - else: - ZValue = 0.5*log((1.0+corr)/(1.0-corr)) - ZValue = ZValue*sqrt(NNN-3) - corrPValue = 2.0*(1.0 - reaper.normp(abs(ZValue))) - - NStr = "N of Cases=%d" % NNN - - if rank == 1: - corrStr = "Spearman's r=%1.3f P=%3.2E" % (corr, corrPValue) - else: - corrStr = "Pearson's r=%1.3f P=%3.2E" % (corr, corrPValue) - - drawSpace.addElement(svg.text(xLeftOffset,yTopOffset-10,NStr, - labelFontS, labelFontF, text_anchor="start")) - drawSpace.addElement(svg.text(xLeftOffset+plotWidth,yTopOffset-25,corrStr, - labelFontS, labelFontF, text_anchor="end")) - """ - """ - return + 'displayR : correlation scatter plot, loadings : loading plot' + + dataXRanked, dataYRanked = webqtlUtil.calRank(dataX, dataY, len(dataX)) + + # Switching Ranked and Unranked X and Y values if a Spearman Rank Correlation + if rank == 0: + dataXPrimary = dataX + dataYPrimary = dataY + dataXAlt = dataXRanked + dataYAlt = dataYRanked + + else: + dataXPrimary = dataXRanked + dataYPrimary = dataYRanked + dataXAlt = dataX + dataYAlt = dataY + + + + xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset + plotWidth = drawSpace.attributes['width'] - xLeftOffset - xRightOffset + plotHeight = drawSpace.attributes['height'] - yTopOffset - yBottomOffset + if plotHeight<=0 or plotWidth<=0: + return + if len(dataXPrimary) < 1 or len(dataXPrimary) != len(dataYPrimary) or (dataLabel and len(dataXPrimary) != len(dataLabel)): + return + + max_X=max(dataXPrimary) + min_X=min(dataXPrimary) + max_Y=max(dataYPrimary) + min_Y=min(dataYPrimary) + + #for some reason I forgot why I need to do this + if loadingPlot: + min_X = min(-0.1,min_X) + max_X = max(0.1,max_X) + min_Y = min(-0.1,min_Y) + max_Y = max(0.1,max_Y) + + xLow, xTop, stepX=detScale(min_X,max_X) + yLow, yTop, stepY=detScale(min_Y,max_Y) + xScale = plotWidth/(xTop-xLow) + yScale = plotHeight/(yTop-yLow) + + #draw drawing region + r = svg.rect(xLeftOffset, yTopOffset, plotWidth, plotHeight, 'none', axesColor, 1) + drawSpace.addElement(r) + + #calculate data points + data = map(lambda X, Y: (X, Y), dataXPrimary, dataYPrimary) + xCoord = map(lambda X, Y: ((X-xLow)*xScale + xLeftOffset, yTopOffset+plotHeight-(Y-yLow)*yScale), dataXPrimary, dataYPrimary) + labelFontF = "verdana" + labelFontS = 11 + + if loadingPlot: + xZero = -xLow*xScale+xLeftOffset + yZero = yTopOffset+plotHeight+yLow*yScale + for point in xCoord: + drawSpace.addElement(svg.line(xZero,yZero,point[0],point[1], "red", 1)) + else: + if connectdot: + pass + #drawSpace.drawPolygon(xCoord,edgeColor=plotColor,closed=0) + else: + pass + + for i, item in enumerate(xCoord): + if dataLabel and dataLabel[i] in specialCases: + drawSpace.addElement(svg.rect(item[0]-3, item[1]-3, 6, 6, "none", "green", 0.5)) + #drawSpace.drawCross(item[0],item[1],color=pid.blue,size=5) + else: + drawSpace.addElement(svg.line(item[0],item[1]+5,item[0],item[1]-5,symbolColor,1)) + drawSpace.addElement(svg.line(item[0]+5,item[1],item[0]-5,item[1],symbolColor,1)) + if showLabel and dataLabel: + pass + drawSpace.addElement(svg.text(item[0], item[1]+14, dataLabel[i], labelFontS, + labelFontF, text_anchor="middle", style="stroke:blue;stroke-width:0.5;")) + #canvas.drawString(, item[0]- canvas.stringWidth(dataLabel[i], + # font=labelFont)/2, item[1]+14, font=labelFont, color=pid.blue) + + #draw scale + #scaleFont=pid.Font(ttf="cour",size=14,bold=1) + x=xLow + for i in range(stepX+1): + xc=xLeftOffset+(x-xLow)*xScale + drawSpace.addElement(svg.line(xc,yTopOffset+plotHeight,xc,yTopOffset+plotHeight+5, axesColor, 1)) + strX = cformat(d=x, rank=rank) + drawSpace.addElement(svg.text(xc,yTopOffset+plotHeight+20,strX,13, "courier", text_anchor="middle")) + x+= (xTop - xLow)/stepX + + y=yLow + for i in range(stepY+1): + yc=yTopOffset+plotHeight-(y-yLow)*yScale + drawSpace.addElement(svg.line(xLeftOffset,yc,xLeftOffset-5,yc, axesColor, 1)) + strY = cformat(d=y, rank=rank) + drawSpace.addElement(svg.text(xLeftOffset-10,yc+5,strY,13, "courier", text_anchor="end")) + y+= (yTop - yLow)/stepY + + #draw label + labelFontF = "verdana" + labelFontS = 17 + if XLabel: + drawSpace.addElement(svg.text(xLeftOffset+plotWidth/2.0, + yTopOffset+plotHeight+yBottomOffset-10,XLabel, + labelFontS, labelFontF, text_anchor="middle")) + + if YLabel: + drawSpace.addElement(svg.text(xLeftOffset-50, + yTopOffset+plotHeight/2,YLabel, + labelFontS, labelFontF, text_anchor="middle", style="writing-mode:tb-rl", transform="rotate(270 %d %d)" % (xLeftOffset-50, yTopOffset+plotHeight/2))) + #drawSpace.drawString(YLabel, xLeftOffset-50, yTopOffset+plotHeight- (plotHeight-drawSpace.stringWidth(YLabel,font=labelFont))/2.0, + # font=labelFont,color=labelColor,angle=90) + + + if fitcurve: + sys.argv = [ "mod_python" ] + #from numarray import linear_algebra as la + #from numarray import ones, array, dot, swapaxes + fitYY = array(dataYPrimary) + fitXX = array([ones(len(dataXPrimary)),dataXPrimary]) + AA = dot(fitXX,swapaxes(fitXX,0,1)) + BB = dot(fitXX,fitYY) + bb = la.linear_least_squares(AA,BB)[0] + + xc1 = xLeftOffset + yc1 = yTopOffset+plotHeight-(bb[0]+bb[1]*xLow-yLow)*yScale + if yc1 > yTopOffset+plotHeight: + yc1 = yTopOffset+plotHeight + xc1 = (yLow-bb[0])/bb[1] + xc1=(xc1-xLow)*xScale+xLeftOffset + elif yc1 < yTopOffset: + yc1 = yTopOffset + xc1 = (yTop-bb[0])/bb[1] + xc1=(xc1-xLow)*xScale+xLeftOffset + else: + pass + + xc2 = xLeftOffset + plotWidth + yc2 = yTopOffset+plotHeight-(bb[0]+bb[1]*xTop-yLow)*yScale + if yc2 > yTopOffset+plotHeight: + yc2 = yTopOffset+plotHeight + xc2 = (yLow-bb[0])/bb[1] + xc2=(xc2-xLow)*xScale+xLeftOffset + elif yc2 < yTopOffset: + yc2 = yTopOffset + xc2 = (yTop-bb[0])/bb[1] + xc2=(xc2-xLow)*xScale+xLeftOffset + else: + pass + + drawSpace.addElement(svg.line(xc1,yc1,xc2,yc2,"green", 1)) + + if displayR: + labelFontF = "trebuc" + labelFontS = 14 + NNN = len(dataX) + + corr = webqtlUtil.calCorrelation(dataXPrimary,dataYPrimary,NNN)[0] + + if NNN < 3: + corrPValue = 1.0 + else: + if abs(corr) >= 1.0: + corrPValue = 0.0 + else: + ZValue = 0.5*log((1.0+corr)/(1.0-corr)) + ZValue = ZValue*sqrt(NNN-3) + corrPValue = 2.0*(1.0 - reaper.normp(abs(ZValue))) + + NStr = "N of Cases=%d" % NNN + + if rank == 1: + corrStr = "Spearman's r=%1.3f P=%3.2E" % (corr, corrPValue) + else: + corrStr = "Pearson's r=%1.3f P=%3.2E" % (corr, corrPValue) + + drawSpace.addElement(svg.text(xLeftOffset,yTopOffset-10,NStr, + labelFontS, labelFontF, text_anchor="start")) + drawSpace.addElement(svg.text(xLeftOffset+plotWidth,yTopOffset-25,corrStr, + labelFontS, labelFontF, text_anchor="end")) + """ + """ + return # This function determines the scale of the plot def detScaleOld(min,max): - if min>=max: - return None - elif min == -1.0 and max == 1.0: - return [-1.2,1.2,12] - else: - a=max-min - b=floor(log10(a)) - c=pow(10.0,b) - if a < c*5.0: - c/=2.0 - #print a,b,c - low=c*floor(min/c) - high=c*ceil(max/c) - return [low,high,round((high-low)/c)] + if min>=max: + return None + elif min == -1.0 and max == 1.0: + return [-1.2,1.2,12] + else: + a=max-min + b=floor(log10(a)) + c=pow(10.0,b) + if a < c*5.0: + c/=2.0 + #print a,b,c + low=c*floor(min/c) + high=c*ceil(max/c) + return [low,high,round((high-low)/c)] def detScale(min=0,max=0,bufferSpace=3): - if min>=max: - return None - elif min == -1.0 and max == 1.0: - return [-1.2,1.2,12] - else: - a=max-min - if max != 0: - max += 0.1*a - if min != 0: - if min > 0 and min < 0.1*a: - min = 0.0 - else: - min -= 0.1*a - a=max-min - b=floor(log10(a)) - c=pow(10.0,b) - low=c*floor(min/c) - high=c*ceil(max/c) - n = round((high-low)/c) - div = 2.0 - while n < 5 or n > 15: - if n < 5: - c /= div - else: - c *= div - if div == 2.0: - div =5.0 - else: - div =2.0 - low=c*floor(min/c) - high=c*ceil(max/c) - n = round((high-low)/c) - - return [low,high,n] + if min>=max: + return None + elif min == -1.0 and max == 1.0: + return [-1.2,1.2,12] + else: + a=max-min + if max != 0: + max += 0.1*a + if min != 0: + if min > 0 and min < 0.1*a: + min = 0.0 + else: + min -= 0.1*a + a=max-min + b=floor(log10(a)) + c=pow(10.0,b) + low=c*floor(min/c) + high=c*ceil(max/c) + n = round((high-low)/c) + div = 2.0 + while n < 5 or n > 15: + if n < 5: + c /= div + else: + c *= div + if div == 2.0: + div =5.0 + else: + div =2.0 + low=c*floor(min/c) + high=c*ceil(max/c) + n = round((high-low)/c) + + return [low,high,n] def colorSpectrumOld(n): - if n == 1: - return [pid.Color(1,0,0)] - elif n == 2: - return [pid.Color(1,0,0),pid.Color(0,0,1)] - elif n == 3: - return [pid.Color(1,0,0),pid.Color(0,1,0),pid.Color(0,0,1)] - else: - step = 2.0/(n-1) - red = 1.0 - green = 0.0 - blue = 0.0 - colors = [pid.Color(red,green,blue)] - i = 1 - greenpeak = 0 - while i < n: - if red >= step: - red -= step - green += step - if green >= 1.0: - greenpeak = 1 - blue += green -1.0 - green = 1.0 - else: - red = 0.0 - if greenpeak: - green -= step - blue += step - else: - green += step - if green >= 1.0: - greenpeak = 1 - blue += green -1.0 - green = 2.0 -green - elif green < 0.0: - green = 0.0 - else: - pass - colors.append(pid.Color(red,green,blue)) - i += 1 - return colors + if n == 1: + return [pid.Color(1,0,0)] + elif n == 2: + return [pid.Color(1,0,0),pid.Color(0,0,1)] + elif n == 3: + return [pid.Color(1,0,0),pid.Color(0,1,0),pid.Color(0,0,1)] + else: + step = 2.0/(n-1) + red = 1.0 + green = 0.0 + blue = 0.0 + colors = [pid.Color(red,green,blue)] + i = 1 + greenpeak = 0 + while i < n: + if red >= step: + red -= step + green += step + if green >= 1.0: + greenpeak = 1 + blue += green -1.0 + green = 1.0 + else: + red = 0.0 + if greenpeak: + green -= step + blue += step + else: + green += step + if green >= 1.0: + greenpeak = 1 + blue += green -1.0 + green = 2.0 -green + elif green < 0.0: + green = 0.0 + else: + pass + colors.append(pid.Color(red,green,blue)) + i += 1 + return colors def bluefunc(x): - return 1.0 / (1.0 + exp(-10*(x-0.6))) + return 1.0 / (1.0 + exp(-10*(x-0.6))) def redfunc(x): - return 1.0 / (1.0 + exp(10*(x-0.5))) + return 1.0 / (1.0 + exp(10*(x-0.5))) def greenfunc(x): - return 1 - pow(redfunc(x+0.2),2) - bluefunc(x-0.3) + return 1 - pow(redfunc(x+0.2),2) - bluefunc(x-0.3) def colorSpectrum(n=100): - multiple = 10 - if n == 1: - return [pid.Color(1,0,0)] - elif n == 2: - return [pid.Color(1,0,0),pid.Color(0,0,1)] - elif n == 3: - return [pid.Color(1,0,0),pid.Color(0,1,0),pid.Color(0,0,1)] - N = n*multiple - out = [None]*N; - for i in range(N): - x = float(i)/N - out[i] = pid.Color(redfunc(x), greenfunc(x), bluefunc(x)); - out2 = [out[0]] - step = N/float(n-1) - j = 0 - for i in range(n-2): - j += step - out2.append(out[int(j)]) - out2.append(out[-1]) - return out2 + multiple = 10 + if n == 1: + return [pid.Color(1,0,0)] + elif n == 2: + return [pid.Color(1,0,0),pid.Color(0,0,1)] + elif n == 3: + return [pid.Color(1,0,0),pid.Color(0,1,0),pid.Color(0,0,1)] + N = n*multiple + out = [None]*N; + for i in range(N): + x = float(i)/N + out[i] = pid.Color(redfunc(x), greenfunc(x), bluefunc(x)); + out2 = [out[0]] + step = N/float(n-1) + j = 0 + for i in range(n-2): + j += step + out2.append(out[int(j)]) + out2.append(out[-1]) + return out2 def colorSpectrumSVG(n=100): - multiple = 10 - if n == 1: - return ["rgb(255,0,0)"] - elif n == 2: - return ["rgb(255,0,0)","rgb(0,0,255)"] - elif n == 3: - return ["rgb(255,0,0)","rgb(0,255,0)","rgb(0,0,255)"] - N = n*multiple - out = [None]*N; - for i in range(N): - x = float(i)/N - out[i] = "rgb(%d, %d, %d)" % (redfunc(x)*255, greenfunc(x)*255, bluefunc(x)*255); - out2 = [out[0]] - step = N/float(n-1) - j = 0 - for i in range(n-2): - j += step - out2.append(out[int(j)]) - out2.append(out[-1]) - return out2 + multiple = 10 + if n == 1: + return ["rgb(255,0,0)"] + elif n == 2: + return ["rgb(255,0,0)","rgb(0,0,255)"] + elif n == 3: + return ["rgb(255,0,0)","rgb(0,255,0)","rgb(0,0,255)"] + N = n*multiple + out = [None]*N; + for i in range(N): + x = float(i)/N + out[i] = "rgb(%d, %d, %d)" % (redfunc(x)*255, greenfunc(x)*255, bluefunc(x)*255); + out2 = [out[0]] + step = N/float(n-1) + j = 0 + for i in range(n-2): + j += step + out2.append(out[int(j)]) + out2.append(out[-1]) + return out2 def BWSpectrum(n=100): - multiple = 10 - if n == 1: - return [pid.Color(0,0,0)] - elif n == 2: - return [pid.Color(0,0,0),pid.Color(1,1,1)] - elif n == 3: - return [pid.Color(0,0,0),pid.Color(0.5,0.5,0.5),pid.Color(1,1,1)] - - step = 1.0/n - x = 0.0 - out = [] - for i in range(n): - out.append(pid.Color(x,x,x)); - x += step - return out + multiple = 10 + if n == 1: + return [pid.Color(0,0,0)] + elif n == 2: + return [pid.Color(0,0,0),pid.Color(1,1,1)] + elif n == 3: + return [pid.Color(0,0,0),pid.Color(0.5,0.5,0.5),pid.Color(1,1,1)] + + step = 1.0/n + x = 0.0 + out = [] + for i in range(n): + out.append(pid.Color(x,x,x)); + x += step + return out diff --git a/wqflask/utility/TDCell.py b/wqflask/utility/TDCell.py index 76b9c5db..8de8e050 100755 --- a/wqflask/utility/TDCell.py +++ b/wqflask/utility/TDCell.py @@ -30,13 +30,12 @@ # ########################################################## - + class TDCell: - def __init__(self, html="", text="", val=0.0): - self.html = html #html, for web page - self.text = text #text value, for output to a text file - self.val = val #sort by value - - def __str__(self): - return self.text + def __init__(self, html="", text="", val=0.0): + self.html = html #html, for web page + self.text = text #text value, for output to a text file + self.val = val #sort by value + def __str__(self): + return self.text diff --git a/wqflask/utility/THCell.py b/wqflask/utility/THCell.py index a96b9e49..dde221b5 100755 --- a/wqflask/utility/THCell.py +++ b/wqflask/utility/THCell.py @@ -32,13 +32,11 @@ class THCell: - def __init__(self, html="", text="", sort=1, idx=-1): - self.html = html #html, for web page - self.text = text #Column text value - self.sort = sort #0: not sortable, 1: yes - self.idx = idx #sort by value - - def __str__(self): - return self.text - + def __init__(self, html="", text="", sort=1, idx=-1): + self.html = html #html, for web page + self.text = text #Column text value + self.sort = sort #0: not sortable, 1: yes + self.idx = idx #sort by value + def __str__(self): + return self.text diff --git a/wqflask/utility/svg.py b/wqflask/utility/svg.py index e49a6c3c..512bc9e6 100755 --- a/wqflask/utility/svg.py +++ b/wqflask/utility/svg.py @@ -74,7 +74,7 @@ by using easy to use classes and methods usualy you start by creating a drawing d.setSVG(s) #and finaly you xmlify the drawing d.toXml() - + this results in the svg source of the drawing, which consists of a circle on a white background. Its as easy as that;) @@ -112,7 +112,7 @@ if sys.version_info[1]<2: True=1 False=0 file=open - + sys.setrecursionlimit=50 #The recursion limit is set conservative so mistakes like s=svg() s.addElement(s) #won't eat up too much processor time. @@ -167,7 +167,7 @@ def _xypointlist(a): def _viewboxlist(a): """formats a tuple""" s='' - for e in a: + for e in a: s+=str(e)+' ' return s @@ -178,7 +178,7 @@ def _pointlist(a): class pathdata: """class used to create a pathdata object which can be used for a path. although most methods are pretty straightforward it might be useful to look at the SVG specification.""" - #I didn't test the methods below. + #I didn't test the methods below. def __init__(self,x=None,y=None): self.path=[] if x is not None and y is not None: @@ -242,10 +242,10 @@ class pathdata: self.path.append('a'+str(rx)+','+str(ry)+' '+str(xrot)+' '+str(laf)+' '+str(sf)+' '+str(x)+' '+str(y)) def __repr__(self): return ' '.join(self.path) - - + + class SVGelement: """SVGelement(type,attributes,elements,text,namespace,**args) Creates a arbitrary svg element and is intended to be subclassed not used on its own. @@ -296,7 +296,7 @@ class SVGelement: if self.cdata: f.write('\n'+'\t'*(level+1)+'\n') if self.text: if type(self.text)==type(''): #If the text is only text @@ -305,13 +305,13 @@ class SVGelement: f.write(str(self.text)) if self.elements: f.write('\t'*level+'\n') - elif self.text: + elif self.text: f.write('\n') elif self.cdata: f.write('\t'*level+'\n') else: f.write('/>\n') - + class tspan(SVGelement): """ts=tspan(text='',**args) @@ -330,12 +330,12 @@ class tspan(SVGelement): def __repr__(self): s="None: self.attributes['stroke-width']=stroke_width - + class ellipse(SVGelement): """e=ellipse(rx,ry,x,y,fill,stroke,stroke_width,**args) @@ -440,8 +440,8 @@ class ellipse(SVGelement): self.attributes['stroke']=stroke if stroke_width<>None: self.attributes['stroke-width']=stroke_width - - + + class circle(SVGelement): """c=circle(x,y,radius,fill,stroke,stroke_width,**args) @@ -464,7 +464,7 @@ class circle(SVGelement): class point(circle): """p=point(x,y,color) - + A point is defined as a circle with a size 1 radius. It may be more efficient to use a very small rectangle if you use many points because a circle is difficult to render. """ @@ -473,7 +473,7 @@ class point(circle): class line(SVGelement): """l=line(x1,y1,x2,y2,stroke,stroke_width,**args) - + A line is defined by a begin x,y pair and an end x,y pair """ def __init__(self,x1=None,y1=None,x2=None,y2=None,stroke=None,stroke_width=None,**args): @@ -490,10 +490,10 @@ class line(SVGelement): self.attributes['stroke-width']=stroke_width if stroke<>None: self.attributes['stroke']=stroke - + class polyline(SVGelement): """pl=polyline([[x1,y1],[x2,y2],...],fill,stroke,stroke_width,**args) - + a polyline is defined by a list of xy pairs """ def __init__(self,points,fill=None,stroke=None,stroke_width=None,**args): @@ -507,7 +507,7 @@ class polyline(SVGelement): class polygon(SVGelement): """pl=polyline([[x1,y1],[x2,y2],...],fill,stroke,stroke_width,**args) - + a polygon is defined by a list of xy pairs """ def __init__(self,points,fill=None,stroke=None,stroke_width=None,**args): @@ -534,11 +534,11 @@ class path(SVGelement): self.attributes['stroke-width']=stroke_width if id<>None: self.attributes['id']=id - - + + class text(SVGelement): """t=text(x,y,text,font_size,font_family,**args) - + a text element can bge used for displaying text on the screen """ def __init__(self,x=None,y=None,text=None,font_size=None,font_family=None,text_anchor=None,**args): @@ -560,7 +560,7 @@ class text(SVGelement): class textpath(SVGelement): """tp=textpath(text,link,**args) - a textpath places a text on a path which is referenced by a link. + a textpath places a text on a path which is referenced by a link. """ def __init__(self,link,text=None,**args): SVGelement.__init__(self,'textPath',{'xlink:href':link},**args) @@ -589,7 +589,7 @@ class pattern(SVGelement): class title(SVGelement): """t=title(text,**args) - + a title is a text element. The text is displayed in the title bar add at least one to the root svg element """ @@ -600,7 +600,7 @@ class title(SVGelement): class description(SVGelement): """d=description(text,**args) - + a description can be added to any element and is used for a tooltip Add this element before adding other elements. """ @@ -648,7 +648,7 @@ class radialgradient(SVGelement): self.attributes['fy']=fy if id<>None: self.attributes['id']=id - + class stop(SVGelement): """st=stop(offset,stop_color,**args) @@ -658,7 +658,7 @@ class stop(SVGelement): SVGelement.__init__(self,'stop',{'offset':offset},**args) if stop_color<>None: self.attributes['stop-color']=stop_color - + class style(SVGelement): """st=style(type,cdata=None,**args) @@ -666,8 +666,8 @@ class style(SVGelement): """ def __init__(self,type,cdata=None,**args): SVGelement.__init__(self,'style',{'type':type},cdata=cdata, **args) - - + + class image(SVGelement): """im=image(url,width,height,x,y,**args) @@ -686,7 +686,7 @@ class image(SVGelement): self.attributes['x']=x if y<>None: self.attributes['y']=y - + class cursor(SVGelement): """c=cursor(url,**args) @@ -695,10 +695,10 @@ class cursor(SVGelement): def __init__(self,url,**args): SVGelement.__init__(self,'cursor',{'xlink:href':url},**args) - + class marker(SVGelement): """m=marker(id,viewbox,refX,refY,markerWidth,markerHeight,**args) - + defines a marker which can be used as an endpoint for a line or other pathtypes add an element to it which should be used as a marker. """ @@ -716,10 +716,10 @@ class marker(SVGelement): self.attributes['markerWidth']=markerWidth if markerHeight<>None: self.attributes['markerHeight']=markerHeight - + class group(SVGelement): """g=group(id,**args) - + a group is defined by an id and is used to contain elements g.addElement(SVGelement) """ @@ -736,14 +736,14 @@ class symbol(SVGelement): display it by referencing its id. sy.addElement(SVGelement) """ - + def __init__(self,id=None,viewBox=None,**args): SVGelement.__init__(self,'symbol',**args) if id<>None: self.attributes['id']=id if viewBox<>None: self.attributes['viewBox']=_viewboxlist(viewBox) - + class defs(SVGelement): """d=defs(**args) @@ -762,10 +762,10 @@ class switch(SVGelement): def __init__(self,**args): SVGelement.__init__(self,'switch',**args) - + class use(SVGelement): """u=use(link,x,y,width,height,**args) - + references a symbol by linking to its id and its position, height and width """ def __init__(self,link,x=None,y=None,width=None,height=None,**args): @@ -779,8 +779,8 @@ class use(SVGelement): self.attributes['width']=width if height<>None: self.attributes['height']=height - - + + class link(SVGelement): """a=link(url,**args) @@ -789,7 +789,7 @@ class link(SVGelement): """ def __init__(self,link='',**args): SVGelement.__init__(self,'a',{'xlink:href':link},**args) - + class view(SVGelement): """v=view(id,**args) @@ -807,11 +807,11 @@ class script(SVGelement): """ def __init__(self,type,cdata=None,**args): SVGelement.__init__(self,'script',{'type':type},cdata=cdata,**args) - + class animate(SVGelement): """an=animate(attribute,from,to,during,**args) - animates an attribute. + animates an attribute. """ def __init__(self,attribute,fr=None,to=None,dur=None,**args): SVGelement.__init__(self,'animate',{'attributeName':attribute},**args) @@ -821,7 +821,7 @@ class animate(SVGelement): self.attributes['to']=to if dur<>None: self.attributes['dur']=dur - + class animateMotion(SVGelement): """an=animateMotion(pathdata,dur,**args) @@ -836,7 +836,7 @@ class animateMotion(SVGelement): class animateTransform(SVGelement): """antr=animateTransform(type,from,to,dur,**args) - + transform an element from and to a value. """ def __init__(self,type=None,fr=None,to=None,dur=None,**args): @@ -864,10 +864,10 @@ class animateColor(SVGelement): if to<>None: self.attributes['to']=to if dur<>None: - self.attributes['dur']=dur + self.attributes['dur']=dur class set(SVGelement): """st=set(attribute,to,during,**args) - + sets an attribute to a value for a """ def __init__(self,attribute,to=None,dur=None,**args): @@ -878,10 +878,10 @@ class set(SVGelement): self.attributes['dur']=dur - + class svg(SVGelement): """s=svg(viewbox,width,height,**args) - + a svg or element is the root of a drawing add all elements to a svg element. You can have different svg elements in one svg file s.addElement(SVGelement) @@ -903,7 +903,7 @@ class svg(SVGelement): if height<>None: self.attributes['height']=height self.namespace="http://www.w3.org/2000/svg" - + class drawing: """d=drawing() @@ -921,17 +921,17 @@ class drawing: def setSVG(self,svg): self.svg=svg #Voeg een element toe aan de grafiek toe. - if use_dom_implementation==0: + if use_dom_implementation==0: def toXml(self, filename='',compress=False): import cStringIO xml=cStringIO.StringIO() xml.write("\n") xml.write("\n" % (item, self.entity[item])) - xml.write("]") + xml.write(" [\n") + for item in self.entity.keys(): + xml.write("\n" % (item, self.entity[item])) + xml.write("]") xml.write(">\n") self.svg.toXml(0,xml) if not filename: @@ -964,7 +964,7 @@ class drawing: compresses if filename ends with svgz or if compress is true """ doctype = implementation.createDocumentType('svg',"-//W3C//DTD SVG 1.0//EN""",'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd ') - + global root #root is defined global so it can be used by the appender. Its also possible to use it as an arugument but #that is a bit messy. @@ -1034,12 +1034,12 @@ class drawing: print "SVG well formed" if __name__=='__main__': - + d=drawing() s=svg((0,0,100,100)) r=rect(-100,-100,300,300,'cyan') s.addElement(r) - + t=title('SVGdraw Demo') s.addElement(t) g=group('animations') @@ -1064,6 +1064,5 @@ if __name__=='__main__': c=circle(i,j,1,'red','black',.5) s.addElement(c) d.setSVG(s) - - print d.toXml() + print d.toXml() diff --git a/wqflask/utility/webqtlUtil.py b/wqflask/utility/webqtlUtil.py index 6af7f846..6409e781 100755 --- a/wqflask/utility/webqtlUtil.py +++ b/wqflask/utility/webqtlUtil.py @@ -90,741 +90,741 @@ PROGRESSBAR = HT.Image('/images/waitAnima2.gif', alt='checkblue',align="middle", ######################################### def decodeEscape(str): - a = str - pattern = re.compile('(%[0-9A-Fa-f][0-9A-Fa-f])') - match = pattern.findall(a) - matched = [] - for item in match: - if item not in matched: - a = a.replace(item, '%c' % eval("0x"+item[-2:])) - matched.append(item) - return a - + a = str + pattern = re.compile('(%[0-9A-Fa-f][0-9A-Fa-f])') + match = pattern.findall(a) + matched = [] + for item in match: + if item not in matched: + a = a.replace(item, '%c' % eval("0x"+item[-2:])) + matched.append(item) + return a + def exportData(hddn, tdata, NP = None): - for key in tdata.keys(): - _val, _var, _N = tdata[key].val, tdata[key].var, tdata[key].N - if _val != None: - hddn[key] = _val - if _var != None: - hddn['V'+key] = _var - if NP and _N != None: - hddn['N'+key] = _N - + for key in tdata.keys(): + _val, _var, _N = tdata[key].val, tdata[key].var, tdata[key].N + if _val != None: + hddn[key] = _val + if _var != None: + hddn['V'+key] = _var + if NP and _N != None: + hddn['N'+key] = _N + def genShortStrainName(RISet='', input_strainName=''): - #aliasStrainDict = {'C57BL/6J':'B6','DBA/2J':'D2'} - strainName = input_strainName - if RISet != 'AXBXA': - if RISet == 'BXD300': - this_RISet = 'BXD' - elif RISet == 'BDF2-2005': - this_RISet = 'CASE05_' - else: - this_RISet = RISet - strainName = string.replace(strainName,this_RISet,'') - strainName = string.replace(strainName,'CASE','') - try: - strainName = "%02d" % int(strainName) - except: - pass - else: - strainName = string.replace(strainName,'AXB','A') - strainName = string.replace(strainName,'BXA','B') - try: - strainName = strainName[0] + "%02d" % int(strainName[1:]) - except: - pass - return strainName + #aliasStrainDict = {'C57BL/6J':'B6','DBA/2J':'D2'} + strainName = input_strainName + if RISet != 'AXBXA': + if RISet == 'BXD300': + this_RISet = 'BXD' + elif RISet == 'BDF2-2005': + this_RISet = 'CASE05_' + else: + this_RISet = RISet + strainName = string.replace(strainName,this_RISet,'') + strainName = string.replace(strainName,'CASE','') + try: + strainName = "%02d" % int(strainName) + except: + pass + else: + strainName = string.replace(strainName,'AXB','A') + strainName = string.replace(strainName,'BXA','B') + try: + strainName = strainName[0] + "%02d" % int(strainName[1:]) + except: + pass + return strainName def toInt(in_str): - "Converts an arbitrary string to an unsigned integer" - start = -1 - end = -1 - for i, char in enumerate(in_str): - if char >= '0' and char <= '9': - if start < 0: - start = i - end = i+1 - else: - if start >= 0: - break - if start < end: - return int(in_str[start:end]) - else: - return -1 + "Converts an arbitrary string to an unsigned integer" + start = -1 + end = -1 + for i, char in enumerate(in_str): + if char >= '0' and char <= '9': + if start < 0: + start = i + end = i+1 + else: + if start >= 0: + break + if start < end: + return int(in_str[start:end]) + else: + return -1 def transpose(m): - 'transpose a matrix' - n = len(m) - return [[m[j][i] for i in range(len(m[0])) for j in range(n)][k*n:k*n+n] for k in range(len(m[0]))] + 'transpose a matrix' + n = len(m) + return [[m[j][i] for i in range(len(m[0])) for j in range(n)][k*n:k*n+n] for k in range(len(m[0]))] def asymTranspose(m): - 'transpose a matrix' - t = max(map(len, m)) - n = len(m) - m2 = [["-"]]*n - for i in range(n): - m2[i] = m[i] + [""]*(t- len(m[i])) - return [[m2[j][i] for i in range(len(m2[0])) for j in range(n)][k*n:k*n+n] for k in range(len(m2[0]))] + 'transpose a matrix' + t = max(map(len, m)) + n = len(m) + m2 = [["-"]]*n + for i in range(n): + m2[i] = m[i] + [""]*(t- len(m[i])) + return [[m2[j][i] for i in range(len(m2[0])) for j in range(n)][k*n:k*n+n] for k in range(len(m2[0]))] def genRandStr(prefix = "", length=8, chars=string.letters+string.digits): - from random import choice - _str = prefix[:] - for i in range(length): - _str += choice(chars) - return _str + from random import choice + _str = prefix[:] + for i in range(length): + _str += choice(chars) + return _str def generate_session(): - import sha - return sha.new(str(time.time())).hexdigest() + import sha + return sha.new(str(time.time())).hexdigest() def cvt2Dict(x): - tmp = {} - for key in x.keys(): - tmp[key] = x[key] - return tmp + tmp = {} + for key in x.keys(): + tmp[key] = x[key] + return tmp def dump_session(session_obj, filename): - "It seems mod python can only cPickle most basic data type" - import cPickle - session_file = open(filename, 'wb') - #try: - # pass - #except: - # pass - cPickle.dump(session_obj, session_file) - session_file.close() - + "It seems mod python can only cPickle most basic data type" + import cPickle + session_file = open(filename, 'wb') + #try: + # pass + #except: + # pass + cPickle.dump(session_obj, session_file) + session_file.close() + def StringAsFloat(str): - 'Converts string to float but catches any exception and returns None' - try: - return float(str) - except: - return None - + 'Converts string to float but catches any exception and returns None' + try: + return float(str) + except: + return None + def IntAsFloat(str): - 'Converts string to Int but catches any exception and returns None' - try: - return int(str) - except: - return None - + 'Converts string to Int but catches any exception and returns None' + try: + return int(str) + except: + return None + def FloatAsFloat(flt): - 'Converts float to string but catches any exception and returns None' - try: - return float("%2.3f" % flt) - except: - return None + 'Converts float to string but catches any exception and returns None' + try: + return float("%2.3f" % flt) + except: + return None def RemoveZero(flt): - 'Converts string to float but catches any exception and returns None' - try: - if abs(flt) < 1e-6: - return None - else: - return flt - except: - return None + 'Converts string to float but catches any exception and returns None' + try: + if abs(flt) < 1e-6: + return None + else: + return flt + except: + return None def SciFloat(d): - 'Converts string to float but catches any exception and returns None' + 'Converts string to float but catches any exception and returns None' - try: - if abs(d) <= 1.0e-4: - return "%1.2e" % d - else: - return "%1.5f" % d - except: - return None + try: + if abs(d) <= 1.0e-4: + return "%1.2e" % d + else: + return "%1.5f" % d + except: + return None ###To be removed def FloatList2String(lst): - 'Converts float list to string but catches any exception and returns None' - tt='' - try: - for item in lst: - if item == None: - tt += 'X ' - else: - tt += '%f ' % item - return tt - except: - return "" + 'Converts float list to string but catches any exception and returns None' + tt='' + try: + for item in lst: + if item == None: + tt += 'X ' + else: + tt += '%f ' % item + return tt + except: + return "" def ListNotNull(lst): - 'Determine if the elements in a list are all null' - for item in lst: - if item is not None: - return 1 - return None - + 'Determine if the elements in a list are all null' + for item in lst: + if item is not None: + return 1 + return None + ###To be removed def FileDataProcess(str): - 'Remove the description text from the input file if theres any' - i=0 - while i'\x20': - break - else: - i+=1 - str=str[i:] - str=string.join(string.split(str,'\000'),'') - i=string.find(str,"*****") - if i>-1: - return str[i+5:] - else: - return str + 'Remove the description text from the input file if theres any' + i=0 + while i'\x20': + break + else: + i+=1 + str=str[i:] + str=string.join(string.split(str,'\000'),'') + i=string.find(str,"*****") + if i>-1: + return str[i+5:] + else: + return str def rank(a,lst,offset=0): - """Calculate the integer rank of a number in an array, can be used to calculate p-value""" - n = len(lst) - if n == 2: - if a lst[1]: - return offset + 2 - else: - return offset +1 - elif n == 1: - if a lst[1]: + return offset + 2 + else: + return offset +1 + elif n == 1: + if a B.LRS: - return 1 - elif A.LRS == B.LRS: - return 0 - else: - return -1 - except: - return 0 - - + try: + if A.LRS > B.LRS: + return 1 + elif A.LRS == B.LRS: + return 0 + else: + return -1 + except: + return 0 + + def cmpScanResult2(A,B): - try: - if A.LRS < B.LRS: - return 1 - elif A.LRS == B.LRS: - return 0 - else: - return -1 - except: - return 0 + try: + if A.LRS < B.LRS: + return 1 + elif A.LRS == B.LRS: + return 0 + else: + return -1 + except: + return 0 def cmpOrder(A,B): - try: - if A[1] < B[1]: - return -1 - elif A[1] == B[1]: - return 0 - else: - return 1 - except: - return 0 + try: + if A[1] < B[1]: + return -1 + elif A[1] == B[1]: + return 0 + else: + return 1 + except: + return 0 def cmpOrder2(A,B): - try: - if A[-1] < B[-1]: - return -1 - elif A[-1] == B[-1]: - return 0 - else: - return 1 - except: - return 0 + try: + if A[-1] < B[-1]: + return -1 + elif A[-1] == B[-1]: + return 0 + else: + return 1 + except: + return 0 def calRank(xVals, yVals, N): ### Zach Sloan, February 4 2010 - """ - Returns a ranked set of X and Y values. These are used when generating - a Spearman scatterplot. Bear in mind that this sets values equal to each - other as the same rank. - """ - XX = [] - YY = [] - X = [0]*len(xVals) - Y = [0]*len(yVals) - j = 0 - - for i in range(len(xVals)): - - if xVals[i] != None and yVals[i] != None: - XX.append((j, xVals[i])) - YY.append((j, yVals[i])) - j = j + 1 - - NN = len(XX) - - XX.sort(cmpOrder2) - YY.sort(cmpOrder2) - - j = 1 - rank = 0.0 - - while j < NN: - - if XX[j][1] != XX[j-1][1]: - X[XX[j-1][0]] = j - j = j+1 - - else: - jt = j+1 - ji = j - for jt in range(j+1, NN): - if (XX[jt][1] != XX[j-1][1]): - break - rank = 0.5*(j+jt) - for ji in range(j-1, jt): - X[XX[ji][0]] = rank - if (jt == NN-1): - if (XX[jt][1] == XX[j-1][1]): - X[XX[NN-1][0]] = rank - j = jt+1 - - if j == NN: - if X[XX[NN-1][0]] == 0: - X[XX[NN-1][0]] = NN - - j = 1 - rank = 0.0 - - while j < NN: - - if YY[j][1] != YY[j-1][1]: - Y[YY[j-1][0]] = j - j = j+1 - else: - jt = j+1 - ji = j - for jt in range(j+1, NN): - if (YY[jt][1] != YY[j-1][1]): - break - rank = 0.5*(j+jt) - for ji in range(j-1, jt): - Y[YY[ji][0]] = rank - if (jt == NN-1): - if (YY[jt][1] == YY[j-1][1]): - Y[YY[NN-1][0]] = rank - j = jt+1 - - if j == NN: - if Y[YY[NN-1][0]] == 0: - Y[YY[NN-1][0]] = NN - - return (X,Y) + """ + Returns a ranked set of X and Y values. These are used when generating + a Spearman scatterplot. Bear in mind that this sets values equal to each + other as the same rank. + """ + XX = [] + YY = [] + X = [0]*len(xVals) + Y = [0]*len(yVals) + j = 0 + + for i in range(len(xVals)): + + if xVals[i] != None and yVals[i] != None: + XX.append((j, xVals[i])) + YY.append((j, yVals[i])) + j = j + 1 + + NN = len(XX) + + XX.sort(cmpOrder2) + YY.sort(cmpOrder2) + + j = 1 + rank = 0.0 + + while j < NN: + + if XX[j][1] != XX[j-1][1]: + X[XX[j-1][0]] = j + j = j+1 + + else: + jt = j+1 + ji = j + for jt in range(j+1, NN): + if (XX[jt][1] != XX[j-1][1]): + break + rank = 0.5*(j+jt) + for ji in range(j-1, jt): + X[XX[ji][0]] = rank + if (jt == NN-1): + if (XX[jt][1] == XX[j-1][1]): + X[XX[NN-1][0]] = rank + j = jt+1 + + if j == NN: + if X[XX[NN-1][0]] == 0: + X[XX[NN-1][0]] = NN + + j = 1 + rank = 0.0 + + while j < NN: + + if YY[j][1] != YY[j-1][1]: + Y[YY[j-1][0]] = j + j = j+1 + else: + jt = j+1 + ji = j + for jt in range(j+1, NN): + if (YY[jt][1] != YY[j-1][1]): + break + rank = 0.5*(j+jt) + for ji in range(j-1, jt): + Y[YY[ji][0]] = rank + if (jt == NN-1): + if (YY[jt][1] == YY[j-1][1]): + Y[YY[NN-1][0]] = rank + j = jt+1 + + if j == NN: + if Y[YY[NN-1][0]] == 0: + Y[YY[NN-1][0]] = NN + + return (X,Y) def calCorrelationRank(xVals,yVals,N): - """ - Calculated Spearman Ranked Correlation. The algorithm works - by setting all tied ranks to the average of those ranks (for - example, if ranks 5-10 all have the same value, each will be set - to rank 7.5). - """ - - XX = [] - YY = [] - j = 0 - - for i in range(len(xVals)): - if xVals[i]!= None and yVals[i]!= None: - XX.append((j,xVals[i])) - YY.append((j,yVals[i])) - j = j+1 - - NN = len(XX) - if NN <6: - return (0.0,NN) - XX.sort(cmpOrder2) - YY.sort(cmpOrder2) - X = [0]*NN - Y = [0]*NN - - j = 1 - rank = 0.0 - t = 0.0 - sx = 0.0 - - while j < NN: - - if XX[j][1] != XX[j-1][1]: - X[XX[j-1][0]] = j - j = j+1 - - else: - jt = j+1 - ji = j - for jt in range(j+1, NN): - if (XX[jt][1] != XX[j-1][1]): - break - rank = 0.5*(j+jt) - for ji in range(j-1, jt): - X[XX[ji][0]] = rank - t = jt-j - sx = sx + (t*t*t-t) - if (jt == NN-1): - if (XX[jt][1] == XX[j-1][1]): - X[XX[NN-1][0]] = rank - j = jt+1 - - if j == NN: - if X[XX[NN-1][0]] == 0: - X[XX[NN-1][0]] = NN - - j = 1 - rank = 0.0 - t = 0.0 - sy = 0.0 - - while j < NN: - - if YY[j][1] != YY[j-1][1]: - Y[YY[j-1][0]] = j - j = j+1 - else: - jt = j+1 - ji = j - for jt in range(j+1, NN): - if (YY[jt][1] != YY[j-1][1]): - break - rank = 0.5*(j+jt) - for ji in range(j-1, jt): - Y[YY[ji][0]] = rank - t = jt - j - sy = sy + (t*t*t-t) - if (jt == NN-1): - if (YY[jt][1] == YY[j-1][1]): - Y[YY[NN-1][0]] = rank - j = jt+1 - - if j == NN: - if Y[YY[NN-1][0]] == 0: - Y[YY[NN-1][0]] = NN - - D = 0.0 - - for i in range(NN): - D += (X[i]-Y[i])*(X[i]-Y[i]) - - fac = (1.0 -sx/(NN*NN*NN-NN))*(1.0-sy/(NN*NN*NN-NN)) - - return ((1-(6.0/(NN*NN*NN-NN))*(D+(sx+sy)/12.0))/math.sqrt(fac),NN) - - + """ + Calculated Spearman Ranked Correlation. The algorithm works + by setting all tied ranks to the average of those ranks (for + example, if ranks 5-10 all have the same value, each will be set + to rank 7.5). + """ + + XX = [] + YY = [] + j = 0 + + for i in range(len(xVals)): + if xVals[i]!= None and yVals[i]!= None: + XX.append((j,xVals[i])) + YY.append((j,yVals[i])) + j = j+1 + + NN = len(XX) + if NN <6: + return (0.0,NN) + XX.sort(cmpOrder2) + YY.sort(cmpOrder2) + X = [0]*NN + Y = [0]*NN + + j = 1 + rank = 0.0 + t = 0.0 + sx = 0.0 + + while j < NN: + + if XX[j][1] != XX[j-1][1]: + X[XX[j-1][0]] = j + j = j+1 + + else: + jt = j+1 + ji = j + for jt in range(j+1, NN): + if (XX[jt][1] != XX[j-1][1]): + break + rank = 0.5*(j+jt) + for ji in range(j-1, jt): + X[XX[ji][0]] = rank + t = jt-j + sx = sx + (t*t*t-t) + if (jt == NN-1): + if (XX[jt][1] == XX[j-1][1]): + X[XX[NN-1][0]] = rank + j = jt+1 + + if j == NN: + if X[XX[NN-1][0]] == 0: + X[XX[NN-1][0]] = NN + + j = 1 + rank = 0.0 + t = 0.0 + sy = 0.0 + + while j < NN: + + if YY[j][1] != YY[j-1][1]: + Y[YY[j-1][0]] = j + j = j+1 + else: + jt = j+1 + ji = j + for jt in range(j+1, NN): + if (YY[jt][1] != YY[j-1][1]): + break + rank = 0.5*(j+jt) + for ji in range(j-1, jt): + Y[YY[ji][0]] = rank + t = jt - j + sy = sy + (t*t*t-t) + if (jt == NN-1): + if (YY[jt][1] == YY[j-1][1]): + Y[YY[NN-1][0]] = rank + j = jt+1 + + if j == NN: + if Y[YY[NN-1][0]] == 0: + Y[YY[NN-1][0]] = NN + + D = 0.0 + + for i in range(NN): + D += (X[i]-Y[i])*(X[i]-Y[i]) + + fac = (1.0 -sx/(NN*NN*NN-NN))*(1.0-sy/(NN*NN*NN-NN)) + + return ((1-(6.0/(NN*NN*NN-NN))*(D+(sx+sy)/12.0))/math.sqrt(fac),NN) + + def calCorrelationRankText(dbdata,userdata,N): ### dcrowell = David Crowell, July 2008 - """Calculates correlation ranks with data formatted from the text file. - dbdata, userdata are lists of strings. N is an int. Returns a float. - Used by correlationPage""" - XX = [] - YY = [] - j = 0 - for i in range(N): - if (dbdata[i]!= None and userdata[i]!=None) and (dbdata[i]!= 'None' and userdata[i]!='None'): - XX.append((j,float(dbdata[i]))) - YY.append((j,float(userdata[i]))) - j += 1 - NN = len(XX) - if NN <6: - return (0.0,NN) - XX.sort(cmpOrder2) - YY.sort(cmpOrder2) - X = [0]*NN - Y = [0]*NN - - j = 1 - rank = 0.0 - t = 0.0 - sx = 0.0 - - while j < NN: - - if XX[j][1] != XX[j-1][1]: - X[XX[j-1][0]] = j - j = j+1 - - else: - jt = j+1 - ji = j - for jt in range(j+1, NN): - if (XX[jt][1] != XX[j-1][1]): - break - rank = 0.5*(j+jt) - for ji in range(j-1, jt): - X[XX[ji][0]] = rank - t = jt-j - sx = sx + (t*t*t-t) - if (jt == NN-1): - if (XX[jt][1] == XX[j-1][1]): - X[XX[NN-1][0]] = rank - j = jt+1 - - if j == NN: - if X[XX[NN-1][0]] == 0: - X[XX[NN-1][0]] = NN - - j = 1 - rank = 0.0 - t = 0.0 - sy = 0.0 - - while j < NN: - - if YY[j][1] != YY[j-1][1]: - Y[YY[j-1][0]] = j - j = j+1 - else: - jt = j+1 - ji = j - for jt in range(j+1, NN): - if (YY[jt][1] != YY[j-1][1]): - break - rank = 0.5*(j+jt) - for ji in range(j-1, jt): - Y[YY[ji][0]] = rank - t = jt - j - sy = sy + (t*t*t-t) - if (jt == NN-1): - if (YY[jt][1] == YY[j-1][1]): - Y[YY[NN-1][0]] = rank - j = jt+1 - - if j == NN: - if Y[YY[NN-1][0]] == 0: - Y[YY[NN-1][0]] = NN - - D = 0.0 - - for i in range(NN): - D += (X[i]-Y[i])*(X[i]-Y[i]) - - fac = (1.0 -sx/(NN*NN*NN-NN))*(1.0-sy/(NN*NN*NN-NN)) - - return ((1-(6.0/(NN*NN*NN-NN))*(D+(sx+sy)/12.0))/math.sqrt(fac),NN) + """Calculates correlation ranks with data formatted from the text file. + dbdata, userdata are lists of strings. N is an int. Returns a float. + Used by correlationPage""" + XX = [] + YY = [] + j = 0 + for i in range(N): + if (dbdata[i]!= None and userdata[i]!=None) and (dbdata[i]!= 'None' and userdata[i]!='None'): + XX.append((j,float(dbdata[i]))) + YY.append((j,float(userdata[i]))) + j += 1 + NN = len(XX) + if NN <6: + return (0.0,NN) + XX.sort(cmpOrder2) + YY.sort(cmpOrder2) + X = [0]*NN + Y = [0]*NN + + j = 1 + rank = 0.0 + t = 0.0 + sx = 0.0 + + while j < NN: + + if XX[j][1] != XX[j-1][1]: + X[XX[j-1][0]] = j + j = j+1 + + else: + jt = j+1 + ji = j + for jt in range(j+1, NN): + if (XX[jt][1] != XX[j-1][1]): + break + rank = 0.5*(j+jt) + for ji in range(j-1, jt): + X[XX[ji][0]] = rank + t = jt-j + sx = sx + (t*t*t-t) + if (jt == NN-1): + if (XX[jt][1] == XX[j-1][1]): + X[XX[NN-1][0]] = rank + j = jt+1 + + if j == NN: + if X[XX[NN-1][0]] == 0: + X[XX[NN-1][0]] = NN + + j = 1 + rank = 0.0 + t = 0.0 + sy = 0.0 + + while j < NN: + + if YY[j][1] != YY[j-1][1]: + Y[YY[j-1][0]] = j + j = j+1 + else: + jt = j+1 + ji = j + for jt in range(j+1, NN): + if (YY[jt][1] != YY[j-1][1]): + break + rank = 0.5*(j+jt) + for ji in range(j-1, jt): + Y[YY[ji][0]] = rank + t = jt - j + sy = sy + (t*t*t-t) + if (jt == NN-1): + if (YY[jt][1] == YY[j-1][1]): + Y[YY[NN-1][0]] = rank + j = jt+1 + + if j == NN: + if Y[YY[NN-1][0]] == 0: + Y[YY[NN-1][0]] = NN + + D = 0.0 + + for i in range(NN): + D += (X[i]-Y[i])*(X[i]-Y[i]) + + fac = (1.0 -sx/(NN*NN*NN-NN))*(1.0-sy/(NN*NN*NN-NN)) + + return ((1-(6.0/(NN*NN*NN-NN))*(D+(sx+sy)/12.0))/math.sqrt(fac),NN) def calCorrelation(dbdata,userdata,N): - X = [] - Y = [] - for i in range(N): - if dbdata[i]!= None and userdata[i]!= None: - X.append(dbdata[i]) - Y.append(userdata[i]) - NN = len(X) - if NN <6: - return (0.0,NN) - sx = reduce(lambda x,y:x+y,X,0.0) - sy = reduce(lambda x,y:x+y,Y,0.0) - meanx = sx/NN - meany = sy/NN - xyd = 0.0 - sxd = 0.0 - syd = 0.0 - for i in range(NN): - xyd += (X[i] - meanx)*(Y[i]-meany) - sxd += (X[i] - meanx)*(X[i] - meanx) - syd += (Y[i] - meany)*(Y[i] - meany) - try: - corr = xyd/(sqrt(sxd)*sqrt(syd)) - except: - corr = 0 - return (corr,NN) + X = [] + Y = [] + for i in range(N): + if dbdata[i]!= None and userdata[i]!= None: + X.append(dbdata[i]) + Y.append(userdata[i]) + NN = len(X) + if NN <6: + return (0.0,NN) + sx = reduce(lambda x,y:x+y,X,0.0) + sy = reduce(lambda x,y:x+y,Y,0.0) + meanx = sx/NN + meany = sy/NN + xyd = 0.0 + sxd = 0.0 + syd = 0.0 + for i in range(NN): + xyd += (X[i] - meanx)*(Y[i]-meany) + sxd += (X[i] - meanx)*(X[i] - meanx) + syd += (Y[i] - meany)*(Y[i] - meany) + try: + corr = xyd/(sqrt(sxd)*sqrt(syd)) + except: + corr = 0 + return (corr,NN) def calCorrelationText(dbdata,userdata,N): ### dcrowell July 2008 - """Calculates correlation coefficients with values formatted from text files. dbdata, userdata are lists of strings. N is an int. Returns a float - Used by correlationPage""" - X = [] - Y = [] - for i in range(N): - #if (dbdata[i]!= None and userdata[i]!= None) and (dbdata[i]!= 'None' and userdata[i]!= 'None'): - # X.append(float(dbdata[i])) - # Y.append(float(userdata[i])) - if dbdata[i] == None or dbdata[i] == 'None' or userdata[i] == None or userdata[i] == 'None': - continue - else: - X.append(float(dbdata[i])) - Y.append(float(userdata[i])) - NN = len(X) - if NN <6: - return (0.0,NN) - sx = sum(X) - sy = sum(Y) - meanx = sx/float(NN) - meany = sy/float(NN) - xyd = 0.0 - sxd = 0.0 - syd = 0.0 - for i in range(NN): - x1 = X[i]-meanx - y1 = Y[i]-meany - xyd += x1*y1 - sxd += x1**2 - syd += y1**2 - try: - corr = xyd/(sqrt(sxd)*sqrt(syd)) - except: - corr = 0 - return (corr,NN) + """Calculates correlation coefficients with values formatted from text files. dbdata, userdata are lists of strings. N is an int. Returns a float + Used by correlationPage""" + X = [] + Y = [] + for i in range(N): + #if (dbdata[i]!= None and userdata[i]!= None) and (dbdata[i]!= 'None' and userdata[i]!= 'None'): + # X.append(float(dbdata[i])) + # Y.append(float(userdata[i])) + if dbdata[i] == None or dbdata[i] == 'None' or userdata[i] == None or userdata[i] == 'None': + continue + else: + X.append(float(dbdata[i])) + Y.append(float(userdata[i])) + NN = len(X) + if NN <6: + return (0.0,NN) + sx = sum(X) + sy = sum(Y) + meanx = sx/float(NN) + meany = sy/float(NN) + xyd = 0.0 + sxd = 0.0 + syd = 0.0 + for i in range(NN): + x1 = X[i]-meanx + y1 = Y[i]-meany + xyd += x1*y1 + sxd += x1**2 + syd += y1**2 + try: + corr = xyd/(sqrt(sxd)*sqrt(syd)) + except: + corr = 0 + return (corr,NN) def readLineCSV(line): ### dcrowell July 2008 - """Parses a CSV string of text and returns a list containing each element as a string. - Used by correlationPage""" - returnList = line.split('","') - returnList[-1]=returnList[-1][:-2] - returnList[0]=returnList[0][1:] - return returnList + """Parses a CSV string of text and returns a list containing each element as a string. + Used by correlationPage""" + returnList = line.split('","') + returnList[-1]=returnList[-1][:-2] + returnList[0]=returnList[0][1:] + return returnList def cmpCorr(A,B): - try: - if abs(A[1]) < abs(B[1]): - return 1 - elif abs(A[1]) == abs(B[1]): - return 0 - else: - return -1 - except: - return 0 + try: + if abs(A[1]) < abs(B[1]): + return 1 + elif abs(A[1]) == abs(B[1]): + return 0 + else: + return -1 + except: + return 0 def cmpLitCorr(A,B): - try: - if abs(A[3]) < abs(B[3]): return 1 - elif abs(A[3]) == abs(B[3]): - if abs(A[1]) < abs(B[1]): return 1 - elif abs(A[1]) == abs(B[1]): return 0 - else: return -1 - else: return -1 - except: - return 0 + try: + if abs(A[3]) < abs(B[3]): return 1 + elif abs(A[3]) == abs(B[3]): + if abs(A[1]) < abs(B[1]): return 1 + elif abs(A[1]) == abs(B[1]): return 0 + else: return -1 + else: return -1 + except: + return 0 def cmpPValue(A,B): - try: - if A.corrPValue < B.corrPValue: - return -1 - elif A.corrPValue == B.corrPValue: - if abs(A.corr) > abs(B.corr): - return -1 - elif abs(A.corr) < abs(B.corr): - return 1 - else: - return 0 - else: - return 1 - except: - return 0 + try: + if A.corrPValue < B.corrPValue: + return -1 + elif A.corrPValue == B.corrPValue: + if abs(A.corr) > abs(B.corr): + return -1 + elif abs(A.corr) < abs(B.corr): + return 1 + else: + return 0 + else: + return 1 + except: + return 0 def cmpEigenValue(A,B): - try: - if A[0] > B[0]: - return -1 - elif A[0] == B[0]: - return 0 - else: - return 1 - except: - return 0 + try: + if A[0] > B[0]: + return -1 + elif A[0] == B[0]: + return 0 + else: + return 1 + except: + return 0 def cmpLRSFull(A,B): - try: - if A[0] < B[0]: - return -1 - elif A[0] == B[0]: - return 0 - else: - return 1 - except: - return 0 + try: + if A[0] < B[0]: + return -1 + elif A[0] == B[0]: + return 0 + else: + return 1 + except: + return 0 def cmpLRSInteract(A,B): - try: - if A[1] < B[1]: - return -1 - elif A[1] == B[1]: - return 0 - else: - return 1 - except: - return 0 - - + try: + if A[1] < B[1]: + return -1 + elif A[1] == B[1]: + return 0 + else: + return 1 + except: + return 0 + + def cmpPos(A,B): - try: - try: - AChr = int(A.chr) - except: - AChr = 20 - try: - BChr = int(B.chr) - except: - BChr = 20 - if AChr > BChr: - return 1 - elif AChr == BChr: - if A.mb > B.mb: - return 1 - if A.mb == B.mb: - return 0 - else: - return -1 - else: - return -1 - except: - return 0 - + try: + try: + AChr = int(A.chr) + except: + AChr = 20 + try: + BChr = int(B.chr) + except: + BChr = 20 + if AChr > BChr: + return 1 + elif AChr == BChr: + if A.mb > B.mb: + return 1 + if A.mb == B.mb: + return 0 + else: + return -1 + else: + return -1 + except: + return 0 + def cmpGenoPos(A,B): - try: - A1 = A.chr - B1 = B.chr - try: - A1 = int(A1) - except: - A1 = 25 - try: - B1 = int(B1) - except: - B1 = 25 - if A1 > B1: - return 1 - elif A1 == B1: - if A.mb > B.mb: - return 1 - if A.mb == B.mb: - return 0 - else: - return -1 - else: - return -1 - except: - return 0 + try: + A1 = A.chr + B1 = B.chr + try: + A1 = int(A1) + except: + A1 = 25 + try: + B1 = int(B1) + except: + B1 = 25 + if A1 > B1: + return 1 + elif A1 == B1: + if A.mb > B.mb: + return 1 + if A.mb == B.mb: + return 0 + else: + return -1 + else: + return -1 + except: + return 0 #XZhou: Must use "BINARY" to enable case sensitive comparison. def authUser(name,password,db, encrypt=None): - try: - if encrypt: - query = 'SELECT privilege, id,name,password, grpName FROM User WHERE name= BINARY \'%s\' and password= BINARY \'%s\'' % (name,password) - else: - query = 'SELECT privilege, id,name,password, grpName FROM User WHERE name= BINARY \'%s\' and password= BINARY SHA(\'%s\')' % (name,password) - db.execute(query) - records = db.fetchone() - if not records: - raise ValueError - return records#(privilege,id,name,password,grpName) - except: - return (None, None, None, None, None) + try: + if encrypt: + query = 'SELECT privilege, id,name,password, grpName FROM User WHERE name= BINARY \'%s\' and password= BINARY \'%s\'' % (name,password) + else: + query = 'SELECT privilege, id,name,password, grpName FROM User WHERE name= BINARY \'%s\' and password= BINARY SHA(\'%s\')' % (name,password) + db.execute(query) + records = db.fetchone() + if not records: + raise ValueError + return records#(privilege,id,name,password,grpName) + except: + return (None, None, None, None, None) def hasAccessToConfidentialPhenotypeTrait(privilege, userName, authorized_users): @@ -840,9 +840,9 @@ def hasAccessToConfidentialPhenotypeTrait(privilege, userName, authorized_users) class VisualizeException(Exception): def __init__(self, message): - self.message = message + self.message = message def __str__(self): - return self.message + return self.message # safeConvert : (string -> A) -> A -> A # to convert a string to type A, using the supplied default value @@ -852,12 +852,12 @@ def safeConvert(f, value, default): return f(value) except: return default - + # safeFloat : string -> float -> float # to convert a string to a float safely def safeFloat(value, default): return safeConvert(float, value, default) - + # safeInt: string -> int -> int # to convert a string to an int safely def safeInt(value, default): @@ -878,7 +878,7 @@ def yesNoToInt(value): if value == "yes": return 1 elif value == "no": - return 0 + return 0 else: return None @@ -890,79 +890,79 @@ def intToYesNo(value): elif value == 0: return "no" else: - return None - + return None + def formatField(name): - name = name.replace("_", " ") - name = name.title() - #name = name.replace("Mb Mm6", "Mb"); - return name.replace("Id", "ID") + name = name.replace("_", " ") + name = name.title() + #name = name.replace("Mb Mm6", "Mb"); + return name.replace("Id", "ID") #XZ, 03/27/2009: This function is very specific. #It is used by AJAX_table.py, correlationPage.py and dataPage.py def genTableObj(tblobj=None, file="", sortby = ("", ""), tableID = "sortable", addIndex = "1", hiddenColumns=[]): - header = tblobj['header'] - body = tblobj['body'] - field, order = sortby - - #ZAS 9/12/2011 - The hiddenColumns array needs to be converted into a string so they can be placed into the javascript of each up/down button - hiddenColumnsString = ",".join(hiddenColumns) - - tbl = HT.TableLite(Class="collap b2", cellspacing=1, cellpadding=5) - - hiddenColumnIdx = [] #indices of columns to hide - idx = -1 - last_idx = 0 #ZS: This is the index of the last item in the regular table header (without any extra parameters). It is used to determine the index of each extra parameter. - for row in header: - hr = HT.TR() - for i, item in enumerate(row): - if (item.text == '') or (item.text not in hiddenColumns): - if item.sort and item.text: - down = HT.Href("javascript:xmlhttpPost('%smain.py?FormID=AJAX_table', '%s', 'sort=%s&order=down&file=%s&tableID=%s&addIndex=%s&hiddenColumns=%s')" % (webqtlConfig.CGIDIR, tableID, item.text, file, tableID, addIndex, hiddenColumnsString),IMGDESC) - up = HT.Href("javascript:xmlhttpPost('%smain.py?FormID=AJAX_table', '%s', 'sort=%s&order=up&file=%s&tableID=%s&addIndex=%s&hiddenColumns=%s')" % (webqtlConfig.CGIDIR, tableID, item.text, file, tableID, addIndex, hiddenColumnsString),IMGASC) - if item.text == field: - idx = item.idx - last_idx = idx - if order == 'up': - up = IMGASCON - elif order == 'down': - down = IMGDESCON - item.html.append(HT.Div(up, down, style="float: bottom;")) - hr.append(item.html) - else: - hiddenColumnIdx.append(i) - tbl.append(hr) - - for i, row in enumerate(body): - for j, item in enumerate(row): - if order == 'down': - if (item.val == '' or item.val == 'x' or item.val == 'None'): - item.val = 0 - if order == 'up': - if (item.val == '' or item.val == 'x' or item.val == 'None'): - item.val = 'zzzzz' - - if idx >= 0: - if order == 'down': - body.sort(lambda A, B: cmp(B[idx].val, A[idx].val), key=natsort_key) - elif order == 'up': - body.sort(lambda A, B: cmp(A[idx].val, B[idx].val), key=natsort_key) - else: - pass - - for i, row in enumerate(body): - hr = HT.TR(Id = row[0].text) - for j, item in enumerate(row): - if (j not in hiddenColumnIdx): - if j == 0: - if addIndex == "1": - item.html.contents = [i+1] + item.html.contents - hr.append(item.html) - tbl.append(hr) - - return tbl + header = tblobj['header'] + body = tblobj['body'] + field, order = sortby + + #ZAS 9/12/2011 - The hiddenColumns array needs to be converted into a string so they can be placed into the javascript of each up/down button + hiddenColumnsString = ",".join(hiddenColumns) + + tbl = HT.TableLite(Class="collap b2", cellspacing=1, cellpadding=5) + + hiddenColumnIdx = [] #indices of columns to hide + idx = -1 + last_idx = 0 #ZS: This is the index of the last item in the regular table header (without any extra parameters). It is used to determine the index of each extra parameter. + for row in header: + hr = HT.TR() + for i, item in enumerate(row): + if (item.text == '') or (item.text not in hiddenColumns): + if item.sort and item.text: + down = HT.Href("javascript:xmlhttpPost('%smain.py?FormID=AJAX_table', '%s', 'sort=%s&order=down&file=%s&tableID=%s&addIndex=%s&hiddenColumns=%s')" % (webqtlConfig.CGIDIR, tableID, item.text, file, tableID, addIndex, hiddenColumnsString),IMGDESC) + up = HT.Href("javascript:xmlhttpPost('%smain.py?FormID=AJAX_table', '%s', 'sort=%s&order=up&file=%s&tableID=%s&addIndex=%s&hiddenColumns=%s')" % (webqtlConfig.CGIDIR, tableID, item.text, file, tableID, addIndex, hiddenColumnsString),IMGASC) + if item.text == field: + idx = item.idx + last_idx = idx + if order == 'up': + up = IMGASCON + elif order == 'down': + down = IMGDESCON + item.html.append(HT.Div(up, down, style="float: bottom;")) + hr.append(item.html) + else: + hiddenColumnIdx.append(i) + tbl.append(hr) + + for i, row in enumerate(body): + for j, item in enumerate(row): + if order == 'down': + if (item.val == '' or item.val == 'x' or item.val == 'None'): + item.val = 0 + if order == 'up': + if (item.val == '' or item.val == 'x' or item.val == 'None'): + item.val = 'zzzzz' + + if idx >= 0: + if order == 'down': + body.sort(lambda A, B: cmp(B[idx].val, A[idx].val), key=natsort_key) + elif order == 'up': + body.sort(lambda A, B: cmp(A[idx].val, B[idx].val), key=natsort_key) + else: + pass + + for i, row in enumerate(body): + hr = HT.TR(Id = row[0].text) + for j, item in enumerate(row): + if (j not in hiddenColumnIdx): + if j == 0: + if addIndex == "1": + item.html.contents = [i+1] + item.html.contents + hr.append(item.html) + tbl.append(hr) + + return tbl def natsort_key(string): r = [] @@ -974,4 +974,3 @@ def natsort_key(string): except: r.append(c) return r - diff --git a/wqflask/wqflask/show_trait/DataEditingPage.py b/wqflask/wqflask/show_trait/DataEditingPage.py index b50428fc..6d709012 100755 --- a/wqflask/wqflask/show_trait/DataEditingPage.py +++ b/wqflask/wqflask/show_trait/DataEditingPage.py @@ -18,1908 +18,1908 @@ from basicStatistics import BasicStatisticsFunctions ######################################### class DataEditingPage(templatePage): - def __init__(self, fd, thisTrait=None): - - templatePage.__init__(self, fd) - - self.dict['title'] = 'Data Editing' - TD_LR = HT.TD(valign="top",width="100%",bgcolor="#fafafa") - - if not self.openMysql(): - return - if not fd.genotype: - fd.readData(incf1=1) - - ############################# - # determine data editing page format - ############################# - varianceDataPage = 0 - if fd.formID == 'varianceChoice': - varianceDataPage = 1 - - if varianceDataPage: - fmID='dataEditing' - nCols = 6 - else: - if fd.enablevariance: - fmID='pre_dataEditing' - nCols = 4 - else: - fmID='dataEditing' - nCols = 4 - - ############################# - ## titles, etc. - ############################# - - #titleTop = HT.Div() - # - #title1 = HT.Paragraph("  Details and Links", style="border-radius: 5px;", Id="title1", Class="sectionheader") - #title1Body = HT.Paragraph(Id="sectionbody1") - # - #if fd.enablevariance and not varianceDataPage: - # title2 = HT.Paragraph("  Submit Variance", style="border-radius: 5px;", Id="title2", Class="sectionheader") - #else: - # title2 = HT.Paragraph("  Basic Statistics", style="border-radius: 5px;", Id="title2", Class="sectionheader") - #title2Body = HT.Paragraph(Id="sectionbody2") - # - #title3 = HT.Paragraph("  Calculate Correlations", style="border-radius: 5px;", Id="title3", Class="sectionheader") - #title3Body = HT.Paragraph(Id="sectionbody3") - # - #title4 = HT.Paragraph("  Mapping Tools", style="border-radius: 5px;", Id="title4", Class="sectionheader") - #title4Body = HT.Paragraph(Id="sectionbody4") - # - #title5 = HT.Paragraph("  Review and Edit Data", style="border-radius: 5px;", Id="title5", Class="sectionheader") - #title5Body = HT.Paragraph(Id="sectionbody5") - - ############################# - ## Hidden field - ############################# - - # Some fields, like method, are defaulted to None; otherwise in IE the field can't be changed using jquery - hddn = { - '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, - 'strainNames':'_', - 'strainVals':'_', - 'strainVars':'_', - 'otherStrainNames':'_', - 'otherStrainVals':'_', - 'otherStrainVars':'_', - 'extra_attributes':'_', - 'other_extra_attributes':'_' - } - - if fd.enablevariance: - hddn['enablevariance']='ON' - if fd.incparentsf1: - hddn['incparentsf1']='ON' - - if thisTrait: - hddn['fullname'] = str(thisTrait) - try: - hddn['normalPlotTitle'] = thisTrait.symbol - hddn['normalPlotTitle'] += ": " - hddn['normalPlotTitle'] += thisTrait.name - except: - hddn['normalPlotTitle'] = str(thisTrait.name) - hddn['fromDataEditingPage'] = 1 - if thisTrait.db and thisTrait.db.type and thisTrait.db.type == 'ProbeSet': - hddn['trait_type'] = thisTrait.db.type - if thisTrait.cellid: - hddn['cellid'] = thisTrait.cellid - else: - self.cursor.execute("SELECT h2 from ProbeSetXRef WHERE DataId = %d" % thisTrait.mysqlid) - heritability = self.cursor.fetchone() - hddn['heritability'] = heritability - - hddn['attribute_names'] = "" - - hddn['mappingMethodId'] = webqtlDatabaseFunction.getMappingMethod (cursor=self.cursor, groupName=fd.RISet) - - ############################# - ## Display Trait Information - ############################# - - #headSpan = self.dispHeader(fd,thisTrait) #Draw header - # - #titleTop.append(headSpan) - - 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, thisTrait) #Display trait information + function buttons - - ############################# - ## Generate form and buttons - ############################# - - mainForm = HT.Form(cgi= os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), - name='dataInput', submit=HT.Input(type='hidden')) - - next=HT.Input(type='submit', name='submit',value='Next',Class="button") - reset=HT.Input(type='Reset',name='',value=' Reset ',Class="button") - correlationMenus = [] - - if thisTrait == None: - thisTrait = webqtlTrait(data=fd.allTraitData, db=None) - - # Variance submit page only - if fd.enablevariance and not varianceDataPage: - title2Body.append("Click the next button to go to the variance submission form.", - HT.Center(next,reset)) - else: - self.dispBasicStatistics(fd, title2Body, thisTrait) - self.dispCorrelationTools(fd, title3Body, thisTrait) - self.dispMappingTools(fd, title4Body, thisTrait) - - ############################# - ## Trait Value Table - ############################# - - self.dispTraitValues(fd, title5Body, varianceDataPage, nCols, mainForm, thisTrait) - - if fd.allstrainlist: - hddn['allstrainlist'] = string.join(fd.allstrainlist, ' ') - for key in hddn.keys(): - mainForm.append(HT.Input(name=key, value=hddn[key], type='hidden')) - - if fd.enablevariance and not varianceDataPage: - #pre dataediting page, need to submit variance - mainForm.append(titleTop, title1,title1Body,title2,title2Body,title3,title3Body,title4,title4Body,title5,title5Body) - else: - mainForm.append(titleTop, title1,title1Body,title2,title2Body,title3,title3Body,title4,title4Body,title5,title5Body) - TD_LR.append(HT.Paragraph(mainForm)) - self.dict['body'] = str(TD_LR) - - ########################################## - ## Function to display header - ########################################## - def dispHeader(self, fd, thisTrait): - headSpan = HT.Div(style="font-size:14px;") - - #If trait, use trait name; otherwise, use identification value - if thisTrait: - if thisTrait.cellid: - headSpan.append(HT.Strong('Trait Data and Analysis ', style='font-size:16px;'),' for Probe ID ', thisTrait.cellid) - else: - headSpan.append(HT.Strong('Trait Data and Analysis ', style='font-size:16px;'),' for Record ID ', thisTrait.name) - else: - if fd.identification: - headSpan.append(HT.Strong('Trait ID ', style='font-size:16px;'),fd.identification) - else: - headSpan.append(HT.Strong('Un-named Trait', style='font-size:16px;')) - - return headSpan - - ########################################## - ## Function to display trait infos - ########################################## - def dispTraitInformation(self, fd, title1Body, hddn, thisTrait): - - _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 thisTrait==None or thisTrait.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 thisTrait.db.type != 'Temp': - if thisTrait.db.type == 'Publish' and thisTrait.confidential: #XZ: confidential phenotype trait - if webqtlUtil.hasAccessToConfidentialPhenotypeTrait(privilege=self.privilege, userName=self.userName, authorized_users=thisTrait.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 thisTrait: - 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 thisTrait and thisTrait.db and thisTrait.db.type == 'ProbeSet': #before, this line was only reached if thisTrait != 0, but now we need to check - try: - hddn['GeneId'] = int(string.strip(thisTrait.geneid)) - except: - pass - - #Info2Disp = HT.Paragraph() - - #XZ: Gene Symbol - if thisTrait.symbol: - #XZ: Show SNP Browser only for mouse - if _Species == 'mouse': - self.cursor.execute("select geneSymbol from GeneList where geneSymbol = %s", thisTrait.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 thisTrait.chr and thisTrait.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" % (thisTrait.chr, thisTrait.mb-0.002, thisTrait.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" % thisTrait.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 thisTrait and thisTrait.db and thisTrait.db.type=="ProbeSet" and thisTrait.symbol: - if _Species in ("mouse", "rat", "human"): - similarUrl = "%s?cmd=sch&gene=%s&alias=1&species=%s" % (os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), thisTrait.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' % thisTrait.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") - )) - - #XZ: Gene Alias - if thisTrait.alias: - alias = string.replace(thisTrait.alias, ";", " ") - alias = string.join(string.split(alias), ", ") - tbl.append(HT.TR( - HT.TD('Aliases: ', Class="fwb fs13", valign="top", nowrap="on"), - HT.TD(width=10, valign="top"), - HT.TD(HT.Span(alias, Class="fs13 fsI"), valign="top") - )) - - #XZ: Description - if thisTrait.description: - tSpan = HT.Span(thisTrait.description, Class="fs13") - if thisTrait.probe_target_description: - tSpan.append('; ', thisTrait.probe_target_description) - else: - tSpan = HT.Span('Not available', Class="fs13") - tbl.append(HT.TR( - HT.TD('Description: ', Class="fwb fs13", valign="top", nowrap="on"), - HT.TD(width=10, valign="top"), - HT.TD(tSpan, valign="top") - )) - - #XZ: Location - - #XZ: deal with Chr and Mb - if thisTrait.chr and thisTrait.mb: - tSpan = HT.Span('Chr %s @ %s Mb' % (thisTrait.chr,thisTrait.mb),Class="fs13") - elif (thisTrait.chr): - tSpan = HT.Span('Chr %s @ Unknown position' % (thisTrait.chr), Class="fs13") - else: - tSpan = HT.Span('Not available', Class="fs13") - - #XZ: deal with direction - if thisTrait.strand_probe == '+': - tSpan.append(' on the plus strand ') - elif thisTrait.strand_probe == '-': - tSpan.append(' on the minus strand ') - else: - pass - - tbl.append(HT.TR( - HT.TD('Location: ', Class="fwb fs13", valign="top", nowrap="on"), - HT.TD(width=10, valign="top"), - HT.TD(tSpan, valign="top") - )) - - ##display Verify Location button - try: - blatsequence = thisTrait.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""" % (thisTrait.db.name, thisTrait.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'+thisTrait.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""" % (thisTrait.db.name, thisTrait.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 = thisTrait.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 thisTrait.db.name.find('Liver') >= 0 and thisTrait.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""" % (thisTrait.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), thisTrait.db, thisTrait.name, thisTrait.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 thisTrait.probe_set_specificity or thisTrait.probe_set_blat_score: - if thisTrait.probe_set_specificity: - 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(thisTrait.probe_set_specificity), " "*3) - if thisTrait.probe_set_blat_score: - tSpan.append("Score: %s" % int(thisTrait.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 thisTrait.cellid: - self.cursor.execute(""" - select ProbeFreeze.Name from ProbeFreeze, ProbeSetFreeze - where - ProbeFreeze.Id = ProbeSetFreeze.ProbeFreezeId AND - ProbeSetFreeze.Id = %d""" % thisTrait.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=thisTrait.db.fullname, url = webqtlConfig.INFOPAGEHREF % thisTrait.db.name, - target='_blank', Class="fs13 fwn non_bold"), valign="top") - )) - - #XZ: ID links - if thisTrait.genbankid or thisTrait.geneid or thisTrait.unigeneid or thisTrait.omim or thisTrait.homologeneid: - idStyle = "background:#dddddd;padding:2" - tSpan = HT.Span(Class="fs13") - if thisTrait.geneid: - gurl = HT.Href(text= 'Gene', target='_blank',\ - url=webqtlConfig.NCBI_LOCUSID % thisTrait.geneid, Class="fs14 fwn", title="Info from NCBI Entrez Gene") - tSpan.append(HT.Span(gurl, style=idStyle), " "*2) - if thisTrait.omim: - gurl = HT.Href(text= 'OMIM', target='_blank', \ - url= webqtlConfig.OMIM_ID % thisTrait.omim,Class="fs14 fwn", title="Summary from On Mendelian Inheritance in Man") - tSpan.append(HT.Span(gurl, style=idStyle), " "*2) - if thisTrait.unigeneid: - try: - gurl = HT.Href(text= 'UniGene',target='_blank',\ - url= webqtlConfig.UNIGEN_ID % tuple(string.split(thisTrait.unigeneid,'.')[:2]),Class="fs14 fwn", title="UniGene ID") - tSpan.append(HT.Span(gurl, style=idStyle), " "*2) - except: - pass - if thisTrait.genbankid: - thisTrait.genbankid = '|'.join(thisTrait.genbankid.split('|')[0:10]) - if thisTrait.genbankid[-1]=='|': - thisTrait.genbankid=thisTrait.genbankid[0:-1] - gurl = HT.Href(text= 'GenBank', target='_blank', \ - url= webqtlConfig.GENBANK_ID % thisTrait.genbankid,Class="fs14 fwn", title="Find the original GenBank sequence used to design the probes") - tSpan.append(HT.Span(gurl, style=idStyle), " "*2) - if thisTrait.homologeneid: - hurl = HT.Href(text= 'HomoloGene', target='_blank',\ - url=webqtlConfig.HOMOLOGENE_ID % thisTrait.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 thisTrait.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'" % thisTrait.symbol) - self.cursor.execute('SELECT kgID, chromosome,txStart,txEnd FROM GeneList_rn33 WHERE geneSymbol = "%s"' % thisTrait.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'" % thisTrait.symbol) - self.cursor.execute('SELECT chromosome,txStart,txEnd FROM GeneList WHERE geneSymbol = "%s"' % thisTrait.symbol) - try: - chr, txst, txen = self.cursor.fetchall()[0] - if chr and txst and txen and thisTrait.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',thisTrait.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" \ - # % (thisTrait.symbol,symatlas_species),Class="fs14 fwn", \ - # title="Expression across many tissues and cell types"), style=linkStyle), " "*2) - if thisTrait.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, thisTrait.geneid),Class="fs14 fwn", \ - title="Expression across many tissues and cell types"), style=linkStyle), " "*2) - tSpan.append(HT.Span(HT.Href(text= 'STRING',target="mainFrame",\ - url="http://string.embl.de/newstring_cgi/show_link_summary.pl?identifier=%s" \ - % thisTrait.symbol,Class="fs14 fwn", \ - title="Protein interactions: known and inferred"), style=linkStyle), " "*2) - if thisTrait.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, thisTrait.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" \ - # % thisTrait.symbol,Class="fs14 fwn", \ - # title="Protein interactions"), style=linkStyle), " "*2) - if thisTrait.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" \ - % thisTrait.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" \ - % thisTrait.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" \ - % thisTrait.symbol, Class="fs14 fwn", \ - title="Allen Brain Atlas"), style=linkStyle), " "*2) - - if thisTrait.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" \ - # % thisTrait.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" \ - % thisTrait.geneid, Class="fs14 fwn", \ - title="Allen Brain Atlas"), style=linkStyle), " "*2) - 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 thisTrait and thisTrait.db and thisTrait.db.type =='Publish': #Check if trait is phenotype - - if thisTrait.confidential: - 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(thisTrait.pre_publication_description, Class="fs13"), valign="top", width=740) - )) - if webqtlUtil.hasAccessToConfidentialPhenotypeTrait(privilege=self.privilege, userName=self.userName, authorized_users=thisTrait.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(thisTrait.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(thisTrait.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(thisTrait.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(thisTrait.lab_code, Class="fs13"), valign="top", width=740) - )) - 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(thisTrait.owner, Class="fs13"), valign="top", width=740) - )) - else: - 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(thisTrait.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(thisTrait.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(thisTrait.title, Class="fs13"), - valign="top", width=740) - )) - if thisTrait.journal: - journal = thisTrait.journal - if thisTrait.year: - journal = thisTrait.journal + " (%s)" % thisTrait.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 thisTrait.pubmed_id: - PubMedLink = webqtlConfig.PUBMEDLINK_URL % thisTrait.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) - )) - - 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 thisTrait and thisTrait.db and thisTrait.db.type == 'Geno': #Check if trait is genotype - - GenoInfo = HT.Paragraph() - if thisTrait.chr and thisTrait.mb: - location = ' Chr %s @ %s Mb' % (thisTrait.chr,thisTrait.mb) - else: - location = "not available" - - if thisTrait.sequence and len(thisTrait.sequence) > 100: - if _Species == "rat": - UCSC_BLAT_URL = webqtlConfig.UCSC_BLAT % ('rat', 'rn3', thisTrait.sequence) - UTHSC_BLAT_URL = webqtlConfig.UTHSC_BLAT % ('rat', 'rn3', thisTrait.sequence) - elif _Species == "mouse": - UCSC_BLAT_URL = webqtlConfig.UCSC_BLAT % ('mouse', 'mm9', thisTrait.sequence) - UTHSC_BLAT_URL = webqtlConfig.UTHSC_BLAT % ('mouse', 'mm9', thisTrait.sequence) - elif _Species == "human": - UCSC_BLAT_URL = webqtlConfig.UCSC_BLAT % ('human', 'hg19', blatsequence) - UTHSC_BLAT_URL = webqtlConfig.UTHSC_BLAT % ('human', 'hg19', thisTrait.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" % thisTrait.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 (thisTrait == None or thisTrait.db.type == 'Temp'): #if temporary trait (user-submitted trait or PCA trait) - - TempInfo = HT.Paragraph() - if thisTrait != None: - if thisTrait.description: - tbl.append(HT.TR(HT.TD(HT.Strong('Description: '),' %s ' % thisTrait.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 - - - ########################################## - ## Function to display analysis tools - ########################################## - def dispBasicStatistics(self, fd, title2Body, thisTrait): - - #XZ, June 22, 2011: The definition and usage of primary_strains, other_strains, specialStrains, all_strains 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.strainlist later. - stats_row = HT.TR() - stats_cell = HT.TD() - - if fd.genotype.type == "riset": - strainlist = fd.f1list + fd.strainlist - else: - strainlist = fd.f1list + fd.parlist + fd.strainlist - - other_strains = [] #XZ: strain that is not of primary group - specialStrains = [] #XZ: This might be replaced by other_strains / ZS: It is just other strains without parent/f1 strains. - all_strains = [] - primary_strains = [] #XZ: strain of primary group, e.g., BXD, LXS - - MDP_menu = HT.Select(name='stats_mdp', Class='stats_mdp') - - for strain in thisTrait.data.keys(): - strainName = strain.replace("_2nd_", "") - if strain not in strainlist: - if (thisTrait.data[strainName].val != None): - if strain.find('F1') < 0: - specialStrains.append(strain) - if (thisTrait.data[strainName].val != None) and (strain not in (fd.f1list + fd.parlist)): - other_strains.append(strain) #XZ: at current stage, other_strains doesn't include parent strains and F1 strains of primary group - else: - if (thisTrait.data[strainName].val != None) and (strain not in (fd.f1list + fd.parlist)): - primary_strains.append(strain) #XZ: at current stage, the primary_strains is the same as fd.strainlist / ZS: I tried defining primary_strains as fd.strainlist instead, but in some cases it ended up including the parent strains (1436869_at BXD) - - if len(other_strains) > 3: - other_strains.sort(key=webqtlUtil.natsort_key) - primary_strains.sort(key=webqtlUtil.natsort_key) - primary_strains = map(lambda X:"_2nd_"+X, fd.f1list + fd.parlist) + primary_strains #XZ: note that fd.f1list and fd.parlist are added. - all_strains = primary_strains + other_strains - other_strains = map(lambda X:"_2nd_"+X, fd.f1list + fd.parlist) + other_strains #XZ: note that fd.f1list and fd.parlist are added. - MDP_menu.append(('All Cases','0')) - MDP_menu.append(('%s Only' % fd.RISet,'1')) - MDP_menu.append(('Non-%s Only' % fd.RISet,'2')) - stats_row.append("Include: ", MDP_menu, HT.BR(), HT.BR()) - else: - if (len(other_strains) > 0) and (len(primary_strains) + len(other_strains) > 3): - MDP_menu.append(('All Cases','0')) - MDP_menu.append(('%s Only' % fd.RISet,'1')) - MDP_menu.append(('Non-%s Only' % fd.RISet,'2')) - stats_row.append("Include: ", MDP_menu, " "*3) - all_strains = primary_strains - all_strains.sort(key=webqtlUtil.natsort_key) - all_strains = map(lambda X:"_2nd_"+X, fd.f1list + fd.parlist) + all_strains - primary_strains = map(lambda X:"_2nd_"+X, fd.f1list + fd.parlist) + primary_strains - else: - all_strains = strainlist - - other_strains.sort(key=webqtlUtil.natsort_key) - all_strains = all_strains + other_strains - pass - - update_button = HT.Input(type='button',value=' Update Figures ', Class="button update") #This is used to reload the page and update the Basic Statistics figures with user-edited data - stats_row.append(update_button, HT.BR(), HT.BR()) - - if (len(other_strains)) > 0 and (len(primary_strains) + len(other_strains) > 4): - #One set of vals for all, selected strain only, and non-selected only - vals1 = [] - vals2 = [] - vals3 = [] - - #Using all strains/cases for values - for i, strainNameOrig in enumerate(all_strains): - strainName = strainNameOrig.replace("_2nd_", "") - - try: - thisval = thisTrait.data[strainName].val - thisvar = thisTrait.data[strainName].var - thisValFull = [strainName,thisval,thisvar] - except: - continue - - vals1.append(thisValFull) - - #Using just the RISet strain - for i, strainNameOrig in enumerate(primary_strains): - strainName = strainNameOrig.replace("_2nd_", "") - - try: - thisval = thisTrait.data[strainName].val - thisvar = thisTrait.data[strainName].var - thisValFull = [strainName,thisval,thisvar] - except: - continue - - vals2.append(thisValFull) - - #Using all non-RISet strains only - for i, strainNameOrig in enumerate(other_strains): - strainName = strainNameOrig.replace("_2nd_", "") - - try: - thisval = thisTrait.data[strainName].val - thisvar = thisTrait.data[strainName].var - thisValFull = [strainName,thisval,thisvar] - except: - continue - - vals3.append(thisValFull) - - vals_set = [vals1,vals2,vals3] - - else: - vals = [] - - #Using all strains/cases for values - for i, strainNameOrig in enumerate(all_strains): - strainName = strainNameOrig.replace("_2nd_", "") - - try: - thisval = thisTrait.data[strainName].val - thisvar = thisTrait.data[strainName].var - thisValFull = [strainName,thisval,thisvar] - except: - continue - - vals.append(thisValFull) - - vals_set = [vals] - - stats_script = HT.Script(language="Javascript") #script needed for tabs - - 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_strains) < 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_strains) < 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 thisTrait.db: - if thisTrait.cellid: - statsTableCell = BasicStatisticsFunctions.basicStatsTable(vals=vals, trait_type=thisTrait.db.type, cellid=thisTrait.cellid) - else: - statsTableCell = BasicStatisticsFunctions.basicStatsTable(vals=vals, trait_type=thisTrait.db.type) - else: - statsTableCell = 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 = thisTrait.symbol - plotTitle += ": " - plotTitle += thisTrait.name - except: - plotTitle = str(thisTrait.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 dispCorrelationTools(self, fd, title3Body, thisTrait): - - _Species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, RISet=fd.RISet) - - RISetgp = fd.RISet - 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') - - nmenu = 0 - self.cursor.execute('SELECT PublishFreeze.FullName,PublishFreeze.Name FROM \ - PublishFreeze,InbredSet WHERE PublishFreeze.InbredSetId = InbredSet.Id \ - and InbredSet.Name = "%s" and PublishFreeze.public > %d' % \ - (RISetgp,webqtlConfig.PUBLICTHRESH)) - for item in self.cursor.fetchall(): - databaseMenu1.append(item) - databaseMenu2.append(item) - databaseMenu3.append(item) - nmenu += 1 - self.cursor.execute('SELECT GenoFreeze.FullName,GenoFreeze.Name FROM GenoFreeze,\ - InbredSet WHERE GenoFreeze.InbredSetId = InbredSet.Id and InbredSet.Name = \ - "%s" and GenoFreeze.public > %d' % (RISetgp,webqtlConfig.PUBLICTHRESH)) - for item in self.cursor.fetchall(): - databaseMenu1.append(item) - databaseMenu2.append(item) - databaseMenu3.append(item) - nmenu += 1 - #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(): - TId, TName = item - databaseMenuSub = HT.Optgroup(label = '%s ------' % TName) - self.cursor.execute('SELECT ProbeSetFreeze.FullName,ProbeSetFreeze.Name FROM ProbeSetFreeze, ProbeFreeze, \ - InbredSet WHERE ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id and ProbeFreeze.TissueId = %d and \ - ProbeSetFreeze.public > %d and ProbeFreeze.InbredSetId = InbredSet.Id and InbredSet.Name like "%s%%" \ - order by ProbeSetFreeze.CreateTime desc, ProbeSetFreeze.AvgId ' % (TId,webqtlConfig.PUBLICTHRESH, RISetgp)) - for item2 in self.cursor.fetchall(): - databaseMenuSub.append(item2) - nmenu += 1 - databaseMenu1.append(databaseMenuSub) - databaseMenu2.append(databaseMenuSub) - databaseMenu3.append(databaseMenuSub) - if nmenu: - if thisTrait and thisTrait.db != None: - databaseMenu1.selected.append(thisTrait.db.fullname) - databaseMenu2.selected.append(thisTrait.db.fullname) - databaseMenu3.selected.append(thisTrait.db.fullname) - - criteriaText = HT.Span("Return:", Class="ffl fwb fs12") - - criteriaMenu1 = HT.Select(name='criteria1', selected='500', onMouseOver="if (NS4 || IE4) activateEl('criterias', event);") - 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')) - - criteriaMenu2 = HT.Select(name='criteria2', selected='500', onMouseOver="if (NS4 || IE4) activateEl('criterias', event);") - criteriaMenu2.append(('top 100','100')) - criteriaMenu2.append(('top 200','200')) - criteriaMenu2.append(('top 500','500')) - criteriaMenu2.append(('top 1000','1000')) - criteriaMenu2.append(('top 2000','2000')) - criteriaMenu2.append(('top 5000','5000')) - criteriaMenu2.append(('top 10000','10000')) - criteriaMenu2.append(('top 15000','15000')) - criteriaMenu2.append(('top 20000','20000')) - - criteriaMenu3 = HT.Select(name='criteria3', selected='500', onMouseOver="if (NS4 || IE4) activateEl('criterias', event);") - criteriaMenu3.append(('top 100','100')) - criteriaMenu3.append(('top 200','200')) - criteriaMenu3.append(('top 500','500')) - criteriaMenu3.append(('top 1000','1000')) - criteriaMenu3.append(('top 2000','2000')) - criteriaMenu3.append(('top 5000','5000')) - criteriaMenu3.append(('top 10000','10000')) - criteriaMenu3.append(('top 15000','15000')) - criteriaMenu3.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 (thisTrait.db != None and thisTrait.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 thisTrait.db != None: - if (thisTrait.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 thisTrait.db != None: - if (thisTrait.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) - - - def dispMappingTools(self, fd, title4Body, thisTrait): - - _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(tuple(["All",-1])) - for i in range(len(fd.genotype)): - if len(fd.genotype[i]) > 1: - chrMenu.append(tuple([fd.genotype[i].name,i])) - - #Menu for Composite Interval Mapping - chrMenu2 = HT.Select(name='chromosomes2') - chrMenu2.append(tuple(["All",-1])) - for i in range(len(fd.genotype)): - if len(fd.genotype[i]) > 1: - chrMenu2.append(tuple([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 mappingMethodId != None: - 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 natural_sort(strain_list): - - sorted = [] - for strain in strain_list: - try: - strain = int(strain) - try: sorted[-1] = sorted[-1] * 10 + strain - except: sorted.append(strain) - except: - sorted.append(strain) - return sorted - - ########################################## - ## Function to display trait tables - ########################################## - def dispTraitValues(self, fd , title5Body, varianceDataPage, nCols, mainForm, thisTrait): - traitTableOptions = HT.Div(style="border: 3px solid #EEEEEE; -moz-border-radius: 10px; -webkit-border-radius: 10px; width: 625px; padding: 5px 5px 10px 8px; font-size: 12px; background: #DDDDDD;") - resetButton = HT.Input(type='button',name='resetButton',value=' Reset ',Class="button") - blockSamplesField = HT.Input(type="text",style="background-color:white;border: 1px solid black;font-size: 14px;", name="removeField") - blockSamplesButton = HT.Input(type='button',value=' Block ', name='blockSamples', Class="button") - showHideNoValue = HT.Input(type='button', name='showHideNoValue', value=' Hide No Value ',Class='button') - blockMenuSpan = HT.Span(Id="blockMenuSpan") - blockMenu = HT.Select(name='block_method') - - if fd.genotype.type == "riset": - allstrainlist_neworder = fd.f1list + fd.strainlist - else: - allstrainlist_neworder = fd.f1list + fd.parlist + fd.strainlist - - attribute_ids = [] - attribute_names = [] - try: - #ZS: Id values for this trait's extra attributes; used to create "Exclude" dropdown and query for attribute values and create - self.cursor.execute("""SELECT CaseAttribute.Id, CaseAttribute.Name - FROM CaseAttribute, CaseAttributeXRef - WHERE CaseAttributeXRef.ProbeSetFreezeId = '%s' AND - CaseAttribute.Id = CaseAttributeXRef.CaseAttributeId - group by CaseAttributeXRef.CaseAttributeId""" % (str(thisTrait.db.id))) - - exclude_menu = HT.Select(name="exclude_menu") - dropdown_menus = [] #ZS: list of dropdown menus with the distinct values of each attribute (contained in DIVs so the style parameter can be edited and they can be hidden) - - for attribute in self.cursor.fetchall(): - attribute_ids.append(attribute[0]) - attribute_names.append(attribute[1]) - for this_attr_name in attribute_names: - exclude_menu.append((this_attr_name.capitalize(), this_attr_name)) - self.cursor.execute("""SELECT DISTINCT CaseAttributeXRef.Value - FROM CaseAttribute, CaseAttributeXRef - WHERE CaseAttribute.Name = '%s' AND - CaseAttributeXRef.CaseAttributeId = CaseAttribute.Id""" % (this_attr_name)) - try: - distinct_values = self.cursor.fetchall() - attr_value_menu_div = HT.Div(style="display:none;", Class="attribute_values") #container used to show/hide dropdown menus - attr_value_menu = HT.Select(name=this_attr_name) - attr_value_menu.append(("None", "show_all")) - for value in distinct_values: - attr_value_menu.append((str(value[0]), value[0])) - attr_value_menu_div.append(attr_value_menu) - dropdown_menus.append(attr_value_menu_div) - except: - pass - except: - pass - - other_strains = [] - for strain in thisTrait.data.keys(): - if strain not in allstrainlist_neworder: - other_strains.append(strain) - - if other_strains: - blockMenu.append(('%s Only' % fd.RISet,'1')) - blockMenu.append(('Non-%s Only' % fd.RISet,'0')) - blockMenuSpan.append(blockMenu) - else: - pass - - showHideOutliers = HT.Input(type='button', name='showHideOutliers', value=' Hide Outliers ', Class='button') - showHideMenuOptions = HT.Span(Id="showHideOptions", style="line-height:225%;") - if other_strains: - showHideMenuOptions.append(HT.Bold("  Block samples by index:    "), blockSamplesField, "   ", blockMenuSpan, "   ", blockSamplesButton, HT.BR()) - else: - showHideMenuOptions.append(HT.Bold("  Block samples by index:    "), blockSamplesField, "   ", blockSamplesButton, HT.BR()) - - exportButton = HT.Input(type='button', name='export', value=' Export ', Class='button') - if len(attribute_names) > 0: - excludeButton = HT.Input(type='button', name='excludeGroup', value=' Block ', Class='button') - showHideMenuOptions.append(HT.Bold("  Block samples by group:"), " "*5, exclude_menu, " "*5) - for menu in dropdown_menus: - showHideMenuOptions.append(menu) - showHideMenuOptions.append(" "*5, excludeButton, HT.BR()) - showHideMenuOptions.append(HT.Bold("  Options:"), " "*5, showHideNoValue, " "*5, showHideOutliers, " "*5, resetButton, " "*5, exportButton) - - traitTableOptions.append(showHideMenuOptions,HT.BR(),HT.BR()) - traitTableOptions.append(HT.Span("  Outliers highlighted in ", HT.Bold(" yellow ", style="background-color:yellow;"), " can be hidden using the ", - HT.Strong(" Hide Outliers "), " button,",HT.BR(),"  and samples with no value (x) can be hidden by clicking ", - HT.Strong(" Hide No Value "), "."), HT.BR()) - - - dispintro = HT.Paragraph("Edit or delete values in the Trait Data boxes, and use the ", HT.Strong("Reset"), " option as needed.",Class="fs12", style="margin-left:20px;") - - table = HT.TableLite(cellspacing=0, cellpadding=0, width="100%", Class="target5") #Everything needs to be inside this table object in order for the toggle to work - container = HT.Div() #This will contain everything and be put into a cell of the table defined above - - container.append(dispintro, traitTableOptions, HT.BR()) - - primary_table = HT.TableLite(cellspacing=0, cellpadding=0, Id="sortable1", Class="tablesorter") - primary_header = self.getTableHeader(fd=fd, thisTrait=thisTrait, nCols=nCols, attribute_names=attribute_names) #Generate header for primary table object - - other_strainsExist = False - for strain in thisTrait.data.keys(): - if strain not in allstrainlist_neworder: - other_strainsExist = True - break - - primary_body = self.addTrait2Table(fd=fd, varianceDataPage=varianceDataPage, strainlist=allstrainlist_neworder, mainForm=mainForm, thisTrait=thisTrait, other_strainsExist=other_strainsExist, attribute_ids=attribute_ids, attribute_names=attribute_names, strains='primary') - - primary_table.append(primary_header) - for i in range(len(primary_body)): - primary_table.append(primary_body[i]) - - other_strains = [] - for strain in thisTrait.data.keys(): - if strain not in allstrainlist_neworder: - allstrainlist_neworder.append(strain) - other_strains.append(strain) - - if other_strains: - other_table = HT.TableLite(cellspacing=0, cellpadding=0, Id="sortable2", Class="tablesorter") #Table object with other (for example, non-BXD / MDP) traits - other_header = self.getTableHeader(fd=fd, thisTrait=thisTrait, nCols=nCols, attribute_names=attribute_names) #Generate header for other table object; same function is used as the one used for the primary table, since the header is the same - other_strains.sort() #Sort other strains - other_strains = map(lambda X:"_2nd_"+X, fd.f1list + fd.parlist) + other_strains #Append F1 and parent strains to the beginning of the sorted list of other strains - - MDPText = HT.Span("Samples:", Class="ffl fwb fs12") - MDPMenu1 = HT.Select(name='MDPChoice1') - MDPMenu2 = HT.Select(name='MDPChoice2') - MDPMenu3 = HT.Select(name='MDPChoice3') - MDPMenu1.append(('%s Only' % fd.RISet,'1')) - MDPMenu2.append(('%s Only' % fd.RISet,'1')) - MDPMenu3.append(('%s Only' % fd.RISet,'1')) - MDPMenu1.append(('Non-%s Only' % fd.RISet,'2')) - MDPMenu2.append(('Non-%s Only' % fd.RISet,'2')) - MDPMenu3.append(('Non-%s Only' % fd.RISet,'2')) - MDPMenu1.append(('All Cases','0')) - MDPMenu2.append(('All Cases','0')) - MDPMenu3.append(('All Cases','0')) - self.MDPRow1.append(HT.TD(MDPText),HT.TD(MDPMenu1)) - self.MDPRow2.append(HT.TD(MDPText),HT.TD(MDPMenu2)) - self.MDPRow3.append(HT.TD(MDPText),HT.TD(MDPMenu3)) - - other_body = self.addTrait2Table(fd=fd, varianceDataPage=varianceDataPage, strainlist=other_strains, mainForm=mainForm, thisTrait=thisTrait, attribute_ids=attribute_ids, attribute_names=attribute_names, strains='other') - - other_table.append(other_header) - for i in range(len(other_body)): - other_table.append(other_body[i]) - else: - pass - - if other_strains or (fd.f1list and thisTrait.data.has_key(fd.f1list[0])) \ - or (fd.f1list and thisTrait.data.has_key(fd.f1list[1])): - fd.allstrainlist = allstrainlist_neworder - - if nCols == 6 and fd.varianceDispName != 'Variance': - mainForm.append(HT.Input(name='isSE', value="yes", type='hidden')) - - primary_div = HT.Div(primary_table, Id="primary") #Container for table with primary (for example, BXD) strain values - container.append(primary_div) - - if other_strains: - other_div = HT.Div(other_table, Id="other") #Container for table with other (for example, Non-BXD/MDP) strain values - container.append(HT.Div(' ', height=30)) - container.append(other_div) - - table.append(HT.TR(HT.TD(container))) - title5Body.append(table) - - def addTrait2Table(self, fd, varianceDataPage, strainlist, mainForm, thisTrait, other_strainsExist=None, attribute_ids=[], attribute_names=[], strains='primary'): - #XZ, Aug 23, 2010: I commented the code related to the display of animal case - #strainInfo = thisTrait.has_key('strainInfo') and thisTrait.strainInfo - - table_body = [] - vals = [] - - for i, strainNameOrig in enumerate(strainlist): - strainName = strainNameOrig.replace("_2nd_", "") - - try: - thisval = thisTrait.data[strainName].val - thisvar = thisTrait.data[strainName].var - thisValFull = [strainName,thisval,thisvar] - except: - continue - - vals.append(thisValFull) - - upperBound, lowerBound = Plot.findOutliers(vals) # ZS: Values greater than upperBound or less than lowerBound are considered outliers. - - for i, strainNameOrig in enumerate(strainlist): - - trId = strainNameOrig - selectCheck = HT.Input(type="checkbox", name="selectCheck", value=trId, Class="checkbox", onClick="highlight(this)") - - strainName = strainNameOrig.replace("_2nd_", "") - strainNameAdd = '' - if fd.RISet == 'AXBXA' and strainName in ('AXB18/19/20','AXB13/14','BXA8/17'): - strainNameAdd = HT.Href(url='/mouseCross.html#AXB/BXA', text=HT.Sup('#'), Class='fs12', target="_blank") - - try: - thisval, thisvar, thisNP = thisTrait.data[strainName].val, thisTrait.data[strainName].var, thisTrait.data[strainName].N - if thisNP: - mainForm.append(HT.Input(name='N'+strainName, value=thisNP, type='hidden')) - else: - pass - except: - thisval = thisvar = 'x' - - try: - traitVal = thisval - dispVal = "%2.3f" % thisval - except: - traitVal = '' - dispVal = 'x' - - strainNameDisp = HT.Span(strainName, Class='fs14 fwn ffl') - - if varianceDataPage: - try: - traitVar = thisvar - dispVar = "%2.3f" % thisvar - except: - traitVar = '' - dispVar = 'x' - - if thisval == 'x': - traitVar = '' #ZS: Used to be 0, but it doesn't seem like a good idea for values of 0 to *always* be at the bottom when you sort; it makes more sense to put "nothing" - - className = 'fs13 b1 c222 ' - valueClassName = 'fs13 b1 c222 valueField ' - rowClassName = 'novalue ' - else: - if (thisval >= upperBound) or (thisval <= lowerBound): - className = 'fs13 b1 c222 outlier ' - valueClassName = 'fs13 b1 c222 valueField ' - rowClassName = 'outlier' - else: - className = 'fs13 b1 c222 ' - valueClassName = 'fs13 b1 c222 valueField ' - rowClassName = ' ' - - if varianceDataPage: - varClassName = valueClassName + str(traitVar) - valueClassName += str(traitVal) - - if strainNameOrig == strainName: - if other_strainsExist and strainNameOrig in (fd.parlist + fd.f1list): - ######################################################################################################################################################## - # ZS: Append value and variance to the value and variance input fields' list of classes; this is so the javascript can update the value when the user - # changes it. The updated value is then used when the table is sorted (tablesorter.js). This needs to be done because the "value" attribute is immutable. - ######################################################################################################################################################### - - valueField = HT.Input(name=strainNameOrig, size=8, maxlength=8, style="text-align:right; background-color:#FFFFFF;", value=dispVal, - onChange= "javascript:this.form['_2nd_%s'].value=this.form['%s'].value;" % (strainNameOrig.replace("/", ""), strainNameOrig.replace("/", "")), Class=valueClassName) - if varianceDataPage: - seField = HT.Input(name='V'+strainNameOrig, size=8, maxlength=8, style="text-align:right", value=dispVar, - onChange= "javascript:this.form['V_2nd_%s'].value=this.form['V%s'].value;" % (strainNameOrig.replace("/", ""), strainNameOrig.replace("/", "")), Class=varClassName) - else: - valueField = HT.Input(name=strainNameOrig, size=8, maxlength=8, style="text-align:right; background-color:#FFFFFF;", value=dispVal, Class=valueClassName) - if varianceDataPage: - seField = HT.Input(name='V'+strainNameOrig, size=8, maxlength=8, style="text-align:right", value=dispVar, Class=varClassName) - else: - valueField = HT.Input(name=strainNameOrig, size=8, maxlength=8, style="text-align:right", value=dispVal, - onChange= "javascript:this.form['%s'].value=this.form['%s'].value;" % (strainNameOrig.replace("/", ""), strainNameOrig.replace("/", "")), Class=valueClassName) - if varianceDataPage: - seField = HT.Input(name='V'+strainNameOrig, size=8, maxlength=8, style="text-align:right", value=dispVar, - onChange= "javascript:this.form['V%s'].value=this.form['V%s'].value;" % (strainNameOrig.replace("/", ""), strainNameOrig.replace("/", "")), Class=varClassName) - - if (strains == 'primary'): - table_row = HT.TR(Id="Primary_"+str(i+1), Class=rowClassName) - else: - table_row = HT.TR(Id="Other_"+str(i+1), Class=rowClassName) - - if varianceDataPage: - table_row.append(HT.TD(str(i+1), selectCheck, width=45, align='right', Class=className)) - table_row.append(HT.TD(strainNameDisp, strainNameAdd, align='right', width=100, Class=className)) - table_row.append(HT.TD(valueField, width=70, align='right', Id="value_"+str(i)+"_"+strains, Class=className)) - table_row.append(HT.TD("±", width=20, align='center', Class=className)) - table_row.append(HT.TD(seField, width=80, align='right', Id="SE_"+str(i)+"_"+strains, Class=className)) - else: - table_row.append(HT.TD(str(i+1), selectCheck, width=45, align='right', Class=className)) - table_row.append(HT.TD(strainNameDisp, strainNameAdd, align='right', width=100, Class=className)) - table_row.append(HT.TD(valueField, width=70, align='right', Id="value_"+str(i)+"_"+strains, Class=className)) - - if thisTrait and thisTrait.db and thisTrait.db.type =='ProbeSet': - if len(attribute_ids) > 0: - - #ZS: Get StrainId value for the next query - self.cursor.execute("""SELECT Strain.Id - FROM Strain, StrainXRef, InbredSet - WHERE Strain.Name = '%s' and - StrainXRef.StrainId = Strain.Id and - InbredSet.Id = StrainXRef.InbredSetId and - InbredSet.Name = '%s'""" % (strainName, fd.RISet)) - - strain_id = self.cursor.fetchone()[0] - - attr_counter = 1 # This is needed so the javascript can know which attribute type to associate this value with for the exported excel sheet (each attribute type being a column). - for attribute_id in attribute_ids: - - #ZS: Add extra case attribute values (if any) - self.cursor.execute("""SELECT Value - FROM CaseAttributeXRef - WHERE ProbeSetFreezeId = '%s' AND - StrainId = '%s' AND - CaseAttributeId = '%s' - group by CaseAttributeXRef.CaseAttributeId""" % (thisTrait.db.id, strain_id, str(attribute_id))) - - attributeValue = self.cursor.fetchone()[0] #Trait-specific attributes, if any - - #ZS: If it's an int, turn it into one for sorting (for example, 101 would be lower than 80 if they're strings instead of ints) - try: - attributeValue = int(attributeValue) - except: - pass - - span_Id = strains+"_attribute"+str(attr_counter)+"_sample"+str(i+1) - attr_container = HT.Span(attributeValue, Id=span_Id) - attr_className = str(attributeValue) + " " + className - table_row.append(HT.TD(attr_container, align='right', Class=attr_className)) - attr_counter += 1 - - table_body.append(table_row) - return table_body - - def getTableHeader(self, fd, thisTrait, nCols, attribute_names): - - table_header = HT.TR() - - col_class = "fs13 fwb ff1 b1 cw cbrb" - - if nCols == 6: - try: - if fd.varianceDispName: - pass - except: - fd.varianceDispName = 'Variance' - - table_header.append(HT.TH('Index', align='right', width=60, Class=col_class), - HT.TH('Sample', align='right', width=100, Class=col_class), - HT.TH('Value', align='right', width=70, Class=col_class), - HT.TH(' ', width=20, Class=col_class), - HT.TH(fd.varianceDispName, align='right', width=80, Class=col_class)) - - elif nCols == 4: - table_header.append(HT.TH('Index', align='right', width=60, Class=col_class), - HT.TH('Sample', align='right', width=100, Class=col_class), - HT.TH('Value', align='right', width=70, Class=col_class)) - - else: - pass - - if len(attribute_names) > 0: - i=0 - for attribute in attribute_names: - char_count = len(attribute) - cell_width = char_count * 14 - table_header.append(HT.TH(attribute, align='right', width=cell_width, Class="attribute_name " + col_class)) - i+=1 - - return table_header - - - def getSortByValue(self): - - sortby = ("", "") - - return sortby + def __init__(self, fd, thisTrait=None): + + templatePage.__init__(self, fd) + + self.dict['title'] = 'Data Editing' + TD_LR = HT.TD(valign="top",width="100%",bgcolor="#fafafa") + + if not self.openMysql(): + return + if not fd.genotype: + fd.readData(incf1=1) + + ############################# + # determine data editing page format + ############################# + varianceDataPage = 0 + if fd.formID == 'varianceChoice': + varianceDataPage = 1 + + if varianceDataPage: + fmID='dataEditing' + nCols = 6 + else: + if fd.enablevariance: + fmID='pre_dataEditing' + nCols = 4 + else: + fmID='dataEditing' + nCols = 4 + + ############################# + ## titles, etc. + ############################# + + #titleTop = HT.Div() + # + #title1 = HT.Paragraph("  Details and Links", style="border-radius: 5px;", Id="title1", Class="sectionheader") + #title1Body = HT.Paragraph(Id="sectionbody1") + # + #if fd.enablevariance and not varianceDataPage: + # title2 = HT.Paragraph("  Submit Variance", style="border-radius: 5px;", Id="title2", Class="sectionheader") + #else: + # title2 = HT.Paragraph("  Basic Statistics", style="border-radius: 5px;", Id="title2", Class="sectionheader") + #title2Body = HT.Paragraph(Id="sectionbody2") + # + #title3 = HT.Paragraph("  Calculate Correlations", style="border-radius: 5px;", Id="title3", Class="sectionheader") + #title3Body = HT.Paragraph(Id="sectionbody3") + # + #title4 = HT.Paragraph("  Mapping Tools", style="border-radius: 5px;", Id="title4", Class="sectionheader") + #title4Body = HT.Paragraph(Id="sectionbody4") + # + #title5 = HT.Paragraph("  Review and Edit Data", style="border-radius: 5px;", Id="title5", Class="sectionheader") + #title5Body = HT.Paragraph(Id="sectionbody5") + + ############################# + ## Hidden field + ############################# + + # Some fields, like method, are defaulted to None; otherwise in IE the field can't be changed using jquery + hddn = { + '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, + 'strainNames':'_', + 'strainVals':'_', + 'strainVars':'_', + 'otherStrainNames':'_', + 'otherStrainVals':'_', + 'otherStrainVars':'_', + 'extra_attributes':'_', + 'other_extra_attributes':'_' + } + + if fd.enablevariance: + hddn['enablevariance']='ON' + if fd.incparentsf1: + hddn['incparentsf1']='ON' + + if thisTrait: + hddn['fullname'] = str(thisTrait) + try: + hddn['normalPlotTitle'] = thisTrait.symbol + hddn['normalPlotTitle'] += ": " + hddn['normalPlotTitle'] += thisTrait.name + except: + hddn['normalPlotTitle'] = str(thisTrait.name) + hddn['fromDataEditingPage'] = 1 + if thisTrait.db and thisTrait.db.type and thisTrait.db.type == 'ProbeSet': + hddn['trait_type'] = thisTrait.db.type + if thisTrait.cellid: + hddn['cellid'] = thisTrait.cellid + else: + self.cursor.execute("SELECT h2 from ProbeSetXRef WHERE DataId = %d" % thisTrait.mysqlid) + heritability = self.cursor.fetchone() + hddn['heritability'] = heritability + + hddn['attribute_names'] = "" + + hddn['mappingMethodId'] = webqtlDatabaseFunction.getMappingMethod (cursor=self.cursor, groupName=fd.RISet) + + ############################# + ## Display Trait Information + ############################# + + #headSpan = self.dispHeader(fd,thisTrait) #Draw header + # + #titleTop.append(headSpan) + + 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, thisTrait) #Display trait information + function buttons + + ############################# + ## Generate form and buttons + ############################# + + mainForm = HT.Form(cgi= os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), + name='dataInput', submit=HT.Input(type='hidden')) + + next=HT.Input(type='submit', name='submit',value='Next',Class="button") + reset=HT.Input(type='Reset',name='',value=' Reset ',Class="button") + correlationMenus = [] + + if thisTrait == None: + thisTrait = webqtlTrait(data=fd.allTraitData, db=None) + + # Variance submit page only + if fd.enablevariance and not varianceDataPage: + title2Body.append("Click the next button to go to the variance submission form.", + HT.Center(next,reset)) + else: + self.dispBasicStatistics(fd, title2Body, thisTrait) + self.dispCorrelationTools(fd, title3Body, thisTrait) + self.dispMappingTools(fd, title4Body, thisTrait) + + ############################# + ## Trait Value Table + ############################# + + self.dispTraitValues(fd, title5Body, varianceDataPage, nCols, mainForm, thisTrait) + + if fd.allstrainlist: + hddn['allstrainlist'] = string.join(fd.allstrainlist, ' ') + for key in hddn.keys(): + mainForm.append(HT.Input(name=key, value=hddn[key], type='hidden')) + + if fd.enablevariance and not varianceDataPage: + #pre dataediting page, need to submit variance + mainForm.append(titleTop, title1,title1Body,title2,title2Body,title3,title3Body,title4,title4Body,title5,title5Body) + else: + mainForm.append(titleTop, title1,title1Body,title2,title2Body,title3,title3Body,title4,title4Body,title5,title5Body) + TD_LR.append(HT.Paragraph(mainForm)) + self.dict['body'] = str(TD_LR) + + ########################################## + ## Function to display header + ########################################## + def dispHeader(self, fd, thisTrait): + headSpan = HT.Div(style="font-size:14px;") + + #If trait, use trait name; otherwise, use identification value + if thisTrait: + if thisTrait.cellid: + headSpan.append(HT.Strong('Trait Data and Analysis ', style='font-size:16px;'),' for Probe ID ', thisTrait.cellid) + else: + headSpan.append(HT.Strong('Trait Data and Analysis ', style='font-size:16px;'),' for Record ID ', thisTrait.name) + else: + if fd.identification: + headSpan.append(HT.Strong('Trait ID ', style='font-size:16px;'),fd.identification) + else: + headSpan.append(HT.Strong('Un-named Trait', style='font-size:16px;')) + + return headSpan + + ########################################## + ## Function to display trait infos + ########################################## + def dispTraitInformation(self, fd, title1Body, hddn, thisTrait): + + _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 thisTrait==None or thisTrait.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 thisTrait.db.type != 'Temp': + if thisTrait.db.type == 'Publish' and thisTrait.confidential: #XZ: confidential phenotype trait + if webqtlUtil.hasAccessToConfidentialPhenotypeTrait(privilege=self.privilege, userName=self.userName, authorized_users=thisTrait.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 thisTrait: + 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 thisTrait and thisTrait.db and thisTrait.db.type == 'ProbeSet': #before, this line was only reached if thisTrait != 0, but now we need to check + try: + hddn['GeneId'] = int(string.strip(thisTrait.geneid)) + except: + pass + + #Info2Disp = HT.Paragraph() + + #XZ: Gene Symbol + if thisTrait.symbol: + #XZ: Show SNP Browser only for mouse + if _Species == 'mouse': + self.cursor.execute("select geneSymbol from GeneList where geneSymbol = %s", thisTrait.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 thisTrait.chr and thisTrait.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" % (thisTrait.chr, thisTrait.mb-0.002, thisTrait.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" % thisTrait.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 thisTrait and thisTrait.db and thisTrait.db.type=="ProbeSet" and thisTrait.symbol: + if _Species in ("mouse", "rat", "human"): + similarUrl = "%s?cmd=sch&gene=%s&alias=1&species=%s" % (os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), thisTrait.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' % thisTrait.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") + )) + + #XZ: Gene Alias + if thisTrait.alias: + alias = string.replace(thisTrait.alias, ";", " ") + alias = string.join(string.split(alias), ", ") + tbl.append(HT.TR( + HT.TD('Aliases: ', Class="fwb fs13", valign="top", nowrap="on"), + HT.TD(width=10, valign="top"), + HT.TD(HT.Span(alias, Class="fs13 fsI"), valign="top") + )) + + #XZ: Description + if thisTrait.description: + tSpan = HT.Span(thisTrait.description, Class="fs13") + if thisTrait.probe_target_description: + tSpan.append('; ', thisTrait.probe_target_description) + else: + tSpan = HT.Span('Not available', Class="fs13") + tbl.append(HT.TR( + HT.TD('Description: ', Class="fwb fs13", valign="top", nowrap="on"), + HT.TD(width=10, valign="top"), + HT.TD(tSpan, valign="top") + )) + + #XZ: Location + + #XZ: deal with Chr and Mb + if thisTrait.chr and thisTrait.mb: + tSpan = HT.Span('Chr %s @ %s Mb' % (thisTrait.chr,thisTrait.mb),Class="fs13") + elif (thisTrait.chr): + tSpan = HT.Span('Chr %s @ Unknown position' % (thisTrait.chr), Class="fs13") + else: + tSpan = HT.Span('Not available', Class="fs13") + + #XZ: deal with direction + if thisTrait.strand_probe == '+': + tSpan.append(' on the plus strand ') + elif thisTrait.strand_probe == '-': + tSpan.append(' on the minus strand ') + else: + pass + + tbl.append(HT.TR( + HT.TD('Location: ', Class="fwb fs13", valign="top", nowrap="on"), + HT.TD(width=10, valign="top"), + HT.TD(tSpan, valign="top") + )) + + ##display Verify Location button + try: + blatsequence = thisTrait.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""" % (thisTrait.db.name, thisTrait.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'+thisTrait.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""" % (thisTrait.db.name, thisTrait.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 = thisTrait.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 thisTrait.db.name.find('Liver') >= 0 and thisTrait.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""" % (thisTrait.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), thisTrait.db, thisTrait.name, thisTrait.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 thisTrait.probe_set_specificity or thisTrait.probe_set_blat_score: + if thisTrait.probe_set_specificity: + 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(thisTrait.probe_set_specificity), " "*3) + if thisTrait.probe_set_blat_score: + tSpan.append("Score: %s" % int(thisTrait.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 thisTrait.cellid: + self.cursor.execute(""" + select ProbeFreeze.Name from ProbeFreeze, ProbeSetFreeze + where + ProbeFreeze.Id = ProbeSetFreeze.ProbeFreezeId AND + ProbeSetFreeze.Id = %d""" % thisTrait.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=thisTrait.db.fullname, url = webqtlConfig.INFOPAGEHREF % thisTrait.db.name, + target='_blank', Class="fs13 fwn non_bold"), valign="top") + )) + + #XZ: ID links + if thisTrait.genbankid or thisTrait.geneid or thisTrait.unigeneid or thisTrait.omim or thisTrait.homologeneid: + idStyle = "background:#dddddd;padding:2" + tSpan = HT.Span(Class="fs13") + if thisTrait.geneid: + gurl = HT.Href(text= 'Gene', target='_blank',\ + url=webqtlConfig.NCBI_LOCUSID % thisTrait.geneid, Class="fs14 fwn", title="Info from NCBI Entrez Gene") + tSpan.append(HT.Span(gurl, style=idStyle), " "*2) + if thisTrait.omim: + gurl = HT.Href(text= 'OMIM', target='_blank', \ + url= webqtlConfig.OMIM_ID % thisTrait.omim,Class="fs14 fwn", title="Summary from On Mendelian Inheritance in Man") + tSpan.append(HT.Span(gurl, style=idStyle), " "*2) + if thisTrait.unigeneid: + try: + gurl = HT.Href(text= 'UniGene',target='_blank',\ + url= webqtlConfig.UNIGEN_ID % tuple(string.split(thisTrait.unigeneid,'.')[:2]),Class="fs14 fwn", title="UniGene ID") + tSpan.append(HT.Span(gurl, style=idStyle), " "*2) + except: + pass + if thisTrait.genbankid: + thisTrait.genbankid = '|'.join(thisTrait.genbankid.split('|')[0:10]) + if thisTrait.genbankid[-1]=='|': + thisTrait.genbankid=thisTrait.genbankid[0:-1] + gurl = HT.Href(text= 'GenBank', target='_blank', \ + url= webqtlConfig.GENBANK_ID % thisTrait.genbankid,Class="fs14 fwn", title="Find the original GenBank sequence used to design the probes") + tSpan.append(HT.Span(gurl, style=idStyle), " "*2) + if thisTrait.homologeneid: + hurl = HT.Href(text= 'HomoloGene', target='_blank',\ + url=webqtlConfig.HOMOLOGENE_ID % thisTrait.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 thisTrait.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'" % thisTrait.symbol) + self.cursor.execute('SELECT kgID, chromosome,txStart,txEnd FROM GeneList_rn33 WHERE geneSymbol = "%s"' % thisTrait.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'" % thisTrait.symbol) + self.cursor.execute('SELECT chromosome,txStart,txEnd FROM GeneList WHERE geneSymbol = "%s"' % thisTrait.symbol) + try: + chr, txst, txen = self.cursor.fetchall()[0] + if chr and txst and txen and thisTrait.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',thisTrait.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" \ + # % (thisTrait.symbol,symatlas_species),Class="fs14 fwn", \ + # title="Expression across many tissues and cell types"), style=linkStyle), " "*2) + if thisTrait.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, thisTrait.geneid),Class="fs14 fwn", \ + title="Expression across many tissues and cell types"), style=linkStyle), " "*2) + tSpan.append(HT.Span(HT.Href(text= 'STRING',target="mainFrame",\ + url="http://string.embl.de/newstring_cgi/show_link_summary.pl?identifier=%s" \ + % thisTrait.symbol,Class="fs14 fwn", \ + title="Protein interactions: known and inferred"), style=linkStyle), " "*2) + if thisTrait.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, thisTrait.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" \ + # % thisTrait.symbol,Class="fs14 fwn", \ + # title="Protein interactions"), style=linkStyle), " "*2) + if thisTrait.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" \ + % thisTrait.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" \ + % thisTrait.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" \ + % thisTrait.symbol, Class="fs14 fwn", \ + title="Allen Brain Atlas"), style=linkStyle), " "*2) + + if thisTrait.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" \ + # % thisTrait.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" \ + % thisTrait.geneid, Class="fs14 fwn", \ + title="Allen Brain Atlas"), style=linkStyle), " "*2) + 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 thisTrait and thisTrait.db and thisTrait.db.type =='Publish': #Check if trait is phenotype + + if thisTrait.confidential: + 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(thisTrait.pre_publication_description, Class="fs13"), valign="top", width=740) + )) + if webqtlUtil.hasAccessToConfidentialPhenotypeTrait(privilege=self.privilege, userName=self.userName, authorized_users=thisTrait.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(thisTrait.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(thisTrait.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(thisTrait.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(thisTrait.lab_code, Class="fs13"), valign="top", width=740) + )) + 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(thisTrait.owner, Class="fs13"), valign="top", width=740) + )) + else: + 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(thisTrait.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(thisTrait.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(thisTrait.title, Class="fs13"), + valign="top", width=740) + )) + if thisTrait.journal: + journal = thisTrait.journal + if thisTrait.year: + journal = thisTrait.journal + " (%s)" % thisTrait.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 thisTrait.pubmed_id: + PubMedLink = webqtlConfig.PUBMEDLINK_URL % thisTrait.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) + )) + + 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 thisTrait and thisTrait.db and thisTrait.db.type == 'Geno': #Check if trait is genotype + + GenoInfo = HT.Paragraph() + if thisTrait.chr and thisTrait.mb: + location = ' Chr %s @ %s Mb' % (thisTrait.chr,thisTrait.mb) + else: + location = "not available" + + if thisTrait.sequence and len(thisTrait.sequence) > 100: + if _Species == "rat": + UCSC_BLAT_URL = webqtlConfig.UCSC_BLAT % ('rat', 'rn3', thisTrait.sequence) + UTHSC_BLAT_URL = webqtlConfig.UTHSC_BLAT % ('rat', 'rn3', thisTrait.sequence) + elif _Species == "mouse": + UCSC_BLAT_URL = webqtlConfig.UCSC_BLAT % ('mouse', 'mm9', thisTrait.sequence) + UTHSC_BLAT_URL = webqtlConfig.UTHSC_BLAT % ('mouse', 'mm9', thisTrait.sequence) + elif _Species == "human": + UCSC_BLAT_URL = webqtlConfig.UCSC_BLAT % ('human', 'hg19', blatsequence) + UTHSC_BLAT_URL = webqtlConfig.UTHSC_BLAT % ('human', 'hg19', thisTrait.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" % thisTrait.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 (thisTrait == None or thisTrait.db.type == 'Temp'): #if temporary trait (user-submitted trait or PCA trait) + + TempInfo = HT.Paragraph() + if thisTrait != None: + if thisTrait.description: + tbl.append(HT.TR(HT.TD(HT.Strong('Description: '),' %s ' % thisTrait.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 + + + ########################################## + ## Function to display analysis tools + ########################################## + def dispBasicStatistics(self, fd, title2Body, thisTrait): + + #XZ, June 22, 2011: The definition and usage of primary_strains, other_strains, specialStrains, all_strains 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.strainlist later. + stats_row = HT.TR() + stats_cell = HT.TD() + + if fd.genotype.type == "riset": + strainlist = fd.f1list + fd.strainlist + else: + strainlist = fd.f1list + fd.parlist + fd.strainlist + + other_strains = [] #XZ: strain that is not of primary group + specialStrains = [] #XZ: This might be replaced by other_strains / ZS: It is just other strains without parent/f1 strains. + all_strains = [] + primary_strains = [] #XZ: strain of primary group, e.g., BXD, LXS + + MDP_menu = HT.Select(name='stats_mdp', Class='stats_mdp') + + for strain in thisTrait.data.keys(): + strainName = strain.replace("_2nd_", "") + if strain not in strainlist: + if (thisTrait.data[strainName].val != None): + if strain.find('F1') < 0: + specialStrains.append(strain) + if (thisTrait.data[strainName].val != None) and (strain not in (fd.f1list + fd.parlist)): + other_strains.append(strain) #XZ: at current stage, other_strains doesn't include parent strains and F1 strains of primary group + else: + if (thisTrait.data[strainName].val != None) and (strain not in (fd.f1list + fd.parlist)): + primary_strains.append(strain) #XZ: at current stage, the primary_strains is the same as fd.strainlist / ZS: I tried defining primary_strains as fd.strainlist instead, but in some cases it ended up including the parent strains (1436869_at BXD) + + if len(other_strains) > 3: + other_strains.sort(key=webqtlUtil.natsort_key) + primary_strains.sort(key=webqtlUtil.natsort_key) + primary_strains = map(lambda X:"_2nd_"+X, fd.f1list + fd.parlist) + primary_strains #XZ: note that fd.f1list and fd.parlist are added. + all_strains = primary_strains + other_strains + other_strains = map(lambda X:"_2nd_"+X, fd.f1list + fd.parlist) + other_strains #XZ: note that fd.f1list and fd.parlist are added. + MDP_menu.append(('All Cases','0')) + MDP_menu.append(('%s Only' % fd.RISet,'1')) + MDP_menu.append(('Non-%s Only' % fd.RISet,'2')) + stats_row.append("Include: ", MDP_menu, HT.BR(), HT.BR()) + else: + if (len(other_strains) > 0) and (len(primary_strains) + len(other_strains) > 3): + MDP_menu.append(('All Cases','0')) + MDP_menu.append(('%s Only' % fd.RISet,'1')) + MDP_menu.append(('Non-%s Only' % fd.RISet,'2')) + stats_row.append("Include: ", MDP_menu, " "*3) + all_strains = primary_strains + all_strains.sort(key=webqtlUtil.natsort_key) + all_strains = map(lambda X:"_2nd_"+X, fd.f1list + fd.parlist) + all_strains + primary_strains = map(lambda X:"_2nd_"+X, fd.f1list + fd.parlist) + primary_strains + else: + all_strains = strainlist + + other_strains.sort(key=webqtlUtil.natsort_key) + all_strains = all_strains + other_strains + pass + + update_button = HT.Input(type='button',value=' Update Figures ', Class="button update") #This is used to reload the page and update the Basic Statistics figures with user-edited data + stats_row.append(update_button, HT.BR(), HT.BR()) + + if (len(other_strains)) > 0 and (len(primary_strains) + len(other_strains) > 4): + #One set of vals for all, selected strain only, and non-selected only + vals1 = [] + vals2 = [] + vals3 = [] + + #Using all strains/cases for values + for i, strainNameOrig in enumerate(all_strains): + strainName = strainNameOrig.replace("_2nd_", "") + + try: + thisval = thisTrait.data[strainName].val + thisvar = thisTrait.data[strainName].var + thisValFull = [strainName,thisval,thisvar] + except: + continue + + vals1.append(thisValFull) + + #Using just the RISet strain + for i, strainNameOrig in enumerate(primary_strains): + strainName = strainNameOrig.replace("_2nd_", "") + + try: + thisval = thisTrait.data[strainName].val + thisvar = thisTrait.data[strainName].var + thisValFull = [strainName,thisval,thisvar] + except: + continue + + vals2.append(thisValFull) + + #Using all non-RISet strains only + for i, strainNameOrig in enumerate(other_strains): + strainName = strainNameOrig.replace("_2nd_", "") + + try: + thisval = thisTrait.data[strainName].val + thisvar = thisTrait.data[strainName].var + thisValFull = [strainName,thisval,thisvar] + except: + continue + + vals3.append(thisValFull) + + vals_set = [vals1,vals2,vals3] + + else: + vals = [] + + #Using all strains/cases for values + for i, strainNameOrig in enumerate(all_strains): + strainName = strainNameOrig.replace("_2nd_", "") + + try: + thisval = thisTrait.data[strainName].val + thisvar = thisTrait.data[strainName].var + thisValFull = [strainName,thisval,thisvar] + except: + continue + + vals.append(thisValFull) + + vals_set = [vals] + + stats_script = HT.Script(language="Javascript") #script needed for tabs + + 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_strains) < 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_strains) < 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 thisTrait.db: + if thisTrait.cellid: + statsTableCell = BasicStatisticsFunctions.basicStatsTable(vals=vals, trait_type=thisTrait.db.type, cellid=thisTrait.cellid) + else: + statsTableCell = BasicStatisticsFunctions.basicStatsTable(vals=vals, trait_type=thisTrait.db.type) + else: + statsTableCell = 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 = thisTrait.symbol + plotTitle += ": " + plotTitle += thisTrait.name + except: + plotTitle = str(thisTrait.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 dispCorrelationTools(self, fd, title3Body, thisTrait): + + _Species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, RISet=fd.RISet) + + RISetgp = fd.RISet + 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') + + nmenu = 0 + self.cursor.execute('SELECT PublishFreeze.FullName,PublishFreeze.Name FROM \ + PublishFreeze,InbredSet WHERE PublishFreeze.InbredSetId = InbredSet.Id \ + and InbredSet.Name = "%s" and PublishFreeze.public > %d' % \ + (RISetgp,webqtlConfig.PUBLICTHRESH)) + for item in self.cursor.fetchall(): + databaseMenu1.append(item) + databaseMenu2.append(item) + databaseMenu3.append(item) + nmenu += 1 + self.cursor.execute('SELECT GenoFreeze.FullName,GenoFreeze.Name FROM GenoFreeze,\ + InbredSet WHERE GenoFreeze.InbredSetId = InbredSet.Id and InbredSet.Name = \ + "%s" and GenoFreeze.public > %d' % (RISetgp,webqtlConfig.PUBLICTHRESH)) + for item in self.cursor.fetchall(): + databaseMenu1.append(item) + databaseMenu2.append(item) + databaseMenu3.append(item) + nmenu += 1 + #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(): + TId, TName = item + databaseMenuSub = HT.Optgroup(label = '%s ------' % TName) + self.cursor.execute('SELECT ProbeSetFreeze.FullName,ProbeSetFreeze.Name FROM ProbeSetFreeze, ProbeFreeze, \ + InbredSet WHERE ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id and ProbeFreeze.TissueId = %d and \ + ProbeSetFreeze.public > %d and ProbeFreeze.InbredSetId = InbredSet.Id and InbredSet.Name like "%s%%" \ + order by ProbeSetFreeze.CreateTime desc, ProbeSetFreeze.AvgId ' % (TId,webqtlConfig.PUBLICTHRESH, RISetgp)) + for item2 in self.cursor.fetchall(): + databaseMenuSub.append(item2) + nmenu += 1 + databaseMenu1.append(databaseMenuSub) + databaseMenu2.append(databaseMenuSub) + databaseMenu3.append(databaseMenuSub) + if nmenu: + if thisTrait and thisTrait.db != None: + databaseMenu1.selected.append(thisTrait.db.fullname) + databaseMenu2.selected.append(thisTrait.db.fullname) + databaseMenu3.selected.append(thisTrait.db.fullname) + + criteriaText = HT.Span("Return:", Class="ffl fwb fs12") + + criteriaMenu1 = HT.Select(name='criteria1', selected='500', onMouseOver="if (NS4 || IE4) activateEl('criterias', event);") + 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')) + + criteriaMenu2 = HT.Select(name='criteria2', selected='500', onMouseOver="if (NS4 || IE4) activateEl('criterias', event);") + criteriaMenu2.append(('top 100','100')) + criteriaMenu2.append(('top 200','200')) + criteriaMenu2.append(('top 500','500')) + criteriaMenu2.append(('top 1000','1000')) + criteriaMenu2.append(('top 2000','2000')) + criteriaMenu2.append(('top 5000','5000')) + criteriaMenu2.append(('top 10000','10000')) + criteriaMenu2.append(('top 15000','15000')) + criteriaMenu2.append(('top 20000','20000')) + + criteriaMenu3 = HT.Select(name='criteria3', selected='500', onMouseOver="if (NS4 || IE4) activateEl('criterias', event);") + criteriaMenu3.append(('top 100','100')) + criteriaMenu3.append(('top 200','200')) + criteriaMenu3.append(('top 500','500')) + criteriaMenu3.append(('top 1000','1000')) + criteriaMenu3.append(('top 2000','2000')) + criteriaMenu3.append(('top 5000','5000')) + criteriaMenu3.append(('top 10000','10000')) + criteriaMenu3.append(('top 15000','15000')) + criteriaMenu3.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 (thisTrait.db != None and thisTrait.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 thisTrait.db != None: + if (thisTrait.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 thisTrait.db != None: + if (thisTrait.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) + + + def dispMappingTools(self, fd, title4Body, thisTrait): + + _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(tuple(["All",-1])) + for i in range(len(fd.genotype)): + if len(fd.genotype[i]) > 1: + chrMenu.append(tuple([fd.genotype[i].name,i])) + + #Menu for Composite Interval Mapping + chrMenu2 = HT.Select(name='chromosomes2') + chrMenu2.append(tuple(["All",-1])) + for i in range(len(fd.genotype)): + if len(fd.genotype[i]) > 1: + chrMenu2.append(tuple([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 mappingMethodId != None: + 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 natural_sort(strain_list): + + sorted = [] + for strain in strain_list: + try: + strain = int(strain) + try: sorted[-1] = sorted[-1] * 10 + strain + except: sorted.append(strain) + except: + sorted.append(strain) + return sorted + + ########################################## + ## Function to display trait tables + ########################################## + def dispTraitValues(self, fd , title5Body, varianceDataPage, nCols, mainForm, thisTrait): + traitTableOptions = HT.Div(style="border: 3px solid #EEEEEE; -moz-border-radius: 10px; -webkit-border-radius: 10px; width: 625px; padding: 5px 5px 10px 8px; font-size: 12px; background: #DDDDDD;") + resetButton = HT.Input(type='button',name='resetButton',value=' Reset ',Class="button") + blockSamplesField = HT.Input(type="text",style="background-color:white;border: 1px solid black;font-size: 14px;", name="removeField") + blockSamplesButton = HT.Input(type='button',value=' Block ', name='blockSamples', Class="button") + showHideNoValue = HT.Input(type='button', name='showHideNoValue', value=' Hide No Value ',Class='button') + blockMenuSpan = HT.Span(Id="blockMenuSpan") + blockMenu = HT.Select(name='block_method') + + if fd.genotype.type == "riset": + allstrainlist_neworder = fd.f1list + fd.strainlist + else: + allstrainlist_neworder = fd.f1list + fd.parlist + fd.strainlist + + attribute_ids = [] + attribute_names = [] + try: + #ZS: Id values for this trait's extra attributes; used to create "Exclude" dropdown and query for attribute values and create + self.cursor.execute("""SELECT CaseAttribute.Id, CaseAttribute.Name + FROM CaseAttribute, CaseAttributeXRef + WHERE CaseAttributeXRef.ProbeSetFreezeId = '%s' AND + CaseAttribute.Id = CaseAttributeXRef.CaseAttributeId + group by CaseAttributeXRef.CaseAttributeId""" % (str(thisTrait.db.id))) + + exclude_menu = HT.Select(name="exclude_menu") + dropdown_menus = [] #ZS: list of dropdown menus with the distinct values of each attribute (contained in DIVs so the style parameter can be edited and they can be hidden) + + for attribute in self.cursor.fetchall(): + attribute_ids.append(attribute[0]) + attribute_names.append(attribute[1]) + for this_attr_name in attribute_names: + exclude_menu.append((this_attr_name.capitalize(), this_attr_name)) + self.cursor.execute("""SELECT DISTINCT CaseAttributeXRef.Value + FROM CaseAttribute, CaseAttributeXRef + WHERE CaseAttribute.Name = '%s' AND + CaseAttributeXRef.CaseAttributeId = CaseAttribute.Id""" % (this_attr_name)) + try: + distinct_values = self.cursor.fetchall() + attr_value_menu_div = HT.Div(style="display:none;", Class="attribute_values") #container used to show/hide dropdown menus + attr_value_menu = HT.Select(name=this_attr_name) + attr_value_menu.append(("None", "show_all")) + for value in distinct_values: + attr_value_menu.append((str(value[0]), value[0])) + attr_value_menu_div.append(attr_value_menu) + dropdown_menus.append(attr_value_menu_div) + except: + pass + except: + pass + + other_strains = [] + for strain in thisTrait.data.keys(): + if strain not in allstrainlist_neworder: + other_strains.append(strain) + + if other_strains: + blockMenu.append(('%s Only' % fd.RISet,'1')) + blockMenu.append(('Non-%s Only' % fd.RISet,'0')) + blockMenuSpan.append(blockMenu) + else: + pass + + showHideOutliers = HT.Input(type='button', name='showHideOutliers', value=' Hide Outliers ', Class='button') + showHideMenuOptions = HT.Span(Id="showHideOptions", style="line-height:225%;") + if other_strains: + showHideMenuOptions.append(HT.Bold("  Block samples by index:    "), blockSamplesField, "   ", blockMenuSpan, "   ", blockSamplesButton, HT.BR()) + else: + showHideMenuOptions.append(HT.Bold("  Block samples by index:    "), blockSamplesField, "   ", blockSamplesButton, HT.BR()) + + exportButton = HT.Input(type='button', name='export', value=' Export ', Class='button') + if len(attribute_names) > 0: + excludeButton = HT.Input(type='button', name='excludeGroup', value=' Block ', Class='button') + showHideMenuOptions.append(HT.Bold("  Block samples by group:"), " "*5, exclude_menu, " "*5) + for menu in dropdown_menus: + showHideMenuOptions.append(menu) + showHideMenuOptions.append(" "*5, excludeButton, HT.BR()) + showHideMenuOptions.append(HT.Bold("  Options:"), " "*5, showHideNoValue, " "*5, showHideOutliers, " "*5, resetButton, " "*5, exportButton) + + traitTableOptions.append(showHideMenuOptions,HT.BR(),HT.BR()) + traitTableOptions.append(HT.Span("  Outliers highlighted in ", HT.Bold(" yellow ", style="background-color:yellow;"), " can be hidden using the ", + HT.Strong(" Hide Outliers "), " button,",HT.BR(),"  and samples with no value (x) can be hidden by clicking ", + HT.Strong(" Hide No Value "), "."), HT.BR()) + + + dispintro = HT.Paragraph("Edit or delete values in the Trait Data boxes, and use the ", HT.Strong("Reset"), " option as needed.",Class="fs12", style="margin-left:20px;") + + table = HT.TableLite(cellspacing=0, cellpadding=0, width="100%", Class="target5") #Everything needs to be inside this table object in order for the toggle to work + container = HT.Div() #This will contain everything and be put into a cell of the table defined above + + container.append(dispintro, traitTableOptions, HT.BR()) + + primary_table = HT.TableLite(cellspacing=0, cellpadding=0, Id="sortable1", Class="tablesorter") + primary_header = self.getTableHeader(fd=fd, thisTrait=thisTrait, nCols=nCols, attribute_names=attribute_names) #Generate header for primary table object + + other_strainsExist = False + for strain in thisTrait.data.keys(): + if strain not in allstrainlist_neworder: + other_strainsExist = True + break + + primary_body = self.addTrait2Table(fd=fd, varianceDataPage=varianceDataPage, strainlist=allstrainlist_neworder, mainForm=mainForm, thisTrait=thisTrait, other_strainsExist=other_strainsExist, attribute_ids=attribute_ids, attribute_names=attribute_names, strains='primary') + + primary_table.append(primary_header) + for i in range(len(primary_body)): + primary_table.append(primary_body[i]) + + other_strains = [] + for strain in thisTrait.data.keys(): + if strain not in allstrainlist_neworder: + allstrainlist_neworder.append(strain) + other_strains.append(strain) + + if other_strains: + other_table = HT.TableLite(cellspacing=0, cellpadding=0, Id="sortable2", Class="tablesorter") #Table object with other (for example, non-BXD / MDP) traits + other_header = self.getTableHeader(fd=fd, thisTrait=thisTrait, nCols=nCols, attribute_names=attribute_names) #Generate header for other table object; same function is used as the one used for the primary table, since the header is the same + other_strains.sort() #Sort other strains + other_strains = map(lambda X:"_2nd_"+X, fd.f1list + fd.parlist) + other_strains #Append F1 and parent strains to the beginning of the sorted list of other strains + + MDPText = HT.Span("Samples:", Class="ffl fwb fs12") + MDPMenu1 = HT.Select(name='MDPChoice1') + MDPMenu2 = HT.Select(name='MDPChoice2') + MDPMenu3 = HT.Select(name='MDPChoice3') + MDPMenu1.append(('%s Only' % fd.RISet,'1')) + MDPMenu2.append(('%s Only' % fd.RISet,'1')) + MDPMenu3.append(('%s Only' % fd.RISet,'1')) + MDPMenu1.append(('Non-%s Only' % fd.RISet,'2')) + MDPMenu2.append(('Non-%s Only' % fd.RISet,'2')) + MDPMenu3.append(('Non-%s Only' % fd.RISet,'2')) + MDPMenu1.append(('All Cases','0')) + MDPMenu2.append(('All Cases','0')) + MDPMenu3.append(('All Cases','0')) + self.MDPRow1.append(HT.TD(MDPText),HT.TD(MDPMenu1)) + self.MDPRow2.append(HT.TD(MDPText),HT.TD(MDPMenu2)) + self.MDPRow3.append(HT.TD(MDPText),HT.TD(MDPMenu3)) + + other_body = self.addTrait2Table(fd=fd, varianceDataPage=varianceDataPage, strainlist=other_strains, mainForm=mainForm, thisTrait=thisTrait, attribute_ids=attribute_ids, attribute_names=attribute_names, strains='other') + + other_table.append(other_header) + for i in range(len(other_body)): + other_table.append(other_body[i]) + else: + pass + + if other_strains or (fd.f1list and thisTrait.data.has_key(fd.f1list[0])) \ + or (fd.f1list and thisTrait.data.has_key(fd.f1list[1])): + fd.allstrainlist = allstrainlist_neworder + + if nCols == 6 and fd.varianceDispName != 'Variance': + mainForm.append(HT.Input(name='isSE', value="yes", type='hidden')) + + primary_div = HT.Div(primary_table, Id="primary") #Container for table with primary (for example, BXD) strain values + container.append(primary_div) + + if other_strains: + other_div = HT.Div(other_table, Id="other") #Container for table with other (for example, Non-BXD/MDP) strain values + container.append(HT.Div(' ', height=30)) + container.append(other_div) + + table.append(HT.TR(HT.TD(container))) + title5Body.append(table) + + def addTrait2Table(self, fd, varianceDataPage, strainlist, mainForm, thisTrait, other_strainsExist=None, attribute_ids=[], attribute_names=[], strains='primary'): + #XZ, Aug 23, 2010: I commented the code related to the display of animal case + #strainInfo = thisTrait.has_key('strainInfo') and thisTrait.strainInfo + + table_body = [] + vals = [] + + for i, strainNameOrig in enumerate(strainlist): + strainName = strainNameOrig.replace("_2nd_", "") + + try: + thisval = thisTrait.data[strainName].val + thisvar = thisTrait.data[strainName].var + thisValFull = [strainName,thisval,thisvar] + except: + continue + + vals.append(thisValFull) + + upperBound, lowerBound = Plot.findOutliers(vals) # ZS: Values greater than upperBound or less than lowerBound are considered outliers. + + for i, strainNameOrig in enumerate(strainlist): + + trId = strainNameOrig + selectCheck = HT.Input(type="checkbox", name="selectCheck", value=trId, Class="checkbox", onClick="highlight(this)") + + strainName = strainNameOrig.replace("_2nd_", "") + strainNameAdd = '' + if fd.RISet == 'AXBXA' and strainName in ('AXB18/19/20','AXB13/14','BXA8/17'): + strainNameAdd = HT.Href(url='/mouseCross.html#AXB/BXA', text=HT.Sup('#'), Class='fs12', target="_blank") + + try: + thisval, thisvar, thisNP = thisTrait.data[strainName].val, thisTrait.data[strainName].var, thisTrait.data[strainName].N + if thisNP: + mainForm.append(HT.Input(name='N'+strainName, value=thisNP, type='hidden')) + else: + pass + except: + thisval = thisvar = 'x' + + try: + traitVal = thisval + dispVal = "%2.3f" % thisval + except: + traitVal = '' + dispVal = 'x' + + strainNameDisp = HT.Span(strainName, Class='fs14 fwn ffl') + + if varianceDataPage: + try: + traitVar = thisvar + dispVar = "%2.3f" % thisvar + except: + traitVar = '' + dispVar = 'x' + + if thisval == 'x': + traitVar = '' #ZS: Used to be 0, but it doesn't seem like a good idea for values of 0 to *always* be at the bottom when you sort; it makes more sense to put "nothing" + + className = 'fs13 b1 c222 ' + valueClassName = 'fs13 b1 c222 valueField ' + rowClassName = 'novalue ' + else: + if (thisval >= upperBound) or (thisval <= lowerBound): + className = 'fs13 b1 c222 outlier ' + valueClassName = 'fs13 b1 c222 valueField ' + rowClassName = 'outlier' + else: + className = 'fs13 b1 c222 ' + valueClassName = 'fs13 b1 c222 valueField ' + rowClassName = ' ' + + if varianceDataPage: + varClassName = valueClassName + str(traitVar) + valueClassName += str(traitVal) + + if strainNameOrig == strainName: + if other_strainsExist and strainNameOrig in (fd.parlist + fd.f1list): + ######################################################################################################################################################## + # ZS: Append value and variance to the value and variance input fields' list of classes; this is so the javascript can update the value when the user + # changes it. The updated value is then used when the table is sorted (tablesorter.js). This needs to be done because the "value" attribute is immutable. + ######################################################################################################################################################### + + valueField = HT.Input(name=strainNameOrig, size=8, maxlength=8, style="text-align:right; background-color:#FFFFFF;", value=dispVal, + onChange= "javascript:this.form['_2nd_%s'].value=this.form['%s'].value;" % (strainNameOrig.replace("/", ""), strainNameOrig.replace("/", "")), Class=valueClassName) + if varianceDataPage: + seField = HT.Input(name='V'+strainNameOrig, size=8, maxlength=8, style="text-align:right", value=dispVar, + onChange= "javascript:this.form['V_2nd_%s'].value=this.form['V%s'].value;" % (strainNameOrig.replace("/", ""), strainNameOrig.replace("/", "")), Class=varClassName) + else: + valueField = HT.Input(name=strainNameOrig, size=8, maxlength=8, style="text-align:right; background-color:#FFFFFF;", value=dispVal, Class=valueClassName) + if varianceDataPage: + seField = HT.Input(name='V'+strainNameOrig, size=8, maxlength=8, style="text-align:right", value=dispVar, Class=varClassName) + else: + valueField = HT.Input(name=strainNameOrig, size=8, maxlength=8, style="text-align:right", value=dispVal, + onChange= "javascript:this.form['%s'].value=this.form['%s'].value;" % (strainNameOrig.replace("/", ""), strainNameOrig.replace("/", "")), Class=valueClassName) + if varianceDataPage: + seField = HT.Input(name='V'+strainNameOrig, size=8, maxlength=8, style="text-align:right", value=dispVar, + onChange= "javascript:this.form['V%s'].value=this.form['V%s'].value;" % (strainNameOrig.replace("/", ""), strainNameOrig.replace("/", "")), Class=varClassName) + + if (strains == 'primary'): + table_row = HT.TR(Id="Primary_"+str(i+1), Class=rowClassName) + else: + table_row = HT.TR(Id="Other_"+str(i+1), Class=rowClassName) + + if varianceDataPage: + table_row.append(HT.TD(str(i+1), selectCheck, width=45, align='right', Class=className)) + table_row.append(HT.TD(strainNameDisp, strainNameAdd, align='right', width=100, Class=className)) + table_row.append(HT.TD(valueField, width=70, align='right', Id="value_"+str(i)+"_"+strains, Class=className)) + table_row.append(HT.TD("±", width=20, align='center', Class=className)) + table_row.append(HT.TD(seField, width=80, align='right', Id="SE_"+str(i)+"_"+strains, Class=className)) + else: + table_row.append(HT.TD(str(i+1), selectCheck, width=45, align='right', Class=className)) + table_row.append(HT.TD(strainNameDisp, strainNameAdd, align='right', width=100, Class=className)) + table_row.append(HT.TD(valueField, width=70, align='right', Id="value_"+str(i)+"_"+strains, Class=className)) + + if thisTrait and thisTrait.db and thisTrait.db.type =='ProbeSet': + if len(attribute_ids) > 0: + + #ZS: Get StrainId value for the next query + self.cursor.execute("""SELECT Strain.Id + FROM Strain, StrainXRef, InbredSet + WHERE Strain.Name = '%s' and + StrainXRef.StrainId = Strain.Id and + InbredSet.Id = StrainXRef.InbredSetId and + InbredSet.Name = '%s'""" % (strainName, fd.RISet)) + + strain_id = self.cursor.fetchone()[0] + + attr_counter = 1 # This is needed so the javascript can know which attribute type to associate this value with for the exported excel sheet (each attribute type being a column). + for attribute_id in attribute_ids: + + #ZS: Add extra case attribute values (if any) + self.cursor.execute("""SELECT Value + FROM CaseAttributeXRef + WHERE ProbeSetFreezeId = '%s' AND + StrainId = '%s' AND + CaseAttributeId = '%s' + group by CaseAttributeXRef.CaseAttributeId""" % (thisTrait.db.id, strain_id, str(attribute_id))) + + attributeValue = self.cursor.fetchone()[0] #Trait-specific attributes, if any + + #ZS: If it's an int, turn it into one for sorting (for example, 101 would be lower than 80 if they're strings instead of ints) + try: + attributeValue = int(attributeValue) + except: + pass + + span_Id = strains+"_attribute"+str(attr_counter)+"_sample"+str(i+1) + attr_container = HT.Span(attributeValue, Id=span_Id) + attr_className = str(attributeValue) + " " + className + table_row.append(HT.TD(attr_container, align='right', Class=attr_className)) + attr_counter += 1 + + table_body.append(table_row) + return table_body + + def getTableHeader(self, fd, thisTrait, nCols, attribute_names): + + table_header = HT.TR() + + col_class = "fs13 fwb ff1 b1 cw cbrb" + + if nCols == 6: + try: + if fd.varianceDispName: + pass + except: + fd.varianceDispName = 'Variance' + + table_header.append(HT.TH('Index', align='right', width=60, Class=col_class), + HT.TH('Sample', align='right', width=100, Class=col_class), + HT.TH('Value', align='right', width=70, Class=col_class), + HT.TH(' ', width=20, Class=col_class), + HT.TH(fd.varianceDispName, align='right', width=80, Class=col_class)) + + elif nCols == 4: + table_header.append(HT.TH('Index', align='right', width=60, Class=col_class), + HT.TH('Sample', align='right', width=100, Class=col_class), + HT.TH('Value', align='right', width=70, Class=col_class)) + + else: + pass + + if len(attribute_names) > 0: + i=0 + for attribute in attribute_names: + char_count = len(attribute) + cell_width = char_count * 14 + table_header.append(HT.TH(attribute, align='right', width=cell_width, Class="attribute_name " + col_class)) + i+=1 + + return table_header + + + def getSortByValue(self): + + sortby = ("", "") + + return sortby diff --git a/wqflask/wqflask/show_trait/show_trait_page.py b/wqflask/wqflask/show_trait/show_trait_page.py index a63071c3..57c68a1c 100644 --- a/wqflask/wqflask/show_trait/show_trait_page.py +++ b/wqflask/wqflask/show_trait/show_trait_page.py @@ -40,148 +40,148 @@ from DataEditingPage import DataEditingPage class ShowTraitPage(DataEditingPage): - def __init__(self, fd, traitInfos = None): - - #templatePage.__init__(self, fd) - - if not self.openMysql(): - return - - #TD_LR = HT.TD(height=200,width="100%",bgColor='#eeeeee') - print("j2") - # When is traitInfos used? - if traitInfos: - print("j2.2") - database, ProbeSetID, CellID = traitInfos - else: - print("j2.3") - print("fd is:", fd) - database = fd['database'][0] - ProbeSetID = fd['ProbeSetID'][0] - print("j2.4") - CellID = fd.get('CellID') - print("j2.6") - - # We're no longer wrapping this in an exception. If we fail, let's fail hard - # Log it and fix it - #try: - print("j3") - thisTrait = webqtlTrait(db=database, name=ProbeSetID, cellid= CellID, cursor=self.cursor) - #except: - # heading = "Trait Data and Analysis Form" - # detail = ["The trait isn't available currently."] - # self.error(heading=heading,detail=detail,error="Error") - # return - print("j4") - if thisTrait.db.type == "ProbeSet": - - self.cursor.execute('''SELECT Id, Name, FullName, confidentiality, AuthorisedUsers - FROM ProbeSetFreeze WHERE Name = "%s"''' % database) - - indId, indName, indFullName, confidential, AuthorisedUsers = self.cursor.fetchall()[0] - - if confidential == 1: - access_to_confidential_dataset = 0 - - #for the dataset that confidentiality is 1 - #1. 'admin' and 'root' can see all of the dataset - #2. 'user' can see the dataset that AuthorisedUsers contains his id(stored in the Id field of User table) - if webqtlConfig.USERDICT[self.privilege] > webqtlConfig.USERDICT['user']: - access_to_confidential_dataset = 1 - else: - AuthorisedUsersList=AuthorisedUsers.split(',') - if AuthorisedUsersList.__contains__(self.userName): - access_to_confidential_dataset = 1 - - if not access_to_confidential_dataset: - #Error, Confidential Database - heading = "Show Database" - detail = ["The %s database you selected is not open to the public \ - at this time, please go back and select other database." % indFullName] - self.error(heading=heading,detail=detail,error="Confidential Database") - return - print("environ:", request.environ) - - # Becuase of proxying remote_addr is probably localhost, so we first try for - # HTTP_X_FORWARDED_FOR - user_ip = request.environ.get('HTTP_X_FORWARDED_FOR') or request.remote_addr # in old app was fd.remote_ip - print("user_ip is:", user_ip) - query = "SELECT count(id) FROM AccessLog WHERE ip_address = %s and \ - UNIX_TIMESTAMP()-UNIX_TIMESTAMP(accesstime)<86400" - self.cursor.execute(query,user_ip) - daycount = self.cursor.fetchall() - if daycount: - daycount = daycount[0][0] - if daycount > webqtlConfig.DAILYMAXIMUM: - heading = "Retrieve Data" - detail = ['For security reasons, the maximum access to a database is \ - %d times per day per ip address. You have reached the limit, please \ - try it again tomorrow.' % webqtlConfig.DAILYMAXIMUM] - self.error(heading=heading,detail=detail) - return - else: - pass - else: - pass - - if thisTrait.db.type != 'ProbeSet' and thisTrait.cellid: - heading = "Retrieve Data" - detail = ['The Record you requested doesn\'t exist!'] - self.error(heading=heading,detail=detail) - return - - #XZ: Aug 23, 2010: I commented out this block because this feature is not used anymore - # check if animal information are available - """ - self.cursor.execute(''' - SELECT - SampleXRef.ProbeFreezeId - FROM - SampleXRef, ProbeSetFreeze - WHERE - SampleXRef.ProbeFreezeId = ProbeSetFreeze.ProbeFreezeId AND - ProbeSetFreeze.Name = "%s" - ''' % thisTrait.db.name) - - sampleId = self.cursor.fetchall() - if sampleId: - thisTrait.strainInfo = 1 - else: - thisTrait.strainInfo = None - """ - - ##identification, etc. - fd.identification = '%s : %s' % (thisTrait.db.shortname,ProbeSetID) - thisTrait.returnURL = webqtlConfig.CGIDIR + webqtlConfig.SCRIPTFILE + '?FormID=showDatabase&database=%s\ - &ProbeSetID=%s&RISet=%s&parentsf1=on' %(database, ProbeSetID, fd['RISet']) - - if CellID: - fd.identification = '%s/%s'%(fd.identification, CellID) - thisTrait.returnURL = '%s&CellID=%s' % (thisTrait.returnURL, CellID) - - #retrieve trait information - try: - thisTrait.retrieveInfo() - thisTrait.retrieveData() - self.updMysql() - self.cursor.execute("insert into AccessLog(accesstime,ip_address) values(Now(),%s)", user_ip) - self.openMysql() - except Exception as why: - print("Got an exception:", why) - heading = "Retrieve Data" - detail = ["The information you requested is not avaiable at this time."] - self.error(heading=heading, detail=detail) - return - - ##read genotype file - fd.RISet = thisTrait.riset - fd.readGenotype() - - if webqtlUtil.ListNotNull(map(lambda x:x.var, thisTrait.data.values())): - fd.displayVariance = 1 - fd.varianceDispName = 'SE' - fd.formID = 'varianceChoice' - - #self.dict['body']= thisTrait - DataEditingPage.__init__(self, fd, thisTrait) - #self.dict['title'] = '%s: Display Trait' % fd.identification + def __init__(self, fd, traitInfos = None): + + #templatePage.__init__(self, fd) + + if not self.openMysql(): + return + + #TD_LR = HT.TD(height=200,width="100%",bgColor='#eeeeee') + print("j2") + # When is traitInfos used? + if traitInfos: + print("j2.2") + database, ProbeSetID, CellID = traitInfos + else: + print("j2.3") + print("fd is:", fd) + database = fd['database'][0] + ProbeSetID = fd['ProbeSetID'][0] + print("j2.4") + CellID = fd.get('CellID') + print("j2.6") + + # We're no longer wrapping this in an exception. If we fail, let's fail hard + # Log it and fix it + #try: + print("j3") + thisTrait = webqtlTrait(db=database, name=ProbeSetID, cellid= CellID, cursor=self.cursor) + #except: + # heading = "Trait Data and Analysis Form" + # detail = ["The trait isn't available currently."] + # self.error(heading=heading,detail=detail,error="Error") + # return + print("j4") + if thisTrait.db.type == "ProbeSet": + + self.cursor.execute('''SELECT Id, Name, FullName, confidentiality, AuthorisedUsers + FROM ProbeSetFreeze WHERE Name = "%s"''' % database) + + indId, indName, indFullName, confidential, AuthorisedUsers = self.cursor.fetchall()[0] + + if confidential == 1: + access_to_confidential_dataset = 0 + + #for the dataset that confidentiality is 1 + #1. 'admin' and 'root' can see all of the dataset + #2. 'user' can see the dataset that AuthorisedUsers contains his id(stored in the Id field of User table) + if webqtlConfig.USERDICT[self.privilege] > webqtlConfig.USERDICT['user']: + access_to_confidential_dataset = 1 + else: + AuthorisedUsersList=AuthorisedUsers.split(',') + if AuthorisedUsersList.__contains__(self.userName): + access_to_confidential_dataset = 1 + + if not access_to_confidential_dataset: + #Error, Confidential Database + heading = "Show Database" + detail = ["The %s database you selected is not open to the public \ + at this time, please go back and select other database." % indFullName] + self.error(heading=heading,detail=detail,error="Confidential Database") + return + print("environ:", request.environ) + + # Becuase of proxying remote_addr is probably localhost, so we first try for + # HTTP_X_FORWARDED_FOR + user_ip = request.environ.get('HTTP_X_FORWARDED_FOR') or request.remote_addr # in old app was fd.remote_ip + print("user_ip is:", user_ip) + query = "SELECT count(id) FROM AccessLog WHERE ip_address = %s and \ + UNIX_TIMESTAMP()-UNIX_TIMESTAMP(accesstime)<86400" + self.cursor.execute(query,user_ip) + daycount = self.cursor.fetchall() + if daycount: + daycount = daycount[0][0] + if daycount > webqtlConfig.DAILYMAXIMUM: + heading = "Retrieve Data" + detail = ['For security reasons, the maximum access to a database is \ + %d times per day per ip address. You have reached the limit, please \ + try it again tomorrow.' % webqtlConfig.DAILYMAXIMUM] + self.error(heading=heading,detail=detail) + return + else: + pass + else: + pass + + if thisTrait.db.type != 'ProbeSet' and thisTrait.cellid: + heading = "Retrieve Data" + detail = ['The Record you requested doesn\'t exist!'] + self.error(heading=heading,detail=detail) + return + + #XZ: Aug 23, 2010: I commented out this block because this feature is not used anymore + # check if animal information are available + """ + self.cursor.execute(''' + SELECT + SampleXRef.ProbeFreezeId + FROM + SampleXRef, ProbeSetFreeze + WHERE + SampleXRef.ProbeFreezeId = ProbeSetFreeze.ProbeFreezeId AND + ProbeSetFreeze.Name = "%s" + ''' % thisTrait.db.name) + + sampleId = self.cursor.fetchall() + if sampleId: + thisTrait.strainInfo = 1 + else: + thisTrait.strainInfo = None + """ + + ##identification, etc. + fd.identification = '%s : %s' % (thisTrait.db.shortname,ProbeSetID) + thisTrait.returnURL = webqtlConfig.CGIDIR + webqtlConfig.SCRIPTFILE + '?FormID=showDatabase&database=%s\ + &ProbeSetID=%s&RISet=%s&parentsf1=on' %(database, ProbeSetID, fd['RISet']) + + if CellID: + fd.identification = '%s/%s'%(fd.identification, CellID) + thisTrait.returnURL = '%s&CellID=%s' % (thisTrait.returnURL, CellID) + + #retrieve trait information + try: + thisTrait.retrieveInfo() + thisTrait.retrieveData() + self.updMysql() + self.cursor.execute("insert into AccessLog(accesstime,ip_address) values(Now(),%s)", user_ip) + self.openMysql() + except Exception as why: + print("Got an exception:", why) + heading = "Retrieve Data" + detail = ["The information you requested is not avaiable at this time."] + self.error(heading=heading, detail=detail) + return + + ##read genotype file + fd.RISet = thisTrait.riset + fd.readGenotype() + + if webqtlUtil.ListNotNull(map(lambda x:x.var, thisTrait.data.values())): + fd.displayVariance = 1 + fd.varianceDispName = 'SE' + fd.formID = 'varianceChoice' + + #self.dict['body']= thisTrait + DataEditingPage.__init__(self, fd, thisTrait) + #self.dict['title'] = '%s: Display Trait' % fd.identification -- cgit v1.2.3 From a6386179f0f94df749d7af232060ff10a68c42f6 Mon Sep 17 00:00:00 2001 From: Sam Ockman Date: Wed, 6 Jun 2012 04:49:20 -0400 Subject: Most of the top fields working --- wqflask/base/webqtlTrait.py | 66 ++++++++++++++++ wqflask/wqflask/show_trait/DataEditingPage.py | 87 +++++++--------------- wqflask/wqflask/show_trait/show_trait_page.py | 1 + .../wqflask/templates/trait_data_and_analysis.html | 17 +++-- 4 files changed, 105 insertions(+), 66 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/webqtlTrait.py b/wqflask/base/webqtlTrait.py index 812d112a..23b98238 100755 --- a/wqflask/base/webqtlTrait.py +++ b/wqflask/base/webqtlTrait.py @@ -590,3 +590,69 @@ class webqtlTrait: setDescription.append( ' --- FROM : ') setDescription.append(self.db.genHTML(Class='cori')) return setDescription + + @property + def description_fmt(self): + '''Return a text formated description''' + if self.description: + formatted = self.description + if self.probe_target_description: + formatted += "; " + self.probe_target_description + else: + formatted = "Not available" + return formatted + + @property + def alias_fmt(self): + '''Return a text formatted alias''' + if self.alias: + alias = string.replace(self.alias, ";", " ") + alias = string.join(string.split(alias), ", ") + return alias + + + @property + def location_fmt(self): + '''Return a text formatted location + + While we're at it we set self.location in case we need it later (do we?) + + ''' + + if self.chr and self.mb: + self.location = 'Chr %s @ %s Mb' % (self.chr,self.mb) + elif self.chr: + self.location = 'Chr %s @ Unknown position' % (self.chr) + else: + self.location = 'Not available' + + fmt = self.location + ##XZ: deal with direction + if self.strand_probe == '+': + fmt += (' on the plus strand ') + elif self.strand_probe == '-': + fmt += (' on the minus strand ') + + return fmt + + + def get_database(self): + """ + Returns the database, and the url referring to the database if it exists + + We're going to to return two values here, and we don't want to have to call this twice from + the template. So it's not a property called from the template, but instead is called from the view + + """ + if self.cellid: + self.cursor.execute(""" + select ProbeFreeze.Name from ProbeFreeze, ProbeSetFreeze + where + ProbeFreeze.Id = ProbeSetFreeze.ProbeFreezeId AND + ProbeSetFreeze.Id = %d""" % thisTrait.db.id) + probeDBName = self.cursor.fetchone()[0] + return dict(name = probeDBName, + url = None) + else: + return dict(name = self.db.fullname, + url = webqtlConfig.INFOPAGEHREF % self.db.name) diff --git a/wqflask/wqflask/show_trait/DataEditingPage.py b/wqflask/wqflask/show_trait/DataEditingPage.py index 1aef0349..fda26322 100755 --- a/wqflask/wqflask/show_trait/DataEditingPage.py +++ b/wqflask/wqflask/show_trait/DataEditingPage.py @@ -345,44 +345,7 @@ class DataEditingPage(templatePage): HT.TD(HT.Span('Not available', Class="fs13 fsI"), valign="top") )) - #XZ: Gene Alias - if thisTrait.alias: - alias = string.replace(thisTrait.alias, ";", " ") - alias = string.join(string.split(alias), ", ") - thisTrait.alias_fmt = alias - - - #XZ: Description - if thisTrait.description: - thisTrait.description_fmt = thisTrait.description - if thisTrait.probe_target_description: - thisTrait.description_fmt += "; " + this.trait.probe_target_description - else: - thisTrait.description_fmt = "Not available" - - #XZ: Location - - #XZ: deal with Chr and Mb - if thisTrait.chr and thisTrait.mb: - thisTrait.location = 'Chr %s @ %s Mb' % (thisTrait.chr,thisTrait.mb) - elif thisTrait.chr: - thisTrait.location = 'Chr %s @ Unknown position' % (thisTrait.chr) - else: - thisTrait.location = 'Not available' - ##XZ: deal with direction - #if thisTrait.strand_probe == '+': - # tSpan.append(' on the plus strand ') - #elif thisTrait.strand_probe == '-': - # tSpan.append(' on the minus strand ') - #else: - # pass - # - #tbl.append(HT.TR( - # HT.TD('Location: ', Class="fwb fs13", valign="top", nowrap="on"), - # HT.TD(width=10, valign="top"), - # HT.TD(tSpan, valign="top") - # )) ##display Verify Location button try: @@ -474,18 +437,18 @@ class DataEditingPage(templatePage): #probeButton.append(probeButton_img) probeText = "Probes" - tSpan = HT.Span(Class="fs13") + #tSpan = HT.Span(Class="fs13") #XZ: deal with blat score and blat specificity. - if thisTrait.probe_set_specificity or thisTrait.probe_set_blat_score: - if thisTrait.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(thisTrait.probe_set_specificity), " "*3) - if thisTrait.probe_set_blat_score: - pass - #tSpan.append("Score: %s" % int(thisTrait.probe_set_blat_score), " "*2) + #if thisTrait.probe_set_specificity or thisTrait.probe_set_blat_score: + # if thisTrait.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(thisTrait.probe_set_specificity), " "*3) + # if thisTrait.probe_set_blat_score: + # pass + # #tSpan.append("Score: %s" % int(thisTrait.probe_set_blat_score), " "*2) - onClick="openNewWin('/blatInfo.html')" + #onClick="openNewWin('/blatInfo.html')" #tbl.append(HT.TR( # HT.TD('Target Score: ', Class="fwb fs13", valign="top", nowrap="on"), @@ -502,26 +465,28 @@ class DataEditingPage(templatePage): # HT.TD(tSpan, valign="top") # )) - if thisTrait.cellid: - self.cursor.execute(""" - select ProbeFreeze.Name from ProbeFreeze, ProbeSetFreeze - where - ProbeFreeze.Id = ProbeSetFreeze.ProbeFreezeId AND - ProbeSetFreeze.Id = %d""" % thisTrait.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: + #if thisTrait.cellid: + # self.cursor.execute(""" + # select ProbeFreeze.Name from ProbeFreeze, ProbeSetFreeze + # where + # ProbeFreeze.Id = ProbeSetFreeze.ProbeFreezeId AND + # ProbeSetFreeze.Id = %d""" % thisTrait.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=thisTrait.db.fullname, url = webqtlConfig.INFOPAGEHREF % thisTrait.db.name, # target='_blank', Class="fs13 fwn non_bold"), valign="top") # )) - pass + #pass + + thisTrait.database = thisTrait.get_database() #XZ: ID links if thisTrait.genbankid or thisTrait.geneid or thisTrait.unigeneid or thisTrait.omim or thisTrait.homologeneid: @@ -534,7 +499,7 @@ class DataEditingPage(templatePage): if thisTrait.omim: gurl = HT.Href(text= 'OMIM', target='_blank', \ url= webqtlConfig.OMIM_ID % thisTrait.omim,Class="fs14 fwn", title="Summary from On Mendelian Inheritance in Man") - tSpan.append(HT.Span(gurl, style=idStyle), " "*2) + #tSpan.append(HT.Span(gurl, style=idStyle), " "*2) if thisTrait.unigeneid: try: gurl = HT.Href(text= 'UniGene',target='_blank',\ diff --git a/wqflask/wqflask/show_trait/show_trait_page.py b/wqflask/wqflask/show_trait/show_trait_page.py index 57c68a1c..b1f71e55 100644 --- a/wqflask/wqflask/show_trait/show_trait_page.py +++ b/wqflask/wqflask/show_trait/show_trait_page.py @@ -43,6 +43,7 @@ class ShowTraitPage(DataEditingPage): def __init__(self, fd, traitInfos = None): #templatePage.__init__(self, fd) + self.fd = fd if not self.openMysql(): return diff --git a/wqflask/wqflask/templates/trait_data_and_analysis.html b/wqflask/wqflask/templates/trait_data_and_analysis.html index 0eb1e012..1e67834c 100644 --- a/wqflask/wqflask/templates/trait_data_and_analysis.html +++ b/wqflask/wqflask/templates/trait_data_and_analysis.html @@ -68,7 +68,7 @@ - {{ thisTrait.location }}
+ {{ thisTrait.location_fmt }}
@@ -76,8 +76,14 @@ - BLAT specificity: 12.0   Score: 240   + + + + BLAT specificity + : {{ "%.1f" % (thisTrait.probe_set_specificity) }}    + Score: {{ "%i" % (thisTrait.probe_set_blat_score) }}   + + @@ -93,8 +99,9 @@ - Hippocampus Consortium M430v2 (Jun06) - PDNN + + {{ thisTrait.database.name }} + -- cgit v1.2.3 From ee24468b3ad5575c4f7ba06aa3319bdab3a34c6c Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Thu, 23 Aug 2012 16:01:08 -0500 Subject: Various minor changes --- web/webqtl/base/webqtlConfigLocal.py | 10 +++++----- wqflask/base/webqtlConfigLocal.py | 11 ++++++----- wqflask/wqflask/dataSharing/SharingInfoPage.py | 4 +++- wqflask/wqflask/views.py | 1 + 4 files changed, 15 insertions(+), 11 deletions(-) (limited to 'wqflask/base') diff --git a/web/webqtl/base/webqtlConfigLocal.py b/web/webqtl/base/webqtlConfigLocal.py index dc86bb10..1f986aa7 100755 --- a/web/webqtl/base/webqtlConfigLocal.py +++ b/web/webqtl/base/webqtlConfigLocal.py @@ -3,15 +3,15 @@ ######################################### MYSQL_SERVER = 'localhost' -DB_NAME = 'db_webqtl' -DB_USER = 'webqtl' +DB_NAME = 'db_webqtl_zas1024' +DB_USER = 'webqtlupd' DB_PASSWD = 'webqtl' MYSQL_UPDSERVER = 'localhost' -DB_UPDNAME = 'db_webqtl' -DB_UPDUSER = 'webqtl' +DB_UPDNAME = 'db_webqtl_zas1024' +DB_UPDUSER = 'webqtlupd' DB_UPDPASSWD = 'webqtl' -GNROOT = '/gnshare/gn/' +GNROOT = '/home/zas1024/gn/' PythonPath = '/usr/bin/python' PIDDLE_FONT_PATH = '/usr/lib/python2.4/site-packages/piddle/truetypefonts/' diff --git a/wqflask/base/webqtlConfigLocal.py b/wqflask/base/webqtlConfigLocal.py index 35da73c2..5aab48ac 100755 --- a/wqflask/base/webqtlConfigLocal.py +++ b/wqflask/base/webqtlConfigLocal.py @@ -3,16 +3,17 @@ ######################################### MYSQL_SERVER = 'localhost' -DB_NAME = 'db_webqtl' +DB_NAME = 'db_webqtl_zas1024' DB_USER = 'webqtlupd' -DB_PASSWD = 'zhou&yan@ut' +DB_PASSWD = 'webqtl' MYSQL_UPDSERVER = 'localhost' -DB_UPDNAME = 'db_webqtl' +DB_UPDNAME = 'db_webqtl_zas1024' DB_UPDUSER = 'webqtlupd' -DB_UPDPASSWD = 'zhou&yan@ut' +DB_UPDPASSWD = 'webqtl' -GNROOT = '/gnshare/gn/' +GNROOT = '/home/zas1024/gn/' +ROOT_URL = 'http://alexandria.uthsc.edu:91/' PythonPath = '/usr/bin/python' PIDDLE_FONT_PATH = '/usr/lib/python2.4/site-packages/piddle/truetypefonts/' diff --git a/wqflask/wqflask/dataSharing/SharingInfoPage.py b/wqflask/wqflask/dataSharing/SharingInfoPage.py index 5503ff74..7ad44440 100755 --- a/wqflask/wqflask/dataSharing/SharingInfoPage.py +++ b/wqflask/wqflask/dataSharing/SharingInfoPage.py @@ -28,6 +28,8 @@ from __future__ import print_function, division from pprint import pformat as pf +import urlparse + import flask from base.templatePage import templatePage @@ -54,7 +56,7 @@ class SharingInfoPage(templatePage): sql = "select GN_AccesionId from InfoFiles where InfoPageName = %s" cursor.execute(sql, InfoPageName) GN_AccessionId = cursor.fetchone() - self.redirect_url = "http://23.21.59.238:5001/data_sharing?GN_AccessionId=%s" % GN_AccessionId + self.redirect_url = urlparse.urljoin(webqtlConfig.ROOT_URL, "/data_sharing?GN_AccessionId=%s" % GN_AccessionId) #self.redirect_url = flask.url_for('data_sharing', GN_AccessionId=GN_AccessionId[0]) print("set self.redirect_url") #print("before redirect") diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 06d8227c..852e6a16 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -19,6 +19,7 @@ print("latest blue") @app.route("/") def index_page(): + print("Sending index_page") return render_template("index_page.html") -- cgit v1.2.3 From 4cc46d84810ca9492e9a38e1a1f88ab36d214791 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Tue, 28 Aug 2012 16:05:09 -0500 Subject: Various changes related to the webqtlCaseData object and the way values/variances/num_cases are called in DataEditingPage.py --- misc/find.txt | 1 + misc/python_stuff.txt | 1 + wqflask/base/webqtlCaseData.py | 69 ++++-- wqflask/base/webqtlTrait.py | 52 ++-- wqflask/utility/webqtlUtil.py | 7 +- wqflask/wqflask/show_trait/DataEditingPage.py | 276 +++++++++++---------- wqflask/wqflask/show_trait/show_trait_page.py | 27 +- .../wqflask/templates/trait_data_and_analysis.html | 24 +- 8 files changed, 261 insertions(+), 196 deletions(-) create mode 100644 misc/find.txt create mode 100644 misc/python_stuff.txt (limited to 'wqflask/base') diff --git a/misc/find.txt b/misc/find.txt new file mode 100644 index 00000000..5c792d80 --- /dev/null +++ b/misc/find.txt @@ -0,0 +1 @@ +find | grep _____ diff --git a/misc/python_stuff.txt b/misc/python_stuff.txt new file mode 100644 index 00000000..f36fe338 --- /dev/null +++ b/misc/python_stuff.txt @@ -0,0 +1 @@ +Classes should always inherit "object" \ No newline at end of file diff --git a/wqflask/base/webqtlCaseData.py b/wqflask/base/webqtlCaseData.py index f68354be..7805df06 100755 --- a/wqflask/base/webqtlCaseData.py +++ b/wqflask/base/webqtlCaseData.py @@ -24,28 +24,59 @@ # # Last updated by GeneNetwork Core Team 2010/10/20 -class webqtlCaseData: - """ - one case data in one trait - """ +print("Mr. Mojo Risin 2") - val = None #Trait Value - var = None #Trait Variance - N = None #Number of individuals +class webqtlCaseData(object): + """one case data in one trait + + """ - def __init__(self, val=val, var=var, N=N): - self.val = val - self.var = var - self.N = N + def __init__(self, name, value=None, variance=None, num_cases=None): + self.name = name + self.value = value # Trait Value + self.variance = variance # Trait Variance + self.num_cases = num_cases # Number of individuals/cases + self.this_id = None # Set a sane default (can't be just "id" cause that's a reserved word) - def __str__(self): + def __repr__(self): str = "" - if self.val != None: - str += "value=%2.3f" % self.val - if self.var != None: - str += " variance=%2.3f" % self.var - if self.N != None: - str += " ndata=%d" % self.N + if self.value != None: + str += "value=%2.3f" % self.value + if self.variance != None: + str += " variance=%2.3f" % self.variance + if self.num_cases != None: + str += " ndata=%d" % self.num_cases return str + + @property + def display_value(self): + if self.value: + return "%2.3f" % self.value + else: + return "x" + + @property + def display_variance(self): + if self.variance: + return "%2.3f" % self.variance + else: + return "x" + + + #try: + # traitVar = thisvar + # dispVar = "%2.3f" % thisvar + #except: + # traitVar = '' + # dispVar = 'x' + + #try: + # traitVal = thisval + # dispVal = "%2.3f" % thisval + #except: + # traitVal = '' + # dispVal = 'x' + - __repr__ = __str__ + #def this_val_full(self): + # strain_name = \ No newline at end of file diff --git a/wqflask/base/webqtlTrait.py b/wqflask/base/webqtlTrait.py index 23b98238..337493ef 100755 --- a/wqflask/base/webqtlTrait.py +++ b/wqflask/base/webqtlTrait.py @@ -225,7 +225,10 @@ class webqtlTrait: - def retrieveData(self, strainlist=[]): + def retrieveData(self, strainlist=None): + + if strainlist == None: + strainlist = [] assert self.db and self.cursor if self.db.type == 'Temp': @@ -328,32 +331,33 @@ class webqtlTrait: self.cursor.execute(query) results = self.cursor.fetchall() self.data.clear() + if results: self.mysqlid = results[0][-1] - if strainlist: - for item in results: - if item[0] in strainlist: - val = item[1] - if val != None: - var = item[2] - ndata = None - if self.db.type in ('Publish', 'Temp'): - ndata = item[3] - self.data[item[0]] = webqtlCaseData(val, var, ndata) + #if strainlist: + for item in results: + #name, value, variance, num_cases = item + if not strainlist or (strainlist and name in strainlist): + #if value != None: + # num_cases = None + # if self.db.type in ('Publish', 'Temp'): + # ndata = item[3] + name = item[0] + self.data[name] = webqtlCaseData(*item) #name, value, variance, num_cases) #end for - else: - for item in results: - val = item[1] - if val != None: - var = item[2] - ndata = None - if self.db.type in ('Publish', 'Temp'): - ndata = item[3] - self.data[item[0]] = webqtlCaseData(val, var, ndata) - #end for - #end if - else: - pass + # else: + # for item in results: + # val = item[1] + # if val != None: + # var = item[2] + # ndata = None + # if self.db.type in ('Publish', 'Temp'): + # ndata = item[3] + # self.data[item[0]] = webqtlCaseData(val, var, ndata) + # #end for + # #end if + #else: + # pass def keys(self): return self.__dict__.keys() diff --git a/wqflask/utility/webqtlUtil.py b/wqflask/utility/webqtlUtil.py index 6409e781..99451e33 100755 --- a/wqflask/utility/webqtlUtil.py +++ b/wqflask/utility/webqtlUtil.py @@ -252,7 +252,12 @@ def FloatList2String(lst): return "" def ListNotNull(lst): - 'Determine if the elements in a list are all null' + '''Obsolete - Use built in function any (or all or whatever) + + + Determine if the elements in a list are all null + + ''' for item in lst: if item is not None: return 1 diff --git a/wqflask/wqflask/show_trait/DataEditingPage.py b/wqflask/wqflask/show_trait/DataEditingPage.py index f9133f27..43f05f14 100755 --- a/wqflask/wqflask/show_trait/DataEditingPage.py +++ b/wqflask/wqflask/show_trait/DataEditingPage.py @@ -11,6 +11,7 @@ import yaml from htmlgen import HTMLgen2 as HT from base import webqtlConfig +from base import webqtlCaseData from utility import webqtlUtil, Plot from base.webqtlTrait import webqtlTrait from dbFunction import webqtlDatabaseFunction @@ -172,17 +173,17 @@ class DataEditingPage(templatePage): if thisTrait == None: thisTrait = webqtlTrait(data=fd.allTraitData, db=None) - # Variance submit page only - if fd.enablevariance and not varianceDataPage: - 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, thisTrait) - #self.dispMappingTools(fd, title4Body, thisTrait) + ## Variance submit page only + #if fd.enablevariance and not varianceDataPage: + # 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, thisTrait) + # #self.dispMappingTools(fd, title4Body, thisTrait) ############################# ## Trait Value Table @@ -892,13 +893,13 @@ class DataEditingPage(templatePage): for strain in thisTrait.data.keys(): strainName = strain.replace("_2nd_", "") if strain not in strainlist: - if (thisTrait.data[strainName].val != None): + if thisTrait.data[strainName].value != None: if strain.find('F1') < 0: specialStrains.append(strain) - if (thisTrait.data[strainName].val != None) and (strain not in (fd.f1list + fd.parlist)): + if (thisTrait.data[strainName].value != None) and (strain not in (fd.f1list + fd.parlist)): other_strains.append(strain) #XZ: at current stage, other_strains doesn't include parent strains and F1 strains of primary group else: - if (thisTrait.data[strainName].val != None) and (strain not in (fd.f1list + fd.parlist)): + if (thisTrait.data[strainName].value != None) and (strain not in (fd.f1list + fd.parlist)): primary_strains.append(strain) #XZ: at current stage, the primary_strains is the same as fd.strainlist / ZS: I tried defining primary_strains as fd.strainlist instead, but in some cases it ended up including the parent strains (1436869_at BXD) if len(other_strains) > 3: @@ -941,41 +942,58 @@ class DataEditingPage(templatePage): vals3 = [] #Using all strains/cases for values - for i, strainNameOrig in enumerate(all_strains): + #for strain_type in (all_strains, primary_strains, other_strains): + for strainNameOrig in all_strains: strainName = strainNameOrig.replace("_2nd_", "") - try: - thisval = thisTrait.data[strainName].val - thisvar = thisTrait.data[strainName].var - thisValFull = [strainName, thisval, thisvar] - except: - continue + #try: + print("* type of thisTrait:", type(thisTrait)) + print(" name:", thisTrait.__class__.__name__) + print(" thisTrait:", thisTrait) + print(" type of thisTrait.data[strainName]:", type(thisTrait.data[strainName])) + print(" name:", thisTrait.data[strainName].__class__.__name__) + print(" thisTrait.data[strainName]:", thisTrait.data[strainName]) + thisval = thisTrait.data[strainName].value + print(" thisval:", thisval) + thisvar = thisTrait.data[strainName].variance + print(" thisvar:", thisvar) + thisValFull = [strainName, thisval, thisvar] + print(" thisValFull:", thisValFull) + #except: + # continue vals1.append(thisValFull) + + + #vals1 = [[strainNameOrig.replace("_2nd_", ""), + # thisTrait.data[strainName].val, + # thisTrait.data[strainName].var] + # for strainNameOrig in all_strains]] + # #Using just the RISet strain - for i, strainNameOrig in enumerate(primary_strains): + for strainNameOrig in primary_strains: strainName = strainNameOrig.replace("_2nd_", "") - try: - thisval = thisTrait.data[strainName].val - thisvar = thisTrait.data[strainName].var - thisValFull = [strainName,thisval,thisvar] - except: - continue + #try: + thisval = thisTrait.data[strainName].value + thisvar = thisTrait.data[strainName].variance + thisValFull = [strainName,thisval,thisvar] + #except: + # continue vals2.append(thisValFull) #Using all non-RISet strains only - for i, strainNameOrig in enumerate(other_strains): + for strainNameOrig in other_strains: strainName = strainNameOrig.replace("_2nd_", "") - try: - thisval = thisTrait.data[strainName].val - thisvar = thisTrait.data[strainName].var - thisValFull = [strainName,thisval,thisvar] - except: - continue + #try: + thisval = thisTrait.data[strainName].value + thisvar = thisTrait.data[strainName].variance + thisValFull = [strainName,thisval,thisvar] + #except: + # continue vals3.append(thisValFull) @@ -985,15 +1003,15 @@ class DataEditingPage(templatePage): vals = [] #Using all strains/cases for values - for i, strainNameOrig in enumerate(all_strains): + for strainNameOrig in all_strains: strainName = strainNameOrig.replace("_2nd_", "") - try: - thisval = thisTrait.data[strainName].val - thisvar = thisTrait.data[strainName].var - thisValFull = [strainName,thisval,thisvar] - except: - continue + #try: + thisval = thisTrait.data[strainName].value + thisvar = thisTrait.data[strainName].variance + thisValFull = [strainName,thisval,thisvar] + #except: + # continue vals.append(thisValFull) @@ -1344,24 +1362,26 @@ class DataEditingPage(templatePage): # updated by NL 5-28-2010 # Interval Mapping chrMenu = HT.Select(name='chromosomes1') - chrMenu.append(tuple(["All",-1])) + chrMenu.append(("All",-1)) for i in range(len(fd.genotype)): - if len(fd.genotype[i]) > 1: - chrMenu.append(tuple([fd.genotype[i].name,i])) + 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(tuple(["All",-1])) + chrMenu2.append(("All",-1)) for i in range(len(fd.genotype)): - if len(fd.genotype[i]) > 1: - chrMenu2.append(tuple([fd.genotype[i].name,i])) + 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 = 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 = 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')) @@ -1521,7 +1541,7 @@ class DataEditingPage(templatePage): submitTable = HT.TableLite(cellspacing=0, cellpadding=0, width="100%", Class="target2") - if mappingMethodId != None: + if not mappingMethodId: if int(mappingMethodId) == 1: submitTable.append(mapping_row) submitTable.append(mapping_script) @@ -1567,17 +1587,6 @@ class DataEditingPage(templatePage): title4Body.append(submitTable) - def natural_sort(strain_list): - - sorted = [] - for strain in strain_list: - try: - strain = int(strain) - try: sorted[-1] = sorted[-1] * 10 + strain - except: sorted.append(strain) - except: - sorted.append(strain) - return sorted ########################################## ## Function to display trait tables @@ -1727,8 +1736,9 @@ class DataEditingPage(templatePage): attribute_names=attribute_names, strains='other') - if other_strains or (fd.f1list and thisTrait.data.has_key(fd.f1list[0])) \ - or (fd.f1list and thisTrait.data.has_key(fd.f1list[1])): + #TODO: Figure out why this if statement is written this way - Zach + if (other_strains or (fd.f1list and thisTrait.data.has_key(fd.f1list[0])) + or (fd.f1list and thisTrait.data.has_key(fd.f1list[1]))): print("hjs") fd.allstrainlist = allstrainlist_neworder @@ -1738,85 +1748,93 @@ class DataEditingPage(templatePage): def addTrait2Table(self, fd, varianceDataPage, strainlist, mainForm, thisTrait, - other_strainsExist=None, attribute_ids=[], - attribute_names=[], strains='primary'): + other_strainsExist=None, attribute_ids=None, + attribute_names=None, strains='primary'): + + if attribute_ids == None: + attribute_ids = [] + + if attribute_names == None: + attribute_names = [] + #XZ, Aug 23, 2010: I commented the code related to the display of animal case #strainInfo = thisTrait.has_key('strainInfo') and thisTrait.strainInfo print("in addTrait2Table") table_body = [] vals = [] - for i, strainNameOrig in enumerate(strainlist): - strainName = strainNameOrig.replace("_2nd_", "") - - try: - thisval = thisTrait.data[strainName].val - thisvar = thisTrait.data[strainName].var - thisValFull = [strainName,thisval,thisvar] - except: - continue - - vals.append(thisValFull) - upperBound, lowerBound = Plot.findOutliers(vals) # ZS: Values greater than upperBound or less than lowerBound are considered outliers. + #################### Only used to find upperBound and lowerBound + #for strainNameOrig in strainlist: + # strainName = strainNameOrig.replace("_2nd_", "") + # print("pen: %s - %s" % (strainNameOrig, strainName)) + # thisval = thisTrait.data[strainName].value + # thisvar = thisTrait.data[strainName].variance + # thisValFull = [strainName, thisval, thisvar] + # + # vals.append(thisValFull) + # + #upperBound, lowerBound = Plot.findOutliers(vals) # ZS: Values greater than upperBound or less than lowerBound are considered outliers. the_strains = [] - for i, strainNameOrig in enumerate(strainlist): - strain = {} - print("zyt - strainNameOrig:", strainNameOrig) - trId = strainNameOrig - #selectCheck = HT.Input(type="checkbox", name="selectCheck", value=trId, Class="checkbox", onClick="highlight(this)") - + for counter, strainNameOrig in enumerate(strainlist, 1): strainName = strainNameOrig.replace("_2nd_", "") strainNameAdd = '' if fd.RISet == 'AXBXA' and strainName in ('AXB18/19/20','AXB13/14','BXA8/17'): strainNameAdd = HT.Href(url='/mouseCross.html#AXB/BXA', text=HT.Sup('#'), Class='fs12', target="_blank") - + try: - thisval, thisvar, thisNP = thisTrait.data[strainName].val, thisTrait.data[strainName].var, thisTrait.data[strainName].N - if thisNP: - mainForm.append(HT.Input(name='N'+strainName, value=thisNP, type='hidden')) - else: - pass - except: - thisval = thisvar = 'x' - - try: - traitVal = thisval - dispVal = "%2.3f" % thisval - except: - traitVal = '' - dispVal = 'x' + strain = thisTrait.data[strainName] + except KeyError: + print("No strain %s, let's create it now" % strainName) + strain = webqtlCaseData.webqtlCaseData(strainName) + print("zyt - strainNameOrig:", strainNameOrig) + #trId = strainNameOrig + #selectCheck = HT.Input(type="checkbox", name="selectCheck", value=trId, Class="checkbox", onClick="highlight(this)") - strain['strain_name'] = strainName - strainNameDisp = HT.Span(strainName, Class='fs14 fwn ffl') + + #try: + # thisval, thisvar, thisNP = thisTrait.data[strainName].value, thisTrait.data[strainName].var, thisTrait.data[strainName].N + # if thisNP: + # mainForm.append(HT.Input(name='N'+strainName, value=thisNP, type='hidden')) + # else: + # pass + #except: + # thisval = thisvar = 'x' - if varianceDataPage: - try: - traitVar = thisvar - dispVar = "%2.3f" % thisvar - except: - traitVar = '' - dispVar = 'x' + #thisval = thisTrait.data[strainName].value + #thisvar = thisTrait.data[strainName].variance + #thisTrait.data[strainName].num_cases - if thisval == 'x': - traitVar = '' #ZS: Used to be 0, but it doesn't seem like a good idea for values of 0 to *always* be at the bottom when you sort; it makes more sense to put "nothing" + #strain['strain_name'] = strainName + #strainNameDisp = HT.Span(strainName, Class='fs14 fwn ffl') - #className = 'fs13 b1 c222 ' - #valueClassName = 'fs13 b1 c222 valueField ' - #rowClassName = 'novalue ' - else: - if (thisval >= upperBound) or (thisval <= lowerBound): - strain['outlier'] = "outlier" # We're going to use this as a class, so we want it to be a word - #className = 'fs13 b1 c222 outlier ' - #valueClassName = 'fs13 b1 c222 valueField ' - #rowClassName = 'outlier' - else: - strain['outlier'] = "not_outlier" - #className = 'fs13 b1 c222 ' - #valueClassName = 'fs13 b1 c222 valueField ' - #rowClassName = ' ' + #if varianceDataPage: + #try: + # traitVar = thisvar + # dispVar = "%2.3f" % thisvar + #except: + # traitVar = '' + # dispVar = 'x' + + #if thisval == 'x': + # traitVar = '' #ZS: Used to be 0, but it doesn't seem like a good idea for values of 0 to *always* be at the bottom when you sort; it makes more sense to put "nothing" + # + # #className = 'fs13 b1 c222 ' + # #valueClassName = 'fs13 b1 c222 valueField ' + # #rowClassName = 'novalue ' + #else: + # if (thisval >= upperBound) or (thisval <= lowerBound): + # strain['outlier'] = "outlier" # We're going to use this as a class, so we want it to be a word + # #className = 'fs13 b1 c222 outlier ' + # #valueClassName = 'fs13 b1 c222 valueField ' + # #rowClassName = 'outlier' + # else: + # strain['outlier'] = "not_outlier" + # #className = 'fs13 b1 c222 ' + # #valueClassName = 'fs13 b1 c222 valueField ' + # #rowClassName = ' ' # #if varianceDataPage: # varClassName = valueClassName + str(traitVar) @@ -1851,15 +1869,15 @@ class DataEditingPage(templatePage): # # onChange= "javascript:this.form['V%s'].value=this.form['V%s'].value;" % (strainNameOrig.replace("/", ""), strainNameOrig.replace("/", "")), Class=varClassName) if strains == 'primary': - strain['the_id'] = "Primary_" + str(i+1) + strain.this_id = "Primary_" + str(counter) #table_row = HT.TR(Id="Primary_"+str(i+1), Class=rowClassName) else: - strain['the_id'] = "Other_" + str(i+1) + strain.this_id = "Other_" + str(counter) #table_row = HT.TR(Id="Other_"+str(i+1), Class=rowClassName) - strain['value'] = traitVal - - strain['se'] = dispVar + #strain['value'] = traitVal + # + #strain['se'] = dispVar #if varianceDataPage: #table_row.append(HT.TD(str(i+1), selectCheck, width=45, align='right', Class=className)) #table_row.append(HT.TD(strainNameDisp, strainNameAdd, align='right', width=100, Class=className)) diff --git a/wqflask/wqflask/show_trait/show_trait_page.py b/wqflask/wqflask/show_trait/show_trait_page.py index b1f71e55..b42f5e8e 100644 --- a/wqflask/wqflask/show_trait/show_trait_page.py +++ b/wqflask/wqflask/show_trait/show_trait_page.py @@ -161,24 +161,25 @@ class ShowTraitPage(DataEditingPage): thisTrait.returnURL = '%s&CellID=%s' % (thisTrait.returnURL, CellID) #retrieve trait information - try: - thisTrait.retrieveInfo() - thisTrait.retrieveData() - self.updMysql() - self.cursor.execute("insert into AccessLog(accesstime,ip_address) values(Now(),%s)", user_ip) - self.openMysql() - except Exception as why: - print("Got an exception:", why) - heading = "Retrieve Data" - detail = ["The information you requested is not avaiable at this time."] - self.error(heading=heading, detail=detail) - return + #try: + thisTrait.retrieveInfo() + thisTrait.retrieveData() + self.updMysql() + self.cursor.execute("insert into AccessLog(accesstime,ip_address) values(Now(),%s)", user_ip) + self.openMysql() + #except Exception as why: + # print("Got an exception:", why) + # heading = "Retrieve Data" + # detail = ["The information you requested is not avaiable at this time."] + # self.error(heading=heading, detail=detail) + # return ##read genotype file fd.RISet = thisTrait.riset fd.readGenotype() - if webqtlUtil.ListNotNull(map(lambda x:x.var, thisTrait.data.values())): + #if webqtlUtil.ListNotNull(map(lambda x:x.var, thisTrait.data.values())): + if any([x.variance for x in thisTrait.data.values()]): fd.displayVariance = 1 fd.varianceDispName = 'SE' fd.formID = 'varianceChoice' diff --git a/wqflask/wqflask/templates/trait_data_and_analysis.html b/wqflask/wqflask/templates/trait_data_and_analysis.html index 4bf06d45..94ba0aad 100644 --- a/wqflask/wqflask/templates/trait_data_and_analysis.html +++ b/wqflask/wqflask/templates/trait_data_and_analysis.html @@ -8,7 +8,7 @@
-
+
{# @@ -3059,7 +3059,7 @@
{% for strain_type in (primary_strains, other_strains) %} -
{# Slightly tortuous, but best way to get the id we need #} +
{# Slightly tortuous, but best way to get the id we need #} @@ -3076,20 +3076,20 @@ {% for strain in strain_type %} - + {# Todo: Add IDs #} @@ -3099,8 +3099,8 @@ {# Todo: Add IDs #} {% endfor %} @@ -3133,4 +3133,8 @@ - {% endblock %} + + + + + {% endblock %} -- cgit v1.2.3 From be095620bc8126026514fdee43e06a9a9f443f97 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Wed, 29 Aug 2012 17:49:43 -0500 Subject: Fixed so that outliers are now correctly highlighted --- wqflask/base/webqtlCaseData.py | 26 ++-- wqflask/utility/Plot.py | 100 ++++++------- wqflask/wqflask/show_trait/DataEditingPage.py | 154 ++++++--------------- .../wqflask/templates/trait_data_and_analysis.html | 2 +- 4 files changed, 103 insertions(+), 179 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/webqtlCaseData.py b/wqflask/base/webqtlCaseData.py index 7805df06..25665c55 100755 --- a/wqflask/base/webqtlCaseData.py +++ b/wqflask/base/webqtlCaseData.py @@ -37,6 +37,7 @@ class webqtlCaseData(object): self.variance = variance # Trait Variance self.num_cases = num_cases # Number of individuals/cases self.this_id = None # Set a sane default (can't be just "id" cause that's a reserved word) + self.outlier = None # Not set to True/False until later def __repr__(self): str = "" @@ -48,6 +49,14 @@ class webqtlCaseData(object): str += " ndata=%d" % self.num_cases return str + @property + def class_outlier(self): + """Template helper""" + if self.outlier: + return "outlier" + else: + return "" + @property def display_value(self): if self.value: @@ -63,20 +72,3 @@ class webqtlCaseData(object): return "x" - #try: - # traitVar = thisvar - # dispVar = "%2.3f" % thisvar - #except: - # traitVar = '' - # dispVar = 'x' - - #try: - # traitVal = thisval - # dispVal = "%2.3f" % thisval - #except: - # traitVal = '' - # dispVal = 'x' - - - #def this_val_full(self): - # strain_name = \ No newline at end of file diff --git a/wqflask/utility/Plot.py b/wqflask/utility/Plot.py index 086f3d57..51a57a6d 100755 --- a/wqflask/utility/Plot.py +++ b/wqflask/utility/Plot.py @@ -25,6 +25,13 @@ # Last updated by GeneNetwork Core Team 2010/10/20 #import piddle as pid + +from __future__ import print_function + +from pprint import pformat as pf + +print("Lysol") + from math import * import random import sys, os @@ -32,6 +39,9 @@ from numarray import linear_algebra as la from numarray import ones, array, dot, swapaxes import reaper +sys.path.append("..") +print(sys.path) +from basicStatistics import corestats import svg import webqtlUtil @@ -254,6 +264,7 @@ def gmedian(lst2): return lst[(N-1)/2] def gpercentile(lst2, np): + """Obsolete - use percentile in corestats instead""" lst = lst2[:] N = len(lst) if N == 0 or np > 100 or np < 0: @@ -270,61 +281,41 @@ def gpercentile(lst2, np): else: return lst[k-1] + d*(lst[k] - lst[k-1]) -def findOutliers(vals): - - valsOnly = [] - dataXZ = vals[:] - for i in range(len(dataXZ)): - valsOnly.append(dataXZ[i][1]) - - data = [('', valsOnly[:])] - - for item in data: - itemvalue = item[1] - nValue = len(itemvalue) - catValue = [] - - for item2 in itemvalue: - try: - tstrain, tvalue = item2 - except: - tvalue = item2 - if nValue <= 4: - continue - else: - catValue.append(tvalue) - - if catValue != []: - lowHinge = gpercentile(catValue, 25) - upHinge = gpercentile(catValue, 75) - Hstep = 1.5*(upHinge - lowHinge) +def find_outliers(vals): + """Calculates the upper and lower bounds of a set of sample/case values + + + >>> find_outliers([3.504, 5.234, 6.123, 7.234, 3.542, 5.341, 7.852, 4.555, 12.537]) + (11.252500000000001, 0.5364999999999993) + + >>> >>> find_outliers([9,12,15,17,31,50,7,5,6,8]) + (32.0, -8.0) + + If there are no vals, returns None for the upper and lower bounds, + which code that calls it will have to deal with. + >>> find_outliers([]) + (None, None) + + """ - outlier = [] - extreme = [] + print("xerxes vals is:", pf(vals)) - upperBound = upHinge + Hstep - lowerBound = lowHinge - Hstep + if vals: + #print("vals is:", pf(vals)) + stats = corestats.Stats(vals) + low_hinge = stats.percentile(25) + up_hinge = stats.percentile(75) + hstep = 1.5 * (up_hinge - low_hinge) - for item in catValue: - if item >= upHinge + 2*Hstep: - extreme.append(item) - elif item >= upHinge + Hstep: - outlier.append(item) - else: - pass + upper_bound = up_hinge + hstep + lower_bound = low_hinge - hstep - for item in catValue: - if item <= lowHinge - 2*Hstep: - extreme.append(item) - elif item <= lowHinge - Hstep: - outlier.append(item) - else: - pass - else: - upperBound = 1000 - lowerBound = -1000 + else: + upper_bound = None + lower_bound = None - return upperBound, lowerBound + print(pf(locals())) + return upper_bound, lower_bound def plotBoxPlot(canvas, data, offset= (40, 40, 40, 40), XLabel="Category", YLabel="Value"): @@ -1281,3 +1272,12 @@ def BWSpectrum(n=100): out.append(pid.Color(x,x,x)); x += step return out + + +def _test(): + import doctest + doctest.testmod() + + +if __name__=="__main__": + _test() diff --git a/wqflask/wqflask/show_trait/DataEditingPage.py b/wqflask/wqflask/show_trait/DataEditingPage.py index 43f05f14..bb6156c3 100755 --- a/wqflask/wqflask/show_trait/DataEditingPage.py +++ b/wqflask/wqflask/show_trait/DataEditingPage.py @@ -1,5 +1,7 @@ from __future__ import absolute_import, print_function, division +print("Google") + import string import os import cPickle @@ -1673,7 +1675,7 @@ class DataEditingPage(templatePage): #showHideMenuOptions.append(HT.Bold("  Options:"), " "*5, showHideNoValue, " "*5, showHideOutliers, " "*5, resetButton, " "*5, exportButton) #traitTableOptions.append(showHideMenuOptions,HT.BR(),HT.BR()) - #traitTableOptions.append(HT.Span("  Outliers highlighted in ", HT.Bold(" yellow ", style="background-color:yellow;"), " can be hidden using the ", + #traitTableOptions.append(HT.Span("  Outliers highlighted in ", HT.Bold(" red ", style="background-color:red;"), " can be hidden using the ", # HT.Strong(" Hide Outliers "), " button,",HT.BR(),"  and samples with no value (x) can be hidden by clicking ", # HT.Strong(" Hide No Value "), "."), HT.BR()) @@ -1703,7 +1705,7 @@ class DataEditingPage(templatePage): primary_strainlist = fd.parlist + allstrainlist_neworder - primary_strains = self.addTrait2Table(fd=fd, + primary_strains = self.create_strain_objects(fd=fd, varianceDataPage=varianceDataPage, strainlist=primary_strainlist, mainForm=mainForm, @@ -1712,6 +1714,7 @@ class DataEditingPage(templatePage): attribute_ids=attribute_ids, attribute_names=attribute_names, strains='primary') + other_strains = [] for strain in thisTrait.data.keys(): @@ -1727,7 +1730,7 @@ class DataEditingPage(templatePage): other_strains.sort() #Sort other strains other_strains = par_f1_strains + other_strains - other_strains = self.addTrait2Table(fd=fd, + other_strains = self.create_strain_objects(fd=fd, varianceDataPage=varianceDataPage, strainlist=other_strains, mainForm=mainForm, @@ -1736,6 +1739,7 @@ class DataEditingPage(templatePage): attribute_names=attribute_names, strains='other') + #TODO: Figure out why this if statement is written this way - Zach if (other_strains or (fd.f1list and thisTrait.data.has_key(fd.f1list[0])) or (fd.f1list and thisTrait.data.has_key(fd.f1list[1]))): @@ -1747,7 +1751,7 @@ class DataEditingPage(templatePage): self.other_strains = other_strains - def addTrait2Table(self, fd, varianceDataPage, strainlist, mainForm, thisTrait, + def create_strain_objects(self, fd, varianceDataPage, strainlist, mainForm, thisTrait, other_strainsExist=None, attribute_ids=None, attribute_names=None, strains='primary'): @@ -1759,23 +1763,26 @@ class DataEditingPage(templatePage): #XZ, Aug 23, 2010: I commented the code related to the display of animal case #strainInfo = thisTrait.has_key('strainInfo') and thisTrait.strainInfo - print("in addTrait2Table") - table_body = [] - vals = [] - - - #################### Only used to find upperBound and lowerBound + print("in create_strain_objects") + #table_body = [] + + ################### Only used to find upperBound and lowerBound + #vals = [] #for strainNameOrig in strainlist: # strainName = strainNameOrig.replace("_2nd_", "") # print("pen: %s - %s" % (strainNameOrig, strainName)) - # thisval = thisTrait.data[strainName].value - # thisvar = thisTrait.data[strainName].variance - # thisValFull = [strainName, thisval, thisvar] - # - # vals.append(thisValFull) + # try: + # thisval = thisTrait.data[strainName].value + # thisvar = thisTrait.data[strainName].variance + # thisValFull = [strainName, thisval, thisvar] + # + # vals.append(thisValFull) + # except KeyError: + # print("**x** Skipping:", strainName) # #upperBound, lowerBound = Plot.findOutliers(vals) # ZS: Values greater than upperBound or less than lowerBound are considered outliers. + the_strains = [] for counter, strainNameOrig in enumerate(strainlist, 1): @@ -1790,107 +1797,15 @@ class DataEditingPage(templatePage): print("No strain %s, let's create it now" % strainName) strain = webqtlCaseData.webqtlCaseData(strainName) print("zyt - strainNameOrig:", strainNameOrig) - #trId = strainNameOrig - #selectCheck = HT.Input(type="checkbox", name="selectCheck", value=trId, Class="checkbox", onClick="highlight(this)") - - - #try: - # thisval, thisvar, thisNP = thisTrait.data[strainName].value, thisTrait.data[strainName].var, thisTrait.data[strainName].N - # if thisNP: - # mainForm.append(HT.Input(name='N'+strainName, value=thisNP, type='hidden')) - # else: - # pass - #except: - # thisval = thisvar = 'x' - - #thisval = thisTrait.data[strainName].value - #thisvar = thisTrait.data[strainName].variance - #thisTrait.data[strainName].num_cases - - #strain['strain_name'] = strainName - #strainNameDisp = HT.Span(strainName, Class='fs14 fwn ffl') - - #if varianceDataPage: - #try: - # traitVar = thisvar - # dispVar = "%2.3f" % thisvar - #except: - # traitVar = '' - # dispVar = 'x' - - #if thisval == 'x': - # traitVar = '' #ZS: Used to be 0, but it doesn't seem like a good idea for values of 0 to *always* be at the bottom when you sort; it makes more sense to put "nothing" - # - # #className = 'fs13 b1 c222 ' - # #valueClassName = 'fs13 b1 c222 valueField ' - # #rowClassName = 'novalue ' - #else: - # if (thisval >= upperBound) or (thisval <= lowerBound): - # strain['outlier'] = "outlier" # We're going to use this as a class, so we want it to be a word - # #className = 'fs13 b1 c222 outlier ' - # #valueClassName = 'fs13 b1 c222 valueField ' - # #rowClassName = 'outlier' - # else: - # strain['outlier'] = "not_outlier" - # #className = 'fs13 b1 c222 ' - # #valueClassName = 'fs13 b1 c222 valueField ' - # #rowClassName = ' ' - # - #if varianceDataPage: - # varClassName = valueClassName + str(traitVar) - #valueClassName += str(traitVal) - - #if strainNameOrig == strainName: - # if other_strainsExist and strainNameOrig in (fd.parlist + fd.f1list): - # ######################################################################################################################################################## - # # ZS: Append value and variance to the value and variance input fields' list of classes; this is so the javascript can update the value when the user - # # changes it. The updated value is then used when the table is sorted (tablesorter.js). This needs to be done because the "value" attribute is immutable. - # ######################################################################################################################################################### - # - # #valueField = HT.Input(name=strainNameOrig, size=8, maxlength=8, style="text-align:right; background-color:#FFFFFF;", value=dispVal, - # # onChange= "javascript:this.form['_2nd_%s'].value=this.form['%s'].value;" % (strainNameOrig.replace("/", ""), strainNameOrig.replace("/", "")), Class=valueClassName) - # if varianceDataPage: - # pass - # #seField = HT.Input(name='V'+strainNameOrig, size=8, maxlength=8, style="text-align:right", value=dispVar, - # # onChange= "javascript:this.form['V_2nd_%s'].value=this.form['V%s'].value;" % (strainNameOrig.replace("/", ""), strainNameOrig.replace("/", "")), Class=varClassName) - # else: - # pass - # #valueField = HT.Input(name=strainNameOrig, size=8, maxlength=8, style="text-align:right; background-color:#FFFFFF;", value=dispVal, Class=valueClassName) - # if varianceDataPage: - # pass - # #seField = HT.Input(name='V'+strainNameOrig, size=8, maxlength=8, style="text-align:right", value=dispVar, Class=varClassName) - #else: - # pass - # #valueField = HT.Input(name=strainNameOrig, size=8, maxlength=8, style="text-align:right", value=dispVal, - # #onChange= "javascript:this.form['%s'].value=this.form['%s'].value;" % (strainNameOrig.replace("/", ""), strainNameOrig.replace("/", "")), Class=valueClassName) - # if varianceDataPage: - # pass - # #seField = HT.Input(name='V'+strainNameOrig, size=8, maxlength=8, style="text-align:right", value=dispVar, - # # onChange= "javascript:this.form['V%s'].value=this.form['V%s'].value;" % (strainNameOrig.replace("/", ""), strainNameOrig.replace("/", "")), Class=varClassName) + if strains == 'primary': strain.this_id = "Primary_" + str(counter) - #table_row = HT.TR(Id="Primary_"+str(i+1), Class=rowClassName) else: strain.this_id = "Other_" + str(counter) - #table_row = HT.TR(Id="Other_"+str(i+1), Class=rowClassName) - - #strain['value'] = traitVal - # - #strain['se'] = dispVar - #if varianceDataPage: - #table_row.append(HT.TD(str(i+1), selectCheck, width=45, align='right', Class=className)) - #table_row.append(HT.TD(strainNameDisp, strainNameAdd, align='right', width=100, Class=className)) - #table_row.append(HT.TD(valueField, width=70, align='right', Id="value_"+str(i)+"_"+strains, Class=className)) - #table_row.append(HT.TD("±", width=20, align='center', Class=className)) - #table_row.append(HT.TD(seField, width=80, align='right', Id="SE_"+str(i)+"_"+strains, Class=className)) - #pass - #else: - #table_row.append(HT.TD(str(i+1), selectCheck, width=45, align='right', Class=className)) - #table_row.append(HT.TD(strainNameDisp, strainNameAdd, align='right', width=100, Class=className)) - #table_row.append(HT.TD(valueField, width=70, align='right', Id="value_"+str(i)+"_"+strains, Class=className)) - #pass - if thisTrait and thisTrait.db and thisTrait.db.type =='ProbeSet': + + #### For extra attribute columns; currently only used by two human datasets - Zach + if thisTrait and thisTrait.db and thisTrait.db.type == 'ProbeSet': if len(attribute_ids) > 0: #ZS: Get StrainId value for the next query @@ -1929,6 +1844,8 @@ class DataEditingPage(templatePage): attr_counter += 1 the_strains.append(strain) #table_body.append(table_row) + + do_outliers(the_strains) print("*the_strains are [%i]: %s" % (len(the_strains), pf(the_strains))) return the_strains @@ -1975,3 +1892,18 @@ class DataEditingPage(templatePage): sortby = ("", "") return sortby + + + +def do_outliers(strain_objects): + values = [strain.value for strain in strain_objects if strain.value != None] + upper_bound, lower_bound = Plot.find_outliers(values) + + for strain in strain_objects: + if strain.value: + if upper_bound and strain.value > upper_bound: + strain.outlier = True + elif lower_bound and strain.value < lower_bound: + strain.outlier = True + else: + strain.outlier = False diff --git a/wqflask/wqflask/templates/trait_data_and_analysis.html b/wqflask/wqflask/templates/trait_data_and_analysis.html index 94ba0aad..3644b436 100644 --- a/wqflask/wqflask/templates/trait_data_and_analysis.html +++ b/wqflask/wqflask/templates/trait_data_and_analysis.html @@ -3076,7 +3076,7 @@ {% for strain in strain_type %} - +
{{ loop.index }} - + - {{ strain.strain_name }} + {{ strain.name }} - -
{{ loop.index }} -- cgit v1.2.3 From e7e3117695ef86a28df96cf32bfb66f6da2bc404 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Fri, 7 Sep 2012 17:08:36 -0500 Subject: Worked with passing form data to correlation page --- wqflask/base/webqtlFormData.py | 73 +- wqflask/wqflask/correlation/CorrelationPage.py | 2069 ++++++++++++++++++++ wqflask/wqflask/correlation/__init__.py | 0 wqflask/wqflask/correlation/correlationFunction.py | 923 +++++++++ wqflask/wqflask/show_trait/DataEditingPage.py | 4 +- wqflask/wqflask/show_trait/show_trait_page.py | 6 +- .../new/javascript/trait_data_and_analysis.coffee | 21 +- .../new/javascript/trait_data_and_analysis.js | 17 +- .../wqflask/templates/trait_data_and_analysis.html | 17 +- wqflask/wqflask/views.py | 10 +- 10 files changed, 3094 insertions(+), 46 deletions(-) create mode 100644 wqflask/wqflask/correlation/CorrelationPage.py create mode 100644 wqflask/wqflask/correlation/__init__.py create mode 100644 wqflask/wqflask/correlation/correlationFunction.py (limited to 'wqflask/base') diff --git a/wqflask/base/webqtlFormData.py b/wqflask/base/webqtlFormData.py index 06faacc0..a9e3b7d4 100755 --- a/wqflask/base/webqtlFormData.py +++ b/wqflask/base/webqtlFormData.py @@ -25,6 +25,10 @@ # Last updated by GeneNetwork Core Team 2010/10/20 #from mod_python import Cookie + +from __future__ import print_function +from pprint import pformat as pf + import string import os @@ -47,12 +51,25 @@ class webqtlFormData: #XZ: Attention! All attribute values must be picklable! - def __init__(self, start_vars = None, req = None, mod_python_session=None, FieldStorage_formdata=None): - - self.__dict__.update(start_vars) - - for item in self.attrs: - setattr(self,item, None) + def __init__(self, + start_vars = None, + req = None, + mod_python_session=None, + FieldStorage_formdata=None): + # Todo: rework this whole thing + print("in webqtlFormData start_vars are:", pf(start_vars)) + for item in webqtlFormData.attrs: + self.__dict__[item] = None + #self.__dict__.update(start_vars) + for item in start_vars: + self.__dict__[item] = start_vars[item] + print(" Now self.dict is:", pf(self.__dict__)) + #for item in self.attrs: + # if getattr(self, item, None): + # print("Setting item %s to None" % (item,)) + # self.attrs[item] = None + # else: + # self.attrs[item] = self.attrs[item].strip() try: self.remote_ip = req.connection.remote_ip @@ -84,31 +101,37 @@ class webqtlFormData: # if value != None: # setattr(self,item,string.strip(value)) - self.ppolar = "" - self.mpolar = "" + self.ppolar = None + self.mpolar = None + + print("[yellow] self.RISet is:", self.RISet) if self.RISet: - try: - # NL, 07/27/2010. ParInfo has been moved from webqtlForm.py to webqtlUtil.py; - f1, f12, self.mpolar, self.ppolar = webqtlUtil.ParInfo[self.RISet] - except: - f1 = f12 = self.mpolar = self.ppolar = None - - try: - self.nperm = int(self.nperm) - self.nboot = int(self.nboot) - except: - self.nperm = 2000 #XZ: Rob asked to change the default value to 2000 - self.nboot = 2000 #XZ: Rob asked to change the default value to 2000 - + #try: + # # NL, 07/27/2010. ParInfo has been moved from webqtlForm.py to webqtlUtil.py; + _f1, _f12, self.mpolar, self.ppolar = webqtlUtil.ParInfo[self.RISet] + #except: + # f1 = f12 = self.mpolar = self.ppolar = None + + + def set_number(stringy): + return int(stringy) if stringy else 2000 # Rob asked to change the default value to 2000 + + self.nperm = set_number(self.nperm) + self.nboot = set_number(self.nboot) + + + #if self.allstrainlist: + # self.allstrainlist = map(string.strip, string.split(self.allstrainlist)) + print("self.allstrainlist is:", self.allstrainlist) if self.allstrainlist: - self.allstrainlist = map(string.strip, string.split(self.allstrainlist)) + self.allstrainlist = self.allstrainlist.split() + print("now self.allstrainlist is:", self.allstrainlist) #self.readGenotype() #self.readData() if self.RISet == 'BXD300': self.RISet = 'BXD' - else: - pass + def __getitem__(self, key): return self.__dict__[key] @@ -133,7 +156,7 @@ class webqtlFormData: self.RISet = 'BXD' else: pass - assert self.RISet + assert self.RISet #genotype_1 is Dataset Object without parents and f1 #genotype_2 is Dataset Object with parents and f1 (not for intercross) self.genotype_1 = reaper.Dataset() diff --git a/wqflask/wqflask/correlation/CorrelationPage.py b/wqflask/wqflask/correlation/CorrelationPage.py new file mode 100644 index 00000000..9caf6595 --- /dev/null +++ b/wqflask/wqflask/correlation/CorrelationPage.py @@ -0,0 +1,2069 @@ +## Copyright (C) University of Tennessee Health Science Center, Memphis, TN. +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Affero General Public License for more details. +# +# This program is available from Source Forge: at GeneNetwork Project +# (sourceforge.net/projects/genenetwork/). +# +# Contact Drs. Robert W. Williams and Xiaodong Zhou (2010) +# at rwilliams@uthsc.edu and xzhou15@uthsc.edu +# +# +# +# This module is used by GeneNetwork project (www.genenetwork.org) +# +# Created by GeneNetwork Core Team 2010/08/10 +# +# Last updated by NL 2011/02/11 +# Last updated by Christian Fernandez 2012/04/07 +# Refactored correlation calculation into smaller functions in preparation of +# separating html from existing code + +from __future__ import print_function + +import string +from math import * +import cPickle +import os +import time +#import pyXLWriter as xl +import pp +import math + +from pprint import pformat as pf + +from htmlgen import HTMLgen2 as HT +import reaper + +from base import webqtlConfig +from utility.THCell import THCell +from utility.TDCell import TDCell +from base.webqtlTrait import webqtlTrait +from base.webqtlDataset import webqtlDataset +from base.templatePage import templatePage +from utility import webqtlUtil +from dbFunction import webqtlDatabaseFunction +import utility.webqtlUtil #this is for parallel computing only. +import correlationFunction + +import logging +logging.basicConfig(filename="/tmp/gn_log", level=logging.INFO) +_log = logging.getLogger("correlation") + +METHOD_SAMPLE_PEARSON = "1" +METHOD_SAMPLE_RANK = "2" +METHOD_LIT = "3" +METHOD_TISSUE_PEARSON = "4" +METHOD_TISSUE_RANK = "5" + +TISSUE_METHODS = [METHOD_TISSUE_PEARSON, METHOD_TISSUE_RANK] + +TISSUE_MOUSE_DB = 1 + +class AuthException(Exception): pass + + +class Trait(object): + def __init__(self, name, raw_values = None, lit_corr = None, tissue_corr = None, p_tissue = None): + self.name = name + self.raw_values = raw_values + self.lit_corr = lit_corr + self.tissue_corr = tissue_corr + self.p_tissue = p_tissue + self.correlation = 0 + self.p_value = 0 + + @staticmethod + def from_csv(line, data_start = 1): + name = line[0] + numbers = line[data_start:] + # _log.info(numbers) + numbers = [ float(number) for number in numbers ] + + return Trait(name, raw_values = numbers) + + def calculate_correlation(self, values, method): + """Calculate the correlation value and p value according to the method specified""" + + #ZS: This takes the list of values of the trait our selected trait is being correlated against and removes the values of the samples our trait has no value for + #There's probably a better way of dealing with this, but I'll have to ask Christian + updated_raw_values = [] + updated_values = [] + for i in range(len(values)): + if values[i] != "None": + updated_raw_values.append(self.raw_values[i]) + updated_values.append(values[i]) + + self.raw_values = updated_raw_values + values = updated_values + + if method == METHOD_SAMPLE_PEARSON or method == METHOD_LIT or method == METHOD_TISSUE_PEARSON: + corr,nOverlap = webqtlUtil.calCorrelation(self.raw_values, values, len(values)) + else: + corr,nOverlap = webqtlUtil.calCorrelationRank(self.raw_values, values, len(values)) + + self.correlation = corr + self.overlap = nOverlap + + if self.overlap < 3: + self.p_value = 1.0 + else: + #ZS - This is probably the wrong way to deal with this. Correlation values of 1.0 definitely exist (the trait correlated against itself), so zero division needs to br prevented. + if abs(self.correlation) >= 1.0: + self.p_value = 0.0 + else: + ZValue = 0.5*log((1.0+self.correlation)/(1.0-self.correlation)) + ZValue = ZValue*sqrt(self.overlap-3) + self.p_value = 2.0*(1.0 - reaper.normp(abs(ZValue))) + + + +#XZ, 01/14/2009: This method is for parallel computing only. +#XZ: It is supposed to be called when "Genetic Correlation, Pearson's r" (method 1) +#XZ: or "Genetic Correlation, Spearman's rho" (method 2) is selected +def compute_corr( input_nnCorr, input_trait, input_list, computing_method): + + allcorrelations = [] + + for line in input_list: + tokens = line.split('","') + tokens[-1] = tokens[-1][:-2] #remove the last " + tokens[0] = tokens[0][1:] #remove the first " + + traitdataName = tokens[0] + database_trait = tokens[1:] + + if computing_method == "1": #XZ: Pearson's r + corr,nOverlap = utility.webqtlUtil.calCorrelationText(input_trait, database_trait, input_nnCorr) + else: #XZ: Spearman's rho + corr,nOverlap = utility.webqtlUtil.calCorrelationRankText(input_trait, database_trait, input_nnCorr) + traitinfo = [traitdataName,corr,nOverlap] + allcorrelations.append(traitinfo) + + return allcorrelations + +def get_correlation_method_key(form_data): + #XZ, 09/28/2008: if user select "1", then display 1, 3 and 4. + #XZ, 09/28/2008: if user select "2", then display 2, 3 and 5. + #XZ, 09/28/2008: if user select "3", then display 1, 3 and 4. + #XZ, 09/28/2008: if user select "4", then display 1, 3 and 4. + #XZ, 09/28/2008: if user select "5", then display 2, 3 and 5. + + method = form_data.formdata.getvalue("method") + if method not in ["1", "2", "3" ,"4", "5"]: + return "1" + + return method + + +def get_custom_trait(form_data, cursor): + """Pulls the custom trait, if it exists, out of the form data""" + trait_name = form_data.formdata.getvalue('fullname') + + if trait_name: + trait = webqtlTrait(fullname=trait_name, cursor=cursor) + trait.retrieveInfo() + return trait + else: + return None + + +#XZ, 09/18/2008: get the information such as value, variance of the input strain names from the form. +def get_sample_data(form_data): + if form_data.allstrainlist: + mdpchoice = form_data.formdata.getvalue('MDPChoice') + #XZ, in HTML source code, it is "BXD Only" or "BXH only", and so on + if mdpchoice == "1": + strainlist = form_data.f1list + form_data.strainlist + #XZ, in HTML source code, it is "MDP Only" + elif mdpchoice == "2": + strainlist = [] + strainlist2 = form_data.f1list + form_data.strainlist + for strain in form_data.allstrainlist: + if strain not in strainlist2: + strainlist.append(strain) + #So called MDP Panel + if strainlist: + strainlist = form_data.f1list+form_data.parlist+strainlist + #XZ, in HTML source code, it is "All Cases" + else: + strainlist = form_data.allstrainlist + #XZ, 09/18/2008: put the trait data into dictionary form_data.allTraitData + form_data.readData(form_data.allstrainlist) + else: + mdpchoice = None + strainlist = form_data.strainlist + #XZ, 09/18/2008: put the trait data into dictionary form_data.allTraitData + form_data.readData() + + return strainlist + + +def get_mdp_choice(form_data): + if form_data.allstrainlist: + return form_data.formdata.getvalue("MDPChoice") + else: + return None + + +def get_species(fd, cursor): + #XZ, 3/16/2010: variable RISet must be pass by the form + RISet = fd.RISet + #XZ, 12/12/2008: get species infomation + species = webqtlDatabaseFunction.retrieveSpecies(cursor=cursor, RISet=RISet) + return species + + +def sortTraitCorrelations(traits, method="1"): + if method in TISSUE_METHODS: + traits.sort(key=lambda trait: trait.tissue_corr != None and abs(trait.tissue_corr), reverse=True) + elif method == METHOD_LIT: + traits.sort(key=lambda trait: trait.lit_corr != None and abs(trait.lit_corr), reverse=True) + else: + traits.sort(key=lambda trait: trait.correlation != None and abs(trait.correlation), reverse=True) + + return traits + + +def auth_user_for_db(db, cursor, target_db_name, privilege, username): + """Authorize a user for access to a database if that database is + confidential. A db (identified by a record in ProbeSetFreeze) contains a + list of authorized users who may access it, as well as its confidentiality + level. + + If the current user's privilege level is greater than 'user', ie: root or + admin, then they are automatically authed, otherwise, check the + AuthorizedUsers field for the presence of their name.""" + + if db.type == 'ProbeSet': + cursor.execute('SELECT Id, Name, FullName, confidentiality, AuthorisedUsers FROM ProbeSetFreeze WHERE Name = "%s"' % target_db_name) + indId, indName, indFullName, confidential, AuthorisedUsers = cursor.fetchall()[0] + + if confidential: + authorized = 0 + + #for the dataset that confidentiality is 1 + #1. 'admin' and 'root' can see all of the dataset + #2. 'user' can see the dataset that AuthorisedUsers contains his id(stored in the Id field of User table) + if webqtlConfig.USERDICT[privilege] > webqtlConfig.USERDICT['user']: + authorized = 1 + else: + if username in AuthorisedUsers.split(","): + authorized = 1 + + if not authorized: + raise AuthException("The %s database you selected is not open to the public at this time, please go back and select other database." % indFullName) + + +class CorrelationPage(templatePage): + + corrMinInformative = 4 + + PAGE_HEADING = "Correlation Table" + CORRELATION_METHODS = {"1" : "Genetic Correlation (Pearson's r)", + "2" : "Genetic Correlation (Spearman's rho)", + "3" : "SGO Literature Correlation", + "4" : "Tissue Correlation (Pearson's r)", + "5" : "Tissue Correlation (Spearman's rho)"} + + RANK_ORDERS = {"1": 0, "2": 1, "3": 0, "4": 0, "5": 1} + + + def error(self, message, error="Error", heading = None): + heading = heading or self.PAGE_HEADING + return templatePage.error(heading = heading, detail = [message], error=error) + + def __init__(self, fd): + print("in CorrelationPage __init__ fd is:", pf(fd.__dict__)) + # Call the superclass constructor + templatePage.__init__(self, fd) + print("in CorrelationPage __init__ now fd is:", pf(fd.__dict__)) + # Connect to the database + if not self.openMysql(): + return + + # Read the genotype from a file + if not fd.genotype: + fd.readGenotype() + + sample_list = get_sample_data(fd) + mdp_choice = get_mdp_choice(fd) # No idea what this is yet + self.species = get_species(fd, self.cursor) + + #XZ, 09/18/2008: get all information about the user selected database. + target_db_name = fd.formdata.getvalue('database') + self.target_db_name = target_db_name + + try: + self.db = webqtlDataset(target_db_name, self.cursor) + except: + detail = ["The database you just requested has not been established yet."] + self.error(detail) + return + + # Auth if needed + try: + auth_user_for_db(self.db, self.cursor, target_db_name, self.privilege, self.userName) + except AuthException, e: + detail = [e.message] + return self.error(detail) + + #XZ, 09/18/2008: filter out the strains that have no value. + self.sample_names, vals, vars, N = fd.informativeStrains(sample_list) + + #CF - If less than a minimum number of strains/cases in common, don't calculate anything + if len(self.sample_names) < self.corrMinInformative: + detail = ['Fewer than %d strain data were entered for %s data set. No calculation of correlation has been attempted.' % (self.corrMinInformative, fd.RISet)] + self.error(heading=PAGE_HEADING,detail=detail) + + + self.method = get_correlation_method_key(fd) + correlation_method = self.CORRELATION_METHODS[self.method] + rankOrder = self.RANK_ORDERS[self.method] + + # CF - Number of results returned + self.returnNumber = int(fd.formdata.getvalue('criteria')) + + self.record_count = 0 + + myTrait = get_custom_trait(fd, self.cursor) + + + # We will not get Literature Correlations if there is no GeneId because there is nothing to look against + self.gene_id = int(fd.formdata.getvalue('GeneId') or 0) + + # We will not get Tissue Correlations if there is no gene symbol because there is nothing to look against + self.trait_symbol = myTrait.symbol + + + #XZ, 12/12/2008: if the species is rat or human, translate the geneid to mouse geneid + self.input_trait_mouse_gene_id = self.translateToMouseGeneID(self.species, self.gene_id) + + #XZ: As of Nov/13/2010, this dataset is 'UTHSC Illumina V6.2 RankInv B6 D2 average CNS GI average (May 08)' + self.tissue_probeset_freeze_id = 1 + + traitList = self.correlate(vals) + + _log.info("Done doing correlation calculation") + +############################################################################################################################################ + + TD_LR = HT.TD(height=200,width="100%",bgColor='#eeeeee') + + mainfmName = webqtlUtil.genRandStr("fm_") + form = HT.Form(cgi= os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), enctype='multipart/form-data', name= mainfmName, submit=HT.Input(type='hidden')) + hddn = {'FormID': 'showDatabase', + 'ProbeSetID': '_', + 'database': self.target_db_name, + 'databaseFull': self.db.fullname, + 'CellID': '_', + 'RISet': fd.RISet, + 'identification': fd.identification} + + if myTrait: + hddn['fullname']=fd.formdata.getvalue('fullname') + if mdp_choice: + hddn['MDPChoice']=mdp_choice + + + #XZ, 09/18/2008: pass the trait data to next page by hidden parameters. + webqtlUtil.exportData(hddn, fd.allTraitData) + + if fd.incparentsf1: + hddn['incparentsf1']='ON' + + if fd.allstrainlist: + hddn['allstrainlist'] = string.join(fd.allstrainlist, ' ') + + + for key in hddn.keys(): + form.append(HT.Input(name=key, value=hddn[key], type='hidden')) + + #XZ, 11/21/2008: add two parameters to form + form.append(HT.Input(name="X_geneSymbol", value="", type='hidden')) + form.append(HT.Input(name="Y_geneSymbol", value="", type='hidden')) + + #XZ, 3/11/2010: add one parameter to record if the method is rank order. + form.append(HT.Input(name="rankOrder", value="%s" % rankOrder, type='hidden')) + + form.append(HT.Input(name="TissueProbeSetFreezeId", value="%s" % self.tissue_probeset_freeze_id, type='hidden')) + + #################################### + # generate the info on top of page # + #################################### + + info = self.getTopInfo(myTrait=myTrait, method=self.method, db=self.db, target_db_name=self.target_db_name, returnNumber=self.returnNumber, methodDict=self.CORRELATION_METHODS, totalTraits=traitList, identification=fd.identification ) + + ############## + # Excel file # + ############## + filename= webqtlUtil.genRandStr("Corr_") + xlsUrl = HT.Input(type='button', value = 'Download Table', onClick= "location.href='/tmp/%s.xls'" % filename, Class='button') + # Create a new Excel workbook + workbook = xl.Writer('%s.xls' % (webqtlConfig.TMPDIR+filename)) + headingStyle = workbook.add_format(align = 'center', bold = 1, border = 1, size=13, fg_color = 0x1E, color="white") + + #XZ, 3/18/2010: pay attention to the line number of header in this file. As of today, there are 7 lines. + worksheet = self.createExcelFileWithTitleAndFooter(workbook=workbook, identification=fd.identification, db=self.db, returnNumber=self.returnNumber) + + newrow = 7 + + +##################################################################### + + + #Select All, Deselect All, Invert Selection, Add to Collection + mintmap = HT.Href(url="#redirect", onClick="databaseFunc(document.getElementsByName('%s')[0], 'showIntMap');" % mainfmName) + mintmap_img = HT.Image("/images/multiple_interval_mapping1_final.jpg", name='mintmap', alt="Multiple Interval Mapping", title="Multiple Interval Mapping", style="border:none;") + mintmap.append(mintmap_img) + mcorr = HT.Href(url="#redirect", onClick="databaseFunc(document.getElementsByName('%s')[0], 'compCorr');" % mainfmName) + mcorr_img = HT.Image("/images/compare_correlates2_final.jpg", alt="Compare Correlates", title="Compare Correlates", style="border:none;") + mcorr.append(mcorr_img) + cormatrix = HT.Href(url="#redirect", onClick="databaseFunc(document.getElementsByName('%s')[0], 'corMatrix');" % mainfmName) + cormatrix_img = HT.Image("/images/correlation_matrix1_final.jpg", alt="Correlation Matrix and PCA", title="Correlation Matrix and PCA", style="border:none;") + cormatrix.append(cormatrix_img) + networkGraph = HT.Href(url="#redirect", onClick="databaseFunc(document.getElementsByName('%s')[0], 'networkGraph');" % mainfmName) + networkGraph_img = HT.Image("/images/network_graph1_final.jpg", name='mintmap', alt="Network Graphs", title="Network Graphs", style="border:none;") + networkGraph.append(networkGraph_img) + heatmap = HT.Href(url="#redirect", onClick="databaseFunc(document.getElementsByName('%s')[0], 'heatmap');" % mainfmName) + heatmap_img = HT.Image("/images/heatmap2_final.jpg", name='mintmap', alt="QTL Heat Map and Clustering", title="QTL Heatmap and Clustering", style="border:none;") + heatmap.append(heatmap_img) + partialCorr = HT.Href(url="#redirect", onClick="databaseFunc(document.getElementsByName('%s')[0], 'partialCorrInput');" % mainfmName) + partialCorr_img = HT.Image("/images/partial_correlation_final.jpg", name='partialCorr', alt="Partial Correlation", title="Partial Correlation", style="border:none;") + partialCorr.append(partialCorr_img) + addselect = HT.Href(url="#redirect", onClick="addRmvSelection('%s', document.getElementsByName('%s')[0], 'addToSelection');" % (fd.RISet, mainfmName)) + addselect_img = HT.Image("/images/add_collection1_final.jpg", name="addselect", alt="Add To Collection", title="Add To Collection", style="border:none;") + addselect.append(addselect_img) + selectall = HT.Href(url="#redirect", onClick="checkAll(document.getElementsByName('%s')[0]);" % mainfmName) + selectall_img = HT.Image("/images/select_all2_final.jpg", name="selectall", alt="Select All", title="Select All", style="border:none;") + selectall.append(selectall_img) + selectinvert = HT.Href(url="#redirect", onClick = "checkInvert(document.getElementsByName('%s')[0]);" % mainfmName) + selectinvert_img = HT.Image("/images/invert_selection2_final.jpg", name="selectinvert", alt="Invert Selection", title="Invert Selection", style="border:none;") + selectinvert.append(selectinvert_img) + reset = HT.Href(url="#redirect", onClick="checkNone(document.getElementsByName('%s')[0]); return false;" % mainfmName) + reset_img = HT.Image("/images/select_none2_final.jpg", alt="Select None", title="Select None", style="border:none;") + reset.append(reset_img) + selecttraits = HT.Input(type='button' ,name='selecttraits',value='Select Traits', onClick="checkTraits(this.form);",Class="button") + selectgt = HT.Input(type='text' ,name='selectgt',value='-1.0', size=6,maxlength=10,onChange="checkNumeric(this,1.0,'-1.0','gthan','greater than filed')") + selectlt = HT.Input(type='text' ,name='selectlt',value='1.0', size=6,maxlength=10,onChange="checkNumeric(this,-1.0,'1.0','lthan','less than field')") + selectandor = HT.Select(name='selectandor') + selectandor.append(('AND','and')) + selectandor.append(('OR','or')) + selectandor.selected.append('AND') + + + #External analysis tools + GCATButton = HT.Href(url="#redirect", onClick="databaseFunc(document.getElementsByName('%s')[0], 'GCAT');" % mainfmName) + GCATButton_img = HT.Image("/images/GCAT_logo_final.jpg", name="GCAT", alt="GCAT", title="GCAT", style="border:none") + GCATButton.append(GCATButton_img) + + ODE = HT.Href(url="#redirect", onClick="databaseFunc(document.getElementsByName('%s')[0], 'ODE');" % mainfmName) + ODE_img = HT.Image("/images/ODE_logo_final.jpg", name="ode", alt="ODE", title="ODE", style="border:none") + ODE.append(ODE_img) + + ''' + #XZ, 07/07/2010: I comment out this block of code. + WebGestaltScript = HT.Script(language="Javascript") + WebGestaltScript.append(""" +setTimeout('openWebGestalt()', 2000); +function openWebGestalt(){ +var thisForm = document['WebGestalt']; +makeWebGestaltTree(thisForm, '%s', %d, 'edag_only.php'); +} + """ % (mainfmName, len(traitList))) + ''' + + self.cursor.execute('SELECT GeneChip.GO_tree_value FROM GeneChip, ProbeFreeze, ProbeSetFreeze WHERE GeneChip.Id = ProbeFreeze.ChipId and ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id and ProbeSetFreeze.Name = "%s"' % self.db.name) + result = self.cursor.fetchone() + + if result: + GO_tree_value = result[0] + + if GO_tree_value: + + WebGestalt = HT.Href(url="#redirect", onClick="databaseFunc(document.getElementsByName('%s')[0], 'GOTree');" % mainfmName) + WebGestalt_img = HT.Image("/images/webgestalt_icon_final.jpg", name="webgestalt", alt="Gene Set Analysis Toolkit", title="Gene Set Analysis Toolkit", style="border:none") + WebGestalt.append(WebGestalt_img) + + hddnWebGestalt = { + 'id_list':'', + 'correlation':'', + 'id_value':'', + 'llid_list':'', + 'id_type':GO_tree_value, + 'idtype':'', + 'species':'', + 'list':'', + 'client':''} + + hddnWebGestalt['ref_type'] = hddnWebGestalt['id_type'] + hddnWebGestalt['cat_type'] = 'GO' + hddnWebGestalt['significancelevel'] = 'Top10' + + if self.species == 'rat': + hddnWebGestalt['org'] = 'Rattus norvegicus' + elif self.species == 'human': + hddnWebGestalt['org'] = 'Homo sapiens' + elif self.species == 'mouse': + hddnWebGestalt['org'] = 'Mus musculus' + else: + hddnWebGestalt['org'] = '' + + for key in hddnWebGestalt.keys(): + form.append(HT.Input(name=key, value=hddnWebGestalt[key], type='hidden')) + + + #Create tables with options, etc + + pageTable = HT.TableLite(cellSpacing=0,cellPadding=0,width="100%", border=0, align="Left") + + containerTable = HT.TableLite(cellSpacing=0,cellPadding=0,width="90%",border=0, align="Left") + + + if not GO_tree_value: + optionsTable = HT.TableLite(cellSpacing=2, cellPadding=0,width="480", height="80", border=0, align="Left") + optionsTable.append(HT.TR(HT.TD(selectall), HT.TD(reset), HT.TD(selectinvert), HT.TD(addselect), HT.TD(GCATButton), HT.TD(ODE), align="left")) + optionsTable.append(HT.TR(HT.TD(" "*1,"Select"), HT.TD("Deselect"), HT.TD(" "*1,"Invert"), HT.TD(" "*3,"Add"), HT.TD("Gene Set"), HT.TD(" "*2,"GCAT"))) + else: + optionsTable = HT.TableLite(cellSpacing=2, cellPadding=0,width="560", height="80", border=0, align="Left") + optionsTable.append(HT.TR(HT.TD(selectall), HT.TD(reset), HT.TD(selectinvert), HT.TD(addselect), HT.TD(GCATButton), HT.TD(ODE), HT.TD(WebGestalt), align="left")) + optionsTable.append(HT.TR(HT.TD(" "*1,"Select"), HT.TD("Deselect"), HT.TD(" "*1,"Invert"), HT.TD(" "*3,"Add"), HT.TD("Gene Set"), HT.TD(" "*2,"GCAT"), HT.TD(" "*3, "ODE"))) + containerTable.append(HT.TR(HT.TD(optionsTable))) + + functionTable = HT.TableLite(cellSpacing=2,cellPadding=0,width="480",height="80", border=0, align="Left") + functionRow = HT.TR(HT.TD(networkGraph, width="16.7%"), HT.TD(cormatrix, width="16.7%"), HT.TD(partialCorr, width="16.7%"), HT.TD(mcorr, width="16.7%"), HT.TD(mintmap, width="16.7%"), HT.TD(heatmap), align="left") + labelRow = HT.TR(HT.TD(" "*1,HT.Text("Graph")), HT.TD(" "*1,HT.Text("Matrix")), HT.TD(" "*1,HT.Text("Partial")), HT.TD(HT.Text("Compare")), HT.TD(HT.Text("QTL Map")), HT.TD(HT.Text(text="Heat Map"))) + functionTable.append(functionRow, labelRow) + containerTable.append(HT.TR(HT.TD(functionTable), HT.BR())) + + #more_options = HT.Image("/images/more_options1_final.jpg", name='more_options', alt="Expand Options", title="Expand Options", style="border:none;", Class="toggleShowHide") + + #containerTable.append(HT.TR(HT.TD(more_options, HT.BR(), HT.BR()))) + + moreOptions = HT.Input(type='button',name='options',value='More Options', onClick="",Class="toggle") + fewerOptions = HT.Input(type='button',name='options',value='Fewer Options', onClick="",Class="toggle") + + """ + if (fd.formdata.getvalue('showHideOptions') == 'less'): + containerTable.append(HT.TR(HT.TD(" "), height="10"), HT.TR(HT.TD(HT.Div(fewerOptions, Class="toggleShowHide")))) + containerTable.append(HT.TR(HT.TD(" "))) + else: + containerTable.append(HT.TR(HT.TD(" "), height="10"), HT.TR(HT.TD(HT.Div(moreOptions, Class="toggleShowHide")))) + containerTable.append(HT.TR(HT.TD(" "))) + """ + + containerTable.append(HT.TR(HT.TD(HT.Span(selecttraits,' with r > ',selectgt, ' ',selectandor, ' r < ',selectlt,Class="bd1 cbddf fs11")), style="display:none;", Class="extra_options")) + + chrMenu = HT.Input(type='hidden',name='chromosomes',value='all') + + corrHeading = HT.Paragraph('Correlation Table', Class="title") + + + tblobj = {} + + if self.db.type=="Geno": + containerTable.append(HT.TR(HT.TD(xlsUrl, height=60))) + + pageTable.append(HT.TR(HT.TD(containerTable))) + + tblobj['header'], worksheet = self.getTableHeaderForGeno( method=self.method, worksheet=worksheet, newrow=newrow, headingStyle=headingStyle) + newrow += 1 + + sortby = self.getSortByValue( calculationMethod = self.method ) + + corrScript = HT.Script(language="Javascript") + corrScript.append("var corrArray = new Array();") + + tblobj['body'], worksheet, corrScript = self.getTableBodyForGeno(traitList=traitList, formName=mainfmName, worksheet=worksheet, newrow=newrow, corrScript=corrScript) + + workbook.close() + objfile = open('%s.obj' % (webqtlConfig.TMPDIR+filename), 'wb') + cPickle.dump(tblobj, objfile) + objfile.close() + + div = HT.Div(webqtlUtil.genTableObj(tblobj=tblobj, file=filename, sortby=sortby, tableID = "sortable", addIndex = "1"), corrScript, Id="sortable") + + pageTable.append(HT.TR(HT.TD(div))) + + form.append(HT.Input(name='ShowStrains',type='hidden', value =1), + HT.Input(name='ShowLine',type='hidden', value =1), + HT.P(), HT.P(), pageTable) + TD_LR.append(corrHeading, info, form, HT.P()) + + self.dict['body'] = str(TD_LR) + self.dict['js1'] = '' + self.dict['title'] = 'Correlation' + + elif self.db.type=="Publish": + + containerTable.append(HT.TR(HT.TD(xlsUrl, height=40))) + + pageTable.append(HT.TR(HT.TD(containerTable))) + + tblobj['header'], worksheet = self.getTableHeaderForPublish(method=self.method, worksheet=worksheet, newrow=newrow, headingStyle=headingStyle) + newrow += 1 + + sortby = self.getSortByValue( calculationMethod = self.method ) + + corrScript = HT.Script(language="Javascript") + corrScript.append("var corrArray = new Array();") + + tblobj['body'], worksheet, corrScript = self.getTableBodyForPublish(traitList=traitList, formName=mainfmName, worksheet=worksheet, newrow=newrow, corrScript=corrScript, species=self.species) + + workbook.close() + + objfile = open('%s.obj' % (webqtlConfig.TMPDIR+filename), 'wb') + cPickle.dump(tblobj, objfile) + objfile.close() + # NL, 07/27/2010. genTableObj function has been moved from templatePage.py to webqtlUtil.py; + div = HT.Div(webqtlUtil.genTableObj(tblobj=tblobj, file=filename, sortby=sortby, tableID = "sortable", addIndex = "1"), corrScript, Id="sortable") + + pageTable.append(HT.TR(HT.TD(div))) + + form.append( + HT.Input(name='ShowStrains',type='hidden', value =1), + HT.Input(name='ShowLine',type='hidden', value =1), + HT.P(), pageTable) + TD_LR.append(corrHeading, info, form, HT.P()) + + self.dict['body'] = str(TD_LR) + self.dict['js1'] = '' + self.dict['title'] = 'Correlation' + + + elif self.db.type=="ProbeSet": + tblobj['header'], worksheet = self.getTableHeaderForProbeSet(method=self.method, worksheet=worksheet, newrow=newrow, headingStyle=headingStyle) + newrow += 1 + + sortby = self.getSortByValue( calculationMethod = self.method ) + + corrScript = HT.Script(language="Javascript") + corrScript.append("var corrArray = new Array();") + + tblobj['body'], worksheet, corrScript = self.getTableBodyForProbeSet(traitList=traitList, primaryTrait=myTrait, formName=mainfmName, worksheet=worksheet, newrow=newrow, corrScript=corrScript, species=self.species) + + workbook.close() + objfile = open('%s.obj' % (webqtlConfig.TMPDIR+filename), 'wb') + cPickle.dump(tblobj, objfile) + objfile.close() + + #XZ: here is the table of traits + div = HT.Div(webqtlUtil.genTableObj(tblobj=tblobj, file=filename, sortby=sortby, tableID = "sortable", addIndex = "1", hiddenColumns=["Gene ID","Homologene ID"]), corrScript, Id="sortable") + + + #XZ, 01/12/2009: create database menu for 'Add Correlation' + self.cursor.execute(""" + select + ProbeSetFreeze.FullName, ProbeSetFreeze.Id, Tissue.name + from + ProbeSetFreeze, ProbeFreeze, ProbeSetFreeze as ps2, ProbeFreeze as p2, Tissue + where + ps2.Id = %d + and ps2.ProbeFreezeId = p2.Id + and ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id + and (ProbeFreeze.InbredSetId = p2.InbredSetId or (ProbeFreeze.InbredSetId in (1, 3) and p2.InbredSetId in (1, 3))) + and p2.ChipId = ProbeFreeze.ChipId + and ps2.Id != ProbeSetFreeze.Id + and ProbeFreeze.TissueId = Tissue.Id + and ProbeSetFreeze.public > %d + order by + ProbeFreeze.TissueId, ProbeSetFreeze.CreateTime desc + """ % (self.db.id, webqtlConfig.PUBLICTHRESH)) + + results = self.cursor.fetchall() + dbCustomizer = HT.Select(results, name = "customizer") + databaseMenuSub = preTissue = "" + for item in results: + TName, TId, TTissue = item + if TTissue != preTissue: + if databaseMenuSub: + dbCustomizer.append(databaseMenuSub) + databaseMenuSub = HT.Optgroup(label = '%s mRNA ------' % TTissue) + preTissue = TTissue + + databaseMenuSub.append(item[:2]) + if databaseMenuSub: + dbCustomizer.append(databaseMenuSub) + + #updated by NL. Delete function generateJavaScript, move js files to dhtml.js, webqtl.js and jqueryFunction.js + #variables: filename, strainIds and vals are required by getquerystring function + strainIds=self.getStrainIds(species=self.species, strains=self.sample_names) + var1 = HT.Input(name="filename", value=filename, type='hidden') + var2 = HT.Input(name="strainIds", value=strainIds, type='hidden') + var3 = HT.Input(name="vals", value=vals, type='hidden') + customizerButton = HT.Input(type="button", Class="button", value="Add Correlation", onClick = "xmlhttpPost('%smain.py?FormID=AJAX_table', 'sortable', (getquerystring(this.form)))" % webqtlConfig.CGIDIR) + + containerTable.append(HT.TR(HT.TD(HT.Span(var1,var2,var3,customizerButton, "with", dbCustomizer, Class="bd1 cbddf fs11"), HT.BR(), HT.BR()), style="display:none;", Class="extra_options")) + + containerTable.append(HT.TR(HT.TD(xlsUrl, HT.BR(), HT.BR()))) + + pageTable.append(HT.TR(HT.TD(containerTable))) + + pageTable.append(HT.TR(HT.TD(div))) + + if self.species == 'human': + heatmap = "" + + form.append(HT.Input(name='ShowStrains',type='hidden', value =1), + HT.Input(name='ShowLine',type='hidden', value =1), + info, HT.BR(), pageTable, HT.BR()) + + TD_LR.append(corrHeading, form, HT.P()) + + + self.dict['body'] = str(TD_LR) + self.dict['title'] = 'Correlation' + # updated by NL. Delete function generateJavaScript, move js files to dhtml.js, webqtl.js and jqueryFunction.js + self.dict['js1'] = '' + self.dict['js2'] = 'onLoad="pageOffset()"' + self.dict['layer'] = self.generateWarningLayer() + else: + self.dict['body'] = "" + + +############################# +# # +# CorrelationPage Functions # +# # +############################# + + + def getSortByValue(self, calculationMethod): + + if calculationMethod == "1": + sortby = ("Sample p(r)", "up") + elif calculationMethod == "2": + sortby = ("Sample p(rho)", "up") + elif calculationMethod == "3": #XZ: literature correlation + sortby = ("Lit Corr","down") + elif calculationMethod == "4": #XZ: tissue correlation + sortby = ("Tissue r", "down") + elif calculationMethod == "5": + sortby = ("Tissue rho", "down") + + return sortby + + + + def generateWarningLayer(self): + + layerString = """ + + + + + """ + + return layerString + + + #XZ, 01/07/2009: In HTML code, the variable 'database' corresponds to the column 'Name' in database table. + def getFileName(self, target_db_name): ### dcrowell August 2008 + """Returns the name of the reference database file with which correlations are calculated. + Takes argument cursor which is a cursor object of any instance of a subclass of templatePage + Used by correlationPage""" + + query = 'SELECT Id, FullName FROM ProbeSetFreeze WHERE Name = "%s"' % target_db_name + self.cursor.execute(query) + result = self.cursor.fetchone() + Id = result[0] + FullName = result[1] + FullName = FullName.replace(' ','_') + FullName = FullName.replace('/','_') + + FileName = 'ProbeSetFreezeId_' + str(Id) + '_FullName_' + FullName + '.txt' + + return FileName + + + #XZ, 01/29/2009: I modified this function. + #XZ: Note that the type of StrainIds must be number, not string. + def getStrainIds(self, species=None, strains=[]): + StrainIds = [] + for item in strains: + self.cursor.execute('''SELECT Strain.Id FROM Strain, Species WHERE + Strain.Name="%s" and Strain.SpeciesId=Species.Id and Species.name = "%s" ''' % (item, species)) + Id = self.cursor.fetchone()[0] + StrainIds.append(Id) + + return StrainIds + + + #XZ, 12/12/2008: if the species is rat or human, translate the geneid to mouse geneid + #XZ, 12/12/2008: if the input geneid is 'None', return 0 + #XZ, 12/12/2008: if the input geneid has no corresponding mouse geneid, return 0 + def translateToMouseGeneID (self, species, geneid): + mouse_geneid = 0; + + #if input geneid is None, return 0. + if not geneid: + return mouse_geneid + + if species == 'mouse': + mouse_geneid = geneid + elif species == 'rat': + self.cursor.execute( "SELECT mouse FROM GeneIDXRef WHERE rat=%d" % int(geneid) ) + record = self.cursor.fetchone() + if record: + mouse_geneid = record[0] + elif species == 'human': + self.cursor.execute( "SELECT mouse FROM GeneIDXRef WHERE human=%d" % int(geneid) ) + record = self.cursor.fetchone() + if record: + mouse_geneid = record[0] + + return mouse_geneid + + + #XZ, 12/16/2008: the input geneid is of mouse type + def checkForLitInfo(self,geneId): + q = 'SELECT 1 FROM LCorrRamin3 WHERE GeneId1=%s LIMIT 1' % geneId + self.cursor.execute(q) + try: + x = self.cursor.fetchone() + if x: return True + else: raise + except: return False + + + #XZ, 12/16/2008: the input geneid is of mouse type + def checkSymbolForTissueCorr(self, tissueProbeSetFreezeId=0, symbol=""): + q = "SELECT 1 FROM TissueProbeSetXRef WHERE TissueProbeSetFreezeId=%s and Symbol='%s' LIMIT 1" % (tissueProbeSetFreezeId,symbol) + self.cursor.execute(q) + try: + x = self.cursor.fetchone() + if x: return True + else: raise + except: return False + + + + def fetchAllDatabaseData(self, species, GeneId, GeneSymbol, strains, db, method, returnNumber, tissueProbeSetFreezeId): + + StrainIds = [] + for item in strains: + self.cursor.execute('''SELECT Strain.Id FROM Strain, Species WHERE Strain.Name="%s" and Strain.SpeciesId=Species.Id and Species.name = "%s" ''' % (item, species)) + Id = self.cursor.fetchone()[0] + StrainIds.append('%d' % Id) + + # break it into smaller chunks so we don't overload the MySql server + nnn = len(StrainIds) / 25 + if len(StrainIds) % 25: + nnn += 1 + oridata = [] + + #XZ, 09/24/2008: build one temporary table that only contains the records associated with the input GeneId + tempTable = None + if GeneId and db.type == "ProbeSet": + if method == "3": + tempTable = self.getTempLiteratureTable(species=species, input_species_geneid=GeneId, returnNumber=returnNumber) + + if method == "4" or method == "5": + tempTable = self.getTempTissueCorrTable(primaryTraitSymbol=GeneSymbol, TissueProbeSetFreezeId=TISSUE_MOUSE_DB, method=method, returnNumber=returnNumber) + + for step in range(nnn): + temp = [] + StrainIdstep = StrainIds[step*25:min(len(StrainIds), (step+1)*25)] + for item in StrainIdstep: temp.append('T%s.value' % item) + + if db.type == "Publish": + query = "SELECT PublishXRef.Id, " + dataStartPos = 1 + query += string.join(temp,', ') + query += ' FROM (PublishXRef, PublishFreeze)' + #XZ, 03/04/2009: Xiaodong changed Data to PublishData + for item in StrainIdstep: + query += 'left join PublishData as T%s on T%s.Id = PublishXRef.DataId and T%s.StrainId=%s\n' %(item,item,item,item) + query += "WHERE PublishXRef.InbredSetId = PublishFreeze.InbredSetId and PublishFreeze.Name = '%s'" % (db.name, ) + #XZ, 09/20/2008: extract literature correlation value together with gene expression values. + #XZ, 09/20/2008: notice the difference between the code in next block. + elif tempTable: + # we can get a little performance out of selecting our LitCorr here + # but also we need to do this because we are unconcerned with probes that have no geneId associated with them + # as we would not have litCorr data. + + if method == "3": + query = "SELECT %s.Name, %s.value," % (db.type,tempTable) + dataStartPos = 2 + if method == "4" or method == "5": + query = "SELECT %s.Name, %s.Correlation, %s.PValue," % (db.type,tempTable, tempTable) + dataStartPos = 3 + + query += string.join(temp,', ') + query += ' FROM (%s, %sXRef, %sFreeze)' % (db.type, db.type, db.type) + if method == "3": + query += ' LEFT JOIN %s ON %s.GeneId2=ProbeSet.GeneId ' % (tempTable,tempTable) + if method == "4" or method == "5": + query += ' LEFT JOIN %s ON %s.Symbol=ProbeSet.Symbol ' % (tempTable,tempTable) + #XZ, 03/04/2009: Xiaodong changed Data to %sData and changed parameters from %(item,item, db.type,item,item) to %(db.type, item,item, db.type,item,item) + for item in StrainIdstep: + query += 'left join %sData as T%s on T%s.Id = %sXRef.DataId and T%s.StrainId=%s\n' %(db.type, item,item, db.type,item,item) + + if method == "3": + query += "WHERE ProbeSet.GeneId IS NOT NULL AND %s.value IS NOT NULL AND %sXRef.%sFreezeId = %sFreeze.Id and %sFreeze.Name = '%s' and %s.Id = %sXRef.%sId order by %s.Id" % (tempTable,db.type, db.type, db.type, db.type, db.name, db.type, db.type, db.type, db.type) + if method == "4" or method == "5": + query += "WHERE ProbeSet.Symbol IS NOT NULL AND %s.Correlation IS NOT NULL AND %sXRef.%sFreezeId = %sFreeze.Id and %sFreeze.Name = '%s' and %s.Id = %sXRef.%sId order by %s.Id" % (tempTable,db.type, db.type, db.type, db.type, db.name, db.type, db.type, db.type, db.type) + else: + query = "SELECT %s.Name," % db.type + dataStartPos = 1 + query += string.join(temp,', ') + query += ' FROM (%s, %sXRef, %sFreeze)' % (db.type, db.type, db.type) + #XZ, 03/04/2009: Xiaodong changed Data to %sData and changed parameters from %(item,item, db.type,item,item) to %(db.type, item,item, db.type,item,item) + for item in StrainIdstep: + query += 'left join %sData as T%s on T%s.Id = %sXRef.DataId and T%s.StrainId=%s\n' %(db.type, item,item, db.type,item,item) + query += "WHERE %sXRef.%sFreezeId = %sFreeze.Id and %sFreeze.Name = '%s' and %s.Id = %sXRef.%sId order by %s.Id" % (db.type, db.type, db.type, db.type, db.name, db.type, db.type, db.type, db.type) + + self.cursor.execute(query) + results = self.cursor.fetchall() + oridata.append(results) + + datasize = len(oridata[0]) + traits = [] + # put all of the separate data together into a huge list of lists + for j in range(datasize): + traitdata = list(oridata[0][j]) + for i in range(1,nnn): + traitdata += list(oridata[i][j][dataStartPos:]) + + trait = Trait(traitdata[0], traitdata[dataStartPos:]) + + if method == METHOD_LIT: + trait.lit_corr = traitdata[1] + + if method in TISSUE_METHODS: + trait.tissue_corr = traitdata[1] + trait.p_tissue = traitdata[2] + + traits.append(trait) + + if tempTable: + self.cursor.execute( 'DROP TEMPORARY TABLE %s' % tempTable ) + + return traits + + + + + # XZ, 09/20/2008: This function creates TEMPORARY TABLE tmpTableName_2 and return its name. + # XZ, 09/20/2008: It stores top literature correlation values associated with the input geneId. + # XZ, 09/20/2008: Attention: In each row, the input geneId is always in column GeneId1. + #XZ, 12/16/2008: the input geneid can be of mouse, rat or human type + def getTempLiteratureTable(self, species, input_species_geneid, returnNumber): + # according to mysql the TEMPORARY TABLE name should not have to be unique because + # it is only available to the current connection. This program will be invoked via command line, but if it + # were to be invoked over mod_python this could cuase problems. mod_python will keep the connection alive + # in its executing threads ( i think) so there is a potential for the table not being dropped between users. + #XZ, 01/29/2009: To prevent the potential risk, I generate random table names and drop the tables after use them. + + + # the 'input_species_geneid' could be rat or human geneid, need to translate it to mouse geneid + translated_mouse_geneid = self.translateToMouseGeneID (species, input_species_geneid) + + tmpTableName_1 = webqtlUtil.genRandStr(prefix="LITERATURE") + + q1 = 'CREATE TEMPORARY TABLE %s (GeneId1 int(12) unsigned, GeneId2 int(12) unsigned PRIMARY KEY, value double)' % tmpTableName_1 + q2 = 'INSERT INTO %s (GeneId1, GeneId2, value) SELECT GeneId1,GeneId2,value FROM LCorrRamin3 WHERE GeneId1=%s' % (tmpTableName_1, translated_mouse_geneid) + q3 = 'INSERT INTO %s (GeneId1, GeneId2, value) SELECT GeneId2,GeneId1,value FROM LCorrRamin3 WHERE GeneId2=%s AND GeneId1!=%s' % (tmpTableName_1, translated_mouse_geneid,translated_mouse_geneid) + for x in [q1,q2,q3]: self.cursor.execute(x) + + #XZ, 09/23/2008: Just use the top records insteard of using all records + tmpTableName_2 = webqtlUtil.genRandStr(prefix="TOPLITERATURE") + + q1 = 'CREATE TEMPORARY TABLE %s (GeneId1 int(12) unsigned, GeneId2 int(12) unsigned PRIMARY KEY, value double)' % tmpTableName_2 + self.cursor.execute(q1) + q2 = 'SELECT GeneId1, GeneId2, value FROM %s ORDER BY value DESC' % tmpTableName_1 + self.cursor.execute(q2) + result = self.cursor.fetchall() + + counter = 0 #this is to count how many records being inserted into table + for one_row in result: + mouse_geneid1, mouse_geneid2, lit_corr_alue = one_row + + #mouse_geneid1 has been tested before, now should test if mouse_geneid2 has corresponding geneid in other species + translated_species_geneid = 0 + if species == 'mouse': + translated_species_geneid = mouse_geneid2 + elif species == 'rat': + self.cursor.execute( "SELECT rat FROM GeneIDXRef WHERE mouse=%d" % int(mouse_geneid2) ) + record = self.cursor.fetchone() + if record: + translated_species_geneid = record[0] + elif species == 'human': + self.cursor.execute( "SELECT human FROM GeneIDXRef WHERE mouse=%d" % int(mouse_geneid2) ) + record = self.cursor.fetchone() + if record: + translated_species_geneid = record[0] + + if translated_species_geneid: + self.cursor.execute( 'INSERT INTO %s (GeneId1, GeneId2, value) VALUES (%d,%d,%f)' % (tmpTableName_2, int(input_species_geneid),int(translated_species_geneid), float(lit_corr_alue)) ) + counter = counter + 1 + + #pay attention to the number + if (counter > 2*returnNumber): + break + + self.cursor.execute('DROP TEMPORARY TABLE %s' % tmpTableName_1) + + return tmpTableName_2 + + + + #XZ, 09/23/2008: In tissue correlation tables, there is no record of GeneId1 == GeneId2 + #XZ, 09/24/2008: Note that the correlation value can be negative. + def getTempTissueCorrTable(self, primaryTraitSymbol="", TissueProbeSetFreezeId=0, method="", returnNumber=0): + + def cmpTissCorrAbsoluteValue(A, B): + try: + if abs(A[1]) < abs(B[1]): return 1 + elif abs(A[1]) == abs(B[1]): + return 0 + else: return -1 + except: + return 0 + + symbolCorrDict, symbolPvalueDict = self.calculateCorrOfAllTissueTrait(primaryTraitSymbol=primaryTraitSymbol, TissueProbeSetFreezeId=TISSUE_MOUSE_DB, method=method) + + symbolCorrList = symbolCorrDict.items() + + symbolCorrList.sort(cmpTissCorrAbsoluteValue) + symbolCorrList = symbolCorrList[0 : 2*returnNumber] + + tmpTableName = webqtlUtil.genRandStr(prefix="TOPTISSUE") + + q1 = 'CREATE TEMPORARY TABLE %s (Symbol varchar(100) PRIMARY KEY, Correlation float, PValue float)' % tmpTableName + self.cursor.execute(q1) + + for one_pair in symbolCorrList: + one_symbol = one_pair[0] + one_corr = one_pair[1] + one_p_value = symbolPvalueDict[one_symbol] + + self.cursor.execute( "INSERT INTO %s (Symbol, Correlation, PValue) VALUES ('%s',%f,%f)" % (tmpTableName, one_symbol, float(one_corr), float(one_p_value)) ) + + return tmpTableName + + + #XZ, 01/09/2009: This function was created by David Crowell. Xiaodong cleaned up and modified it. + def fetchLitCorrelations(self, species, GeneId, db, returnNumber): ### Used to generate Lit Correlations when calculations are done from text file. dcrowell August 2008 + """Uses getTempLiteratureTable to generate table of literatire correlations. This function then gathers that data and + pairs it with the TraitID string. Takes as its arguments a formdata instance, and a database instance. + Returns a dictionary of 'TraitID':'LitCorr' for the requested correlation""" + + tempTable = self.getTempLiteratureTable(species=species, input_species_geneid=GeneId, returnNumber=returnNumber) + + query = "SELECT %s.Name, %s.value" % (db.type,tempTable) + query += ' FROM (%s, %sXRef, %sFreeze)' % (db.type, db.type, db.type) + query += ' LEFT JOIN %s ON %s.GeneId2=ProbeSet.GeneId ' % (tempTable,tempTable) + query += "WHERE ProbeSet.GeneId IS NOT NULL AND %s.value IS NOT NULL AND %sXRef.%sFreezeId = %sFreeze.Id and %sFreeze.Name = '%s' and %s.Id = %sXRef.%sId order by %s.Id" % (tempTable, db.type, db.type, db.type, db.type, db.name, db.type, db.type, db.type, db.type) + + self.cursor.execute(query) + results = self.cursor.fetchall() + + litCorrDict = {} + + for entry in results: + traitName,litcorr = entry + litCorrDict[traitName] = litcorr + + self.cursor.execute('DROP TEMPORARY TABLE %s' % tempTable) + + return litCorrDict + + + + #XZ, 01/09/2009: Xiaodong created this function. + def fetchTissueCorrelations(self, db, primaryTraitSymbol="", TissueProbeSetFreezeId=0, method="", returnNumber = 0): + """Uses getTempTissueCorrTable to generate table of tissue correlations. This function then gathers that data and + pairs it with the TraitID string. Takes as its arguments a formdata instance, and a database instance. + Returns a dictionary of 'TraitID':(tissueCorr, tissuePValue) for the requested correlation""" + + + tempTable = self.getTempTissueCorrTable(primaryTraitSymbol=primaryTraitSymbol, TissueProbeSetFreezeId=TISSUE_MOUSE_DB, method=method, returnNumber=returnNumber) + + query = "SELECT ProbeSet.Name, %s.Correlation, %s.PValue" % (tempTable, tempTable) + query += ' FROM (ProbeSet, ProbeSetXRef, ProbeSetFreeze)' + query += ' LEFT JOIN %s ON %s.Symbol=ProbeSet.Symbol ' % (tempTable,tempTable) + query += "WHERE ProbeSetFreeze.Name = '%s' and ProbeSetFreeze.Id=ProbeSetXRef.ProbeSetFreezeId and ProbeSet.Id = ProbeSetXRef.ProbeSetId and ProbeSet.Symbol IS NOT NULL AND %s.Correlation IS NOT NULL" % (db.name, tempTable) + + self.cursor.execute(query) + results = self.cursor.fetchall() + + tissueCorrDict = {} + + for entry in results: + traitName, tissueCorr, tissuePValue = entry + tissueCorrDict[traitName] = (tissueCorr, tissuePValue) + + self.cursor.execute('DROP TEMPORARY TABLE %s' % tempTable) + + return tissueCorrDict + + + + #XZ, 01/13/2008 + def getLiteratureCorrelationByList(self, input_trait_mouse_geneid=None, species=None, traitList=None): + + tmpTableName = webqtlUtil.genRandStr(prefix="LITERATURE") + + q1 = 'CREATE TEMPORARY TABLE %s (GeneId1 int(12) unsigned, GeneId2 int(12) unsigned PRIMARY KEY, value double)' % tmpTableName + q2 = 'INSERT INTO %s (GeneId1, GeneId2, value) SELECT GeneId1,GeneId2,value FROM LCorrRamin3 WHERE GeneId1=%s' % (tmpTableName, input_trait_mouse_geneid) + q3 = 'INSERT INTO %s (GeneId1, GeneId2, value) SELECT GeneId2,GeneId1,value FROM LCorrRamin3 WHERE GeneId2=%s AND GeneId1!=%s' % (tmpTableName, input_trait_mouse_geneid, input_trait_mouse_geneid) + + for x in [q1,q2,q3]: + self.cursor.execute(x) + + for thisTrait in traitList: + try: + if thisTrait.geneid: + thisTrait.mouse_geneid = self.translateToMouseGeneID(species, thisTrait.geneid) + else: + thisTrait.mouse_geneid = 0 + except: + thisTrait.mouse_geneid = 0 + + if thisTrait.mouse_geneid and str(thisTrait.mouse_geneid).find(";") == -1: + try: + self.cursor.execute("SELECT value FROM %s WHERE GeneId2 = %s" % (tmpTableName, thisTrait.mouse_geneid)) + result = self.cursor.fetchone() + if result: + thisTrait.LCorr = result[0] + else: + thisTrait.LCorr = None + except: + thisTrait.LCorr = None + else: + thisTrait.LCorr = None + + self.cursor.execute("DROP TEMPORARY TABLE %s" % tmpTableName) + + return traitList + + def get_trait(self, cached, vals): + + if cached: + _log.info("Using the fast method because the file exists") + lit_corrs = {} + tissue_corrs = {} + use_lit = False + if self.method == METHOD_LIT: + lit_corrs = self.fetchLitCorrelations(species=self.species, GeneId=self.gene_id, db=self.db, returnNumber=self.returnNumber) + use_lit = True + + use_tissue_corr = False + if self.method in TISSUE_METHODS: + tissue_corrs = self.fetchTissueCorrelations(db=self.db, primaryTraitSymbol=self.trait_symbol, TissueProbeSetFreezeId=TISSUE_MOUSE_DB, method=self.method, returnNumber = self.returnNumber) + use_tissue_corr = True + + DatabaseFileName = self.getFileName( target_db_name=self.target_db_name ) + datasetFile = open(webqtlConfig.TEXTDIR+DatabaseFileName,'r') + + #XZ, 01/08/2009: read the first line + line = datasetFile.readline() + cached_sample_names = webqtlUtil.readLineCSV(line)[1:] + + #XZ, 01/08/2009: This step is critical. It is necessary for this new method. + #XZ: The original function fetchAllDatabaseData uses all strains stored in variable _strains to + #XZ: retrieve the values of each strain from database in real time. + #XZ: The new method uses all strains stored in variable dataset_strains to create a new variable + #XZ: _newvals. _newvals has the same length as dataset_strains. The items in _newvals is in + #XZ: the same order of items in dataset_strains. The value of each item in _newvals is either + #XZ: the value of correspinding strain in _vals or 'None'. + new_vals = [] + for name in cached_sample_names: + if name in self.sample_names: + new_vals.append(float(vals[self.sample_names.index(name)])) + else: + new_vals.append('None') + + nnCorr = len(new_vals) + + #XZ, 01/14/2009: If literature corr or tissue corr is selected, + #XZ: there is no need to use parallel computing. + + traits = [] + data_start = 1 + for line in datasetFile: + raw_trait = webqtlUtil.readLineCSV(line) + trait = Trait.from_csv(raw_trait, data_start) + trait.lit_corr = lit_corrs.get(trait.name) + trait.tissue_corr, trait.p_tissue = tissue_corrs.get(trait.name, (None, None)) + traits.append(trait) + + return traits, new_vals + + else: + _log.info("Using the slow method for correlation") + + _log.info("Fetching from database") + traits = self.fetchAllDatabaseData(species=self.species, GeneId=self.gene_id, GeneSymbol=self.trait_symbol, strains=self.sample_names, db=self.db, method=self.method, returnNumber=self.returnNumber, tissueProbeSetFreezeId= self.tissue_probeset_freeze_id) + _log.info("Done fetching from database") + totalTraits = len(traits) #XZ, 09/18/2008: total trait number + + return traits, vals + + + def do_parallel_correlation(self): + _log.info("Invoking parallel computing") + input_line_list = datasetFile.readlines() + _log.info("Read lines from the file") + all_line_number = len(input_line_list) + + step = 1000 + job_number = math.ceil( float(all_line_number)/step ) + + job_input_lists = [] + + _log.info("Configuring jobs") + + for job_index in range( int(job_number) ): + starti = job_index*step + endi = min((job_index+1)*step, all_line_number) + + one_job_input_list = [] + + for i in range( starti, endi ): + one_job_input_list.append( input_line_list[i] ) + + job_input_lists.append( one_job_input_list ) + + _log.info("Creating pp servers") + + ppservers = () + # Creates jobserver with automatically detected number of workers + job_server = pp.Server(ppservers=ppservers) + + _log.info("Done creating servers") + + jobs = [] + results = [] + + _log.info("Starting parallel computation, submitting jobs") + for one_job_input_list in job_input_lists: #pay attention to modules from outside + jobs.append( job_server.submit(func=compute_corr, args=(nnCorr, _newvals, one_job_input_list, self.method), depfuncs=(), modules=("utility.webqtlUtil",)) ) + _log.info("Done submitting jobs") + + for one_job in jobs: + one_result = one_job() + results.append( one_result ) + + _log.info("Acquiring results") + + for one_result in results: + for one_traitinfo in one_result: + allcorrelations.append( one_traitinfo ) + + _log.info("Appending the results") + + datasetFile.close() + totalTraits = len(allcorrelations) + _log.info("Done correlating using the fast method") + + + def correlate(self, vals): + + correlations = [] + + #XZ: Use the fast method only for probeset dataset, and this dataset must have been created. + #XZ: Otherwise, use original method + _log.info("Entering correlation") + + db_filename = self.getFileName( target_db_name=self.target_db_name ) + + cache_available = db_filename in os.listdir(webqtlConfig.TEXTDIR) + + # If the cache file exists, do a cached correlation for probeset data + if self.db.type == "ProbeSet": +# if self.method in [METHOD_SAMPLE_PEARSON, METHOD_SAMPLE_RANK] and cache_available: +# traits = do_parallel_correlation() +# +# else: + + (traits, vals) = self.get_trait(cache_available, vals) + + for trait in traits: + trait.calculate_correlation(vals, self.method) + + self.record_count = len(traits) #ZS: This isn't a good way to get this value, so I need to change it later + + #XZ, 3/31/2010: Theoretically, we should create one function 'comTissueCorr' + #to compare each trait by their tissue corr p values. + #But because the tissue corr p values are generated by permutation test, + #the top ones always have p value 0. So comparing p values actually does nothing. + #In addition, for the tissue data in our database, the N is always the same. + #So it's safe to compare with tissue corr statistic value. + #That's the same as literature corr. + #if self.method in [METHOD_LIT, METHOD_TISSUE_PEARSON, METHOD_TISSUE_RANK] and self.gene_id: + # traits.sort(webqtlUtil.cmpLitCorr) + #else: + #if self.method in TISSUE_METHODS: + # sort(traits, key=lambda A: math.fabs(A.tissue_corr)) + #elif self.method == METHOD_LIT: + # traits.sort(traits, key=lambda A: math.fabs(A.lit_corr)) + #else: + traits = sortTraitCorrelations(traits, self.method) + + # Strip to the top N correlations + traits = traits[:min(self.returnNumber, len(traits))] + + addLiteratureCorr = False + addTissueCorr = False + + trait_list = [] + for trait in traits: + db_trait = webqtlTrait(db=self.db, name=trait.name, cursor=self.cursor) + db_trait.retrieveInfo( QTL='Yes' ) + + db_trait.Name = trait.name + db_trait.corr = trait.correlation + db_trait.nOverlap = trait.overlap + db_trait.corrPValue = trait.p_value + + # NL, 07/19/2010 + # js function changed, add a new parameter rankOrder for js function 'showTissueCorrPlot' + db_trait.RANK_ORDER = self.RANK_ORDERS[self.method] + + #XZ, 26/09/2008: Method is 4 or 5. Have fetched tissue corr, but no literature correlation yet. + if self.method in TISSUE_METHODS: + db_trait.tissueCorr = trait.tissue_corr + db_trait.tissuePValue = trait.p_tissue + addTissueCorr = True + + + #XZ, 26/09/2008: Method is 3, Have fetched literature corr, but no tissue corr yet. + elif self.method == METHOD_LIT: + db_trait.LCorr = trait.lit_corr + db_trait.mouse_geneid = self.translateToMouseGeneID(self.species, db_trait.geneid) + addLiteratureCorr = True + + #XZ, 26/09/2008: Method is 1 or 2. Have NOT fetched literature corr and tissue corr yet. + # Phenotype data will not have geneid, and neither will some probes + # we need to handle this because we will get an attribute error + else: + if self.input_trait_mouse_gene_id and self.db.type=="ProbeSet": + addLiteratureCorr = True + if self.trait_symbol and self.db.type=="ProbeSet": + addTissueCorr = True + + trait_list.append(db_trait) + + if addLiteratureCorr: + trait_list = self.getLiteratureCorrelationByList(self.input_trait_mouse_gene_id, + self.species, trait_list) + if addTissueCorr: + trait_list = self.getTissueCorrelationByList( + primaryTraitSymbol = self.trait_symbol, + traitList = trait_list, + TissueProbeSetFreezeId = TISSUE_MOUSE_DB, + method=self.method) + + return trait_list + + + def calculateCorrOfAllTissueTrait(self, primaryTraitSymbol=None, TissueProbeSetFreezeId=None, method=None): + + symbolCorrDict = {} + symbolPvalueDict = {} + + primaryTraitSymbolValueDict = correlationFunction.getGeneSymbolTissueValueDictForTrait(cursor=self.cursor, GeneNameLst=[primaryTraitSymbol], TissueProbeSetFreezeId=TISSUE_MOUSE_DB) + primaryTraitValue = primaryTraitSymbolValueDict.values()[0] + + SymbolValueDict = correlationFunction.getGeneSymbolTissueValueDictForTrait(cursor=self.cursor, GeneNameLst=[], TissueProbeSetFreezeId=TISSUE_MOUSE_DB) + + if method in ["2","5"]: + symbolCorrDict, symbolPvalueDict = correlationFunction.batchCalTissueCorr(primaryTraitValue,SymbolValueDict,method='spearman') + else: + symbolCorrDict, symbolPvalueDict = correlationFunction.batchCalTissueCorr(primaryTraitValue,SymbolValueDict) + + + return (symbolCorrDict, symbolPvalueDict) + + + + #XZ, 10/13/2010 + def getTissueCorrelationByList(self, primaryTraitSymbol=None, traitList=None, TissueProbeSetFreezeId=None, method=None): + + primaryTraitSymbolValueDict = correlationFunction.getGeneSymbolTissueValueDictForTrait(cursor=self.cursor, GeneNameLst=[primaryTraitSymbol], TissueProbeSetFreezeId=TISSUE_MOUSE_DB) + + if primaryTraitSymbol.lower() in primaryTraitSymbolValueDict: + primaryTraitValue = primaryTraitSymbolValueDict[primaryTraitSymbol.lower()] + + geneSymbolList = [] + + for thisTrait in traitList: + if hasattr(thisTrait, 'symbol'): + geneSymbolList.append(thisTrait.symbol) + + SymbolValueDict = correlationFunction.getGeneSymbolTissueValueDictForTrait(cursor=self.cursor, GeneNameLst=geneSymbolList, TissueProbeSetFreezeId=TISSUE_MOUSE_DB) + + for thisTrait in traitList: + if hasattr(thisTrait, 'symbol') and thisTrait.symbol and thisTrait.symbol.lower() in SymbolValueDict: + oneTraitValue = SymbolValueDict[thisTrait.symbol.lower()] + if method in ["2","5"]: + result = correlationFunction.calZeroOrderCorrForTiss( primaryTraitValue, oneTraitValue, method='spearman' ) + else: + result = correlationFunction.calZeroOrderCorrForTiss( primaryTraitValue, oneTraitValue) + thisTrait.tissueCorr = result[0] + thisTrait.tissuePValue = result[2] + else: + thisTrait.tissueCorr = None + thisTrait.tissuePValue = None + else: + for thisTrait in traitList: + thisTrait.tissueCorr = None + thisTrait.tissuePValue = None + + return traitList + + + def getTopInfo(self, myTrait=None, method=None, db=None, target_db_name=None, returnNumber=None, methodDict=None, totalTraits=None, identification=None ): + + if myTrait: + if method in ["1","2"]: #genetic correlation + info = HT.Paragraph("Values of Record %s in the " % myTrait.getGivenName(), HT.Href(text=myTrait.db.fullname,url=webqtlConfig.INFOPAGEHREF % myTrait.db.name,target="_blank", Class="fwn"), + " database were compared to all %d records in the " % self.record_count, HT.Href(text=db.fullname,url=webqtlConfig.INFOPAGEHREF % target_db_name,target="_blank", Class="fwn"), + ' database. The top %d correlations ranked by the %s are displayed.' % (returnNumber,methodDict[method]), + ' You can resort this list using the small arrowheads in the top row.') + else: + #myTrait.retrieveInfo()#need to know geneid and symbol + if method == "3":#literature correlation + searchDBName = "Literature Correlation" + searchDBLink = "/correlationAnnotation.html#literatureCorr" + else: #tissue correlation + searchDBName = "Tissue Correlation" + searchDBLink = "/correlationAnnotation.html#tissueCorr" + info = HT.Paragraph("Your input record %s in the " % myTrait.getGivenName(), HT.Href(text=myTrait.db.fullname,url=webqtlConfig.INFOPAGEHREF % myTrait.db.name,target="_blank", Class="fwn"), + " database corresponds to ", + HT.Href(text='gene Id %s, and gene symbol %s' % (myTrait.geneid, myTrait.symbol), target='_blank',url="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=gene&cmd=Retrieve&dopt=Graphics&list_uids=%s" % myTrait.geneid, Class="fs12 fwn"), + '. GN ranked all genes in the ', HT.Href(text=searchDBName,url=searchDBLink,target="_blank", Class="fwn"),' database by the %s.' % methodDict[method], + ' The top %d probes or probesets in the ' % returnNumber, HT.Href(text=db.fullname,url=webqtlConfig.INFOPAGEHREF % target_db_name,target="_blank", Class="fwn"), + ' database corresponding to the top genes ranked by the %s are displayed.' %( methodDict[method]), + ' You can resort this list using the small arrowheads in the top row.' ) + + elif identification: + info = HT.Paragraph('Values of %s were compared to all %d traits in ' % (identification, self.record_count), + HT.Href(text=db.fullname,url=webqtlConfig.INFOPAGEHREF % target_db_name,target="_blank",Class="fwn"), + ' database. The TOP %d correlations ranked by the %s are displayed.' % (returnNumber,methodDict[method]), + ' You can resort this list using the small arrowheads in the top row.') + + else: + info = HT.Paragraph('Trait values were compared to all values in ', + HT.Href(text=db.fullname,url=webqtlConfig.INFOPAGEHREF % target_db_name,target="_blank",Class="fwn"), + ' database. The TOP %d correlations ranked by the %s are displayed.' % (returnNumber,methodDict[method]), + ' You can resort this list using the small arrowheads in the top row.') + + if db.type=="Geno": + info.append(HT.BR(),HT.BR(),'Clicking on the Locus will open the genotypes data for that locus. Click on the correlation to see a scatter plot of the trait data.') + elif db.type=="Publish": + info.append(HT.BR(),HT.BR(),'Clicking on the record ID will open the published phenotype data for that publication. Click on the correlation to see a scatter plot of the trait data. ') + elif db.type=="ProbeSet": + info.append(HT.BR(),'Click the correlation values to generate scatter plots. Select the Record ID to open the Trait Data and Analysis form. Select the symbol to open NCBI Entrez.') + else: + pass + + + return info + + + def createExcelFileWithTitleAndFooter(self, workbook=None, identification=None, db=None, returnNumber=None): + + worksheet = workbook.add_worksheet() + + titleStyle = workbook.add_format(align = 'left', bold = 0, size=14, border = 1, border_color="gray") + + ##Write title Info + # Modified by Hongqiang Li + worksheet.write([1, 0], "Citations: Please see %s/reference.html" % webqtlConfig.PORTADDR, titleStyle) + worksheet.write([1, 0], "Citations: Please see %s/reference.html" % webqtlConfig.PORTADDR, titleStyle) + worksheet.write([2, 0], "Trait : %s" % identification, titleStyle) + worksheet.write([3, 0], "Database : %s" % db.fullname, titleStyle) + worksheet.write([4, 0], "Date : %s" % time.strftime("%B %d, %Y", time.gmtime()), titleStyle) + worksheet.write([5, 0], "Time : %s GMT" % time.strftime("%H:%M ", time.gmtime()), titleStyle) + worksheet.write([6, 0], "Status of data ownership: Possibly unpublished data; please see %s/statusandContact.html for details on sources, ownership, and usage of these data." % webqtlConfig.PORTADDR, titleStyle) + #Write footer info + worksheet.write([9 + returnNumber, 0], "Funding for The GeneNetwork: NIAAA (U01AA13499, U24AA13513), NIDA, NIMH, and NIAAA (P20-DA21131), NCI MMHCC (U01CA105417), and NCRR (U01NR 105417)", titleStyle) + worksheet.write([10 + returnNumber, 0], "PLEASE RETAIN DATA SOURCE INFORMATION WHENEVER POSSIBLE", titleStyle) + + return worksheet + + + def getTableHeaderForGeno(self, method=None, worksheet=None, newrow=None, headingStyle=None): + + tblobj_header = [] + + if method in ["1","3","4"]: + tblobj_header = [[THCell(HT.TD(' ', Class="fs13 fwb ffl b1 cw cbrb"), sort=0), + THCell(HT.TD('Record', HT.BR(), 'ID', HT.BR(), Class="fs13 fwb ffl b1 cw cbrb"), text='Record ID', idx=1), + THCell(HT.TD('Location', HT.BR(), 'Chr and Mb', HT.BR(), Class="fs13 fwb ffl b1 cw cbrb"), text='Location (Chr and Mb)', idx=2), + THCell(HT.TD(HT.Href( + text = HT.Span('Sample',HT.BR(), 'r', HT.Sup(' ?', style="color:#f00"),HT.BR(), Class="fs13 fwb ffl cw"), + target = '_blank', + url = "/correlationAnnotation.html#genetic_r"), + Class="fs13 fwb ffl b1 cw cbrb", nowrap='ON'), text="Sample r", idx=3), + THCell(HT.TD('N',HT.BR(),'Cases',HT.BR(), Class="fs13 fwb ffl b1 cw cbrb"), text="N Cases", idx=4), + THCell(HT.TD(HT.Href( + text = HT.Span('Sample',HT.BR(), 'p(r)', HT.Sup(' ?', style="color:#f00"),HT.BR(), Class="fs13 fwb ffl cw"), + target = '_blank', + url = "/correlationAnnotation.html#genetic_p_r"), + Class="fs13 fwb ffl b1 cw cbrb", nowrap='ON'), text="Sample p(r)", idx=5)]] + + for ncol, item in enumerate(['Record ID', 'Location (Chr, Mb)', 'Sample r', 'N Cases', 'Sample p(r)']): + worksheet.write([newrow, ncol], item, headingStyle) + worksheet.set_column([ncol, ncol], 2*len(item)) + else: + tblobj_header = [[THCell(HT.TD(' ', Class="fs13 fwb ffl b1 cw cbrb"), sort=0), + THCell(HT.TD('Record', HT.BR(), 'ID', HT.BR(), Class="fs13 fwb ffl b1 cw cbrb"), text='Record ID', idx=1), + THCell(HT.TD('Location', HT.BR(), 'Chr and Mb', HT.BR(), Class="fs13 fwb ffl b1 cw cbrb"), text='Location (Chr and Mb)', idx=2), + THCell(HT.TD(HT.Href( + text = HT.Span('Sample',HT.BR(), 'rho', HT.Sup(' ?', style="color:#f00"),HT.BR(), Class="fs13 fwb ffl cw"), + target = '_blank', + url = "/correlationAnnotation.html#genetic_rho"), + Class="fs13 fwb ffl b1 cw cbrb", nowrap='ON'), text="Sample rho", idx=3), + THCell(HT.TD('N',HT.BR(),'Cases',HT.BR(), Class="fs13 fwb ffl b1 cw cbrb"), text="N Cases", idx=4), + THCell(HT.TD(HT.Href( + text = HT.Span('Sample',HT.BR(), 'p(rho)', HT.Sup(' ?', style="color:#f00"),HT.BR(), Class="fs13 fwb ffl cw"), + target = '_blank', + url = "/correlationAnnotation.html#genetic_p_rho"), + Class="fs13 fwb ffl b1 cw cbrb", nowrap='ON'), text="Sample p(rho)", idx=5)]] + + for ncol, item in enumerate(['Record ID', 'Location (Chr, Mb)', 'Sample rho', 'N Cases', 'Sample p(rho)']): + worksheet.write([newrow, ncol], item, headingStyle) + worksheet.set_column([ncol, ncol], 2*len(item)) + + + return tblobj_header, worksheet + + + def getTableBodyForGeno(self, traitList, formName=None, worksheet=None, newrow=None, corrScript=None): + + tblobj_body = [] + + for thisTrait in traitList: + tr = [] + + trId = str(thisTrait) + + corrScript.append('corrArray["%s"] = {corr:%1.4f};' % (trId, thisTrait.corr)) + + tr.append(TDCell(HT.TD(HT.Input(type="checkbox", Class="checkbox", name="searchResult",value=trId, onClick="highlight(this)"), nowrap="on", Class="fs12 fwn ffl b1 c222"), text=trId)) + + tr.append(TDCell(HT.TD(HT.Href(text=thisTrait.name,url="javascript:showTrait('%s', '%s')" % (formName, thisTrait.name), Class="fs12 fwn ffl"),align="left", Class="fs12 fwn ffl b1 c222"), text=thisTrait.name, val=thisTrait.name.upper())) + + #XZ: trait_location_value is used for sorting + trait_location_repr = '--' + trait_location_value = 1000000 + + if thisTrait.chr and thisTrait.mb: + try: + trait_location_value = int(thisTrait.chr)*1000 + thisTrait.mb + except: + if thisTrait.chr.upper() == 'X': + trait_location_value = 20*1000 + thisTrait.mb + else: + trait_location_value = ord(str(thisTrait.chr).upper()[0])*1000 + thisTrait.mb + + trait_location_repr = 'Chr%s: %.6f' % (thisTrait.chr, float(thisTrait.mb) ) + + tr.append(TDCell(HT.TD(trait_location_repr, Class="fs12 fwn b1 c222", nowrap="on"), trait_location_repr, trait_location_value)) + + + repr='%3.3f' % thisTrait.corr + tr.append(TDCell(HT.TD(HT.Href(text=repr, url="javascript:showCorrPlot('%s', '%s')" % (formName, thisTrait.name), Class="fs12 fwn ffl"), Class="fs12 fwn ffl b1 c222", nowrap='ON', align='right'),repr,abs(thisTrait.corr))) + + repr = '%d' % thisTrait.nOverlap + tr.append(TDCell(HT.TD(repr, Class="fs12 fwn ffl b1 c222",align='right'),repr,thisTrait.nOverlap)) + + repr = webqtlUtil.SciFloat(thisTrait.corrPValue) + tr.append(TDCell(HT.TD(repr,nowrap='ON', Class="fs12 fwn ffl b1 c222", align='right'),repr,thisTrait.corrPValue)) + + tblobj_body.append(tr) + + for ncol, item in enumerate([thisTrait.name, trait_location_repr, thisTrait.corr, thisTrait.nOverlap, thisTrait.corrPValue]): + worksheet.write([newrow, ncol], item) + newrow += 1 + + return tblobj_body, worksheet, corrScript + + + def getTableHeaderForPublish(self, method=None, worksheet=None, newrow=None, headingStyle=None): + + tblobj_header = [] + + if method in ["1","3","4"]: + tblobj_header = [[THCell(HT.TD(' ', Class="fs13 fwb ffl b1 cw cbrb", nowrap="on"), sort=0), + THCell(HT.TD('Record',HT.BR(), 'ID',HT.BR(), Class="fs13 fwb ffl b1 cw cbrb", nowrap="on"), text="Record ID", idx=1), + THCell(HT.TD('Phenotype', HT.BR(),HT.BR(), Class="fs13 fwb ffl b1 cw cbrb", nowrap="on"), text="Phenotype", idx=2), + THCell(HT.TD('Authors', HT.BR(),HT.BR(), Class="fs13 fwb ffl b1 cw cbrb", nowrap="on"), text="Authors", idx=3), + THCell(HT.TD('Year', HT.BR(),HT.BR(), Class="fs13 fwb ffl b1 cw cbrb", nowrap="on"), text="Year", idx=4), + THCell(HT.TD('Max',HT.BR(), 'LRS', HT.BR(), Class="fs13 fwb ffl b1 cw cbrb", nowrap="on"), text="Max LRS", idx=5), + THCell(HT.TD('Max LRS Location',HT.BR(),'Chr and Mb',HT.BR(), Class="fs13 fwb ffl b1 cw cbrb", nowrap="on"), text="Max LRS Location", idx=6), + THCell(HT.TD(HT.Href( + text = HT.Span('Sample',HT.BR(), 'r', HT.Sup(' ?', style="color:#f00"),HT.BR(), Class="fs13 fwb ffl cw"), + target = '_blank', + url = "/correlationAnnotation.html#genetic_r"), + Class="fs13 fwb ffl b1 cw cbrb", nowrap='ON'), text="Sample r", idx=7), + THCell(HT.TD('N',HT.BR(),'Cases',HT.BR(), Class="fs13 fwb ffl b1 cw cbrb"), text="N Cases", idx=8), + THCell(HT.TD(HT.Href( + text = HT.Span('Sample',HT.BR(), 'p(r)', HT.Sup(' ?', style="color:#f00"),HT.BR(), Class="fs13 fwb ffl cw"), + target = '_blank', + url = "/correlationAnnotation.html#genetic_p_r"), + Class="fs13 fwb ffl b1 cw cbrb", nowrap='ON'), text="Sample p(r)", idx=9)]] + + for ncol, item in enumerate(["Record", "Phenotype", "Authors", "Year", "Pubmed Id", "Max LRS", "Max LRS Location (Chr: Mb)", "Sample r", "N Cases", "Sample p(r)"]): + worksheet.write([newrow, ncol], item, headingStyle) + worksheet.set_column([ncol, ncol], 2*len(item)) + else: + tblobj_header = [[THCell(HT.TD(' ', Class="fs13 fwb ffl b1 cw cbrb", nowrap="on"), sort=0), + THCell(HT.TD('Record',HT.BR(), 'ID',HT.BR(), Class="fs13 fwb ffl b1 cw cbrb", nowrap="on"), text="Record ID", idx=1), + THCell(HT.TD('Phenotype', HT.BR(),HT.BR(), Class="fs13 fwb ffl b1 cw cbrb", nowrap="on"), text="Phenotype", idx=2), + THCell(HT.TD('Authors', HT.BR(),HT.BR(), Class="fs13 fwb ffl b1 cw cbrb", nowrap="on"), text="Authors", idx=3), + THCell(HT.TD('Year', HT.BR(),HT.BR(), Class="fs13 fwb ffl b1 cw cbrb", nowrap="on"), text="Year", idx=4), + THCell(HT.TD('Max',HT.BR(), 'LRS', HT.BR(), Class="fs13 fwb ffl b1 cw cbrb", nowrap="on"), text="Max LRS", idx=5), + THCell(HT.TD('Max LRS Location',HT.BR(),'Chr and Mb',HT.BR(), Class="fs13 fwb ffl b1 cw cbrb", nowrap="on"), text="Max LRS Location", idx=6), + THCell(HT.TD(HT.Href( + text = HT.Span('Sample',HT.BR(), 'rho', HT.Sup(' ?', style="color:#f00"),HT.BR(), Class="fs13 fwb ffl cw"), + target = '_blank', + url = "/correlationAnnotation.html#genetic_rho"), + Class="fs13 fwb ffl b1 cw cbrb", nowrap='ON'), text="Sample rho", idx=7), + THCell(HT.TD('N',HT.BR(),'Cases',HT.BR(), Class="fs13 fwb ffl b1 cw cbrb"), text="N Cases", idx=8), + THCell(HT.TD(HT.Href( + text = HT.Span('Sample',HT.BR(), 'p(rho)', HT.Sup(' ?', style="color:#f00"),HT.BR(), Class="fs13 fwb ffl cw"), + target = '_blank', + url = "/correlationAnnotation.html#genetic_p_rho"), + Class="fs13 fwb ffl b1 cw cbrb", nowrap='ON'), text="Sample p(rho)", idx=9)]] + + for ncol, item in enumerate(["Record", "Phenotype", "Authors", "Year", "Pubmed Id", "Max LRS", "Max LRS Location (Chr: Mb)", "Sample rho", "N Cases", "Sample p(rho)"]): + worksheet.write([newrow, ncol], item, headingStyle) + worksheet.set_column([ncol, ncol], 2*len(item)) + + + return tblobj_header, worksheet + + + def getTableBodyForPublish(self, traitList, formName=None, worksheet=None, newrow=None, corrScript=None, species=''): + + tblobj_body = [] + + for thisTrait in traitList: + tr = [] + + trId = str(thisTrait) + + corrScript.append('corrArray["%s"] = {corr:%1.4f};' % (trId, thisTrait.corr)) + + tr.append(TDCell(HT.TD(HT.Input(type="checkbox", Class="checkbox", name="searchResult",value=trId, onClick="highlight(this)"), nowrap="on", Class="fs12 fwn ffl b1 c222"), text=trId)) + + tr.append(TDCell(HT.TD(HT.Href(text=thisTrait.name,url="javascript:showTrait('%s', '%s')" % (formName, thisTrait.name), Class="fs12 fwn"), nowrap="yes",align="center", Class="fs12 fwn b1 c222"),str(thisTrait.name), thisTrait.name)) + + PhenotypeString = thisTrait.post_publication_description + if thisTrait.confidential: + if not webqtlUtil.hasAccessToConfidentialPhenotypeTrait(privilege=self.privilege, userName=self.userName, authorized_users=thisTrait.authorized_users): + PhenotypeString = thisTrait.pre_publication_description + + tr.append(TDCell(HT.TD(PhenotypeString, Class="fs12 fwn b1 c222"), PhenotypeString, PhenotypeString.upper())) + + tr.append(TDCell(HT.TD(thisTrait.authors, Class="fs12 fwn b1 c222 fsI"),thisTrait.authors, thisTrait.authors.strip().upper())) + + try: + PubMedLinkText = myear = repr = int(thisTrait.year) + except: + PubMedLinkText = repr = "--" + myear = 0 + if thisTrait.pubmed_id: + PubMedLink = HT.Href(text= repr,url= webqtlConfig.PUBMEDLINK_URL % thisTrait.pubmed_id,target='_blank', Class="fs12 fwn") + else: + PubMedLink = repr + + tr.append(TDCell(HT.TD(PubMedLink, Class="fs12 fwn b1 c222", align='center'), repr, myear)) + + #LRS and its location + LRS_score_repr = '--' + LRS_score_value = 0 + LRS_location_repr = '--' + LRS_location_value = 1000000 + LRS_flag = 1 + + #Max LRS and its Locus location + if thisTrait.lrs and thisTrait.locus: + self.cursor.execute(""" + select Geno.Chr, Geno.Mb from Geno, Species + where Species.Name = '%s' and + Geno.Name = '%s' and + Geno.SpeciesId = Species.Id + """ % (species, thisTrait.locus)) + result = self.cursor.fetchone() + + if result: + if result[0] and result[1]: + LRS_Chr = result[0] + LRS_Mb = result[1] + + #XZ: LRS_location_value is used for sorting + try: + LRS_location_value = int(LRS_Chr)*1000 + float(LRS_Mb) + except: + if LRS_Chr.upper() == 'X': + LRS_location_value = 20*1000 + float(LRS_Mb) + else: + LRS_location_value = ord(str(LRS_chr).upper()[0])*1000 + float(LRS_Mb) + + + LRS_score_repr = '%3.1f' % thisTrait.lrs + LRS_score_value = thisTrait.lrs + LRS_location_repr = 'Chr%s: %.6f' % (LRS_Chr, float(LRS_Mb) ) + LRS_flag = 0 + + #tr.append(TDCell(HT.TD(HT.Href(text=LRS_score_repr,url="javascript:showIntervalMapping('%s', '%s : %s')" % (formName, thisTrait.db.shortname, thisTrait.name), Class="fs12 fwn"), Class="fs12 fwn ffl b1 c222", align='right', nowrap="on"),LRS_score_repr, LRS_score_value)) + tr.append(TDCell(HT.TD(LRS_score_repr, Class="fs12 fwn b1 c222", align='right', nowrap="on"), LRS_score_repr, LRS_score_value)) + tr.append(TDCell(HT.TD(LRS_location_repr, Class="fs12 fwn b1 c222"), LRS_location_repr, LRS_location_value)) + + if LRS_flag: + tr.append(TDCell(HT.TD(LRS_score_repr, Class="fs12 fwn b1 c222"), LRS_score_repr, LRS_score_value)) + tr.append(TDCell(HT.TD(LRS_location_repr, Class="fs12 fwn b1 c222"), LRS_location_repr, LRS_location_value)) + + repr = '%3.4f' % thisTrait.corr + tr.append(TDCell(HT.TD(HT.Href(text=repr,url="javascript:showCorrPlot('%s', '%s')" % (formName,thisTrait.name), Class="fs12 fwn"), Class="fs12 fwn b1 c222", align='right',nowrap="on"), repr, abs(thisTrait.corr))) + + repr = '%d' % thisTrait.nOverlap + tr.append(TDCell(HT.TD(repr, Class="fs12 fwn ffl b1 c222", align='right'),repr,thisTrait.nOverlap)) + + repr = webqtlUtil.SciFloat(thisTrait.corrPValue) + tr.append(TDCell(HT.TD(repr,nowrap='ON', Class="fs12 fwn ffl b1 c222", align='right'),repr,thisTrait.corrPValue)) + + tblobj_body.append(tr) + + for ncol, item in enumerate([thisTrait.name, PhenotypeString, thisTrait.authors, thisTrait.year, thisTrait.pubmed_id, LRS_score_repr, LRS_location_repr, thisTrait.corr, thisTrait.nOverlap, thisTrait.corrPValue]): + worksheet.write([newrow, ncol], item) + newrow += 1 + + return tblobj_body, worksheet, corrScript + + + def getTableHeaderForProbeSet(self, method=None, worksheet=None, newrow=None, headingStyle=None): + + tblobj_header = [] + + if method in ["1","3","4"]: + tblobj_header = [[THCell(HT.TD(' ', Class="fs13 fwb ffl b1 cw cbrb",nowrap='ON'), sort=0), + THCell(HT.TD('Record',HT.BR(), 'ID',HT.BR(), Class="fs13 fwb ffl b1 cw cbrb"), text="Record ID", idx=1), + THCell(HT.TD('Gene',HT.BR(), 'ID',HT.BR(), Class="fs13 fwb ffl b1 cw cbrb"), text="Gene ID", idx=2), + THCell(HT.TD('Homologene',HT.BR(), 'ID',HT.BR(), Class="fs13 fwb ffl b1 cw cbrb"), text="Homologene ID", idx=3), + THCell(HT.TD('Symbol',HT.BR(),HT.BR(), Class="fs13 fwb ffl b1 cw cbrb"), text="Symbol", idx=4), + THCell(HT.TD('Description',HT.BR(),HT.BR(), Class="fs13 fwb ffl b1 cw cbrb"), text="Description", idx=5), + THCell(HT.TD('Location',HT.BR(), 'Chr and Mb', HT.BR(), Class="fs13 fwb ffl b1 cw cbrb"), text="Location (Chr: Mb)", idx=6), + THCell(HT.TD('Mean',HT.BR(),'Expr',HT.BR(), Class="fs13 fwb ffl b1 cw cbrb"), text="Mean Expr", idx=7), + THCell(HT.TD('Max',HT.BR(),'LRS',HT.BR(), Class="fs13 fwb ffl b1 cw cbrb", nowrap='ON'), text="Max LRS", idx=8), + THCell(HT.TD('Max LRS Location',HT.BR(),'Chr and Mb',HT.BR(), Class="fs13 fwb ffl b1 cw cbrb", nowrap='ON'), text="Max LRS Location (Chr: Mb)", idx=9), + THCell(HT.TD(HT.Href( + text = HT.Span('Sample',HT.BR(), 'r', HT.Sup(' ?', style="color:#f00"),HT.BR(), Class="fs13 fwb ffl cw"), + target = '_blank', + url = "/correlationAnnotation.html#genetic_r"), + Class="fs13 fwb ffl b1 cw cbrb", nowrap='ON'), text="Sample r", idx=10), + THCell(HT.TD('N',HT.BR(),'Cases',HT.BR(), Class="fs13 fwb ffl b1 cw cbrb"), text="N Cases", idx=11), + THCell(HT.TD(HT.Href( + text = HT.Span('Sample',HT.BR(), 'p(r)', HT.Sup(' ?', style="color:#f00"),HT.BR(), Class="fs13 fwb ffl cw"), + target = '_blank', + url = "/correlationAnnotation.html#genetic_p_r"), + Class="fs13 fwb ffl b1 cw cbrb", nowrap='ON'), text="Sample p(r)", idx=12), + THCell(HT.TD(HT.Href( + text = HT.Span('Lit',HT.BR(), 'Corr', HT.Sup(' ?', style="color:#f00"),HT.BR(), Class="fs13 fwb ffl cw"), + target = '_blank', + url = "/correlationAnnotation.html#literatureCorr"), + Class="fs13 fwb ffl b1 cw cbrb", nowrap='ON'), text="Lit Corr", idx=13), + #XZ, 09/22/2008: tissue correlation + THCell(HT.TD(HT.Href( + text = HT.Span('Tissue',HT.BR(), 'r', HT.Sup(' ?', style="color:#f00"),HT.BR(), Class="fs13 fwb ffl cw"), + target = '_blank', + url = "/correlationAnnotation.html#tissue_r"), + Class="fs13 fwb ffl b1 cw cbrb", nowrap='ON'), text="Tissue r", idx=14), + THCell(HT.TD(HT.Href( + text = HT.Span('Tissue',HT.BR(), 'p(r)', HT.Sup(' ?', style="color:#f00"),HT.BR(), Class="fs13 fwb ffl cw"), + target = '_blank', + url = "/correlationAnnotation.html#tissue_p_r"), + Class="fs13 fwb ffl b1 cw cbrb", nowrap='ON'), text="Tissue p(r)", idx=15)]] + + for ncol, item in enumerate(['Record', 'Gene ID', 'Homologene ID', 'Symbol', 'Description', 'Location (Chr: Mb)', 'Mean Expr', 'Max LRS', 'Max LRS Location (Chr: Mb)', 'Sample r', 'N Cases', 'Sample p(r)', 'Lit Corr', 'Tissue r', 'Tissue p(r)']): + worksheet.write([newrow, ncol], item, headingStyle) + worksheet.set_column([ncol, ncol], 2*len(item)) + else: + tblobj_header = [[THCell(HT.TD(' ', Class="fs13 fwb ffl b1 cw cbrb",nowrap='ON'), sort=0), + THCell(HT.TD('Record',HT.BR(), 'ID',HT.BR(), Class="fs13 fwb ffl b1 cw cbrb"), text="Record ID", idx=1), + THCell(HT.TD('Gene',HT.BR(), 'ID',HT.BR(), Class="fs13 fwb ffl b1 cw cbrb"), text="Gene ID", idx=2), + THCell(HT.TD('Homologene',HT.BR(), 'ID',HT.BR(), Class="fs13 fwb ffl b1 cw cbrb"), text="Homologene ID", idx=3), + THCell(HT.TD('Symbol',HT.BR(),HT.BR(), Class="fs13 fwb ffl b1 cw cbrb"), text="Symbol", idx=4), + THCell(HT.TD('Description',HT.BR(),HT.BR(), Class="fs13 fwb ffl b1 cw cbrb"), text="Description", idx=5), + THCell(HT.TD('Location',HT.BR(), 'Chr and Mb', HT.BR(), Class="fs13 fwb ffl b1 cw cbrb"), text="Location (Chr: Mb)", idx=6), + THCell(HT.TD('Mean',HT.BR(),'Expr',HT.BR(), Class="fs13 fwb ffl b1 cw cbrb"), text="Mean Expr", idx=7), + THCell(HT.TD('Max',HT.BR(),'LRS',HT.BR(), Class="fs13 fwb ffl b1 cw cbrb", nowrap='ON'), text="Max LRS", idx=8), + THCell(HT.TD('Max LRS Location',HT.BR(),'Chr and Mb',HT.BR(), Class="fs13 fwb ffl b1 cw cbrb", nowrap='ON'), text="Max LRS Location (Chr: Mb)", idx=9), + THCell(HT.TD(HT.Href( + text = HT.Span('Sample',HT.BR(), 'rho', HT.Sup(' ?', style="color:#f00"),HT.BR(), Class="fs13 fwb ffl cw"), + target = '_blank', + url = "/correlationAnnotation.html#genetic_rho"), + Class="fs13 fwb ffl b1 cw cbrb", nowrap='ON'), text="Sample rho", idx=10), + THCell(HT.TD('N',HT.BR(),'Cases',HT.BR(), Class="fs13 fwb ffl b1 cw cbrb"), text="N Cases", idx=11), + THCell(HT.TD(HT.Href( + text = HT.Span('Sample',HT.BR(), 'p(rho)', HT.Sup(' ?', style="color:#f00"),HT.BR(), Class="fs13 fwb ffl cw"), + target = '_blank', + url = "/correlationAnnotation.html#genetic_p_rho"), + Class="fs13 fwb ffl b1 cw cbrb", nowrap='ON'), text="Sample p(rho)", idx=12), + THCell(HT.TD(HT.Href( + text = HT.Span('Lit',HT.BR(), 'Corr', HT.Sup(' ?', style="color:#f00"),HT.BR(), Class="fs13 fwb ffl cw"), + target = '_blank', + url = "/correlationAnnotation.html#literatureCorr"), + Class="fs13 fwb ffl b1 cw cbrb", nowrap='ON'), text="Lit Corr", idx=13), + #XZ, 09/22/2008: tissue correlation + THCell(HT.TD(HT.Href( + text = HT.Span('Tissue',HT.BR(), 'rho', HT.Sup(' ?', style="color:#f00"),HT.BR(), Class="fs13 fwb ffl cw"), + target = '_blank', + url = "/correlationAnnotation.html#tissue_r"), + Class="fs13 fwb ffl b1 cw cbrb", nowrap='ON'), text="Tissue rho", idx=14), + THCell(HT.TD(HT.Href( + text = HT.Span('Tissue',HT.BR(), 'p(rho)', HT.Sup(' ?', style="color:#f00"),HT.BR(), Class="fs13 fwb ffl cw"), + target = '_blank', + url = "/correlationAnnotation.html#tissue_p_r"), + Class="fs13 fwb ffl b1 cw cbrb", nowrap='ON'), text="Tissue p(rho)", idx=15)]] + + for ncol, item in enumerate(['Record ID', 'Gene ID', 'Homologene ID', 'Symbol', 'Description', 'Location (Chr: Mb)', 'Mean Expr', 'Max LRS', 'Max LRS Location (Chr: Mb)', 'Sample rho', 'N Cases', 'Sample p(rho)', 'Lit Corr', 'Tissue rho', 'Tissue p(rho)']): + worksheet.write([newrow, ncol], item, headingStyle) + worksheet.set_column([ncol, ncol], 2*len(item)) + + return tblobj_header, worksheet + + + def getTableBodyForProbeSet(self, traitList=[], primaryTrait=None, formName=None, worksheet=None, newrow=None, corrScript=None, species=''): + + tblobj_body = [] + + for thisTrait in traitList: + + if thisTrait.symbol: + pass + else: + thisTrait.symbol = "--" + + if thisTrait.geneid: + symbolurl = HT.Href(text=thisTrait.symbol,target='_blank',url="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=gene&cmd=Retrieve&dopt=Graphics&list_uids=%s" % thisTrait.geneid, Class="fs12 fwn") + else: + symbolurl = HT.Href(text=thisTrait.symbol,target='_blank',url="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?CMD=search&DB=gene&term=%s" % thisTrait.symbol, Class="fs12 fwn") + + tr = [] + + trId = str(thisTrait) + + corrScript.append('corrArray["%s"] = {corr:%1.4f};' % (trId, thisTrait.corr)) + + #XZ, 12/08/2008: checkbox + tr.append(TDCell(HT.TD(HT.Input(type="checkbox", Class="checkbox", name="searchResult",value=trId, onClick="highlight(this)"), nowrap="on", Class="fs12 fwn ffl b1 c222"), text=trId)) + + #XZ, 12/08/2008: probeset name + tr.append(TDCell(HT.TD(HT.Href(text=thisTrait.name,url="javascript:showTrait('%s', '%s')" % (formName,thisTrait.name), Class="fs12 fwn"), Class="fs12 fwn b1 c222"), thisTrait.name, thisTrait.name.upper())) + + #XZ, 12/08/2008: gene id + if thisTrait.geneid: + tr.append(TDCell(None, thisTrait.geneid, val=999)) + else: + tr.append(TDCell(None, thisTrait.geneid, val=999)) + + #XZ, 12/08/2008: homologene id + if thisTrait.homologeneid: + tr.append(TDCell("", thisTrait.homologeneid, val=999)) + else: + tr.append(TDCell("", thisTrait.homologeneid, val=999)) + + #XZ, 12/08/2008: gene symbol + tr.append(TDCell(HT.TD(symbolurl, Class="fs12 fwn b1 c222 fsI"),thisTrait.symbol, thisTrait.symbol.upper())) + + #XZ, 12/08/2008: description + #XZ, 06/05/2009: Rob asked to add probe target description + description_string = str(thisTrait.description).strip() + target_string = str(thisTrait.probe_target_description).strip() + + description_display = '' + + if len(description_string) > 1 and description_string != 'None': + description_display = description_string + else: + description_display = thisTrait.symbol + + if len(description_display) > 1 and description_display != 'N/A' and len(target_string) > 1 and target_string != 'None': + description_display = description_display + '; ' + target_string.strip() + + tr.append(TDCell(HT.TD(description_display, Class="fs12 fwn b1 c222"), description_display, description_display)) + + #XZ: trait_location_value is used for sorting + trait_location_repr = '--' + trait_location_value = 1000000 + + if thisTrait.chr and thisTrait.mb: + try: + trait_location_value = int(thisTrait.chr)*1000 + thisTrait.mb + except: + if thisTrait.chr.upper() == 'X': + trait_location_value = 20*1000 + thisTrait.mb + else: + trait_location_value = ord(str(thisTrait.chr).upper()[0])*1000 + thisTrait.mb + + trait_location_repr = 'Chr%s: %.6f' % (thisTrait.chr, float(thisTrait.mb) ) + + tr.append(TDCell(HT.TD(trait_location_repr, Class="fs12 fwn b1 c222", nowrap="on"), trait_location_repr, trait_location_value)) + + """ + #XZ, 12/08/2008: chromosome number + #XZ, 12/10/2008: use Mbvalue to sort chromosome + tr.append(TDCell( HT.TD(thisTrait.chr, Class="fs12 fwn b1 c222", align='right'), thisTrait.chr, Mbvalue) ) + + #XZ, 12/08/2008: Rob wants 6 digit precision, and we have to deal with that the mb could be None + if not thisTrait.mb: + tr.append(TDCell(HT.TD(thisTrait.mb, Class="fs12 fwn b1 c222",align='right'), thisTrait.mb, Mbvalue)) + else: + tr.append(TDCell(HT.TD('%.6f' % thisTrait.mb, Class="fs12 fwn b1 c222", align='right'), thisTrait.mb, Mbvalue)) + """ + + + + #XZ, 01/12/08: This SQL query is much faster. + self.cursor.execute(""" + select ProbeSetXRef.mean from ProbeSetXRef, ProbeSet + where ProbeSetXRef.ProbeSetFreezeId = %d and + ProbeSet.Id = ProbeSetXRef.ProbeSetId and + ProbeSet.Name = '%s' + """ % (thisTrait.db.id, thisTrait.name)) + result = self.cursor.fetchone() + if result: + if result[0]: + mean = result[0] + else: + mean=0 + else: + mean = 0 + + #XZ, 06/05/2009: It is neccessary to turn on nowrap + repr = "%2.3f" % mean + tr.append(TDCell(HT.TD(repr, Class="fs12 fwn ffl b1 c222", align='right', nowrap='ON'),repr, mean)) + + #LRS and its location + LRS_score_repr = '--' + LRS_score_value = 0 + LRS_location_repr = '--' + LRS_location_value = 1000000 + LRS_flag = 1 + + #Max LRS and its Locus location + if thisTrait.lrs and thisTrait.locus: + self.cursor.execute(""" + select Geno.Chr, Geno.Mb from Geno, Species + where Species.Name = '%s' and + Geno.Name = '%s' and + Geno.SpeciesId = Species.Id + """ % (species, thisTrait.locus)) + result = self.cursor.fetchone() + + if result: + if result[0] and result[1]: + LRS_Chr = result[0] + LRS_Mb = result[1] + + #XZ: LRS_location_value is used for sorting + try: + LRS_location_value = int(LRS_Chr)*1000 + float(LRS_Mb) + except: + if LRS_Chr.upper() == 'X': + LRS_location_value = 20*1000 + float(LRS_Mb) + else: + LRS_location_value = ord(str(LRS_chr).upper()[0])*1000 + float(LRS_Mb) + + + LRS_score_repr = '%3.1f' % thisTrait.lrs + LRS_score_value = thisTrait.lrs + LRS_location_repr = 'Chr%s: %.6f' % (LRS_Chr, float(LRS_Mb) ) + LRS_flag = 0 + + #tr.append(TDCell(HT.TD(HT.Href(text=LRS_score_repr,url="javascript:showIntervalMapping('%s', '%s : %s')" % (formName, thisTrait.db.shortname, thisTrait.name), Class="fs12 fwn"), Class="fs12 fwn ffl b1 c222", align='right', nowrap="on"),LRS_score_repr, LRS_score_value)) + tr.append(TDCell(HT.TD(LRS_score_repr, Class="fs12 fwn b1 c222", align='right', nowrap="on"), LRS_score_repr, LRS_score_value)) + tr.append(TDCell(HT.TD(LRS_location_repr, Class="fs12 fwn b1 c222", nowrap="on"), LRS_location_repr, LRS_location_value)) + + if LRS_flag: + tr.append(TDCell(HT.TD(LRS_score_repr, Class="fs12 fwn b1 c222"), LRS_score_repr, LRS_score_value)) + tr.append(TDCell(HT.TD(LRS_location_repr, Class="fs12 fwn b1 c222"), LRS_location_repr, LRS_location_value)) + + + #XZ, 12/08/2008: generic correlation + repr='%3.3f' % thisTrait.corr + tr.append(TDCell(HT.TD(HT.Href(text=repr, url="javascript:showCorrPlot('%s', '%s')" % (formName, thisTrait.name), Class="fs12 fwn ffl"), Class="fs12 fwn ffl b1 c222", align='right'),repr,abs(thisTrait.corr))) + + #XZ, 12/08/2008: number of overlaped cases + repr = '%d' % thisTrait.nOverlap + tr.append(TDCell(HT.TD(repr, Class="fs12 fwn ffl b1 c222", align='right'),repr,thisTrait.nOverlap)) + + #XZ, 12/08/2008: p value of genetic correlation + repr = webqtlUtil.SciFloat(thisTrait.corrPValue) + tr.append(TDCell(HT.TD(repr,nowrap='ON', Class="fs12 fwn ffl b1 c222", align='right'),repr,thisTrait.corrPValue)) + + #XZ, 12/08/2008: literature correlation + LCorr = 0.0 + LCorrStr = "--" + if hasattr(thisTrait, 'LCorr') and thisTrait.LCorr: + LCorr = thisTrait.LCorr + LCorrStr = "%2.3f" % thisTrait.LCorr + tr.append(TDCell(HT.TD(LCorrStr, Class="fs12 fwn b1 c222", align='right'), LCorrStr, abs(LCorr))) + + #XZ, 09/22/2008: tissue correlation. + TCorr = 0.0 + TCorrStr = "--" + #XZ, 11/20/2008: need to pass two geneids: input_trait_mouse_geneid and thisTrait.mouse_geneid + if hasattr(thisTrait, 'tissueCorr') and thisTrait.tissueCorr: + TCorr = thisTrait.tissueCorr + TCorrStr = "%2.3f" % thisTrait.tissueCorr + # NL, 07/19/2010: add a new parameter rankOrder for js function 'showTissueCorrPlot' + rankOrder = self.RANK_ORDERS[self.method] + TCorrPlotURL = "javascript:showTissueCorrPlot('%s','%s','%s',%d)" %(formName, primaryTrait.symbol, thisTrait.symbol,rankOrder) + tr.append(TDCell(HT.TD(HT.Href(text=TCorrStr, url=TCorrPlotURL, Class="fs12 fwn ff1"), Class="fs12 fwn ff1 b1 c222", align='right'), TCorrStr, abs(TCorr))) + else: + tr.append(TDCell(HT.TD(TCorrStr, Class="fs12 fwn b1 c222", align='right'), TCorrStr, abs(TCorr))) + + #XZ, 12/08/2008: p value of tissue correlation + TPValue = 1.0 + TPValueStr = "--" + if hasattr(thisTrait, 'tissueCorr') and thisTrait.tissuePValue: #XZ, 09/22/2008: thisTrait.tissuePValue can't be used here because it could be 0 + TPValue = thisTrait.tissuePValue + TPValueStr = "%2.3f" % thisTrait.tissuePValue + tr.append(TDCell(HT.TD(TPValueStr, Class="fs12 fwn b1 c222", align='right'), TPValueStr, TPValue)) + + tblobj_body.append(tr) + + for ncol, item in enumerate([thisTrait.name, thisTrait.geneid, thisTrait.homologeneid, thisTrait.symbol, thisTrait.description, trait_location_repr, mean, LRS_score_repr, LRS_location_repr, thisTrait.corr, thisTrait.nOverlap, thisTrait.corrPValue, LCorr, TCorr, TPValue]): + worksheet.write([newrow, ncol], item) + + newrow += 1 + + return tblobj_body, worksheet, corrScript diff --git a/wqflask/wqflask/correlation/__init__.py b/wqflask/wqflask/correlation/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/wqflask/wqflask/correlation/correlationFunction.py b/wqflask/wqflask/correlation/correlationFunction.py new file mode 100644 index 00000000..4d62a468 --- /dev/null +++ b/wqflask/wqflask/correlation/correlationFunction.py @@ -0,0 +1,923 @@ +# Copyright (C) University of Tennessee Health Science Center, Memphis, TN. +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Affero General Public License for more details. +# +# This program is available from Source Forge: at GeneNetwork Project +# (sourceforge.net/projects/genenetwork/). +# +# Contact Drs. Robert W. Williams and Xiaodong Zhou (2010) +# at rwilliams@uthsc.edu and xzhou15@uthsc.edu +# +# +# +# This module is used by GeneNetwork project (www.genenetwork.org) +# +# Created by GeneNetwork Core Team 2010/08/10 +# +# Last updated by NL 2011/03/23 + + +import math +import rpy2.robjects +import pp +import string + +from utility import webqtlUtil +from base.webqtlTrait import webqtlTrait +from dbFunction import webqtlDatabaseFunction + + + +#XZ: The input 'controls' is String. It contains the full name of control traits. +#XZ: The input variable 'strainlst' is List. It contains the strain names of primary trait. +#XZ: The returned tcstrains is the list of list [[],[]...]. So are tcvals and tcvars. The last returned parameter is list of numbers. +#XZ, 03/29/2010: For each returned control trait, there is no None value in it. +def controlStrains(controls, strainlst): + + controls = controls.split(',') + + cvals = {} + for oneTraitName in controls: + oneTrait = webqtlTrait(fullname=oneTraitName, cursor=webqtlDatabaseFunction.getCursor() ) + oneTrait.retrieveData() + cvals[oneTraitName] = oneTrait.data + + tcstrains = [] + tcvals = [] + tcvars = [] + + for oneTraitName in controls: + strains = [] + vals = [] + vars = [] + + for _strain in strainlst: + if cvals[oneTraitName].has_key(_strain): + _val = cvals[oneTraitName][_strain].val + if _val != None: + strains.append(_strain) + vals.append(_val) + vars.append(None) + + tcstrains.append(strains) + tcvals.append(vals) + tcvars.append(vars) + + return tcstrains, tcvals, tcvars, [len(x) for x in tcstrains] + + + +#XZ, 03/29/2010: After execution of functon "controlStrains" and "fixStrains", primary trait and control traits have the same strains and in the same order. There is no 'None' value in them. +def fixStrains(_strains,_controlstrains,_vals,_controlvals,_vars,_controlvars): + """Corrects strains, vals, and vars so that all contrain only those strains common + to the reference trait and all control traits.""" + + def dictify(strains,vals,vars): + subdict = {} + for i in xrange(len(strains)): + subdict[strains[i]] = (vals[i],vars[i]) + return subdict + + #XZ: The 'dicts' is a list of dictionary. The first element is the dictionary of reference trait. The rest elements are for control traits. + dicts = [] + dicts.append(dictify(_strains,_vals,_vars)) + + nCstrains = len(_controlstrains) + for i in xrange(nCstrains): + dicts.append(dictify(_controlstrains[i],_controlvals[i],_controlvars[i])) + + _newstrains = [] + _vals = [] + _vars = [] + _controlvals = [[] for x in xrange(nCstrains)] + _controlvars = [[] for x in xrange(nCstrains)] + + for strain in _strains: + inall = True + for d in dicts: + if strain not in d: + inall = False + break + if inall: + _newstrains.append(strain) + _vals.append(dicts[0][strain][0]) + _vars.append(dicts[0][strain][1]) + for i in xrange(nCstrains): + _controlvals[i].append(dicts[i+1][strain][0]) + _controlvars[i].append(dicts[i+1][strain][1]) + + return _newstrains, _vals, _controlvals, _vars, _controlvars + + +#XZ, 6/15/2010: If there is no identical control traits, the returned list is empty. +#else, the returned list has two elements of control trait name. +def findIdenticalControlTraits ( controlVals, controlNames ): + nameOfIdenticalTraits = [] + + controlTraitNumber = len(controlVals) + + if controlTraitNumber > 1: + + #XZ: reset the precision of values and convert to string type + for oneTraitVal in controlVals: + for oneStrainVal in oneTraitVal: + oneStrainVal = '%.3f' % oneStrainVal + + for i, oneTraitVal in enumerate( controlVals ): + for j in range(i+1, controlTraitNumber): + if oneTraitVal == controlVals[j]: + nameOfIdenticalTraits.append(controlNames[i]) + nameOfIdenticalTraits.append(controlNames[j]) + + return nameOfIdenticalTraits + +#XZ, 6/15/2010: If there is no identical control traits, the returned list is empty. +#else, the returned list has two elements of control trait name. +#primaryVal is of list type. It contains value of primary trait. +#primaryName is of string type. +#controlVals is of list type. Each element is list too. Each element contain value of one control trait. +#controlNames is of list type. +def findIdenticalTraits (primaryVal, primaryName, controlVals, controlNames ): + nameOfIdenticalTraits = [] + + #XZ: reset the precision of values and convert to string type + for oneStrainVal in primaryVal: + oneStrainVal = '%.3f' % oneStrainVal + + for oneTraitVal in controlVals: + for oneStrainVal in oneTraitVal: + oneStrainVal = '%.3f' % oneStrainVal + + controlTraitNumber = len(controlVals) + + if controlTraitNumber > 1: + for i, oneTraitVal in enumerate( controlVals ): + for j in range(i+1, controlTraitNumber): + if oneTraitVal == controlVals[j]: + nameOfIdenticalTraits.append(controlNames[i]) + nameOfIdenticalTraits.append(controlNames[j]) + break + + if len(nameOfIdenticalTraits) == 0: + for i, oneTraitVal in enumerate( controlVals ): + if primaryVal == oneTraitVal: + nameOfIdenticalTraits.append(primaryName) + nameOfIdenticalTraits.append(controlNames[i]) + break + + return nameOfIdenticalTraits + + + +#XZ, 03/29/2010: The strains in primaryVal, controlVals, targetVals must be of the same number and in same order. +#XZ: No value in primaryVal and controlVals could be None. + +def determinePartialsByR (primaryVal, controlVals, targetVals, targetNames, method='p'): + + def compute_partial ( primaryVal, controlVals, targetVals, targetNames, method ): + + rpy2.robjects.r(""" +pcor.test <- function(x,y,z,use="mat",method="p",na.rm=T){ + # The partial correlation coefficient between x and y given z + # + # pcor.test is free and comes with ABSOLUTELY NO WARRANTY. + # + # x and y should be vectors + # + # z can be either a vector or a matrix + # + # use: There are two methods to calculate the partial correlation coefficient. + # One is by using variance-covariance matrix ("mat") and the other is by using recursive formula ("rec"). + # Default is "mat". + # + # method: There are three ways to calculate the correlation coefficient, + # which are Pearson's ("p"), Spearman's ("s"), and Kendall's ("k") methods. + # The last two methods which are Spearman's and Kendall's coefficient are based on the non-parametric analysis. + # Default is "p". + # + # na.rm: If na.rm is T, then all the missing samples are deleted from the whole dataset, which is (x,y,z). + # If not, the missing samples will be removed just when the correlation coefficient is calculated. + # However, the number of samples for the p-value is the number of samples after removing + # all the missing samples from the whole dataset. + # Default is "T". + + x <- c(x) + y <- c(y) + z <- as.data.frame(z) + + if(use == "mat"){ + p.use <- "Var-Cov matrix" + pcor = pcor.mat(x,y,z,method=method,na.rm=na.rm) + }else if(use == "rec"){ + p.use <- "Recursive formula" + pcor = pcor.rec(x,y,z,method=method,na.rm=na.rm) + }else{ + stop("use should be either rec or mat!\n") + } + + # print the method + if(gregexpr("p",method)[[1]][1] == 1){ + p.method <- "Pearson" + }else if(gregexpr("s",method)[[1]][1] == 1){ + p.method <- "Spearman" + }else if(gregexpr("k",method)[[1]][1] == 1){ + p.method <- "Kendall" + }else{ + stop("method should be pearson or spearman or kendall!\n") + } + + # sample number + n <- dim(na.omit(data.frame(x,y,z)))[1] + + # given variables' number + gn <- dim(z)[2] + + # p-value + if(p.method == "Kendall"){ + statistic <- pcor/sqrt(2*(2*(n-gn)+5)/(9*(n-gn)*(n-1-gn))) + p.value <- 2*pnorm(-abs(statistic)) + + }else{ + statistic <- pcor*sqrt((n-2-gn)/(1-pcor^2)) + p.value <- 2*pnorm(-abs(statistic)) + } + + data.frame(estimate=pcor,p.value=p.value,statistic=statistic,n=n,gn=gn,Method=p.method,Use=p.use) +} + +# By using var-cov matrix +pcor.mat <- function(x,y,z,method="p",na.rm=T){ + + x <- c(x) + y <- c(y) + z <- as.data.frame(z) + + if(dim(z)[2] == 0){ + stop("There should be given data\n") + } + + data <- data.frame(x,y,z) + + if(na.rm == T){ + data = na.omit(data) + } + + xdata <- na.omit(data.frame(data[,c(1,2)])) + Sxx <- cov(xdata,xdata,m=method) + + xzdata <- na.omit(data) + xdata <- data.frame(xzdata[,c(1,2)]) + zdata <- data.frame(xzdata[,-c(1,2)]) + Sxz <- cov(xdata,zdata,m=method) + + zdata <- na.omit(data.frame(data[,-c(1,2)])) + Szz <- cov(zdata,zdata,m=method) + + # is Szz positive definite? + zz.ev <- eigen(Szz)$values + if(min(zz.ev)[1]<0){ + stop("\'Szz\' is not positive definite!\n") + } + + # partial correlation + Sxx.z <- Sxx - Sxz %*% solve(Szz) %*% t(Sxz) + + rxx.z <- cov2cor(Sxx.z)[1,2] + + rxx.z +} + +# By using recursive formula +pcor.rec <- function(x,y,z,method="p",na.rm=T){ + # + + x <- c(x) + y <- c(y) + z <- as.data.frame(z) + + if(dim(z)[2] == 0){ + stop("There should be given data\n") + } + + data <- data.frame(x,y,z) + + if(na.rm == T){ + data = na.omit(data) + } + + # recursive formula + if(dim(z)[2] == 1){ + tdata <- na.omit(data.frame(data[,1],data[,2])) + rxy <- cor(tdata[,1],tdata[,2],m=method) + + tdata <- na.omit(data.frame(data[,1],data[,-c(1,2)])) + rxz <- cor(tdata[,1],tdata[,2],m=method) + + tdata <- na.omit(data.frame(data[,2],data[,-c(1,2)])) + ryz <- cor(tdata[,1],tdata[,2],m=method) + + rxy.z <- (rxy - rxz*ryz)/( sqrt(1-rxz^2)*sqrt(1-ryz^2) ) + + return(rxy.z) + }else{ + x <- c(data[,1]) + y <- c(data[,2]) + z0 <- c(data[,3]) + zc <- as.data.frame(data[,-c(1,2,3)]) + + rxy.zc <- pcor.rec(x,y,zc,method=method,na.rm=na.rm) + rxz0.zc <- pcor.rec(x,z0,zc,method=method,na.rm=na.rm) + ryz0.zc <- pcor.rec(y,z0,zc,method=method,na.rm=na.rm) + + rxy.z <- (rxy.zc - rxz0.zc*ryz0.zc)/( sqrt(1-rxz0.zc^2)*sqrt(1-ryz0.zc^2) ) + return(rxy.z) + } +} +""") + + R_pcorr_function = rpy2.robjects.r['pcor.test'] + R_corr_test = rpy2.robjects.r['cor.test'] + + primary = rpy2.robjects.FloatVector(range(len(primaryVal))) + for i in range(len(primaryVal)): + primary[i] = primaryVal[i] + + control = rpy2.robjects.r.matrix(rpy2.robjects.FloatVector( range(len(controlVals)*len(controlVals[0])) ), ncol=len(controlVals)) + for i in range(len(controlVals)): + for j in range(len(controlVals[0])): + control[i*len(controlVals[0]) + j] = controlVals[i][j] + + allcorrelations = [] + + for targetIndex, oneTargetVals in enumerate(targetVals): + + this_primary = None + this_control = None + this_target = None + + if None in oneTargetVals: + + goodIndex = [] + for i in range(len(oneTargetVals)): + if oneTargetVals[i] != None: + goodIndex.append(i) + + this_primary = rpy2.robjects.FloatVector(range(len(goodIndex))) + for i in range(len(goodIndex)): + this_primary[i] = primaryVal[goodIndex[i]] + + this_control = rpy2.robjects.r.matrix(rpy2.robjects.FloatVector( range(len(controlVals)*len(goodIndex)) ), ncol=len(controlVals)) + for i in range(len(controlVals)): + for j in range(len(goodIndex)): + this_control[i*len(goodIndex) + j] = controlVals[i][goodIndex[j]] + + this_target = rpy2.robjects.FloatVector(range(len(goodIndex))) + for i in range(len(goodIndex)): + this_target[i] = oneTargetVals[goodIndex[i]] + + else: + this_primary = primary + this_control = control + this_target = rpy2.robjects.FloatVector(range(len(oneTargetVals))) + for i in range(len(oneTargetVals)): + this_target[i] = oneTargetVals[i] + + one_name = targetNames[targetIndex] + one_N = len(this_primary) + + #calculate partial correlation + one_pc_coefficient = 'NA' + one_pc_p = 1 + + try: + if method == 's': + result = R_pcorr_function(this_primary, this_target, this_control, method='s') + else: + result = R_pcorr_function(this_primary, this_target, this_control) + + #XZ: In very few cases, the returned coefficient is nan. + #XZ: One way to detect nan is to compare the number to itself. NaN is always != NaN + if result[0][0] == result[0][0]: + one_pc_coefficient = result[0][0] + #XZ: when the coefficient value is 1 (primary trait and target trait are the same), + #XZ: occationally, the returned p value is nan instead of 0. + if result[1][0] == result[1][0]: + one_pc_p = result[1][0] + elif abs(one_pc_coefficient - 1) < 0.0000001: + one_pc_p = 0 + except: + pass + + #calculate zero order correlation + one_corr_coefficient = 0 + one_corr_p = 1 + + try: + if method == 's': + R_result = R_corr_test(this_primary, this_target, method='spearman') + else: + R_result = R_corr_test(this_primary, this_target) + + one_corr_coefficient = R_result[3][0] + one_corr_p = R_result[2][0] + except: + pass + + traitinfo = [ one_name, one_N, one_pc_coefficient, one_pc_p, one_corr_coefficient, one_corr_p ] + + allcorrelations.append(traitinfo) + + return allcorrelations + #End of function compute_partial + + + allcorrelations = [] + + target_trait_number = len(targetVals) + + if target_trait_number < 1000: + allcorrelations = compute_partial ( primaryVal, controlVals, targetVals, targetNames, method ) + else: + step = 1000 + job_number = math.ceil( float(target_trait_number)/step ) + + job_targetVals_lists = [] + job_targetNames_lists = [] + + for job_index in range( int(job_number) ): + starti = job_index*step + endi = min((job_index+1)*step, target_trait_number) + + one_job_targetVals_list = [] + one_job_targetNames_list = [] + + for i in range( starti, endi ): + one_job_targetVals_list.append( targetVals[i] ) + one_job_targetNames_list.append( targetNames[i] ) + + job_targetVals_lists.append( one_job_targetVals_list ) + job_targetNames_lists.append( one_job_targetNames_list ) + + ppservers = () + # Creates jobserver with automatically detected number of workers + job_server = pp.Server(ppservers=ppservers) + + jobs = [] + results = [] + + for i, one_job_targetVals_list in enumerate( job_targetVals_lists ): + one_job_targetNames_list = job_targetNames_lists[i] + #pay attention to modules from outside + jobs.append( job_server.submit(func=compute_partial, args=( primaryVal, controlVals, one_job_targetVals_list, one_job_targetNames_list, method), depfuncs=(), modules=("rpy2.robjects",)) ) + + for one_job in jobs: + one_result = one_job() + results.append( one_result ) + + for one_result in results: + for one_traitinfo in one_result: + allcorrelations.append( one_traitinfo ) + + return allcorrelations + + + +#XZ, April 30, 2010: The input primaryTrait and targetTrait are instance of webqtlTrait +#XZ: The primaryTrait and targetTrait should have executed retrieveData function +def calZeroOrderCorr (primaryTrait, targetTrait, method='pearson'): + + #primaryTrait.retrieveData() + + #there is no None value in primary_val + primary_strain, primary_val, primary_var = primaryTrait.exportInformative() + + #targetTrait.retrieveData() + + #there might be None value in target_val + target_val = targetTrait.exportData(primary_strain, type="val") + + R_primary = rpy2.robjects.FloatVector(range(len(primary_val))) + for i in range(len(primary_val)): + R_primary[i] = primary_val[i] + + N = len(target_val) + + if None in target_val: + goodIndex = [] + for i in range(len(target_val)): + if target_val[i] != None: + goodIndex.append(i) + + N = len(goodIndex) + + R_primary = rpy2.robjects.FloatVector(range(len(goodIndex))) + for i in range(len(goodIndex)): + R_primary[i] = primary_val[goodIndex[i]] + + R_target = rpy2.robjects.FloatVector(range(len(goodIndex))) + for i in range(len(goodIndex)): + R_target[i] = target_val[goodIndex[i]] + + else: + R_target = rpy2.robjects.FloatVector(range(len(target_val))) + for i in range(len(target_val)): + R_target[i] = target_val[i] + + R_corr_test = rpy2.robjects.r['cor.test'] + + if method == 'spearman': + R_result = R_corr_test(R_primary, R_target, method='spearman') + else: + R_result = R_corr_test(R_primary, R_target) + + corr_result = [] + corr_result.append( R_result[3][0] ) + corr_result.append( N ) + corr_result.append( R_result[2][0] ) + + return corr_result + +##################################################################################### +#Input: primaryValue(list): one list of expression values of one probeSet, +# targetValue(list): one list of expression values of one probeSet, +# method(string): indicate correlation method ('pearson' or 'spearman') +#Output: corr_result(list): first item is Correlation Value, second item is tissue number, +# third item is PValue +#Function: get correlation value,Tissue quantity ,p value result by using R; +#Note : This function is special case since both primaryValue and targetValue are from +#the same dataset. So the length of these two parameters is the same. They are pairs. +#Also, in the datatable TissueProbeSetData, all Tissue values are loaded based on +#the same tissue order +##################################################################################### + +def calZeroOrderCorrForTiss (primaryValue=[], targetValue=[], method='pearson'): + + R_primary = rpy2.robjects.FloatVector(range(len(primaryValue))) + N = len(primaryValue) + for i in range(len(primaryValue)): + R_primary[i] = primaryValue[i] + + R_target = rpy2.robjects.FloatVector(range(len(targetValue))) + for i in range(len(targetValue)): + R_target[i]=targetValue[i] + + R_corr_test = rpy2.robjects.r['cor.test'] + if method =='spearman': + R_result = R_corr_test(R_primary, R_target, method='spearman') + else: + R_result = R_corr_test(R_primary, R_target) + + corr_result =[] + corr_result.append( R_result[3][0]) + corr_result.append( N ) + corr_result.append( R_result[2][0]) + + return corr_result + + + + +def batchCalTissueCorr(primaryTraitValue=[], SymbolValueDict={}, method='pearson'): + + def cal_tissue_corr(primaryTraitValue, oneSymbolValueDict, method ): + + oneSymbolCorrDict = {} + oneSymbolPvalueDict = {} + + R_corr_test = rpy2.robjects.r['cor.test'] + + R_primary = rpy2.robjects.FloatVector(range(len(primaryTraitValue))) + + for i in range(len(primaryTraitValue)): + R_primary[i] = primaryTraitValue[i] + + for (oneTraitSymbol, oneTraitValue) in oneSymbolValueDict.iteritems(): + R_target = rpy2.robjects.FloatVector(range(len(oneTraitValue))) + for i in range(len(oneTraitValue)): + R_target[i] = oneTraitValue[i] + + if method =='spearman': + R_result = R_corr_test(R_primary, R_target, method='spearman') + else: + R_result = R_corr_test(R_primary, R_target) + + oneSymbolCorrDict[oneTraitSymbol] = R_result[3][0] + oneSymbolPvalueDict[oneTraitSymbol] = R_result[2][0] + + return(oneSymbolCorrDict, oneSymbolPvalueDict) + + + + symbolCorrDict = {} + symbolPvalueDict = {} + + items_number = len(SymbolValueDict) + + if items_number <= 1000: + symbolCorrDict, symbolPvalueDict = cal_tissue_corr(primaryTraitValue, SymbolValueDict, method) + else: + items_list = SymbolValueDict.items() + + step = 1000 + job_number = math.ceil( float(items_number)/step ) + + job_oneSymbolValueDict_list = [] + + for job_index in range( int(job_number) ): + starti = job_index*step + endi = min((job_index+1)*step, items_number) + + oneSymbolValueDict = {} + + for i in range( starti, endi ): + one_item = items_list[i] + one_symbol = one_item[0] + one_value = one_item[1] + oneSymbolValueDict[one_symbol] = one_value + + job_oneSymbolValueDict_list.append( oneSymbolValueDict ) + + + ppservers = () + # Creates jobserver with automatically detected number of workers + job_server = pp.Server(ppservers=ppservers) + + jobs = [] + results = [] + + for i, oneSymbolValueDict in enumerate( job_oneSymbolValueDict_list ): + + #pay attention to modules from outside + jobs.append( job_server.submit(func=cal_tissue_corr, args=(primaryTraitValue, oneSymbolValueDict, method), depfuncs=(), modules=("rpy2.robjects",)) ) + + for one_job in jobs: + one_result = one_job() + results.append( one_result ) + + for one_result in results: + oneSymbolCorrDict, oneSymbolPvalueDict = one_result + symbolCorrDict.update( oneSymbolCorrDict ) + symbolPvalueDict.update( oneSymbolPvalueDict ) + + return (symbolCorrDict, symbolPvalueDict) + +########################################################################### +#Input: cursor, GeneNameLst (list), TissueProbeSetFreezeId +#output: geneIdDict,dataIdDict,ChrDict,MbDict,descDict,pTargetDescDict (Dict) +#function: get multi dicts for short and long label functions, and for getSymbolValuePairDict and +# getGeneSymbolTissueValueDict to build dict to get CorrPvArray +#Note: If there are multiple probesets for one gene, select the one with highest mean. +########################################################################### +def getTissueProbeSetXRefInfo(cursor=None,GeneNameLst=[],TissueProbeSetFreezeId=0): + Symbols ="" + symbolList =[] + geneIdDict ={} + dataIdDict = {} + ChrDict = {} + MbDict = {} + descDict = {} + pTargetDescDict = {} + + count = len(GeneNameLst) + + # Added by NL 01/06/2011 + # Note that:inner join is necessary in this query to get distinct record in one symbol group with highest mean value + # Duo to the limit size of TissueProbeSetFreezeId table in DB, performance of inner join is acceptable. + if count==0: + query=''' + select t.Symbol,t.GeneId, t.DataId,t.Chr, t.Mb,t.description,t.Probe_Target_Description + from ( + select Symbol, max(Mean) as maxmean + from TissueProbeSetXRef + where TissueProbeSetFreezeId=%s and Symbol!='' and Symbol Is Not Null group by Symbol) + as x inner join TissueProbeSetXRef as t on t.Symbol = x.Symbol and t.Mean = x.maxmean; + '''%TissueProbeSetFreezeId + + else: + for i, item in enumerate(GeneNameLst): + + if i == count-1: + Symbols += "'%s'" %item + else: + Symbols += "'%s'," %item + + Symbols = "("+ Symbols+")" + query=''' + select t.Symbol,t.GeneId, t.DataId,t.Chr, t.Mb,t.description,t.Probe_Target_Description + from ( + select Symbol, max(Mean) as maxmean + from TissueProbeSetXRef + where TissueProbeSetFreezeId=%s and Symbol in %s group by Symbol) + as x inner join TissueProbeSetXRef as t on t.Symbol = x.Symbol and t.Mean = x.maxmean; + '''% (TissueProbeSetFreezeId,Symbols) + + try: + + cursor.execute(query) + results =cursor.fetchall() + resultCount = len(results) + # Key in all dicts is the lower-cased symbol + for i, item in enumerate(results): + symbol = item[0] + symbolList.append(symbol) + + key =symbol.lower() + geneIdDict[key]=item[1] + dataIdDict[key]=item[2] + ChrDict[key]=item[3] + MbDict[key]=item[4] + descDict[key]=item[5] + pTargetDescDict[key]=item[6] + + except: + symbolList = None + geneIdDict=None + dataIdDict=None + ChrDict=None + MbDict=None + descDict=None + pTargetDescDict=None + + return symbolList,geneIdDict,dataIdDict,ChrDict,MbDict,descDict,pTargetDescDict + +########################################################################### +#Input: cursor, symbolList (list), dataIdDict(Dict) +#output: symbolValuepairDict (dictionary):one dictionary of Symbol and Value Pair, +# key is symbol, value is one list of expression values of one probeSet; +#function: get one dictionary whose key is gene symbol and value is tissue expression data (list type). +#Attention! All keys are lower case! +########################################################################### +def getSymbolValuePairDict(cursor=None,symbolList=None,dataIdDict={}): + symbolList = map(string.lower, symbolList) + symbolValuepairDict={} + valueList=[] + + for key in symbolList: + if dataIdDict.has_key(key): + DataId = dataIdDict[key] + + valueQuery = "select value from TissueProbeSetData where Id=%s" % DataId + try : + cursor.execute(valueQuery) + valueResults = cursor.fetchall() + for item in valueResults: + item =item[0] + valueList.append(item) + symbolValuepairDict[key] = valueList + valueList=[] + except: + symbolValuepairDict[key] = None + + return symbolValuepairDict + + +######################################################################################################## +#input: cursor, symbolList (list), dataIdDict(Dict): key is symbol +#output: SymbolValuePairDict(dictionary):one dictionary of Symbol and Value Pair. +# key is symbol, value is one list of expression values of one probeSet. +#function: wrapper function for getSymbolValuePairDict function +# build gene symbol list if necessary, cut it into small lists if necessary, +# then call getSymbolValuePairDict function and merge the results. +######################################################################################################## + +def getGeneSymbolTissueValueDict(cursor=None,symbolList=None,dataIdDict={}): + limitNum=1000 + count = len(symbolList) + + SymbolValuePairDict = {} + + if count !=0 and count <=limitNum: + SymbolValuePairDict = getSymbolValuePairDict(cursor=cursor,symbolList=symbolList,dataIdDict=dataIdDict) + + elif count >limitNum: + SymbolValuePairDict={} + n = count/limitNum + start =0 + stop =0 + + for i in range(n): + stop =limitNum*(i+1) + gList1 = symbolList[start:stop] + PairDict1 = getSymbolValuePairDict(cursor=cursor,symbolList=gList1,dataIdDict=dataIdDict) + start =limitNum*(i+1) + + SymbolValuePairDict.update(PairDict1) + + if stop < count: + stop = count + gList2 = symbolList[start:stop] + PairDict2 = getSymbolValuePairDict(cursor=cursor,symbolList=gList2,dataIdDict=dataIdDict) + SymbolValuePairDict.update(PairDict2) + + return SymbolValuePairDict + +######################################################################################################## +#input: cursor, GeneNameLst (list), TissueProbeSetFreezeId(int) +#output: SymbolValuePairDict(dictionary):one dictionary of Symbol and Value Pair. +# key is symbol, value is one list of expression values of one probeSet. +#function: wrapper function of getGeneSymbolTissueValueDict function +# for CorrelationPage.py +######################################################################################################## + +def getGeneSymbolTissueValueDictForTrait(cursor=None,GeneNameLst=[],TissueProbeSetFreezeId=0): + SymbolValuePairDict={} + symbolList,geneIdDict,dataIdDict,ChrDict,MbDict,descDict,pTargetDescDict = getTissueProbeSetXRefInfo(cursor=cursor,GeneNameLst=GeneNameLst,TissueProbeSetFreezeId=TissueProbeSetFreezeId) + if symbolList: + SymbolValuePairDict = getGeneSymbolTissueValueDict(cursor=cursor,symbolList=symbolList,dataIdDict=dataIdDict) + return SymbolValuePairDict + +######################################################################################################## +#Input: cursor(cursor): MySQL connnection cursor; +# priGeneSymbolList(list): one list of gene symbol; +# symbolValuepairDict(dictionary): one dictionary of Symbol and Value Pair, +# key is symbol, value is one list of expression values of one probeSet; +#Output: corrArray(array): array of Correlation Value, +# pvArray(array): array of PValue; +#Function: build corrArray, pvArray for display by calling calculation function:calZeroOrderCorrForTiss +######################################################################################################## + +def getCorrPvArray(cursor=None,priGeneSymbolList=[],symbolValuepairDict={}): + # setting initial value for corrArray, pvArray equal to 0 + Num = len(priGeneSymbolList) + + corrArray = [([0] * (Num))[:] for i in range(Num)] + pvArray = [([0] * (Num))[:] for i in range(Num)] + i = 0 + for pkey in priGeneSymbolList: + j = 0 + pkey = pkey.strip().lower()# key in symbolValuepairDict is low case + if symbolValuepairDict.has_key(pkey): + priValue = symbolValuepairDict[pkey] + for tkey in priGeneSymbolList: + tkey = tkey.strip().lower()# key in symbolValuepairDict is low case + if priValue and symbolValuepairDict.has_key(tkey): + tarValue = symbolValuepairDict[tkey] + + if tarValue: + if i>j: + # corrArray stores Pearson Correlation values + # pvArray stores Pearson P-Values + pcorr_result =calZeroOrderCorrForTiss(primaryValue=priValue,targetValue=tarValue) + corrArray[i][j] =pcorr_result[0] + pvArray[i][j] =pcorr_result[2] + elif i console.log("Found Show Outliers") $('#show_hide_outliers').val("Hide Outliers") console.log("Should be now Hide Outliers") - + + ### Calculate Correlations Code ### @@ -165,6 +166,17 @@ $ -> $('select[name=corr_method]').change(on_corr_method_change) + on_corr_submit = -> + console.log("in beginning of on_corr_submit") + values = $('#trait_data_form').serialize() + console.log("in on_corr_submit, values are:", values) + $.ajax "/corr_compute", + type: 'GET' + dataType: 'html' + data: values + + $('#corr_compute').click(on_corr_submit) + ### End Calculate Correlations Code ### @@ -177,8 +189,9 @@ $ -> _.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) - make_table() - edit_data_change() # Set the values at the beginning + #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 index 96b245ea..0de0297b 100644 --- a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js +++ b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js @@ -10,7 +10,7 @@ }; $(function() { - var edit_data_change, hide_tabs, make_table, on_corr_method_change, process_id, show_hide_outliers, stats_mdp_change, update_stat_values; + var edit_data_change, hide_tabs, make_table, on_corr_method_change, on_corr_submit, process_id, show_hide_outliers, stats_mdp_change, update_stat_values; hide_tabs = function(start) { var x, _i, _results; _results = []; @@ -199,6 +199,18 @@ return $('#' + corr_method + "_r_desc").show().effect("highlight"); }; $('select[name=corr_method]').change(on_corr_method_change); + on_corr_submit = function() { + var values; + console.log("in beginning of on_corr_submit"); + values = $('#trait_data_form').serialize(); + console.log("in on_corr_submit, values are:", values); + return $.ajax("/corr_compute", { + type: 'GET', + dataType: 'html', + data: values + }); + }; + $('#corr_compute').click(on_corr_submit); /* End Calculate Correlations Code */ @@ -209,9 +221,6 @@ _.mixin(_.str.exports()); $('#value_table').change(edit_data_change); console.log("loaded"); - console.log("basic_table is:", basic_table); - make_table(); - edit_data_change(); return console.log("end"); }); diff --git a/wqflask/wqflask/templates/trait_data_and_analysis.html b/wqflask/wqflask/templates/trait_data_and_analysis.html index f6917a90..a5d0e05c 100644 --- a/wqflask/wqflask/templates/trait_data_and_analysis.html +++ b/wqflask/wqflask/templates/trait_data_and_analysis.html @@ -8,7 +8,7 @@ @@ -1308,9 +1311,9 @@ - --> --> diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 1ed3c1fd..114ec458 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -8,6 +8,7 @@ from flask import render_template, request from wqflask import search_results from wqflask.show_trait import show_trait_page +from wqflask.correlation import CorrelationPage from wqflask.dataSharing import SharingInfo, SharingInfoPage @@ -74,7 +75,14 @@ def showDatabaseBXD(): print("showDatabaseBXD template_vars:", pf(template_vars.__dict__)) return render_template("trait_data_and_analysis.html", **template_vars.__dict__) - +@app.route("/corr_compute") +def corr_compute(): + print("In corr_compute") + fd = webqtlFormData.webqtlFormData(request.args) + print("Have fd") + template_vars = CorrelationPage.CorrelationPage(fd) + print("Made it to rendering") + return render_template("corr_compute.html", **template_vars.__dict__) # Todo: Can we simplify this? -Sam def sharing_info_page(): -- cgit v1.2.3 From f1d7725c5f7529c5f587bab4ea89d3467b903ddb Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Wed, 12 Sep 2012 18:22:45 -0500 Subject: Worked towards correctly passing form data to correlation page and addressed various bugs that arose while doing so --- misc/byobu_commands.txt | 6 - misc/find.txt | 1 - misc/notes.txt | 41 +++++++ misc/python_stuff.txt | 1 - misc/runserver.txt | 1 - misc/virtual_env.txt | 1 - wqflask/base/webqtlFormData.py | 121 +++++++++++---------- wqflask/wqflask/correlation/CorrelationPage.py | 82 +++++++------- .../new/javascript/trait_data_and_analysis.coffee | 12 +- .../new/javascript/trait_data_and_analysis.js | 9 +- 10 files changed, 160 insertions(+), 115 deletions(-) delete mode 100644 misc/byobu_commands.txt delete mode 100644 misc/find.txt create mode 100644 misc/notes.txt delete mode 100644 misc/python_stuff.txt delete mode 100644 misc/runserver.txt delete mode 100644 misc/virtual_env.txt (limited to 'wqflask/base') diff --git a/misc/byobu_commands.txt b/misc/byobu_commands.txt deleted file mode 100644 index 48e85396..00000000 --- a/misc/byobu_commands.txt +++ /dev/null @@ -1,6 +0,0 @@ -byobu -RD -control-a then :multiuser on -control-a then :acladd sam - -type: screen -list for sessions -screen -r zas1024/25679.byobu diff --git a/misc/find.txt b/misc/find.txt deleted file mode 100644 index 5c792d80..00000000 --- a/misc/find.txt +++ /dev/null @@ -1 +0,0 @@ -find | grep _____ diff --git a/misc/notes.txt b/misc/notes.txt new file mode 100644 index 00000000..be023c1d --- /dev/null +++ b/misc/notes.txt @@ -0,0 +1,41 @@ +To get server running: + +Start up virtual environment: +source ~/ve27/bin/activate + +To set WQFLASK_SETTINGS environment variable: +export WQFLASK_SETTINGS=~/gene/wqflask/cfg/zach_settings.py (or wherever file is located) + +To search for commands in history if necessary: +history | grep "(whatever is being searched for)" + +Run server: +python runserver.py + +=========================================== + +Start screen session +byobu -RD (to start) +control-a then :multiuser on +control-a then :acladd sam + +type: screen -list for sessions +screen -r zas1024/25679.byobu + +or if only one: + +screen -r zas1024/ + +=========================================== + +Coffeescript Stuff: + +coffee -c (filename) +coffee -c -w (to watch for changes and recompile) +coffee --help (for information about setting options) + +=========================================== + +Python stuff: + +Classes should always inherit "object" \ No newline at end of file diff --git a/misc/python_stuff.txt b/misc/python_stuff.txt deleted file mode 100644 index f36fe338..00000000 --- a/misc/python_stuff.txt +++ /dev/null @@ -1 +0,0 @@ -Classes should always inherit "object" \ No newline at end of file diff --git a/misc/runserver.txt b/misc/runserver.txt deleted file mode 100644 index 71e3dfd7..00000000 --- a/misc/runserver.txt +++ /dev/null @@ -1 +0,0 @@ -python runserver.py diff --git a/misc/virtual_env.txt b/misc/virtual_env.txt deleted file mode 100644 index 7a8f20be..00000000 --- a/misc/virtual_env.txt +++ /dev/null @@ -1 +0,0 @@ -source ~/ve27/bin/activate diff --git a/wqflask/base/webqtlFormData.py b/wqflask/base/webqtlFormData.py index a9e3b7d4..177c72a2 100755 --- a/wqflask/base/webqtlFormData.py +++ b/wqflask/base/webqtlFormData.py @@ -60,17 +60,12 @@ class webqtlFormData: print("in webqtlFormData start_vars are:", pf(start_vars)) for item in webqtlFormData.attrs: self.__dict__[item] = None - #self.__dict__.update(start_vars) + for item in start_vars: self.__dict__[item] = start_vars[item] - print(" Now self.dict is:", pf(self.__dict__)) - #for item in self.attrs: - # if getattr(self, item, None): - # print("Setting item %s to None" % (item,)) - # self.attrs[item] = None - # else: - # self.attrs[item] = self.attrs[item].strip() + #print(" Now self.dict is:", pf(self.__dict__)) + #Todo: This can't be good below...rework try: self.remote_ip = req.connection.remote_ip except: @@ -151,23 +146,32 @@ class webqtlFormData: def readGenotype(self): - 'read genotype from .geno file' + '''read genotype from .geno file''' if self.RISet == 'BXD300': self.RISet = 'BXD' - else: - pass - assert self.RISet + + assert self.RISet, "self.RISet needs to be set" + #genotype_1 is Dataset Object without parents and f1 #genotype_2 is Dataset Object with parents and f1 (not for intercross) + self.genotype_1 = reaper.Dataset() - self.genotype_1.read(os.path.join(webqtlConfig.GENODIR, self.RISet + '.geno')) + + full_filename = os.path.join(webqtlConfig.GENODIR, self.RISet + '.geno') + + # reaper barfs on unicode filenames, so here we ensure it's a string + full_filename = str(full_filename) + self.genotype_1.read(full_filename) + + print("Got to after read") + try: # NL, 07/27/2010. ParInfo has been moved from webqtlForm.py to webqtlUtil.py; _f1, _f12, _mat, _pat = webqtlUtil.ParInfo[self.RISet] - except: + except KeyError: _f1 = _f12 = _mat = _pat = None - self.genotype_2 =self.genotype_1 + self.genotype_2 = self.genotype_1 if self.genotype_1.type == "riset" and _mat and _pat: self.genotype_2 = self.genotype_1.add(Mat=_mat, Pat=_pat) #, F1=_f1) @@ -177,78 +181,83 @@ class webqtlFormData: else: self.incparentsf1 = 0 self.genotype = self.genotype_1 + self.strainlist = list(self.genotype.prgy) - self.f1list = self.parlist = [] + self.f1list = [] + self.parlist = [] + if _f1 and _f12: self.f1list = [_f1, _f12] if _mat and _pat: self.parlist = [_mat, _pat] + - def readData(self, strainlst=[], incf1=[]): - 'read user input data or from trait data and analysis form' + def readData(self, strainlist, incf1=None): + '''read user input data or from trait data and analysis form''' + + if incf1 == None: + incf1 = [] if not self.genotype: self.readGenotype() - if not strainlst: + if not strainlist: if incf1: - strainlst = self.f1list + self.strainlist + strainlist = self.f1list + self.strainlist else: - strainlst = self.strainlist + strainlist = self.strainlist + #print("before traitfiledata self.traitfile is:", pf(self.traitfile)) - traitfiledata = self.formdata.getfirst('traitfile') - traitpastedata = self.formdata.getfirst('traitpaste') - variancefiledata = self.formdata.getfirst('variancefile') - variancepastedata = self.formdata.getfirst('variancepaste') - Nfiledata = self.formdata.getfirst('Nfile') + traitfiledata = getattr(self, "traitfile", None) + traitpastedata = getattr(self, "traitpaste", None) + variancefiledata = getattr(self, "variancefile", None) + variancepastedata = getattr(self, "variancepaste", None) + Nfiledata = getattr(self, "Nfile", None) + #### Todo: Rewrite below when we get to someone submitting their own trait ##### if traitfiledata: - tt = string.split(traitfiledata) - vals = map(webqtlUtil.StringAsFloat, tt) + tt = traitfiledata.split() + values = map(webqtlUtil.StringAsFloat, tt) elif traitpastedata: - tt = string.split(traitpastedata) - vals = map(webqtlUtil.StringAsFloat, tt) + tt = traitpastedata.split() + values = map(webqtlUtil.StringAsFloat, tt) else: - vals = map(self.FormDataAsFloat, strainlst) - - if len(vals) < len(strainlst): - vals += [None]*(len(strainlst) - len(vals)) - elif len(vals) > len(strainlst): - vals = vals[:len(strainlst)] - else: - pass + values = map(self.FormDataAsFloat, strainlist) + if len(values) < len(strainlist): + values += [None] * (len(strainlist) - len(values)) + elif len(values) > len(strainlist): + values = values[:len(strainlist)] + if variancefiledata: - tt = string.split(variancefiledata) - vars = map(webqtlUtil.StringAsFloat, tt) + tt = variancefiledata.split() + variances = map(webqtlUtil.StringAsFloat, tt) elif variancepastedata: - tt = string.split(variancepastedata) - vars = map(webqtlUtil.StringAsFloat, tt) + tt = variancepastedata.split() + variances = map(webqtlUtil.StringAsFloat, tt) else: - vars = map(self.FormVarianceAsFloat, strainlst) + variances = map(self.FormVarianceAsFloat, strainlist) - if len(vars) < len(strainlst): - vars += [None]*(len(strainlst) - len(vars)) - elif len(vars) > len(strainlst): - vars = vars[:len(strainlst)] - else: - pass + if len(variances) < len(strainlist): + variances += [None]*(len(strainlist) - len(variances)) + elif len(variances) > len(strainlist): + variances = variances[:len(strainlist)] if Nfiledata: tt = string.split(Nfiledata) nstrains = map(webqtlUtil.IntAsFloat, tt) - if len(nstrains) < len(strainlst): - nstrains += [None]*(len(strainlst) - len(nstrains)) + if len(nstrains) < len(strainlist): + nstrains += [None]*(len(strainlist) - len(nstrains)) else: - nstrains = map(self.FormNAsFloat, strainlst) + nstrains = map(self.FormNAsFloat, strainlist) - ##vals, vars, nstrains is obsolete + ##values, variances, nstrains is obsolete self.allTraitData = {} - for i, _strain in enumerate(strainlst): - if vals[i] != None: - self.allTraitData[_strain] = webqtlCaseData(vals[i], vars[i], nstrains[i]) + for i, _strain in enumerate(strainlist): + if values[i] != None: + self.allTraitData[_strain] = webqtlCaseData(values[i], variances[i], nstrains[i]) diff --git a/wqflask/wqflask/correlation/CorrelationPage.py b/wqflask/wqflask/correlation/CorrelationPage.py index 9caf6595..62e4c4ab 100644 --- a/wqflask/wqflask/correlation/CorrelationPage.py +++ b/wqflask/wqflask/correlation/CorrelationPage.py @@ -177,42 +177,37 @@ def get_custom_trait(form_data, cursor): #XZ, 09/18/2008: get the information such as value, variance of the input strain names from the form. -def get_sample_data(form_data): - if form_data.allstrainlist: - mdpchoice = form_data.formdata.getvalue('MDPChoice') - #XZ, in HTML source code, it is "BXD Only" or "BXH only", and so on +def get_sample_data(fd): + print("fd is:", pf(fd.__dict__)) + if fd.allstrainlist: + mdpchoice = fd.MDPChoice + #XZ, in HTML source code, it is "BXD Only", "BXH Only", and so on if mdpchoice == "1": - strainlist = form_data.f1list + form_data.strainlist - #XZ, in HTML source code, it is "MDP Only" + strainlist = fd.f1list + fd.strainlist + #XZ, in HTML source code, it is "Non-BXD Only", "Non-BXD Only", etc elif mdpchoice == "2": strainlist = [] - strainlist2 = form_data.f1list + form_data.strainlist - for strain in form_data.allstrainlist: + strainlist2 = fd.f1list + fd.strainlist + for strain in fd.allstrainlist: if strain not in strainlist2: strainlist.append(strain) #So called MDP Panel if strainlist: - strainlist = form_data.f1list+form_data.parlist+strainlist + strainlist = fd.f1list + fd.parlist+strainlist #XZ, in HTML source code, it is "All Cases" else: - strainlist = form_data.allstrainlist - #XZ, 09/18/2008: put the trait data into dictionary form_data.allTraitData - form_data.readData(form_data.allstrainlist) + strainlist = fd.allstrainlist + #XZ, 09/18/2008: put the trait data into dictionary fd.allTraitData + fd.readData(fd.allstrainlist) else: mdpchoice = None - strainlist = form_data.strainlist - #XZ, 09/18/2008: put the trait data into dictionary form_data.allTraitData - form_data.readData() + strainlist = fd.strainlist + #XZ, 09/18/2008: put the trait data into dictionary fd.allTraitData + fd.readData() return strainlist -def get_mdp_choice(form_data): - if form_data.allstrainlist: - return form_data.formdata.getvalue("MDPChoice") - else: - return None - def get_species(fd, cursor): #XZ, 3/16/2010: variable RISet must be pass by the form @@ -277,7 +272,7 @@ class CorrelationPage(templatePage): RANK_ORDERS = {"1": 0, "2": 1, "3": 0, "4": 0, "5": 1} - def error(self, message, error="Error", heading = None): + def error(self, message, *args, **kw): heading = heading or self.PAGE_HEADING return templatePage.error(heading = heading, detail = [message], error=error) @@ -295,23 +290,30 @@ class CorrelationPage(templatePage): fd.readGenotype() sample_list = get_sample_data(fd) - mdp_choice = get_mdp_choice(fd) # No idea what this is yet + + # Whether the user chose BXD Only, Non-BXD Only, or All Strains + # (replace BXD with whatever the group/inbredset name is) + # "mdp" stands for "mouse diversity panel" This is outdated; it now represents any + # cases/strains from the non-primary group + mdp_choice = fd.MDPChoice if fd.allstrainlist else None + self.species = get_species(fd, self.cursor) #XZ, 09/18/2008: get all information about the user selected database. - target_db_name = fd.formdata.getvalue('database') - self.target_db_name = target_db_name + #target_db_name = fd.corr_dataset + self.target_db_name = fd.corr_dataset - try: - self.db = webqtlDataset(target_db_name, self.cursor) - except: - detail = ["The database you just requested has not been established yet."] - self.error(detail) - return + #try: + #print("target_db_name is:", target_db_name) + self.db = webqtlDataset(self.target_db_name, self.cursor) + #except: + # detail = ["The database you just requested has not been established yet."] + # self.error(detail) + # return # Auth if needed try: - auth_user_for_db(self.db, self.cursor, target_db_name, self.privilege, self.userName) + auth_user_for_db(self.db, self.cursor, self.target_db_name, self.privilege, self.userName) except AuthException, e: detail = [e.message] return self.error(detail) @@ -322,7 +324,7 @@ class CorrelationPage(templatePage): #CF - If less than a minimum number of strains/cases in common, don't calculate anything if len(self.sample_names) < self.corrMinInformative: detail = ['Fewer than %d strain data were entered for %s data set. No calculation of correlation has been attempted.' % (self.corrMinInformative, fd.RISet)] - self.error(heading=PAGE_HEADING,detail=detail) + self.error(heading=None, detail=detail) self.method = get_correlation_method_key(fd) @@ -330,15 +332,16 @@ class CorrelationPage(templatePage): rankOrder = self.RANK_ORDERS[self.method] # CF - Number of results returned - self.returnNumber = int(fd.formdata.getvalue('criteria')) + self.returnNumber = int(fd.criteria) self.record_count = 0 myTrait = get_custom_trait(fd, self.cursor) - # We will not get Literature Correlations if there is no GeneId because there is nothing to look against - self.gene_id = int(fd.formdata.getvalue('GeneId') or 0) + # We will not get Literature Correlations if there is no GeneId because there is nothing + # to look against + self.gene_id = int(fd.GeneId) # We will not get Tissue Correlations if there is no gene symbol because there is nothing to look against self.trait_symbol = myTrait.symbol @@ -359,7 +362,8 @@ class CorrelationPage(templatePage): TD_LR = HT.TD(height=200,width="100%",bgColor='#eeeeee') mainfmName = webqtlUtil.genRandStr("fm_") - form = HT.Form(cgi= os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), enctype='multipart/form-data', name= mainfmName, submit=HT.Input(type='hidden')) + form = HT.Form(cgi = os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), + enctype='multipart/form-data', name= mainfmName, submit=HT.Input(type='hidden')) hddn = {'FormID': 'showDatabase', 'ProbeSetID': '_', 'database': self.target_db_name, @@ -369,9 +373,9 @@ class CorrelationPage(templatePage): 'identification': fd.identification} if myTrait: - hddn['fullname']=fd.formdata.getvalue('fullname') + hddn['fullname'] = fd.fullname if mdp_choice: - hddn['MDPChoice']=mdp_choice + hddn['MDPChoice']= mdp_choice #XZ, 09/18/2008: pass the trait data to next page by hidden parameters. diff --git a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee index 3ea90b9c..7bfa6d01 100644 --- a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee +++ b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee @@ -170,10 +170,14 @@ $ -> console.log("in beginning of on_corr_submit") values = $('#trait_data_form').serialize() console.log("in on_corr_submit, values are:", values) - $.ajax "/corr_compute", - type: 'GET' - dataType: 'html' - data: values + + params = $.param(values) + window.location.href = "/corr_compute?" + params + + #$.ajax "/corr_compute", + # type: 'GET' + # dataType: 'html' + # data: values $('#corr_compute').click(on_corr_submit) diff --git a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js index 0de0297b..e1f870d9 100644 --- a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js +++ b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js @@ -200,15 +200,12 @@ }; $('select[name=corr_method]').change(on_corr_method_change); on_corr_submit = function() { - var values; + var params, values; console.log("in beginning of on_corr_submit"); values = $('#trait_data_form').serialize(); console.log("in on_corr_submit, values are:", values); - return $.ajax("/corr_compute", { - type: 'GET', - dataType: 'html', - data: values - }); + params = $.param(values); + return window.location.href = "/corr_compute?" + params; }; $('#corr_compute').click(on_corr_submit); /* -- cgit v1.2.3 From a979480aae5eaa056c84dc3cb05a5e2443c4fbd0 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Thu, 13 Sep 2012 16:10:27 -0500 Subject: Worked on improving readData and informativeStrains functions in webqtlFormData while trying to get correlation page running --- misc/notes.txt | 6 ++ wqflask/base/webqtlFormData.py | 72 ++++++++++++++-------- wqflask/wqflask/correlation/CorrelationPage.py | 18 +++--- .../new/javascript/trait_data_and_analysis.coffee | 28 ++++----- .../new/javascript/trait_data_and_analysis.js | 11 +--- .../wqflask/templates/trait_data_and_analysis.html | 12 +--- wqflask/wqflask/views.py | 6 +- 7 files changed, 83 insertions(+), 70 deletions(-) (limited to 'wqflask/base') diff --git a/misc/notes.txt b/misc/notes.txt index be023c1d..9d31fb5d 100644 --- a/misc/notes.txt +++ b/misc/notes.txt @@ -36,6 +36,12 @@ coffee --help (for information about setting options) =========================================== +Unset ASKPASS when trying to git push + +unset SSH_ASKPASS + +=========================================== + Python stuff: Classes should always inherit "object" \ No newline at end of file diff --git a/wqflask/base/webqtlFormData.py b/wqflask/base/webqtlFormData.py index 177c72a2..9f58d437 100755 --- a/wqflask/base/webqtlFormData.py +++ b/wqflask/base/webqtlFormData.py @@ -63,7 +63,7 @@ class webqtlFormData: for item in start_vars: self.__dict__[item] = start_vars[item] - #print(" Now self.dict is:", pf(self.__dict__)) + print(" Now self.dict is:", pf(self.__dict__)) #Todo: This can't be good below...rework try: @@ -216,6 +216,13 @@ class webqtlFormData: #### Todo: Rewrite below when we get to someone submitting their own trait ##### + def to_float(item): + try: + return float(item) + except ValueError: + return None + + print("bottle strainlist is:", strainlist) if traitfiledata: tt = traitfiledata.split() values = map(webqtlUtil.StringAsFloat, tt) @@ -223,12 +230,17 @@ class webqtlFormData: tt = traitpastedata.split() values = map(webqtlUtil.StringAsFloat, tt) else: - values = map(self.FormDataAsFloat, strainlist) + print("mapping formdataasfloat") + #values = map(self.FormDataAsFloat, strainlist) + values = [to_float(getattr(self, key)) for key in strainlist] + print("rocket values is:", values) + if len(values) < len(strainlist): values += [None] * (len(strainlist) - len(values)) elif len(values) > len(strainlist): values = values[:len(strainlist)] + print("now values is:", values) if variancefiledata: @@ -257,40 +269,48 @@ class webqtlFormData: self.allTraitData = {} for i, _strain in enumerate(strainlist): if values[i] != None: - self.allTraitData[_strain] = webqtlCaseData(values[i], variances[i], nstrains[i]) + self.allTraitData[_strain] = webqtlCaseData( + _strain, values[i], variances[i], nstrains[i]) + print("allTraitData is:", pf(self.allTraitData)) - def informativeStrains(self, strainlst=[], incVars = 0): - '''if readData was called, use this to output the informative strains - (strain with values)''' - if not strainlst: - strainlst = self.strainlist + def informativeStrains(self, strainlist=None, include_variances = None): + '''if readData was called, use this to output informative strains (strain with values)''' + + if not strainlist: + strainlist = self.strainlist + strains = [] - vals = [] - vars = [] - for _strain in strainlst: - if self.allTraitData.has_key(_strain): - _val, _var = self.allTraitData[_strain].val, self.allTraitData[_strain].var + values = [] + variances = [] + + #print("self.allTraitData is:", pf(self.allTraitData)) + + for strain in strainlist: + if strain in self.allTraitData: + _val, _var = self.allTraitData[strain].value, self.allTraitData[strain].variance if _val != None: - if incVars: + if include_variances: if _var != None: - strains.append(_strain) - vals.append(_val) - vars.append(_var) + strains.append(strain) + values.append(_val) + variances.append(_var) else: - strains.append(_strain) - vals.append(_val) - vars.append(None) - return strains, vals, vars, len(strains) + strains.append(strain) + values.append(_val) + variances.append(None) + + return strains, values, variances, len(strains) - def FormDataAsFloat(self, key): - try: - return float(self.formdata.getfirst(key)) - except: - return None + #def FormDataAsFloat(self, key): + # + # #try: + # # return float(self.key) + # #except: + # # return None def FormVarianceAsFloat(self, key): diff --git a/wqflask/wqflask/correlation/CorrelationPage.py b/wqflask/wqflask/correlation/CorrelationPage.py index 62e4c4ab..0af5297a 100644 --- a/wqflask/wqflask/correlation/CorrelationPage.py +++ b/wqflask/wqflask/correlation/CorrelationPage.py @@ -157,7 +157,7 @@ def get_correlation_method_key(form_data): #XZ, 09/28/2008: if user select "4", then display 1, 3 and 4. #XZ, 09/28/2008: if user select "5", then display 2, 3 and 5. - method = form_data.formdata.getvalue("method") + method = form_data.method if method not in ["1", "2", "3" ,"4", "5"]: return "1" @@ -166,7 +166,7 @@ def get_correlation_method_key(form_data): def get_custom_trait(form_data, cursor): """Pulls the custom trait, if it exists, out of the form data""" - trait_name = form_data.formdata.getvalue('fullname') + trait_name = form_data.fullname if trait_name: trait = webqtlTrait(fullname=trait_name, cursor=cursor) @@ -178,7 +178,7 @@ def get_custom_trait(form_data, cursor): #XZ, 09/18/2008: get the information such as value, variance of the input strain names from the form. def get_sample_data(fd): - print("fd is:", pf(fd.__dict__)) + #print("fd is:", pf(fd.__dict__)) if fd.allstrainlist: mdpchoice = fd.MDPChoice #XZ, in HTML source code, it is "BXD Only", "BXH Only", and so on @@ -277,10 +277,10 @@ class CorrelationPage(templatePage): return templatePage.error(heading = heading, detail = [message], error=error) def __init__(self, fd): - print("in CorrelationPage __init__ fd is:", pf(fd.__dict__)) + #print("in CorrelationPage __init__ fd is:", pf(fd.__dict__)) # Call the superclass constructor templatePage.__init__(self, fd) - print("in CorrelationPage __init__ now fd is:", pf(fd.__dict__)) + #print("in CorrelationPage __init__ now fd is:", pf(fd.__dict__)) # Connect to the database if not self.openMysql(): return @@ -290,6 +290,7 @@ class CorrelationPage(templatePage): fd.readGenotype() sample_list = get_sample_data(fd) + print("sample_list is", pf(sample_list)) # Whether the user chose BXD Only, Non-BXD Only, or All Strains # (replace BXD with whatever the group/inbredset name is) @@ -321,17 +322,18 @@ class CorrelationPage(templatePage): #XZ, 09/18/2008: filter out the strains that have no value. self.sample_names, vals, vars, N = fd.informativeStrains(sample_list) - #CF - If less than a minimum number of strains/cases in common, don't calculate anything + print("samplenames is:", pf(self.sample_names)) + #CF - If less than a minimum number of strains/cases in common, don't calculate anything if len(self.sample_names) < self.corrMinInformative: detail = ['Fewer than %d strain data were entered for %s data set. No calculation of correlation has been attempted.' % (self.corrMinInformative, fd.RISet)] self.error(heading=None, detail=detail) - self.method = get_correlation_method_key(fd) + self.method = fd.method correlation_method = self.CORRELATION_METHODS[self.method] rankOrder = self.RANK_ORDERS[self.method] - # CF - Number of results returned + # CF - Number of results returned self.returnNumber = int(fd.criteria) self.record_count = 0 diff --git a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee index 7bfa6d01..5c153ccb 100644 --- a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee +++ b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee @@ -166,20 +166,20 @@ $ -> $('select[name=corr_method]').change(on_corr_method_change) - on_corr_submit = -> - console.log("in beginning of on_corr_submit") - values = $('#trait_data_form').serialize() - console.log("in on_corr_submit, values are:", values) - - params = $.param(values) - window.location.href = "/corr_compute?" + params - - #$.ajax "/corr_compute", - # type: 'GET' - # dataType: 'html' - # data: values - - $('#corr_compute').click(on_corr_submit) + #on_corr_submit = -> + # console.log("in beginning of on_corr_submit") + # values = $('#trait_data_form').serialize() + # console.log("in on_corr_submit, values are:", values) + # + # params = $.param(values) + # window.location.href = "/corr_compute?" + params + # + # #$.ajax "/corr_compute", + # # type: 'GET' + # # dataType: 'html' + # # data: values + # + #$('#corr_compute').click(on_corr_submit) ### End Calculate Correlations Code diff --git a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js index e1f870d9..55acbada 100644 --- a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js +++ b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js @@ -10,7 +10,7 @@ }; $(function() { - var edit_data_change, hide_tabs, make_table, on_corr_method_change, on_corr_submit, process_id, show_hide_outliers, stats_mdp_change, update_stat_values; + var 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 = []; @@ -199,15 +199,6 @@ return $('#' + corr_method + "_r_desc").show().effect("highlight"); }; $('select[name=corr_method]').change(on_corr_method_change); - on_corr_submit = function() { - var params, values; - console.log("in beginning of on_corr_submit"); - values = $('#trait_data_form').serialize(); - console.log("in on_corr_submit, values are:", values); - params = $.param(values); - return window.location.href = "/corr_compute?" + params; - }; - $('#corr_compute').click(on_corr_submit); /* End Calculate Correlations Code */ diff --git a/wqflask/wqflask/templates/trait_data_and_analysis.html b/wqflask/wqflask/templates/trait_data_and_analysis.html index a5d0e05c..c25db7c4 100644 --- a/wqflask/wqflask/templates/trait_data_and_analysis.html +++ b/wqflask/wqflask/templates/trait_data_and_analysis.html @@ -8,7 +8,7 @@
-
+
{# @@ -51,9 +51,9 @@ #} - {% for key in hddn %} - - {% endfor %} + {% for key in hddn %} + + {% endfor %}
Trait Data and Analysis  for Record ID 1441186_at @@ -770,7 +770,9 @@ Pearson    Spearman Rank

-

+ +

+ The Sample Correlation is computed @@ -801,6 +803,7 @@ Pearson and Spearman Rank correlations have been computed for all pairs of genes
using data from mouse samples.
+
- + {# @@ -683,13 +683,7 @@

  Calculate Correlations

-

+

@@ -771,7 +765,7 @@ "sample_method" value="spearman">

-

+

The Sample Correlation diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 114ec458..677c7f43 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -75,10 +75,10 @@ def showDatabaseBXD(): print("showDatabaseBXD template_vars:", pf(template_vars.__dict__)) return render_template("trait_data_and_analysis.html", **template_vars.__dict__) -@app.route("/corr_compute") +@app.route("/corr_compute", methods=('POST',)) def corr_compute(): - print("In corr_compute") - fd = webqtlFormData.webqtlFormData(request.args) + #print("In corr_compute, request.args is:", pf(request.form)) + fd = webqtlFormData.webqtlFormData(request.form) print("Have fd") template_vars = CorrelationPage.CorrelationPage(fd) print("Made it to rendering") -- cgit v1.2.3 From 9ac815b8f6977743dacfe767aabdf4523895fe7c Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Fri, 14 Sep 2012 16:18:47 -0500 Subject: Got the dynamic javascript stats table working --- wqflask/base/webqtlFormData.py | 1 + wqflask/wqflask/show_trait/DataEditingPage.py | 1 + .../new/javascript/trait_data_and_analysis.coffee | 51 ++++++++++--------- .../new/javascript/trait_data_and_analysis.js | 58 +++++++++++----------- wqflask/wqflask/templates/search_result_page.html | 10 ++-- .../wqflask/templates/trait_data_and_analysis.html | 4 +- wqflask/wqflask/views.py | 19 +++++-- 7 files changed, 78 insertions(+), 66 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/webqtlFormData.py b/wqflask/base/webqtlFormData.py index 9f58d437..a8aef2a5 100755 --- a/wqflask/base/webqtlFormData.py +++ b/wqflask/base/webqtlFormData.py @@ -45,6 +45,7 @@ from utility import webqtlUtil class webqtlFormData: 'Represents data from a WebQTL form page, needed to generate the next page' + attrs = ('formID','RISet','genotype','strainlist','allstrainlist', 'suggestive','significance','submitID','identification', 'enablevariance', 'nperm','nboot','email','incparentsf1','genotype_1','genotype_2','traitInfo') diff --git a/wqflask/wqflask/show_trait/DataEditingPage.py b/wqflask/wqflask/show_trait/DataEditingPage.py index 643db81d..8ee1d9c8 100755 --- a/wqflask/wqflask/show_trait/DataEditingPage.py +++ b/wqflask/wqflask/show_trait/DataEditingPage.py @@ -244,6 +244,7 @@ class DataEditingPage(templatePage): self.sample_groups['primary_only'] = fd.RISet + " Only" self.sample_groups['other_only'] = "Non-" + fd.RISet self.sample_groups['all_cases'] = "All Cases" + self.js_data = dict(sample_groups = self.sample_groups) #self.basic_table['columns'] = yaml.load(""" diff --git a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee index 5c153ccb..16dd2571 100644 --- a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee +++ b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee @@ -20,7 +20,7 @@ $ -> $(".stats_mdp").change(stats_mdp_change) update_stat_values = (the_values)-> - for category in ['primary', 'other', 'all'] + for category in ['primary_only', 'other_only', 'all_cases'] id = "#" + process_id(category, "mean") console.log("id:", id) total = 0 @@ -52,9 +52,9 @@ $ -> edit_data_change = -> the_values = - primary: [] - other: [] - all: [] + primary_only: [] + other_only: [] + all_cases: [] console.log("at beginning:", the_values) values = $('#value_table').find(".edit_strain_value") #console.log("values are:", values) @@ -73,20 +73,23 @@ $ -> if is_number(real_value) and real_value != "" real_value = parseFloat(real_value) if _(category).startsWith("Primary") - the_values.primary.push(real_value) + the_values.primary_only.push(real_value) else if _(category).startsWith("Other") - the_values.other.push(real_value) - the_values.all.push(real_value) - console.log("torwads end:", the_values) + the_values.other_only.push(real_value) + the_values.all_cases.push(real_value) + console.log("towards end:", the_values) update_stat_values(the_values) make_table = -> header = "" - for column in basic_table['columns'] - console.log("column:", column) - the_id = process_id("column", column.t) - 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 += """""" header += "" + console.log("windex header is:", header) rows = [ { @@ -114,9 +117,10 @@ $ -> console.log("rowing") row_line = """""" row_line += """""" - for column in basic_table['columns'] - console.log("apple:", column) - the_id = process_id(column.t, row.vn) + 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 += """""" row_line += """""" @@ -152,10 +156,9 @@ $ -> $('#show_hide_outliers').val("Hide Outliers") console.log("Should be now Hide Outliers") - - ### - Calculate Correlations Code - ### + + #Calculate Correlations Code + on_corr_method_change = -> console.log("in beginning of on_corr_method_change") @@ -181,9 +184,9 @@ $ -> # #$('#corr_compute').click(on_corr_submit) - ### - End Calculate Correlations Code - ### + + #End Calculate Correlations Code + console.log("before registering show_hide_outliers") @@ -195,7 +198,7 @@ $ -> 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 + 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 index 55acbada..0b49dde3 100644 --- a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js +++ b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js @@ -29,7 +29,7 @@ $(".stats_mdp").change(stats_mdp_change); update_stat_values = function(the_values) { var category, current_mean, current_n_of_samples, id, in_box, n_of_samples, the_mean, total, value, _i, _j, _len, _len1, _ref, _ref1, _results; - _ref = ['primary', 'other', 'all']; + _ref = ['primary_only', 'other_only', 'all_cases']; _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { category = _ref[_i]; @@ -72,9 +72,9 @@ edit_data_change = function() { var category, checkbox, checked, real_value, row, the_values, value, values, _i, _len; the_values = { - primary: [], - other: [], - all: [] + primary_only: [], + other_only: [], + all_cases: [] }; console.log("at beginning:", the_values); values = $('#value_table').find(".edit_strain_value"); @@ -94,27 +94,30 @@ if (is_number(real_value) && real_value !== "") { real_value = parseFloat(real_value); if (_(category).startsWith("Primary")) { - the_values.primary.push(real_value); + the_values.primary_only.push(real_value); } else if (_(category).startsWith("Other")) { - the_values.other.push(real_value); + the_values.other_only.push(real_value); } - the_values.all.push(real_value); + the_values.all_cases.push(real_value); } } - console.log("torwads end:", the_values); + console.log("towards end:", the_values); return update_stat_values(the_values); }; make_table = function() { - var column, header, row, row_line, rows, table, the_id, the_rows, _i, _j, _k, _len, _len1, _len2, _ref, _ref1; + var header, key, row, row_line, rows, table, the_id, the_rows, value, _i, _len, _ref, _ref1; header = ""; - _ref = basic_table['columns']; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - column = _ref[_i]; - console.log("column:", column); - the_id = process_id("column", column.t); - 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 += ""; } header += ""; + console.log("windex header is:", header); rows = [ { vn: "n_of_samples", @@ -133,16 +136,17 @@ console.log("rows are:", rows); the_rows = ""; console.log("length of rows:", rows.length); - for (_j = 0, _len1 = rows.length; _j < _len1; _j++) { - row = rows[_j]; + for (_i = 0, _len = rows.length; _i < _len; _i++) { + row = rows[_i]; console.log("rowing"); row_line = ""; row_line += ""; - _ref1 = basic_table['columns']; - for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) { - column = _ref1[_k]; - console.log("apple:", column); - the_id = process_id(column.t, row.vn); + 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 += ""; } @@ -186,10 +190,6 @@ return console.log("Should be now Hide Outliers"); } }; - /* - Calculate Correlations Code - */ - on_corr_method_change = function() { var corr_method; console.log("in beginning of on_corr_method_change"); @@ -199,16 +199,14 @@ return $('#' + corr_method + "_r_desc").show().effect("highlight"); }; $('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()); $('#value_table').change(edit_data_change); console.log("loaded"); + make_table(); + edit_data_change(); return console.log("end"); }); diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html index 09094fc6..afcd06d0 100644 --- a/wqflask/wqflask/templates/search_result_page.html +++ b/wqflask/wqflask/templates/search_result_page.html @@ -39,7 +39,7 @@

To add one or more records to your Selection window, use the checkbox and then click the Add to Collection button.

- + @@ -54,16 +54,16 @@
 #{ column.n }#{ value }
#{ row.pretty }foo
 " + column.n + "" + value + "
" + row.pretty + "foo
@@ -173,7 +173,7 @@ diff --git a/wqflask/wqflask/templates/trait_data_and_analysis.html b/wqflask/wqflask/templates/trait_data_and_analysis.html index c25db7c4..59dfedb3 100644 --- a/wqflask/wqflask/templates/trait_data_and_analysis.html +++ b/wqflask/wqflask/templates/trait_data_and_analysis.html @@ -1305,8 +1305,8 @@ ---> diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 677c7f43..1b60f255 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -1,5 +1,8 @@ from __future__ import absolute_import, division, print_function +import json +import yaml + import flask from wqflask import app @@ -16,10 +19,9 @@ from base import webqtlFormData from pprint import pformat as pf -import yaml - print("latest blue") + @app.route("/") def index_page(): print("Sending index_page") @@ -41,6 +43,7 @@ def data_sharing(): info=info, htmlfilelist=htmlfilelist) + @app.route("/search") def search(): if 'info_database' in request.args: @@ -67,14 +70,19 @@ def whats_new(): print("\nnews_item is: %s\n" % (news_item)) return render_template("whats_new.html", news_items=news_items) -@app.route("/showDatabaseBXD") -def showDatabaseBXD(): + +@app.route("/show_trait") +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) - print("showDatabaseBXD template_vars:", pf(template_vars.__dict__)) + + template_vars.js_data = json.dumps(template_vars.js_data) + + print("show_trait template_vars:", pf(template_vars.__dict__)) return render_template("trait_data_and_analysis.html", **template_vars.__dict__) + @app.route("/corr_compute", methods=('POST',)) def corr_compute(): #print("In corr_compute, request.args is:", pf(request.form)) @@ -84,6 +92,7 @@ def corr_compute(): print("Made it to rendering") return render_template("corr_compute.html", **template_vars.__dict__) + # Todo: Can we simplify this? -Sam def sharing_info_page(): print("In sharing_info_page") -- cgit v1.2.3 From 1e081d88b96660c69d2de9e6b00a54f800348cde Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Wed, 19 Sep 2012 17:06:42 -0500 Subject: Made pearson/spearman options disappear if lit correlation is chosen, began to address how to deal with Trait object in CorrelationPage --- wqflask/base/webqtlTrait.py | 34 ++++++++++++++++++++++ wqflask/wqflask/correlation/CorrelationPage.py | 33 +++++++++++---------- .../new/javascript/trait_data_and_analysis.coffee | 4 +++ .../new/javascript/trait_data_and_analysis.js | 7 ++++- .../wqflask/templates/trait_data_and_analysis.html | 9 +++--- wqflask/wqflask/views.py | 2 +- 6 files changed, 68 insertions(+), 21 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/webqtlTrait.py b/wqflask/base/webqtlTrait.py index 337493ef..8240eafc 100755 --- a/wqflask/base/webqtlTrait.py +++ b/wqflask/base/webqtlTrait.py @@ -660,3 +660,37 @@ class webqtlTrait: else: return dict(name = self.db.fullname, url = webqtlConfig.INFOPAGEHREF % self.db.name) + + def calculate_correlation(self, values, method): + """Calculate the correlation value and p value according to the method specified""" + + #ZS: This takes the list of values of the trait our selected trait is being correlated against and removes the values of the samples our trait has no value for + #There's probably a better way of dealing with this, but I'll have to ask Christian + updated_raw_values = [] + updated_values = [] + for i in range(len(values)): + if values[i] != "None": + updated_raw_values.append(self.raw_values[i]) + updated_values.append(values[i]) + + self.raw_values = updated_raw_values + values = updated_values + + if method == METHOD_SAMPLE_PEARSON or method == METHOD_LIT or method == METHOD_TISSUE_PEARSON: + corr, nOverlap = webqtlUtil.calCorrelation(self.raw_values, values, len(values)) + else: + corr, nOverlap = webqtlUtil.calCorrelationRank(self.raw_values, values, len(values)) + + self.correlation = corr + self.overlap = nOverlap + + if self.overlap < 3: + self.p_value = 1.0 + else: + #ZS - This is probably the wrong way to deal with this. Correlation values of 1.0 definitely exist (the trait correlated against itself), so zero division needs to br prevented. + if abs(self.correlation) >= 1.0: + self.p_value = 0.0 + else: + ZValue = 0.5*log((1.0+self.correlation)/(1.0-self.correlation)) + ZValue = ZValue*sqrt(self.overlap-3) + self.p_value = 2.0*(1.0 - reaper.normp(abs(ZValue))) diff --git a/wqflask/wqflask/correlation/CorrelationPage.py b/wqflask/wqflask/correlation/CorrelationPage.py index 1f7f2553..a9db493b 100644 --- a/wqflask/wqflask/correlation/CorrelationPage.py +++ b/wqflask/wqflask/correlation/CorrelationPage.py @@ -72,7 +72,9 @@ class AuthException(Exception): pass class Trait(object): - def __init__(self, name, raw_values = None, lit_corr = None, tissue_corr = None, p_tissue = None): + + + def __init__(self, name, raw_values = None, lit_corr = None, tissue_corr = None, p_tissue = None): self.name = name self.raw_values = raw_values self.lit_corr = lit_corr @@ -260,16 +262,16 @@ def auth_user_for_db(db, cursor, target_db_name, privilege, username): class CorrelationPage(templatePage): - corrMinInformative = 4 + corr_min_informative = 4 PAGE_HEADING = "Correlation Table" - CORRELATION_METHODS = {"1" : "Genetic Correlation (Pearson's r)", - "2" : "Genetic Correlation (Spearman's rho)", - "3" : "SGO Literature Correlation", - "4" : "Tissue Correlation (Pearson's r)", - "5" : "Tissue Correlation (Spearman's rho)"} - - RANK_ORDERS = {"1": 0, "2": 1, "3": 0, "4": 0, "5": 1} + #CORRELATION_METHODS = {"1" : "Genetic Correlation (Pearson's r)", + # "2" : "Genetic Correlation (Spearman's rho)", + # "3" : "SGO Literature Correlation", + # "4" : "Tissue Correlation (Pearson's r)", + # "5" : "Tissue Correlation (Spearman's rho)"} + # + #RANK_ORDERS = {"1": 0, "2": 1, "3": 0, "4": 0, "5": 1} def error(self, message, *args, **kw): @@ -288,7 +290,7 @@ class CorrelationPage(templatePage): #print("in CorrelationPage __init__ now fd is:", pf(fd.__dict__)) # Connect to the database if not self.openMysql(): - returnt + return # Read the genotype from a file if not fd.genotype: @@ -329,19 +331,20 @@ class CorrelationPage(templatePage): print("samplenames is:", pf(self.sample_names)) #CF - If less than a minimum number of strains/cases in common, don't calculate anything - if len(self.sample_names) < self.corrMinInformative: - detail = ['Fewer than %d strain data were entered for %s data set. No calculation of correlation has been attempted.' % (self.corrMinInformative, fd.RISet)] + if len(self.sample_names) < self.corr_min_informative: + detail = ['Fewer than %d strain data were entered for %s data set. No calculation of correlation has been attempted.' % (self.corr_min_informative, fd.RISet)] self.error(heading=None, detail=detail) for key, value in self.__dict__.items(): if key.startswith("corr"): print("[red] %s - %s" % (key, value)) - correlation_method = self.CORRELATION_METHODS[self.method] - rankOrder = self.RANK_ORDERS[self.method] + #correlation_method = self.CORRELATION_METHODS[self.method] + #rankOrder = self.RANK_ORDERS[self.method] # CF - Number of results returned - self.returnNumber = int(fd.criteria) + # Todo: Get rid of self.returnNumber + self.returnNumber = self.corr_return_results self.record_count = 0 diff --git a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee index 5aef18e5..2952bef5 100644 --- a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee +++ b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee @@ -196,6 +196,10 @@ $ -> 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) diff --git a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js index 05b25197..04f43822 100644 --- a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js +++ b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js @@ -218,7 +218,12 @@ corr_method = $('select[name=corr_method]').val(); console.log("corr_method is:", corr_method); $('.correlation_desc').hide(); - return $('#' + corr_method + "_r_desc").show().effect("highlight"); + $('#' + 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"); diff --git a/wqflask/wqflask/templates/trait_data_and_analysis.html b/wqflask/wqflask/templates/trait_data_and_analysis.html index 05fd457a..16f2e2be 100644 --- a/wqflask/wqflask/templates/trait_data_and_analysis.html +++ b/wqflask/wqflask/templates/trait_data_and_analysis.html @@ -762,10 +762,11 @@
- + Select All - + Select None - + Invert Selection {# - #} - + {{ thisTrait.name.upper() }}

- Pearson -     - Spearman Rank -
+
+ Pearson +     + Spearman Rank +



diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 1b60f255..0befb74a 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -90,7 +90,7 @@ def corr_compute(): print("Have fd") template_vars = CorrelationPage.CorrelationPage(fd) print("Made it to rendering") - return render_template("corr_compute.html", **template_vars.__dict__) + return render_template("correlation_page.html", **template_vars.__dict__) # Todo: Can we simplify this? -Sam -- cgit v1.2.3 From 73fe24131cbd89cdeb6c4c1027c75ca0b6bba3d5 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Tue, 25 Sep 2012 15:44:51 -0500 Subject: Fixed issue with parent strains appearing twice and began replacing variable names (strain -> sample, for example) --- misc/notes.txt | 14 +- wqflask/base/webqtlFormData.py | 90 ++--- wqflask/base/webqtlTrait.py | 34 +- wqflask/wqflask/show_trait/DataEditingPage.py | 373 +++++++++------------ .../new/javascript/trait_data_and_analysis.coffee | 4 +- .../new/javascript/trait_data_and_analysis.js | 4 +- .../wqflask/templates/trait_data_and_analysis.html | 30 +- 7 files changed, 245 insertions(+), 304 deletions(-) (limited to 'wqflask/base') diff --git a/misc/notes.txt b/misc/notes.txt index 9d31fb5d..76962804 100644 --- a/misc/notes.txt +++ b/misc/notes.txt @@ -6,6 +6,9 @@ source ~/ve27/bin/activate To set WQFLASK_SETTINGS environment variable: export WQFLASK_SETTINGS=~/gene/wqflask/cfg/zach_settings.py (or wherever file is located) +To change screen environment variable (if man not working or to get color, for example): +export TERM=screen + To search for commands in history if necessary: history | grep "(whatever is being searched for)" @@ -44,4 +47,13 @@ unset SSH_ASKPASS Python stuff: -Classes should always inherit "object" \ No newline at end of file +Classes should always inherit "object" + +=========================================== + +htop: Gives information on processes, cpu/memory load, etc +dstat: Also gives various system information, resource usage, etc +df: Reports file system disk space usage + + + diff --git a/wqflask/base/webqtlFormData.py b/wqflask/base/webqtlFormData.py index a8aef2a5..eb1ebd5e 100755 --- a/wqflask/base/webqtlFormData.py +++ b/wqflask/base/webqtlFormData.py @@ -46,7 +46,7 @@ from utility import webqtlUtil class webqtlFormData: 'Represents data from a WebQTL form page, needed to generate the next page' - attrs = ('formID','RISet','genotype','strainlist','allstrainlist', + attrs = ('formID','RISet','genotype','samplelist','allsamplelist', 'suggestive','significance','submitID','identification', 'enablevariance', 'nperm','nboot','email','incparentsf1','genotype_1','genotype_2','traitInfo') @@ -116,12 +116,12 @@ class webqtlFormData: self.nboot = set_number(self.nboot) - #if self.allstrainlist: - # self.allstrainlist = map(string.strip, string.split(self.allstrainlist)) - print("self.allstrainlist is:", self.allstrainlist) - if self.allstrainlist: - self.allstrainlist = self.allstrainlist.split() - print("now self.allstrainlist is:", self.allstrainlist) + #if self.allsamplelist: + # self.allsamplelist = map(string.strip, string.split(self.allsamplelist)) + print("self.allsamplelist is:", self.allsamplelist) + if self.allsamplelist: + self.allsamplelist = self.allsamplelist.split() + print("now self.allsamplelist is:", self.allsamplelist) #self.readGenotype() #self.readData() @@ -183,7 +183,7 @@ class webqtlFormData: self.incparentsf1 = 0 self.genotype = self.genotype_1 - self.strainlist = list(self.genotype.prgy) + self.samplelist = list(self.genotype.prgy) self.f1list = [] self.parlist = [] @@ -193,7 +193,7 @@ class webqtlFormData: self.parlist = [_mat, _pat] - def readData(self, strainlist, incf1=None): + def readData(self, samplelist, incf1=None): '''read user input data or from trait data and analysis form''' if incf1 == None: @@ -201,11 +201,11 @@ class webqtlFormData: if not self.genotype: self.readGenotype() - if not strainlist: + if not samplelist: if incf1: - strainlist = self.f1list + self.strainlist + samplelist = self.f1list + self.samplelist else: - strainlist = self.strainlist + samplelist = self.samplelist #print("before traitfiledata self.traitfile is:", pf(self.traitfile)) @@ -223,7 +223,7 @@ class webqtlFormData: except ValueError: return None - print("bottle strainlist is:", strainlist) + print("bottle samplelist is:", samplelist) if traitfiledata: tt = traitfiledata.split() values = map(webqtlUtil.StringAsFloat, tt) @@ -232,15 +232,15 @@ class webqtlFormData: values = map(webqtlUtil.StringAsFloat, tt) else: print("mapping formdataasfloat") - #values = map(self.FormDataAsFloat, strainlist) - values = [to_float(getattr(self, key)) for key in strainlist] + #values = map(self.FormDataAsFloat, samplelist) + values = [to_float(getattr(self, key)) for key in samplelist] print("rocket values is:", values) - if len(values) < len(strainlist): - values += [None] * (len(strainlist) - len(values)) - elif len(values) > len(strainlist): - values = values[:len(strainlist)] + if len(values) < len(samplelist): + values += [None] * (len(samplelist) - len(values)) + elif len(values) > len(samplelist): + values = values[:len(samplelist)] print("now values is:", values) @@ -251,58 +251,58 @@ class webqtlFormData: tt = variancepastedata.split() variances = map(webqtlUtil.StringAsFloat, tt) else: - variances = map(self.FormVarianceAsFloat, strainlist) + variances = map(self.FormVarianceAsFloat, samplelist) - if len(variances) < len(strainlist): - variances += [None]*(len(strainlist) - len(variances)) - elif len(variances) > len(strainlist): - variances = variances[:len(strainlist)] + if len(variances) < len(samplelist): + variances += [None]*(len(samplelist) - len(variances)) + elif len(variances) > len(samplelist): + variances = variances[:len(samplelist)] if Nfiledata: tt = string.split(Nfiledata) - nstrains = map(webqtlUtil.IntAsFloat, tt) - if len(nstrains) < len(strainlist): - nstrains += [None]*(len(strainlist) - len(nstrains)) + nsamples = map(webqtlUtil.IntAsFloat, tt) + if len(nsamples) < len(samplelist): + nsamples += [None]*(len(samplelist) - len(nsamples)) else: - nstrains = map(self.FormNAsFloat, strainlist) + nsamples = map(self.FormNAsFloat, samplelist) - ##values, variances, nstrains is obsolete + ##values, variances, nsamples is obsolete self.allTraitData = {} - for i, _strain in enumerate(strainlist): + for i, _sample in enumerate(samplelist): if values[i] != None: - self.allTraitData[_strain] = webqtlCaseData( - _strain, values[i], variances[i], nstrains[i]) + self.allTraitData[_sample] = webqtlCaseData( + _sample, values[i], variances[i], nsamples[i]) print("allTraitData is:", pf(self.allTraitData)) - def informativeStrains(self, strainlist=None, include_variances = None): - '''if readData was called, use this to output informative strains (strain with values)''' + def informativeStrains(self, samplelist=None, include_variances = None): + '''if readData was called, use this to output informative samples (sample with values)''' - if not strainlist: - strainlist = self.strainlist + if not samplelist: + samplelist = self.samplelist - strains = [] + samples = [] values = [] variances = [] #print("self.allTraitData is:", pf(self.allTraitData)) - for strain in strainlist: - if strain in self.allTraitData: - _val, _var = self.allTraitData[strain].value, self.allTraitData[strain].variance + for sample in samplelist: + if sample in self.allTraitData: + _val, _var = self.allTraitData[sample].value, self.allTraitData[sample].variance if _val != None: if include_variances: if _var != None: - strains.append(strain) + samples.append(sample) values.append(_val) variances.append(_var) else: - strains.append(strain) + samples.append(sample) values.append(_val) variances.append(None) - return strains, values, variances, len(strains) + return samples, values, variances, len(samples) @@ -336,8 +336,8 @@ class webqtlFormData: self.identification = 'BXD : Coat color example by Lu Lu, et al' #self.readGenotype() #self.genotype.ReadMM('AXBXAforQTL') - #self.strainlist = map((lambda x, y='': '%s%s' % (y,x)), self.genotype.prgy) - #self.strainlist.sort() + #self.samplelist = map((lambda x, y='': '%s%s' % (y,x)), self.genotype.prgy) + #self.samplelist.sort() self.allTraitData = {'BXD29': webqtlCaseData(3), 'BXD28': webqtlCaseData(2), 'BXD25': webqtlCaseData(2), 'BXD24': webqtlCaseData(2), 'BXD27': webqtlCaseData(2), 'BXD21': webqtlCaseData(1), 'BXD20': webqtlCaseData(4), 'BXD23': webqtlCaseData(4), diff --git a/wqflask/base/webqtlTrait.py b/wqflask/base/webqtlTrait.py index 8240eafc..4d642ffe 100755 --- a/wqflask/base/webqtlTrait.py +++ b/wqflask/base/webqtlTrait.py @@ -160,20 +160,20 @@ class webqtlTrait: __str__ = getName __repr__ = __str__ - def exportData(self, strainlist, type="val"): + def exportData(self, samplelist, type="val"): """ - export data according to strainlist + export data according to samplelist mostly used in calculating correlation """ result = [] - for strain in strainlist: - if self.data.has_key(strain): + for sample in samplelist: + if self.data.has_key(sample): if type=='val': - result.append(self.data[strain].val) + result.append(self.data[sample].val) elif type=='var': - result.append(self.data[strain].var) + result.append(self.data[sample].var) elif type=='N': - result.append(self.data[strain].N) + result.append(self.data[sample].N) else: raise KeyError, `type`+' type is incorrect.' else: @@ -182,19 +182,19 @@ class webqtlTrait: def exportInformative(self, incVar=0): """ - export informative strain + export informative sample mostly used in qtl regression """ - strains = [] + samples = [] vals = [] vars = [] - for strain, value in self.data.items(): + for sample, value in self.data.items(): if value.val != None: if not incVar or value.var != None: - strains.append(strain) + samples.append(sample) vals.append(value.val) vars.append(value.var) - return strains, vals, vars + return samples, vals, vars # @@ -225,10 +225,10 @@ class webqtlTrait: - def retrieveData(self, strainlist=None): + def retrieveData(self, samplelist=None): - if strainlist == None: - strainlist = [] + if samplelist == None: + samplelist = [] assert self.db and self.cursor if self.db.type == 'Temp': @@ -334,10 +334,10 @@ class webqtlTrait: if results: self.mysqlid = results[0][-1] - #if strainlist: + #if samplelist: for item in results: #name, value, variance, num_cases = item - if not strainlist or (strainlist and name in strainlist): + if not samplelist or (samplelist and name in samplelist): #if value != None: # num_cases = None # if self.db.type in ('Publish', 'Temp'): diff --git a/wqflask/wqflask/show_trait/DataEditingPage.py b/wqflask/wqflask/show_trait/DataEditingPage.py index 13de0b40..01541e9e 100755 --- a/wqflask/wqflask/show_trait/DataEditingPage.py +++ b/wqflask/wqflask/show_trait/DataEditingPage.py @@ -108,9 +108,9 @@ class DataEditingPage(templatePage): bootCheck = None, permCheck = None, applyVarianceSE = None, - strainNames = '_', - strainVals = '_', - strainVars = '_', + sampleNames = '_', + sampleVals = '_', + sampleVars = '_', otherStrainNames = '_', otherStrainVals = '_', otherStrainVars = '_', @@ -196,8 +196,8 @@ class DataEditingPage(templatePage): # self.dispTraitValues(fd, varianceDataPage, nCols, thisTrait) # - if fd.allstrainlist: - hddn['allstrainlist'] = string.join(fd.allstrainlist, ' ') + if fd.allsamplelist: + hddn['allsamplelist'] = string.join(fd.allsamplelist, ' ') # We put isSE into hddn if nCols == 6 and fd.varianceDispName != 'Variance': @@ -892,87 +892,87 @@ class DataEditingPage(templatePage): ########################################## def dispBasicStatistics(self, fd, thisTrait): - #XZ, June 22, 2011: The definition and usage of primary_strains, other_strains, specialStrains, all_strains 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.strainlist later. + #XZ, June 22, 2011: The definition and usage of primary_samples, other_samples, specialStrains, all_samples are not clear and hard to understand. But since they are only used in this function for draw graph purpose, they will not hurt the business logic outside. As of June 21, 2011, this function seems work fine, so no hurry to clean up. These parameters and code in this function should be cleaned along with fd.f1list, fd.parlist, fd.samplelist later. #stats_row = HT.TR() #stats_cell = HT.TD() if fd.genotype.type == "riset": - strainlist = fd.f1list + fd.strainlist + samplelist = fd.f1list + fd.samplelist else: - strainlist = fd.f1list + fd.parlist + fd.strainlist + samplelist = fd.f1list + fd.parlist + fd.samplelist - other_strains = [] #XZ: strain that is not of primary group - specialStrains = [] #XZ: This might be replaced by other_strains / ZS: It is just other strains without parent/f1 strains. - all_strains = [] - primary_strains = [] #XZ: strain of primary group, e.g., BXD, LXS + 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 strain in thisTrait.data.keys(): - strainName = strain.replace("_2nd_", "") - if strain not in strainlist: - if thisTrait.data[strainName].value != None: - if strain.find('F1') < 0: - specialStrains.append(strain) - if (thisTrait.data[strainName].value != None) and (strain not in (fd.f1list + fd.parlist)): - other_strains.append(strain) #XZ: at current stage, other_strains doesn't include parent strains and F1 strains of primary group + for sample in thisTrait.data.keys(): + sampleName = sample.replace("_2nd_", "") + if sample not in samplelist: + if thisTrait.data[sampleName].value != None: + if sample.find('F1') < 0: + specialStrains.append(sample) + if (thisTrait.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 (thisTrait.data[strainName].value != None) and (strain not in (fd.f1list + fd.parlist)): - primary_strains.append(strain) #XZ: at current stage, the primary_strains is the same as fd.strainlist / ZS: I tried defining primary_strains as fd.strainlist instead, but in some cases it ended up including the parent strains (1436869_at BXD) - - if len(other_strains) > 3: - other_strains.sort(key=webqtlUtil.natsort_key) - primary_strains.sort(key=webqtlUtil.natsort_key) - primary_strains = map(lambda X:"_2nd_"+X, fd.f1list + fd.parlist) + primary_strains #XZ: note that fd.f1list and fd.parlist are added. - all_strains = primary_strains + other_strains - other_strains = map(lambda X:"_2nd_"+X, fd.f1list + fd.parlist) + other_strains #XZ: note that fd.f1list and fd.parlist are added. + if (thisTrait.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_strains) > 0) and (len(primary_strains) + len(other_strains) > 3): + 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_strains = primary_strains - all_strains.sort(key=webqtlUtil.natsort_key) - all_strains = map(lambda X:"_2nd_"+X, fd.f1list + fd.parlist) + all_strains - primary_strains = map(lambda X:"_2nd_"+X, fd.f1list + fd.parlist) + primary_strains + 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_strains = strainlist + all_samples = samplelist - other_strains.sort(key=webqtlUtil.natsort_key) - all_strains = all_strains + other_strains + other_samples.sort(key=webqtlUtil.natsort_key) + all_samples = all_samples + other_samples - if (len(other_strains)) > 0 and (len(primary_strains) + len(other_strains) > 4): - #One set of vals for all, selected strain only, and non-selected only + 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 strains/cases for values - #for strain_type in (all_strains, primary_strains, other_strains): - for strainNameOrig in all_strains: - strainName = strainNameOrig.replace("_2nd_", "") + #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 thisTrait:", type(thisTrait)) print(" name:", thisTrait.__class__.__name__) print(" thisTrait:", thisTrait) - print(" type of thisTrait.data[strainName]:", type(thisTrait.data[strainName])) - print(" name:", thisTrait.data[strainName].__class__.__name__) - print(" thisTrait.data[strainName]:", thisTrait.data[strainName]) - thisval = thisTrait.data[strainName].value + print(" type of thisTrait.data[sampleName]:", type(thisTrait.data[sampleName])) + print(" name:", thisTrait.data[sampleName].__class__.__name__) + print(" thisTrait.data[sampleName]:", thisTrait.data[sampleName]) + thisval = thisTrait.data[sampleName].value print(" thisval:", thisval) - thisvar = thisTrait.data[strainName].variance + thisvar = thisTrait.data[sampleName].variance print(" thisvar:", thisvar) - thisValFull = [strainName, thisval, thisvar] + thisValFull = [sampleName, thisval, thisvar] print(" thisValFull:", thisValFull) #except: # continue @@ -980,33 +980,33 @@ class DataEditingPage(templatePage): vals1.append(thisValFull) - #vals1 = [[strainNameOrig.replace("_2nd_", ""), - # thisTrait.data[strainName].val, - # thisTrait.data[strainName].var] - # for strainNameOrig in all_strains]] + #vals1 = [[sampleNameOrig.replace("_2nd_", ""), + # thisTrait.data[sampleName].val, + # thisTrait.data[sampleName].var] + # for sampleNameOrig in all_samples]] # - #Using just the RISet strain - for strainNameOrig in primary_strains: - strainName = strainNameOrig.replace("_2nd_", "") + #Using just the RISet sample + for sampleNameOrig in primary_samples: + sampleName = sampleNameOrig.replace("_2nd_", "") #try: - thisval = thisTrait.data[strainName].value - thisvar = thisTrait.data[strainName].variance - thisValFull = [strainName,thisval,thisvar] + thisval = thisTrait.data[sampleName].value + thisvar = thisTrait.data[sampleName].variance + thisValFull = [sampleName,thisval,thisvar] #except: # continue vals2.append(thisValFull) - #Using all non-RISet strains only - for strainNameOrig in other_strains: - strainName = strainNameOrig.replace("_2nd_", "") + #Using all non-RISet samples only + for sampleNameOrig in other_samples: + sampleName = sampleNameOrig.replace("_2nd_", "") #try: - thisval = thisTrait.data[strainName].value - thisvar = thisTrait.data[strainName].variance - thisValFull = [strainName,thisval,thisvar] + thisval = thisTrait.data[sampleName].value + thisvar = thisTrait.data[sampleName].variance + thisValFull = [sampleName,thisval,thisvar] #except: # continue @@ -1017,14 +1017,14 @@ class DataEditingPage(templatePage): else: vals = [] - #Using all strains/cases for values - for strainNameOrig in all_strains: - strainName = strainNameOrig.replace("_2nd_", "") + #Using all samples/cases for values + for sampleNameOrig in all_samples: + sampleName = sampleNameOrig.replace("_2nd_", "") #try: - thisval = thisTrait.data[strainName].value - thisvar = thisTrait.data[strainName].variance - thisValFull = [strainName,thisval,thisvar] + thisval = thisTrait.data[sampleName].value + thisvar = thisTrait.data[sampleName].variance + thisValFull = [sampleName,thisval,thisvar] #except: # continue @@ -1041,10 +1041,10 @@ class DataEditingPage(templatePage): stats_script_text = """$(function() { $("#stats_tabs").tabs();});""" #stats_cell.append(stats_container) break - elif (i == 1 and len(primary_strains) < 4): + 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_strains) < 4): + 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();});""" @@ -1609,14 +1609,15 @@ class DataEditingPage(templatePage): print("in dispTraitValues") if fd.genotype.type == "riset": - allstrainlist_neworder = fd.f1list + fd.strainlist + allsamplelist_neworder = fd.f1list + fd.samplelist else: - allstrainlist_neworder = fd.f1list + fd.parlist + fd.strainlist + allsamplelist_neworder = fd.f1list + fd.parlist + fd.samplelist attribute_ids = [] attribute_names = [] #try: - #ZS: Id values for this trait's extra attributes; used to create "Exclude" dropdown and query for attribute values and create + #ZS: Id values for this trait's extra attributes; + #used to create "Exclude" dropdown and query for attribute values and create self.cursor.execute("""SELECT CaseAttribute.Id, CaseAttribute.Name FROM CaseAttribute, CaseAttributeXRef WHERE CaseAttributeXRef.ProbeSetFreezeId = %s AND @@ -1624,150 +1625,78 @@ class DataEditingPage(templatePage): group by CaseAttributeXRef.CaseAttributeId""", (str(thisTrait.db.id),)) - #exclude_menu = HT.Select(name="exclude_menu") - #dropdown_menus = [] #ZS: list of dropdown menus with the distinct values of each attribute (contained in DIVs so the style parameter can be edited and they can be hidden) - - #for attribute in self.cursor.fetchall(): - # #attribute_ids.append(attribute[0]) - # #attribute_names.append(attribute[1]) - # pass for this_attr_name in attribute_names: - #exclude_menu.append((this_attr_name.capitalize(), this_attr_name)) # Todo: Needs testing still! self.cursor.execute("""SELECT DISTINCT CaseAttributeXRef.Value FROM CaseAttribute, CaseAttributeXRef WHERE CaseAttribute.Name = %s AND CaseAttributeXRef.CaseAttributeId = CaseAttribute.Id""", (this_attr_name,)) - #try: + distinct_values = self.cursor.fetchall() - #attr_value_menu_div = HT.Div(style="display:none;", Class="attribute_values") #container used to show/hide dropdown menus - #attr_value_menu = HT.Select(name=this_attr_name) - #attr_value_menu.append(("None", "show_all")) - #for value in distinct_values: - # #attr_value_menu.append((str(value[0]), value[0])) - # pass - #attr_value_menu_div.append(attr_value_menu) - #dropdown_menus.append(attr_value_menu_div) - #except: - # pass - #except: - # pass - - #for strain in thisTrait.data.keys(): - # if strain not in allstrainlist_neworder: - # pass - # #other_strains.append(strain) - # - #if other_strains: - # #blockMenu.append(('%s Only' % fd.RISet,'1')) - # #blockMenu.append(('Non-%s Only' % fd.RISet,'0')) - # #blockMenuSpan.append(blockMenu) - # pass - #else: - # pass - - #showHideOutliers = HT.Input(type='button', name='showHideOutliers', value=' Hide Outliers ', Class='button') - #showHideMenuOptions = HT.Span(Id="showHideOptions", style="line-height:225%;") - #if other_strains: - # pass - #showHideMenuOptions.append(HT.Bold("  Block samples by index:    "), blockSamplesField, "   ", blockMenuSpan, "   ", blockSamplesButton, HT.BR()) - #else: - # pass - #showHideMenuOptions.append(HT.Bold("  Block samples by index:    "), blockSamplesField, "   ", blockSamplesButton, HT.BR()) - #exportButton = HT.Input(type='button', name='export', value=' Export ', Class='button') - #if len(attribute_names) > 0: - # excludeButton = HT.Input(type='button', name='excludeGroup', value=' Block ', Class='button') - #showHideMenuOptions.append(HT.Bold("  Block samples by group:"), " "*5, exclude_menu, " "*5) - #for menu in dropdown_menus: - # pass - #showHideMenuOptions.append(menu) - #showHideMenuOptions.append(" "*5, excludeButton, HT.BR()) - #showHideMenuOptions.append(HT.Bold("  Options:"), " "*5, showHideNoValue, " "*5, showHideOutliers, " "*5, resetButton, " "*5, exportButton) - - #traitTableOptions.append(showHideMenuOptions,HT.BR(),HT.BR()) - #traitTableOptions.append(HT.Span("  Outliers highlighted in ", HT.Bold(" red ", style="background-color:red;"), " can be hidden using the ", - # HT.Strong(" Hide Outliers "), " button,",HT.BR(),"  and samples with no value (x) can be hidden by clicking ", - # HT.Strong(" Hide No Value "), "."), HT.BR()) - - - #dispintro = HT.Paragraph("Edit or delete values in the Trait Data boxes, and use the ", HT.Strong("Reset"), " option as needed.",Class="fs12", style="margin-left:20px;") - # - #table = HT.TableLite(cellspacing=0, cellpadding=0, width="100%", Class="target5") #Everything needs to be inside this table object in order for the toggle to work - #container = HT.Div() #This will contain everything and be put into a cell of the table defined above - # - #container.append(dispintro, traitTableOptions, HT.BR()) - - #primary_table = HT.TableLite(cellspacing=0, cellpadding=0, Id="sortable1", Class="tablesorter") - #primary_header = self.getTableHeader(fd=fd, thisTrait=thisTrait, nCols=nCols, attribute_names=attribute_names) #Generate header for primary table object - - #other_strainsExist = False - this_trait_strains = set(thisTrait.data.keys()) - #ZS - Checks if there are any strains in this_trait_strains that aren't in allstrainlist_neworder - other_strainsExist = this_trait_strains - set(allstrainlist_neworder) - - #for strain in thisTrait.data.keys(): - # print("hjl - strain is:", strain) - # if strain not in allstrainlist_neworder: - # other_strainsExist = True - # break + this_trait_samples = set(thisTrait.data.keys()) + #ZS - Checks if there are any samples in this_trait_samples that aren't in allsamplelist_neworder + other_samplesExist = this_trait_samples - set(allsamplelist_neworder) mainForm = None # Just trying to get things working - primary_strainlist = fd.parlist + allstrainlist_neworder + primary_samplelist = allsamplelist_neworder + + print("primary_samplelist is:", pf(primary_samplelist)) - primary_strains = self.create_strain_objects(fd=fd, + primary_samples = self.create_sample_objects(fd=fd, varianceDataPage=varianceDataPage, - strainlist=primary_strainlist, + samplelist=primary_samplelist, mainForm=mainForm, thisTrait=thisTrait, - other_strainsExist=other_strainsExist, + other_samplesExist=other_samplesExist, attribute_ids=attribute_ids, attribute_names=attribute_names, - strains='primary') - + samples='primary') + - other_strains = [] - for strain in thisTrait.data.keys(): - print("hjk - strain is:", strain) - if strain not in allstrainlist_neworder + fd.f1list + fd.parlist: - allstrainlist_neworder.append(strain) - other_strains.append(strain) + other_samples = [] + for sample in thisTrait.data.keys(): + print("hjk - sample is:", sample) + if sample not in allsamplelist_neworder: + allsamplelist_neworder.append(sample) + other_samples.append(sample) - if other_strains: + if other_samples: unappended_par_f1 = fd.f1list + fd.parlist - par_f1_strains = ["_2nd_" + strain for strain in unappended_par_f1] + par_f1_samples = ["_2nd_" + sample for sample in unappended_par_f1] - other_strains.sort() #Sort other strains - other_strains = par_f1_strains + other_strains + other_samples.sort() #Sort other samples + other_samples = par_f1_samples + other_samples - other_strains = self.create_strain_objects(fd=fd, + other_samples = self.create_sample_objects(fd=fd, varianceDataPage=varianceDataPage, - strainlist=other_strains, + samplelist=other_samples, mainForm=mainForm, thisTrait=thisTrait, attribute_ids=attribute_ids, attribute_names=attribute_names, - strains='other') + samples='other') #TODO: Figure out why this if statement is written this way - Zach - if (other_strains or (fd.f1list and thisTrait.data.has_key(fd.f1list[0])) + if (other_samples or (fd.f1list and thisTrait.data.has_key(fd.f1list[0])) or (fd.f1list and thisTrait.data.has_key(fd.f1list[1]))): print("hjs") - fd.allstrainlist = allstrainlist_neworder + fd.allsamplelist = allsamplelist_neworder - self.primary_strains = dict(header = "%s Only" % (fd.RISet), - strains = primary_strains,) + self.primary_samples = dict(header = "%s Only" % (fd.RISet), + samples = primary_samples,) - self.other_strains = dict(header = "Non-%s" % (fd.RISet), - strains = other_strains,) + self.other_samples = dict(header = "Non-%s" % (fd.RISet), + samples = other_samples,) + - def create_strain_objects(self, fd, varianceDataPage, strainlist, mainForm, thisTrait, - other_strainsExist=None, attribute_ids=None, - attribute_names=None, strains='primary'): + def create_sample_objects(self, fd, varianceDataPage, samplelist, mainForm, thisTrait, + other_samplesExist=None, attribute_ids=None, + attribute_names=None, samples='primary'): if attribute_ids == None: attribute_ids = [] @@ -1776,47 +1705,47 @@ class DataEditingPage(templatePage): attribute_names = [] #XZ, Aug 23, 2010: I commented the code related to the display of animal case - #strainInfo = thisTrait.has_key('strainInfo') and thisTrait.strainInfo - print("in create_strain_objects") + #sampleInfo = thisTrait.has_key('sampleInfo') and thisTrait.sampleInfo + print("in create_sample_objects") #table_body = [] ################### Only used to find upperBound and lowerBound #vals = [] - #for strainNameOrig in strainlist: - # strainName = strainNameOrig.replace("_2nd_", "") - # print("pen: %s - %s" % (strainNameOrig, strainName)) + #for sampleNameOrig in samplelist: + # sampleName = sampleNameOrig.replace("_2nd_", "") + # print("pen: %s - %s" % (sampleNameOrig, sampleName)) # try: - # thisval = thisTrait.data[strainName].value - # thisvar = thisTrait.data[strainName].variance - # thisValFull = [strainName, thisval, thisvar] + # thisval = thisTrait.data[sampleName].value + # thisvar = thisTrait.data[sampleName].variance + # thisValFull = [sampleName, thisval, thisvar] # # vals.append(thisValFull) # except KeyError: - # print("**x** Skipping:", strainName) + # print("**x** Skipping:", sampleName) # #upperBound, lowerBound = Plot.findOutliers(vals) # ZS: Values greater than upperBound or less than lowerBound are considered outliers. - the_strains = [] + the_samples = [] - for counter, strainNameOrig in enumerate(strainlist, 1): - strainName = strainNameOrig.replace("_2nd_", "") - strainNameAdd = '' - if fd.RISet == 'AXBXA' and strainName in ('AXB18/19/20','AXB13/14','BXA8/17'): - strainNameAdd = HT.Href(url='/mouseCross.html#AXB/BXA', text=HT.Sup('#'), Class='fs12', target="_blank") + for counter, sampleNameOrig in enumerate(samplelist, 1): + sampleName = sampleNameOrig.replace("_2nd_", "") + sampleNameAdd = '' + if fd.RISet == 'AXBXA' and sampleName in ('AXB18/19/20','AXB13/14','BXA8/17'): + sampleNameAdd = HT.Href(url='/mouseCross.html#AXB/BXA', text=HT.Sup('#'), Class='fs12', target="_blank") try: - strain = thisTrait.data[strainName] + sample = thisTrait.data[sampleName] except KeyError: - print("No strain %s, let's create it now" % strainName) - strain = webqtlCaseData.webqtlCaseData(strainName) - print("zyt - strainNameOrig:", strainNameOrig) + print("No sample %s, let's create it now" % sampleName) + sample = webqtlCaseData.webqtlCaseData(sampleName) + print("zyt - sampleNameOrig:", sampleNameOrig) - if strains == 'primary': - strain.this_id = "Primary_" + str(counter) + if samples == 'primary': + sample.this_id = "Primary_" + str(counter) else: - strain.this_id = "Other_" + str(counter) + sample.this_id = "Other_" + str(counter) #### For extra attribute columns; currently only used by two human datasets - Zach if thisTrait and thisTrait.db and thisTrait.db.type == 'ProbeSet': @@ -1828,9 +1757,9 @@ class DataEditingPage(templatePage): WHERE Strain.Name = '%s' and StrainXRef.StrainId = Strain.Id and InbredSet.Id = StrainXRef.InbredSetId and - InbredSet.Name = '%s'""" % (strainName, fd.RISet)) + InbredSet.Name = '%s'""" % (sampleName, fd.RISet)) - strain_id = self.cursor.fetchone()[0] + sample_id = self.cursor.fetchone()[0] attr_counter = 1 # This is needed so the javascript can know which attribute type to associate this value with for the exported excel sheet (each attribute type being a column). for attribute_id in attribute_ids: @@ -1841,7 +1770,7 @@ class DataEditingPage(templatePage): WHERE ProbeSetFreezeId = '%s' AND StrainId = '%s' AND CaseAttributeId = '%s' - group by CaseAttributeXRef.CaseAttributeId""" % (thisTrait.db.id, strain_id, str(attribute_id))) + group by CaseAttributeXRef.CaseAttributeId""" % (thisTrait.db.id, sample_id, str(attribute_id))) attributeValue = self.cursor.fetchone()[0] #Trait-specific attributes, if any @@ -1851,17 +1780,17 @@ class DataEditingPage(templatePage): except: pass - span_Id = strains+"_attribute"+str(attr_counter)+"_sample"+str(i+1) + span_Id = samples+"_attribute"+str(attr_counter)+"_sample"+str(i+1) attr_container = HT.Span(attributeValue, Id=span_Id) attr_className = str(attributeValue) + " " + className table_row.append(HT.TD(attr_container, align='right', Class=attr_className)) attr_counter += 1 - the_strains.append(strain) + the_samples.append(sample) #table_body.append(table_row) - do_outliers(the_strains) - print("*the_strains are [%i]: %s" % (len(the_strains), pf(the_strains))) - return the_strains + do_outliers(the_samples) + print("*the_samples are [%i]: %s" % (len(the_samples), pf(the_samples))) + return the_samples def getTableHeader(self, fd, thisTrait, nCols, attribute_names): @@ -1909,15 +1838,15 @@ class DataEditingPage(templatePage): -def do_outliers(strain_objects): - values = [strain.value for strain in strain_objects if strain.value != None] +def do_outliers(sample_objects): + values = [sample.value for sample in sample_objects if sample.value != None] upper_bound, lower_bound = Plot.find_outliers(values) - for strain in strain_objects: - if strain.value: - if upper_bound and strain.value > upper_bound: - strain.outlier = True - elif lower_bound and strain.value < lower_bound: - strain.outlier = True + for sample in sample_objects: + if sample.value: + if upper_bound and sample.value > upper_bound: + sample.outlier = True + elif lower_bound and sample.value < lower_bound: + sample.outlier = True else: - strain.outlier = False + sample.outlier = False diff --git a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee index 94ae0203..803045d5 100644 --- a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee +++ b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee @@ -46,13 +46,13 @@ $ -> all_cases: new Stats([]) console.log("at beginning:", sample_sets) - values = $('#value_table').find(".edit_strain_value") + 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_strain_checkbox") + checkbox = $(row).find(".edit_sample_checkbox") checked = $(checkbox).attr('checked') if checked and is_number(real_value) and real_value != "" diff --git a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js index 9d7918a1..55bc1302 100644 --- a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js +++ b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js @@ -69,13 +69,13 @@ all_cases: new Stats([]) }; console.log("at beginning:", sample_sets); - values = $('#value_table').find(".edit_strain_value"); + 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_strain_checkbox"); + checkbox = $(row).find(".edit_sample_checkbox"); checked = $(checkbox).attr('checked'); if (checked && is_number(real_value) && real_value !== "") { real_value = parseFloat(real_value); diff --git a/wqflask/wqflask/templates/trait_data_and_analysis.html b/wqflask/wqflask/templates/trait_data_and_analysis.html index 3d2ec636..89ce7d46 100644 --- a/wqflask/wqflask/templates/trait_data_and_analysis.html +++ b/wqflask/wqflask/templates/trait_data_and_analysis.html @@ -14,10 +14,10 @@ - + - + @@ -32,11 +32,11 @@ - + - + @@ -1245,12 +1245,12 @@
- {% for strain_type in (primary_strains, other_strains) %} + {% for sample_type in (primary_samples, other_samples) %}
-

{{ strain_type.header }}

+

{{ sample_type.header }}

-
{# Slightly tortuous, but best way to get the id we need #} +
{# Slightly tortuous, but best way to get the id we need #} @@ -1266,21 +1266,21 @@ - {% for strain in strain_type.strains %} - + {% for sample in sample_type.samples %} + {# Todo: Add IDs #} @@ -1290,8 +1290,8 @@ {# Todo: Add IDs #} {% endfor %} -- cgit v1.2.3 From 667c45ac54d4faab396723d1649dff1e27686b1f Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Tue, 25 Sep 2012 18:26:15 -0500 Subject: Got trait data page running for human dataset, changed list of sample objects to a SampleList object --- wqflask/base/webqtlCaseData.py | 2 +- wqflask/base/webqtlDataset.py | 4 +- wqflask/base/webqtlFormData.py | 9 +- wqflask/base/webqtlTrait.py | 4 +- wqflask/wqflask/show_trait/DataEditingPage.py | 261 ++++++--------------- wqflask/wqflask/show_trait/show_trait_page.py | 64 +---- .../wqflask/templates/trait_data_and_analysis.html | 11 +- 7 files changed, 96 insertions(+), 259 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/webqtlCaseData.py b/wqflask/base/webqtlCaseData.py index 25665c55..c805a95c 100755 --- a/wqflask/base/webqtlCaseData.py +++ b/wqflask/base/webqtlCaseData.py @@ -40,7 +40,7 @@ class webqtlCaseData(object): self.outlier = None # Not set to True/False until later def __repr__(self): - str = "" + str = " " if self.value != None: str += "value=%2.3f" % self.value if self.variance != None: diff --git a/wqflask/base/webqtlDataset.py b/wqflask/base/webqtlDataset.py index f8491bb1..4f98e90c 100755 --- a/wqflask/base/webqtlDataset.py +++ b/wqflask/base/webqtlDataset.py @@ -32,8 +32,8 @@ import webqtlConfig class webqtlDataset: """ - Database class defines a database in webqtl, can be either Microarray, - Published phenotype, genotype, or user input database(temp) + Dataset class defines a dataset in webqtl, can be either Microarray, + Published phenotype, genotype, or user input dataset(temp) """ def __init__(self, dbName, cursor=None): diff --git a/wqflask/base/webqtlFormData.py b/wqflask/base/webqtlFormData.py index eb1ebd5e..63263895 100755 --- a/wqflask/base/webqtlFormData.py +++ b/wqflask/base/webqtlFormData.py @@ -46,9 +46,9 @@ from utility import webqtlUtil class webqtlFormData: 'Represents data from a WebQTL form page, needed to generate the next page' - attrs = ('formID','RISet','genotype','samplelist','allsamplelist', - 'suggestive','significance','submitID','identification', 'enablevariance', - 'nperm','nboot','email','incparentsf1','genotype_1','genotype_2','traitInfo') + attrs = ('formID','RISet','genotype','samplelist','allsamplelist', 'display_variance' + 'suggestive','significance','submitID','identification', 'enablevariance', + 'nperm','nboot','email','incparentsf1','genotype_1','genotype_2','traitInfo') #XZ: Attention! All attribute values must be picklable! @@ -61,6 +61,9 @@ class webqtlFormData: print("in webqtlFormData start_vars are:", pf(start_vars)) for item in webqtlFormData.attrs: self.__dict__[item] = None + + #ZS: This is only used in DataEditingPage.py (as far as I know) + self.varianceDispName = None for item in start_vars: self.__dict__[item] = start_vars[item] diff --git a/wqflask/base/webqtlTrait.py b/wqflask/base/webqtlTrait.py index 4d642ffe..efbc1464 100755 --- a/wqflask/base/webqtlTrait.py +++ b/wqflask/base/webqtlTrait.py @@ -157,8 +157,8 @@ class webqtlTrait: #def __str__(self): # #return "%s %s" % (self.getName(), self.riset) # return self.getName() - __str__ = getName - __repr__ = __str__ + #__str__ = getName + #__repr__ = __str__ def exportData(self, samplelist, type="val"): """ diff --git a/wqflask/wqflask/show_trait/DataEditingPage.py b/wqflask/wqflask/show_trait/DataEditingPage.py index 83dbfe03..d186889b 100755 --- a/wqflask/wqflask/show_trait/DataEditingPage.py +++ b/wqflask/wqflask/show_trait/DataEditingPage.py @@ -1,7 +1,5 @@ from __future__ import absolute_import, print_function, division -print("Google") - import string import os import cPickle @@ -22,26 +20,17 @@ from basicStatistics import BasicStatisticsFunctions from pprint import pformat as pf -######################################### -# DataEditingPage -######################################### class DataEditingPage(templatePage): def __init__(self, fd, this_trait=None): templatePage.__init__(self, fd) - - #self.dict['title'] = 'Data Editing' - #TD_LR = HT.TD(valign="top",width="100%",bgcolor="#fafafa") - - if not self.openMysql(): - return + assert self.openMysql(), "No datbase!" + 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 @@ -54,33 +43,6 @@ class DataEditingPage(templatePage): else: fmID='dataEditing' - ############################# - ## titles, etc. - ############################# - - #titleTop = HT.Div() - # - #title1 = HT.Paragraph("  Details and Links", style="border-radius: 5px;", Id="title1", Class="sectionheader") - #title1Body = HT.Paragraph(Id="sectionbody1") - # - #if fd.enablevariance and not variance_data_page: - # title2 = HT.Paragraph("  Submit Variance", style="border-radius: 5px;", Id="title2", Class="sectionheader") - #else: - # title2 = HT.Paragraph("  Basic Statistics", style="border-radius: 5px;", Id="title2", Class="sectionheader") - #title2Body = HT.Paragraph(Id="sectionbody2") - # - #title3 = HT.Paragraph("  Calculate Correlations", style="border-radius: 5px;", Id="title3", Class="sectionheader") - #title3Body = HT.Paragraph(Id="sectionbody3") - # - #title4 = HT.Paragraph("  Mapping Tools", style="border-radius: 5px;", Id="title4", Class="sectionheader") - #title4Body = HT.Paragraph(Id="sectionbody4") - # - #title5 = HT.Paragraph("  Review and Edit Data", style="border-radius: 5px;", Id="title5", Class="sectionheader") - #title5Body = HT.Paragraph(Id="sectionbody5") - - ############################# - ## Hidden field - ############################# # Some fields, like method, are defaulted to None; otherwise in IE the field can't be changed using jquery hddn = OrderedDict( @@ -134,41 +96,23 @@ class DataEditingPage(templatePage): if this_trait.cellid: hddn['cellid'] = this_trait.cellid else: - self.cursor.execute("SELECT h2 from ProbeSetXRef WHERE DataId = %d" % this_trait.mysqlid) + 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) - - ############################# - ## Display Trait Information - ############################# - - #headSpan = self.dispHeader(fd,this_trait) #Draw header - # - #titleTop.append(headSpan) + 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 - ############################# - ## Generate form and buttons - ############################# - - #mainForm = HT.Form(cgi= os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), - # name='dataInput', submit=HT.Input(type='hidden')) - - #next=HT.Input(type='submit', name='submit',value='Next',Class="button") - #reset=HT.Input(type='Reset',name='',value=' Reset ',Class="button") - #correlationMenus = [] - if this_trait == None: this_trait = webqtlTrait(data=fd.allTraitData, db=None) @@ -182,105 +126,29 @@ class DataEditingPage(templatePage): # # We'll get this part working later # print("Calling dispBasicStatistics") # self.dispBasicStatistics(fd, this_trait) - + self.build_correlation_tools(fd, this_trait) - - # self.dispMappingTools(fd, title4Body, this_trait) - ############################# - ## Trait Value Table - ############################# - # + self.make_sample_lists(fd, variance_data_page, this_trait) - # + if fd.allsamplelist: hddn['allsamplelist'] = string.join(fd.allsamplelist, ' ') - # We put isSE into hddn if fd.varianceDispName != 'Variance': hddn['isSE'] = "yes" - #for key in hddn.keys(): - # mainForm.append(HT.Input(name=key, value=hddn[key], type='hidden')) - # - #if fd.enablevariance and not variance_data_page: - # #pre dataediting page, need to submit variance - # mainForm.append(titleTop, title1,title1Body,title2,title2Body,title3,title3Body,title4,title4Body,title5,title5Body) - #else: - # mainForm.append(titleTop, title1,title1Body,title2,title2Body,title3,title3Body,title4,title4Body,title5,title5Body) - #TD_LR.append(HT.Paragraph(mainForm)) - #self.dict['body'] = str(TD_LR) - - # We'll need access to this_trait and hddn uin the Jinja2 Template, so we put it inside self + # 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.basic_table = {} - #self.basic_table['rows'] = yaml.load(""" - # - N of Samples - # - Mean - # - Median - # - Standard Error (SE) - # - Standard Deviation (SD) - # - Minimum - # - Maximum - # - Range (log2) - # - Range (fold) - # - Interquartile Range - # """) - - #self.sample_groups = [] - #self.sample_groups.append(dict(label=fd.RISet + " Only", - # value="primary_only")) - #self.sample_groups.append(dict(label="Non-"+fd.RISet, - # value="other_only")) - #self.sample_groups.append(dict(label="All Cases", - # value="all_cases")) - - self.sample_groups = OrderedDict() - self.sample_groups['primary_only'] = fd.RISet + " Only" - self.sample_groups['other_only'] = "Non-" + fd.RISet - self.sample_groups['all_cases'] = "All Cases" - self.js_data = dict(sample_groups = self.sample_groups) - - - #self.basic_table['columns'] = yaml.load(""" - # - - # n: All Cases - # t: all - # - - # n: BXD Only - # t: primary - # - - # n: Non-BXD Only - # t: other - # """) - - #print(pf(self.basic_table)) - - ########################################## - ## Function to display header - ########################################## - def dispHeader(self, fd, this_trait): - headSpan = HT.Div(style="font-size:14px;") - - #If trait, use trait name; otherwise, use identification value - if this_trait: - if this_trait.cellid: - headSpan.append(HT.Strong('Trait Data and Analysis ', style='font-size:16px;'),' for Probe ID ', this_trait.cellid) - else: - headSpan.append(HT.Strong('Trait Data and Analysis ', style='font-size:16px;'),' for Record ID ', this_trait.name) - else: - if fd.identification: - headSpan.append(HT.Strong('Trait ID ', style='font-size:16px;'),fd.identification) - else: - headSpan.append(HT.Strong('Un-named Trait', style='font-size:16px;')) + 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) - return headSpan - ########################################## - ## Function to display trait infos - ########################################## def dispTraitInformation(self, fd, title1Body, hddn, this_trait): _Species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, RISet=fd.RISet) @@ -884,9 +752,6 @@ class DataEditingPage(templatePage): pass - ########################################## - ## Function to display analysis tools - ########################################## 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. @@ -1029,7 +894,6 @@ class DataEditingPage(templatePage): vals_set = [vals] - #stats_script = HT.Script(language="Javascript") #script needed for tabs self.stats_data = [] for i, vals in enumerate(vals_set): if i == 0 and len(vals) < 4: @@ -1628,7 +1492,8 @@ class DataEditingPage(templatePage): this_trait_samples = set(this_trait.data.keys()) #ZS - Checks if there are any samples in this_trait_samples that aren't in all_samples_ordered - other_samplesExist = this_trait_samples - set(all_samples_ordered) + #Will need to be used in the future to determine whether to create one or two tables are created (probably) + #other_samples_exist = this_trait_samples - set(all_samples_ordered) #mainForm = None # Just trying to get things working @@ -1636,15 +1501,16 @@ class DataEditingPage(templatePage): print("primary_samplelist is:", pf(primary_samplelist)) - primary_samples = self.create_sample_objects(fd=fd, + primary_samples = SampleList(self.cursor, + fd=fd, variance_data_page=variance_data_page, samplelist=primary_samplelist, #mainForm=mainForm, this_trait=this_trait, - other_samplesExist=other_samplesExist, attribute_ids=attribute_ids, attribute_names=attribute_names, - samples='primary') + samples='primary', + header="%s Only" % (fd.RISet)) other_samples = [] @@ -1661,14 +1527,16 @@ class DataEditingPage(templatePage): other_samples.sort() #Sort other samples other_samples = par_f1_samples + other_samples - other_samples = self.create_sample_objects(fd=fd, + other_samples = SampleList(self.cursor, + fd=fd, variance_data_page=variance_data_page, samplelist=other_samples, #mainForm=mainForm, this_trait=this_trait, attribute_ids=attribute_ids, attribute_names=attribute_names, - samples='other') + samples='other', + header="Non-%s" % (fd.RISet)) #TODO: Figure out why this if statement is written this way - Zach @@ -1678,16 +1546,28 @@ class DataEditingPage(templatePage): fd.allsamplelist = all_samples_ordered - self.primary_samples = dict(header = "%s Only" % (fd.RISet), - samples = primary_samples,) - - self.other_samples = dict(header = "Non-%s" % (fd.RISet), - samples = other_samples,) + #self.primary_samples = dict(header = "%s Only" % (fd.RISet), + # samples = primary_samples,) + # + #self.other_samples = dict(header = "Non-%s" % (fd.RISet), + # samples = other_samples,) - - def create_sample_objects(self, fd, variance_data_page, samplelist, this_trait, - other_samplesExist=None, attribute_ids=None, - attribute_names=None, samples='primary'): + self.sample_groups = (primary_samples, other_samples) + + +class SampleList(list): + def __init__(self, + cursor, + fd, + variance_data_page, + samplelist, + this_trait, + attribute_ids, + attribute_names, + samples, + header): + + self.header = header if attribute_ids == None: attribute_ids = [] @@ -1717,7 +1597,7 @@ class DataEditingPage(templatePage): #upperBound, lowerBound = Plot.findOutliers(vals) # ZS: Values greater than upperBound or less than lowerBound are considered outliers. - the_samples = [] + #the_samples = [] for counter, sampleNameOrig in enumerate(samplelist, 1): sampleName = sampleNameOrig.replace("_2nd_", "") @@ -1731,7 +1611,7 @@ class DataEditingPage(templatePage): print("No sample %s, let's create it now" % sampleName) sample = webqtlCaseData.webqtlCaseData(sampleName) print("zyt - sampleNameOrig:", sampleNameOrig) - + print(" type of sample:", type(sample)) if samples == 'primary': sample.this_id = "Primary_" + str(counter) @@ -1743,27 +1623,27 @@ class DataEditingPage(templatePage): if len(attribute_ids) > 0: #ZS: Get StrainId value for the next query - self.cursor.execute("""SELECT Strain.Id - FROM Strain, StrainXRef, InbredSet + cursor.execute("""SELECT Strain.Id + FROM Strain, StrainXRef, InbredSetd WHERE Strain.Name = '%s' and StrainXRef.StrainId = Strain.Id and InbredSet.Id = StrainXRef.InbredSetId and InbredSet.Name = '%s'""" % (sampleName, fd.RISet)) - sample_id = self.cursor.fetchone()[0] + sample_id = cursor.fetchone()[0] attr_counter = 1 # This is needed so the javascript can know which attribute type to associate this value with for the exported excel sheet (each attribute type being a column). for attribute_id in attribute_ids: #ZS: Add extra case attribute values (if any) - self.cursor.execute("""SELECT Value + cursor.execute("""SELECT Value FROM CaseAttributeXRef WHERE ProbeSetFreezeId = '%s' AND StrainId = '%s' AND CaseAttributeId = '%s' group by CaseAttributeXRef.CaseAttributeId""" % (this_trait.db.id, sample_id, str(attribute_id))) - attributeValue = self.cursor.fetchone()[0] #Trait-specific attributes, if any + attributeValue = cursor.fetchone()[0] #Trait-specific attributes, if any #ZS: If it's an int, turn it into one for sorting (for example, 101 would be lower than 80 if they're strings instead of ints) try: @@ -1776,23 +1656,26 @@ class DataEditingPage(templatePage): attr_className = str(attributeValue) + " " + className table_row.append(HT.TD(attr_container, align='right', Class=attr_className)) attr_counter += 1 - the_samples.append(sample) + self.append(sample) #table_body.append(table_row) - do_outliers(the_samples) - print("*the_samples are [%i]: %s" % (len(the_samples), pf(the_samples))) - return the_samples + self.do_outliers() + #do_outliers(the_samples) + print("*the_samples are [%i]: %s" % (len(self), pf(self))) + for sample in self: + print("apple:", type(sample), sample) + #return the_samples -def do_outliers(sample_objects): - values = [sample.value for sample in sample_objects if sample.value != None] - upper_bound, lower_bound = Plot.find_outliers(values) - - for sample in sample_objects: - if sample.value: - if upper_bound and sample.value > upper_bound: - sample.outlier = True - elif lower_bound and sample.value < lower_bound: - sample.outlier = True - else: - sample.outlier = False + def do_outliers(self): + values = [sample.value for sample in self if sample.value != None] + upper_bound, lower_bound = Plot.find_outliers(values) + + for sample in self: + if sample.value: + if upper_bound and sample.value > upper_bound: + sample.outlier = True + elif lower_bound and sample.value < lower_bound: + sample.outlier = True + else: + sample.outlier = False diff --git a/wqflask/wqflask/show_trait/show_trait_page.py b/wqflask/wqflask/show_trait/show_trait_page.py index 858f16ea..cf056d35 100644 --- a/wqflask/wqflask/show_trait/show_trait_page.py +++ b/wqflask/wqflask/show_trait/show_trait_page.py @@ -41,39 +41,24 @@ from DataEditingPage import DataEditingPage class ShowTraitPage(DataEditingPage): def __init__(self, fd, traitInfos = None): - - #templatePage.__init__(self, fd) self.fd = fd - if not self.openMysql(): - return + # This sets self.cursor + assert self.openMysql(), "No database" - #TD_LR = HT.TD(height=200,width="100%",bgColor='#eeeeee') - print("j2") # When is traitInfos used? if traitInfos: - print("j2.2") database, ProbeSetID, CellID = traitInfos else: - print("j2.3") print("fd is:", fd) database = fd['database'] ProbeSetID = fd['ProbeSetID'] - print("j2.4") + CellID = fd.get('CellID') - print("j2.6") + - # We're no longer wrapping this in an exception. If we fail, let's fail hard - # Log it and fix it - #try: - print("j3") thisTrait = webqtlTrait(db=database, name=ProbeSetID, cellid=CellID, cursor=self.cursor) - #except: - # heading = "Trait Data and Analysis Form" - # detail = ["The trait isn't available currently."] - # self.error(heading=heading,detail=detail,error="Error") - # return - print("j4") + if thisTrait.db.type == "ProbeSet": self.cursor.execute('''SELECT Id, Name, FullName, confidentiality, AuthorisedUsers @@ -120,10 +105,7 @@ class ShowTraitPage(DataEditingPage): try it again tomorrow.' % webqtlConfig.DAILYMAXIMUM] self.error(heading=heading,detail=detail) return - else: - pass - else: - pass + if thisTrait.db.type != 'ProbeSet' and thisTrait.cellid: heading = "Retrieve Data" @@ -131,26 +113,6 @@ class ShowTraitPage(DataEditingPage): self.error(heading=heading,detail=detail) return - #XZ: Aug 23, 2010: I commented out this block because this feature is not used anymore - # check if animal information are available - """ - self.cursor.execute(''' - SELECT - SampleXRef.ProbeFreezeId - FROM - SampleXRef, ProbeSetFreeze - WHERE - SampleXRef.ProbeFreezeId = ProbeSetFreeze.ProbeFreezeId AND - ProbeSetFreeze.Name = "%s" - ''' % thisTrait.db.name) - - sampleId = self.cursor.fetchall() - if sampleId: - thisTrait.strainInfo = 1 - else: - thisTrait.strainInfo = None - """ - ##identification, etc. fd.identification = '%s : %s' % (thisTrait.db.shortname,ProbeSetID) thisTrait.returnURL = webqtlConfig.CGIDIR + webqtlConfig.SCRIPTFILE + '?FormID=showDatabase&database=%s\ @@ -160,19 +122,12 @@ class ShowTraitPage(DataEditingPage): fd.identification = '%s/%s'%(fd.identification, CellID) thisTrait.returnURL = '%s&CellID=%s' % (thisTrait.returnURL, CellID) - #retrieve trait information - #try: thisTrait.retrieveInfo() thisTrait.retrieveData() self.updMysql() self.cursor.execute("insert into AccessLog(accesstime,ip_address) values(Now(),%s)", user_ip) self.openMysql() - #except Exception as why: - # print("Got an exception:", why) - # heading = "Retrieve Data" - # detail = ["The information you requested is not avaiable at this time."] - # self.error(heading=heading, detail=detail) - # return + ##read genotype file fd.RISet = thisTrait.riset @@ -180,10 +135,7 @@ class ShowTraitPage(DataEditingPage): #if webqtlUtil.ListNotNull(map(lambda x:x.var, thisTrait.data.values())): if any([x.variance for x in thisTrait.data.values()]): - fd.displayVariance = 1 - fd.varianceDispName = 'SE' + fd.display_variance = True fd.formID = 'varianceChoice' - #self.dict['body']= thisTrait DataEditingPage.__init__(self, fd, thisTrait) - #self.dict['title'] = '%s: Display Trait' % fd.identification diff --git a/wqflask/wqflask/templates/trait_data_and_analysis.html b/wqflask/wqflask/templates/trait_data_and_analysis.html index 6ae91c6d..7cfb7916 100644 --- a/wqflask/wqflask/templates/trait_data_and_analysis.html +++ b/wqflask/wqflask/templates/trait_data_and_analysis.html @@ -243,7 +243,7 @@

Include:
SE
{{ loop.index }} - + - {{ strain.name }} + {{ sample.name }} - -
Samples: @@ -1266,7 +1265,7 @@ - {% for sample in sample_type.samples %} + {% for sample in sample_type %} -
SE
{{ loop.index }} -- cgit v1.2.3 From 45fb8b4961e1dc8251502f04cb94a4fcf1848f83 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Thu, 27 Sep 2012 17:40:16 -0500 Subject: Worked on getting attributes in the SampleList object to display data properly, changed SampleList from an object list to object --- wqflask/base/webqtlTrait.py | 16 +- wqflask/utility/__init__.py | 14 +- wqflask/wqflask/__init__.py | 3 + wqflask/wqflask/show_trait/DataEditingPage.py | 192 ++++++++++----------- .../wqflask/templates/trait_data_and_analysis.html | 4 +- 5 files changed, 113 insertions(+), 116 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/webqtlTrait.py b/wqflask/base/webqtlTrait.py index efbc1464..d6d537b7 100755 --- a/wqflask/base/webqtlTrait.py +++ b/wqflask/base/webqtlTrait.py @@ -359,14 +359,14 @@ class webqtlTrait: #else: # pass - def keys(self): - return self.__dict__.keys() - - def has_key(self, key): - return self.__dict__.has_key(key) - - def items(self): - return self.__dict__.items() + #def keys(self): + # return self.__dict__.keys() + # + #def has_key(self, key): + # return self.__dict__.has_key(key) + # + #def items(self): + # return self.__dict__.items() def retrieveInfo(self, QTL = None): assert self.db and self.cursor diff --git a/wqflask/utility/__init__.py b/wqflask/utility/__init__.py index 206d0d1c..d0e4a3fa 100755 --- a/wqflask/utility/__init__.py +++ b/wqflask/utility/__init__.py @@ -1,12 +1,12 @@ +from pprint import pformat as pf + + class Bunch(object): - """Make the configuration a little cleaner""" - def __init__(self, config_string = "", **kw): - if config_string: - td = yaml.load(config_string) - self.__dict__.update(td) - else: + """Like a dictionary but using object notation""" + def __init__(self, **kw): self.__dict__ = kw def __repr__(self): - return yaml.dump(self.__dict__, default_flow_style=False) + return pf(self.__dict__) + diff --git a/wqflask/wqflask/__init__.py b/wqflask/wqflask/__init__.py index a7492e77..ff018fdc 100644 --- a/wqflask/wqflask/__init__.py +++ b/wqflask/wqflask/__init__.py @@ -3,6 +3,8 @@ from __future__ import absolute_import, division, print_function import sys print("sys.path is:", sys.path) +import jinja2 + from flask import Flask from utility import formatting @@ -14,6 +16,7 @@ app.config.from_object('cfg.default_settings') app.config.from_envvar('WQFLASK_SETTINGS') app.jinja_env.globals.update( + undefined = jinja2.StrictUndefined, numify = formatting.numify ) diff --git a/wqflask/wqflask/show_trait/DataEditingPage.py b/wqflask/wqflask/show_trait/DataEditingPage.py index e431fd76..24a37926 100755 --- a/wqflask/wqflask/show_trait/DataEditingPage.py +++ b/wqflask/wqflask/show_trait/DataEditingPage.py @@ -1466,43 +1466,23 @@ class DataEditingPage(templatePage): if fd.genotype.type == "riset": all_samples_ordered = fd.f1list + fd.samplelist else: - all_samples_ordered = fd.f1list + fd.parlist + fd.samplelist - - #ZS: Id values for this trait's extra attributes; - #used to create "Exclude" dropdown and query for attribute values and create - self.cursor.execute("""SELECT CaseAttribute.Id, CaseAttribute.Name - FROM CaseAttribute, CaseAttributeXRef - WHERE CaseAttributeXRef.ProbeSetFreezeId = %s AND - CaseAttribute.Id = CaseAttributeXRef.CaseAttributeId - group by CaseAttributeXRef.CaseAttributeId""", - (str(this_trait.db.id),)) - - - - for this_attr_name in attribute_names: - # Todo: Needs testing still! - self.cursor.execute("""SELECT DISTINCT CaseAttributeXRef.Value - FROM CaseAttribute, CaseAttributeXRef - WHERE CaseAttribute.Name = %s AND - CaseAttributeXRef.CaseAttributeId = CaseAttribute.Id""", - (this_attr_name,)) - - distinct_values = self.cursor.fetchall() + 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)) + 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, - samples='primary', + 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(): @@ -1515,15 +1495,15 @@ class DataEditingPage(templatePage): unappended_par_f1 = fd.f1list + fd.parlist par_f1_samples = ["_2nd_" + sample for sample in unappended_par_f1] - other_samples.sort() #Sort other samples - other_samples = par_f1_samples + other_samples + 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, - samples='other', + sample_group_type='other', header="Non-%s" % (fd.RISet)) self.sample_groups = (primary_samples, other_samples) @@ -1531,36 +1511,39 @@ class DataEditingPage(templatePage): 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 - - - + #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 -class SampleList(list): +class SampleList(object): def __init__(self, cursor, fd, variance_data_page, sample_names, this_trait, - samples, + sample_group_type, header): + self.cursor = cursor + self.fd = fd + self.this_trait = this_trait + self.sample_group_type = sample_group_type # primary or other self.header = header - - + + self.sample_list = [] # The actual list self.calc_attributes() + + print("camera: attributes are:", pf(self.attributes)) for counter, sample_name in enumerate(sample_names, 1): sample_name = sample_name.replace("_2nd_", "") #ZS - If there's no value for the sample/strain, create the sample object (so samples with no value are still displayed in the table) try: - sample = this_trait.data[sample_name] + sample = self.this_trait.data[sample_name] except KeyError: print("No sample %s, let's create it now" % sample_name) sample = webqtlCaseData.webqtlCaseData(sample_name) @@ -1569,37 +1552,37 @@ class SampleList(list): #if fd.RISet == 'AXBXA' and sampleName in ('AXB18/19/20','AXB13/14','BXA8/17'): # sampleNameAdd = HT.Href(url='/mouseCross.html#AXB/BXA', text=HT.Sup('#'), Class='fs12', target="_blank") sample.extra_info = {} - if fd.RISet == 'AXBXA' and sample_name in ('AXB18/19/20','AXB13/14','BXA8/17'): + if self.fd.RISet == 'AXBXA' and sample_name in ('AXB18/19/20','AXB13/14','BXA8/17'): sample.extra_info['url'] = "/mouseCross.html#AXB/BXA" sample.extra_info['css_class'] = "fs12" - - print("zyt - sampleNameOrig:", sampleNameOrig) + print(" type of sample:", type(sample)) - if samples == 'primary': + if sample_group_type == 'primary': sample.this_id = "Primary_" + str(counter) else: sample.this_id = "Other_" + str(counter) #### For extra attribute columns; currently only used by two human datasets - Zach - if this_trait and this_trait.db and this_trait.db.type == 'ProbeSet': - self.get_extra_attribute_values(attribute_ids, this_trait, sample_name) - self.append(sample) - #table_body.append(table_row) + if self.this_trait and self.this_trait.db and self.this_trait.db.type == 'ProbeSet': + self.get_extra_attribute_values(sample_name) + self.sample_list.append(sample) self.do_outliers() #do_outliers(the_samples) - print("*the_samples are [%i]: %s" % (len(self), pf(self))) - for sample in self: + print("*the_samples are [%i]: %s" % (len(self.sample_list), pf(self.sample_list))) + for sample in self.sample_list: print("apple:", type(sample), sample) #return the_samples + def __repr__(self): + return " --> %s" % (pf(self.__dict__)) def do_outliers(self): - values = [sample.value for sample in self if sample.value != None] + values = [sample.value for sample in self.sample_list if sample.value != None] upper_bound, lower_bound = Plot.find_outliers(values) - for sample in self: + for sample in self.sample_list: if sample.value: if upper_bound and sample.value > upper_bound: sample.outlier = True @@ -1608,23 +1591,24 @@ class SampleList(list): else: sample.outlier = False + def calc_attributes(self): """Finds which extra attributes apply to this dataset""" - #ZS: Id and name values for this trait's extra attributes self.cursor.execute('''SELECT CaseAttribute.Id, CaseAttribute.Name FROM CaseAttribute, CaseAttributeXRef WHERE CaseAttributeXRef.ProbeSetFreezeId = %s AND CaseAttribute.Id = CaseAttributeXRef.CaseAttributeId group by CaseAttributeXRef.CaseAttributeId''', - (str(this_trait.db.id),)) + (str(self.this_trait.db.id),)) #self.attributes = {key, value in self.cursor.fetchall()} #self.attributes = OrderedDict(self.attributes.iteritems()) self.attributes = {} for key, value in self.cursor.fetchall(): + print("radish: %s - %s" % (key, value)) self.attributes[key] = Bunch() self.attributes[key].name = value @@ -1633,64 +1617,65 @@ class SampleList(list): WHERE CaseAttribute.Name = %s AND CaseAttributeXRef.CaseAttributeId = CaseAttribute.Id''', (value,)) - self.attributes[key].distinct_values = self.cursor.fetchall() - - - try: - - exclude_menu = HT.Select(name="exclude_menu") - dropdown_menus = [] #ZS: list of dropdown menus with the distinct values of each attribute (contained in DIVs so the style parameter can be edited and they can be hidden) - - for attribute in self.cursor.fetchall(): - attribute_ids.append(attribute[0]) - attribute_names.append(attribute[1]) - for this_attr_name in attribute_names: - exclude_menu.append((this_attr_name.capitalize(), this_attr_name)) - self.cursor.execute("""SELECT DISTINCT CaseAttributeXRef.Value - FROM CaseAttribute, CaseAttributeXRef - WHERE CaseAttribute.Name = '%s' AND - CaseAttributeXRef.CaseAttributeId = CaseAttribute.Id""" % (this_attr_name)) - try: - distinct_values = self.cursor.fetchall() - attr_value_menu_div = HT.Div(style="display:none;", Class="attribute_values") #container used to show/hide dropdown menus - attr_value_menu = HT.Select(name=this_attr_name) - attr_value_menu.append(("None", "show_all")) - for value in distinct_values: - attr_value_menu.append((str(value[0]), value[0])) - attr_value_menu_div.append(attr_value_menu) - dropdown_menus.append(attr_value_menu_div) - except: - pass - except: - pass + self.attributes[key].distinct_values = [item[0] for item in self.cursor.fetchall()] + self.attributes[key].distinct_values.sort(key=natural_sort_key) + + + #try: + # + # exclude_menu = HT.Select(name="exclude_menu") + # dropdown_menus = [] #ZS: list of dropdown menus with the distinct values of each attribute (contained in DIVs so the style parameter can be edited and they can be hidden) + # + # for attribute in self.cursor.fetchall(): + # attribute_ids.append(attribute[0]) + # attribute_names.append(attribute[1]) + # for this_attr_name in attribute_names: + # exclude_menu.append((this_attr_name.capitalize(), this_attr_name)) + # self.cursor.execute("""SELECT DISTINCT CaseAttributeXRef.Value + # FROM CaseAttribute, CaseAttributeXRef + # WHERE CaseAttribute.Name = '%s' AND + # CaseAttributeXRef.CaseAttributeId = CaseAttribute.Id""" % (this_attr_name)) + # try: + # distinct_values = self.cursor.fetchall() + # attr_value_menu_div = HT.Div(style="display:none;", Class="attribute_values") #container used to show/hide dropdown menus + # attr_value_menu = HT.Select(name=this_attr_name) + # attr_value_menu.append(("None", "show_all")) + # for value in distinct_values: + # attr_value_menu.append((str(value[0]), value[0])) + # attr_value_menu_div.append(attr_value_menu) + # dropdown_menus.append(attr_value_menu_div) + # except: + # pass + #except: + # pass - def get_extra_attribute_values(self): + def get_extra_attribute_values(self, sample_name): - if len(attribute_ids) > 0: + if len(self.attributes) > 0: #ZS: Get StrainId value for the next query - cursor.execute("""SELECT Strain.Id - FROM Strain, StrainXRef, InbredSetd - WHERE Strain.Name = '%s' and + self.cursor.execute("""SELECT Strain.Id + FROM Strain, StrainXRef, InbredSet + WHERE Strain.Name = %s and StrainXRef.StrainId = Strain.Id and InbredSet.Id = StrainXRef.InbredSetId and - InbredSet.Name = '%s'""" % (sampleName, fd.RISet)) + InbredSet.Name = %s""", (sample_name, self.fd.RISet)) - sample_id = cursor.fetchone()[0] + sample_id = self.cursor.fetchone()[0] attr_counter = 1 # This is needed so the javascript can know which attribute type to associate this value with for the exported excel sheet (each attribute type being a column). - for attribute_id in attribute_ids: + for attribute_id in self.attributes.keys(): #ZS: Add extra case attribute values (if any) - cursor.execute("""SELECT Value + self.cursor.execute("""SELECT Value FROM CaseAttributeXRef WHERE ProbeSetFreezeId = '%s' AND StrainId = '%s' AND CaseAttributeId = '%s' - group by CaseAttributeXRef.CaseAttributeId""" % (this_trait.db.id, sample_id, str(attribute_id))) + group by CaseAttributeXRef.CaseAttributeId""" % (self.this_trait.db.id, sample_id, str(attribute_id))) - attributeValue = cursor.fetchone()[0] #Trait-specific attributes, if any + attributeValue = self.cursor.fetchone()[0] #Trait-specific attributes, if any #ZS: If it's an int, turn it into one for sorting (for example, 101 would be lower than 80 if they're strings instead of ints) try: @@ -1698,8 +1683,17 @@ class SampleList(list): except ValueError: pass - span_Id = samples+"_attribute"+str(attr_counter)+"_sample"+str(i+1) - attr_container = HT.Span(attributeValue, Id=span_Id) - attr_className = str(attributeValue) + " " + className - table_row.append(HT.TD(attr_container, align='right', Class=attr_className)) + #span_Id = samples+"_attribute"+str(attr_counter)+"_sample"+str(i+1) + #attr_container = HT.Span(attributeValue, Id=span_Id) + #attr_className = str(attributeValue) + " " + className + #table_row.append(HT.TD(attr_container, align='right', Class=attr_className)) attr_counter += 1 + + +def natural_sort_key(x): + """Get expected results when using as a key for sort - ints or strings are sorted properly""" + try: + x = int(x) + except ValueError: + pass + return x \ No newline at end of file diff --git a/wqflask/wqflask/templates/trait_data_and_analysis.html b/wqflask/wqflask/templates/trait_data_and_analysis.html index 7cfb7916..6a5a4a80 100644 --- a/wqflask/wqflask/templates/trait_data_and_analysis.html +++ b/wqflask/wqflask/templates/trait_data_and_analysis.html @@ -1249,7 +1249,7 @@

{{ sample_type.header }}

-
+
@@ -1265,7 +1265,7 @@ - {% for sample in sample_type %} + {% for sample in sample_type.sample_list %} + + {% for attribute in sample_type.attributes|sort() %} + + {% endfor %} {% for sample in sample_type.sample_list %} @@ -1291,7 +1295,15 @@ + size="8" maxlength="8" style="text-align:right"> + + + {# Loop through each attribute type and input value #} + {% for attribute in sample_type.attributes|sort() %} + + {% endfor %} {% endfor %} -- cgit v1.2.3 From 8bd404246b83f46f34c9b162c39c2dfc6ab39049 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Fri, 28 Sep 2012 16:56:42 -0500 Subject: Removed show_trait_page.py and moved relevant code over to DataEditingPage.py (though the user security stuff still needs to be moved over) --- wqflask/base/webqtlFormData.py | 1 + wqflask/wqflask/show_trait/DataEditingPage.py | 44 +++++++++++++++++++++++++-- wqflask/wqflask/views.py | 6 ++-- 3 files changed, 46 insertions(+), 5 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/webqtlFormData.py b/wqflask/base/webqtlFormData.py index 63263895..710c9f53 100755 --- a/wqflask/base/webqtlFormData.py +++ b/wqflask/base/webqtlFormData.py @@ -43,6 +43,7 @@ from utility import webqtlUtil + class webqtlFormData: 'Represents data from a WebQTL form page, needed to generate the next page' diff --git a/wqflask/wqflask/show_trait/DataEditingPage.py b/wqflask/wqflask/show_trait/DataEditingPage.py index 92d0feaf..12e816f8 100755 --- a/wqflask/wqflask/show_trait/DataEditingPage.py +++ b/wqflask/wqflask/show_trait/DataEditingPage.py @@ -20,13 +20,29 @@ 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, this_trait=None): + 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) @@ -43,7 +59,6 @@ class DataEditingPage(templatePage): 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, @@ -149,6 +164,31 @@ class DataEditingPage(templatePage): 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) diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 0befb74a..bc80a1e6 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -10,7 +10,7 @@ from wqflask import app from flask import render_template, request from wqflask import search_results -from wqflask.show_trait import show_trait_page +from wqflask.show_trait import DataEditingPage from wqflask.correlation import CorrelationPage from wqflask.dataSharing import SharingInfo, SharingInfoPage @@ -75,8 +75,8 @@ def whats_new(): 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 = show_trait_page.ShowTraitPage(fd) + template_vars = DataEditingPage.DataEditingPage(fd) template_vars.js_data = json.dumps(template_vars.js_data) print("show_trait template_vars:", pf(template_vars.__dict__)) -- cgit v1.2.3 From 3c57b46a3c746f0bce58de9a70aca55d1df20002 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Tue, 23 Oct 2012 17:06:01 -0500 Subject: Finished coffeescript that handles the home page dataset selection dropdowns --- misc/notes.txt | 2 + wqflask/base/webqtlCaseData.py | 4 +- .../static/new/javascript/dataset_menu_structure | 6792 ++++++++++++++++++++ .../new/javascript/dataset_menu_structure.json | 6792 -------------------- .../new/javascript/dataset_select_menu.coffee | 834 +-- .../static/new/javascript/dataset_select_menu.js | 408 +- .../static/new/javascript/show_trait.coffee | 8 +- .../wqflask/static/new/javascript/show_trait.js | 9 +- wqflask/wqflask/templates/new_index_page.html | 24 +- 9 files changed, 7310 insertions(+), 7563 deletions(-) create mode 100644 wqflask/wqflask/static/new/javascript/dataset_menu_structure delete mode 100644 wqflask/wqflask/static/new/javascript/dataset_menu_structure.json (limited to 'wqflask/base') diff --git a/misc/notes.txt b/misc/notes.txt index c12cd2bb..e7b94087 100644 --- a/misc/notes.txt +++ b/misc/notes.txt @@ -36,6 +36,8 @@ screen -r zas1024/ Start up log: Go to /tmp and tail -f flask_gn_log +=========================================== + Coffeescript Stuff: coffee -c (filename) diff --git a/wqflask/base/webqtlCaseData.py b/wqflask/base/webqtlCaseData.py index 6352a083..42763aed 100755 --- a/wqflask/base/webqtlCaseData.py +++ b/wqflask/base/webqtlCaseData.py @@ -27,9 +27,7 @@ print("Mr. Mojo Risin 2") class webqtlCaseData(object): - """one case data in one trait - - """ + """one case data in one trait""" def __init__(self, name, value=None, variance=None, num_cases=None): self.name = name diff --git a/wqflask/wqflask/static/new/javascript/dataset_menu_structure b/wqflask/wqflask/static/new/javascript/dataset_menu_structure new file mode 100644 index 00000000..d25d3cf5 --- /dev/null +++ b/wqflask/wqflask/static/new/javascript/dataset_menu_structure @@ -0,0 +1,6792 @@ +{ + "datasets": { + "All Species": { + "All Groups": { + "Phenotypes": [ + [ + "All Phenotypes", + "All Phenotypes" + ] + ] + } + }, + "arabidopsis": { + "BayXSha": { + "Genotypes": [ + [ + "BayXShaGeno", + "BayXSha Genotypes" + ] + ], + "Phenotypes": [ + [ + "BayXShaPublish", + "BayXSha Published Phenotypes" + ] + ] + }, + "ColXBur": { + "Genotypes": [ + [ + "ColXBurGeno", + "ColXBur Genotypes" + ] + ], + "Phenotypes": [ + [ + "ColXBurPublish", + "ColXBur Published Phenotypes" + ] + ] + }, + "ColXCvi": { + "Genotypes": [ + [ + "ColXCviGeno", + "ColXCvi Genotypes" + ] + ], + "Phenotypes": [ + [ + "ColXCviPublish", + "ColXCvi Published Phenotypes" + ] + ] + } + }, + "barley": { + "QSM": { + "Genotypes": [ + [ + "QSMGeno", + "QSM Genotypes" + ] + ], + "Leaf": [ + [ + "B1LI0809R", + "Barley1 Leaf INOC TTKS (Aug09) RMA" + ], + [ + "B1LI0809M5", + "Barley1 Leaf INOC TTKS (Aug09) MAS5" + ], + [ + "B1MI0809M5", + "Barley1 Leaf MOCK TTKS (Aug09) MAS5" + ], + [ + "B1MI0809R", + "Barley1 Leaf MOCK TTKS (Aug09) RMA" + ], + [ + "B30_K_1206_M", + "Barley1 Leaf MAS 5.0 SCRI (Dec06)" + ], + [ + "B30_K_1206_R", + "Barley1 Leaf gcRMA SCRI (Dec06)" + ], + [ + "B30_K_1206_Rn", + "Barley1 Leaf gcRMAn SCRI (Dec06)" + ] + ], + "Phenotypes": [ + [ + "QSMPublish", + "QSM Published Phenotypes" + ] + ] + }, + "SXM": { + "Embryo": [ + [ + "B139_K_1206_R", + "Barley1 Embryo gcRMA SCRI (Dec06)" + ], + [ + "B139_K_1206_M", + "Barley1 Embryo MAS 5.0 SCRI (Dec06)" + ], + [ + "B150_K_0406_R", + "Barley1 Embryo0 gcRMA SCRI (Apr06)" + ] + ], + "Genotypes": [ + [ + "SXMGeno", + "SXM Genotypes" + ] + ], + "Leaf": [ + [ + "B1LI0809R", + "Barley1 Leaf INOC TTKS (Aug09) RMA" + ], + [ + "B1LI0809M5", + "Barley1 Leaf INOC TTKS (Aug09) MAS5" + ], + [ + "B1MI0809M5", + "Barley1 Leaf MOCK TTKS (Aug09) MAS5" + ], + [ + "B1MI0809R", + "Barley1 Leaf MOCK TTKS (Aug09) RMA" + ], + [ + "B30_K_1206_M", + "Barley1 Leaf MAS 5.0 SCRI (Dec06)" + ], + [ + "B30_K_1206_R", + "Barley1 Leaf gcRMA SCRI (Dec06)" + ], + [ + "B30_K_1206_Rn", + "Barley1 Leaf gcRMAn SCRI (Dec06)" + ] + ], + "Phenotypes": [ + [ + "SXMPublish", + "SXM Published Phenotypes" + ] + ] + } + }, + "drosophila": { + "DGRP": { + "Genotypes": [ + [ + "DGRPGeno", + "DGRP Genotypes" + ] + ], + "Phenotypes": [ + [ + "DGRPPublish", + "DGRP Published Phenotypes" + ] + ], + "Whole Body": [ + [ + "NCSU_DrosWB_LC_RMA_0111", + "NCSU Drosophila Whole Body (Jan11) RMA" + ], + [ + "UAB_DrosWB_LC_RMA_1009", + "UAB Whole body D.m. mRNA control (Oct09) RMA" + ], + [ + "UAB_DrosWB_LE_RMA_1009", + "UAB Whole body D.m. mRNA lead (pbAc) (Oct09) RMA" + ] + ] + }, + "Oregon-R_x_2b3": { + "Genotypes": [ + [ + "Oregon-R_x_2b3Geno", + "Oregon-R_x_2b3 Genotypes" + ] + ], + "Phenotypes": [ + [ + "Oregon-R_x_2b3Publish", + "Oregon-R_x_2b3 Published Phenotypes" + ] + ], + "Whole Body": [ + [ + "NCSU_DrosWB_LC_RMA_0111", + "NCSU Drosophila Whole Body (Jan11) RMA" + ], + [ + "UAB_DrosWB_LC_RMA_1009", + "UAB Whole body D.m. mRNA control (Oct09) RMA" + ], + [ + "UAB_DrosWB_LE_RMA_1009", + "UAB Whole body D.m. mRNA lead (pbAc) (Oct09) RMA" + ] + ] + } + }, + "human": { + "AD-cases-controls": { + "Brain": [ + [ + "GSE15222_F_N_RI_0409", + "GSE15222 Human Brain Normal Myers (Apr09) RankInv" + ], + [ + "GSE15222_F_A_RI_0409", + "GSE15222 Human Brain Alzheimer Myers (Apr09) RankInv" + ], + [ + "GSE5281_F_RMA_N_0709", + "GSE5281 Human Brain Normal Full Liang (Jul09) RMA" + ], + [ + "GSE5281_F_RMA_Alzh_0709", + "GSE5281 Human Brain Alzheimer Full Liang (Jul09) RMA" + ], + [ + "INIA_MacFas_brain_RMA_0110", + "INIA Macaca fasicularis Brain (Jan10) RMA **" + ], + [ + "GSE15222_F_RI_0409", + "GSE15222 Human Brain Myers (Apr09) RankInv" + ], + [ + "GSE5281_F_RMA0709", + "GSE5281 Human Brain Full Liang (Jul09) RMA" + ], + [ + "GSE5281_RMA0709", + "GSE5281 Human Brain Best 102 Liang (Jul09) RMA" + ], + [ + "UCLA_CTB6B6CTF2_BRAIN_FEMALE", + "UCLA CTB6B6CTF2 Brain Female mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_BRAIN_MALE", + "UCLA CTB6B6CTF2 Brain Male mlratio **" + ], + [ + "UCLA_BHF2_BRAIN_MALE", + "UCLA BHF2 Brain Male mlratio" + ], + [ + "UCLA_BHF2_BRAIN_FEMALE", + "UCLA BHF2 Brain Female mlratio" + ], + [ + "UCLA_BHHBF2_BRAIN_FEMALE", + "UCLA BHHBF2 Brain Female Only" + ], + [ + "UCLA_BHHBF2_BRAIN_MALE", + "UCLA BHHBF2 Brain Male Only" + ], + [ + "UCLA_BHHBF2_BRAIN_2005", + "UCLA BHHBF2 Brain (2005) mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_BRAIN_2005", + "UCLA CTB6/B6CTF2 Brain (2005) mlratio **" + ], + [ + "UCLA_BHF2_BRAIN_0605", + "UCLA BHF2 Brain (June05) mlratio" + ], + [ + "BR_M2_1106_R", + "UCHSC BXD Whole Brain M430 2.0 (Nov06) RMA" + ], + [ + "IBR_M_0606_R", + "INIA Brain mRNA M430 (Jun06) RMA" + ], + [ + "IBR_M_0106_P", + "INIA Brain mRNA M430 (Jan06) PDNN" + ], + [ + "IBR_M_0106_R", + "INIA Brain mRNA M430 (Jan06) RMA" + ], + [ + "BR_U_1105_P", + "UTHSC Brain mRNA U74Av2 (Nov05) PDNN" + ], + [ + "BR_U_0805_M", + "UTHSC Brain mRNA U74Av2 (Aug05) MAS5" + ], + [ + "BR_U_0805_P", + "UTHSC Brain mRNA U74Av2 (Aug05) PDNN" + ], + [ + "BR_U_0805_R", + "UTHSC Brain mRNA U74Av2 (Aug05) RMA" + ], + [ + "BRF2_M_0805_R", + "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) RMA" + ], + [ + "BRF2_M_0805_P", + "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) PDNN" + ], + [ + "BRF2_M_0805_M", + "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) MAS5" + ], + [ + "BRF2_M_0304_P", + "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) PDNN" + ], + [ + "BRF2_M_0304_R", + "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) RMA" + ], + [ + "BRF2_M_0304_M", + "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) MAS5" + ], + [ + "CB_M_0204_P", + "INIA Brain mRNA M430 (Feb04) PDNN" + ] + ], + "Genotypes": [ + [ + "AD-cases-controlsGeno", + "AD-cases-controls Genotypes" + ] + ], + "Phenotypes": [ + [ + "AD-cases-controlsPublish", + "AD-cases-controls Published Phenotypes" + ] + ] + }, + "AD-cases-controls-Myers": { + "Brain": [ + [ + "GSE15222_F_N_RI_0409", + "GSE15222 Human Brain Normal Myers (Apr09) RankInv" + ], + [ + "GSE15222_F_A_RI_0409", + "GSE15222 Human Brain Alzheimer Myers (Apr09) RankInv" + ], + [ + "GSE5281_F_RMA_N_0709", + "GSE5281 Human Brain Normal Full Liang (Jul09) RMA" + ], + [ + "GSE5281_F_RMA_Alzh_0709", + "GSE5281 Human Brain Alzheimer Full Liang (Jul09) RMA" + ], + [ + "INIA_MacFas_brain_RMA_0110", + "INIA Macaca fasicularis Brain (Jan10) RMA **" + ], + [ + "GSE15222_F_RI_0409", + "GSE15222 Human Brain Myers (Apr09) RankInv" + ], + [ + "GSE5281_F_RMA0709", + "GSE5281 Human Brain Full Liang (Jul09) RMA" + ], + [ + "GSE5281_RMA0709", + "GSE5281 Human Brain Best 102 Liang (Jul09) RMA" + ], + [ + "UCLA_CTB6B6CTF2_BRAIN_FEMALE", + "UCLA CTB6B6CTF2 Brain Female mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_BRAIN_MALE", + "UCLA CTB6B6CTF2 Brain Male mlratio **" + ], + [ + "UCLA_BHF2_BRAIN_MALE", + "UCLA BHF2 Brain Male mlratio" + ], + [ + "UCLA_BHF2_BRAIN_FEMALE", + "UCLA BHF2 Brain Female mlratio" + ], + [ + "UCLA_BHHBF2_BRAIN_FEMALE", + "UCLA BHHBF2 Brain Female Only" + ], + [ + "UCLA_BHHBF2_BRAIN_MALE", + "UCLA BHHBF2 Brain Male Only" + ], + [ + "UCLA_BHHBF2_BRAIN_2005", + "UCLA BHHBF2 Brain (2005) mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_BRAIN_2005", + "UCLA CTB6/B6CTF2 Brain (2005) mlratio **" + ], + [ + "UCLA_BHF2_BRAIN_0605", + "UCLA BHF2 Brain (June05) mlratio" + ], + [ + "BR_M2_1106_R", + "UCHSC BXD Whole Brain M430 2.0 (Nov06) RMA" + ], + [ + "IBR_M_0606_R", + "INIA Brain mRNA M430 (Jun06) RMA" + ], + [ + "IBR_M_0106_P", + "INIA Brain mRNA M430 (Jan06) PDNN" + ], + [ + "IBR_M_0106_R", + "INIA Brain mRNA M430 (Jan06) RMA" + ], + [ + "BR_U_1105_P", + "UTHSC Brain mRNA U74Av2 (Nov05) PDNN" + ], + [ + "BR_U_0805_M", + "UTHSC Brain mRNA U74Av2 (Aug05) MAS5" + ], + [ + "BR_U_0805_P", + "UTHSC Brain mRNA U74Av2 (Aug05) PDNN" + ], + [ + "BR_U_0805_R", + "UTHSC Brain mRNA U74Av2 (Aug05) RMA" + ], + [ + "BRF2_M_0805_R", + "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) RMA" + ], + [ + "BRF2_M_0805_P", + "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) PDNN" + ], + [ + "BRF2_M_0805_M", + "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) MAS5" + ], + [ + "BRF2_M_0304_P", + "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) PDNN" + ], + [ + "BRF2_M_0304_R", + "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) RMA" + ], + [ + "BRF2_M_0304_M", + "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) MAS5" + ], + [ + "CB_M_0204_P", + "INIA Brain mRNA M430 (Feb04) PDNN" + ] + ], + "Genotypes": [ + [ + "AD-cases-controls-MyersGeno", + "AD-cases-controls-Myers Genotypes" + ] + ], + "Phenotypes": [ + [ + "AD-cases-controls-MyersPublish", + "AD-cases-controls-Myers Published Phenotypes" + ] + ] + }, + "CANDLE": { + "Genotypes": [ + [ + "CANDLEGeno", + "CANDLE Genotypes" + ] + ], + "Newborn Cord Blood": [ + [ + "CANDLE_NB_0711", + "CANDLE Newborn Cord ILMv6.3 (Jun11) QUANT **" + ] + ], + "Phenotypes": [ + [ + "CANDLEPublish", + "CANDLE Published Phenotypes" + ] + ] + }, + "CEPH-2004": { + "Genotypes": [ + [ + "CEPH-2004Geno", + "CEPH-2004 Genotypes" + ] + ], + "Lymphoblast B-cell": [ + [ + "UT_CEPH_RankInv0909", + "UTHSC CEPH B-cells Illumina (Sep09) RankInv" + ], + [ + "Human_1008", + "Monks CEPH B-cells Agilent (Dec04) Log10Ratio" + ] + ], + "Phenotypes": [ + [ + "CEPH-2004Publish", + "CEPH-2004 Published Phenotypes" + ] + ] + }, + "HB": { + "Cerebellum": [ + [ + "HBTRC-MLC_0611", + "HBTRC-MLC Human Cerebellum Agilent (Jun11) mlratio" + ], + [ + "HBTRC-MLC_N_0611", + "HBTRC-MLC Human Cerebellum Agilent Normal (Jun11) mlratio" + ], + [ + "HBTRC-MLC_AD_0611", + "HBTRC-MLC Human Cerebellum Agilent AD (Jun11) mlratio" + ], + [ + "HBTRC-MLC_HD_0611", + "HBTRC-MLC Human Cerebellum Agilent HD (Jun11) mlratio" + ], + [ + "GCB_M2_0505_M", + "GE-NIAAA Cerebellum mRNA M430v2 (May05) MAS5" + ], + [ + "GCB_M2_0505_R", + "GE-NIAAA Cerebellum mRNA M430v2 (May05) RMA" + ], + [ + "GCB_M2_0505_P", + "GE-NIAAA Cerebellum mRNA M430v2 (May05) PDNN" + ], + [ + "CB_M_0305_R", + "SJUT Cerebellum mRNA M430 (Mar05) RMA" + ], + [ + "CB_M_0305_M", + "SJUT Cerebellum mRNA M430 (Mar05) MAS5" + ], + [ + "CB_M_0305_P", + "SJUT Cerebellum mRNA M430 (Mar05) PDNN" + ], + [ + "CB_M_1004_R", + "SJUT Cerebellum mRNA M430 (Oct04) RMA" + ], + [ + "CB_M_1004_M", + "SJUT Cerebellum mRNA M430 (Oct04) MAS5" + ], + [ + "CB_M_1004_P", + "SJUT Cerebellum mRNA M430 (Oct04) PDNN" + ], + [ + "CB_M_1003_M", + "SJUT Cerebellum mRNA M430 (Oct03) MAS5" + ] + ], + "Genotypes": [ + [ + "HBGeno", + "HB Genotypes" + ] + ], + "Phenotypes": [ + [ + "HBPublish", + "HB Published Phenotypes" + ] + ], + "Prefrontal Cortex": [ + [ + "HBTRC-MLPFC_0611", + "HBTRC-MLC Human Prefrontal Cortex Agilent (Jun11) mlratio" + ], + [ + "HBTRC-MLPFC_N_0611", + "HBTRC-MLC Human Prefrontal Cortex Agilent Normal (Jun11) mlratio" + ], + [ + "HBTRC-MLPFC_AD_0611", + "HBTRC-MLC Human Prefrontal Cortex Agilent AD (Jun11) mlratio" + ], + [ + "HBTRC-MLPFC_HD_0611", + "HBTRC-MLC Human Prefrontal Cortex Agilent HD (Jun11) mlratio" + ], + [ + "INIA_MacFas_Pf_RMA_0110", + "INIA Macaca fasicularis Prefrontal Cortex control (Jan10) RMA **" + ], + [ + "INIA_MacFas_PfE_RMA_0110", + "INIA Macaca fasicularis Prefrontal Cortex ethanol (Jan10) RMA **" + ], + [ + "VCUSal_1006_R", + "VCU BXD PFC Et vs Sal M430 2.0 (Dec06) Sscore" + ], + [ + "VCUEtOH_1206_R", + "VCU BXD PFC EtOH M430 2.0 (Dec06) RMA" + ], + [ + "VCUSal_1206_R", + "VCU BXD PFC Sal M430 2.0 (Dec06) RMA" + ], + [ + "VCU_PF_Air_0111_R", + "VCU BXD PFC CIE Air M430 2.0 (Jan11) RMA **" + ], + [ + "VCU_PF_Et_0111_R", + "VCU BXD PFC CIE EtOH M430 2.0 (Jan11) RMA **" + ], + [ + "VCU_PF_AvE_0111_Ss", + "VCU BXD PFC EtOH vs CIE Air M430 2.0 (Jan11) Sscore **" + ], + [ + "VCUEt_vs_Sal_0806_R", + "VCU LXS PFC Et vs Sal M430A 2.0 (Aug06) Sscore **" + ], + [ + "VCUEtOH_0806_R", + "VCU LXS PFC EtOH M430A 2.0 (Aug06) RMA **" + ], + [ + "VCUSal_0806_R", + "VCU LXS PFC Sal M430A 2.0 (Aug06) RMA" + ] + ], + "Primary Visual Cortex": [ + [ + "KIN_YSM_V1C_0711", + "KIN/YSM Human V1C Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ], + [ + "HBTRC-MLVC_0611", + "HBTRC-MLC Human Visual Cortex Agilent (Jun11) mlratio" + ], + [ + "HBTRC-MLVC_N_0611", + "HBTRC-MLC Human Visual Cortex Agilent Normal (Jun11) mlratio" + ], + [ + "HBTRC-MLVC_AD_0611", + "HBTRC-MLC Human Visual Cortex Agilent AD (Jun11) mlratio" + ], + [ + "HBTRC-MLVC_HD_0611", + "HBTRC-MLC Human Visual Cortex Agilent HD (Jun11) mlratio" + ] + ] + }, + "HLC": { + "Genotypes": [ + [ + "HLCGeno", + "HLC Genotypes" + ] + ], + "Liver": [ + [ + "GSE16780_UCLA_ML0911", + "GSE16780 UCLA Hybrid MDP Liver Affy HT M430A (Sep11) RMA" + ], + [ + "JAX_CSB_L_0711", + "JAX Liver Affy M430 2.0 (Jul11) MDP" + ], + [ + "JAX_CSB_L_HF_0711", + "JAX Liver HF Affy M430 2.0 (Jul11) MDP" + ], + [ + "JAX_CSB_L_6C_0711", + "JAX Liver 6C Affy M430 2.0 (Jul11) MDP" + ], + [ + "HLC_0311", + "GSE9588 Human Liver Normal (Mar11) Both Sexes" + ], + [ + "HLCM_0311", + "GSE9588 Human Liver Normal (Mar11) Males" + ], + [ + "LV_G_0106_F", + "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Females" + ], + [ + "LV_G_0106_M", + "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Males" + ], + [ + "LV_G_0106_B", + "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Both Sexes" + ], + [ + "GenEx_BXD_liverSal_RMA_F_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Females **" + ], + [ + "GenEx_BXD_liverSal_RMA_M_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Males **" + ], + [ + "GenEx_BXD_liverSal_RMA_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" + ], + [ + "GenEx_BXD_liverEt_RMA_F_0211", + "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Females **" + ], + [ + "GenEx_BXD_liverEt_RMA_M_0211", + "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Males **" + ], + [ + "GenEx_BXD_liverEt_RMA_0211", + "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" + ], + [ + "SUH_Liv_RMA_0611", + "SUH BXD Liver Affy Mouse Gene 1.0 ST (Jun11) RMA **" + ], + [ + "OXUKHS_ILMLiver_RI0510", + "OX UK HS ILM6v1.1 Liver (May 2010) RankInv" + ], + [ + "HXB_Liver_1208", + "MDC/CAS/UCL Liver 230v2 (Dec08) RMA" + ], + [ + "UCLA_CTB6B6CTF2_LIVER_MALE", + "UCLA CTB6B6CTF2 Liver Male mlratio **" + ], + [ + "UCLA_BHF2_LIVER_MALE", + "UCLA BHF2 Liver Male mlratio" + ], + [ + "UCLA_CTB6B6CTF2_LIVER_FEMALE", + "UCLA CTB6B6CTF2 Liver Female mlratio **" + ], + [ + "UCLA_BHHBF2_LIVER_FEMALE", + "UCLA BHHBF2 Liver Female Only" + ], + [ + "UCLA_BHHBF2_LIVER_MALE", + "UCLA BHHBF2 Liver Male Only" + ], + [ + "UCLA_BHF2_LIVER_FEMALE", + "UCLA BHF2 Liver Female mlratio" + ], + [ + "UCLA_BHHBF2_LIVER_2005", + "UCLA BHHBF2 Liver (2005) mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_LIVER_2005", + "UCLA CTB6/B6CTF2 Liver (2005) mlratio **" + ], + [ + "UCLA_BHF2_LIVER_0605", + "UCLA BHF2 Liver (June05) mlratio" + ], + [ + "UCLA_BDF2_LIVER_1999", + "UCLA BDF2 Liver (1999) mlratio" + ], + [ + "LVF2_M_0704_R", + "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) RMA" + ], + [ + "LVF2_M_0704_M", + "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) MAS5" + ], + [ + "HLCF_0311", + "GSE9588 Human Liver Normal (Mar11) Females" + ] + ], + "Phenotypes": [ + [ + "HLCPublish", + "HLC Published Phenotypes" + ] + ] + }, + "HSB": { + "Amygdala": [ + [ + "KIN_YSM_AMY_0711", + "KIN/YSM Human AMY Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ], + [ + "INIA_AmgCoh_0311", + "INIA Amygdala Cohort Affy MoGene 1.0 ST (Mar11) RMA" + ], + [ + "INIA_Amg_BLA_RMA_1110", + "INIA Amygdala Affy MoGene 1.0 ST (Nov10) RMA" + ], + [ + "INIA_Amg_BLA_RMA_M_1110", + "INIA Amygdala Affy MoGene 1.0 ST (Nov10) RMA Male" + ], + [ + "INIA_Amg_BLA_RMA_F_1110", + "INIA Amygdala Affy MoGene 1.0 ST (Nov10) RMA Female" + ], + [ + "INIA_MacFas_AMGc_RMA_0110", + "INIA Macaca fasicularis Amygdala control (Jan10) RMA **" + ], + [ + "INIA_MacFas_AMGe_RMA_0110", + "INIA Macaca fasicularis Amygdala ethanol (Jan10) RMA **" + ] + ], + "Caudal Ganglionic Eminence": [ + [ + "KIN_YSM_CGE_0711", + "KIN/YSM Human CGE Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ] + ], + "Cerebellar Cortex": [ + [ + "KIN_YSM_CBC_0711", + "KIN/YSM Human CBC Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ] + ], + "Diencephalon": [ + [ + "KIN_YSM_DIE_0711", + "KIN/YSM Human DIE Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ] + ], + "Dorsal Thalamus": [ + [ + "KIN_YSM_DTH_0711", + "KIN/YSM Human DTH Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ] + ], + "Dorsolateral Prefrontal Cortex": [ + [ + "KIN_YSM_DFC_0711", + "KIN/YSM Human DFC Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ] + ], + "Frontal Cerebral Wall": [ + [ + "KIN_YSM_FC_0711", + "KIN/YSM Human FC Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ] + ], + "Genotypes": [ + [ + "HSBGeno", + "HSB Genotypes" + ] + ], + "Hippocampus": [ + [ + "KIN_YSM_HIP_0711", + "KIN/YSM Human HIP Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ], + [ + "UMUTAffyExon_0209_RMA_MDP", + "UMUTAffy Hippocampus Exon (Feb09) RMA MDP" + ], + [ + "HC_M2_0606_MDP", + "Hippocampus Consortium M430v2 (Jun06) RMA MDP" + ], + [ + "OXUKHS_ILMHipp_RI0510", + "OX UK HS ILM6v1.1 Hippocampus (May 2010) RankInv" + ], + [ + "INIA_MacFas_Hc_RMA_0110", + "INIA Macaca fasicularis Hippocampus control (Jan10) RMA **" + ], + [ + "INIA_MacFas_He_RMA_0110", + "INIA Macaca fasicularis Hippocampus ethanol (Jan10) RMA **" + ], + [ + "UT_HippRatEx_RMA_0709", + "UT Hippocampus Affy RaEx 1.0 Exon (Jul09) RMA" + ], + [ + "Illum_LXS_Hipp_loess0807", + "Hippocampus Illumina (Aug07) LOESS" + ], + [ + "Illum_LXS_Hipp_loess_nb0807", + "Hippocampus Illumina (Aug07) LOESS_NB" + ], + [ + "Illum_LXS_Hipp_quant0807", + "Hippocampus Illumina (Aug07) QUANT" + ], + [ + "Illum_LXS_Hipp_quant_nb0807", + "Hippocampus Illumina (Aug07) QUANT_NB" + ], + [ + "Illum_LXS_Hipp_rsn0807", + "Hippocampus Illumina (Aug07) RSN" + ], + [ + "Illum_LXS_Hipp_rsn_nb0807", + "Hippocampus Illumina (Aug07) RSN_NB" + ], + [ + "Hipp_Illumina_RankInv_0507", + "Hippocampus Illumina (May07) RankInv" + ], + [ + "HC_M2_0606_P", + "Hippocampus Consortium M430v2 (Jun06) PDNN" + ], + [ + "HC_M2_0606_M", + "Hippocampus Consortium M430v2 (Jun06) MAS5" + ], + [ + "HC_M2_0606_R", + "Hippocampus Consortium M430v2 (Jun06) RMA" + ], + [ + "HC_M2CB_1205_R", + "Hippocampus Consortium M430v2 CXB (Dec05) RMA" + ], + [ + "HC_M2CB_1205_P", + "Hippocampus Consortium M430v2 CXB (Dec05) PDNN" + ], + [ + "UMUTAffyExon_0209_RMA", + "UMUTAffy Hippocampus Exon (Feb09) RMA" + ], + [ + "UT_ILM_BXD_hipp_NON_0909", + "UTHSC Hippocampus Illumina v6.1 NON (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_NOS_0909", + "UTHSC Hippocampus Illumina v6.1 NOS (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_NOE_0909", + "UTHSC Hippocampus Illumina v6.1 NOE (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_RSS_0909", + "UTHSC Hippocampus Illumina v6.1 RSS (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_RSE_0909", + "UTHSC Hippocampus Illumina v6.1 RSE (Sep09) RankInv" + ], + [ + "Illum_LXS_Hipp_RSE_1008", + "Hippocampus Illumina RSE (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_NOS_1008", + "Hippocampus Illumina NOS (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_NOE_1008", + "Hippocampus Illumina NOE (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_RSS_1008", + "Hippocampus Illumina RSS (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_NON_1008", + "Hippocampus Illumina NON (Oct08) RankInv beta" + ] + ], + "Inferior Temporal Cortex": [ + [ + "KIN_YSM_ITC_0711", + "KIN/YSM Human ITC Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ] + ], + "Lateral Ganglionic Eminence": [ + [ + "KIN_YSM_LGE_0711", + "KIN/YSM Human LGE Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ] + ], + "Medial Ganglionic Eminence": [ + [ + "KIN_YSM_MGE_0711", + "KIN/YSM Human MGE Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ] + ], + "Medial Prefrontal Cortex": [ + [ + "KIN_YSM_MFC_0711", + "KIN/YSM Human MFC Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ] + ], + "Mediodorsal Nucleus of Thalamus": [ + [ + "KIN_YSM_MD_0711", + "KIN/YSM Human MD Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ] + ], + "Occipital Cerebral Wall": [ + [ + "KIN_YSM_OC_0711", + "KIN/YSM Human OC Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ] + ], + "Orbital Prefrontal Cortex": [ + [ + "KIN_YSM_OFC_0711", + "KIN/YSM Human OFC Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ] + ], + "Parietal Cerebral Wall": [ + [ + "KIN_YSM_PC_0711", + "KIN/YSM Human PC Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ] + ], + "Phenotypes": [ + [ + "HSBPublish", + "HSB Published Phenotypes" + ] + ], + "Posterior Inferior Parietal Cortex": [ + [ + "KIN_YSM_IPC_0711", + "KIN/YSM Human IPC Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ] + ], + "Posterior Superior Temporal Cortex": [ + [ + "KIN_YSM_STC_0711", + "KIN/YSM Human STC Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ] + ], + "Primary Auditory (A1) Cortex": [ + [ + "KIN_YSM_A1C_0711", + "KIN/YSM Human A1C Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ] + ], + "Primary Motor (M1) Cortex": [ + [ + "KIN_YSM_M1C_0711", + "KIN/YSM Human M1C Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ] + ], + "Primary Somatosensory (S1) Cortex": [ + [ + "KIN_YSM_S1C_0711", + "KIN/YSM Human S1C Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ] + ], + "Primary Visual Cortex": [ + [ + "KIN_YSM_V1C_0711", + "KIN/YSM Human V1C Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ], + [ + "HBTRC-MLVC_0611", + "HBTRC-MLC Human Visual Cortex Agilent (Jun11) mlratio" + ], + [ + "HBTRC-MLVC_N_0611", + "HBTRC-MLC Human Visual Cortex Agilent Normal (Jun11) mlratio" + ], + [ + "HBTRC-MLVC_AD_0611", + "HBTRC-MLC Human Visual Cortex Agilent AD (Jun11) mlratio" + ], + [ + "HBTRC-MLVC_HD_0611", + "HBTRC-MLC Human Visual Cortex Agilent HD (Jun11) mlratio" + ] + ], + "Striatum": [ + [ + "DevStriatum_ILM6.2P3RInv_1111", + "BIDMC/UTHSC Dev Striatum P3 ILMv6.2 (Nov11) RankInv **" + ], + [ + "DevStriatum_ILM6.2P14RInv_1111", + "BIDMC/UTHSC Dev Striatum P14 ILMv6.2 (Nov11) RankInv **" + ], + [ + "KIN_YSM_STR_0711", + "KIN/YSM Human STR Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ], + [ + "OHSU_HS-CC_ILMStr_0211", + "OHSU HS-CC Striatum ILM6v1 (Feb11) RankInv" + ], + [ + "UTHSC_Striatum_RankInv_1210", + "HQF BXD Striatum ILM6.1 (Dec10v2) RankInv" + ], + [ + "UTHSC_Str_RankInv_1210", + "HQF BXD Striatum ILM6.1 (Dec10) RankInv" + ], + [ + "UTHSC_1107_RankInv", + "HQF BXD Striatum ILM6.1 (Nov07) RankInv" + ], + [ + "SA_M2_0905_P", + "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) PDNN" + ], + [ + "SA_M2_0905_M", + "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) MAS5" + ], + [ + "SA_M2_0905_R", + "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) RMA" + ], + [ + "SA_M2_0405_MC", + "HBP Rosen Striatum M430V2 (Apr05) MAS5 Clean" + ], + [ + "SA_M2_0405_RC", + "HBP Rosen Striatum M430V2 (Apr05) RMA Clean" + ], + [ + "SA_M2_0405_PC", + "HBP Rosen Striatum M430V2 (Apr05) PDNN Clean" + ], + [ + "SA_M2_0405_SS", + "HBP Rosen Striatum M430V2 (Apr05) SScore" + ], + [ + "SA_M2_0405_RR", + "HBP Rosen Striatum M430V2 (Apr05) RMA Orig" + ], + [ + "Striatum_Exon_0209", + "HQF Striatum Exon (Feb09) RMA" + ], + [ + "DevStriatum_ILM6.2P3RInv_1110", + "BIDMC/UTHSC Dev Striatum P3 ILMv6.2 (Nov10) RankInv **" + ], + [ + "DevStriatum_ILM6.2P14RInv_1110", + "BIDMC/UTHSC Dev Striatum P14 ILMv6.2 (Nov10) RankInv **" + ] + ], + "Temporal Cerebral Wall": [ + [ + "KIN_YSM_TC_0711", + "KIN/YSM Human TC Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ] + ], + "Upper (Rostral) Rhombic Lip": [ + [ + "KIN_YSM_URL_0711", + "KIN/YSM Human URL Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ] + ], + "Ventral Forebrain": [ + [ + "KIN_YSM_VF_0711", + "KIN/YSM Human VF Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ] + ], + "Ventrolateral Prefrontal Cortex": [ + [ + "KIN_YSM_VFC_0711", + "KIN/YSM Human VFC Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ] + ] + } + }, + "macaque monkey": { + "Macaca-fasicularis": { + "Amygdala": [ + [ + "KIN_YSM_AMY_0711", + "KIN/YSM Human AMY Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ], + [ + "INIA_AmgCoh_0311", + "INIA Amygdala Cohort Affy MoGene 1.0 ST (Mar11) RMA" + ], + [ + "INIA_Amg_BLA_RMA_1110", + "INIA Amygdala Affy MoGene 1.0 ST (Nov10) RMA" + ], + [ + "INIA_Amg_BLA_RMA_M_1110", + "INIA Amygdala Affy MoGene 1.0 ST (Nov10) RMA Male" + ], + [ + "INIA_Amg_BLA_RMA_F_1110", + "INIA Amygdala Affy MoGene 1.0 ST (Nov10) RMA Female" + ], + [ + "INIA_MacFas_AMGc_RMA_0110", + "INIA Macaca fasicularis Amygdala control (Jan10) RMA **" + ], + [ + "INIA_MacFas_AMGe_RMA_0110", + "INIA Macaca fasicularis Amygdala ethanol (Jan10) RMA **" + ] + ], + "Brain": [ + [ + "GSE15222_F_N_RI_0409", + "GSE15222 Human Brain Normal Myers (Apr09) RankInv" + ], + [ + "GSE15222_F_A_RI_0409", + "GSE15222 Human Brain Alzheimer Myers (Apr09) RankInv" + ], + [ + "GSE5281_F_RMA_N_0709", + "GSE5281 Human Brain Normal Full Liang (Jul09) RMA" + ], + [ + "GSE5281_F_RMA_Alzh_0709", + "GSE5281 Human Brain Alzheimer Full Liang (Jul09) RMA" + ], + [ + "INIA_MacFas_brain_RMA_0110", + "INIA Macaca fasicularis Brain (Jan10) RMA **" + ], + [ + "GSE15222_F_RI_0409", + "GSE15222 Human Brain Myers (Apr09) RankInv" + ], + [ + "GSE5281_F_RMA0709", + "GSE5281 Human Brain Full Liang (Jul09) RMA" + ], + [ + "GSE5281_RMA0709", + "GSE5281 Human Brain Best 102 Liang (Jul09) RMA" + ], + [ + "UCLA_CTB6B6CTF2_BRAIN_FEMALE", + "UCLA CTB6B6CTF2 Brain Female mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_BRAIN_MALE", + "UCLA CTB6B6CTF2 Brain Male mlratio **" + ], + [ + "UCLA_BHF2_BRAIN_MALE", + "UCLA BHF2 Brain Male mlratio" + ], + [ + "UCLA_BHF2_BRAIN_FEMALE", + "UCLA BHF2 Brain Female mlratio" + ], + [ + "UCLA_BHHBF2_BRAIN_FEMALE", + "UCLA BHHBF2 Brain Female Only" + ], + [ + "UCLA_BHHBF2_BRAIN_MALE", + "UCLA BHHBF2 Brain Male Only" + ], + [ + "UCLA_BHHBF2_BRAIN_2005", + "UCLA BHHBF2 Brain (2005) mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_BRAIN_2005", + "UCLA CTB6/B6CTF2 Brain (2005) mlratio **" + ], + [ + "UCLA_BHF2_BRAIN_0605", + "UCLA BHF2 Brain (June05) mlratio" + ], + [ + "BR_M2_1106_R", + "UCHSC BXD Whole Brain M430 2.0 (Nov06) RMA" + ], + [ + "IBR_M_0606_R", + "INIA Brain mRNA M430 (Jun06) RMA" + ], + [ + "IBR_M_0106_P", + "INIA Brain mRNA M430 (Jan06) PDNN" + ], + [ + "IBR_M_0106_R", + "INIA Brain mRNA M430 (Jan06) RMA" + ], + [ + "BR_U_1105_P", + "UTHSC Brain mRNA U74Av2 (Nov05) PDNN" + ], + [ + "BR_U_0805_M", + "UTHSC Brain mRNA U74Av2 (Aug05) MAS5" + ], + [ + "BR_U_0805_P", + "UTHSC Brain mRNA U74Av2 (Aug05) PDNN" + ], + [ + "BR_U_0805_R", + "UTHSC Brain mRNA U74Av2 (Aug05) RMA" + ], + [ + "BRF2_M_0805_R", + "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) RMA" + ], + [ + "BRF2_M_0805_P", + "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) PDNN" + ], + [ + "BRF2_M_0805_M", + "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) MAS5" + ], + [ + "BRF2_M_0304_P", + "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) PDNN" + ], + [ + "BRF2_M_0304_R", + "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) RMA" + ], + [ + "BRF2_M_0304_M", + "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) MAS5" + ], + [ + "CB_M_0204_P", + "INIA Brain mRNA M430 (Feb04) PDNN" + ] + ], + "Genotypes": [ + [ + "Macaca-fasicularisGeno", + "Macaca-fasicularis Genotypes" + ] + ], + "Hippocampus": [ + [ + "KIN_YSM_HIP_0711", + "KIN/YSM Human HIP Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ], + [ + "UMUTAffyExon_0209_RMA_MDP", + "UMUTAffy Hippocampus Exon (Feb09) RMA MDP" + ], + [ + "HC_M2_0606_MDP", + "Hippocampus Consortium M430v2 (Jun06) RMA MDP" + ], + [ + "OXUKHS_ILMHipp_RI0510", + "OX UK HS ILM6v1.1 Hippocampus (May 2010) RankInv" + ], + [ + "INIA_MacFas_Hc_RMA_0110", + "INIA Macaca fasicularis Hippocampus control (Jan10) RMA **" + ], + [ + "INIA_MacFas_He_RMA_0110", + "INIA Macaca fasicularis Hippocampus ethanol (Jan10) RMA **" + ], + [ + "UT_HippRatEx_RMA_0709", + "UT Hippocampus Affy RaEx 1.0 Exon (Jul09) RMA" + ], + [ + "Illum_LXS_Hipp_loess0807", + "Hippocampus Illumina (Aug07) LOESS" + ], + [ + "Illum_LXS_Hipp_loess_nb0807", + "Hippocampus Illumina (Aug07) LOESS_NB" + ], + [ + "Illum_LXS_Hipp_quant0807", + "Hippocampus Illumina (Aug07) QUANT" + ], + [ + "Illum_LXS_Hipp_quant_nb0807", + "Hippocampus Illumina (Aug07) QUANT_NB" + ], + [ + "Illum_LXS_Hipp_rsn0807", + "Hippocampus Illumina (Aug07) RSN" + ], + [ + "Illum_LXS_Hipp_rsn_nb0807", + "Hippocampus Illumina (Aug07) RSN_NB" + ], + [ + "Hipp_Illumina_RankInv_0507", + "Hippocampus Illumina (May07) RankInv" + ], + [ + "HC_M2_0606_P", + "Hippocampus Consortium M430v2 (Jun06) PDNN" + ], + [ + "HC_M2_0606_M", + "Hippocampus Consortium M430v2 (Jun06) MAS5" + ], + [ + "HC_M2_0606_R", + "Hippocampus Consortium M430v2 (Jun06) RMA" + ], + [ + "HC_M2CB_1205_R", + "Hippocampus Consortium M430v2 CXB (Dec05) RMA" + ], + [ + "HC_M2CB_1205_P", + "Hippocampus Consortium M430v2 CXB (Dec05) PDNN" + ], + [ + "UMUTAffyExon_0209_RMA", + "UMUTAffy Hippocampus Exon (Feb09) RMA" + ], + [ + "UT_ILM_BXD_hipp_NON_0909", + "UTHSC Hippocampus Illumina v6.1 NON (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_NOS_0909", + "UTHSC Hippocampus Illumina v6.1 NOS (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_NOE_0909", + "UTHSC Hippocampus Illumina v6.1 NOE (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_RSS_0909", + "UTHSC Hippocampus Illumina v6.1 RSS (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_RSE_0909", + "UTHSC Hippocampus Illumina v6.1 RSE (Sep09) RankInv" + ], + [ + "Illum_LXS_Hipp_RSE_1008", + "Hippocampus Illumina RSE (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_NOS_1008", + "Hippocampus Illumina NOS (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_NOE_1008", + "Hippocampus Illumina NOE (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_RSS_1008", + "Hippocampus Illumina RSS (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_NON_1008", + "Hippocampus Illumina NON (Oct08) RankInv beta" + ] + ], + "Nucleus Accumbens": [ + [ + "INIA_MacFas_Ac_RMA_0110", + "INIA Macaca fasicularis Nucleus Accumbens control (Jan10) RMA **" + ], + [ + "INIA_MacFas_Ae_RMA_0110", + "INIA Macaca fasicularis Nucleus Accumbens ethanol (Jan10) RMA **" + ], + [ + "VCUSalo_1007_R", + "VCU BXD NA Sal M430 2.0 (Oct07) RMA" + ], + [ + "VCUEtOH_1007_R", + "VCU BXD NA EtOH M430 2.0 (Oct07) RMA **" + ], + [ + "VCUSal_1007_R", + "VCU BXD NA Et vs Sal M430 2.0 (Oct07) Sscore **" + ] + ], + "Phenotypes": [ + [ + "Macaca-fasicularisPublish", + "Macaca-fasicularis Published Phenotypes" + ] + ], + "Prefrontal Cortex": [ + [ + "HBTRC-MLPFC_0611", + "HBTRC-MLC Human Prefrontal Cortex Agilent (Jun11) mlratio" + ], + [ + "HBTRC-MLPFC_N_0611", + "HBTRC-MLC Human Prefrontal Cortex Agilent Normal (Jun11) mlratio" + ], + [ + "HBTRC-MLPFC_AD_0611", + "HBTRC-MLC Human Prefrontal Cortex Agilent AD (Jun11) mlratio" + ], + [ + "HBTRC-MLPFC_HD_0611", + "HBTRC-MLC Human Prefrontal Cortex Agilent HD (Jun11) mlratio" + ], + [ + "INIA_MacFas_Pf_RMA_0110", + "INIA Macaca fasicularis Prefrontal Cortex control (Jan10) RMA **" + ], + [ + "INIA_MacFas_PfE_RMA_0110", + "INIA Macaca fasicularis Prefrontal Cortex ethanol (Jan10) RMA **" + ], + [ + "VCUSal_1006_R", + "VCU BXD PFC Et vs Sal M430 2.0 (Dec06) Sscore" + ], + [ + "VCUEtOH_1206_R", + "VCU BXD PFC EtOH M430 2.0 (Dec06) RMA" + ], + [ + "VCUSal_1206_R", + "VCU BXD PFC Sal M430 2.0 (Dec06) RMA" + ], + [ + "VCU_PF_Air_0111_R", + "VCU BXD PFC CIE Air M430 2.0 (Jan11) RMA **" + ], + [ + "VCU_PF_Et_0111_R", + "VCU BXD PFC CIE EtOH M430 2.0 (Jan11) RMA **" + ], + [ + "VCU_PF_AvE_0111_Ss", + "VCU BXD PFC EtOH vs CIE Air M430 2.0 (Jan11) Sscore **" + ], + [ + "VCUEt_vs_Sal_0806_R", + "VCU LXS PFC Et vs Sal M430A 2.0 (Aug06) Sscore **" + ], + [ + "VCUEtOH_0806_R", + "VCU LXS PFC EtOH M430A 2.0 (Aug06) RMA **" + ], + [ + "VCUSal_0806_R", + "VCU LXS PFC Sal M430A 2.0 (Aug06) RMA" + ] + ] + } + }, + "mouse": { + "AKXD": { + "Genotypes": [ + [ + "AKXDGeno", + "AKXD Genotypes" + ] + ], + "Mammary Tumors": [ + [ + "NCI_Mam_Tum_RMA_0409", + "NCI Mammary M430v2 (Apr09) RMA" + ], + [ + "NCI_Agil_Mam_Tum_RMA_0409", + "NCI Mammary LMT miRNA v2 (Apr09) RMA" + ], + [ + "MA_M_0704_R", + "NCI Mammary mRNA M430 (July04) RMA" + ], + [ + "MA_M_0704_M", + "NCI Mammary mRNA M430 (July04) MAS5" + ] + ], + "Phenotypes": [ + [ + "AKXDPublish", + "AKXD Published Phenotypes" + ] + ] + }, + "AXBXA": { + "Eye": [ + [ + "Eye_AXBXA_1008_RankInv", + "Eye AXBXA Illumina V6.2(Oct08) RankInv Beta" + ], + [ + "Eye_M2_0908_R", + "Eye M430v2 (Sep08) RMA" + ], + [ + "Eye_M2_0908_R_NB", + "Eye M430v2 Mutant Gpnmb (Sep08) RMA **" + ], + [ + "Eye_M2_0908_R_ND", + "Eye M430v2 WT Gpnmb (Sep08) RMA **" + ], + [ + "Eye_M2_0908_WTWT", + "Eye M430v2 WT WT (Sep08) RMA **" + ], + [ + "Eye_M2_0908_R_WT", + "Eye M430v2 WT Tyrp1 (Sep08) RMA **" + ], + [ + "Eye_M2_0908_R_MT", + "Eye M430v2 Mutant Tyrp1 (Sep08) RMA **" + ], + [ + "BXD_GLA_0911", + "BXD Glaucoma Affy M430 2.0 Trial (Sep11) RMA **" + ], + [ + "UIOWA_Eye_RMA_0906", + "UIOWA Eye mRNA RAE230v2 (Sep06) RMA" + ] + ], + "Genotypes": [ + [ + "AXBXAGeno", + "AXBXA Genotypes" + ] + ], + "Phenotypes": [ + [ + "AXBXAPublish", + "AXBXA Published Phenotypes" + ] + ] + }, + "B6BTBRF2": { + "Genotypes": [ + [ + "B6BTBRF2Geno", + "B6BTBRF2 Genotypes" + ] + ], + "Liver": [ + [ + "GSE16780_UCLA_ML0911", + "GSE16780 UCLA Hybrid MDP Liver Affy HT M430A (Sep11) RMA" + ], + [ + "JAX_CSB_L_0711", + "JAX Liver Affy M430 2.0 (Jul11) MDP" + ], + [ + "JAX_CSB_L_HF_0711", + "JAX Liver HF Affy M430 2.0 (Jul11) MDP" + ], + [ + "JAX_CSB_L_6C_0711", + "JAX Liver 6C Affy M430 2.0 (Jul11) MDP" + ], + [ + "HLC_0311", + "GSE9588 Human Liver Normal (Mar11) Both Sexes" + ], + [ + "HLCM_0311", + "GSE9588 Human Liver Normal (Mar11) Males" + ], + [ + "LV_G_0106_F", + "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Females" + ], + [ + "LV_G_0106_M", + "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Males" + ], + [ + "LV_G_0106_B", + "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Both Sexes" + ], + [ + "GenEx_BXD_liverSal_RMA_F_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Females **" + ], + [ + "GenEx_BXD_liverSal_RMA_M_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Males **" + ], + [ + "GenEx_BXD_liverSal_RMA_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" + ], + [ + "GenEx_BXD_liverEt_RMA_F_0211", + "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Females **" + ], + [ + "GenEx_BXD_liverEt_RMA_M_0211", + "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Males **" + ], + [ + "GenEx_BXD_liverEt_RMA_0211", + "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" + ], + [ + "SUH_Liv_RMA_0611", + "SUH BXD Liver Affy Mouse Gene 1.0 ST (Jun11) RMA **" + ], + [ + "OXUKHS_ILMLiver_RI0510", + "OX UK HS ILM6v1.1 Liver (May 2010) RankInv" + ], + [ + "HXB_Liver_1208", + "MDC/CAS/UCL Liver 230v2 (Dec08) RMA" + ], + [ + "UCLA_CTB6B6CTF2_LIVER_MALE", + "UCLA CTB6B6CTF2 Liver Male mlratio **" + ], + [ + "UCLA_BHF2_LIVER_MALE", + "UCLA BHF2 Liver Male mlratio" + ], + [ + "UCLA_CTB6B6CTF2_LIVER_FEMALE", + "UCLA CTB6B6CTF2 Liver Female mlratio **" + ], + [ + "UCLA_BHHBF2_LIVER_FEMALE", + "UCLA BHHBF2 Liver Female Only" + ], + [ + "UCLA_BHHBF2_LIVER_MALE", + "UCLA BHHBF2 Liver Male Only" + ], + [ + "UCLA_BHF2_LIVER_FEMALE", + "UCLA BHF2 Liver Female mlratio" + ], + [ + "UCLA_BHHBF2_LIVER_2005", + "UCLA BHHBF2 Liver (2005) mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_LIVER_2005", + "UCLA CTB6/B6CTF2 Liver (2005) mlratio **" + ], + [ + "UCLA_BHF2_LIVER_0605", + "UCLA BHF2 Liver (June05) mlratio" + ], + [ + "UCLA_BDF2_LIVER_1999", + "UCLA BDF2 Liver (1999) mlratio" + ], + [ + "LVF2_M_0704_R", + "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) RMA" + ], + [ + "LVF2_M_0704_M", + "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) MAS5" + ], + [ + "HLCF_0311", + "GSE9588 Human Liver Normal (Mar11) Females" + ] + ], + "Phenotypes": [ + [ + "B6BTBRF2Publish", + "B6BTBRF2 Published Phenotypes" + ] + ] + }, + "B6D2F2": { + "Brain": [ + [ + "GSE15222_F_N_RI_0409", + "GSE15222 Human Brain Normal Myers (Apr09) RankInv" + ], + [ + "GSE15222_F_A_RI_0409", + "GSE15222 Human Brain Alzheimer Myers (Apr09) RankInv" + ], + [ + "GSE5281_F_RMA_N_0709", + "GSE5281 Human Brain Normal Full Liang (Jul09) RMA" + ], + [ + "GSE5281_F_RMA_Alzh_0709", + "GSE5281 Human Brain Alzheimer Full Liang (Jul09) RMA" + ], + [ + "INIA_MacFas_brain_RMA_0110", + "INIA Macaca fasicularis Brain (Jan10) RMA **" + ], + [ + "GSE15222_F_RI_0409", + "GSE15222 Human Brain Myers (Apr09) RankInv" + ], + [ + "GSE5281_F_RMA0709", + "GSE5281 Human Brain Full Liang (Jul09) RMA" + ], + [ + "GSE5281_RMA0709", + "GSE5281 Human Brain Best 102 Liang (Jul09) RMA" + ], + [ + "UCLA_CTB6B6CTF2_BRAIN_FEMALE", + "UCLA CTB6B6CTF2 Brain Female mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_BRAIN_MALE", + "UCLA CTB6B6CTF2 Brain Male mlratio **" + ], + [ + "UCLA_BHF2_BRAIN_MALE", + "UCLA BHF2 Brain Male mlratio" + ], + [ + "UCLA_BHF2_BRAIN_FEMALE", + "UCLA BHF2 Brain Female mlratio" + ], + [ + "UCLA_BHHBF2_BRAIN_FEMALE", + "UCLA BHHBF2 Brain Female Only" + ], + [ + "UCLA_BHHBF2_BRAIN_MALE", + "UCLA BHHBF2 Brain Male Only" + ], + [ + "UCLA_BHHBF2_BRAIN_2005", + "UCLA BHHBF2 Brain (2005) mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_BRAIN_2005", + "UCLA CTB6/B6CTF2 Brain (2005) mlratio **" + ], + [ + "UCLA_BHF2_BRAIN_0605", + "UCLA BHF2 Brain (June05) mlratio" + ], + [ + "BR_M2_1106_R", + "UCHSC BXD Whole Brain M430 2.0 (Nov06) RMA" + ], + [ + "IBR_M_0606_R", + "INIA Brain mRNA M430 (Jun06) RMA" + ], + [ + "IBR_M_0106_P", + "INIA Brain mRNA M430 (Jan06) PDNN" + ], + [ + "IBR_M_0106_R", + "INIA Brain mRNA M430 (Jan06) RMA" + ], + [ + "BR_U_1105_P", + "UTHSC Brain mRNA U74Av2 (Nov05) PDNN" + ], + [ + "BR_U_0805_M", + "UTHSC Brain mRNA U74Av2 (Aug05) MAS5" + ], + [ + "BR_U_0805_P", + "UTHSC Brain mRNA U74Av2 (Aug05) PDNN" + ], + [ + "BR_U_0805_R", + "UTHSC Brain mRNA U74Av2 (Aug05) RMA" + ], + [ + "BRF2_M_0805_R", + "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) RMA" + ], + [ + "BRF2_M_0805_P", + "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) PDNN" + ], + [ + "BRF2_M_0805_M", + "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) MAS5" + ], + [ + "BRF2_M_0304_P", + "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) PDNN" + ], + [ + "BRF2_M_0304_R", + "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) RMA" + ], + [ + "BRF2_M_0304_M", + "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) MAS5" + ], + [ + "CB_M_0204_P", + "INIA Brain mRNA M430 (Feb04) PDNN" + ] + ], + "Genotypes": [ + [ + "B6D2F2Geno", + "B6D2F2 Genotypes" + ] + ], + "Phenotypes": [ + [ + "B6D2F2Publish", + "B6D2F2 Published Phenotypes" + ] + ] + }, + "BDF2-1999": { + "Genotypes": [ + [ + "BDF2-1999Geno", + "BDF2-1999 Genotypes" + ] + ], + "Liver": [ + [ + "GSE16780_UCLA_ML0911", + "GSE16780 UCLA Hybrid MDP Liver Affy HT M430A (Sep11) RMA" + ], + [ + "JAX_CSB_L_0711", + "JAX Liver Affy M430 2.0 (Jul11) MDP" + ], + [ + "JAX_CSB_L_HF_0711", + "JAX Liver HF Affy M430 2.0 (Jul11) MDP" + ], + [ + "JAX_CSB_L_6C_0711", + "JAX Liver 6C Affy M430 2.0 (Jul11) MDP" + ], + [ + "HLC_0311", + "GSE9588 Human Liver Normal (Mar11) Both Sexes" + ], + [ + "HLCM_0311", + "GSE9588 Human Liver Normal (Mar11) Males" + ], + [ + "LV_G_0106_F", + "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Females" + ], + [ + "LV_G_0106_M", + "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Males" + ], + [ + "LV_G_0106_B", + "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Both Sexes" + ], + [ + "GenEx_BXD_liverSal_RMA_F_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Females **" + ], + [ + "GenEx_BXD_liverSal_RMA_M_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Males **" + ], + [ + "GenEx_BXD_liverSal_RMA_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" + ], + [ + "GenEx_BXD_liverEt_RMA_F_0211", + "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Females **" + ], + [ + "GenEx_BXD_liverEt_RMA_M_0211", + "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Males **" + ], + [ + "GenEx_BXD_liverEt_RMA_0211", + "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" + ], + [ + "SUH_Liv_RMA_0611", + "SUH BXD Liver Affy Mouse Gene 1.0 ST (Jun11) RMA **" + ], + [ + "OXUKHS_ILMLiver_RI0510", + "OX UK HS ILM6v1.1 Liver (May 2010) RankInv" + ], + [ + "HXB_Liver_1208", + "MDC/CAS/UCL Liver 230v2 (Dec08) RMA" + ], + [ + "UCLA_CTB6B6CTF2_LIVER_MALE", + "UCLA CTB6B6CTF2 Liver Male mlratio **" + ], + [ + "UCLA_BHF2_LIVER_MALE", + "UCLA BHF2 Liver Male mlratio" + ], + [ + "UCLA_CTB6B6CTF2_LIVER_FEMALE", + "UCLA CTB6B6CTF2 Liver Female mlratio **" + ], + [ + "UCLA_BHHBF2_LIVER_FEMALE", + "UCLA BHHBF2 Liver Female Only" + ], + [ + "UCLA_BHHBF2_LIVER_MALE", + "UCLA BHHBF2 Liver Male Only" + ], + [ + "UCLA_BHF2_LIVER_FEMALE", + "UCLA BHF2 Liver Female mlratio" + ], + [ + "UCLA_BHHBF2_LIVER_2005", + "UCLA BHHBF2 Liver (2005) mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_LIVER_2005", + "UCLA CTB6/B6CTF2 Liver (2005) mlratio **" + ], + [ + "UCLA_BHF2_LIVER_0605", + "UCLA BHF2 Liver (June05) mlratio" + ], + [ + "UCLA_BDF2_LIVER_1999", + "UCLA BDF2 Liver (1999) mlratio" + ], + [ + "LVF2_M_0704_R", + "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) RMA" + ], + [ + "LVF2_M_0704_M", + "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) MAS5" + ], + [ + "HLCF_0311", + "GSE9588 Human Liver Normal (Mar11) Females" + ] + ], + "Phenotypes": [ + [ + "BDF2-1999Publish", + "BDF2-1999 Published Phenotypes" + ] + ] + }, + "BDF2-2005": { + "Genotypes": [ + [ + "BDF2-2005Geno", + "BDF2-2005 Genotypes" + ] + ], + "Phenotypes": [ + [ + "BDF2-2005Publish", + "BDF2-2005 Published Phenotypes" + ] + ], + "Striatum": [ + [ + "DevStriatum_ILM6.2P3RInv_1111", + "BIDMC/UTHSC Dev Striatum P3 ILMv6.2 (Nov11) RankInv **" + ], + [ + "DevStriatum_ILM6.2P14RInv_1111", + "BIDMC/UTHSC Dev Striatum P14 ILMv6.2 (Nov11) RankInv **" + ], + [ + "KIN_YSM_STR_0711", + "KIN/YSM Human STR Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ], + [ + "OHSU_HS-CC_ILMStr_0211", + "OHSU HS-CC Striatum ILM6v1 (Feb11) RankInv" + ], + [ + "UTHSC_Striatum_RankInv_1210", + "HQF BXD Striatum ILM6.1 (Dec10v2) RankInv" + ], + [ + "UTHSC_Str_RankInv_1210", + "HQF BXD Striatum ILM6.1 (Dec10) RankInv" + ], + [ + "UTHSC_1107_RankInv", + "HQF BXD Striatum ILM6.1 (Nov07) RankInv" + ], + [ + "SA_M2_0905_P", + "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) PDNN" + ], + [ + "SA_M2_0905_M", + "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) MAS5" + ], + [ + "SA_M2_0905_R", + "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) RMA" + ], + [ + "SA_M2_0405_MC", + "HBP Rosen Striatum M430V2 (Apr05) MAS5 Clean" + ], + [ + "SA_M2_0405_RC", + "HBP Rosen Striatum M430V2 (Apr05) RMA Clean" + ], + [ + "SA_M2_0405_PC", + "HBP Rosen Striatum M430V2 (Apr05) PDNN Clean" + ], + [ + "SA_M2_0405_SS", + "HBP Rosen Striatum M430V2 (Apr05) SScore" + ], + [ + "SA_M2_0405_RR", + "HBP Rosen Striatum M430V2 (Apr05) RMA Orig" + ], + [ + "Striatum_Exon_0209", + "HQF Striatum Exon (Feb09) RMA" + ], + [ + "DevStriatum_ILM6.2P3RInv_1110", + "BIDMC/UTHSC Dev Striatum P3 ILMv6.2 (Nov10) RankInv **" + ], + [ + "DevStriatum_ILM6.2P14RInv_1110", + "BIDMC/UTHSC Dev Striatum P14 ILMv6.2 (Nov10) RankInv **" + ] + ] + }, + "BHF2": { + "Adipose": [ + [ + "UCLA_BHF2_ADIPOSE_MALE", + "UCLA BHF2 Adipose Male mlratio" + ], + [ + "UCLA_CTB6B6CTF2_ADIPOSE_MALE", + "UCLA CTB6B6CTF2 Adipose Male mlratio **" + ], + [ + "UCLA_BHF2_ADIPOSE_FEMALE", + "UCLA BHF2 Adipose Female mlratio" + ], + [ + "UCLA_CTB6B6CTF2_ADIPOSE_FEMALE", + "UCLA CTB6B6CTF2 Adipose Female mlratio **" + ], + [ + "UCLA_BHHBF2_ADIPOSE_MALE", + "UCLA BHHBF2 Adipose Male Only" + ], + [ + "UCLA_BHHBF2_ADIPOSE_FEMALE", + "UCLA BHHBF2 Adipose Female Only" + ], + [ + "UCLA_BHHBF2_ADIPOSE_2005", + "UCLA BHHBF2 Adipose (2005) mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_ADIPOSE_2005", + "UCLA CTB6/B6CTF2 Adipose (2005) mlratio **" + ], + [ + "UCLA_BHF2_ADIPOSE_0605", + "UCLA BHF2 Adipose (June05) mlratio" + ] + ], + "Brain": [ + [ + "GSE15222_F_N_RI_0409", + "GSE15222 Human Brain Normal Myers (Apr09) RankInv" + ], + [ + "GSE15222_F_A_RI_0409", + "GSE15222 Human Brain Alzheimer Myers (Apr09) RankInv" + ], + [ + "GSE5281_F_RMA_N_0709", + "GSE5281 Human Brain Normal Full Liang (Jul09) RMA" + ], + [ + "GSE5281_F_RMA_Alzh_0709", + "GSE5281 Human Brain Alzheimer Full Liang (Jul09) RMA" + ], + [ + "INIA_MacFas_brain_RMA_0110", + "INIA Macaca fasicularis Brain (Jan10) RMA **" + ], + [ + "GSE15222_F_RI_0409", + "GSE15222 Human Brain Myers (Apr09) RankInv" + ], + [ + "GSE5281_F_RMA0709", + "GSE5281 Human Brain Full Liang (Jul09) RMA" + ], + [ + "GSE5281_RMA0709", + "GSE5281 Human Brain Best 102 Liang (Jul09) RMA" + ], + [ + "UCLA_CTB6B6CTF2_BRAIN_FEMALE", + "UCLA CTB6B6CTF2 Brain Female mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_BRAIN_MALE", + "UCLA CTB6B6CTF2 Brain Male mlratio **" + ], + [ + "UCLA_BHF2_BRAIN_MALE", + "UCLA BHF2 Brain Male mlratio" + ], + [ + "UCLA_BHF2_BRAIN_FEMALE", + "UCLA BHF2 Brain Female mlratio" + ], + [ + "UCLA_BHHBF2_BRAIN_FEMALE", + "UCLA BHHBF2 Brain Female Only" + ], + [ + "UCLA_BHHBF2_BRAIN_MALE", + "UCLA BHHBF2 Brain Male Only" + ], + [ + "UCLA_BHHBF2_BRAIN_2005", + "UCLA BHHBF2 Brain (2005) mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_BRAIN_2005", + "UCLA CTB6/B6CTF2 Brain (2005) mlratio **" + ], + [ + "UCLA_BHF2_BRAIN_0605", + "UCLA BHF2 Brain (June05) mlratio" + ], + [ + "BR_M2_1106_R", + "UCHSC BXD Whole Brain M430 2.0 (Nov06) RMA" + ], + [ + "IBR_M_0606_R", + "INIA Brain mRNA M430 (Jun06) RMA" + ], + [ + "IBR_M_0106_P", + "INIA Brain mRNA M430 (Jan06) PDNN" + ], + [ + "IBR_M_0106_R", + "INIA Brain mRNA M430 (Jan06) RMA" + ], + [ + "BR_U_1105_P", + "UTHSC Brain mRNA U74Av2 (Nov05) PDNN" + ], + [ + "BR_U_0805_M", + "UTHSC Brain mRNA U74Av2 (Aug05) MAS5" + ], + [ + "BR_U_0805_P", + "UTHSC Brain mRNA U74Av2 (Aug05) PDNN" + ], + [ + "BR_U_0805_R", + "UTHSC Brain mRNA U74Av2 (Aug05) RMA" + ], + [ + "BRF2_M_0805_R", + "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) RMA" + ], + [ + "BRF2_M_0805_P", + "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) PDNN" + ], + [ + "BRF2_M_0805_M", + "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) MAS5" + ], + [ + "BRF2_M_0304_P", + "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) PDNN" + ], + [ + "BRF2_M_0304_R", + "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) RMA" + ], + [ + "BRF2_M_0304_M", + "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) MAS5" + ], + [ + "CB_M_0204_P", + "INIA Brain mRNA M430 (Feb04) PDNN" + ] + ], + "Genotypes": [ + [ + "BHF2Geno", + "BHF2 Genotypes" + ] + ], + "Liver": [ + [ + "GSE16780_UCLA_ML0911", + "GSE16780 UCLA Hybrid MDP Liver Affy HT M430A (Sep11) RMA" + ], + [ + "JAX_CSB_L_0711", + "JAX Liver Affy M430 2.0 (Jul11) MDP" + ], + [ + "JAX_CSB_L_HF_0711", + "JAX Liver HF Affy M430 2.0 (Jul11) MDP" + ], + [ + "JAX_CSB_L_6C_0711", + "JAX Liver 6C Affy M430 2.0 (Jul11) MDP" + ], + [ + "HLC_0311", + "GSE9588 Human Liver Normal (Mar11) Both Sexes" + ], + [ + "HLCM_0311", + "GSE9588 Human Liver Normal (Mar11) Males" + ], + [ + "LV_G_0106_F", + "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Females" + ], + [ + "LV_G_0106_M", + "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Males" + ], + [ + "LV_G_0106_B", + "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Both Sexes" + ], + [ + "GenEx_BXD_liverSal_RMA_F_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Females **" + ], + [ + "GenEx_BXD_liverSal_RMA_M_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Males **" + ], + [ + "GenEx_BXD_liverSal_RMA_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" + ], + [ + "GenEx_BXD_liverEt_RMA_F_0211", + "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Females **" + ], + [ + "GenEx_BXD_liverEt_RMA_M_0211", + "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Males **" + ], + [ + "GenEx_BXD_liverEt_RMA_0211", + "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" + ], + [ + "SUH_Liv_RMA_0611", + "SUH BXD Liver Affy Mouse Gene 1.0 ST (Jun11) RMA **" + ], + [ + "OXUKHS_ILMLiver_RI0510", + "OX UK HS ILM6v1.1 Liver (May 2010) RankInv" + ], + [ + "HXB_Liver_1208", + "MDC/CAS/UCL Liver 230v2 (Dec08) RMA" + ], + [ + "UCLA_CTB6B6CTF2_LIVER_MALE", + "UCLA CTB6B6CTF2 Liver Male mlratio **" + ], + [ + "UCLA_BHF2_LIVER_MALE", + "UCLA BHF2 Liver Male mlratio" + ], + [ + "UCLA_CTB6B6CTF2_LIVER_FEMALE", + "UCLA CTB6B6CTF2 Liver Female mlratio **" + ], + [ + "UCLA_BHHBF2_LIVER_FEMALE", + "UCLA BHHBF2 Liver Female Only" + ], + [ + "UCLA_BHHBF2_LIVER_MALE", + "UCLA BHHBF2 Liver Male Only" + ], + [ + "UCLA_BHF2_LIVER_FEMALE", + "UCLA BHF2 Liver Female mlratio" + ], + [ + "UCLA_BHHBF2_LIVER_2005", + "UCLA BHHBF2 Liver (2005) mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_LIVER_2005", + "UCLA CTB6/B6CTF2 Liver (2005) mlratio **" + ], + [ + "UCLA_BHF2_LIVER_0605", + "UCLA BHF2 Liver (June05) mlratio" + ], + [ + "UCLA_BDF2_LIVER_1999", + "UCLA BDF2 Liver (1999) mlratio" + ], + [ + "LVF2_M_0704_R", + "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) RMA" + ], + [ + "LVF2_M_0704_M", + "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) MAS5" + ], + [ + "HLCF_0311", + "GSE9588 Human Liver Normal (Mar11) Females" + ] + ], + "Muscle": [ + [ + "EPFLMouseMuscleRMA1211", + "EPFL/LISP BXD Muscle Affy Mouse Gene 1.0 ST (Dec11) RMA **" + ], + [ + "EPFLMouseMuscleCDRMA1211", + "EPFL/LISP BXD CD Muscle Affy Mouse Gene 1.0 ST (Dec11) RMA **" + ], + [ + "EPFLMouseMuscleHFDRMA1211", + "EPFL/LISP BXD HFD Muscle Affy Mouse Gene 1.0 ST (Dec11) RMA **" + ], + [ + "UCLA_CTB6B6CTF2_MUSCLE_FEMALE", + "UCLA CTB6B6CTF2 Muscle Female mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_MUSCLE_MALE", + "UCLA CTB6B6CTF2 Muscle Male mlratio **" + ], + [ + "UCLA_BHHBF2_MUSCLE_FEMALE", + "UCLA BHHBF2 Muscle Female Only" + ], + [ + "UCLA_BHHBF2_MUSCLE_MALE", + "UCLA BHHBF2 Muscle Male Only" + ], + [ + "UCLA_BHF2_MUSCLE_MALE", + "UCLA BHF2 Muscle Male mlratio **" + ], + [ + "UCLA_BHF2_MUSCLE_FEMALE", + "UCLA BHF2 Muscle Female mlratio **" + ], + [ + "UCLA_BHHBF2_MUSCLE_2005", + "UCLA BHHBF2 Muscle (2005) mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_MUSCLE_2005", + "UCLA CTB6/B6CTF2 Muscle (2005) mlratio **" + ], + [ + "UCLA_BHF2_MUSCLE_0605", + "UCLA BHF2 Muscle (June05) mlratio **" + ] + ], + "Phenotypes": [ + [ + "BHF2Publish", + "BHF2 Published Phenotypes" + ] + ] + }, + "BHHBF2": { + "Adipose": [ + [ + "UCLA_BHF2_ADIPOSE_MALE", + "UCLA BHF2 Adipose Male mlratio" + ], + [ + "UCLA_CTB6B6CTF2_ADIPOSE_MALE", + "UCLA CTB6B6CTF2 Adipose Male mlratio **" + ], + [ + "UCLA_BHF2_ADIPOSE_FEMALE", + "UCLA BHF2 Adipose Female mlratio" + ], + [ + "UCLA_CTB6B6CTF2_ADIPOSE_FEMALE", + "UCLA CTB6B6CTF2 Adipose Female mlratio **" + ], + [ + "UCLA_BHHBF2_ADIPOSE_MALE", + "UCLA BHHBF2 Adipose Male Only" + ], + [ + "UCLA_BHHBF2_ADIPOSE_FEMALE", + "UCLA BHHBF2 Adipose Female Only" + ], + [ + "UCLA_BHHBF2_ADIPOSE_2005", + "UCLA BHHBF2 Adipose (2005) mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_ADIPOSE_2005", + "UCLA CTB6/B6CTF2 Adipose (2005) mlratio **" + ], + [ + "UCLA_BHF2_ADIPOSE_0605", + "UCLA BHF2 Adipose (June05) mlratio" + ] + ], + "Brain": [ + [ + "GSE15222_F_N_RI_0409", + "GSE15222 Human Brain Normal Myers (Apr09) RankInv" + ], + [ + "GSE15222_F_A_RI_0409", + "GSE15222 Human Brain Alzheimer Myers (Apr09) RankInv" + ], + [ + "GSE5281_F_RMA_N_0709", + "GSE5281 Human Brain Normal Full Liang (Jul09) RMA" + ], + [ + "GSE5281_F_RMA_Alzh_0709", + "GSE5281 Human Brain Alzheimer Full Liang (Jul09) RMA" + ], + [ + "INIA_MacFas_brain_RMA_0110", + "INIA Macaca fasicularis Brain (Jan10) RMA **" + ], + [ + "GSE15222_F_RI_0409", + "GSE15222 Human Brain Myers (Apr09) RankInv" + ], + [ + "GSE5281_F_RMA0709", + "GSE5281 Human Brain Full Liang (Jul09) RMA" + ], + [ + "GSE5281_RMA0709", + "GSE5281 Human Brain Best 102 Liang (Jul09) RMA" + ], + [ + "UCLA_CTB6B6CTF2_BRAIN_FEMALE", + "UCLA CTB6B6CTF2 Brain Female mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_BRAIN_MALE", + "UCLA CTB6B6CTF2 Brain Male mlratio **" + ], + [ + "UCLA_BHF2_BRAIN_MALE", + "UCLA BHF2 Brain Male mlratio" + ], + [ + "UCLA_BHF2_BRAIN_FEMALE", + "UCLA BHF2 Brain Female mlratio" + ], + [ + "UCLA_BHHBF2_BRAIN_FEMALE", + "UCLA BHHBF2 Brain Female Only" + ], + [ + "UCLA_BHHBF2_BRAIN_MALE", + "UCLA BHHBF2 Brain Male Only" + ], + [ + "UCLA_BHHBF2_BRAIN_2005", + "UCLA BHHBF2 Brain (2005) mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_BRAIN_2005", + "UCLA CTB6/B6CTF2 Brain (2005) mlratio **" + ], + [ + "UCLA_BHF2_BRAIN_0605", + "UCLA BHF2 Brain (June05) mlratio" + ], + [ + "BR_M2_1106_R", + "UCHSC BXD Whole Brain M430 2.0 (Nov06) RMA" + ], + [ + "IBR_M_0606_R", + "INIA Brain mRNA M430 (Jun06) RMA" + ], + [ + "IBR_M_0106_P", + "INIA Brain mRNA M430 (Jan06) PDNN" + ], + [ + "IBR_M_0106_R", + "INIA Brain mRNA M430 (Jan06) RMA" + ], + [ + "BR_U_1105_P", + "UTHSC Brain mRNA U74Av2 (Nov05) PDNN" + ], + [ + "BR_U_0805_M", + "UTHSC Brain mRNA U74Av2 (Aug05) MAS5" + ], + [ + "BR_U_0805_P", + "UTHSC Brain mRNA U74Av2 (Aug05) PDNN" + ], + [ + "BR_U_0805_R", + "UTHSC Brain mRNA U74Av2 (Aug05) RMA" + ], + [ + "BRF2_M_0805_R", + "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) RMA" + ], + [ + "BRF2_M_0805_P", + "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) PDNN" + ], + [ + "BRF2_M_0805_M", + "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) MAS5" + ], + [ + "BRF2_M_0304_P", + "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) PDNN" + ], + [ + "BRF2_M_0304_R", + "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) RMA" + ], + [ + "BRF2_M_0304_M", + "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) MAS5" + ], + [ + "CB_M_0204_P", + "INIA Brain mRNA M430 (Feb04) PDNN" + ] + ], + "Genotypes": [ + [ + "BHHBF2Geno", + "BHHBF2 Genotypes" + ] + ], + "Liver": [ + [ + "GSE16780_UCLA_ML0911", + "GSE16780 UCLA Hybrid MDP Liver Affy HT M430A (Sep11) RMA" + ], + [ + "JAX_CSB_L_0711", + "JAX Liver Affy M430 2.0 (Jul11) MDP" + ], + [ + "JAX_CSB_L_HF_0711", + "JAX Liver HF Affy M430 2.0 (Jul11) MDP" + ], + [ + "JAX_CSB_L_6C_0711", + "JAX Liver 6C Affy M430 2.0 (Jul11) MDP" + ], + [ + "HLC_0311", + "GSE9588 Human Liver Normal (Mar11) Both Sexes" + ], + [ + "HLCM_0311", + "GSE9588 Human Liver Normal (Mar11) Males" + ], + [ + "LV_G_0106_F", + "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Females" + ], + [ + "LV_G_0106_M", + "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Males" + ], + [ + "LV_G_0106_B", + "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Both Sexes" + ], + [ + "GenEx_BXD_liverSal_RMA_F_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Females **" + ], + [ + "GenEx_BXD_liverSal_RMA_M_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Males **" + ], + [ + "GenEx_BXD_liverSal_RMA_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" + ], + [ + "GenEx_BXD_liverEt_RMA_F_0211", + "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Females **" + ], + [ + "GenEx_BXD_liverEt_RMA_M_0211", + "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Males **" + ], + [ + "GenEx_BXD_liverEt_RMA_0211", + "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" + ], + [ + "SUH_Liv_RMA_0611", + "SUH BXD Liver Affy Mouse Gene 1.0 ST (Jun11) RMA **" + ], + [ + "OXUKHS_ILMLiver_RI0510", + "OX UK HS ILM6v1.1 Liver (May 2010) RankInv" + ], + [ + "HXB_Liver_1208", + "MDC/CAS/UCL Liver 230v2 (Dec08) RMA" + ], + [ + "UCLA_CTB6B6CTF2_LIVER_MALE", + "UCLA CTB6B6CTF2 Liver Male mlratio **" + ], + [ + "UCLA_BHF2_LIVER_MALE", + "UCLA BHF2 Liver Male mlratio" + ], + [ + "UCLA_CTB6B6CTF2_LIVER_FEMALE", + "UCLA CTB6B6CTF2 Liver Female mlratio **" + ], + [ + "UCLA_BHHBF2_LIVER_FEMALE", + "UCLA BHHBF2 Liver Female Only" + ], + [ + "UCLA_BHHBF2_LIVER_MALE", + "UCLA BHHBF2 Liver Male Only" + ], + [ + "UCLA_BHF2_LIVER_FEMALE", + "UCLA BHF2 Liver Female mlratio" + ], + [ + "UCLA_BHHBF2_LIVER_2005", + "UCLA BHHBF2 Liver (2005) mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_LIVER_2005", + "UCLA CTB6/B6CTF2 Liver (2005) mlratio **" + ], + [ + "UCLA_BHF2_LIVER_0605", + "UCLA BHF2 Liver (June05) mlratio" + ], + [ + "UCLA_BDF2_LIVER_1999", + "UCLA BDF2 Liver (1999) mlratio" + ], + [ + "LVF2_M_0704_R", + "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) RMA" + ], + [ + "LVF2_M_0704_M", + "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) MAS5" + ], + [ + "HLCF_0311", + "GSE9588 Human Liver Normal (Mar11) Females" + ] + ], + "Muscle": [ + [ + "EPFLMouseMuscleRMA1211", + "EPFL/LISP BXD Muscle Affy Mouse Gene 1.0 ST (Dec11) RMA **" + ], + [ + "EPFLMouseMuscleCDRMA1211", + "EPFL/LISP BXD CD Muscle Affy Mouse Gene 1.0 ST (Dec11) RMA **" + ], + [ + "EPFLMouseMuscleHFDRMA1211", + "EPFL/LISP BXD HFD Muscle Affy Mouse Gene 1.0 ST (Dec11) RMA **" + ], + [ + "UCLA_CTB6B6CTF2_MUSCLE_FEMALE", + "UCLA CTB6B6CTF2 Muscle Female mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_MUSCLE_MALE", + "UCLA CTB6B6CTF2 Muscle Male mlratio **" + ], + [ + "UCLA_BHHBF2_MUSCLE_FEMALE", + "UCLA BHHBF2 Muscle Female Only" + ], + [ + "UCLA_BHHBF2_MUSCLE_MALE", + "UCLA BHHBF2 Muscle Male Only" + ], + [ + "UCLA_BHF2_MUSCLE_MALE", + "UCLA BHF2 Muscle Male mlratio **" + ], + [ + "UCLA_BHF2_MUSCLE_FEMALE", + "UCLA BHF2 Muscle Female mlratio **" + ], + [ + "UCLA_BHHBF2_MUSCLE_2005", + "UCLA BHHBF2 Muscle (2005) mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_MUSCLE_2005", + "UCLA CTB6/B6CTF2 Muscle (2005) mlratio **" + ], + [ + "UCLA_BHF2_MUSCLE_0605", + "UCLA BHF2 Muscle (June05) mlratio **" + ] + ], + "Phenotypes": [ + [ + "BHHBF2Publish", + "BHHBF2 Published Phenotypes" + ] + ] + }, + "BXD": { + "Amygdala": [ + [ + "KIN_YSM_AMY_0711", + "KIN/YSM Human AMY Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ], + [ + "INIA_AmgCoh_0311", + "INIA Amygdala Cohort Affy MoGene 1.0 ST (Mar11) RMA" + ], + [ + "INIA_Amg_BLA_RMA_1110", + "INIA Amygdala Affy MoGene 1.0 ST (Nov10) RMA" + ], + [ + "INIA_Amg_BLA_RMA_M_1110", + "INIA Amygdala Affy MoGene 1.0 ST (Nov10) RMA Male" + ], + [ + "INIA_Amg_BLA_RMA_F_1110", + "INIA Amygdala Affy MoGene 1.0 ST (Nov10) RMA Female" + ], + [ + "INIA_MacFas_AMGc_RMA_0110", + "INIA Macaca fasicularis Amygdala control (Jan10) RMA **" + ], + [ + "INIA_MacFas_AMGe_RMA_0110", + "INIA Macaca fasicularis Amygdala ethanol (Jan10) RMA **" + ] + ], + "Brain": [ + [ + "GSE15222_F_N_RI_0409", + "GSE15222 Human Brain Normal Myers (Apr09) RankInv" + ], + [ + "GSE15222_F_A_RI_0409", + "GSE15222 Human Brain Alzheimer Myers (Apr09) RankInv" + ], + [ + "GSE5281_F_RMA_N_0709", + "GSE5281 Human Brain Normal Full Liang (Jul09) RMA" + ], + [ + "GSE5281_F_RMA_Alzh_0709", + "GSE5281 Human Brain Alzheimer Full Liang (Jul09) RMA" + ], + [ + "INIA_MacFas_brain_RMA_0110", + "INIA Macaca fasicularis Brain (Jan10) RMA **" + ], + [ + "GSE15222_F_RI_0409", + "GSE15222 Human Brain Myers (Apr09) RankInv" + ], + [ + "GSE5281_F_RMA0709", + "GSE5281 Human Brain Full Liang (Jul09) RMA" + ], + [ + "GSE5281_RMA0709", + "GSE5281 Human Brain Best 102 Liang (Jul09) RMA" + ], + [ + "UCLA_CTB6B6CTF2_BRAIN_FEMALE", + "UCLA CTB6B6CTF2 Brain Female mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_BRAIN_MALE", + "UCLA CTB6B6CTF2 Brain Male mlratio **" + ], + [ + "UCLA_BHF2_BRAIN_MALE", + "UCLA BHF2 Brain Male mlratio" + ], + [ + "UCLA_BHF2_BRAIN_FEMALE", + "UCLA BHF2 Brain Female mlratio" + ], + [ + "UCLA_BHHBF2_BRAIN_FEMALE", + "UCLA BHHBF2 Brain Female Only" + ], + [ + "UCLA_BHHBF2_BRAIN_MALE", + "UCLA BHHBF2 Brain Male Only" + ], + [ + "UCLA_BHHBF2_BRAIN_2005", + "UCLA BHHBF2 Brain (2005) mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_BRAIN_2005", + "UCLA CTB6/B6CTF2 Brain (2005) mlratio **" + ], + [ + "UCLA_BHF2_BRAIN_0605", + "UCLA BHF2 Brain (June05) mlratio" + ], + [ + "BR_M2_1106_R", + "UCHSC BXD Whole Brain M430 2.0 (Nov06) RMA" + ], + [ + "IBR_M_0606_R", + "INIA Brain mRNA M430 (Jun06) RMA" + ], + [ + "IBR_M_0106_P", + "INIA Brain mRNA M430 (Jan06) PDNN" + ], + [ + "IBR_M_0106_R", + "INIA Brain mRNA M430 (Jan06) RMA" + ], + [ + "BR_U_1105_P", + "UTHSC Brain mRNA U74Av2 (Nov05) PDNN" + ], + [ + "BR_U_0805_M", + "UTHSC Brain mRNA U74Av2 (Aug05) MAS5" + ], + [ + "BR_U_0805_P", + "UTHSC Brain mRNA U74Av2 (Aug05) PDNN" + ], + [ + "BR_U_0805_R", + "UTHSC Brain mRNA U74Av2 (Aug05) RMA" + ], + [ + "BRF2_M_0805_R", + "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) RMA" + ], + [ + "BRF2_M_0805_P", + "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) PDNN" + ], + [ + "BRF2_M_0805_M", + "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) MAS5" + ], + [ + "BRF2_M_0304_P", + "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) PDNN" + ], + [ + "BRF2_M_0304_R", + "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) RMA" + ], + [ + "BRF2_M_0304_M", + "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) MAS5" + ], + [ + "CB_M_0204_P", + "INIA Brain mRNA M430 (Feb04) PDNN" + ] + ], + "Cartilage": [ + [ + "UCLA_BXDBXH_CARTILAGE_V2", + "UCLA BXD and BXH Cartilage v2" + ], + [ + "UCLA_BXHBXD_CARTILAGE_V2", + "UCLA BXH and BXD Cartilage v2" + ], + [ + "UCLA_BXDBXH_CARTILAGE", + "UCLA BXD and BXH Cartilage" + ], + [ + "UCLA_BXHBXD_CARTILAGE", + "UCLA BXH and BXD Cartilage" + ], + [ + "UCLA_BXD_CARTILAGE", + "UCLA BXD Cartilage" + ], + [ + "UCLA_BXH_CARTILAGE", + "UCLA BXH Cartilage" + ] + ], + "Cerebellum": [ + [ + "HBTRC-MLC_0611", + "HBTRC-MLC Human Cerebellum Agilent (Jun11) mlratio" + ], + [ + "HBTRC-MLC_N_0611", + "HBTRC-MLC Human Cerebellum Agilent Normal (Jun11) mlratio" + ], + [ + "HBTRC-MLC_AD_0611", + "HBTRC-MLC Human Cerebellum Agilent AD (Jun11) mlratio" + ], + [ + "HBTRC-MLC_HD_0611", + "HBTRC-MLC Human Cerebellum Agilent HD (Jun11) mlratio" + ], + [ + "GCB_M2_0505_M", + "GE-NIAAA Cerebellum mRNA M430v2 (May05) MAS5" + ], + [ + "GCB_M2_0505_R", + "GE-NIAAA Cerebellum mRNA M430v2 (May05) RMA" + ], + [ + "GCB_M2_0505_P", + "GE-NIAAA Cerebellum mRNA M430v2 (May05) PDNN" + ], + [ + "CB_M_0305_R", + "SJUT Cerebellum mRNA M430 (Mar05) RMA" + ], + [ + "CB_M_0305_M", + "SJUT Cerebellum mRNA M430 (Mar05) MAS5" + ], + [ + "CB_M_0305_P", + "SJUT Cerebellum mRNA M430 (Mar05) PDNN" + ], + [ + "CB_M_1004_R", + "SJUT Cerebellum mRNA M430 (Oct04) RMA" + ], + [ + "CB_M_1004_M", + "SJUT Cerebellum mRNA M430 (Oct04) MAS5" + ], + [ + "CB_M_1004_P", + "SJUT Cerebellum mRNA M430 (Oct04) PDNN" + ], + [ + "CB_M_1003_M", + "SJUT Cerebellum mRNA M430 (Oct03) MAS5" + ] + ], + "Eye": [ + [ + "Eye_AXBXA_1008_RankInv", + "Eye AXBXA Illumina V6.2(Oct08) RankInv Beta" + ], + [ + "Eye_M2_0908_R", + "Eye M430v2 (Sep08) RMA" + ], + [ + "Eye_M2_0908_R_NB", + "Eye M430v2 Mutant Gpnmb (Sep08) RMA **" + ], + [ + "Eye_M2_0908_R_ND", + "Eye M430v2 WT Gpnmb (Sep08) RMA **" + ], + [ + "Eye_M2_0908_WTWT", + "Eye M430v2 WT WT (Sep08) RMA **" + ], + [ + "Eye_M2_0908_R_WT", + "Eye M430v2 WT Tyrp1 (Sep08) RMA **" + ], + [ + "Eye_M2_0908_R_MT", + "Eye M430v2 Mutant Tyrp1 (Sep08) RMA **" + ], + [ + "BXD_GLA_0911", + "BXD Glaucoma Affy M430 2.0 Trial (Sep11) RMA **" + ], + [ + "UIOWA_Eye_RMA_0906", + "UIOWA Eye mRNA RAE230v2 (Sep06) RMA" + ] + ], + "Genotypes": [ + [ + "BXDGeno", + "BXD Genotypes" + ] + ], + "Hematopoietic Cells": [ + [ + "UMCG_0907_HemaStem_ori", + "UMCG Stem Cells ILM6v1.1 (Apr09) original" + ], + [ + "UMCG_0907_HemaStem", + "UMCG Stem Cells ILM6v1.1 (Apr09) transformed" + ], + [ + "UMCG_0907_Pro_ori", + "UMCG Progenitor Cells ILM6v1.1 (Apr09) original" + ], + [ + "UMCG_0907_Pro", + "UMCG Progenitor Cells ILM6v1.1 (Apr09) transformed" + ], + [ + "UMCG_0907_Eryth_ori", + "UMCG Erythroid Cells ILM6v1.1 (Apr09) original" + ], + [ + "UMCG_0907_Eryth", + "UMCG Erythroid Cells ILM6v1.1 (Apr09) transformed" + ], + [ + "UMCG_0907_Myeloid_ori", + "UMCG Myeloid Cells ILM6v1.1 (Apr09) original" + ], + [ + "UMCG_0907_Myeloid", + "UMCG Myeloid Cells ILM6v1.1 (Apr09) transformed" + ], + [ + "HC_U_0304_R", + "GNF Stem Cells U74Av2 (Mar04) RMA" + ] + ], + "Hippocampus": [ + [ + "KIN_YSM_HIP_0711", + "KIN/YSM Human HIP Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ], + [ + "UMUTAffyExon_0209_RMA_MDP", + "UMUTAffy Hippocampus Exon (Feb09) RMA MDP" + ], + [ + "HC_M2_0606_MDP", + "Hippocampus Consortium M430v2 (Jun06) RMA MDP" + ], + [ + "OXUKHS_ILMHipp_RI0510", + "OX UK HS ILM6v1.1 Hippocampus (May 2010) RankInv" + ], + [ + "INIA_MacFas_Hc_RMA_0110", + "INIA Macaca fasicularis Hippocampus control (Jan10) RMA **" + ], + [ + "INIA_MacFas_He_RMA_0110", + "INIA Macaca fasicularis Hippocampus ethanol (Jan10) RMA **" + ], + [ + "UT_HippRatEx_RMA_0709", + "UT Hippocampus Affy RaEx 1.0 Exon (Jul09) RMA" + ], + [ + "Illum_LXS_Hipp_loess0807", + "Hippocampus Illumina (Aug07) LOESS" + ], + [ + "Illum_LXS_Hipp_loess_nb0807", + "Hippocampus Illumina (Aug07) LOESS_NB" + ], + [ + "Illum_LXS_Hipp_quant0807", + "Hippocampus Illumina (Aug07) QUANT" + ], + [ + "Illum_LXS_Hipp_quant_nb0807", + "Hippocampus Illumina (Aug07) QUANT_NB" + ], + [ + "Illum_LXS_Hipp_rsn0807", + "Hippocampus Illumina (Aug07) RSN" + ], + [ + "Illum_LXS_Hipp_rsn_nb0807", + "Hippocampus Illumina (Aug07) RSN_NB" + ], + [ + "Hipp_Illumina_RankInv_0507", + "Hippocampus Illumina (May07) RankInv" + ], + [ + "HC_M2_0606_P", + "Hippocampus Consortium M430v2 (Jun06) PDNN" + ], + [ + "HC_M2_0606_M", + "Hippocampus Consortium M430v2 (Jun06) MAS5" + ], + [ + "HC_M2_0606_R", + "Hippocampus Consortium M430v2 (Jun06) RMA" + ], + [ + "HC_M2CB_1205_R", + "Hippocampus Consortium M430v2 CXB (Dec05) RMA" + ], + [ + "HC_M2CB_1205_P", + "Hippocampus Consortium M430v2 CXB (Dec05) PDNN" + ], + [ + "UMUTAffyExon_0209_RMA", + "UMUTAffy Hippocampus Exon (Feb09) RMA" + ], + [ + "UT_ILM_BXD_hipp_NON_0909", + "UTHSC Hippocampus Illumina v6.1 NON (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_NOS_0909", + "UTHSC Hippocampus Illumina v6.1 NOS (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_NOE_0909", + "UTHSC Hippocampus Illumina v6.1 NOE (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_RSS_0909", + "UTHSC Hippocampus Illumina v6.1 RSS (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_RSE_0909", + "UTHSC Hippocampus Illumina v6.1 RSE (Sep09) RankInv" + ], + [ + "Illum_LXS_Hipp_RSE_1008", + "Hippocampus Illumina RSE (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_NOS_1008", + "Hippocampus Illumina NOS (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_NOE_1008", + "Hippocampus Illumina NOE (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_RSS_1008", + "Hippocampus Illumina RSS (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_NON_1008", + "Hippocampus Illumina NON (Oct08) RankInv beta" + ] + ], + "Hypothalamus": [ + [ + "INIA_Hyp_RMA_1110", + "INIA Hypothalamus Affy MoGene 1.0 ST (Nov10)" + ], + [ + "INIA_Hyp_M_RMA_1110", + "INIA Hypothalamus Affy MoGene 1.0 ST (Nov10) Male" + ], + [ + "INIA_Hyp_F_RMA_1110", + "INIA Hypothalamus Affy MoGene 1.0 ST (Nov10) Female" + ] + ], + "Kidney": [ + [ + "MA_M2F_0706_R", + "Mouse kidney M430v2 Female (Aug06) RMA" + ], + [ + "MA_M2M_0706_R", + "Mouse kidney M430v2 Male (Aug06) RMA" + ], + [ + "MA_M2_0806_R", + "Mouse kidney M430v2 Sex Balanced (Aug06) RMA" + ], + [ + "MA_M2_0806_P", + "Mouse Kidney M430v2 Sex Balanced (Aug06) PDNN" + ], + [ + "MA_M2_0706_P", + "Mouse Kidney M430v2 (Jul06) PDNN" + ], + [ + "MA_M2_0706_R", + "Mouse Kidney M430v2 (Jul06) RMA" + ], + [ + "KI_2A_0405_M", + "MDC/CAS/ICL Kidney 230A (Apr05) MAS5" + ], + [ + "KI_2A_0405_Rz", + "MDC/CAS/ICL Kidney 230A (Apr05) RMA 2z+8" + ], + [ + "KI_2A_0405_R", + "MDC/CAS/ICL Kidney 230A (Apr05) RMA" + ] + ], + "Leucocytes": [ + [ + "Illum_BXD_PBL_1108", + "UWA Illumina PBL (Nov08) RSN **" + ] + ], + "Liver": [ + [ + "GSE16780_UCLA_ML0911", + "GSE16780 UCLA Hybrid MDP Liver Affy HT M430A (Sep11) RMA" + ], + [ + "JAX_CSB_L_0711", + "JAX Liver Affy M430 2.0 (Jul11) MDP" + ], + [ + "JAX_CSB_L_HF_0711", + "JAX Liver HF Affy M430 2.0 (Jul11) MDP" + ], + [ + "JAX_CSB_L_6C_0711", + "JAX Liver 6C Affy M430 2.0 (Jul11) MDP" + ], + [ + "HLC_0311", + "GSE9588 Human Liver Normal (Mar11) Both Sexes" + ], + [ + "HLCM_0311", + "GSE9588 Human Liver Normal (Mar11) Males" + ], + [ + "LV_G_0106_F", + "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Females" + ], + [ + "LV_G_0106_M", + "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Males" + ], + [ + "LV_G_0106_B", + "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Both Sexes" + ], + [ + "GenEx_BXD_liverSal_RMA_F_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Females **" + ], + [ + "GenEx_BXD_liverSal_RMA_M_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Males **" + ], + [ + "GenEx_BXD_liverSal_RMA_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" + ], + [ + "GenEx_BXD_liverEt_RMA_F_0211", + "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Females **" + ], + [ + "GenEx_BXD_liverEt_RMA_M_0211", + "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Males **" + ], + [ + "GenEx_BXD_liverEt_RMA_0211", + "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" + ], + [ + "SUH_Liv_RMA_0611", + "SUH BXD Liver Affy Mouse Gene 1.0 ST (Jun11) RMA **" + ], + [ + "OXUKHS_ILMLiver_RI0510", + "OX UK HS ILM6v1.1 Liver (May 2010) RankInv" + ], + [ + "HXB_Liver_1208", + "MDC/CAS/UCL Liver 230v2 (Dec08) RMA" + ], + [ + "UCLA_CTB6B6CTF2_LIVER_MALE", + "UCLA CTB6B6CTF2 Liver Male mlratio **" + ], + [ + "UCLA_BHF2_LIVER_MALE", + "UCLA BHF2 Liver Male mlratio" + ], + [ + "UCLA_CTB6B6CTF2_LIVER_FEMALE", + "UCLA CTB6B6CTF2 Liver Female mlratio **" + ], + [ + "UCLA_BHHBF2_LIVER_FEMALE", + "UCLA BHHBF2 Liver Female Only" + ], + [ + "UCLA_BHHBF2_LIVER_MALE", + "UCLA BHHBF2 Liver Male Only" + ], + [ + "UCLA_BHF2_LIVER_FEMALE", + "UCLA BHF2 Liver Female mlratio" + ], + [ + "UCLA_BHHBF2_LIVER_2005", + "UCLA BHHBF2 Liver (2005) mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_LIVER_2005", + "UCLA CTB6/B6CTF2 Liver (2005) mlratio **" + ], + [ + "UCLA_BHF2_LIVER_0605", + "UCLA BHF2 Liver (June05) mlratio" + ], + [ + "UCLA_BDF2_LIVER_1999", + "UCLA BDF2 Liver (1999) mlratio" + ], + [ + "LVF2_M_0704_R", + "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) RMA" + ], + [ + "LVF2_M_0704_M", + "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) MAS5" + ], + [ + "HLCF_0311", + "GSE9588 Human Liver Normal (Mar11) Females" + ] + ], + "Lung": [ + [ + "OXUKHS_ILMLung_RI0510", + "OX UK HS ILM6v1.1 Lung (May 2010) RankInv" + ], + [ + "HZI_0408_R", + "HZI Lung M430v2 (Apr08) RMA" + ], + [ + "HZI_0408_M", + "HZI Lung M430v2 (Apr08) MAS5" + ] + ], + "Midbrain": [ + [ + "VUBXDMouseMidBrainQ0212", + "VU BXD Midbrain Agilent SurePrint G3 Mouse GE (Feb12) Quantile" + ] + ], + "Muscle": [ + [ + "EPFLMouseMuscleRMA1211", + "EPFL/LISP BXD Muscle Affy Mouse Gene 1.0 ST (Dec11) RMA **" + ], + [ + "EPFLMouseMuscleCDRMA1211", + "EPFL/LISP BXD CD Muscle Affy Mouse Gene 1.0 ST (Dec11) RMA **" + ], + [ + "EPFLMouseMuscleHFDRMA1211", + "EPFL/LISP BXD HFD Muscle Affy Mouse Gene 1.0 ST (Dec11) RMA **" + ], + [ + "UCLA_CTB6B6CTF2_MUSCLE_FEMALE", + "UCLA CTB6B6CTF2 Muscle Female mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_MUSCLE_MALE", + "UCLA CTB6B6CTF2 Muscle Male mlratio **" + ], + [ + "UCLA_BHHBF2_MUSCLE_FEMALE", + "UCLA BHHBF2 Muscle Female Only" + ], + [ + "UCLA_BHHBF2_MUSCLE_MALE", + "UCLA BHHBF2 Muscle Male Only" + ], + [ + "UCLA_BHF2_MUSCLE_MALE", + "UCLA BHF2 Muscle Male mlratio **" + ], + [ + "UCLA_BHF2_MUSCLE_FEMALE", + "UCLA BHF2 Muscle Female mlratio **" + ], + [ + "UCLA_BHHBF2_MUSCLE_2005", + "UCLA BHHBF2 Muscle (2005) mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_MUSCLE_2005", + "UCLA CTB6/B6CTF2 Muscle (2005) mlratio **" + ], + [ + "UCLA_BHF2_MUSCLE_0605", + "UCLA BHF2 Muscle (June05) mlratio **" + ] + ], + "Neocortex": [ + [ + "DevNeocortex_ILM6.2P14RInv_1111", + "BIDMC/UTHSC Dev Neocortex P14 ILMv6.2 (Nov11) RankInv **" + ], + [ + "DevNeocortex_ILM6.2P3RInv_1111", + "BIDMC/UTHSC Dev Neocortex P3 ILMv6.2 (Nov11) RankInv **" + ], + [ + "HQFNeoc_1210v2_RankInv", + "HQF BXD Neocortex ILM6v1.1 (Dec10v2) RankInv" + ], + [ + "HQFNeoc_1210_RankInv", + "HQF BXD Neocortex ILM6v1.1 (Dec10) RankInv" + ], + [ + "HQFNeoc_0208_RankInv", + "HQF BXD Neocortex ILM6v1.1 (Feb08) RankInv" + ], + [ + "DevNeocortex_ILM6.2P3RInv_1110", + "BIDMC/UTHSC Dev Neocortex P3 ILMv6.2 (Nov10) RankInv **" + ], + [ + "DevNeocortex_ILM6.2P14RInv_1110", + "BIDMC/UTHSC Dev Neocortex P14 ILMv6.2 (Nov10) RankInv **" + ] + ], + "Nucleus Accumbens": [ + [ + "INIA_MacFas_Ac_RMA_0110", + "INIA Macaca fasicularis Nucleus Accumbens control (Jan10) RMA **" + ], + [ + "INIA_MacFas_Ae_RMA_0110", + "INIA Macaca fasicularis Nucleus Accumbens ethanol (Jan10) RMA **" + ], + [ + "VCUSalo_1007_R", + "VCU BXD NA Sal M430 2.0 (Oct07) RMA" + ], + [ + "VCUEtOH_1007_R", + "VCU BXD NA EtOH M430 2.0 (Oct07) RMA **" + ], + [ + "VCUSal_1007_R", + "VCU BXD NA Et vs Sal M430 2.0 (Oct07) Sscore **" + ] + ], + "Phenotypes": [ + [ + "BXDPublish", + "BXD Published Phenotypes" + ] + ], + "Prefrontal Cortex": [ + [ + "HBTRC-MLPFC_0611", + "HBTRC-MLC Human Prefrontal Cortex Agilent (Jun11) mlratio" + ], + [ + "HBTRC-MLPFC_N_0611", + "HBTRC-MLC Human Prefrontal Cortex Agilent Normal (Jun11) mlratio" + ], + [ + "HBTRC-MLPFC_AD_0611", + "HBTRC-MLC Human Prefrontal Cortex Agilent AD (Jun11) mlratio" + ], + [ + "HBTRC-MLPFC_HD_0611", + "HBTRC-MLC Human Prefrontal Cortex Agilent HD (Jun11) mlratio" + ], + [ + "INIA_MacFas_Pf_RMA_0110", + "INIA Macaca fasicularis Prefrontal Cortex control (Jan10) RMA **" + ], + [ + "INIA_MacFas_PfE_RMA_0110", + "INIA Macaca fasicularis Prefrontal Cortex ethanol (Jan10) RMA **" + ], + [ + "VCUSal_1006_R", + "VCU BXD PFC Et vs Sal M430 2.0 (Dec06) Sscore" + ], + [ + "VCUEtOH_1206_R", + "VCU BXD PFC EtOH M430 2.0 (Dec06) RMA" + ], + [ + "VCUSal_1206_R", + "VCU BXD PFC Sal M430 2.0 (Dec06) RMA" + ], + [ + "VCU_PF_Air_0111_R", + "VCU BXD PFC CIE Air M430 2.0 (Jan11) RMA **" + ], + [ + "VCU_PF_Et_0111_R", + "VCU BXD PFC CIE EtOH M430 2.0 (Jan11) RMA **" + ], + [ + "VCU_PF_AvE_0111_Ss", + "VCU BXD PFC EtOH vs CIE Air M430 2.0 (Jan11) Sscore **" + ], + [ + "VCUEt_vs_Sal_0806_R", + "VCU LXS PFC Et vs Sal M430A 2.0 (Aug06) Sscore **" + ], + [ + "VCUEtOH_0806_R", + "VCU LXS PFC EtOH M430A 2.0 (Aug06) RMA **" + ], + [ + "VCUSal_0806_R", + "VCU LXS PFC Sal M430A 2.0 (Aug06) RMA" + ] + ], + "Retina": [ + [ + "Illum_Retina_BXD_RankInv0410", + "HEI Retina Illumina V6.2 (April 2010) RankInv" + ], + [ + "B6D2ONCILM_0412", + "B6D2 ONC Illumina v6.1 (Apr12) RankInv **" + ], + [ + "ONCRetILM6_0412", + "ONC Retina Illumina V6.2 (Apr12) RankInv **" + ], + [ + "G2HEIONCRetILM6_0911", + "G2 HEI ONC Retina Illumina V6.2 (Sep11) RankInv **" + ], + [ + "HEIONCRetILM6_0911", + "HEI ONC Retina Illumina V6.2 (Sep11) RankInv **" + ], + [ + "HEIONCvsCRetILM6_0911", + "HEI ONC vs Control Retina Illumina V6.2 (Sep11) RankInv **" + ], + [ + "ILM_Retina_BXD_F_RankInv1210", + "HEI Retina Females Illumina V6.2 (Dec10) RankInv **" + ], + [ + "ILM_Retina_BXD_M_RankInv1210", + "HEI Retina Males Illumina V6.2 (Dec10) RankInv **" + ], + [ + "ILM_Retina_BXD_FM_RankInv1210", + "HEI Retina F-M Illumina V6.2 (Dec10) RankInv **" + ], + [ + "G2NEI_ILM_Retina_BXD_RI0410", + "G2NEI Retina Illumina V6.2 (April 2010) RankInv **" + ] + ], + "Spleen": [ + [ + "UTHSC_SPL_RMA_1210", + "UTHSC Affy MoGene 1.0 ST Spleen (Dec10) RMA" + ], + [ + "UTHSC_SPL_RMA_1010", + "UTHSC Affy MoGene 1.0 ST Spleen (Oct10) RMA" + ], + [ + "IoP_SPL_RMA_0509", + "IoP Affy MOE 430v2 Spleen (May09) RMA" + ], + [ + "Illum_BXD_Spl_1108", + "UWA Illumina Spleen (Nov08) RSN **" + ], + [ + "UTK_BXDSpl_VST_0110", + "UTK Spleen ILM6.1 (Jan10) VST" + ], + [ + "STSPL_1107_R", + "Stuart Spleen M430v2 (Nov07) RMA" + ] + ], + "Striatum": [ + [ + "DevStriatum_ILM6.2P3RInv_1111", + "BIDMC/UTHSC Dev Striatum P3 ILMv6.2 (Nov11) RankInv **" + ], + [ + "DevStriatum_ILM6.2P14RInv_1111", + "BIDMC/UTHSC Dev Striatum P14 ILMv6.2 (Nov11) RankInv **" + ], + [ + "KIN_YSM_STR_0711", + "KIN/YSM Human STR Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ], + [ + "OHSU_HS-CC_ILMStr_0211", + "OHSU HS-CC Striatum ILM6v1 (Feb11) RankInv" + ], + [ + "UTHSC_Striatum_RankInv_1210", + "HQF BXD Striatum ILM6.1 (Dec10v2) RankInv" + ], + [ + "UTHSC_Str_RankInv_1210", + "HQF BXD Striatum ILM6.1 (Dec10) RankInv" + ], + [ + "UTHSC_1107_RankInv", + "HQF BXD Striatum ILM6.1 (Nov07) RankInv" + ], + [ + "SA_M2_0905_P", + "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) PDNN" + ], + [ + "SA_M2_0905_M", + "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) MAS5" + ], + [ + "SA_M2_0905_R", + "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) RMA" + ], + [ + "SA_M2_0405_MC", + "HBP Rosen Striatum M430V2 (Apr05) MAS5 Clean" + ], + [ + "SA_M2_0405_RC", + "HBP Rosen Striatum M430V2 (Apr05) RMA Clean" + ], + [ + "SA_M2_0405_PC", + "HBP Rosen Striatum M430V2 (Apr05) PDNN Clean" + ], + [ + "SA_M2_0405_SS", + "HBP Rosen Striatum M430V2 (Apr05) SScore" + ], + [ + "SA_M2_0405_RR", + "HBP Rosen Striatum M430V2 (Apr05) RMA Orig" + ], + [ + "Striatum_Exon_0209", + "HQF Striatum Exon (Feb09) RMA" + ], + [ + "DevStriatum_ILM6.2P3RInv_1110", + "BIDMC/UTHSC Dev Striatum P3 ILMv6.2 (Nov10) RankInv **" + ], + [ + "DevStriatum_ILM6.2P14RInv_1110", + "BIDMC/UTHSC Dev Striatum P14 ILMv6.2 (Nov10) RankInv **" + ] + ], + "T Cell (helper)": [ + [ + "RTHC_0211_R", + "HZI Thelp M430v2 (Feb11) RMA" + ] + ], + "T Cell (regulatory)": [ + [ + "RTC_1106_R", + "HZI Treg M430v2 (Feb11) RMA" + ] + ], + "Thymus": [ + [ + "Illum_BXD_Thy_1108", + "UWA Illumina Thymus (Nov08) RSN **" + ] + ], + "Ventral Tegmental Area": [ + [ + "VCUEtvsSal_0609_R", + "VCU BXD VTA Et vs Sal M430 2.0 (Jun09) Sscore **" + ], + [ + "VCUEtOH_0609_R", + "VCU BXD VTA EtOH M430 2.0 (Jun09) RMA **" + ], + [ + "VCUSal_0609_R", + "VCU BXD VTA Sal M430 2.0 (Jun09) RMA **" + ] + ] + }, + "BXH": { + "Cartilage": [ + [ + "UCLA_BXDBXH_CARTILAGE_V2", + "UCLA BXD and BXH Cartilage v2" + ], + [ + "UCLA_BXHBXD_CARTILAGE_V2", + "UCLA BXH and BXD Cartilage v2" + ], + [ + "UCLA_BXDBXH_CARTILAGE", + "UCLA BXD and BXH Cartilage" + ], + [ + "UCLA_BXHBXD_CARTILAGE", + "UCLA BXH and BXD Cartilage" + ], + [ + "UCLA_BXD_CARTILAGE", + "UCLA BXD Cartilage" + ], + [ + "UCLA_BXH_CARTILAGE", + "UCLA BXH Cartilage" + ] + ], + "Genotypes": [ + [ + "BXHGeno", + "BXH Genotypes" + ] + ], + "Phenotypes": [ + [ + "BXHPublish", + "BXH Published Phenotypes" + ] + ] + }, + "CTB6F2": { + "Adipose": [ + [ + "UCLA_BHF2_ADIPOSE_MALE", + "UCLA BHF2 Adipose Male mlratio" + ], + [ + "UCLA_CTB6B6CTF2_ADIPOSE_MALE", + "UCLA CTB6B6CTF2 Adipose Male mlratio **" + ], + [ + "UCLA_BHF2_ADIPOSE_FEMALE", + "UCLA BHF2 Adipose Female mlratio" + ], + [ + "UCLA_CTB6B6CTF2_ADIPOSE_FEMALE", + "UCLA CTB6B6CTF2 Adipose Female mlratio **" + ], + [ + "UCLA_BHHBF2_ADIPOSE_MALE", + "UCLA BHHBF2 Adipose Male Only" + ], + [ + "UCLA_BHHBF2_ADIPOSE_FEMALE", + "UCLA BHHBF2 Adipose Female Only" + ], + [ + "UCLA_BHHBF2_ADIPOSE_2005", + "UCLA BHHBF2 Adipose (2005) mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_ADIPOSE_2005", + "UCLA CTB6/B6CTF2 Adipose (2005) mlratio **" + ], + [ + "UCLA_BHF2_ADIPOSE_0605", + "UCLA BHF2 Adipose (June05) mlratio" + ] + ], + "Brain": [ + [ + "GSE15222_F_N_RI_0409", + "GSE15222 Human Brain Normal Myers (Apr09) RankInv" + ], + [ + "GSE15222_F_A_RI_0409", + "GSE15222 Human Brain Alzheimer Myers (Apr09) RankInv" + ], + [ + "GSE5281_F_RMA_N_0709", + "GSE5281 Human Brain Normal Full Liang (Jul09) RMA" + ], + [ + "GSE5281_F_RMA_Alzh_0709", + "GSE5281 Human Brain Alzheimer Full Liang (Jul09) RMA" + ], + [ + "INIA_MacFas_brain_RMA_0110", + "INIA Macaca fasicularis Brain (Jan10) RMA **" + ], + [ + "GSE15222_F_RI_0409", + "GSE15222 Human Brain Myers (Apr09) RankInv" + ], + [ + "GSE5281_F_RMA0709", + "GSE5281 Human Brain Full Liang (Jul09) RMA" + ], + [ + "GSE5281_RMA0709", + "GSE5281 Human Brain Best 102 Liang (Jul09) RMA" + ], + [ + "UCLA_CTB6B6CTF2_BRAIN_FEMALE", + "UCLA CTB6B6CTF2 Brain Female mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_BRAIN_MALE", + "UCLA CTB6B6CTF2 Brain Male mlratio **" + ], + [ + "UCLA_BHF2_BRAIN_MALE", + "UCLA BHF2 Brain Male mlratio" + ], + [ + "UCLA_BHF2_BRAIN_FEMALE", + "UCLA BHF2 Brain Female mlratio" + ], + [ + "UCLA_BHHBF2_BRAIN_FEMALE", + "UCLA BHHBF2 Brain Female Only" + ], + [ + "UCLA_BHHBF2_BRAIN_MALE", + "UCLA BHHBF2 Brain Male Only" + ], + [ + "UCLA_BHHBF2_BRAIN_2005", + "UCLA BHHBF2 Brain (2005) mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_BRAIN_2005", + "UCLA CTB6/B6CTF2 Brain (2005) mlratio **" + ], + [ + "UCLA_BHF2_BRAIN_0605", + "UCLA BHF2 Brain (June05) mlratio" + ], + [ + "BR_M2_1106_R", + "UCHSC BXD Whole Brain M430 2.0 (Nov06) RMA" + ], + [ + "IBR_M_0606_R", + "INIA Brain mRNA M430 (Jun06) RMA" + ], + [ + "IBR_M_0106_P", + "INIA Brain mRNA M430 (Jan06) PDNN" + ], + [ + "IBR_M_0106_R", + "INIA Brain mRNA M430 (Jan06) RMA" + ], + [ + "BR_U_1105_P", + "UTHSC Brain mRNA U74Av2 (Nov05) PDNN" + ], + [ + "BR_U_0805_M", + "UTHSC Brain mRNA U74Av2 (Aug05) MAS5" + ], + [ + "BR_U_0805_P", + "UTHSC Brain mRNA U74Av2 (Aug05) PDNN" + ], + [ + "BR_U_0805_R", + "UTHSC Brain mRNA U74Av2 (Aug05) RMA" + ], + [ + "BRF2_M_0805_R", + "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) RMA" + ], + [ + "BRF2_M_0805_P", + "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) PDNN" + ], + [ + "BRF2_M_0805_M", + "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) MAS5" + ], + [ + "BRF2_M_0304_P", + "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) PDNN" + ], + [ + "BRF2_M_0304_R", + "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) RMA" + ], + [ + "BRF2_M_0304_M", + "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) MAS5" + ], + [ + "CB_M_0204_P", + "INIA Brain mRNA M430 (Feb04) PDNN" + ] + ], + "Genotypes": [ + [ + "CTB6F2Geno", + "CTB6F2 Genotypes" + ] + ], + "Liver": [ + [ + "GSE16780_UCLA_ML0911", + "GSE16780 UCLA Hybrid MDP Liver Affy HT M430A (Sep11) RMA" + ], + [ + "JAX_CSB_L_0711", + "JAX Liver Affy M430 2.0 (Jul11) MDP" + ], + [ + "JAX_CSB_L_HF_0711", + "JAX Liver HF Affy M430 2.0 (Jul11) MDP" + ], + [ + "JAX_CSB_L_6C_0711", + "JAX Liver 6C Affy M430 2.0 (Jul11) MDP" + ], + [ + "HLC_0311", + "GSE9588 Human Liver Normal (Mar11) Both Sexes" + ], + [ + "HLCM_0311", + "GSE9588 Human Liver Normal (Mar11) Males" + ], + [ + "LV_G_0106_F", + "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Females" + ], + [ + "LV_G_0106_M", + "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Males" + ], + [ + "LV_G_0106_B", + "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Both Sexes" + ], + [ + "GenEx_BXD_liverSal_RMA_F_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Females **" + ], + [ + "GenEx_BXD_liverSal_RMA_M_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Males **" + ], + [ + "GenEx_BXD_liverSal_RMA_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" + ], + [ + "GenEx_BXD_liverEt_RMA_F_0211", + "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Females **" + ], + [ + "GenEx_BXD_liverEt_RMA_M_0211", + "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Males **" + ], + [ + "GenEx_BXD_liverEt_RMA_0211", + "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" + ], + [ + "SUH_Liv_RMA_0611", + "SUH BXD Liver Affy Mouse Gene 1.0 ST (Jun11) RMA **" + ], + [ + "OXUKHS_ILMLiver_RI0510", + "OX UK HS ILM6v1.1 Liver (May 2010) RankInv" + ], + [ + "HXB_Liver_1208", + "MDC/CAS/UCL Liver 230v2 (Dec08) RMA" + ], + [ + "UCLA_CTB6B6CTF2_LIVER_MALE", + "UCLA CTB6B6CTF2 Liver Male mlratio **" + ], + [ + "UCLA_BHF2_LIVER_MALE", + "UCLA BHF2 Liver Male mlratio" + ], + [ + "UCLA_CTB6B6CTF2_LIVER_FEMALE", + "UCLA CTB6B6CTF2 Liver Female mlratio **" + ], + [ + "UCLA_BHHBF2_LIVER_FEMALE", + "UCLA BHHBF2 Liver Female Only" + ], + [ + "UCLA_BHHBF2_LIVER_MALE", + "UCLA BHHBF2 Liver Male Only" + ], + [ + "UCLA_BHF2_LIVER_FEMALE", + "UCLA BHF2 Liver Female mlratio" + ], + [ + "UCLA_BHHBF2_LIVER_2005", + "UCLA BHHBF2 Liver (2005) mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_LIVER_2005", + "UCLA CTB6/B6CTF2 Liver (2005) mlratio **" + ], + [ + "UCLA_BHF2_LIVER_0605", + "UCLA BHF2 Liver (June05) mlratio" + ], + [ + "UCLA_BDF2_LIVER_1999", + "UCLA BDF2 Liver (1999) mlratio" + ], + [ + "LVF2_M_0704_R", + "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) RMA" + ], + [ + "LVF2_M_0704_M", + "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) MAS5" + ], + [ + "HLCF_0311", + "GSE9588 Human Liver Normal (Mar11) Females" + ] + ], + "Muscle": [ + [ + "EPFLMouseMuscleRMA1211", + "EPFL/LISP BXD Muscle Affy Mouse Gene 1.0 ST (Dec11) RMA **" + ], + [ + "EPFLMouseMuscleCDRMA1211", + "EPFL/LISP BXD CD Muscle Affy Mouse Gene 1.0 ST (Dec11) RMA **" + ], + [ + "EPFLMouseMuscleHFDRMA1211", + "EPFL/LISP BXD HFD Muscle Affy Mouse Gene 1.0 ST (Dec11) RMA **" + ], + [ + "UCLA_CTB6B6CTF2_MUSCLE_FEMALE", + "UCLA CTB6B6CTF2 Muscle Female mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_MUSCLE_MALE", + "UCLA CTB6B6CTF2 Muscle Male mlratio **" + ], + [ + "UCLA_BHHBF2_MUSCLE_FEMALE", + "UCLA BHHBF2 Muscle Female Only" + ], + [ + "UCLA_BHHBF2_MUSCLE_MALE", + "UCLA BHHBF2 Muscle Male Only" + ], + [ + "UCLA_BHF2_MUSCLE_MALE", + "UCLA BHF2 Muscle Male mlratio **" + ], + [ + "UCLA_BHF2_MUSCLE_FEMALE", + "UCLA BHF2 Muscle Female mlratio **" + ], + [ + "UCLA_BHHBF2_MUSCLE_2005", + "UCLA BHHBF2 Muscle (2005) mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_MUSCLE_2005", + "UCLA CTB6/B6CTF2 Muscle (2005) mlratio **" + ], + [ + "UCLA_BHF2_MUSCLE_0605", + "UCLA BHF2 Muscle (June05) mlratio **" + ] + ], + "Phenotypes": [ + [ + "CTB6F2Publish", + "CTB6F2 Published Phenotypes" + ] + ] + }, + "CXB": { + "Genotypes": [ + [ + "CXBGeno", + "CXB Genotypes" + ] + ], + "Hippocampus": [ + [ + "KIN_YSM_HIP_0711", + "KIN/YSM Human HIP Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ], + [ + "UMUTAffyExon_0209_RMA_MDP", + "UMUTAffy Hippocampus Exon (Feb09) RMA MDP" + ], + [ + "HC_M2_0606_MDP", + "Hippocampus Consortium M430v2 (Jun06) RMA MDP" + ], + [ + "OXUKHS_ILMHipp_RI0510", + "OX UK HS ILM6v1.1 Hippocampus (May 2010) RankInv" + ], + [ + "INIA_MacFas_Hc_RMA_0110", + "INIA Macaca fasicularis Hippocampus control (Jan10) RMA **" + ], + [ + "INIA_MacFas_He_RMA_0110", + "INIA Macaca fasicularis Hippocampus ethanol (Jan10) RMA **" + ], + [ + "UT_HippRatEx_RMA_0709", + "UT Hippocampus Affy RaEx 1.0 Exon (Jul09) RMA" + ], + [ + "Illum_LXS_Hipp_loess0807", + "Hippocampus Illumina (Aug07) LOESS" + ], + [ + "Illum_LXS_Hipp_loess_nb0807", + "Hippocampus Illumina (Aug07) LOESS_NB" + ], + [ + "Illum_LXS_Hipp_quant0807", + "Hippocampus Illumina (Aug07) QUANT" + ], + [ + "Illum_LXS_Hipp_quant_nb0807", + "Hippocampus Illumina (Aug07) QUANT_NB" + ], + [ + "Illum_LXS_Hipp_rsn0807", + "Hippocampus Illumina (Aug07) RSN" + ], + [ + "Illum_LXS_Hipp_rsn_nb0807", + "Hippocampus Illumina (Aug07) RSN_NB" + ], + [ + "Hipp_Illumina_RankInv_0507", + "Hippocampus Illumina (May07) RankInv" + ], + [ + "HC_M2_0606_P", + "Hippocampus Consortium M430v2 (Jun06) PDNN" + ], + [ + "HC_M2_0606_M", + "Hippocampus Consortium M430v2 (Jun06) MAS5" + ], + [ + "HC_M2_0606_R", + "Hippocampus Consortium M430v2 (Jun06) RMA" + ], + [ + "HC_M2CB_1205_R", + "Hippocampus Consortium M430v2 CXB (Dec05) RMA" + ], + [ + "HC_M2CB_1205_P", + "Hippocampus Consortium M430v2 CXB (Dec05) PDNN" + ], + [ + "UMUTAffyExon_0209_RMA", + "UMUTAffy Hippocampus Exon (Feb09) RMA" + ], + [ + "UT_ILM_BXD_hipp_NON_0909", + "UTHSC Hippocampus Illumina v6.1 NON (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_NOS_0909", + "UTHSC Hippocampus Illumina v6.1 NOS (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_NOE_0909", + "UTHSC Hippocampus Illumina v6.1 NOE (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_RSS_0909", + "UTHSC Hippocampus Illumina v6.1 RSS (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_RSE_0909", + "UTHSC Hippocampus Illumina v6.1 RSE (Sep09) RankInv" + ], + [ + "Illum_LXS_Hipp_RSE_1008", + "Hippocampus Illumina RSE (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_NOS_1008", + "Hippocampus Illumina NOS (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_NOE_1008", + "Hippocampus Illumina NOE (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_RSS_1008", + "Hippocampus Illumina RSS (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_NON_1008", + "Hippocampus Illumina NON (Oct08) RankInv beta" + ] + ], + "Phenotypes": [ + [ + "CXBPublish", + "CXB Published Phenotypes" + ] + ], + "Spleen": [ + [ + "UTHSC_SPL_RMA_1210", + "UTHSC Affy MoGene 1.0 ST Spleen (Dec10) RMA" + ], + [ + "UTHSC_SPL_RMA_1010", + "UTHSC Affy MoGene 1.0 ST Spleen (Oct10) RMA" + ], + [ + "IoP_SPL_RMA_0509", + "IoP Affy MOE 430v2 Spleen (May09) RMA" + ], + [ + "Illum_BXD_Spl_1108", + "UWA Illumina Spleen (Nov08) RSN **" + ], + [ + "UTK_BXDSpl_VST_0110", + "UTK Spleen ILM6.1 (Jan10) VST" + ], + [ + "STSPL_1107_R", + "Stuart Spleen M430v2 (Nov07) RMA" + ] + ] + }, + "HS": { + "Genotypes": [ + [ + "HSGeno", + "HS Genotypes" + ] + ], + "Hippocampus": [ + [ + "KIN_YSM_HIP_0711", + "KIN/YSM Human HIP Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ], + [ + "UMUTAffyExon_0209_RMA_MDP", + "UMUTAffy Hippocampus Exon (Feb09) RMA MDP" + ], + [ + "HC_M2_0606_MDP", + "Hippocampus Consortium M430v2 (Jun06) RMA MDP" + ], + [ + "OXUKHS_ILMHipp_RI0510", + "OX UK HS ILM6v1.1 Hippocampus (May 2010) RankInv" + ], + [ + "INIA_MacFas_Hc_RMA_0110", + "INIA Macaca fasicularis Hippocampus control (Jan10) RMA **" + ], + [ + "INIA_MacFas_He_RMA_0110", + "INIA Macaca fasicularis Hippocampus ethanol (Jan10) RMA **" + ], + [ + "UT_HippRatEx_RMA_0709", + "UT Hippocampus Affy RaEx 1.0 Exon (Jul09) RMA" + ], + [ + "Illum_LXS_Hipp_loess0807", + "Hippocampus Illumina (Aug07) LOESS" + ], + [ + "Illum_LXS_Hipp_loess_nb0807", + "Hippocampus Illumina (Aug07) LOESS_NB" + ], + [ + "Illum_LXS_Hipp_quant0807", + "Hippocampus Illumina (Aug07) QUANT" + ], + [ + "Illum_LXS_Hipp_quant_nb0807", + "Hippocampus Illumina (Aug07) QUANT_NB" + ], + [ + "Illum_LXS_Hipp_rsn0807", + "Hippocampus Illumina (Aug07) RSN" + ], + [ + "Illum_LXS_Hipp_rsn_nb0807", + "Hippocampus Illumina (Aug07) RSN_NB" + ], + [ + "Hipp_Illumina_RankInv_0507", + "Hippocampus Illumina (May07) RankInv" + ], + [ + "HC_M2_0606_P", + "Hippocampus Consortium M430v2 (Jun06) PDNN" + ], + [ + "HC_M2_0606_M", + "Hippocampus Consortium M430v2 (Jun06) MAS5" + ], + [ + "HC_M2_0606_R", + "Hippocampus Consortium M430v2 (Jun06) RMA" + ], + [ + "HC_M2CB_1205_R", + "Hippocampus Consortium M430v2 CXB (Dec05) RMA" + ], + [ + "HC_M2CB_1205_P", + "Hippocampus Consortium M430v2 CXB (Dec05) PDNN" + ], + [ + "UMUTAffyExon_0209_RMA", + "UMUTAffy Hippocampus Exon (Feb09) RMA" + ], + [ + "UT_ILM_BXD_hipp_NON_0909", + "UTHSC Hippocampus Illumina v6.1 NON (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_NOS_0909", + "UTHSC Hippocampus Illumina v6.1 NOS (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_NOE_0909", + "UTHSC Hippocampus Illumina v6.1 NOE (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_RSS_0909", + "UTHSC Hippocampus Illumina v6.1 RSS (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_RSE_0909", + "UTHSC Hippocampus Illumina v6.1 RSE (Sep09) RankInv" + ], + [ + "Illum_LXS_Hipp_RSE_1008", + "Hippocampus Illumina RSE (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_NOS_1008", + "Hippocampus Illumina NOS (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_NOE_1008", + "Hippocampus Illumina NOE (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_RSS_1008", + "Hippocampus Illumina RSS (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_NON_1008", + "Hippocampus Illumina NON (Oct08) RankInv beta" + ] + ], + "Liver": [ + [ + "GSE16780_UCLA_ML0911", + "GSE16780 UCLA Hybrid MDP Liver Affy HT M430A (Sep11) RMA" + ], + [ + "JAX_CSB_L_0711", + "JAX Liver Affy M430 2.0 (Jul11) MDP" + ], + [ + "JAX_CSB_L_HF_0711", + "JAX Liver HF Affy M430 2.0 (Jul11) MDP" + ], + [ + "JAX_CSB_L_6C_0711", + "JAX Liver 6C Affy M430 2.0 (Jul11) MDP" + ], + [ + "HLC_0311", + "GSE9588 Human Liver Normal (Mar11) Both Sexes" + ], + [ + "HLCM_0311", + "GSE9588 Human Liver Normal (Mar11) Males" + ], + [ + "LV_G_0106_F", + "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Females" + ], + [ + "LV_G_0106_M", + "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Males" + ], + [ + "LV_G_0106_B", + "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Both Sexes" + ], + [ + "GenEx_BXD_liverSal_RMA_F_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Females **" + ], + [ + "GenEx_BXD_liverSal_RMA_M_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Males **" + ], + [ + "GenEx_BXD_liverSal_RMA_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" + ], + [ + "GenEx_BXD_liverEt_RMA_F_0211", + "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Females **" + ], + [ + "GenEx_BXD_liverEt_RMA_M_0211", + "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Males **" + ], + [ + "GenEx_BXD_liverEt_RMA_0211", + "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" + ], + [ + "SUH_Liv_RMA_0611", + "SUH BXD Liver Affy Mouse Gene 1.0 ST (Jun11) RMA **" + ], + [ + "OXUKHS_ILMLiver_RI0510", + "OX UK HS ILM6v1.1 Liver (May 2010) RankInv" + ], + [ + "HXB_Liver_1208", + "MDC/CAS/UCL Liver 230v2 (Dec08) RMA" + ], + [ + "UCLA_CTB6B6CTF2_LIVER_MALE", + "UCLA CTB6B6CTF2 Liver Male mlratio **" + ], + [ + "UCLA_BHF2_LIVER_MALE", + "UCLA BHF2 Liver Male mlratio" + ], + [ + "UCLA_CTB6B6CTF2_LIVER_FEMALE", + "UCLA CTB6B6CTF2 Liver Female mlratio **" + ], + [ + "UCLA_BHHBF2_LIVER_FEMALE", + "UCLA BHHBF2 Liver Female Only" + ], + [ + "UCLA_BHHBF2_LIVER_MALE", + "UCLA BHHBF2 Liver Male Only" + ], + [ + "UCLA_BHF2_LIVER_FEMALE", + "UCLA BHF2 Liver Female mlratio" + ], + [ + "UCLA_BHHBF2_LIVER_2005", + "UCLA BHHBF2 Liver (2005) mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_LIVER_2005", + "UCLA CTB6/B6CTF2 Liver (2005) mlratio **" + ], + [ + "UCLA_BHF2_LIVER_0605", + "UCLA BHF2 Liver (June05) mlratio" + ], + [ + "UCLA_BDF2_LIVER_1999", + "UCLA BDF2 Liver (1999) mlratio" + ], + [ + "LVF2_M_0704_R", + "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) RMA" + ], + [ + "LVF2_M_0704_M", + "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) MAS5" + ], + [ + "HLCF_0311", + "GSE9588 Human Liver Normal (Mar11) Females" + ] + ], + "Lung": [ + [ + "OXUKHS_ILMLung_RI0510", + "OX UK HS ILM6v1.1 Lung (May 2010) RankInv" + ], + [ + "HZI_0408_R", + "HZI Lung M430v2 (Apr08) RMA" + ], + [ + "HZI_0408_M", + "HZI Lung M430v2 (Apr08) MAS5" + ] + ], + "Phenotypes": [ + [ + "HSPublish", + "HS Published Phenotypes" + ] + ] + }, + "HS-CC": { + "Genotypes": [ + [ + "HS-CCGeno", + "HS-CC Genotypes" + ] + ], + "Phenotypes": [ + [ + "HS-CCPublish", + "HS-CC Published Phenotypes" + ] + ], + "Striatum": [ + [ + "DevStriatum_ILM6.2P3RInv_1111", + "BIDMC/UTHSC Dev Striatum P3 ILMv6.2 (Nov11) RankInv **" + ], + [ + "DevStriatum_ILM6.2P14RInv_1111", + "BIDMC/UTHSC Dev Striatum P14 ILMv6.2 (Nov11) RankInv **" + ], + [ + "KIN_YSM_STR_0711", + "KIN/YSM Human STR Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ], + [ + "OHSU_HS-CC_ILMStr_0211", + "OHSU HS-CC Striatum ILM6v1 (Feb11) RankInv" + ], + [ + "UTHSC_Striatum_RankInv_1210", + "HQF BXD Striatum ILM6.1 (Dec10v2) RankInv" + ], + [ + "UTHSC_Str_RankInv_1210", + "HQF BXD Striatum ILM6.1 (Dec10) RankInv" + ], + [ + "UTHSC_1107_RankInv", + "HQF BXD Striatum ILM6.1 (Nov07) RankInv" + ], + [ + "SA_M2_0905_P", + "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) PDNN" + ], + [ + "SA_M2_0905_M", + "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) MAS5" + ], + [ + "SA_M2_0905_R", + "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) RMA" + ], + [ + "SA_M2_0405_MC", + "HBP Rosen Striatum M430V2 (Apr05) MAS5 Clean" + ], + [ + "SA_M2_0405_RC", + "HBP Rosen Striatum M430V2 (Apr05) RMA Clean" + ], + [ + "SA_M2_0405_PC", + "HBP Rosen Striatum M430V2 (Apr05) PDNN Clean" + ], + [ + "SA_M2_0405_SS", + "HBP Rosen Striatum M430V2 (Apr05) SScore" + ], + [ + "SA_M2_0405_RR", + "HBP Rosen Striatum M430V2 (Apr05) RMA Orig" + ], + [ + "Striatum_Exon_0209", + "HQF Striatum Exon (Feb09) RMA" + ], + [ + "DevStriatum_ILM6.2P3RInv_1110", + "BIDMC/UTHSC Dev Striatum P3 ILMv6.2 (Nov10) RankInv **" + ], + [ + "DevStriatum_ILM6.2P14RInv_1110", + "BIDMC/UTHSC Dev Striatum P14 ILMv6.2 (Nov10) RankInv **" + ] + ] + }, + "LXS": { + "Genotypes": [ + [ + "LXSGeno", + "LXS Genotypes" + ] + ], + "Hippocampus": [ + [ + "KIN_YSM_HIP_0711", + "KIN/YSM Human HIP Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ], + [ + "UMUTAffyExon_0209_RMA_MDP", + "UMUTAffy Hippocampus Exon (Feb09) RMA MDP" + ], + [ + "HC_M2_0606_MDP", + "Hippocampus Consortium M430v2 (Jun06) RMA MDP" + ], + [ + "OXUKHS_ILMHipp_RI0510", + "OX UK HS ILM6v1.1 Hippocampus (May 2010) RankInv" + ], + [ + "INIA_MacFas_Hc_RMA_0110", + "INIA Macaca fasicularis Hippocampus control (Jan10) RMA **" + ], + [ + "INIA_MacFas_He_RMA_0110", + "INIA Macaca fasicularis Hippocampus ethanol (Jan10) RMA **" + ], + [ + "UT_HippRatEx_RMA_0709", + "UT Hippocampus Affy RaEx 1.0 Exon (Jul09) RMA" + ], + [ + "Illum_LXS_Hipp_loess0807", + "Hippocampus Illumina (Aug07) LOESS" + ], + [ + "Illum_LXS_Hipp_loess_nb0807", + "Hippocampus Illumina (Aug07) LOESS_NB" + ], + [ + "Illum_LXS_Hipp_quant0807", + "Hippocampus Illumina (Aug07) QUANT" + ], + [ + "Illum_LXS_Hipp_quant_nb0807", + "Hippocampus Illumina (Aug07) QUANT_NB" + ], + [ + "Illum_LXS_Hipp_rsn0807", + "Hippocampus Illumina (Aug07) RSN" + ], + [ + "Illum_LXS_Hipp_rsn_nb0807", + "Hippocampus Illumina (Aug07) RSN_NB" + ], + [ + "Hipp_Illumina_RankInv_0507", + "Hippocampus Illumina (May07) RankInv" + ], + [ + "HC_M2_0606_P", + "Hippocampus Consortium M430v2 (Jun06) PDNN" + ], + [ + "HC_M2_0606_M", + "Hippocampus Consortium M430v2 (Jun06) MAS5" + ], + [ + "HC_M2_0606_R", + "Hippocampus Consortium M430v2 (Jun06) RMA" + ], + [ + "HC_M2CB_1205_R", + "Hippocampus Consortium M430v2 CXB (Dec05) RMA" + ], + [ + "HC_M2CB_1205_P", + "Hippocampus Consortium M430v2 CXB (Dec05) PDNN" + ], + [ + "UMUTAffyExon_0209_RMA", + "UMUTAffy Hippocampus Exon (Feb09) RMA" + ], + [ + "UT_ILM_BXD_hipp_NON_0909", + "UTHSC Hippocampus Illumina v6.1 NON (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_NOS_0909", + "UTHSC Hippocampus Illumina v6.1 NOS (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_NOE_0909", + "UTHSC Hippocampus Illumina v6.1 NOE (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_RSS_0909", + "UTHSC Hippocampus Illumina v6.1 RSS (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_RSE_0909", + "UTHSC Hippocampus Illumina v6.1 RSE (Sep09) RankInv" + ], + [ + "Illum_LXS_Hipp_RSE_1008", + "Hippocampus Illumina RSE (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_NOS_1008", + "Hippocampus Illumina NOS (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_NOE_1008", + "Hippocampus Illumina NOE (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_RSS_1008", + "Hippocampus Illumina RSS (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_NON_1008", + "Hippocampus Illumina NON (Oct08) RankInv beta" + ] + ], + "Phenotypes": [ + [ + "LXSPublish", + "LXS Published Phenotypes" + ] + ], + "Prefrontal Cortex": [ + [ + "HBTRC-MLPFC_0611", + "HBTRC-MLC Human Prefrontal Cortex Agilent (Jun11) mlratio" + ], + [ + "HBTRC-MLPFC_N_0611", + "HBTRC-MLC Human Prefrontal Cortex Agilent Normal (Jun11) mlratio" + ], + [ + "HBTRC-MLPFC_AD_0611", + "HBTRC-MLC Human Prefrontal Cortex Agilent AD (Jun11) mlratio" + ], + [ + "HBTRC-MLPFC_HD_0611", + "HBTRC-MLC Human Prefrontal Cortex Agilent HD (Jun11) mlratio" + ], + [ + "INIA_MacFas_Pf_RMA_0110", + "INIA Macaca fasicularis Prefrontal Cortex control (Jan10) RMA **" + ], + [ + "INIA_MacFas_PfE_RMA_0110", + "INIA Macaca fasicularis Prefrontal Cortex ethanol (Jan10) RMA **" + ], + [ + "VCUSal_1006_R", + "VCU BXD PFC Et vs Sal M430 2.0 (Dec06) Sscore" + ], + [ + "VCUEtOH_1206_R", + "VCU BXD PFC EtOH M430 2.0 (Dec06) RMA" + ], + [ + "VCUSal_1206_R", + "VCU BXD PFC Sal M430 2.0 (Dec06) RMA" + ], + [ + "VCU_PF_Air_0111_R", + "VCU BXD PFC CIE Air M430 2.0 (Jan11) RMA **" + ], + [ + "VCU_PF_Et_0111_R", + "VCU BXD PFC CIE EtOH M430 2.0 (Jan11) RMA **" + ], + [ + "VCU_PF_AvE_0111_Ss", + "VCU BXD PFC EtOH vs CIE Air M430 2.0 (Jan11) Sscore **" + ], + [ + "VCUEt_vs_Sal_0806_R", + "VCU LXS PFC Et vs Sal M430A 2.0 (Aug06) Sscore **" + ], + [ + "VCUEtOH_0806_R", + "VCU LXS PFC EtOH M430A 2.0 (Aug06) RMA **" + ], + [ + "VCUSal_0806_R", + "VCU LXS PFC Sal M430A 2.0 (Aug06) RMA" + ] + ] + }, + "MDP": { + "Genotypes": [ + [ + "MDPGeno", + "MDP Genotypes" + ] + ], + "Hippocampus": [ + [ + "KIN_YSM_HIP_0711", + "KIN/YSM Human HIP Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ], + [ + "UMUTAffyExon_0209_RMA_MDP", + "UMUTAffy Hippocampus Exon (Feb09) RMA MDP" + ], + [ + "HC_M2_0606_MDP", + "Hippocampus Consortium M430v2 (Jun06) RMA MDP" + ], + [ + "OXUKHS_ILMHipp_RI0510", + "OX UK HS ILM6v1.1 Hippocampus (May 2010) RankInv" + ], + [ + "INIA_MacFas_Hc_RMA_0110", + "INIA Macaca fasicularis Hippocampus control (Jan10) RMA **" + ], + [ + "INIA_MacFas_He_RMA_0110", + "INIA Macaca fasicularis Hippocampus ethanol (Jan10) RMA **" + ], + [ + "UT_HippRatEx_RMA_0709", + "UT Hippocampus Affy RaEx 1.0 Exon (Jul09) RMA" + ], + [ + "Illum_LXS_Hipp_loess0807", + "Hippocampus Illumina (Aug07) LOESS" + ], + [ + "Illum_LXS_Hipp_loess_nb0807", + "Hippocampus Illumina (Aug07) LOESS_NB" + ], + [ + "Illum_LXS_Hipp_quant0807", + "Hippocampus Illumina (Aug07) QUANT" + ], + [ + "Illum_LXS_Hipp_quant_nb0807", + "Hippocampus Illumina (Aug07) QUANT_NB" + ], + [ + "Illum_LXS_Hipp_rsn0807", + "Hippocampus Illumina (Aug07) RSN" + ], + [ + "Illum_LXS_Hipp_rsn_nb0807", + "Hippocampus Illumina (Aug07) RSN_NB" + ], + [ + "Hipp_Illumina_RankInv_0507", + "Hippocampus Illumina (May07) RankInv" + ], + [ + "HC_M2_0606_P", + "Hippocampus Consortium M430v2 (Jun06) PDNN" + ], + [ + "HC_M2_0606_M", + "Hippocampus Consortium M430v2 (Jun06) MAS5" + ], + [ + "HC_M2_0606_R", + "Hippocampus Consortium M430v2 (Jun06) RMA" + ], + [ + "HC_M2CB_1205_R", + "Hippocampus Consortium M430v2 CXB (Dec05) RMA" + ], + [ + "HC_M2CB_1205_P", + "Hippocampus Consortium M430v2 CXB (Dec05) PDNN" + ], + [ + "UMUTAffyExon_0209_RMA", + "UMUTAffy Hippocampus Exon (Feb09) RMA" + ], + [ + "UT_ILM_BXD_hipp_NON_0909", + "UTHSC Hippocampus Illumina v6.1 NON (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_NOS_0909", + "UTHSC Hippocampus Illumina v6.1 NOS (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_NOE_0909", + "UTHSC Hippocampus Illumina v6.1 NOE (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_RSS_0909", + "UTHSC Hippocampus Illumina v6.1 RSS (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_RSE_0909", + "UTHSC Hippocampus Illumina v6.1 RSE (Sep09) RankInv" + ], + [ + "Illum_LXS_Hipp_RSE_1008", + "Hippocampus Illumina RSE (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_NOS_1008", + "Hippocampus Illumina NOS (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_NOE_1008", + "Hippocampus Illumina NOE (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_RSS_1008", + "Hippocampus Illumina RSS (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_NON_1008", + "Hippocampus Illumina NON (Oct08) RankInv beta" + ] + ], + "Liver": [ + [ + "GSE16780_UCLA_ML0911", + "GSE16780 UCLA Hybrid MDP Liver Affy HT M430A (Sep11) RMA" + ], + [ + "JAX_CSB_L_0711", + "JAX Liver Affy M430 2.0 (Jul11) MDP" + ], + [ + "JAX_CSB_L_HF_0711", + "JAX Liver HF Affy M430 2.0 (Jul11) MDP" + ], + [ + "JAX_CSB_L_6C_0711", + "JAX Liver 6C Affy M430 2.0 (Jul11) MDP" + ], + [ + "HLC_0311", + "GSE9588 Human Liver Normal (Mar11) Both Sexes" + ], + [ + "HLCM_0311", + "GSE9588 Human Liver Normal (Mar11) Males" + ], + [ + "LV_G_0106_F", + "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Females" + ], + [ + "LV_G_0106_M", + "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Males" + ], + [ + "LV_G_0106_B", + "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Both Sexes" + ], + [ + "GenEx_BXD_liverSal_RMA_F_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Females **" + ], + [ + "GenEx_BXD_liverSal_RMA_M_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Males **" + ], + [ + "GenEx_BXD_liverSal_RMA_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" + ], + [ + "GenEx_BXD_liverEt_RMA_F_0211", + "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Females **" + ], + [ + "GenEx_BXD_liverEt_RMA_M_0211", + "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Males **" + ], + [ + "GenEx_BXD_liverEt_RMA_0211", + "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" + ], + [ + "SUH_Liv_RMA_0611", + "SUH BXD Liver Affy Mouse Gene 1.0 ST (Jun11) RMA **" + ], + [ + "OXUKHS_ILMLiver_RI0510", + "OX UK HS ILM6v1.1 Liver (May 2010) RankInv" + ], + [ + "HXB_Liver_1208", + "MDC/CAS/UCL Liver 230v2 (Dec08) RMA" + ], + [ + "UCLA_CTB6B6CTF2_LIVER_MALE", + "UCLA CTB6B6CTF2 Liver Male mlratio **" + ], + [ + "UCLA_BHF2_LIVER_MALE", + "UCLA BHF2 Liver Male mlratio" + ], + [ + "UCLA_CTB6B6CTF2_LIVER_FEMALE", + "UCLA CTB6B6CTF2 Liver Female mlratio **" + ], + [ + "UCLA_BHHBF2_LIVER_FEMALE", + "UCLA BHHBF2 Liver Female Only" + ], + [ + "UCLA_BHHBF2_LIVER_MALE", + "UCLA BHHBF2 Liver Male Only" + ], + [ + "UCLA_BHF2_LIVER_FEMALE", + "UCLA BHF2 Liver Female mlratio" + ], + [ + "UCLA_BHHBF2_LIVER_2005", + "UCLA BHHBF2 Liver (2005) mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_LIVER_2005", + "UCLA CTB6/B6CTF2 Liver (2005) mlratio **" + ], + [ + "UCLA_BHF2_LIVER_0605", + "UCLA BHF2 Liver (June05) mlratio" + ], + [ + "UCLA_BDF2_LIVER_1999", + "UCLA BDF2 Liver (1999) mlratio" + ], + [ + "LVF2_M_0704_R", + "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) RMA" + ], + [ + "LVF2_M_0704_M", + "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) MAS5" + ], + [ + "HLCF_0311", + "GSE9588 Human Liver Normal (Mar11) Females" + ] + ], + "Phenotypes": [ + [ + "MDPPublish", + "Mouse Phenome Database" + ] + ] + }, + "NZBXFVB-N2": { + "Genotypes": [ + [ + "NZBXFVB-N2Geno", + "NZBXFVB-N2 Genotypes" + ] + ], + "Mammary Tumors": [ + [ + "NCI_Mam_Tum_RMA_0409", + "NCI Mammary M430v2 (Apr09) RMA" + ], + [ + "NCI_Agil_Mam_Tum_RMA_0409", + "NCI Mammary LMT miRNA v2 (Apr09) RMA" + ], + [ + "MA_M_0704_R", + "NCI Mammary mRNA M430 (July04) RMA" + ], + [ + "MA_M_0704_M", + "NCI Mammary mRNA M430 (July04) MAS5" + ] + ], + "Phenotypes": [ + [ + "NZBXFVB-N2Publish", + "NZBXFVB-N2 Published Phenotypes" + ] + ] + } + }, + "rat": { + "HXBBXH": { + "Adrenal Gland": [ + [ + "HXB_Adrenal_1208", + "MDC/CAS/UCL Adrenal 230A (Dec08) RMA" + ] + ], + "Genotypes": [ + [ + "HXBBXHGeno", + "HXBBXH Genotypes" + ] + ], + "Heart": [ + [ + "HXB_Heart_1208", + "MDC/CAS/UCL Heart 230_V2 (Dec08) RMA" + ] + ], + "Hippocampus": [ + [ + "KIN_YSM_HIP_0711", + "KIN/YSM Human HIP Affy Hu-Exon 1.0 ST (Jul11) Quantile **" + ], + [ + "UMUTAffyExon_0209_RMA_MDP", + "UMUTAffy Hippocampus Exon (Feb09) RMA MDP" + ], + [ + "HC_M2_0606_MDP", + "Hippocampus Consortium M430v2 (Jun06) RMA MDP" + ], + [ + "OXUKHS_ILMHipp_RI0510", + "OX UK HS ILM6v1.1 Hippocampus (May 2010) RankInv" + ], + [ + "INIA_MacFas_Hc_RMA_0110", + "INIA Macaca fasicularis Hippocampus control (Jan10) RMA **" + ], + [ + "INIA_MacFas_He_RMA_0110", + "INIA Macaca fasicularis Hippocampus ethanol (Jan10) RMA **" + ], + [ + "UT_HippRatEx_RMA_0709", + "UT Hippocampus Affy RaEx 1.0 Exon (Jul09) RMA" + ], + [ + "Illum_LXS_Hipp_loess0807", + "Hippocampus Illumina (Aug07) LOESS" + ], + [ + "Illum_LXS_Hipp_loess_nb0807", + "Hippocampus Illumina (Aug07) LOESS_NB" + ], + [ + "Illum_LXS_Hipp_quant0807", + "Hippocampus Illumina (Aug07) QUANT" + ], + [ + "Illum_LXS_Hipp_quant_nb0807", + "Hippocampus Illumina (Aug07) QUANT_NB" + ], + [ + "Illum_LXS_Hipp_rsn0807", + "Hippocampus Illumina (Aug07) RSN" + ], + [ + "Illum_LXS_Hipp_rsn_nb0807", + "Hippocampus Illumina (Aug07) RSN_NB" + ], + [ + "Hipp_Illumina_RankInv_0507", + "Hippocampus Illumina (May07) RankInv" + ], + [ + "HC_M2_0606_P", + "Hippocampus Consortium M430v2 (Jun06) PDNN" + ], + [ + "HC_M2_0606_M", + "Hippocampus Consortium M430v2 (Jun06) MAS5" + ], + [ + "HC_M2_0606_R", + "Hippocampus Consortium M430v2 (Jun06) RMA" + ], + [ + "HC_M2CB_1205_R", + "Hippocampus Consortium M430v2 CXB (Dec05) RMA" + ], + [ + "HC_M2CB_1205_P", + "Hippocampus Consortium M430v2 CXB (Dec05) PDNN" + ], + [ + "UMUTAffyExon_0209_RMA", + "UMUTAffy Hippocampus Exon (Feb09) RMA" + ], + [ + "UT_ILM_BXD_hipp_NON_0909", + "UTHSC Hippocampus Illumina v6.1 NON (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_NOS_0909", + "UTHSC Hippocampus Illumina v6.1 NOS (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_NOE_0909", + "UTHSC Hippocampus Illumina v6.1 NOE (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_RSS_0909", + "UTHSC Hippocampus Illumina v6.1 RSS (Sep09) RankInv" + ], + [ + "UT_ILM_BXD_hipp_RSE_0909", + "UTHSC Hippocampus Illumina v6.1 RSE (Sep09) RankInv" + ], + [ + "Illum_LXS_Hipp_RSE_1008", + "Hippocampus Illumina RSE (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_NOS_1008", + "Hippocampus Illumina NOS (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_NOE_1008", + "Hippocampus Illumina NOE (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_RSS_1008", + "Hippocampus Illumina RSS (Oct08) RankInv beta" + ], + [ + "Illum_LXS_Hipp_NON_1008", + "Hippocampus Illumina NON (Oct08) RankInv beta" + ] + ], + "Kidney": [ + [ + "MA_M2F_0706_R", + "Mouse kidney M430v2 Female (Aug06) RMA" + ], + [ + "MA_M2M_0706_R", + "Mouse kidney M430v2 Male (Aug06) RMA" + ], + [ + "MA_M2_0806_R", + "Mouse kidney M430v2 Sex Balanced (Aug06) RMA" + ], + [ + "MA_M2_0806_P", + "Mouse Kidney M430v2 Sex Balanced (Aug06) PDNN" + ], + [ + "MA_M2_0706_P", + "Mouse Kidney M430v2 (Jul06) PDNN" + ], + [ + "MA_M2_0706_R", + "Mouse Kidney M430v2 (Jul06) RMA" + ], + [ + "KI_2A_0405_M", + "MDC/CAS/ICL Kidney 230A (Apr05) MAS5" + ], + [ + "KI_2A_0405_Rz", + "MDC/CAS/ICL Kidney 230A (Apr05) RMA 2z+8" + ], + [ + "KI_2A_0405_R", + "MDC/CAS/ICL Kidney 230A (Apr05) RMA" + ] + ], + "Liver": [ + [ + "GSE16780_UCLA_ML0911", + "GSE16780 UCLA Hybrid MDP Liver Affy HT M430A (Sep11) RMA" + ], + [ + "JAX_CSB_L_0711", + "JAX Liver Affy M430 2.0 (Jul11) MDP" + ], + [ + "JAX_CSB_L_HF_0711", + "JAX Liver HF Affy M430 2.0 (Jul11) MDP" + ], + [ + "JAX_CSB_L_6C_0711", + "JAX Liver 6C Affy M430 2.0 (Jul11) MDP" + ], + [ + "HLC_0311", + "GSE9588 Human Liver Normal (Mar11) Both Sexes" + ], + [ + "HLCM_0311", + "GSE9588 Human Liver Normal (Mar11) Males" + ], + [ + "LV_G_0106_F", + "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Females" + ], + [ + "LV_G_0106_M", + "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Males" + ], + [ + "LV_G_0106_B", + "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Both Sexes" + ], + [ + "GenEx_BXD_liverSal_RMA_F_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Females **" + ], + [ + "GenEx_BXD_liverSal_RMA_M_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Males **" + ], + [ + "GenEx_BXD_liverSal_RMA_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" + ], + [ + "GenEx_BXD_liverEt_RMA_F_0211", + "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Females **" + ], + [ + "GenEx_BXD_liverEt_RMA_M_0211", + "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Males **" + ], + [ + "GenEx_BXD_liverEt_RMA_0211", + "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" + ], + [ + "SUH_Liv_RMA_0611", + "SUH BXD Liver Affy Mouse Gene 1.0 ST (Jun11) RMA **" + ], + [ + "OXUKHS_ILMLiver_RI0510", + "OX UK HS ILM6v1.1 Liver (May 2010) RankInv" + ], + [ + "HXB_Liver_1208", + "MDC/CAS/UCL Liver 230v2 (Dec08) RMA" + ], + [ + "UCLA_CTB6B6CTF2_LIVER_MALE", + "UCLA CTB6B6CTF2 Liver Male mlratio **" + ], + [ + "UCLA_BHF2_LIVER_MALE", + "UCLA BHF2 Liver Male mlratio" + ], + [ + "UCLA_CTB6B6CTF2_LIVER_FEMALE", + "UCLA CTB6B6CTF2 Liver Female mlratio **" + ], + [ + "UCLA_BHHBF2_LIVER_FEMALE", + "UCLA BHHBF2 Liver Female Only" + ], + [ + "UCLA_BHHBF2_LIVER_MALE", + "UCLA BHHBF2 Liver Male Only" + ], + [ + "UCLA_BHF2_LIVER_FEMALE", + "UCLA BHF2 Liver Female mlratio" + ], + [ + "UCLA_BHHBF2_LIVER_2005", + "UCLA BHHBF2 Liver (2005) mlratio **" + ], + [ + "UCLA_CTB6B6CTF2_LIVER_2005", + "UCLA CTB6/B6CTF2 Liver (2005) mlratio **" + ], + [ + "UCLA_BHF2_LIVER_0605", + "UCLA BHF2 Liver (June05) mlratio" + ], + [ + "UCLA_BDF2_LIVER_1999", + "UCLA BDF2 Liver (1999) mlratio" + ], + [ + "LVF2_M_0704_R", + "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) RMA" + ], + [ + "LVF2_M_0704_M", + "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) MAS5" + ], + [ + "HLCF_0311", + "GSE9588 Human Liver Normal (Mar11) Females" + ] + ], + "Peritoneal Fat": [ + [ + "FT_2A_0805_M", + "MDC/CAS/ICL Peritoneal Fat 230A (Aug05) MAS5" + ], + [ + "FT_2A_0605_Rz", + "MDC/CAS/ICL Peritoneal Fat 230A (Jun05) RMA 2z+8" + ] + ], + "Phenotypes": [ + [ + "HXBBXHPublish", + "HXBBXH Published Phenotypes" + ] + ] + }, + "SRxSHRSPF2": { + "Eye": [ + [ + "Eye_AXBXA_1008_RankInv", + "Eye AXBXA Illumina V6.2(Oct08) RankInv Beta" + ], + [ + "Eye_M2_0908_R", + "Eye M430v2 (Sep08) RMA" + ], + [ + "Eye_M2_0908_R_NB", + "Eye M430v2 Mutant Gpnmb (Sep08) RMA **" + ], + [ + "Eye_M2_0908_R_ND", + "Eye M430v2 WT Gpnmb (Sep08) RMA **" + ], + [ + "Eye_M2_0908_WTWT", + "Eye M430v2 WT WT (Sep08) RMA **" + ], + [ + "Eye_M2_0908_R_WT", + "Eye M430v2 WT Tyrp1 (Sep08) RMA **" + ], + [ + "Eye_M2_0908_R_MT", + "Eye M430v2 Mutant Tyrp1 (Sep08) RMA **" + ], + [ + "BXD_GLA_0911", + "BXD Glaucoma Affy M430 2.0 Trial (Sep11) RMA **" + ], + [ + "UIOWA_Eye_RMA_0906", + "UIOWA Eye mRNA RAE230v2 (Sep06) RMA" + ] + ], + "Genotypes": [ + [ + "SRxSHRSPF2Geno", + "SRxSHRSPF2 Genotypes" + ] + ], + "Phenotypes": [ + [ + "SRxSHRSPF2Publish", + "SRxSHRSPF2 Published Phenotypes" + ] + ] + } + }, + "soybean": { + "J12XJ58F2": { + "Genotypes": [ + [ + "J12XJ58F2Geno", + "J12XJ58F2 Genotypes" + ] + ], + "Phenotypes": [ + [ + "J12XJ58F2Publish", + "J12XJ58F2 Published Phenotypes" + ] + ] + } + }, + "tomato": { + "LXP": { + "Genotypes": [ + [ + "LXPGeno", + "LXP Genotypes" + ] + ], + "Phenotypes": [ + [ + "LXPPublish", + "LXP Published Phenotypes" + ] + ] + } + } + }, + "groups": { + "All Species": [ + [ + "All Groups", + "All Groups" + ] + ], + "arabidopsis": [ + [ + "BayXSha", + "BayXSha" + ], + [ + "ColXBur", + "ColXBur" + ], + [ + "ColXCvi", + "ColXCvi" + ] + ], + "barley": [ + [ + "QSM", + "QSM" + ], + [ + "SXM", + "SXM" + ] + ], + "drosophila": [ + [ + "DGRP", + "Drosophila Genetic Reference Panel" + ], + [ + "Oregon-R_x_2b3", + "Oregon-R x 2b3" + ] + ], + "human": [ + [ + "AD-cases-controls", + "AD Cases & Controls (Liang)" + ], + [ + "AD-cases-controls-Myers", + "AD Cases & Controls (Myers)" + ], + [ + "CANDLE", + "CANDLE" + ], + [ + "CEPH-2004", + "CEPH Families" + ], + [ + "HB", + "Harvard Brain Tissue Resource Center" + ], + [ + "HLC", + "Human Liver Cohort" + ], + [ + "HSB", + "KIN/YSM" + ] + ], + "macaque monkey": [ + [ + "Macaca-fasicularis", + "Macaca fasicularis (Cynomolgus monkey)" + ] + ], + "mouse": [ + [ + "AKXD", + "AKXD" + ], + [ + "AXBXA", + "AXB/BXA" + ], + [ + "B6BTBRF2", + "B6BTBRF2" + ], + [ + "B6D2F2", + "B6D2F2" + ], + [ + "BDF2-1999", + "BDF2 UCLA" + ], + [ + "BDF2-2005", + "BDF2-2005" + ], + [ + "BHF2", + "BHF2 (Apoe Null) UCLA" + ], + [ + "BHHBF2", + "BH/HB F2 UCLA" + ], + [ + "BXD", + "BXD" + ], + [ + "BXH", + "BXH" + ], + [ + "CTB6F2", + "CastB6/B6Cast F2 UCLA" + ], + [ + "CXB", + "CXB" + ], + [ + "HS", + "Heterogeneous Stock" + ], + [ + "HS-CC", + "Heterogeneous Stock Collaborative Cross" + ], + [ + "LXS", + "LXS" + ], + [ + "MDP", + "Mouse Diversity Panel" + ], + [ + "NZBXFVB-N2", + "NZB/FVB N2 NCI" + ] + ], + "rat": [ + [ + "HXBBXH", + "HXB/BXH" + ], + [ + "SRxSHRSPF2", + "UIOWA SRxSHRSP F2" + ] + ], + "soybean": [ + [ + "J12XJ58F2", + "J12XJ58F2" + ] + ], + "tomato": [ + [ + "LXP", + "LXP" + ] + ] + }, + "species": [ + [ + "human", + "Human" + ], + [ + "macaque monkey", + "Macaque monkey" + ], + [ + "mouse", + "Mouse" + ], + [ + "rat", + "Rat" + ], + [ + "drosophila", + "Drosophila" + ], + [ + "arabidopsis", + "Arabidopsis thaliana" + ], + [ + "barley", + "Barley" + ], + [ + "soybean", + "Soybean" + ], + [ + "tomato", + "Tomato" + ], + [ + "All Species", + "All Species" + ] + ], + "types": { + "All Species": { + "All Groups": [ + [ + "Phenotypes", + "Phenotypes" + ] + ] + }, + "arabidopsis": { + "BayXSha": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ] + ], + "ColXBur": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ] + ], + "ColXCvi": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ] + ] + }, + "barley": { + "QSM": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Leaf", + "Leaf mRNA" + ] + ], + "SXM": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Embryo", + "Embryo mRNA" + ], + [ + "Leaf", + "Leaf mRNA" + ] + ] + }, + "drosophila": { + "DGRP": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Whole Body", + "Whole Body mRNA" + ] + ], + "Oregon-R_x_2b3": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Whole Body", + "Whole Body mRNA" + ] + ] + }, + "human": { + "AD-cases-controls": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Brain", + "Brain mRNA" + ] + ], + "AD-cases-controls-Myers": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Brain", + "Brain mRNA" + ] + ], + "CANDLE": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Newborn Cord Blood", + "Newborn Cord Blood mRNA" + ] + ], + "CEPH-2004": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Lymphoblast B-cell", + "Lymphoblast B-cell mRNA" + ] + ], + "HB": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Cerebellum", + "Cerebellum mRNA" + ], + [ + "Prefrontal Cortex", + "Prefrontal Cortex mRNA" + ], + [ + "Primary Visual Cortex", + "Primary Visual Cortex mRNA" + ] + ], + "HLC": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Liver", + "Liver mRNA" + ] + ], + "HSB": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Amygdala", + "Amygdala mRNA" + ], + [ + "Caudal Ganglionic Eminence", + "Caudal Ganglionic Eminence mRNA" + ], + [ + "Cerebellar Cortex", + "Cerebellar Cortex mRNA" + ], + [ + "Diencephalon", + "Diencephalon mRNA" + ], + [ + "Dorsal Thalamus", + "Dorsal Thalamus mRNA" + ], + [ + "Dorsolateral Prefrontal Cortex", + "Dorsolateral Prefrontal Cortex mRNA" + ], + [ + "Frontal Cerebral Wall", + "Frontal Cerebral Wall mRNA" + ], + [ + "Hippocampus", + "Hippocampus mRNA" + ], + [ + "Inferior Temporal Cortex", + "Inferior Temporal Cortex mRNA" + ], + [ + "Lateral Ganglionic Eminence", + "Lateral Ganglionic Eminence mRNA" + ], + [ + "Medial Ganglionic Eminence", + "Medial Ganglionic Eminence mRNA" + ], + [ + "Medial Prefrontal Cortex", + "Medial Prefrontal Cortex mRNA" + ], + [ + "Mediodorsal Nucleus of Thalamus", + "Mediodorsal Nucleus of Thalamus mRNA" + ], + [ + "Occipital Cerebral Wall", + "Occipital Cerebral Wall mRNA" + ], + [ + "Orbital Prefrontal Cortex", + "Orbital Prefrontal Cortex mRNA" + ], + [ + "Parietal Cerebral Wall", + "Parietal Cerebral Wall mRNA" + ], + [ + "Posterior Inferior Parietal Cortex", + "Posterior Inferior Parietal Cortex mRNA" + ], + [ + "Posterior Superior Temporal Cortex", + "Posterior Superior Temporal Cortex mRNA" + ], + [ + "Primary Auditory (A1) Cortex", + "Primary Auditory (A1) Cortex mRNA" + ], + [ + "Primary Motor (M1) Cortex", + "Primary Motor (M1) Cortex mRNA" + ], + [ + "Primary Somatosensory (S1) Cortex", + "Primary Somatosensory (S1) Cortex mRNA" + ], + [ + "Primary Visual Cortex", + "Primary Visual Cortex mRNA" + ], + [ + "Striatum", + "Striatum mRNA" + ], + [ + "Temporal Cerebral Wall", + "Temporal Cerebral Wall mRNA" + ], + [ + "Upper (Rostral) Rhombic Lip", + "Upper (Rostral) Rhombic Lip mRNA" + ], + [ + "Ventral Forebrain", + "Ventral Forebrain mRNA" + ], + [ + "Ventrolateral Prefrontal Cortex", + "Ventrolateral Prefrontal Cortex mRNA" + ] + ] + }, + "macaque monkey": { + "Macaca-fasicularis": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Amygdala", + "Amygdala mRNA" + ], + [ + "Brain", + "Brain mRNA" + ], + [ + "Hippocampus", + "Hippocampus mRNA" + ], + [ + "Nucleus Accumbens", + "Nucleus Accumbens mRNA" + ], + [ + "Prefrontal Cortex", + "Prefrontal Cortex mRNA" + ] + ] + }, + "mouse": { + "AKXD": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Mammary Tumors", + "Mammary Tumors mRNA" + ] + ], + "AXBXA": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Eye", + "Eye mRNA" + ] + ], + "B6BTBRF2": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Liver", + "Liver mRNA" + ] + ], + "B6D2F2": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Brain", + "Brain mRNA" + ] + ], + "BDF2-1999": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Liver", + "Liver mRNA" + ] + ], + "BDF2-2005": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Striatum", + "Striatum mRNA" + ] + ], + "BHF2": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Adipose", + "Adipose mRNA" + ], + [ + "Brain", + "Brain mRNA" + ], + [ + "Liver", + "Liver mRNA" + ], + [ + "Muscle", + "Muscle mRNA" + ] + ], + "BHHBF2": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Adipose", + "Adipose mRNA" + ], + [ + "Brain", + "Brain mRNA" + ], + [ + "Liver", + "Liver mRNA" + ], + [ + "Muscle", + "Muscle mRNA" + ] + ], + "BXD": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Amygdala", + "Amygdala mRNA" + ], + [ + "Brain", + "Brain mRNA" + ], + [ + "Cartilage", + "Cartilage mRNA" + ], + [ + "Cerebellum", + "Cerebellum mRNA" + ], + [ + "Eye", + "Eye mRNA" + ], + [ + "Hematopoietic Cells", + "Hematopoietic Cells mRNA" + ], + [ + "Hippocampus", + "Hippocampus mRNA" + ], + [ + "Hypothalamus", + "Hypothalamus mRNA" + ], + [ + "Kidney", + "Kidney mRNA" + ], + [ + "Leucocytes", + "Leucocytes mRNA" + ], + [ + "Liver", + "Liver mRNA" + ], + [ + "Lung", + "Lung mRNA" + ], + [ + "Midbrain", + "Midbrain mRNA" + ], + [ + "Muscle", + "Muscle mRNA" + ], + [ + "Neocortex", + "Neocortex mRNA" + ], + [ + "Nucleus Accumbens", + "Nucleus Accumbens mRNA" + ], + [ + "Prefrontal Cortex", + "Prefrontal Cortex mRNA" + ], + [ + "Retina", + "Retina mRNA" + ], + [ + "Spleen", + "Spleen mRNA" + ], + [ + "Striatum", + "Striatum mRNA" + ], + [ + "T Cell (helper)", + "T Cell (helper) mRNA" + ], + [ + "T Cell (regulatory)", + "T Cell (regulatory) mRNA" + ], + [ + "Thymus", + "Thymus mRNA" + ], + [ + "Ventral Tegmental Area", + "Ventral Tegmental Area mRNA" + ] + ], + "BXH": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Cartilage", + "Cartilage mRNA" + ] + ], + "CTB6F2": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Adipose", + "Adipose mRNA" + ], + [ + "Brain", + "Brain mRNA" + ], + [ + "Liver", + "Liver mRNA" + ], + [ + "Muscle", + "Muscle mRNA" + ] + ], + "CXB": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Hippocampus", + "Hippocampus mRNA" + ], + [ + "Spleen", + "Spleen mRNA" + ] + ], + "HS": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Hippocampus", + "Hippocampus mRNA" + ], + [ + "Liver", + "Liver mRNA" + ], + [ + "Lung", + "Lung mRNA" + ] + ], + "HS-CC": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Striatum", + "Striatum mRNA" + ] + ], + "LXS": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Hippocampus", + "Hippocampus mRNA" + ], + [ + "Prefrontal Cortex", + "Prefrontal Cortex mRNA" + ] + ], + "MDP": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Hippocampus", + "Hippocampus mRNA" + ], + [ + "Liver", + "Liver mRNA" + ] + ], + "NZBXFVB-N2": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Mammary Tumors", + "Mammary Tumors mRNA" + ] + ] + }, + "rat": { + "HXBBXH": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Adrenal Gland", + "Adrenal Gland mRNA" + ], + [ + "Heart", + "Heart mRNA" + ], + [ + "Hippocampus", + "Hippocampus mRNA" + ], + [ + "Kidney", + "Kidney mRNA" + ], + [ + "Liver", + "Liver mRNA" + ], + [ + "Peritoneal Fat", + "Peritoneal Fat mRNA" + ] + ], + "SRxSHRSPF2": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ], + [ + "Eye", + "Eye mRNA" + ] + ] + }, + "soybean": { + "J12XJ58F2": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ] + ] + }, + "tomato": { + "LXP": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Genotypes", + "Genotypes" + ] + ] + } + } +} \ No newline at end of file diff --git a/wqflask/wqflask/static/new/javascript/dataset_menu_structure.json b/wqflask/wqflask/static/new/javascript/dataset_menu_structure.json deleted file mode 100644 index d25d3cf5..00000000 --- a/wqflask/wqflask/static/new/javascript/dataset_menu_structure.json +++ /dev/null @@ -1,6792 +0,0 @@ -{ - "datasets": { - "All Species": { - "All Groups": { - "Phenotypes": [ - [ - "All Phenotypes", - "All Phenotypes" - ] - ] - } - }, - "arabidopsis": { - "BayXSha": { - "Genotypes": [ - [ - "BayXShaGeno", - "BayXSha Genotypes" - ] - ], - "Phenotypes": [ - [ - "BayXShaPublish", - "BayXSha Published Phenotypes" - ] - ] - }, - "ColXBur": { - "Genotypes": [ - [ - "ColXBurGeno", - "ColXBur Genotypes" - ] - ], - "Phenotypes": [ - [ - "ColXBurPublish", - "ColXBur Published Phenotypes" - ] - ] - }, - "ColXCvi": { - "Genotypes": [ - [ - "ColXCviGeno", - "ColXCvi Genotypes" - ] - ], - "Phenotypes": [ - [ - "ColXCviPublish", - "ColXCvi Published Phenotypes" - ] - ] - } - }, - "barley": { - "QSM": { - "Genotypes": [ - [ - "QSMGeno", - "QSM Genotypes" - ] - ], - "Leaf": [ - [ - "B1LI0809R", - "Barley1 Leaf INOC TTKS (Aug09) RMA" - ], - [ - "B1LI0809M5", - "Barley1 Leaf INOC TTKS (Aug09) MAS5" - ], - [ - "B1MI0809M5", - "Barley1 Leaf MOCK TTKS (Aug09) MAS5" - ], - [ - "B1MI0809R", - "Barley1 Leaf MOCK TTKS (Aug09) RMA" - ], - [ - "B30_K_1206_M", - "Barley1 Leaf MAS 5.0 SCRI (Dec06)" - ], - [ - "B30_K_1206_R", - "Barley1 Leaf gcRMA SCRI (Dec06)" - ], - [ - "B30_K_1206_Rn", - "Barley1 Leaf gcRMAn SCRI (Dec06)" - ] - ], - "Phenotypes": [ - [ - "QSMPublish", - "QSM Published Phenotypes" - ] - ] - }, - "SXM": { - "Embryo": [ - [ - "B139_K_1206_R", - "Barley1 Embryo gcRMA SCRI (Dec06)" - ], - [ - "B139_K_1206_M", - "Barley1 Embryo MAS 5.0 SCRI (Dec06)" - ], - [ - "B150_K_0406_R", - "Barley1 Embryo0 gcRMA SCRI (Apr06)" - ] - ], - "Genotypes": [ - [ - "SXMGeno", - "SXM Genotypes" - ] - ], - "Leaf": [ - [ - "B1LI0809R", - "Barley1 Leaf INOC TTKS (Aug09) RMA" - ], - [ - "B1LI0809M5", - "Barley1 Leaf INOC TTKS (Aug09) MAS5" - ], - [ - "B1MI0809M5", - "Barley1 Leaf MOCK TTKS (Aug09) MAS5" - ], - [ - "B1MI0809R", - "Barley1 Leaf MOCK TTKS (Aug09) RMA" - ], - [ - "B30_K_1206_M", - "Barley1 Leaf MAS 5.0 SCRI (Dec06)" - ], - [ - "B30_K_1206_R", - "Barley1 Leaf gcRMA SCRI (Dec06)" - ], - [ - "B30_K_1206_Rn", - "Barley1 Leaf gcRMAn SCRI (Dec06)" - ] - ], - "Phenotypes": [ - [ - "SXMPublish", - "SXM Published Phenotypes" - ] - ] - } - }, - "drosophila": { - "DGRP": { - "Genotypes": [ - [ - "DGRPGeno", - "DGRP Genotypes" - ] - ], - "Phenotypes": [ - [ - "DGRPPublish", - "DGRP Published Phenotypes" - ] - ], - "Whole Body": [ - [ - "NCSU_DrosWB_LC_RMA_0111", - "NCSU Drosophila Whole Body (Jan11) RMA" - ], - [ - "UAB_DrosWB_LC_RMA_1009", - "UAB Whole body D.m. mRNA control (Oct09) RMA" - ], - [ - "UAB_DrosWB_LE_RMA_1009", - "UAB Whole body D.m. mRNA lead (pbAc) (Oct09) RMA" - ] - ] - }, - "Oregon-R_x_2b3": { - "Genotypes": [ - [ - "Oregon-R_x_2b3Geno", - "Oregon-R_x_2b3 Genotypes" - ] - ], - "Phenotypes": [ - [ - "Oregon-R_x_2b3Publish", - "Oregon-R_x_2b3 Published Phenotypes" - ] - ], - "Whole Body": [ - [ - "NCSU_DrosWB_LC_RMA_0111", - "NCSU Drosophila Whole Body (Jan11) RMA" - ], - [ - "UAB_DrosWB_LC_RMA_1009", - "UAB Whole body D.m. mRNA control (Oct09) RMA" - ], - [ - "UAB_DrosWB_LE_RMA_1009", - "UAB Whole body D.m. mRNA lead (pbAc) (Oct09) RMA" - ] - ] - } - }, - "human": { - "AD-cases-controls": { - "Brain": [ - [ - "GSE15222_F_N_RI_0409", - "GSE15222 Human Brain Normal Myers (Apr09) RankInv" - ], - [ - "GSE15222_F_A_RI_0409", - "GSE15222 Human Brain Alzheimer Myers (Apr09) RankInv" - ], - [ - "GSE5281_F_RMA_N_0709", - "GSE5281 Human Brain Normal Full Liang (Jul09) RMA" - ], - [ - "GSE5281_F_RMA_Alzh_0709", - "GSE5281 Human Brain Alzheimer Full Liang (Jul09) RMA" - ], - [ - "INIA_MacFas_brain_RMA_0110", - "INIA Macaca fasicularis Brain (Jan10) RMA **" - ], - [ - "GSE15222_F_RI_0409", - "GSE15222 Human Brain Myers (Apr09) RankInv" - ], - [ - "GSE5281_F_RMA0709", - "GSE5281 Human Brain Full Liang (Jul09) RMA" - ], - [ - "GSE5281_RMA0709", - "GSE5281 Human Brain Best 102 Liang (Jul09) RMA" - ], - [ - "UCLA_CTB6B6CTF2_BRAIN_FEMALE", - "UCLA CTB6B6CTF2 Brain Female mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_BRAIN_MALE", - "UCLA CTB6B6CTF2 Brain Male mlratio **" - ], - [ - "UCLA_BHF2_BRAIN_MALE", - "UCLA BHF2 Brain Male mlratio" - ], - [ - "UCLA_BHF2_BRAIN_FEMALE", - "UCLA BHF2 Brain Female mlratio" - ], - [ - "UCLA_BHHBF2_BRAIN_FEMALE", - "UCLA BHHBF2 Brain Female Only" - ], - [ - "UCLA_BHHBF2_BRAIN_MALE", - "UCLA BHHBF2 Brain Male Only" - ], - [ - "UCLA_BHHBF2_BRAIN_2005", - "UCLA BHHBF2 Brain (2005) mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_BRAIN_2005", - "UCLA CTB6/B6CTF2 Brain (2005) mlratio **" - ], - [ - "UCLA_BHF2_BRAIN_0605", - "UCLA BHF2 Brain (June05) mlratio" - ], - [ - "BR_M2_1106_R", - "UCHSC BXD Whole Brain M430 2.0 (Nov06) RMA" - ], - [ - "IBR_M_0606_R", - "INIA Brain mRNA M430 (Jun06) RMA" - ], - [ - "IBR_M_0106_P", - "INIA Brain mRNA M430 (Jan06) PDNN" - ], - [ - "IBR_M_0106_R", - "INIA Brain mRNA M430 (Jan06) RMA" - ], - [ - "BR_U_1105_P", - "UTHSC Brain mRNA U74Av2 (Nov05) PDNN" - ], - [ - "BR_U_0805_M", - "UTHSC Brain mRNA U74Av2 (Aug05) MAS5" - ], - [ - "BR_U_0805_P", - "UTHSC Brain mRNA U74Av2 (Aug05) PDNN" - ], - [ - "BR_U_0805_R", - "UTHSC Brain mRNA U74Av2 (Aug05) RMA" - ], - [ - "BRF2_M_0805_R", - "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) RMA" - ], - [ - "BRF2_M_0805_P", - "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) PDNN" - ], - [ - "BRF2_M_0805_M", - "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) MAS5" - ], - [ - "BRF2_M_0304_P", - "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) PDNN" - ], - [ - "BRF2_M_0304_R", - "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) RMA" - ], - [ - "BRF2_M_0304_M", - "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) MAS5" - ], - [ - "CB_M_0204_P", - "INIA Brain mRNA M430 (Feb04) PDNN" - ] - ], - "Genotypes": [ - [ - "AD-cases-controlsGeno", - "AD-cases-controls Genotypes" - ] - ], - "Phenotypes": [ - [ - "AD-cases-controlsPublish", - "AD-cases-controls Published Phenotypes" - ] - ] - }, - "AD-cases-controls-Myers": { - "Brain": [ - [ - "GSE15222_F_N_RI_0409", - "GSE15222 Human Brain Normal Myers (Apr09) RankInv" - ], - [ - "GSE15222_F_A_RI_0409", - "GSE15222 Human Brain Alzheimer Myers (Apr09) RankInv" - ], - [ - "GSE5281_F_RMA_N_0709", - "GSE5281 Human Brain Normal Full Liang (Jul09) RMA" - ], - [ - "GSE5281_F_RMA_Alzh_0709", - "GSE5281 Human Brain Alzheimer Full Liang (Jul09) RMA" - ], - [ - "INIA_MacFas_brain_RMA_0110", - "INIA Macaca fasicularis Brain (Jan10) RMA **" - ], - [ - "GSE15222_F_RI_0409", - "GSE15222 Human Brain Myers (Apr09) RankInv" - ], - [ - "GSE5281_F_RMA0709", - "GSE5281 Human Brain Full Liang (Jul09) RMA" - ], - [ - "GSE5281_RMA0709", - "GSE5281 Human Brain Best 102 Liang (Jul09) RMA" - ], - [ - "UCLA_CTB6B6CTF2_BRAIN_FEMALE", - "UCLA CTB6B6CTF2 Brain Female mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_BRAIN_MALE", - "UCLA CTB6B6CTF2 Brain Male mlratio **" - ], - [ - "UCLA_BHF2_BRAIN_MALE", - "UCLA BHF2 Brain Male mlratio" - ], - [ - "UCLA_BHF2_BRAIN_FEMALE", - "UCLA BHF2 Brain Female mlratio" - ], - [ - "UCLA_BHHBF2_BRAIN_FEMALE", - "UCLA BHHBF2 Brain Female Only" - ], - [ - "UCLA_BHHBF2_BRAIN_MALE", - "UCLA BHHBF2 Brain Male Only" - ], - [ - "UCLA_BHHBF2_BRAIN_2005", - "UCLA BHHBF2 Brain (2005) mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_BRAIN_2005", - "UCLA CTB6/B6CTF2 Brain (2005) mlratio **" - ], - [ - "UCLA_BHF2_BRAIN_0605", - "UCLA BHF2 Brain (June05) mlratio" - ], - [ - "BR_M2_1106_R", - "UCHSC BXD Whole Brain M430 2.0 (Nov06) RMA" - ], - [ - "IBR_M_0606_R", - "INIA Brain mRNA M430 (Jun06) RMA" - ], - [ - "IBR_M_0106_P", - "INIA Brain mRNA M430 (Jan06) PDNN" - ], - [ - "IBR_M_0106_R", - "INIA Brain mRNA M430 (Jan06) RMA" - ], - [ - "BR_U_1105_P", - "UTHSC Brain mRNA U74Av2 (Nov05) PDNN" - ], - [ - "BR_U_0805_M", - "UTHSC Brain mRNA U74Av2 (Aug05) MAS5" - ], - [ - "BR_U_0805_P", - "UTHSC Brain mRNA U74Av2 (Aug05) PDNN" - ], - [ - "BR_U_0805_R", - "UTHSC Brain mRNA U74Av2 (Aug05) RMA" - ], - [ - "BRF2_M_0805_R", - "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) RMA" - ], - [ - "BRF2_M_0805_P", - "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) PDNN" - ], - [ - "BRF2_M_0805_M", - "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) MAS5" - ], - [ - "BRF2_M_0304_P", - "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) PDNN" - ], - [ - "BRF2_M_0304_R", - "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) RMA" - ], - [ - "BRF2_M_0304_M", - "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) MAS5" - ], - [ - "CB_M_0204_P", - "INIA Brain mRNA M430 (Feb04) PDNN" - ] - ], - "Genotypes": [ - [ - "AD-cases-controls-MyersGeno", - "AD-cases-controls-Myers Genotypes" - ] - ], - "Phenotypes": [ - [ - "AD-cases-controls-MyersPublish", - "AD-cases-controls-Myers Published Phenotypes" - ] - ] - }, - "CANDLE": { - "Genotypes": [ - [ - "CANDLEGeno", - "CANDLE Genotypes" - ] - ], - "Newborn Cord Blood": [ - [ - "CANDLE_NB_0711", - "CANDLE Newborn Cord ILMv6.3 (Jun11) QUANT **" - ] - ], - "Phenotypes": [ - [ - "CANDLEPublish", - "CANDLE Published Phenotypes" - ] - ] - }, - "CEPH-2004": { - "Genotypes": [ - [ - "CEPH-2004Geno", - "CEPH-2004 Genotypes" - ] - ], - "Lymphoblast B-cell": [ - [ - "UT_CEPH_RankInv0909", - "UTHSC CEPH B-cells Illumina (Sep09) RankInv" - ], - [ - "Human_1008", - "Monks CEPH B-cells Agilent (Dec04) Log10Ratio" - ] - ], - "Phenotypes": [ - [ - "CEPH-2004Publish", - "CEPH-2004 Published Phenotypes" - ] - ] - }, - "HB": { - "Cerebellum": [ - [ - "HBTRC-MLC_0611", - "HBTRC-MLC Human Cerebellum Agilent (Jun11) mlratio" - ], - [ - "HBTRC-MLC_N_0611", - "HBTRC-MLC Human Cerebellum Agilent Normal (Jun11) mlratio" - ], - [ - "HBTRC-MLC_AD_0611", - "HBTRC-MLC Human Cerebellum Agilent AD (Jun11) mlratio" - ], - [ - "HBTRC-MLC_HD_0611", - "HBTRC-MLC Human Cerebellum Agilent HD (Jun11) mlratio" - ], - [ - "GCB_M2_0505_M", - "GE-NIAAA Cerebellum mRNA M430v2 (May05) MAS5" - ], - [ - "GCB_M2_0505_R", - "GE-NIAAA Cerebellum mRNA M430v2 (May05) RMA" - ], - [ - "GCB_M2_0505_P", - "GE-NIAAA Cerebellum mRNA M430v2 (May05) PDNN" - ], - [ - "CB_M_0305_R", - "SJUT Cerebellum mRNA M430 (Mar05) RMA" - ], - [ - "CB_M_0305_M", - "SJUT Cerebellum mRNA M430 (Mar05) MAS5" - ], - [ - "CB_M_0305_P", - "SJUT Cerebellum mRNA M430 (Mar05) PDNN" - ], - [ - "CB_M_1004_R", - "SJUT Cerebellum mRNA M430 (Oct04) RMA" - ], - [ - "CB_M_1004_M", - "SJUT Cerebellum mRNA M430 (Oct04) MAS5" - ], - [ - "CB_M_1004_P", - "SJUT Cerebellum mRNA M430 (Oct04) PDNN" - ], - [ - "CB_M_1003_M", - "SJUT Cerebellum mRNA M430 (Oct03) MAS5" - ] - ], - "Genotypes": [ - [ - "HBGeno", - "HB Genotypes" - ] - ], - "Phenotypes": [ - [ - "HBPublish", - "HB Published Phenotypes" - ] - ], - "Prefrontal Cortex": [ - [ - "HBTRC-MLPFC_0611", - "HBTRC-MLC Human Prefrontal Cortex Agilent (Jun11) mlratio" - ], - [ - "HBTRC-MLPFC_N_0611", - "HBTRC-MLC Human Prefrontal Cortex Agilent Normal (Jun11) mlratio" - ], - [ - "HBTRC-MLPFC_AD_0611", - "HBTRC-MLC Human Prefrontal Cortex Agilent AD (Jun11) mlratio" - ], - [ - "HBTRC-MLPFC_HD_0611", - "HBTRC-MLC Human Prefrontal Cortex Agilent HD (Jun11) mlratio" - ], - [ - "INIA_MacFas_Pf_RMA_0110", - "INIA Macaca fasicularis Prefrontal Cortex control (Jan10) RMA **" - ], - [ - "INIA_MacFas_PfE_RMA_0110", - "INIA Macaca fasicularis Prefrontal Cortex ethanol (Jan10) RMA **" - ], - [ - "VCUSal_1006_R", - "VCU BXD PFC Et vs Sal M430 2.0 (Dec06) Sscore" - ], - [ - "VCUEtOH_1206_R", - "VCU BXD PFC EtOH M430 2.0 (Dec06) RMA" - ], - [ - "VCUSal_1206_R", - "VCU BXD PFC Sal M430 2.0 (Dec06) RMA" - ], - [ - "VCU_PF_Air_0111_R", - "VCU BXD PFC CIE Air M430 2.0 (Jan11) RMA **" - ], - [ - "VCU_PF_Et_0111_R", - "VCU BXD PFC CIE EtOH M430 2.0 (Jan11) RMA **" - ], - [ - "VCU_PF_AvE_0111_Ss", - "VCU BXD PFC EtOH vs CIE Air M430 2.0 (Jan11) Sscore **" - ], - [ - "VCUEt_vs_Sal_0806_R", - "VCU LXS PFC Et vs Sal M430A 2.0 (Aug06) Sscore **" - ], - [ - "VCUEtOH_0806_R", - "VCU LXS PFC EtOH M430A 2.0 (Aug06) RMA **" - ], - [ - "VCUSal_0806_R", - "VCU LXS PFC Sal M430A 2.0 (Aug06) RMA" - ] - ], - "Primary Visual Cortex": [ - [ - "KIN_YSM_V1C_0711", - "KIN/YSM Human V1C Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ], - [ - "HBTRC-MLVC_0611", - "HBTRC-MLC Human Visual Cortex Agilent (Jun11) mlratio" - ], - [ - "HBTRC-MLVC_N_0611", - "HBTRC-MLC Human Visual Cortex Agilent Normal (Jun11) mlratio" - ], - [ - "HBTRC-MLVC_AD_0611", - "HBTRC-MLC Human Visual Cortex Agilent AD (Jun11) mlratio" - ], - [ - "HBTRC-MLVC_HD_0611", - "HBTRC-MLC Human Visual Cortex Agilent HD (Jun11) mlratio" - ] - ] - }, - "HLC": { - "Genotypes": [ - [ - "HLCGeno", - "HLC Genotypes" - ] - ], - "Liver": [ - [ - "GSE16780_UCLA_ML0911", - "GSE16780 UCLA Hybrid MDP Liver Affy HT M430A (Sep11) RMA" - ], - [ - "JAX_CSB_L_0711", - "JAX Liver Affy M430 2.0 (Jul11) MDP" - ], - [ - "JAX_CSB_L_HF_0711", - "JAX Liver HF Affy M430 2.0 (Jul11) MDP" - ], - [ - "JAX_CSB_L_6C_0711", - "JAX Liver 6C Affy M430 2.0 (Jul11) MDP" - ], - [ - "HLC_0311", - "GSE9588 Human Liver Normal (Mar11) Both Sexes" - ], - [ - "HLCM_0311", - "GSE9588 Human Liver Normal (Mar11) Males" - ], - [ - "LV_G_0106_F", - "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Females" - ], - [ - "LV_G_0106_M", - "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Males" - ], - [ - "LV_G_0106_B", - "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Both Sexes" - ], - [ - "GenEx_BXD_liverSal_RMA_F_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Females **" - ], - [ - "GenEx_BXD_liverSal_RMA_M_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Males **" - ], - [ - "GenEx_BXD_liverSal_RMA_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" - ], - [ - "GenEx_BXD_liverEt_RMA_F_0211", - "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Females **" - ], - [ - "GenEx_BXD_liverEt_RMA_M_0211", - "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Males **" - ], - [ - "GenEx_BXD_liverEt_RMA_0211", - "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" - ], - [ - "SUH_Liv_RMA_0611", - "SUH BXD Liver Affy Mouse Gene 1.0 ST (Jun11) RMA **" - ], - [ - "OXUKHS_ILMLiver_RI0510", - "OX UK HS ILM6v1.1 Liver (May 2010) RankInv" - ], - [ - "HXB_Liver_1208", - "MDC/CAS/UCL Liver 230v2 (Dec08) RMA" - ], - [ - "UCLA_CTB6B6CTF2_LIVER_MALE", - "UCLA CTB6B6CTF2 Liver Male mlratio **" - ], - [ - "UCLA_BHF2_LIVER_MALE", - "UCLA BHF2 Liver Male mlratio" - ], - [ - "UCLA_CTB6B6CTF2_LIVER_FEMALE", - "UCLA CTB6B6CTF2 Liver Female mlratio **" - ], - [ - "UCLA_BHHBF2_LIVER_FEMALE", - "UCLA BHHBF2 Liver Female Only" - ], - [ - "UCLA_BHHBF2_LIVER_MALE", - "UCLA BHHBF2 Liver Male Only" - ], - [ - "UCLA_BHF2_LIVER_FEMALE", - "UCLA BHF2 Liver Female mlratio" - ], - [ - "UCLA_BHHBF2_LIVER_2005", - "UCLA BHHBF2 Liver (2005) mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_LIVER_2005", - "UCLA CTB6/B6CTF2 Liver (2005) mlratio **" - ], - [ - "UCLA_BHF2_LIVER_0605", - "UCLA BHF2 Liver (June05) mlratio" - ], - [ - "UCLA_BDF2_LIVER_1999", - "UCLA BDF2 Liver (1999) mlratio" - ], - [ - "LVF2_M_0704_R", - "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) RMA" - ], - [ - "LVF2_M_0704_M", - "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) MAS5" - ], - [ - "HLCF_0311", - "GSE9588 Human Liver Normal (Mar11) Females" - ] - ], - "Phenotypes": [ - [ - "HLCPublish", - "HLC Published Phenotypes" - ] - ] - }, - "HSB": { - "Amygdala": [ - [ - "KIN_YSM_AMY_0711", - "KIN/YSM Human AMY Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ], - [ - "INIA_AmgCoh_0311", - "INIA Amygdala Cohort Affy MoGene 1.0 ST (Mar11) RMA" - ], - [ - "INIA_Amg_BLA_RMA_1110", - "INIA Amygdala Affy MoGene 1.0 ST (Nov10) RMA" - ], - [ - "INIA_Amg_BLA_RMA_M_1110", - "INIA Amygdala Affy MoGene 1.0 ST (Nov10) RMA Male" - ], - [ - "INIA_Amg_BLA_RMA_F_1110", - "INIA Amygdala Affy MoGene 1.0 ST (Nov10) RMA Female" - ], - [ - "INIA_MacFas_AMGc_RMA_0110", - "INIA Macaca fasicularis Amygdala control (Jan10) RMA **" - ], - [ - "INIA_MacFas_AMGe_RMA_0110", - "INIA Macaca fasicularis Amygdala ethanol (Jan10) RMA **" - ] - ], - "Caudal Ganglionic Eminence": [ - [ - "KIN_YSM_CGE_0711", - "KIN/YSM Human CGE Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ] - ], - "Cerebellar Cortex": [ - [ - "KIN_YSM_CBC_0711", - "KIN/YSM Human CBC Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ] - ], - "Diencephalon": [ - [ - "KIN_YSM_DIE_0711", - "KIN/YSM Human DIE Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ] - ], - "Dorsal Thalamus": [ - [ - "KIN_YSM_DTH_0711", - "KIN/YSM Human DTH Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ] - ], - "Dorsolateral Prefrontal Cortex": [ - [ - "KIN_YSM_DFC_0711", - "KIN/YSM Human DFC Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ] - ], - "Frontal Cerebral Wall": [ - [ - "KIN_YSM_FC_0711", - "KIN/YSM Human FC Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ] - ], - "Genotypes": [ - [ - "HSBGeno", - "HSB Genotypes" - ] - ], - "Hippocampus": [ - [ - "KIN_YSM_HIP_0711", - "KIN/YSM Human HIP Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ], - [ - "UMUTAffyExon_0209_RMA_MDP", - "UMUTAffy Hippocampus Exon (Feb09) RMA MDP" - ], - [ - "HC_M2_0606_MDP", - "Hippocampus Consortium M430v2 (Jun06) RMA MDP" - ], - [ - "OXUKHS_ILMHipp_RI0510", - "OX UK HS ILM6v1.1 Hippocampus (May 2010) RankInv" - ], - [ - "INIA_MacFas_Hc_RMA_0110", - "INIA Macaca fasicularis Hippocampus control (Jan10) RMA **" - ], - [ - "INIA_MacFas_He_RMA_0110", - "INIA Macaca fasicularis Hippocampus ethanol (Jan10) RMA **" - ], - [ - "UT_HippRatEx_RMA_0709", - "UT Hippocampus Affy RaEx 1.0 Exon (Jul09) RMA" - ], - [ - "Illum_LXS_Hipp_loess0807", - "Hippocampus Illumina (Aug07) LOESS" - ], - [ - "Illum_LXS_Hipp_loess_nb0807", - "Hippocampus Illumina (Aug07) LOESS_NB" - ], - [ - "Illum_LXS_Hipp_quant0807", - "Hippocampus Illumina (Aug07) QUANT" - ], - [ - "Illum_LXS_Hipp_quant_nb0807", - "Hippocampus Illumina (Aug07) QUANT_NB" - ], - [ - "Illum_LXS_Hipp_rsn0807", - "Hippocampus Illumina (Aug07) RSN" - ], - [ - "Illum_LXS_Hipp_rsn_nb0807", - "Hippocampus Illumina (Aug07) RSN_NB" - ], - [ - "Hipp_Illumina_RankInv_0507", - "Hippocampus Illumina (May07) RankInv" - ], - [ - "HC_M2_0606_P", - "Hippocampus Consortium M430v2 (Jun06) PDNN" - ], - [ - "HC_M2_0606_M", - "Hippocampus Consortium M430v2 (Jun06) MAS5" - ], - [ - "HC_M2_0606_R", - "Hippocampus Consortium M430v2 (Jun06) RMA" - ], - [ - "HC_M2CB_1205_R", - "Hippocampus Consortium M430v2 CXB (Dec05) RMA" - ], - [ - "HC_M2CB_1205_P", - "Hippocampus Consortium M430v2 CXB (Dec05) PDNN" - ], - [ - "UMUTAffyExon_0209_RMA", - "UMUTAffy Hippocampus Exon (Feb09) RMA" - ], - [ - "UT_ILM_BXD_hipp_NON_0909", - "UTHSC Hippocampus Illumina v6.1 NON (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_NOS_0909", - "UTHSC Hippocampus Illumina v6.1 NOS (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_NOE_0909", - "UTHSC Hippocampus Illumina v6.1 NOE (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_RSS_0909", - "UTHSC Hippocampus Illumina v6.1 RSS (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_RSE_0909", - "UTHSC Hippocampus Illumina v6.1 RSE (Sep09) RankInv" - ], - [ - "Illum_LXS_Hipp_RSE_1008", - "Hippocampus Illumina RSE (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_NOS_1008", - "Hippocampus Illumina NOS (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_NOE_1008", - "Hippocampus Illumina NOE (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_RSS_1008", - "Hippocampus Illumina RSS (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_NON_1008", - "Hippocampus Illumina NON (Oct08) RankInv beta" - ] - ], - "Inferior Temporal Cortex": [ - [ - "KIN_YSM_ITC_0711", - "KIN/YSM Human ITC Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ] - ], - "Lateral Ganglionic Eminence": [ - [ - "KIN_YSM_LGE_0711", - "KIN/YSM Human LGE Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ] - ], - "Medial Ganglionic Eminence": [ - [ - "KIN_YSM_MGE_0711", - "KIN/YSM Human MGE Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ] - ], - "Medial Prefrontal Cortex": [ - [ - "KIN_YSM_MFC_0711", - "KIN/YSM Human MFC Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ] - ], - "Mediodorsal Nucleus of Thalamus": [ - [ - "KIN_YSM_MD_0711", - "KIN/YSM Human MD Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ] - ], - "Occipital Cerebral Wall": [ - [ - "KIN_YSM_OC_0711", - "KIN/YSM Human OC Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ] - ], - "Orbital Prefrontal Cortex": [ - [ - "KIN_YSM_OFC_0711", - "KIN/YSM Human OFC Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ] - ], - "Parietal Cerebral Wall": [ - [ - "KIN_YSM_PC_0711", - "KIN/YSM Human PC Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ] - ], - "Phenotypes": [ - [ - "HSBPublish", - "HSB Published Phenotypes" - ] - ], - "Posterior Inferior Parietal Cortex": [ - [ - "KIN_YSM_IPC_0711", - "KIN/YSM Human IPC Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ] - ], - "Posterior Superior Temporal Cortex": [ - [ - "KIN_YSM_STC_0711", - "KIN/YSM Human STC Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ] - ], - "Primary Auditory (A1) Cortex": [ - [ - "KIN_YSM_A1C_0711", - "KIN/YSM Human A1C Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ] - ], - "Primary Motor (M1) Cortex": [ - [ - "KIN_YSM_M1C_0711", - "KIN/YSM Human M1C Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ] - ], - "Primary Somatosensory (S1) Cortex": [ - [ - "KIN_YSM_S1C_0711", - "KIN/YSM Human S1C Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ] - ], - "Primary Visual Cortex": [ - [ - "KIN_YSM_V1C_0711", - "KIN/YSM Human V1C Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ], - [ - "HBTRC-MLVC_0611", - "HBTRC-MLC Human Visual Cortex Agilent (Jun11) mlratio" - ], - [ - "HBTRC-MLVC_N_0611", - "HBTRC-MLC Human Visual Cortex Agilent Normal (Jun11) mlratio" - ], - [ - "HBTRC-MLVC_AD_0611", - "HBTRC-MLC Human Visual Cortex Agilent AD (Jun11) mlratio" - ], - [ - "HBTRC-MLVC_HD_0611", - "HBTRC-MLC Human Visual Cortex Agilent HD (Jun11) mlratio" - ] - ], - "Striatum": [ - [ - "DevStriatum_ILM6.2P3RInv_1111", - "BIDMC/UTHSC Dev Striatum P3 ILMv6.2 (Nov11) RankInv **" - ], - [ - "DevStriatum_ILM6.2P14RInv_1111", - "BIDMC/UTHSC Dev Striatum P14 ILMv6.2 (Nov11) RankInv **" - ], - [ - "KIN_YSM_STR_0711", - "KIN/YSM Human STR Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ], - [ - "OHSU_HS-CC_ILMStr_0211", - "OHSU HS-CC Striatum ILM6v1 (Feb11) RankInv" - ], - [ - "UTHSC_Striatum_RankInv_1210", - "HQF BXD Striatum ILM6.1 (Dec10v2) RankInv" - ], - [ - "UTHSC_Str_RankInv_1210", - "HQF BXD Striatum ILM6.1 (Dec10) RankInv" - ], - [ - "UTHSC_1107_RankInv", - "HQF BXD Striatum ILM6.1 (Nov07) RankInv" - ], - [ - "SA_M2_0905_P", - "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) PDNN" - ], - [ - "SA_M2_0905_M", - "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) MAS5" - ], - [ - "SA_M2_0905_R", - "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) RMA" - ], - [ - "SA_M2_0405_MC", - "HBP Rosen Striatum M430V2 (Apr05) MAS5 Clean" - ], - [ - "SA_M2_0405_RC", - "HBP Rosen Striatum M430V2 (Apr05) RMA Clean" - ], - [ - "SA_M2_0405_PC", - "HBP Rosen Striatum M430V2 (Apr05) PDNN Clean" - ], - [ - "SA_M2_0405_SS", - "HBP Rosen Striatum M430V2 (Apr05) SScore" - ], - [ - "SA_M2_0405_RR", - "HBP Rosen Striatum M430V2 (Apr05) RMA Orig" - ], - [ - "Striatum_Exon_0209", - "HQF Striatum Exon (Feb09) RMA" - ], - [ - "DevStriatum_ILM6.2P3RInv_1110", - "BIDMC/UTHSC Dev Striatum P3 ILMv6.2 (Nov10) RankInv **" - ], - [ - "DevStriatum_ILM6.2P14RInv_1110", - "BIDMC/UTHSC Dev Striatum P14 ILMv6.2 (Nov10) RankInv **" - ] - ], - "Temporal Cerebral Wall": [ - [ - "KIN_YSM_TC_0711", - "KIN/YSM Human TC Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ] - ], - "Upper (Rostral) Rhombic Lip": [ - [ - "KIN_YSM_URL_0711", - "KIN/YSM Human URL Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ] - ], - "Ventral Forebrain": [ - [ - "KIN_YSM_VF_0711", - "KIN/YSM Human VF Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ] - ], - "Ventrolateral Prefrontal Cortex": [ - [ - "KIN_YSM_VFC_0711", - "KIN/YSM Human VFC Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ] - ] - } - }, - "macaque monkey": { - "Macaca-fasicularis": { - "Amygdala": [ - [ - "KIN_YSM_AMY_0711", - "KIN/YSM Human AMY Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ], - [ - "INIA_AmgCoh_0311", - "INIA Amygdala Cohort Affy MoGene 1.0 ST (Mar11) RMA" - ], - [ - "INIA_Amg_BLA_RMA_1110", - "INIA Amygdala Affy MoGene 1.0 ST (Nov10) RMA" - ], - [ - "INIA_Amg_BLA_RMA_M_1110", - "INIA Amygdala Affy MoGene 1.0 ST (Nov10) RMA Male" - ], - [ - "INIA_Amg_BLA_RMA_F_1110", - "INIA Amygdala Affy MoGene 1.0 ST (Nov10) RMA Female" - ], - [ - "INIA_MacFas_AMGc_RMA_0110", - "INIA Macaca fasicularis Amygdala control (Jan10) RMA **" - ], - [ - "INIA_MacFas_AMGe_RMA_0110", - "INIA Macaca fasicularis Amygdala ethanol (Jan10) RMA **" - ] - ], - "Brain": [ - [ - "GSE15222_F_N_RI_0409", - "GSE15222 Human Brain Normal Myers (Apr09) RankInv" - ], - [ - "GSE15222_F_A_RI_0409", - "GSE15222 Human Brain Alzheimer Myers (Apr09) RankInv" - ], - [ - "GSE5281_F_RMA_N_0709", - "GSE5281 Human Brain Normal Full Liang (Jul09) RMA" - ], - [ - "GSE5281_F_RMA_Alzh_0709", - "GSE5281 Human Brain Alzheimer Full Liang (Jul09) RMA" - ], - [ - "INIA_MacFas_brain_RMA_0110", - "INIA Macaca fasicularis Brain (Jan10) RMA **" - ], - [ - "GSE15222_F_RI_0409", - "GSE15222 Human Brain Myers (Apr09) RankInv" - ], - [ - "GSE5281_F_RMA0709", - "GSE5281 Human Brain Full Liang (Jul09) RMA" - ], - [ - "GSE5281_RMA0709", - "GSE5281 Human Brain Best 102 Liang (Jul09) RMA" - ], - [ - "UCLA_CTB6B6CTF2_BRAIN_FEMALE", - "UCLA CTB6B6CTF2 Brain Female mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_BRAIN_MALE", - "UCLA CTB6B6CTF2 Brain Male mlratio **" - ], - [ - "UCLA_BHF2_BRAIN_MALE", - "UCLA BHF2 Brain Male mlratio" - ], - [ - "UCLA_BHF2_BRAIN_FEMALE", - "UCLA BHF2 Brain Female mlratio" - ], - [ - "UCLA_BHHBF2_BRAIN_FEMALE", - "UCLA BHHBF2 Brain Female Only" - ], - [ - "UCLA_BHHBF2_BRAIN_MALE", - "UCLA BHHBF2 Brain Male Only" - ], - [ - "UCLA_BHHBF2_BRAIN_2005", - "UCLA BHHBF2 Brain (2005) mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_BRAIN_2005", - "UCLA CTB6/B6CTF2 Brain (2005) mlratio **" - ], - [ - "UCLA_BHF2_BRAIN_0605", - "UCLA BHF2 Brain (June05) mlratio" - ], - [ - "BR_M2_1106_R", - "UCHSC BXD Whole Brain M430 2.0 (Nov06) RMA" - ], - [ - "IBR_M_0606_R", - "INIA Brain mRNA M430 (Jun06) RMA" - ], - [ - "IBR_M_0106_P", - "INIA Brain mRNA M430 (Jan06) PDNN" - ], - [ - "IBR_M_0106_R", - "INIA Brain mRNA M430 (Jan06) RMA" - ], - [ - "BR_U_1105_P", - "UTHSC Brain mRNA U74Av2 (Nov05) PDNN" - ], - [ - "BR_U_0805_M", - "UTHSC Brain mRNA U74Av2 (Aug05) MAS5" - ], - [ - "BR_U_0805_P", - "UTHSC Brain mRNA U74Av2 (Aug05) PDNN" - ], - [ - "BR_U_0805_R", - "UTHSC Brain mRNA U74Av2 (Aug05) RMA" - ], - [ - "BRF2_M_0805_R", - "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) RMA" - ], - [ - "BRF2_M_0805_P", - "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) PDNN" - ], - [ - "BRF2_M_0805_M", - "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) MAS5" - ], - [ - "BRF2_M_0304_P", - "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) PDNN" - ], - [ - "BRF2_M_0304_R", - "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) RMA" - ], - [ - "BRF2_M_0304_M", - "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) MAS5" - ], - [ - "CB_M_0204_P", - "INIA Brain mRNA M430 (Feb04) PDNN" - ] - ], - "Genotypes": [ - [ - "Macaca-fasicularisGeno", - "Macaca-fasicularis Genotypes" - ] - ], - "Hippocampus": [ - [ - "KIN_YSM_HIP_0711", - "KIN/YSM Human HIP Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ], - [ - "UMUTAffyExon_0209_RMA_MDP", - "UMUTAffy Hippocampus Exon (Feb09) RMA MDP" - ], - [ - "HC_M2_0606_MDP", - "Hippocampus Consortium M430v2 (Jun06) RMA MDP" - ], - [ - "OXUKHS_ILMHipp_RI0510", - "OX UK HS ILM6v1.1 Hippocampus (May 2010) RankInv" - ], - [ - "INIA_MacFas_Hc_RMA_0110", - "INIA Macaca fasicularis Hippocampus control (Jan10) RMA **" - ], - [ - "INIA_MacFas_He_RMA_0110", - "INIA Macaca fasicularis Hippocampus ethanol (Jan10) RMA **" - ], - [ - "UT_HippRatEx_RMA_0709", - "UT Hippocampus Affy RaEx 1.0 Exon (Jul09) RMA" - ], - [ - "Illum_LXS_Hipp_loess0807", - "Hippocampus Illumina (Aug07) LOESS" - ], - [ - "Illum_LXS_Hipp_loess_nb0807", - "Hippocampus Illumina (Aug07) LOESS_NB" - ], - [ - "Illum_LXS_Hipp_quant0807", - "Hippocampus Illumina (Aug07) QUANT" - ], - [ - "Illum_LXS_Hipp_quant_nb0807", - "Hippocampus Illumina (Aug07) QUANT_NB" - ], - [ - "Illum_LXS_Hipp_rsn0807", - "Hippocampus Illumina (Aug07) RSN" - ], - [ - "Illum_LXS_Hipp_rsn_nb0807", - "Hippocampus Illumina (Aug07) RSN_NB" - ], - [ - "Hipp_Illumina_RankInv_0507", - "Hippocampus Illumina (May07) RankInv" - ], - [ - "HC_M2_0606_P", - "Hippocampus Consortium M430v2 (Jun06) PDNN" - ], - [ - "HC_M2_0606_M", - "Hippocampus Consortium M430v2 (Jun06) MAS5" - ], - [ - "HC_M2_0606_R", - "Hippocampus Consortium M430v2 (Jun06) RMA" - ], - [ - "HC_M2CB_1205_R", - "Hippocampus Consortium M430v2 CXB (Dec05) RMA" - ], - [ - "HC_M2CB_1205_P", - "Hippocampus Consortium M430v2 CXB (Dec05) PDNN" - ], - [ - "UMUTAffyExon_0209_RMA", - "UMUTAffy Hippocampus Exon (Feb09) RMA" - ], - [ - "UT_ILM_BXD_hipp_NON_0909", - "UTHSC Hippocampus Illumina v6.1 NON (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_NOS_0909", - "UTHSC Hippocampus Illumina v6.1 NOS (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_NOE_0909", - "UTHSC Hippocampus Illumina v6.1 NOE (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_RSS_0909", - "UTHSC Hippocampus Illumina v6.1 RSS (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_RSE_0909", - "UTHSC Hippocampus Illumina v6.1 RSE (Sep09) RankInv" - ], - [ - "Illum_LXS_Hipp_RSE_1008", - "Hippocampus Illumina RSE (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_NOS_1008", - "Hippocampus Illumina NOS (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_NOE_1008", - "Hippocampus Illumina NOE (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_RSS_1008", - "Hippocampus Illumina RSS (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_NON_1008", - "Hippocampus Illumina NON (Oct08) RankInv beta" - ] - ], - "Nucleus Accumbens": [ - [ - "INIA_MacFas_Ac_RMA_0110", - "INIA Macaca fasicularis Nucleus Accumbens control (Jan10) RMA **" - ], - [ - "INIA_MacFas_Ae_RMA_0110", - "INIA Macaca fasicularis Nucleus Accumbens ethanol (Jan10) RMA **" - ], - [ - "VCUSalo_1007_R", - "VCU BXD NA Sal M430 2.0 (Oct07) RMA" - ], - [ - "VCUEtOH_1007_R", - "VCU BXD NA EtOH M430 2.0 (Oct07) RMA **" - ], - [ - "VCUSal_1007_R", - "VCU BXD NA Et vs Sal M430 2.0 (Oct07) Sscore **" - ] - ], - "Phenotypes": [ - [ - "Macaca-fasicularisPublish", - "Macaca-fasicularis Published Phenotypes" - ] - ], - "Prefrontal Cortex": [ - [ - "HBTRC-MLPFC_0611", - "HBTRC-MLC Human Prefrontal Cortex Agilent (Jun11) mlratio" - ], - [ - "HBTRC-MLPFC_N_0611", - "HBTRC-MLC Human Prefrontal Cortex Agilent Normal (Jun11) mlratio" - ], - [ - "HBTRC-MLPFC_AD_0611", - "HBTRC-MLC Human Prefrontal Cortex Agilent AD (Jun11) mlratio" - ], - [ - "HBTRC-MLPFC_HD_0611", - "HBTRC-MLC Human Prefrontal Cortex Agilent HD (Jun11) mlratio" - ], - [ - "INIA_MacFas_Pf_RMA_0110", - "INIA Macaca fasicularis Prefrontal Cortex control (Jan10) RMA **" - ], - [ - "INIA_MacFas_PfE_RMA_0110", - "INIA Macaca fasicularis Prefrontal Cortex ethanol (Jan10) RMA **" - ], - [ - "VCUSal_1006_R", - "VCU BXD PFC Et vs Sal M430 2.0 (Dec06) Sscore" - ], - [ - "VCUEtOH_1206_R", - "VCU BXD PFC EtOH M430 2.0 (Dec06) RMA" - ], - [ - "VCUSal_1206_R", - "VCU BXD PFC Sal M430 2.0 (Dec06) RMA" - ], - [ - "VCU_PF_Air_0111_R", - "VCU BXD PFC CIE Air M430 2.0 (Jan11) RMA **" - ], - [ - "VCU_PF_Et_0111_R", - "VCU BXD PFC CIE EtOH M430 2.0 (Jan11) RMA **" - ], - [ - "VCU_PF_AvE_0111_Ss", - "VCU BXD PFC EtOH vs CIE Air M430 2.0 (Jan11) Sscore **" - ], - [ - "VCUEt_vs_Sal_0806_R", - "VCU LXS PFC Et vs Sal M430A 2.0 (Aug06) Sscore **" - ], - [ - "VCUEtOH_0806_R", - "VCU LXS PFC EtOH M430A 2.0 (Aug06) RMA **" - ], - [ - "VCUSal_0806_R", - "VCU LXS PFC Sal M430A 2.0 (Aug06) RMA" - ] - ] - } - }, - "mouse": { - "AKXD": { - "Genotypes": [ - [ - "AKXDGeno", - "AKXD Genotypes" - ] - ], - "Mammary Tumors": [ - [ - "NCI_Mam_Tum_RMA_0409", - "NCI Mammary M430v2 (Apr09) RMA" - ], - [ - "NCI_Agil_Mam_Tum_RMA_0409", - "NCI Mammary LMT miRNA v2 (Apr09) RMA" - ], - [ - "MA_M_0704_R", - "NCI Mammary mRNA M430 (July04) RMA" - ], - [ - "MA_M_0704_M", - "NCI Mammary mRNA M430 (July04) MAS5" - ] - ], - "Phenotypes": [ - [ - "AKXDPublish", - "AKXD Published Phenotypes" - ] - ] - }, - "AXBXA": { - "Eye": [ - [ - "Eye_AXBXA_1008_RankInv", - "Eye AXBXA Illumina V6.2(Oct08) RankInv Beta" - ], - [ - "Eye_M2_0908_R", - "Eye M430v2 (Sep08) RMA" - ], - [ - "Eye_M2_0908_R_NB", - "Eye M430v2 Mutant Gpnmb (Sep08) RMA **" - ], - [ - "Eye_M2_0908_R_ND", - "Eye M430v2 WT Gpnmb (Sep08) RMA **" - ], - [ - "Eye_M2_0908_WTWT", - "Eye M430v2 WT WT (Sep08) RMA **" - ], - [ - "Eye_M2_0908_R_WT", - "Eye M430v2 WT Tyrp1 (Sep08) RMA **" - ], - [ - "Eye_M2_0908_R_MT", - "Eye M430v2 Mutant Tyrp1 (Sep08) RMA **" - ], - [ - "BXD_GLA_0911", - "BXD Glaucoma Affy M430 2.0 Trial (Sep11) RMA **" - ], - [ - "UIOWA_Eye_RMA_0906", - "UIOWA Eye mRNA RAE230v2 (Sep06) RMA" - ] - ], - "Genotypes": [ - [ - "AXBXAGeno", - "AXBXA Genotypes" - ] - ], - "Phenotypes": [ - [ - "AXBXAPublish", - "AXBXA Published Phenotypes" - ] - ] - }, - "B6BTBRF2": { - "Genotypes": [ - [ - "B6BTBRF2Geno", - "B6BTBRF2 Genotypes" - ] - ], - "Liver": [ - [ - "GSE16780_UCLA_ML0911", - "GSE16780 UCLA Hybrid MDP Liver Affy HT M430A (Sep11) RMA" - ], - [ - "JAX_CSB_L_0711", - "JAX Liver Affy M430 2.0 (Jul11) MDP" - ], - [ - "JAX_CSB_L_HF_0711", - "JAX Liver HF Affy M430 2.0 (Jul11) MDP" - ], - [ - "JAX_CSB_L_6C_0711", - "JAX Liver 6C Affy M430 2.0 (Jul11) MDP" - ], - [ - "HLC_0311", - "GSE9588 Human Liver Normal (Mar11) Both Sexes" - ], - [ - "HLCM_0311", - "GSE9588 Human Liver Normal (Mar11) Males" - ], - [ - "LV_G_0106_F", - "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Females" - ], - [ - "LV_G_0106_M", - "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Males" - ], - [ - "LV_G_0106_B", - "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Both Sexes" - ], - [ - "GenEx_BXD_liverSal_RMA_F_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Females **" - ], - [ - "GenEx_BXD_liverSal_RMA_M_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Males **" - ], - [ - "GenEx_BXD_liverSal_RMA_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" - ], - [ - "GenEx_BXD_liverEt_RMA_F_0211", - "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Females **" - ], - [ - "GenEx_BXD_liverEt_RMA_M_0211", - "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Males **" - ], - [ - "GenEx_BXD_liverEt_RMA_0211", - "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" - ], - [ - "SUH_Liv_RMA_0611", - "SUH BXD Liver Affy Mouse Gene 1.0 ST (Jun11) RMA **" - ], - [ - "OXUKHS_ILMLiver_RI0510", - "OX UK HS ILM6v1.1 Liver (May 2010) RankInv" - ], - [ - "HXB_Liver_1208", - "MDC/CAS/UCL Liver 230v2 (Dec08) RMA" - ], - [ - "UCLA_CTB6B6CTF2_LIVER_MALE", - "UCLA CTB6B6CTF2 Liver Male mlratio **" - ], - [ - "UCLA_BHF2_LIVER_MALE", - "UCLA BHF2 Liver Male mlratio" - ], - [ - "UCLA_CTB6B6CTF2_LIVER_FEMALE", - "UCLA CTB6B6CTF2 Liver Female mlratio **" - ], - [ - "UCLA_BHHBF2_LIVER_FEMALE", - "UCLA BHHBF2 Liver Female Only" - ], - [ - "UCLA_BHHBF2_LIVER_MALE", - "UCLA BHHBF2 Liver Male Only" - ], - [ - "UCLA_BHF2_LIVER_FEMALE", - "UCLA BHF2 Liver Female mlratio" - ], - [ - "UCLA_BHHBF2_LIVER_2005", - "UCLA BHHBF2 Liver (2005) mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_LIVER_2005", - "UCLA CTB6/B6CTF2 Liver (2005) mlratio **" - ], - [ - "UCLA_BHF2_LIVER_0605", - "UCLA BHF2 Liver (June05) mlratio" - ], - [ - "UCLA_BDF2_LIVER_1999", - "UCLA BDF2 Liver (1999) mlratio" - ], - [ - "LVF2_M_0704_R", - "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) RMA" - ], - [ - "LVF2_M_0704_M", - "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) MAS5" - ], - [ - "HLCF_0311", - "GSE9588 Human Liver Normal (Mar11) Females" - ] - ], - "Phenotypes": [ - [ - "B6BTBRF2Publish", - "B6BTBRF2 Published Phenotypes" - ] - ] - }, - "B6D2F2": { - "Brain": [ - [ - "GSE15222_F_N_RI_0409", - "GSE15222 Human Brain Normal Myers (Apr09) RankInv" - ], - [ - "GSE15222_F_A_RI_0409", - "GSE15222 Human Brain Alzheimer Myers (Apr09) RankInv" - ], - [ - "GSE5281_F_RMA_N_0709", - "GSE5281 Human Brain Normal Full Liang (Jul09) RMA" - ], - [ - "GSE5281_F_RMA_Alzh_0709", - "GSE5281 Human Brain Alzheimer Full Liang (Jul09) RMA" - ], - [ - "INIA_MacFas_brain_RMA_0110", - "INIA Macaca fasicularis Brain (Jan10) RMA **" - ], - [ - "GSE15222_F_RI_0409", - "GSE15222 Human Brain Myers (Apr09) RankInv" - ], - [ - "GSE5281_F_RMA0709", - "GSE5281 Human Brain Full Liang (Jul09) RMA" - ], - [ - "GSE5281_RMA0709", - "GSE5281 Human Brain Best 102 Liang (Jul09) RMA" - ], - [ - "UCLA_CTB6B6CTF2_BRAIN_FEMALE", - "UCLA CTB6B6CTF2 Brain Female mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_BRAIN_MALE", - "UCLA CTB6B6CTF2 Brain Male mlratio **" - ], - [ - "UCLA_BHF2_BRAIN_MALE", - "UCLA BHF2 Brain Male mlratio" - ], - [ - "UCLA_BHF2_BRAIN_FEMALE", - "UCLA BHF2 Brain Female mlratio" - ], - [ - "UCLA_BHHBF2_BRAIN_FEMALE", - "UCLA BHHBF2 Brain Female Only" - ], - [ - "UCLA_BHHBF2_BRAIN_MALE", - "UCLA BHHBF2 Brain Male Only" - ], - [ - "UCLA_BHHBF2_BRAIN_2005", - "UCLA BHHBF2 Brain (2005) mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_BRAIN_2005", - "UCLA CTB6/B6CTF2 Brain (2005) mlratio **" - ], - [ - "UCLA_BHF2_BRAIN_0605", - "UCLA BHF2 Brain (June05) mlratio" - ], - [ - "BR_M2_1106_R", - "UCHSC BXD Whole Brain M430 2.0 (Nov06) RMA" - ], - [ - "IBR_M_0606_R", - "INIA Brain mRNA M430 (Jun06) RMA" - ], - [ - "IBR_M_0106_P", - "INIA Brain mRNA M430 (Jan06) PDNN" - ], - [ - "IBR_M_0106_R", - "INIA Brain mRNA M430 (Jan06) RMA" - ], - [ - "BR_U_1105_P", - "UTHSC Brain mRNA U74Av2 (Nov05) PDNN" - ], - [ - "BR_U_0805_M", - "UTHSC Brain mRNA U74Av2 (Aug05) MAS5" - ], - [ - "BR_U_0805_P", - "UTHSC Brain mRNA U74Av2 (Aug05) PDNN" - ], - [ - "BR_U_0805_R", - "UTHSC Brain mRNA U74Av2 (Aug05) RMA" - ], - [ - "BRF2_M_0805_R", - "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) RMA" - ], - [ - "BRF2_M_0805_P", - "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) PDNN" - ], - [ - "BRF2_M_0805_M", - "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) MAS5" - ], - [ - "BRF2_M_0304_P", - "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) PDNN" - ], - [ - "BRF2_M_0304_R", - "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) RMA" - ], - [ - "BRF2_M_0304_M", - "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) MAS5" - ], - [ - "CB_M_0204_P", - "INIA Brain mRNA M430 (Feb04) PDNN" - ] - ], - "Genotypes": [ - [ - "B6D2F2Geno", - "B6D2F2 Genotypes" - ] - ], - "Phenotypes": [ - [ - "B6D2F2Publish", - "B6D2F2 Published Phenotypes" - ] - ] - }, - "BDF2-1999": { - "Genotypes": [ - [ - "BDF2-1999Geno", - "BDF2-1999 Genotypes" - ] - ], - "Liver": [ - [ - "GSE16780_UCLA_ML0911", - "GSE16780 UCLA Hybrid MDP Liver Affy HT M430A (Sep11) RMA" - ], - [ - "JAX_CSB_L_0711", - "JAX Liver Affy M430 2.0 (Jul11) MDP" - ], - [ - "JAX_CSB_L_HF_0711", - "JAX Liver HF Affy M430 2.0 (Jul11) MDP" - ], - [ - "JAX_CSB_L_6C_0711", - "JAX Liver 6C Affy M430 2.0 (Jul11) MDP" - ], - [ - "HLC_0311", - "GSE9588 Human Liver Normal (Mar11) Both Sexes" - ], - [ - "HLCM_0311", - "GSE9588 Human Liver Normal (Mar11) Males" - ], - [ - "LV_G_0106_F", - "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Females" - ], - [ - "LV_G_0106_M", - "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Males" - ], - [ - "LV_G_0106_B", - "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Both Sexes" - ], - [ - "GenEx_BXD_liverSal_RMA_F_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Females **" - ], - [ - "GenEx_BXD_liverSal_RMA_M_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Males **" - ], - [ - "GenEx_BXD_liverSal_RMA_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" - ], - [ - "GenEx_BXD_liverEt_RMA_F_0211", - "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Females **" - ], - [ - "GenEx_BXD_liverEt_RMA_M_0211", - "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Males **" - ], - [ - "GenEx_BXD_liverEt_RMA_0211", - "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" - ], - [ - "SUH_Liv_RMA_0611", - "SUH BXD Liver Affy Mouse Gene 1.0 ST (Jun11) RMA **" - ], - [ - "OXUKHS_ILMLiver_RI0510", - "OX UK HS ILM6v1.1 Liver (May 2010) RankInv" - ], - [ - "HXB_Liver_1208", - "MDC/CAS/UCL Liver 230v2 (Dec08) RMA" - ], - [ - "UCLA_CTB6B6CTF2_LIVER_MALE", - "UCLA CTB6B6CTF2 Liver Male mlratio **" - ], - [ - "UCLA_BHF2_LIVER_MALE", - "UCLA BHF2 Liver Male mlratio" - ], - [ - "UCLA_CTB6B6CTF2_LIVER_FEMALE", - "UCLA CTB6B6CTF2 Liver Female mlratio **" - ], - [ - "UCLA_BHHBF2_LIVER_FEMALE", - "UCLA BHHBF2 Liver Female Only" - ], - [ - "UCLA_BHHBF2_LIVER_MALE", - "UCLA BHHBF2 Liver Male Only" - ], - [ - "UCLA_BHF2_LIVER_FEMALE", - "UCLA BHF2 Liver Female mlratio" - ], - [ - "UCLA_BHHBF2_LIVER_2005", - "UCLA BHHBF2 Liver (2005) mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_LIVER_2005", - "UCLA CTB6/B6CTF2 Liver (2005) mlratio **" - ], - [ - "UCLA_BHF2_LIVER_0605", - "UCLA BHF2 Liver (June05) mlratio" - ], - [ - "UCLA_BDF2_LIVER_1999", - "UCLA BDF2 Liver (1999) mlratio" - ], - [ - "LVF2_M_0704_R", - "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) RMA" - ], - [ - "LVF2_M_0704_M", - "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) MAS5" - ], - [ - "HLCF_0311", - "GSE9588 Human Liver Normal (Mar11) Females" - ] - ], - "Phenotypes": [ - [ - "BDF2-1999Publish", - "BDF2-1999 Published Phenotypes" - ] - ] - }, - "BDF2-2005": { - "Genotypes": [ - [ - "BDF2-2005Geno", - "BDF2-2005 Genotypes" - ] - ], - "Phenotypes": [ - [ - "BDF2-2005Publish", - "BDF2-2005 Published Phenotypes" - ] - ], - "Striatum": [ - [ - "DevStriatum_ILM6.2P3RInv_1111", - "BIDMC/UTHSC Dev Striatum P3 ILMv6.2 (Nov11) RankInv **" - ], - [ - "DevStriatum_ILM6.2P14RInv_1111", - "BIDMC/UTHSC Dev Striatum P14 ILMv6.2 (Nov11) RankInv **" - ], - [ - "KIN_YSM_STR_0711", - "KIN/YSM Human STR Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ], - [ - "OHSU_HS-CC_ILMStr_0211", - "OHSU HS-CC Striatum ILM6v1 (Feb11) RankInv" - ], - [ - "UTHSC_Striatum_RankInv_1210", - "HQF BXD Striatum ILM6.1 (Dec10v2) RankInv" - ], - [ - "UTHSC_Str_RankInv_1210", - "HQF BXD Striatum ILM6.1 (Dec10) RankInv" - ], - [ - "UTHSC_1107_RankInv", - "HQF BXD Striatum ILM6.1 (Nov07) RankInv" - ], - [ - "SA_M2_0905_P", - "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) PDNN" - ], - [ - "SA_M2_0905_M", - "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) MAS5" - ], - [ - "SA_M2_0905_R", - "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) RMA" - ], - [ - "SA_M2_0405_MC", - "HBP Rosen Striatum M430V2 (Apr05) MAS5 Clean" - ], - [ - "SA_M2_0405_RC", - "HBP Rosen Striatum M430V2 (Apr05) RMA Clean" - ], - [ - "SA_M2_0405_PC", - "HBP Rosen Striatum M430V2 (Apr05) PDNN Clean" - ], - [ - "SA_M2_0405_SS", - "HBP Rosen Striatum M430V2 (Apr05) SScore" - ], - [ - "SA_M2_0405_RR", - "HBP Rosen Striatum M430V2 (Apr05) RMA Orig" - ], - [ - "Striatum_Exon_0209", - "HQF Striatum Exon (Feb09) RMA" - ], - [ - "DevStriatum_ILM6.2P3RInv_1110", - "BIDMC/UTHSC Dev Striatum P3 ILMv6.2 (Nov10) RankInv **" - ], - [ - "DevStriatum_ILM6.2P14RInv_1110", - "BIDMC/UTHSC Dev Striatum P14 ILMv6.2 (Nov10) RankInv **" - ] - ] - }, - "BHF2": { - "Adipose": [ - [ - "UCLA_BHF2_ADIPOSE_MALE", - "UCLA BHF2 Adipose Male mlratio" - ], - [ - "UCLA_CTB6B6CTF2_ADIPOSE_MALE", - "UCLA CTB6B6CTF2 Adipose Male mlratio **" - ], - [ - "UCLA_BHF2_ADIPOSE_FEMALE", - "UCLA BHF2 Adipose Female mlratio" - ], - [ - "UCLA_CTB6B6CTF2_ADIPOSE_FEMALE", - "UCLA CTB6B6CTF2 Adipose Female mlratio **" - ], - [ - "UCLA_BHHBF2_ADIPOSE_MALE", - "UCLA BHHBF2 Adipose Male Only" - ], - [ - "UCLA_BHHBF2_ADIPOSE_FEMALE", - "UCLA BHHBF2 Adipose Female Only" - ], - [ - "UCLA_BHHBF2_ADIPOSE_2005", - "UCLA BHHBF2 Adipose (2005) mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_ADIPOSE_2005", - "UCLA CTB6/B6CTF2 Adipose (2005) mlratio **" - ], - [ - "UCLA_BHF2_ADIPOSE_0605", - "UCLA BHF2 Adipose (June05) mlratio" - ] - ], - "Brain": [ - [ - "GSE15222_F_N_RI_0409", - "GSE15222 Human Brain Normal Myers (Apr09) RankInv" - ], - [ - "GSE15222_F_A_RI_0409", - "GSE15222 Human Brain Alzheimer Myers (Apr09) RankInv" - ], - [ - "GSE5281_F_RMA_N_0709", - "GSE5281 Human Brain Normal Full Liang (Jul09) RMA" - ], - [ - "GSE5281_F_RMA_Alzh_0709", - "GSE5281 Human Brain Alzheimer Full Liang (Jul09) RMA" - ], - [ - "INIA_MacFas_brain_RMA_0110", - "INIA Macaca fasicularis Brain (Jan10) RMA **" - ], - [ - "GSE15222_F_RI_0409", - "GSE15222 Human Brain Myers (Apr09) RankInv" - ], - [ - "GSE5281_F_RMA0709", - "GSE5281 Human Brain Full Liang (Jul09) RMA" - ], - [ - "GSE5281_RMA0709", - "GSE5281 Human Brain Best 102 Liang (Jul09) RMA" - ], - [ - "UCLA_CTB6B6CTF2_BRAIN_FEMALE", - "UCLA CTB6B6CTF2 Brain Female mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_BRAIN_MALE", - "UCLA CTB6B6CTF2 Brain Male mlratio **" - ], - [ - "UCLA_BHF2_BRAIN_MALE", - "UCLA BHF2 Brain Male mlratio" - ], - [ - "UCLA_BHF2_BRAIN_FEMALE", - "UCLA BHF2 Brain Female mlratio" - ], - [ - "UCLA_BHHBF2_BRAIN_FEMALE", - "UCLA BHHBF2 Brain Female Only" - ], - [ - "UCLA_BHHBF2_BRAIN_MALE", - "UCLA BHHBF2 Brain Male Only" - ], - [ - "UCLA_BHHBF2_BRAIN_2005", - "UCLA BHHBF2 Brain (2005) mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_BRAIN_2005", - "UCLA CTB6/B6CTF2 Brain (2005) mlratio **" - ], - [ - "UCLA_BHF2_BRAIN_0605", - "UCLA BHF2 Brain (June05) mlratio" - ], - [ - "BR_M2_1106_R", - "UCHSC BXD Whole Brain M430 2.0 (Nov06) RMA" - ], - [ - "IBR_M_0606_R", - "INIA Brain mRNA M430 (Jun06) RMA" - ], - [ - "IBR_M_0106_P", - "INIA Brain mRNA M430 (Jan06) PDNN" - ], - [ - "IBR_M_0106_R", - "INIA Brain mRNA M430 (Jan06) RMA" - ], - [ - "BR_U_1105_P", - "UTHSC Brain mRNA U74Av2 (Nov05) PDNN" - ], - [ - "BR_U_0805_M", - "UTHSC Brain mRNA U74Av2 (Aug05) MAS5" - ], - [ - "BR_U_0805_P", - "UTHSC Brain mRNA U74Av2 (Aug05) PDNN" - ], - [ - "BR_U_0805_R", - "UTHSC Brain mRNA U74Av2 (Aug05) RMA" - ], - [ - "BRF2_M_0805_R", - "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) RMA" - ], - [ - "BRF2_M_0805_P", - "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) PDNN" - ], - [ - "BRF2_M_0805_M", - "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) MAS5" - ], - [ - "BRF2_M_0304_P", - "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) PDNN" - ], - [ - "BRF2_M_0304_R", - "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) RMA" - ], - [ - "BRF2_M_0304_M", - "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) MAS5" - ], - [ - "CB_M_0204_P", - "INIA Brain mRNA M430 (Feb04) PDNN" - ] - ], - "Genotypes": [ - [ - "BHF2Geno", - "BHF2 Genotypes" - ] - ], - "Liver": [ - [ - "GSE16780_UCLA_ML0911", - "GSE16780 UCLA Hybrid MDP Liver Affy HT M430A (Sep11) RMA" - ], - [ - "JAX_CSB_L_0711", - "JAX Liver Affy M430 2.0 (Jul11) MDP" - ], - [ - "JAX_CSB_L_HF_0711", - "JAX Liver HF Affy M430 2.0 (Jul11) MDP" - ], - [ - "JAX_CSB_L_6C_0711", - "JAX Liver 6C Affy M430 2.0 (Jul11) MDP" - ], - [ - "HLC_0311", - "GSE9588 Human Liver Normal (Mar11) Both Sexes" - ], - [ - "HLCM_0311", - "GSE9588 Human Liver Normal (Mar11) Males" - ], - [ - "LV_G_0106_F", - "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Females" - ], - [ - "LV_G_0106_M", - "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Males" - ], - [ - "LV_G_0106_B", - "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Both Sexes" - ], - [ - "GenEx_BXD_liverSal_RMA_F_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Females **" - ], - [ - "GenEx_BXD_liverSal_RMA_M_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Males **" - ], - [ - "GenEx_BXD_liverSal_RMA_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" - ], - [ - "GenEx_BXD_liverEt_RMA_F_0211", - "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Females **" - ], - [ - "GenEx_BXD_liverEt_RMA_M_0211", - "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Males **" - ], - [ - "GenEx_BXD_liverEt_RMA_0211", - "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" - ], - [ - "SUH_Liv_RMA_0611", - "SUH BXD Liver Affy Mouse Gene 1.0 ST (Jun11) RMA **" - ], - [ - "OXUKHS_ILMLiver_RI0510", - "OX UK HS ILM6v1.1 Liver (May 2010) RankInv" - ], - [ - "HXB_Liver_1208", - "MDC/CAS/UCL Liver 230v2 (Dec08) RMA" - ], - [ - "UCLA_CTB6B6CTF2_LIVER_MALE", - "UCLA CTB6B6CTF2 Liver Male mlratio **" - ], - [ - "UCLA_BHF2_LIVER_MALE", - "UCLA BHF2 Liver Male mlratio" - ], - [ - "UCLA_CTB6B6CTF2_LIVER_FEMALE", - "UCLA CTB6B6CTF2 Liver Female mlratio **" - ], - [ - "UCLA_BHHBF2_LIVER_FEMALE", - "UCLA BHHBF2 Liver Female Only" - ], - [ - "UCLA_BHHBF2_LIVER_MALE", - "UCLA BHHBF2 Liver Male Only" - ], - [ - "UCLA_BHF2_LIVER_FEMALE", - "UCLA BHF2 Liver Female mlratio" - ], - [ - "UCLA_BHHBF2_LIVER_2005", - "UCLA BHHBF2 Liver (2005) mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_LIVER_2005", - "UCLA CTB6/B6CTF2 Liver (2005) mlratio **" - ], - [ - "UCLA_BHF2_LIVER_0605", - "UCLA BHF2 Liver (June05) mlratio" - ], - [ - "UCLA_BDF2_LIVER_1999", - "UCLA BDF2 Liver (1999) mlratio" - ], - [ - "LVF2_M_0704_R", - "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) RMA" - ], - [ - "LVF2_M_0704_M", - "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) MAS5" - ], - [ - "HLCF_0311", - "GSE9588 Human Liver Normal (Mar11) Females" - ] - ], - "Muscle": [ - [ - "EPFLMouseMuscleRMA1211", - "EPFL/LISP BXD Muscle Affy Mouse Gene 1.0 ST (Dec11) RMA **" - ], - [ - "EPFLMouseMuscleCDRMA1211", - "EPFL/LISP BXD CD Muscle Affy Mouse Gene 1.0 ST (Dec11) RMA **" - ], - [ - "EPFLMouseMuscleHFDRMA1211", - "EPFL/LISP BXD HFD Muscle Affy Mouse Gene 1.0 ST (Dec11) RMA **" - ], - [ - "UCLA_CTB6B6CTF2_MUSCLE_FEMALE", - "UCLA CTB6B6CTF2 Muscle Female mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_MUSCLE_MALE", - "UCLA CTB6B6CTF2 Muscle Male mlratio **" - ], - [ - "UCLA_BHHBF2_MUSCLE_FEMALE", - "UCLA BHHBF2 Muscle Female Only" - ], - [ - "UCLA_BHHBF2_MUSCLE_MALE", - "UCLA BHHBF2 Muscle Male Only" - ], - [ - "UCLA_BHF2_MUSCLE_MALE", - "UCLA BHF2 Muscle Male mlratio **" - ], - [ - "UCLA_BHF2_MUSCLE_FEMALE", - "UCLA BHF2 Muscle Female mlratio **" - ], - [ - "UCLA_BHHBF2_MUSCLE_2005", - "UCLA BHHBF2 Muscle (2005) mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_MUSCLE_2005", - "UCLA CTB6/B6CTF2 Muscle (2005) mlratio **" - ], - [ - "UCLA_BHF2_MUSCLE_0605", - "UCLA BHF2 Muscle (June05) mlratio **" - ] - ], - "Phenotypes": [ - [ - "BHF2Publish", - "BHF2 Published Phenotypes" - ] - ] - }, - "BHHBF2": { - "Adipose": [ - [ - "UCLA_BHF2_ADIPOSE_MALE", - "UCLA BHF2 Adipose Male mlratio" - ], - [ - "UCLA_CTB6B6CTF2_ADIPOSE_MALE", - "UCLA CTB6B6CTF2 Adipose Male mlratio **" - ], - [ - "UCLA_BHF2_ADIPOSE_FEMALE", - "UCLA BHF2 Adipose Female mlratio" - ], - [ - "UCLA_CTB6B6CTF2_ADIPOSE_FEMALE", - "UCLA CTB6B6CTF2 Adipose Female mlratio **" - ], - [ - "UCLA_BHHBF2_ADIPOSE_MALE", - "UCLA BHHBF2 Adipose Male Only" - ], - [ - "UCLA_BHHBF2_ADIPOSE_FEMALE", - "UCLA BHHBF2 Adipose Female Only" - ], - [ - "UCLA_BHHBF2_ADIPOSE_2005", - "UCLA BHHBF2 Adipose (2005) mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_ADIPOSE_2005", - "UCLA CTB6/B6CTF2 Adipose (2005) mlratio **" - ], - [ - "UCLA_BHF2_ADIPOSE_0605", - "UCLA BHF2 Adipose (June05) mlratio" - ] - ], - "Brain": [ - [ - "GSE15222_F_N_RI_0409", - "GSE15222 Human Brain Normal Myers (Apr09) RankInv" - ], - [ - "GSE15222_F_A_RI_0409", - "GSE15222 Human Brain Alzheimer Myers (Apr09) RankInv" - ], - [ - "GSE5281_F_RMA_N_0709", - "GSE5281 Human Brain Normal Full Liang (Jul09) RMA" - ], - [ - "GSE5281_F_RMA_Alzh_0709", - "GSE5281 Human Brain Alzheimer Full Liang (Jul09) RMA" - ], - [ - "INIA_MacFas_brain_RMA_0110", - "INIA Macaca fasicularis Brain (Jan10) RMA **" - ], - [ - "GSE15222_F_RI_0409", - "GSE15222 Human Brain Myers (Apr09) RankInv" - ], - [ - "GSE5281_F_RMA0709", - "GSE5281 Human Brain Full Liang (Jul09) RMA" - ], - [ - "GSE5281_RMA0709", - "GSE5281 Human Brain Best 102 Liang (Jul09) RMA" - ], - [ - "UCLA_CTB6B6CTF2_BRAIN_FEMALE", - "UCLA CTB6B6CTF2 Brain Female mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_BRAIN_MALE", - "UCLA CTB6B6CTF2 Brain Male mlratio **" - ], - [ - "UCLA_BHF2_BRAIN_MALE", - "UCLA BHF2 Brain Male mlratio" - ], - [ - "UCLA_BHF2_BRAIN_FEMALE", - "UCLA BHF2 Brain Female mlratio" - ], - [ - "UCLA_BHHBF2_BRAIN_FEMALE", - "UCLA BHHBF2 Brain Female Only" - ], - [ - "UCLA_BHHBF2_BRAIN_MALE", - "UCLA BHHBF2 Brain Male Only" - ], - [ - "UCLA_BHHBF2_BRAIN_2005", - "UCLA BHHBF2 Brain (2005) mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_BRAIN_2005", - "UCLA CTB6/B6CTF2 Brain (2005) mlratio **" - ], - [ - "UCLA_BHF2_BRAIN_0605", - "UCLA BHF2 Brain (June05) mlratio" - ], - [ - "BR_M2_1106_R", - "UCHSC BXD Whole Brain M430 2.0 (Nov06) RMA" - ], - [ - "IBR_M_0606_R", - "INIA Brain mRNA M430 (Jun06) RMA" - ], - [ - "IBR_M_0106_P", - "INIA Brain mRNA M430 (Jan06) PDNN" - ], - [ - "IBR_M_0106_R", - "INIA Brain mRNA M430 (Jan06) RMA" - ], - [ - "BR_U_1105_P", - "UTHSC Brain mRNA U74Av2 (Nov05) PDNN" - ], - [ - "BR_U_0805_M", - "UTHSC Brain mRNA U74Av2 (Aug05) MAS5" - ], - [ - "BR_U_0805_P", - "UTHSC Brain mRNA U74Av2 (Aug05) PDNN" - ], - [ - "BR_U_0805_R", - "UTHSC Brain mRNA U74Av2 (Aug05) RMA" - ], - [ - "BRF2_M_0805_R", - "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) RMA" - ], - [ - "BRF2_M_0805_P", - "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) PDNN" - ], - [ - "BRF2_M_0805_M", - "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) MAS5" - ], - [ - "BRF2_M_0304_P", - "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) PDNN" - ], - [ - "BRF2_M_0304_R", - "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) RMA" - ], - [ - "BRF2_M_0304_M", - "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) MAS5" - ], - [ - "CB_M_0204_P", - "INIA Brain mRNA M430 (Feb04) PDNN" - ] - ], - "Genotypes": [ - [ - "BHHBF2Geno", - "BHHBF2 Genotypes" - ] - ], - "Liver": [ - [ - "GSE16780_UCLA_ML0911", - "GSE16780 UCLA Hybrid MDP Liver Affy HT M430A (Sep11) RMA" - ], - [ - "JAX_CSB_L_0711", - "JAX Liver Affy M430 2.0 (Jul11) MDP" - ], - [ - "JAX_CSB_L_HF_0711", - "JAX Liver HF Affy M430 2.0 (Jul11) MDP" - ], - [ - "JAX_CSB_L_6C_0711", - "JAX Liver 6C Affy M430 2.0 (Jul11) MDP" - ], - [ - "HLC_0311", - "GSE9588 Human Liver Normal (Mar11) Both Sexes" - ], - [ - "HLCM_0311", - "GSE9588 Human Liver Normal (Mar11) Males" - ], - [ - "LV_G_0106_F", - "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Females" - ], - [ - "LV_G_0106_M", - "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Males" - ], - [ - "LV_G_0106_B", - "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Both Sexes" - ], - [ - "GenEx_BXD_liverSal_RMA_F_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Females **" - ], - [ - "GenEx_BXD_liverSal_RMA_M_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Males **" - ], - [ - "GenEx_BXD_liverSal_RMA_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" - ], - [ - "GenEx_BXD_liverEt_RMA_F_0211", - "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Females **" - ], - [ - "GenEx_BXD_liverEt_RMA_M_0211", - "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Males **" - ], - [ - "GenEx_BXD_liverEt_RMA_0211", - "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" - ], - [ - "SUH_Liv_RMA_0611", - "SUH BXD Liver Affy Mouse Gene 1.0 ST (Jun11) RMA **" - ], - [ - "OXUKHS_ILMLiver_RI0510", - "OX UK HS ILM6v1.1 Liver (May 2010) RankInv" - ], - [ - "HXB_Liver_1208", - "MDC/CAS/UCL Liver 230v2 (Dec08) RMA" - ], - [ - "UCLA_CTB6B6CTF2_LIVER_MALE", - "UCLA CTB6B6CTF2 Liver Male mlratio **" - ], - [ - "UCLA_BHF2_LIVER_MALE", - "UCLA BHF2 Liver Male mlratio" - ], - [ - "UCLA_CTB6B6CTF2_LIVER_FEMALE", - "UCLA CTB6B6CTF2 Liver Female mlratio **" - ], - [ - "UCLA_BHHBF2_LIVER_FEMALE", - "UCLA BHHBF2 Liver Female Only" - ], - [ - "UCLA_BHHBF2_LIVER_MALE", - "UCLA BHHBF2 Liver Male Only" - ], - [ - "UCLA_BHF2_LIVER_FEMALE", - "UCLA BHF2 Liver Female mlratio" - ], - [ - "UCLA_BHHBF2_LIVER_2005", - "UCLA BHHBF2 Liver (2005) mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_LIVER_2005", - "UCLA CTB6/B6CTF2 Liver (2005) mlratio **" - ], - [ - "UCLA_BHF2_LIVER_0605", - "UCLA BHF2 Liver (June05) mlratio" - ], - [ - "UCLA_BDF2_LIVER_1999", - "UCLA BDF2 Liver (1999) mlratio" - ], - [ - "LVF2_M_0704_R", - "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) RMA" - ], - [ - "LVF2_M_0704_M", - "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) MAS5" - ], - [ - "HLCF_0311", - "GSE9588 Human Liver Normal (Mar11) Females" - ] - ], - "Muscle": [ - [ - "EPFLMouseMuscleRMA1211", - "EPFL/LISP BXD Muscle Affy Mouse Gene 1.0 ST (Dec11) RMA **" - ], - [ - "EPFLMouseMuscleCDRMA1211", - "EPFL/LISP BXD CD Muscle Affy Mouse Gene 1.0 ST (Dec11) RMA **" - ], - [ - "EPFLMouseMuscleHFDRMA1211", - "EPFL/LISP BXD HFD Muscle Affy Mouse Gene 1.0 ST (Dec11) RMA **" - ], - [ - "UCLA_CTB6B6CTF2_MUSCLE_FEMALE", - "UCLA CTB6B6CTF2 Muscle Female mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_MUSCLE_MALE", - "UCLA CTB6B6CTF2 Muscle Male mlratio **" - ], - [ - "UCLA_BHHBF2_MUSCLE_FEMALE", - "UCLA BHHBF2 Muscle Female Only" - ], - [ - "UCLA_BHHBF2_MUSCLE_MALE", - "UCLA BHHBF2 Muscle Male Only" - ], - [ - "UCLA_BHF2_MUSCLE_MALE", - "UCLA BHF2 Muscle Male mlratio **" - ], - [ - "UCLA_BHF2_MUSCLE_FEMALE", - "UCLA BHF2 Muscle Female mlratio **" - ], - [ - "UCLA_BHHBF2_MUSCLE_2005", - "UCLA BHHBF2 Muscle (2005) mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_MUSCLE_2005", - "UCLA CTB6/B6CTF2 Muscle (2005) mlratio **" - ], - [ - "UCLA_BHF2_MUSCLE_0605", - "UCLA BHF2 Muscle (June05) mlratio **" - ] - ], - "Phenotypes": [ - [ - "BHHBF2Publish", - "BHHBF2 Published Phenotypes" - ] - ] - }, - "BXD": { - "Amygdala": [ - [ - "KIN_YSM_AMY_0711", - "KIN/YSM Human AMY Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ], - [ - "INIA_AmgCoh_0311", - "INIA Amygdala Cohort Affy MoGene 1.0 ST (Mar11) RMA" - ], - [ - "INIA_Amg_BLA_RMA_1110", - "INIA Amygdala Affy MoGene 1.0 ST (Nov10) RMA" - ], - [ - "INIA_Amg_BLA_RMA_M_1110", - "INIA Amygdala Affy MoGene 1.0 ST (Nov10) RMA Male" - ], - [ - "INIA_Amg_BLA_RMA_F_1110", - "INIA Amygdala Affy MoGene 1.0 ST (Nov10) RMA Female" - ], - [ - "INIA_MacFas_AMGc_RMA_0110", - "INIA Macaca fasicularis Amygdala control (Jan10) RMA **" - ], - [ - "INIA_MacFas_AMGe_RMA_0110", - "INIA Macaca fasicularis Amygdala ethanol (Jan10) RMA **" - ] - ], - "Brain": [ - [ - "GSE15222_F_N_RI_0409", - "GSE15222 Human Brain Normal Myers (Apr09) RankInv" - ], - [ - "GSE15222_F_A_RI_0409", - "GSE15222 Human Brain Alzheimer Myers (Apr09) RankInv" - ], - [ - "GSE5281_F_RMA_N_0709", - "GSE5281 Human Brain Normal Full Liang (Jul09) RMA" - ], - [ - "GSE5281_F_RMA_Alzh_0709", - "GSE5281 Human Brain Alzheimer Full Liang (Jul09) RMA" - ], - [ - "INIA_MacFas_brain_RMA_0110", - "INIA Macaca fasicularis Brain (Jan10) RMA **" - ], - [ - "GSE15222_F_RI_0409", - "GSE15222 Human Brain Myers (Apr09) RankInv" - ], - [ - "GSE5281_F_RMA0709", - "GSE5281 Human Brain Full Liang (Jul09) RMA" - ], - [ - "GSE5281_RMA0709", - "GSE5281 Human Brain Best 102 Liang (Jul09) RMA" - ], - [ - "UCLA_CTB6B6CTF2_BRAIN_FEMALE", - "UCLA CTB6B6CTF2 Brain Female mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_BRAIN_MALE", - "UCLA CTB6B6CTF2 Brain Male mlratio **" - ], - [ - "UCLA_BHF2_BRAIN_MALE", - "UCLA BHF2 Brain Male mlratio" - ], - [ - "UCLA_BHF2_BRAIN_FEMALE", - "UCLA BHF2 Brain Female mlratio" - ], - [ - "UCLA_BHHBF2_BRAIN_FEMALE", - "UCLA BHHBF2 Brain Female Only" - ], - [ - "UCLA_BHHBF2_BRAIN_MALE", - "UCLA BHHBF2 Brain Male Only" - ], - [ - "UCLA_BHHBF2_BRAIN_2005", - "UCLA BHHBF2 Brain (2005) mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_BRAIN_2005", - "UCLA CTB6/B6CTF2 Brain (2005) mlratio **" - ], - [ - "UCLA_BHF2_BRAIN_0605", - "UCLA BHF2 Brain (June05) mlratio" - ], - [ - "BR_M2_1106_R", - "UCHSC BXD Whole Brain M430 2.0 (Nov06) RMA" - ], - [ - "IBR_M_0606_R", - "INIA Brain mRNA M430 (Jun06) RMA" - ], - [ - "IBR_M_0106_P", - "INIA Brain mRNA M430 (Jan06) PDNN" - ], - [ - "IBR_M_0106_R", - "INIA Brain mRNA M430 (Jan06) RMA" - ], - [ - "BR_U_1105_P", - "UTHSC Brain mRNA U74Av2 (Nov05) PDNN" - ], - [ - "BR_U_0805_M", - "UTHSC Brain mRNA U74Av2 (Aug05) MAS5" - ], - [ - "BR_U_0805_P", - "UTHSC Brain mRNA U74Av2 (Aug05) PDNN" - ], - [ - "BR_U_0805_R", - "UTHSC Brain mRNA U74Av2 (Aug05) RMA" - ], - [ - "BRF2_M_0805_R", - "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) RMA" - ], - [ - "BRF2_M_0805_P", - "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) PDNN" - ], - [ - "BRF2_M_0805_M", - "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) MAS5" - ], - [ - "BRF2_M_0304_P", - "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) PDNN" - ], - [ - "BRF2_M_0304_R", - "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) RMA" - ], - [ - "BRF2_M_0304_M", - "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) MAS5" - ], - [ - "CB_M_0204_P", - "INIA Brain mRNA M430 (Feb04) PDNN" - ] - ], - "Cartilage": [ - [ - "UCLA_BXDBXH_CARTILAGE_V2", - "UCLA BXD and BXH Cartilage v2" - ], - [ - "UCLA_BXHBXD_CARTILAGE_V2", - "UCLA BXH and BXD Cartilage v2" - ], - [ - "UCLA_BXDBXH_CARTILAGE", - "UCLA BXD and BXH Cartilage" - ], - [ - "UCLA_BXHBXD_CARTILAGE", - "UCLA BXH and BXD Cartilage" - ], - [ - "UCLA_BXD_CARTILAGE", - "UCLA BXD Cartilage" - ], - [ - "UCLA_BXH_CARTILAGE", - "UCLA BXH Cartilage" - ] - ], - "Cerebellum": [ - [ - "HBTRC-MLC_0611", - "HBTRC-MLC Human Cerebellum Agilent (Jun11) mlratio" - ], - [ - "HBTRC-MLC_N_0611", - "HBTRC-MLC Human Cerebellum Agilent Normal (Jun11) mlratio" - ], - [ - "HBTRC-MLC_AD_0611", - "HBTRC-MLC Human Cerebellum Agilent AD (Jun11) mlratio" - ], - [ - "HBTRC-MLC_HD_0611", - "HBTRC-MLC Human Cerebellum Agilent HD (Jun11) mlratio" - ], - [ - "GCB_M2_0505_M", - "GE-NIAAA Cerebellum mRNA M430v2 (May05) MAS5" - ], - [ - "GCB_M2_0505_R", - "GE-NIAAA Cerebellum mRNA M430v2 (May05) RMA" - ], - [ - "GCB_M2_0505_P", - "GE-NIAAA Cerebellum mRNA M430v2 (May05) PDNN" - ], - [ - "CB_M_0305_R", - "SJUT Cerebellum mRNA M430 (Mar05) RMA" - ], - [ - "CB_M_0305_M", - "SJUT Cerebellum mRNA M430 (Mar05) MAS5" - ], - [ - "CB_M_0305_P", - "SJUT Cerebellum mRNA M430 (Mar05) PDNN" - ], - [ - "CB_M_1004_R", - "SJUT Cerebellum mRNA M430 (Oct04) RMA" - ], - [ - "CB_M_1004_M", - "SJUT Cerebellum mRNA M430 (Oct04) MAS5" - ], - [ - "CB_M_1004_P", - "SJUT Cerebellum mRNA M430 (Oct04) PDNN" - ], - [ - "CB_M_1003_M", - "SJUT Cerebellum mRNA M430 (Oct03) MAS5" - ] - ], - "Eye": [ - [ - "Eye_AXBXA_1008_RankInv", - "Eye AXBXA Illumina V6.2(Oct08) RankInv Beta" - ], - [ - "Eye_M2_0908_R", - "Eye M430v2 (Sep08) RMA" - ], - [ - "Eye_M2_0908_R_NB", - "Eye M430v2 Mutant Gpnmb (Sep08) RMA **" - ], - [ - "Eye_M2_0908_R_ND", - "Eye M430v2 WT Gpnmb (Sep08) RMA **" - ], - [ - "Eye_M2_0908_WTWT", - "Eye M430v2 WT WT (Sep08) RMA **" - ], - [ - "Eye_M2_0908_R_WT", - "Eye M430v2 WT Tyrp1 (Sep08) RMA **" - ], - [ - "Eye_M2_0908_R_MT", - "Eye M430v2 Mutant Tyrp1 (Sep08) RMA **" - ], - [ - "BXD_GLA_0911", - "BXD Glaucoma Affy M430 2.0 Trial (Sep11) RMA **" - ], - [ - "UIOWA_Eye_RMA_0906", - "UIOWA Eye mRNA RAE230v2 (Sep06) RMA" - ] - ], - "Genotypes": [ - [ - "BXDGeno", - "BXD Genotypes" - ] - ], - "Hematopoietic Cells": [ - [ - "UMCG_0907_HemaStem_ori", - "UMCG Stem Cells ILM6v1.1 (Apr09) original" - ], - [ - "UMCG_0907_HemaStem", - "UMCG Stem Cells ILM6v1.1 (Apr09) transformed" - ], - [ - "UMCG_0907_Pro_ori", - "UMCG Progenitor Cells ILM6v1.1 (Apr09) original" - ], - [ - "UMCG_0907_Pro", - "UMCG Progenitor Cells ILM6v1.1 (Apr09) transformed" - ], - [ - "UMCG_0907_Eryth_ori", - "UMCG Erythroid Cells ILM6v1.1 (Apr09) original" - ], - [ - "UMCG_0907_Eryth", - "UMCG Erythroid Cells ILM6v1.1 (Apr09) transformed" - ], - [ - "UMCG_0907_Myeloid_ori", - "UMCG Myeloid Cells ILM6v1.1 (Apr09) original" - ], - [ - "UMCG_0907_Myeloid", - "UMCG Myeloid Cells ILM6v1.1 (Apr09) transformed" - ], - [ - "HC_U_0304_R", - "GNF Stem Cells U74Av2 (Mar04) RMA" - ] - ], - "Hippocampus": [ - [ - "KIN_YSM_HIP_0711", - "KIN/YSM Human HIP Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ], - [ - "UMUTAffyExon_0209_RMA_MDP", - "UMUTAffy Hippocampus Exon (Feb09) RMA MDP" - ], - [ - "HC_M2_0606_MDP", - "Hippocampus Consortium M430v2 (Jun06) RMA MDP" - ], - [ - "OXUKHS_ILMHipp_RI0510", - "OX UK HS ILM6v1.1 Hippocampus (May 2010) RankInv" - ], - [ - "INIA_MacFas_Hc_RMA_0110", - "INIA Macaca fasicularis Hippocampus control (Jan10) RMA **" - ], - [ - "INIA_MacFas_He_RMA_0110", - "INIA Macaca fasicularis Hippocampus ethanol (Jan10) RMA **" - ], - [ - "UT_HippRatEx_RMA_0709", - "UT Hippocampus Affy RaEx 1.0 Exon (Jul09) RMA" - ], - [ - "Illum_LXS_Hipp_loess0807", - "Hippocampus Illumina (Aug07) LOESS" - ], - [ - "Illum_LXS_Hipp_loess_nb0807", - "Hippocampus Illumina (Aug07) LOESS_NB" - ], - [ - "Illum_LXS_Hipp_quant0807", - "Hippocampus Illumina (Aug07) QUANT" - ], - [ - "Illum_LXS_Hipp_quant_nb0807", - "Hippocampus Illumina (Aug07) QUANT_NB" - ], - [ - "Illum_LXS_Hipp_rsn0807", - "Hippocampus Illumina (Aug07) RSN" - ], - [ - "Illum_LXS_Hipp_rsn_nb0807", - "Hippocampus Illumina (Aug07) RSN_NB" - ], - [ - "Hipp_Illumina_RankInv_0507", - "Hippocampus Illumina (May07) RankInv" - ], - [ - "HC_M2_0606_P", - "Hippocampus Consortium M430v2 (Jun06) PDNN" - ], - [ - "HC_M2_0606_M", - "Hippocampus Consortium M430v2 (Jun06) MAS5" - ], - [ - "HC_M2_0606_R", - "Hippocampus Consortium M430v2 (Jun06) RMA" - ], - [ - "HC_M2CB_1205_R", - "Hippocampus Consortium M430v2 CXB (Dec05) RMA" - ], - [ - "HC_M2CB_1205_P", - "Hippocampus Consortium M430v2 CXB (Dec05) PDNN" - ], - [ - "UMUTAffyExon_0209_RMA", - "UMUTAffy Hippocampus Exon (Feb09) RMA" - ], - [ - "UT_ILM_BXD_hipp_NON_0909", - "UTHSC Hippocampus Illumina v6.1 NON (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_NOS_0909", - "UTHSC Hippocampus Illumina v6.1 NOS (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_NOE_0909", - "UTHSC Hippocampus Illumina v6.1 NOE (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_RSS_0909", - "UTHSC Hippocampus Illumina v6.1 RSS (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_RSE_0909", - "UTHSC Hippocampus Illumina v6.1 RSE (Sep09) RankInv" - ], - [ - "Illum_LXS_Hipp_RSE_1008", - "Hippocampus Illumina RSE (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_NOS_1008", - "Hippocampus Illumina NOS (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_NOE_1008", - "Hippocampus Illumina NOE (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_RSS_1008", - "Hippocampus Illumina RSS (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_NON_1008", - "Hippocampus Illumina NON (Oct08) RankInv beta" - ] - ], - "Hypothalamus": [ - [ - "INIA_Hyp_RMA_1110", - "INIA Hypothalamus Affy MoGene 1.0 ST (Nov10)" - ], - [ - "INIA_Hyp_M_RMA_1110", - "INIA Hypothalamus Affy MoGene 1.0 ST (Nov10) Male" - ], - [ - "INIA_Hyp_F_RMA_1110", - "INIA Hypothalamus Affy MoGene 1.0 ST (Nov10) Female" - ] - ], - "Kidney": [ - [ - "MA_M2F_0706_R", - "Mouse kidney M430v2 Female (Aug06) RMA" - ], - [ - "MA_M2M_0706_R", - "Mouse kidney M430v2 Male (Aug06) RMA" - ], - [ - "MA_M2_0806_R", - "Mouse kidney M430v2 Sex Balanced (Aug06) RMA" - ], - [ - "MA_M2_0806_P", - "Mouse Kidney M430v2 Sex Balanced (Aug06) PDNN" - ], - [ - "MA_M2_0706_P", - "Mouse Kidney M430v2 (Jul06) PDNN" - ], - [ - "MA_M2_0706_R", - "Mouse Kidney M430v2 (Jul06) RMA" - ], - [ - "KI_2A_0405_M", - "MDC/CAS/ICL Kidney 230A (Apr05) MAS5" - ], - [ - "KI_2A_0405_Rz", - "MDC/CAS/ICL Kidney 230A (Apr05) RMA 2z+8" - ], - [ - "KI_2A_0405_R", - "MDC/CAS/ICL Kidney 230A (Apr05) RMA" - ] - ], - "Leucocytes": [ - [ - "Illum_BXD_PBL_1108", - "UWA Illumina PBL (Nov08) RSN **" - ] - ], - "Liver": [ - [ - "GSE16780_UCLA_ML0911", - "GSE16780 UCLA Hybrid MDP Liver Affy HT M430A (Sep11) RMA" - ], - [ - "JAX_CSB_L_0711", - "JAX Liver Affy M430 2.0 (Jul11) MDP" - ], - [ - "JAX_CSB_L_HF_0711", - "JAX Liver HF Affy M430 2.0 (Jul11) MDP" - ], - [ - "JAX_CSB_L_6C_0711", - "JAX Liver 6C Affy M430 2.0 (Jul11) MDP" - ], - [ - "HLC_0311", - "GSE9588 Human Liver Normal (Mar11) Both Sexes" - ], - [ - "HLCM_0311", - "GSE9588 Human Liver Normal (Mar11) Males" - ], - [ - "LV_G_0106_F", - "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Females" - ], - [ - "LV_G_0106_M", - "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Males" - ], - [ - "LV_G_0106_B", - "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Both Sexes" - ], - [ - "GenEx_BXD_liverSal_RMA_F_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Females **" - ], - [ - "GenEx_BXD_liverSal_RMA_M_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Males **" - ], - [ - "GenEx_BXD_liverSal_RMA_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" - ], - [ - "GenEx_BXD_liverEt_RMA_F_0211", - "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Females **" - ], - [ - "GenEx_BXD_liverEt_RMA_M_0211", - "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Males **" - ], - [ - "GenEx_BXD_liverEt_RMA_0211", - "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" - ], - [ - "SUH_Liv_RMA_0611", - "SUH BXD Liver Affy Mouse Gene 1.0 ST (Jun11) RMA **" - ], - [ - "OXUKHS_ILMLiver_RI0510", - "OX UK HS ILM6v1.1 Liver (May 2010) RankInv" - ], - [ - "HXB_Liver_1208", - "MDC/CAS/UCL Liver 230v2 (Dec08) RMA" - ], - [ - "UCLA_CTB6B6CTF2_LIVER_MALE", - "UCLA CTB6B6CTF2 Liver Male mlratio **" - ], - [ - "UCLA_BHF2_LIVER_MALE", - "UCLA BHF2 Liver Male mlratio" - ], - [ - "UCLA_CTB6B6CTF2_LIVER_FEMALE", - "UCLA CTB6B6CTF2 Liver Female mlratio **" - ], - [ - "UCLA_BHHBF2_LIVER_FEMALE", - "UCLA BHHBF2 Liver Female Only" - ], - [ - "UCLA_BHHBF2_LIVER_MALE", - "UCLA BHHBF2 Liver Male Only" - ], - [ - "UCLA_BHF2_LIVER_FEMALE", - "UCLA BHF2 Liver Female mlratio" - ], - [ - "UCLA_BHHBF2_LIVER_2005", - "UCLA BHHBF2 Liver (2005) mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_LIVER_2005", - "UCLA CTB6/B6CTF2 Liver (2005) mlratio **" - ], - [ - "UCLA_BHF2_LIVER_0605", - "UCLA BHF2 Liver (June05) mlratio" - ], - [ - "UCLA_BDF2_LIVER_1999", - "UCLA BDF2 Liver (1999) mlratio" - ], - [ - "LVF2_M_0704_R", - "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) RMA" - ], - [ - "LVF2_M_0704_M", - "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) MAS5" - ], - [ - "HLCF_0311", - "GSE9588 Human Liver Normal (Mar11) Females" - ] - ], - "Lung": [ - [ - "OXUKHS_ILMLung_RI0510", - "OX UK HS ILM6v1.1 Lung (May 2010) RankInv" - ], - [ - "HZI_0408_R", - "HZI Lung M430v2 (Apr08) RMA" - ], - [ - "HZI_0408_M", - "HZI Lung M430v2 (Apr08) MAS5" - ] - ], - "Midbrain": [ - [ - "VUBXDMouseMidBrainQ0212", - "VU BXD Midbrain Agilent SurePrint G3 Mouse GE (Feb12) Quantile" - ] - ], - "Muscle": [ - [ - "EPFLMouseMuscleRMA1211", - "EPFL/LISP BXD Muscle Affy Mouse Gene 1.0 ST (Dec11) RMA **" - ], - [ - "EPFLMouseMuscleCDRMA1211", - "EPFL/LISP BXD CD Muscle Affy Mouse Gene 1.0 ST (Dec11) RMA **" - ], - [ - "EPFLMouseMuscleHFDRMA1211", - "EPFL/LISP BXD HFD Muscle Affy Mouse Gene 1.0 ST (Dec11) RMA **" - ], - [ - "UCLA_CTB6B6CTF2_MUSCLE_FEMALE", - "UCLA CTB6B6CTF2 Muscle Female mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_MUSCLE_MALE", - "UCLA CTB6B6CTF2 Muscle Male mlratio **" - ], - [ - "UCLA_BHHBF2_MUSCLE_FEMALE", - "UCLA BHHBF2 Muscle Female Only" - ], - [ - "UCLA_BHHBF2_MUSCLE_MALE", - "UCLA BHHBF2 Muscle Male Only" - ], - [ - "UCLA_BHF2_MUSCLE_MALE", - "UCLA BHF2 Muscle Male mlratio **" - ], - [ - "UCLA_BHF2_MUSCLE_FEMALE", - "UCLA BHF2 Muscle Female mlratio **" - ], - [ - "UCLA_BHHBF2_MUSCLE_2005", - "UCLA BHHBF2 Muscle (2005) mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_MUSCLE_2005", - "UCLA CTB6/B6CTF2 Muscle (2005) mlratio **" - ], - [ - "UCLA_BHF2_MUSCLE_0605", - "UCLA BHF2 Muscle (June05) mlratio **" - ] - ], - "Neocortex": [ - [ - "DevNeocortex_ILM6.2P14RInv_1111", - "BIDMC/UTHSC Dev Neocortex P14 ILMv6.2 (Nov11) RankInv **" - ], - [ - "DevNeocortex_ILM6.2P3RInv_1111", - "BIDMC/UTHSC Dev Neocortex P3 ILMv6.2 (Nov11) RankInv **" - ], - [ - "HQFNeoc_1210v2_RankInv", - "HQF BXD Neocortex ILM6v1.1 (Dec10v2) RankInv" - ], - [ - "HQFNeoc_1210_RankInv", - "HQF BXD Neocortex ILM6v1.1 (Dec10) RankInv" - ], - [ - "HQFNeoc_0208_RankInv", - "HQF BXD Neocortex ILM6v1.1 (Feb08) RankInv" - ], - [ - "DevNeocortex_ILM6.2P3RInv_1110", - "BIDMC/UTHSC Dev Neocortex P3 ILMv6.2 (Nov10) RankInv **" - ], - [ - "DevNeocortex_ILM6.2P14RInv_1110", - "BIDMC/UTHSC Dev Neocortex P14 ILMv6.2 (Nov10) RankInv **" - ] - ], - "Nucleus Accumbens": [ - [ - "INIA_MacFas_Ac_RMA_0110", - "INIA Macaca fasicularis Nucleus Accumbens control (Jan10) RMA **" - ], - [ - "INIA_MacFas_Ae_RMA_0110", - "INIA Macaca fasicularis Nucleus Accumbens ethanol (Jan10) RMA **" - ], - [ - "VCUSalo_1007_R", - "VCU BXD NA Sal M430 2.0 (Oct07) RMA" - ], - [ - "VCUEtOH_1007_R", - "VCU BXD NA EtOH M430 2.0 (Oct07) RMA **" - ], - [ - "VCUSal_1007_R", - "VCU BXD NA Et vs Sal M430 2.0 (Oct07) Sscore **" - ] - ], - "Phenotypes": [ - [ - "BXDPublish", - "BXD Published Phenotypes" - ] - ], - "Prefrontal Cortex": [ - [ - "HBTRC-MLPFC_0611", - "HBTRC-MLC Human Prefrontal Cortex Agilent (Jun11) mlratio" - ], - [ - "HBTRC-MLPFC_N_0611", - "HBTRC-MLC Human Prefrontal Cortex Agilent Normal (Jun11) mlratio" - ], - [ - "HBTRC-MLPFC_AD_0611", - "HBTRC-MLC Human Prefrontal Cortex Agilent AD (Jun11) mlratio" - ], - [ - "HBTRC-MLPFC_HD_0611", - "HBTRC-MLC Human Prefrontal Cortex Agilent HD (Jun11) mlratio" - ], - [ - "INIA_MacFas_Pf_RMA_0110", - "INIA Macaca fasicularis Prefrontal Cortex control (Jan10) RMA **" - ], - [ - "INIA_MacFas_PfE_RMA_0110", - "INIA Macaca fasicularis Prefrontal Cortex ethanol (Jan10) RMA **" - ], - [ - "VCUSal_1006_R", - "VCU BXD PFC Et vs Sal M430 2.0 (Dec06) Sscore" - ], - [ - "VCUEtOH_1206_R", - "VCU BXD PFC EtOH M430 2.0 (Dec06) RMA" - ], - [ - "VCUSal_1206_R", - "VCU BXD PFC Sal M430 2.0 (Dec06) RMA" - ], - [ - "VCU_PF_Air_0111_R", - "VCU BXD PFC CIE Air M430 2.0 (Jan11) RMA **" - ], - [ - "VCU_PF_Et_0111_R", - "VCU BXD PFC CIE EtOH M430 2.0 (Jan11) RMA **" - ], - [ - "VCU_PF_AvE_0111_Ss", - "VCU BXD PFC EtOH vs CIE Air M430 2.0 (Jan11) Sscore **" - ], - [ - "VCUEt_vs_Sal_0806_R", - "VCU LXS PFC Et vs Sal M430A 2.0 (Aug06) Sscore **" - ], - [ - "VCUEtOH_0806_R", - "VCU LXS PFC EtOH M430A 2.0 (Aug06) RMA **" - ], - [ - "VCUSal_0806_R", - "VCU LXS PFC Sal M430A 2.0 (Aug06) RMA" - ] - ], - "Retina": [ - [ - "Illum_Retina_BXD_RankInv0410", - "HEI Retina Illumina V6.2 (April 2010) RankInv" - ], - [ - "B6D2ONCILM_0412", - "B6D2 ONC Illumina v6.1 (Apr12) RankInv **" - ], - [ - "ONCRetILM6_0412", - "ONC Retina Illumina V6.2 (Apr12) RankInv **" - ], - [ - "G2HEIONCRetILM6_0911", - "G2 HEI ONC Retina Illumina V6.2 (Sep11) RankInv **" - ], - [ - "HEIONCRetILM6_0911", - "HEI ONC Retina Illumina V6.2 (Sep11) RankInv **" - ], - [ - "HEIONCvsCRetILM6_0911", - "HEI ONC vs Control Retina Illumina V6.2 (Sep11) RankInv **" - ], - [ - "ILM_Retina_BXD_F_RankInv1210", - "HEI Retina Females Illumina V6.2 (Dec10) RankInv **" - ], - [ - "ILM_Retina_BXD_M_RankInv1210", - "HEI Retina Males Illumina V6.2 (Dec10) RankInv **" - ], - [ - "ILM_Retina_BXD_FM_RankInv1210", - "HEI Retina F-M Illumina V6.2 (Dec10) RankInv **" - ], - [ - "G2NEI_ILM_Retina_BXD_RI0410", - "G2NEI Retina Illumina V6.2 (April 2010) RankInv **" - ] - ], - "Spleen": [ - [ - "UTHSC_SPL_RMA_1210", - "UTHSC Affy MoGene 1.0 ST Spleen (Dec10) RMA" - ], - [ - "UTHSC_SPL_RMA_1010", - "UTHSC Affy MoGene 1.0 ST Spleen (Oct10) RMA" - ], - [ - "IoP_SPL_RMA_0509", - "IoP Affy MOE 430v2 Spleen (May09) RMA" - ], - [ - "Illum_BXD_Spl_1108", - "UWA Illumina Spleen (Nov08) RSN **" - ], - [ - "UTK_BXDSpl_VST_0110", - "UTK Spleen ILM6.1 (Jan10) VST" - ], - [ - "STSPL_1107_R", - "Stuart Spleen M430v2 (Nov07) RMA" - ] - ], - "Striatum": [ - [ - "DevStriatum_ILM6.2P3RInv_1111", - "BIDMC/UTHSC Dev Striatum P3 ILMv6.2 (Nov11) RankInv **" - ], - [ - "DevStriatum_ILM6.2P14RInv_1111", - "BIDMC/UTHSC Dev Striatum P14 ILMv6.2 (Nov11) RankInv **" - ], - [ - "KIN_YSM_STR_0711", - "KIN/YSM Human STR Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ], - [ - "OHSU_HS-CC_ILMStr_0211", - "OHSU HS-CC Striatum ILM6v1 (Feb11) RankInv" - ], - [ - "UTHSC_Striatum_RankInv_1210", - "HQF BXD Striatum ILM6.1 (Dec10v2) RankInv" - ], - [ - "UTHSC_Str_RankInv_1210", - "HQF BXD Striatum ILM6.1 (Dec10) RankInv" - ], - [ - "UTHSC_1107_RankInv", - "HQF BXD Striatum ILM6.1 (Nov07) RankInv" - ], - [ - "SA_M2_0905_P", - "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) PDNN" - ], - [ - "SA_M2_0905_M", - "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) MAS5" - ], - [ - "SA_M2_0905_R", - "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) RMA" - ], - [ - "SA_M2_0405_MC", - "HBP Rosen Striatum M430V2 (Apr05) MAS5 Clean" - ], - [ - "SA_M2_0405_RC", - "HBP Rosen Striatum M430V2 (Apr05) RMA Clean" - ], - [ - "SA_M2_0405_PC", - "HBP Rosen Striatum M430V2 (Apr05) PDNN Clean" - ], - [ - "SA_M2_0405_SS", - "HBP Rosen Striatum M430V2 (Apr05) SScore" - ], - [ - "SA_M2_0405_RR", - "HBP Rosen Striatum M430V2 (Apr05) RMA Orig" - ], - [ - "Striatum_Exon_0209", - "HQF Striatum Exon (Feb09) RMA" - ], - [ - "DevStriatum_ILM6.2P3RInv_1110", - "BIDMC/UTHSC Dev Striatum P3 ILMv6.2 (Nov10) RankInv **" - ], - [ - "DevStriatum_ILM6.2P14RInv_1110", - "BIDMC/UTHSC Dev Striatum P14 ILMv6.2 (Nov10) RankInv **" - ] - ], - "T Cell (helper)": [ - [ - "RTHC_0211_R", - "HZI Thelp M430v2 (Feb11) RMA" - ] - ], - "T Cell (regulatory)": [ - [ - "RTC_1106_R", - "HZI Treg M430v2 (Feb11) RMA" - ] - ], - "Thymus": [ - [ - "Illum_BXD_Thy_1108", - "UWA Illumina Thymus (Nov08) RSN **" - ] - ], - "Ventral Tegmental Area": [ - [ - "VCUEtvsSal_0609_R", - "VCU BXD VTA Et vs Sal M430 2.0 (Jun09) Sscore **" - ], - [ - "VCUEtOH_0609_R", - "VCU BXD VTA EtOH M430 2.0 (Jun09) RMA **" - ], - [ - "VCUSal_0609_R", - "VCU BXD VTA Sal M430 2.0 (Jun09) RMA **" - ] - ] - }, - "BXH": { - "Cartilage": [ - [ - "UCLA_BXDBXH_CARTILAGE_V2", - "UCLA BXD and BXH Cartilage v2" - ], - [ - "UCLA_BXHBXD_CARTILAGE_V2", - "UCLA BXH and BXD Cartilage v2" - ], - [ - "UCLA_BXDBXH_CARTILAGE", - "UCLA BXD and BXH Cartilage" - ], - [ - "UCLA_BXHBXD_CARTILAGE", - "UCLA BXH and BXD Cartilage" - ], - [ - "UCLA_BXD_CARTILAGE", - "UCLA BXD Cartilage" - ], - [ - "UCLA_BXH_CARTILAGE", - "UCLA BXH Cartilage" - ] - ], - "Genotypes": [ - [ - "BXHGeno", - "BXH Genotypes" - ] - ], - "Phenotypes": [ - [ - "BXHPublish", - "BXH Published Phenotypes" - ] - ] - }, - "CTB6F2": { - "Adipose": [ - [ - "UCLA_BHF2_ADIPOSE_MALE", - "UCLA BHF2 Adipose Male mlratio" - ], - [ - "UCLA_CTB6B6CTF2_ADIPOSE_MALE", - "UCLA CTB6B6CTF2 Adipose Male mlratio **" - ], - [ - "UCLA_BHF2_ADIPOSE_FEMALE", - "UCLA BHF2 Adipose Female mlratio" - ], - [ - "UCLA_CTB6B6CTF2_ADIPOSE_FEMALE", - "UCLA CTB6B6CTF2 Adipose Female mlratio **" - ], - [ - "UCLA_BHHBF2_ADIPOSE_MALE", - "UCLA BHHBF2 Adipose Male Only" - ], - [ - "UCLA_BHHBF2_ADIPOSE_FEMALE", - "UCLA BHHBF2 Adipose Female Only" - ], - [ - "UCLA_BHHBF2_ADIPOSE_2005", - "UCLA BHHBF2 Adipose (2005) mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_ADIPOSE_2005", - "UCLA CTB6/B6CTF2 Adipose (2005) mlratio **" - ], - [ - "UCLA_BHF2_ADIPOSE_0605", - "UCLA BHF2 Adipose (June05) mlratio" - ] - ], - "Brain": [ - [ - "GSE15222_F_N_RI_0409", - "GSE15222 Human Brain Normal Myers (Apr09) RankInv" - ], - [ - "GSE15222_F_A_RI_0409", - "GSE15222 Human Brain Alzheimer Myers (Apr09) RankInv" - ], - [ - "GSE5281_F_RMA_N_0709", - "GSE5281 Human Brain Normal Full Liang (Jul09) RMA" - ], - [ - "GSE5281_F_RMA_Alzh_0709", - "GSE5281 Human Brain Alzheimer Full Liang (Jul09) RMA" - ], - [ - "INIA_MacFas_brain_RMA_0110", - "INIA Macaca fasicularis Brain (Jan10) RMA **" - ], - [ - "GSE15222_F_RI_0409", - "GSE15222 Human Brain Myers (Apr09) RankInv" - ], - [ - "GSE5281_F_RMA0709", - "GSE5281 Human Brain Full Liang (Jul09) RMA" - ], - [ - "GSE5281_RMA0709", - "GSE5281 Human Brain Best 102 Liang (Jul09) RMA" - ], - [ - "UCLA_CTB6B6CTF2_BRAIN_FEMALE", - "UCLA CTB6B6CTF2 Brain Female mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_BRAIN_MALE", - "UCLA CTB6B6CTF2 Brain Male mlratio **" - ], - [ - "UCLA_BHF2_BRAIN_MALE", - "UCLA BHF2 Brain Male mlratio" - ], - [ - "UCLA_BHF2_BRAIN_FEMALE", - "UCLA BHF2 Brain Female mlratio" - ], - [ - "UCLA_BHHBF2_BRAIN_FEMALE", - "UCLA BHHBF2 Brain Female Only" - ], - [ - "UCLA_BHHBF2_BRAIN_MALE", - "UCLA BHHBF2 Brain Male Only" - ], - [ - "UCLA_BHHBF2_BRAIN_2005", - "UCLA BHHBF2 Brain (2005) mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_BRAIN_2005", - "UCLA CTB6/B6CTF2 Brain (2005) mlratio **" - ], - [ - "UCLA_BHF2_BRAIN_0605", - "UCLA BHF2 Brain (June05) mlratio" - ], - [ - "BR_M2_1106_R", - "UCHSC BXD Whole Brain M430 2.0 (Nov06) RMA" - ], - [ - "IBR_M_0606_R", - "INIA Brain mRNA M430 (Jun06) RMA" - ], - [ - "IBR_M_0106_P", - "INIA Brain mRNA M430 (Jan06) PDNN" - ], - [ - "IBR_M_0106_R", - "INIA Brain mRNA M430 (Jan06) RMA" - ], - [ - "BR_U_1105_P", - "UTHSC Brain mRNA U74Av2 (Nov05) PDNN" - ], - [ - "BR_U_0805_M", - "UTHSC Brain mRNA U74Av2 (Aug05) MAS5" - ], - [ - "BR_U_0805_P", - "UTHSC Brain mRNA U74Av2 (Aug05) PDNN" - ], - [ - "BR_U_0805_R", - "UTHSC Brain mRNA U74Av2 (Aug05) RMA" - ], - [ - "BRF2_M_0805_R", - "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) RMA" - ], - [ - "BRF2_M_0805_P", - "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) PDNN" - ], - [ - "BRF2_M_0805_M", - "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) MAS5" - ], - [ - "BRF2_M_0304_P", - "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) PDNN" - ], - [ - "BRF2_M_0304_R", - "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) RMA" - ], - [ - "BRF2_M_0304_M", - "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) MAS5" - ], - [ - "CB_M_0204_P", - "INIA Brain mRNA M430 (Feb04) PDNN" - ] - ], - "Genotypes": [ - [ - "CTB6F2Geno", - "CTB6F2 Genotypes" - ] - ], - "Liver": [ - [ - "GSE16780_UCLA_ML0911", - "GSE16780 UCLA Hybrid MDP Liver Affy HT M430A (Sep11) RMA" - ], - [ - "JAX_CSB_L_0711", - "JAX Liver Affy M430 2.0 (Jul11) MDP" - ], - [ - "JAX_CSB_L_HF_0711", - "JAX Liver HF Affy M430 2.0 (Jul11) MDP" - ], - [ - "JAX_CSB_L_6C_0711", - "JAX Liver 6C Affy M430 2.0 (Jul11) MDP" - ], - [ - "HLC_0311", - "GSE9588 Human Liver Normal (Mar11) Both Sexes" - ], - [ - "HLCM_0311", - "GSE9588 Human Liver Normal (Mar11) Males" - ], - [ - "LV_G_0106_F", - "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Females" - ], - [ - "LV_G_0106_M", - "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Males" - ], - [ - "LV_G_0106_B", - "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Both Sexes" - ], - [ - "GenEx_BXD_liverSal_RMA_F_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Females **" - ], - [ - "GenEx_BXD_liverSal_RMA_M_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Males **" - ], - [ - "GenEx_BXD_liverSal_RMA_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" - ], - [ - "GenEx_BXD_liverEt_RMA_F_0211", - "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Females **" - ], - [ - "GenEx_BXD_liverEt_RMA_M_0211", - "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Males **" - ], - [ - "GenEx_BXD_liverEt_RMA_0211", - "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" - ], - [ - "SUH_Liv_RMA_0611", - "SUH BXD Liver Affy Mouse Gene 1.0 ST (Jun11) RMA **" - ], - [ - "OXUKHS_ILMLiver_RI0510", - "OX UK HS ILM6v1.1 Liver (May 2010) RankInv" - ], - [ - "HXB_Liver_1208", - "MDC/CAS/UCL Liver 230v2 (Dec08) RMA" - ], - [ - "UCLA_CTB6B6CTF2_LIVER_MALE", - "UCLA CTB6B6CTF2 Liver Male mlratio **" - ], - [ - "UCLA_BHF2_LIVER_MALE", - "UCLA BHF2 Liver Male mlratio" - ], - [ - "UCLA_CTB6B6CTF2_LIVER_FEMALE", - "UCLA CTB6B6CTF2 Liver Female mlratio **" - ], - [ - "UCLA_BHHBF2_LIVER_FEMALE", - "UCLA BHHBF2 Liver Female Only" - ], - [ - "UCLA_BHHBF2_LIVER_MALE", - "UCLA BHHBF2 Liver Male Only" - ], - [ - "UCLA_BHF2_LIVER_FEMALE", - "UCLA BHF2 Liver Female mlratio" - ], - [ - "UCLA_BHHBF2_LIVER_2005", - "UCLA BHHBF2 Liver (2005) mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_LIVER_2005", - "UCLA CTB6/B6CTF2 Liver (2005) mlratio **" - ], - [ - "UCLA_BHF2_LIVER_0605", - "UCLA BHF2 Liver (June05) mlratio" - ], - [ - "UCLA_BDF2_LIVER_1999", - "UCLA BDF2 Liver (1999) mlratio" - ], - [ - "LVF2_M_0704_R", - "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) RMA" - ], - [ - "LVF2_M_0704_M", - "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) MAS5" - ], - [ - "HLCF_0311", - "GSE9588 Human Liver Normal (Mar11) Females" - ] - ], - "Muscle": [ - [ - "EPFLMouseMuscleRMA1211", - "EPFL/LISP BXD Muscle Affy Mouse Gene 1.0 ST (Dec11) RMA **" - ], - [ - "EPFLMouseMuscleCDRMA1211", - "EPFL/LISP BXD CD Muscle Affy Mouse Gene 1.0 ST (Dec11) RMA **" - ], - [ - "EPFLMouseMuscleHFDRMA1211", - "EPFL/LISP BXD HFD Muscle Affy Mouse Gene 1.0 ST (Dec11) RMA **" - ], - [ - "UCLA_CTB6B6CTF2_MUSCLE_FEMALE", - "UCLA CTB6B6CTF2 Muscle Female mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_MUSCLE_MALE", - "UCLA CTB6B6CTF2 Muscle Male mlratio **" - ], - [ - "UCLA_BHHBF2_MUSCLE_FEMALE", - "UCLA BHHBF2 Muscle Female Only" - ], - [ - "UCLA_BHHBF2_MUSCLE_MALE", - "UCLA BHHBF2 Muscle Male Only" - ], - [ - "UCLA_BHF2_MUSCLE_MALE", - "UCLA BHF2 Muscle Male mlratio **" - ], - [ - "UCLA_BHF2_MUSCLE_FEMALE", - "UCLA BHF2 Muscle Female mlratio **" - ], - [ - "UCLA_BHHBF2_MUSCLE_2005", - "UCLA BHHBF2 Muscle (2005) mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_MUSCLE_2005", - "UCLA CTB6/B6CTF2 Muscle (2005) mlratio **" - ], - [ - "UCLA_BHF2_MUSCLE_0605", - "UCLA BHF2 Muscle (June05) mlratio **" - ] - ], - "Phenotypes": [ - [ - "CTB6F2Publish", - "CTB6F2 Published Phenotypes" - ] - ] - }, - "CXB": { - "Genotypes": [ - [ - "CXBGeno", - "CXB Genotypes" - ] - ], - "Hippocampus": [ - [ - "KIN_YSM_HIP_0711", - "KIN/YSM Human HIP Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ], - [ - "UMUTAffyExon_0209_RMA_MDP", - "UMUTAffy Hippocampus Exon (Feb09) RMA MDP" - ], - [ - "HC_M2_0606_MDP", - "Hippocampus Consortium M430v2 (Jun06) RMA MDP" - ], - [ - "OXUKHS_ILMHipp_RI0510", - "OX UK HS ILM6v1.1 Hippocampus (May 2010) RankInv" - ], - [ - "INIA_MacFas_Hc_RMA_0110", - "INIA Macaca fasicularis Hippocampus control (Jan10) RMA **" - ], - [ - "INIA_MacFas_He_RMA_0110", - "INIA Macaca fasicularis Hippocampus ethanol (Jan10) RMA **" - ], - [ - "UT_HippRatEx_RMA_0709", - "UT Hippocampus Affy RaEx 1.0 Exon (Jul09) RMA" - ], - [ - "Illum_LXS_Hipp_loess0807", - "Hippocampus Illumina (Aug07) LOESS" - ], - [ - "Illum_LXS_Hipp_loess_nb0807", - "Hippocampus Illumina (Aug07) LOESS_NB" - ], - [ - "Illum_LXS_Hipp_quant0807", - "Hippocampus Illumina (Aug07) QUANT" - ], - [ - "Illum_LXS_Hipp_quant_nb0807", - "Hippocampus Illumina (Aug07) QUANT_NB" - ], - [ - "Illum_LXS_Hipp_rsn0807", - "Hippocampus Illumina (Aug07) RSN" - ], - [ - "Illum_LXS_Hipp_rsn_nb0807", - "Hippocampus Illumina (Aug07) RSN_NB" - ], - [ - "Hipp_Illumina_RankInv_0507", - "Hippocampus Illumina (May07) RankInv" - ], - [ - "HC_M2_0606_P", - "Hippocampus Consortium M430v2 (Jun06) PDNN" - ], - [ - "HC_M2_0606_M", - "Hippocampus Consortium M430v2 (Jun06) MAS5" - ], - [ - "HC_M2_0606_R", - "Hippocampus Consortium M430v2 (Jun06) RMA" - ], - [ - "HC_M2CB_1205_R", - "Hippocampus Consortium M430v2 CXB (Dec05) RMA" - ], - [ - "HC_M2CB_1205_P", - "Hippocampus Consortium M430v2 CXB (Dec05) PDNN" - ], - [ - "UMUTAffyExon_0209_RMA", - "UMUTAffy Hippocampus Exon (Feb09) RMA" - ], - [ - "UT_ILM_BXD_hipp_NON_0909", - "UTHSC Hippocampus Illumina v6.1 NON (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_NOS_0909", - "UTHSC Hippocampus Illumina v6.1 NOS (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_NOE_0909", - "UTHSC Hippocampus Illumina v6.1 NOE (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_RSS_0909", - "UTHSC Hippocampus Illumina v6.1 RSS (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_RSE_0909", - "UTHSC Hippocampus Illumina v6.1 RSE (Sep09) RankInv" - ], - [ - "Illum_LXS_Hipp_RSE_1008", - "Hippocampus Illumina RSE (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_NOS_1008", - "Hippocampus Illumina NOS (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_NOE_1008", - "Hippocampus Illumina NOE (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_RSS_1008", - "Hippocampus Illumina RSS (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_NON_1008", - "Hippocampus Illumina NON (Oct08) RankInv beta" - ] - ], - "Phenotypes": [ - [ - "CXBPublish", - "CXB Published Phenotypes" - ] - ], - "Spleen": [ - [ - "UTHSC_SPL_RMA_1210", - "UTHSC Affy MoGene 1.0 ST Spleen (Dec10) RMA" - ], - [ - "UTHSC_SPL_RMA_1010", - "UTHSC Affy MoGene 1.0 ST Spleen (Oct10) RMA" - ], - [ - "IoP_SPL_RMA_0509", - "IoP Affy MOE 430v2 Spleen (May09) RMA" - ], - [ - "Illum_BXD_Spl_1108", - "UWA Illumina Spleen (Nov08) RSN **" - ], - [ - "UTK_BXDSpl_VST_0110", - "UTK Spleen ILM6.1 (Jan10) VST" - ], - [ - "STSPL_1107_R", - "Stuart Spleen M430v2 (Nov07) RMA" - ] - ] - }, - "HS": { - "Genotypes": [ - [ - "HSGeno", - "HS Genotypes" - ] - ], - "Hippocampus": [ - [ - "KIN_YSM_HIP_0711", - "KIN/YSM Human HIP Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ], - [ - "UMUTAffyExon_0209_RMA_MDP", - "UMUTAffy Hippocampus Exon (Feb09) RMA MDP" - ], - [ - "HC_M2_0606_MDP", - "Hippocampus Consortium M430v2 (Jun06) RMA MDP" - ], - [ - "OXUKHS_ILMHipp_RI0510", - "OX UK HS ILM6v1.1 Hippocampus (May 2010) RankInv" - ], - [ - "INIA_MacFas_Hc_RMA_0110", - "INIA Macaca fasicularis Hippocampus control (Jan10) RMA **" - ], - [ - "INIA_MacFas_He_RMA_0110", - "INIA Macaca fasicularis Hippocampus ethanol (Jan10) RMA **" - ], - [ - "UT_HippRatEx_RMA_0709", - "UT Hippocampus Affy RaEx 1.0 Exon (Jul09) RMA" - ], - [ - "Illum_LXS_Hipp_loess0807", - "Hippocampus Illumina (Aug07) LOESS" - ], - [ - "Illum_LXS_Hipp_loess_nb0807", - "Hippocampus Illumina (Aug07) LOESS_NB" - ], - [ - "Illum_LXS_Hipp_quant0807", - "Hippocampus Illumina (Aug07) QUANT" - ], - [ - "Illum_LXS_Hipp_quant_nb0807", - "Hippocampus Illumina (Aug07) QUANT_NB" - ], - [ - "Illum_LXS_Hipp_rsn0807", - "Hippocampus Illumina (Aug07) RSN" - ], - [ - "Illum_LXS_Hipp_rsn_nb0807", - "Hippocampus Illumina (Aug07) RSN_NB" - ], - [ - "Hipp_Illumina_RankInv_0507", - "Hippocampus Illumina (May07) RankInv" - ], - [ - "HC_M2_0606_P", - "Hippocampus Consortium M430v2 (Jun06) PDNN" - ], - [ - "HC_M2_0606_M", - "Hippocampus Consortium M430v2 (Jun06) MAS5" - ], - [ - "HC_M2_0606_R", - "Hippocampus Consortium M430v2 (Jun06) RMA" - ], - [ - "HC_M2CB_1205_R", - "Hippocampus Consortium M430v2 CXB (Dec05) RMA" - ], - [ - "HC_M2CB_1205_P", - "Hippocampus Consortium M430v2 CXB (Dec05) PDNN" - ], - [ - "UMUTAffyExon_0209_RMA", - "UMUTAffy Hippocampus Exon (Feb09) RMA" - ], - [ - "UT_ILM_BXD_hipp_NON_0909", - "UTHSC Hippocampus Illumina v6.1 NON (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_NOS_0909", - "UTHSC Hippocampus Illumina v6.1 NOS (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_NOE_0909", - "UTHSC Hippocampus Illumina v6.1 NOE (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_RSS_0909", - "UTHSC Hippocampus Illumina v6.1 RSS (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_RSE_0909", - "UTHSC Hippocampus Illumina v6.1 RSE (Sep09) RankInv" - ], - [ - "Illum_LXS_Hipp_RSE_1008", - "Hippocampus Illumina RSE (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_NOS_1008", - "Hippocampus Illumina NOS (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_NOE_1008", - "Hippocampus Illumina NOE (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_RSS_1008", - "Hippocampus Illumina RSS (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_NON_1008", - "Hippocampus Illumina NON (Oct08) RankInv beta" - ] - ], - "Liver": [ - [ - "GSE16780_UCLA_ML0911", - "GSE16780 UCLA Hybrid MDP Liver Affy HT M430A (Sep11) RMA" - ], - [ - "JAX_CSB_L_0711", - "JAX Liver Affy M430 2.0 (Jul11) MDP" - ], - [ - "JAX_CSB_L_HF_0711", - "JAX Liver HF Affy M430 2.0 (Jul11) MDP" - ], - [ - "JAX_CSB_L_6C_0711", - "JAX Liver 6C Affy M430 2.0 (Jul11) MDP" - ], - [ - "HLC_0311", - "GSE9588 Human Liver Normal (Mar11) Both Sexes" - ], - [ - "HLCM_0311", - "GSE9588 Human Liver Normal (Mar11) Males" - ], - [ - "LV_G_0106_F", - "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Females" - ], - [ - "LV_G_0106_M", - "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Males" - ], - [ - "LV_G_0106_B", - "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Both Sexes" - ], - [ - "GenEx_BXD_liverSal_RMA_F_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Females **" - ], - [ - "GenEx_BXD_liverSal_RMA_M_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Males **" - ], - [ - "GenEx_BXD_liverSal_RMA_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" - ], - [ - "GenEx_BXD_liverEt_RMA_F_0211", - "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Females **" - ], - [ - "GenEx_BXD_liverEt_RMA_M_0211", - "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Males **" - ], - [ - "GenEx_BXD_liverEt_RMA_0211", - "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" - ], - [ - "SUH_Liv_RMA_0611", - "SUH BXD Liver Affy Mouse Gene 1.0 ST (Jun11) RMA **" - ], - [ - "OXUKHS_ILMLiver_RI0510", - "OX UK HS ILM6v1.1 Liver (May 2010) RankInv" - ], - [ - "HXB_Liver_1208", - "MDC/CAS/UCL Liver 230v2 (Dec08) RMA" - ], - [ - "UCLA_CTB6B6CTF2_LIVER_MALE", - "UCLA CTB6B6CTF2 Liver Male mlratio **" - ], - [ - "UCLA_BHF2_LIVER_MALE", - "UCLA BHF2 Liver Male mlratio" - ], - [ - "UCLA_CTB6B6CTF2_LIVER_FEMALE", - "UCLA CTB6B6CTF2 Liver Female mlratio **" - ], - [ - "UCLA_BHHBF2_LIVER_FEMALE", - "UCLA BHHBF2 Liver Female Only" - ], - [ - "UCLA_BHHBF2_LIVER_MALE", - "UCLA BHHBF2 Liver Male Only" - ], - [ - "UCLA_BHF2_LIVER_FEMALE", - "UCLA BHF2 Liver Female mlratio" - ], - [ - "UCLA_BHHBF2_LIVER_2005", - "UCLA BHHBF2 Liver (2005) mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_LIVER_2005", - "UCLA CTB6/B6CTF2 Liver (2005) mlratio **" - ], - [ - "UCLA_BHF2_LIVER_0605", - "UCLA BHF2 Liver (June05) mlratio" - ], - [ - "UCLA_BDF2_LIVER_1999", - "UCLA BDF2 Liver (1999) mlratio" - ], - [ - "LVF2_M_0704_R", - "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) RMA" - ], - [ - "LVF2_M_0704_M", - "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) MAS5" - ], - [ - "HLCF_0311", - "GSE9588 Human Liver Normal (Mar11) Females" - ] - ], - "Lung": [ - [ - "OXUKHS_ILMLung_RI0510", - "OX UK HS ILM6v1.1 Lung (May 2010) RankInv" - ], - [ - "HZI_0408_R", - "HZI Lung M430v2 (Apr08) RMA" - ], - [ - "HZI_0408_M", - "HZI Lung M430v2 (Apr08) MAS5" - ] - ], - "Phenotypes": [ - [ - "HSPublish", - "HS Published Phenotypes" - ] - ] - }, - "HS-CC": { - "Genotypes": [ - [ - "HS-CCGeno", - "HS-CC Genotypes" - ] - ], - "Phenotypes": [ - [ - "HS-CCPublish", - "HS-CC Published Phenotypes" - ] - ], - "Striatum": [ - [ - "DevStriatum_ILM6.2P3RInv_1111", - "BIDMC/UTHSC Dev Striatum P3 ILMv6.2 (Nov11) RankInv **" - ], - [ - "DevStriatum_ILM6.2P14RInv_1111", - "BIDMC/UTHSC Dev Striatum P14 ILMv6.2 (Nov11) RankInv **" - ], - [ - "KIN_YSM_STR_0711", - "KIN/YSM Human STR Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ], - [ - "OHSU_HS-CC_ILMStr_0211", - "OHSU HS-CC Striatum ILM6v1 (Feb11) RankInv" - ], - [ - "UTHSC_Striatum_RankInv_1210", - "HQF BXD Striatum ILM6.1 (Dec10v2) RankInv" - ], - [ - "UTHSC_Str_RankInv_1210", - "HQF BXD Striatum ILM6.1 (Dec10) RankInv" - ], - [ - "UTHSC_1107_RankInv", - "HQF BXD Striatum ILM6.1 (Nov07) RankInv" - ], - [ - "SA_M2_0905_P", - "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) PDNN" - ], - [ - "SA_M2_0905_M", - "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) MAS5" - ], - [ - "SA_M2_0905_R", - "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) RMA" - ], - [ - "SA_M2_0405_MC", - "HBP Rosen Striatum M430V2 (Apr05) MAS5 Clean" - ], - [ - "SA_M2_0405_RC", - "HBP Rosen Striatum M430V2 (Apr05) RMA Clean" - ], - [ - "SA_M2_0405_PC", - "HBP Rosen Striatum M430V2 (Apr05) PDNN Clean" - ], - [ - "SA_M2_0405_SS", - "HBP Rosen Striatum M430V2 (Apr05) SScore" - ], - [ - "SA_M2_0405_RR", - "HBP Rosen Striatum M430V2 (Apr05) RMA Orig" - ], - [ - "Striatum_Exon_0209", - "HQF Striatum Exon (Feb09) RMA" - ], - [ - "DevStriatum_ILM6.2P3RInv_1110", - "BIDMC/UTHSC Dev Striatum P3 ILMv6.2 (Nov10) RankInv **" - ], - [ - "DevStriatum_ILM6.2P14RInv_1110", - "BIDMC/UTHSC Dev Striatum P14 ILMv6.2 (Nov10) RankInv **" - ] - ] - }, - "LXS": { - "Genotypes": [ - [ - "LXSGeno", - "LXS Genotypes" - ] - ], - "Hippocampus": [ - [ - "KIN_YSM_HIP_0711", - "KIN/YSM Human HIP Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ], - [ - "UMUTAffyExon_0209_RMA_MDP", - "UMUTAffy Hippocampus Exon (Feb09) RMA MDP" - ], - [ - "HC_M2_0606_MDP", - "Hippocampus Consortium M430v2 (Jun06) RMA MDP" - ], - [ - "OXUKHS_ILMHipp_RI0510", - "OX UK HS ILM6v1.1 Hippocampus (May 2010) RankInv" - ], - [ - "INIA_MacFas_Hc_RMA_0110", - "INIA Macaca fasicularis Hippocampus control (Jan10) RMA **" - ], - [ - "INIA_MacFas_He_RMA_0110", - "INIA Macaca fasicularis Hippocampus ethanol (Jan10) RMA **" - ], - [ - "UT_HippRatEx_RMA_0709", - "UT Hippocampus Affy RaEx 1.0 Exon (Jul09) RMA" - ], - [ - "Illum_LXS_Hipp_loess0807", - "Hippocampus Illumina (Aug07) LOESS" - ], - [ - "Illum_LXS_Hipp_loess_nb0807", - "Hippocampus Illumina (Aug07) LOESS_NB" - ], - [ - "Illum_LXS_Hipp_quant0807", - "Hippocampus Illumina (Aug07) QUANT" - ], - [ - "Illum_LXS_Hipp_quant_nb0807", - "Hippocampus Illumina (Aug07) QUANT_NB" - ], - [ - "Illum_LXS_Hipp_rsn0807", - "Hippocampus Illumina (Aug07) RSN" - ], - [ - "Illum_LXS_Hipp_rsn_nb0807", - "Hippocampus Illumina (Aug07) RSN_NB" - ], - [ - "Hipp_Illumina_RankInv_0507", - "Hippocampus Illumina (May07) RankInv" - ], - [ - "HC_M2_0606_P", - "Hippocampus Consortium M430v2 (Jun06) PDNN" - ], - [ - "HC_M2_0606_M", - "Hippocampus Consortium M430v2 (Jun06) MAS5" - ], - [ - "HC_M2_0606_R", - "Hippocampus Consortium M430v2 (Jun06) RMA" - ], - [ - "HC_M2CB_1205_R", - "Hippocampus Consortium M430v2 CXB (Dec05) RMA" - ], - [ - "HC_M2CB_1205_P", - "Hippocampus Consortium M430v2 CXB (Dec05) PDNN" - ], - [ - "UMUTAffyExon_0209_RMA", - "UMUTAffy Hippocampus Exon (Feb09) RMA" - ], - [ - "UT_ILM_BXD_hipp_NON_0909", - "UTHSC Hippocampus Illumina v6.1 NON (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_NOS_0909", - "UTHSC Hippocampus Illumina v6.1 NOS (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_NOE_0909", - "UTHSC Hippocampus Illumina v6.1 NOE (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_RSS_0909", - "UTHSC Hippocampus Illumina v6.1 RSS (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_RSE_0909", - "UTHSC Hippocampus Illumina v6.1 RSE (Sep09) RankInv" - ], - [ - "Illum_LXS_Hipp_RSE_1008", - "Hippocampus Illumina RSE (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_NOS_1008", - "Hippocampus Illumina NOS (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_NOE_1008", - "Hippocampus Illumina NOE (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_RSS_1008", - "Hippocampus Illumina RSS (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_NON_1008", - "Hippocampus Illumina NON (Oct08) RankInv beta" - ] - ], - "Phenotypes": [ - [ - "LXSPublish", - "LXS Published Phenotypes" - ] - ], - "Prefrontal Cortex": [ - [ - "HBTRC-MLPFC_0611", - "HBTRC-MLC Human Prefrontal Cortex Agilent (Jun11) mlratio" - ], - [ - "HBTRC-MLPFC_N_0611", - "HBTRC-MLC Human Prefrontal Cortex Agilent Normal (Jun11) mlratio" - ], - [ - "HBTRC-MLPFC_AD_0611", - "HBTRC-MLC Human Prefrontal Cortex Agilent AD (Jun11) mlratio" - ], - [ - "HBTRC-MLPFC_HD_0611", - "HBTRC-MLC Human Prefrontal Cortex Agilent HD (Jun11) mlratio" - ], - [ - "INIA_MacFas_Pf_RMA_0110", - "INIA Macaca fasicularis Prefrontal Cortex control (Jan10) RMA **" - ], - [ - "INIA_MacFas_PfE_RMA_0110", - "INIA Macaca fasicularis Prefrontal Cortex ethanol (Jan10) RMA **" - ], - [ - "VCUSal_1006_R", - "VCU BXD PFC Et vs Sal M430 2.0 (Dec06) Sscore" - ], - [ - "VCUEtOH_1206_R", - "VCU BXD PFC EtOH M430 2.0 (Dec06) RMA" - ], - [ - "VCUSal_1206_R", - "VCU BXD PFC Sal M430 2.0 (Dec06) RMA" - ], - [ - "VCU_PF_Air_0111_R", - "VCU BXD PFC CIE Air M430 2.0 (Jan11) RMA **" - ], - [ - "VCU_PF_Et_0111_R", - "VCU BXD PFC CIE EtOH M430 2.0 (Jan11) RMA **" - ], - [ - "VCU_PF_AvE_0111_Ss", - "VCU BXD PFC EtOH vs CIE Air M430 2.0 (Jan11) Sscore **" - ], - [ - "VCUEt_vs_Sal_0806_R", - "VCU LXS PFC Et vs Sal M430A 2.0 (Aug06) Sscore **" - ], - [ - "VCUEtOH_0806_R", - "VCU LXS PFC EtOH M430A 2.0 (Aug06) RMA **" - ], - [ - "VCUSal_0806_R", - "VCU LXS PFC Sal M430A 2.0 (Aug06) RMA" - ] - ] - }, - "MDP": { - "Genotypes": [ - [ - "MDPGeno", - "MDP Genotypes" - ] - ], - "Hippocampus": [ - [ - "KIN_YSM_HIP_0711", - "KIN/YSM Human HIP Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ], - [ - "UMUTAffyExon_0209_RMA_MDP", - "UMUTAffy Hippocampus Exon (Feb09) RMA MDP" - ], - [ - "HC_M2_0606_MDP", - "Hippocampus Consortium M430v2 (Jun06) RMA MDP" - ], - [ - "OXUKHS_ILMHipp_RI0510", - "OX UK HS ILM6v1.1 Hippocampus (May 2010) RankInv" - ], - [ - "INIA_MacFas_Hc_RMA_0110", - "INIA Macaca fasicularis Hippocampus control (Jan10) RMA **" - ], - [ - "INIA_MacFas_He_RMA_0110", - "INIA Macaca fasicularis Hippocampus ethanol (Jan10) RMA **" - ], - [ - "UT_HippRatEx_RMA_0709", - "UT Hippocampus Affy RaEx 1.0 Exon (Jul09) RMA" - ], - [ - "Illum_LXS_Hipp_loess0807", - "Hippocampus Illumina (Aug07) LOESS" - ], - [ - "Illum_LXS_Hipp_loess_nb0807", - "Hippocampus Illumina (Aug07) LOESS_NB" - ], - [ - "Illum_LXS_Hipp_quant0807", - "Hippocampus Illumina (Aug07) QUANT" - ], - [ - "Illum_LXS_Hipp_quant_nb0807", - "Hippocampus Illumina (Aug07) QUANT_NB" - ], - [ - "Illum_LXS_Hipp_rsn0807", - "Hippocampus Illumina (Aug07) RSN" - ], - [ - "Illum_LXS_Hipp_rsn_nb0807", - "Hippocampus Illumina (Aug07) RSN_NB" - ], - [ - "Hipp_Illumina_RankInv_0507", - "Hippocampus Illumina (May07) RankInv" - ], - [ - "HC_M2_0606_P", - "Hippocampus Consortium M430v2 (Jun06) PDNN" - ], - [ - "HC_M2_0606_M", - "Hippocampus Consortium M430v2 (Jun06) MAS5" - ], - [ - "HC_M2_0606_R", - "Hippocampus Consortium M430v2 (Jun06) RMA" - ], - [ - "HC_M2CB_1205_R", - "Hippocampus Consortium M430v2 CXB (Dec05) RMA" - ], - [ - "HC_M2CB_1205_P", - "Hippocampus Consortium M430v2 CXB (Dec05) PDNN" - ], - [ - "UMUTAffyExon_0209_RMA", - "UMUTAffy Hippocampus Exon (Feb09) RMA" - ], - [ - "UT_ILM_BXD_hipp_NON_0909", - "UTHSC Hippocampus Illumina v6.1 NON (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_NOS_0909", - "UTHSC Hippocampus Illumina v6.1 NOS (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_NOE_0909", - "UTHSC Hippocampus Illumina v6.1 NOE (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_RSS_0909", - "UTHSC Hippocampus Illumina v6.1 RSS (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_RSE_0909", - "UTHSC Hippocampus Illumina v6.1 RSE (Sep09) RankInv" - ], - [ - "Illum_LXS_Hipp_RSE_1008", - "Hippocampus Illumina RSE (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_NOS_1008", - "Hippocampus Illumina NOS (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_NOE_1008", - "Hippocampus Illumina NOE (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_RSS_1008", - "Hippocampus Illumina RSS (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_NON_1008", - "Hippocampus Illumina NON (Oct08) RankInv beta" - ] - ], - "Liver": [ - [ - "GSE16780_UCLA_ML0911", - "GSE16780 UCLA Hybrid MDP Liver Affy HT M430A (Sep11) RMA" - ], - [ - "JAX_CSB_L_0711", - "JAX Liver Affy M430 2.0 (Jul11) MDP" - ], - [ - "JAX_CSB_L_HF_0711", - "JAX Liver HF Affy M430 2.0 (Jul11) MDP" - ], - [ - "JAX_CSB_L_6C_0711", - "JAX Liver 6C Affy M430 2.0 (Jul11) MDP" - ], - [ - "HLC_0311", - "GSE9588 Human Liver Normal (Mar11) Both Sexes" - ], - [ - "HLCM_0311", - "GSE9588 Human Liver Normal (Mar11) Males" - ], - [ - "LV_G_0106_F", - "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Females" - ], - [ - "LV_G_0106_M", - "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Males" - ], - [ - "LV_G_0106_B", - "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Both Sexes" - ], - [ - "GenEx_BXD_liverSal_RMA_F_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Females **" - ], - [ - "GenEx_BXD_liverSal_RMA_M_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Males **" - ], - [ - "GenEx_BXD_liverSal_RMA_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" - ], - [ - "GenEx_BXD_liverEt_RMA_F_0211", - "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Females **" - ], - [ - "GenEx_BXD_liverEt_RMA_M_0211", - "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Males **" - ], - [ - "GenEx_BXD_liverEt_RMA_0211", - "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" - ], - [ - "SUH_Liv_RMA_0611", - "SUH BXD Liver Affy Mouse Gene 1.0 ST (Jun11) RMA **" - ], - [ - "OXUKHS_ILMLiver_RI0510", - "OX UK HS ILM6v1.1 Liver (May 2010) RankInv" - ], - [ - "HXB_Liver_1208", - "MDC/CAS/UCL Liver 230v2 (Dec08) RMA" - ], - [ - "UCLA_CTB6B6CTF2_LIVER_MALE", - "UCLA CTB6B6CTF2 Liver Male mlratio **" - ], - [ - "UCLA_BHF2_LIVER_MALE", - "UCLA BHF2 Liver Male mlratio" - ], - [ - "UCLA_CTB6B6CTF2_LIVER_FEMALE", - "UCLA CTB6B6CTF2 Liver Female mlratio **" - ], - [ - "UCLA_BHHBF2_LIVER_FEMALE", - "UCLA BHHBF2 Liver Female Only" - ], - [ - "UCLA_BHHBF2_LIVER_MALE", - "UCLA BHHBF2 Liver Male Only" - ], - [ - "UCLA_BHF2_LIVER_FEMALE", - "UCLA BHF2 Liver Female mlratio" - ], - [ - "UCLA_BHHBF2_LIVER_2005", - "UCLA BHHBF2 Liver (2005) mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_LIVER_2005", - "UCLA CTB6/B6CTF2 Liver (2005) mlratio **" - ], - [ - "UCLA_BHF2_LIVER_0605", - "UCLA BHF2 Liver (June05) mlratio" - ], - [ - "UCLA_BDF2_LIVER_1999", - "UCLA BDF2 Liver (1999) mlratio" - ], - [ - "LVF2_M_0704_R", - "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) RMA" - ], - [ - "LVF2_M_0704_M", - "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) MAS5" - ], - [ - "HLCF_0311", - "GSE9588 Human Liver Normal (Mar11) Females" - ] - ], - "Phenotypes": [ - [ - "MDPPublish", - "Mouse Phenome Database" - ] - ] - }, - "NZBXFVB-N2": { - "Genotypes": [ - [ - "NZBXFVB-N2Geno", - "NZBXFVB-N2 Genotypes" - ] - ], - "Mammary Tumors": [ - [ - "NCI_Mam_Tum_RMA_0409", - "NCI Mammary M430v2 (Apr09) RMA" - ], - [ - "NCI_Agil_Mam_Tum_RMA_0409", - "NCI Mammary LMT miRNA v2 (Apr09) RMA" - ], - [ - "MA_M_0704_R", - "NCI Mammary mRNA M430 (July04) RMA" - ], - [ - "MA_M_0704_M", - "NCI Mammary mRNA M430 (July04) MAS5" - ] - ], - "Phenotypes": [ - [ - "NZBXFVB-N2Publish", - "NZBXFVB-N2 Published Phenotypes" - ] - ] - } - }, - "rat": { - "HXBBXH": { - "Adrenal Gland": [ - [ - "HXB_Adrenal_1208", - "MDC/CAS/UCL Adrenal 230A (Dec08) RMA" - ] - ], - "Genotypes": [ - [ - "HXBBXHGeno", - "HXBBXH Genotypes" - ] - ], - "Heart": [ - [ - "HXB_Heart_1208", - "MDC/CAS/UCL Heart 230_V2 (Dec08) RMA" - ] - ], - "Hippocampus": [ - [ - "KIN_YSM_HIP_0711", - "KIN/YSM Human HIP Affy Hu-Exon 1.0 ST (Jul11) Quantile **" - ], - [ - "UMUTAffyExon_0209_RMA_MDP", - "UMUTAffy Hippocampus Exon (Feb09) RMA MDP" - ], - [ - "HC_M2_0606_MDP", - "Hippocampus Consortium M430v2 (Jun06) RMA MDP" - ], - [ - "OXUKHS_ILMHipp_RI0510", - "OX UK HS ILM6v1.1 Hippocampus (May 2010) RankInv" - ], - [ - "INIA_MacFas_Hc_RMA_0110", - "INIA Macaca fasicularis Hippocampus control (Jan10) RMA **" - ], - [ - "INIA_MacFas_He_RMA_0110", - "INIA Macaca fasicularis Hippocampus ethanol (Jan10) RMA **" - ], - [ - "UT_HippRatEx_RMA_0709", - "UT Hippocampus Affy RaEx 1.0 Exon (Jul09) RMA" - ], - [ - "Illum_LXS_Hipp_loess0807", - "Hippocampus Illumina (Aug07) LOESS" - ], - [ - "Illum_LXS_Hipp_loess_nb0807", - "Hippocampus Illumina (Aug07) LOESS_NB" - ], - [ - "Illum_LXS_Hipp_quant0807", - "Hippocampus Illumina (Aug07) QUANT" - ], - [ - "Illum_LXS_Hipp_quant_nb0807", - "Hippocampus Illumina (Aug07) QUANT_NB" - ], - [ - "Illum_LXS_Hipp_rsn0807", - "Hippocampus Illumina (Aug07) RSN" - ], - [ - "Illum_LXS_Hipp_rsn_nb0807", - "Hippocampus Illumina (Aug07) RSN_NB" - ], - [ - "Hipp_Illumina_RankInv_0507", - "Hippocampus Illumina (May07) RankInv" - ], - [ - "HC_M2_0606_P", - "Hippocampus Consortium M430v2 (Jun06) PDNN" - ], - [ - "HC_M2_0606_M", - "Hippocampus Consortium M430v2 (Jun06) MAS5" - ], - [ - "HC_M2_0606_R", - "Hippocampus Consortium M430v2 (Jun06) RMA" - ], - [ - "HC_M2CB_1205_R", - "Hippocampus Consortium M430v2 CXB (Dec05) RMA" - ], - [ - "HC_M2CB_1205_P", - "Hippocampus Consortium M430v2 CXB (Dec05) PDNN" - ], - [ - "UMUTAffyExon_0209_RMA", - "UMUTAffy Hippocampus Exon (Feb09) RMA" - ], - [ - "UT_ILM_BXD_hipp_NON_0909", - "UTHSC Hippocampus Illumina v6.1 NON (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_NOS_0909", - "UTHSC Hippocampus Illumina v6.1 NOS (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_NOE_0909", - "UTHSC Hippocampus Illumina v6.1 NOE (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_RSS_0909", - "UTHSC Hippocampus Illumina v6.1 RSS (Sep09) RankInv" - ], - [ - "UT_ILM_BXD_hipp_RSE_0909", - "UTHSC Hippocampus Illumina v6.1 RSE (Sep09) RankInv" - ], - [ - "Illum_LXS_Hipp_RSE_1008", - "Hippocampus Illumina RSE (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_NOS_1008", - "Hippocampus Illumina NOS (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_NOE_1008", - "Hippocampus Illumina NOE (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_RSS_1008", - "Hippocampus Illumina RSS (Oct08) RankInv beta" - ], - [ - "Illum_LXS_Hipp_NON_1008", - "Hippocampus Illumina NON (Oct08) RankInv beta" - ] - ], - "Kidney": [ - [ - "MA_M2F_0706_R", - "Mouse kidney M430v2 Female (Aug06) RMA" - ], - [ - "MA_M2M_0706_R", - "Mouse kidney M430v2 Male (Aug06) RMA" - ], - [ - "MA_M2_0806_R", - "Mouse kidney M430v2 Sex Balanced (Aug06) RMA" - ], - [ - "MA_M2_0806_P", - "Mouse Kidney M430v2 Sex Balanced (Aug06) PDNN" - ], - [ - "MA_M2_0706_P", - "Mouse Kidney M430v2 (Jul06) PDNN" - ], - [ - "MA_M2_0706_R", - "Mouse Kidney M430v2 (Jul06) RMA" - ], - [ - "KI_2A_0405_M", - "MDC/CAS/ICL Kidney 230A (Apr05) MAS5" - ], - [ - "KI_2A_0405_Rz", - "MDC/CAS/ICL Kidney 230A (Apr05) RMA 2z+8" - ], - [ - "KI_2A_0405_R", - "MDC/CAS/ICL Kidney 230A (Apr05) RMA" - ] - ], - "Liver": [ - [ - "GSE16780_UCLA_ML0911", - "GSE16780 UCLA Hybrid MDP Liver Affy HT M430A (Sep11) RMA" - ], - [ - "JAX_CSB_L_0711", - "JAX Liver Affy M430 2.0 (Jul11) MDP" - ], - [ - "JAX_CSB_L_HF_0711", - "JAX Liver HF Affy M430 2.0 (Jul11) MDP" - ], - [ - "JAX_CSB_L_6C_0711", - "JAX Liver 6C Affy M430 2.0 (Jul11) MDP" - ], - [ - "HLC_0311", - "GSE9588 Human Liver Normal (Mar11) Both Sexes" - ], - [ - "HLCM_0311", - "GSE9588 Human Liver Normal (Mar11) Males" - ], - [ - "LV_G_0106_F", - "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Females" - ], - [ - "LV_G_0106_M", - "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Males" - ], - [ - "LV_G_0106_B", - "UNC Agilent G4121A Liver LOWESS Stanford (Jan06) Both Sexes" - ], - [ - "GenEx_BXD_liverSal_RMA_F_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Females **" - ], - [ - "GenEx_BXD_liverSal_RMA_M_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Males **" - ], - [ - "GenEx_BXD_liverSal_RMA_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" - ], - [ - "GenEx_BXD_liverEt_RMA_F_0211", - "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Females **" - ], - [ - "GenEx_BXD_liverEt_RMA_M_0211", - "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Males **" - ], - [ - "GenEx_BXD_liverEt_RMA_0211", - "GenEx BXD EtOH Liver Affy M430 2.0 (Feb11) RMA Both Sexes **" - ], - [ - "SUH_Liv_RMA_0611", - "SUH BXD Liver Affy Mouse Gene 1.0 ST (Jun11) RMA **" - ], - [ - "OXUKHS_ILMLiver_RI0510", - "OX UK HS ILM6v1.1 Liver (May 2010) RankInv" - ], - [ - "HXB_Liver_1208", - "MDC/CAS/UCL Liver 230v2 (Dec08) RMA" - ], - [ - "UCLA_CTB6B6CTF2_LIVER_MALE", - "UCLA CTB6B6CTF2 Liver Male mlratio **" - ], - [ - "UCLA_BHF2_LIVER_MALE", - "UCLA BHF2 Liver Male mlratio" - ], - [ - "UCLA_CTB6B6CTF2_LIVER_FEMALE", - "UCLA CTB6B6CTF2 Liver Female mlratio **" - ], - [ - "UCLA_BHHBF2_LIVER_FEMALE", - "UCLA BHHBF2 Liver Female Only" - ], - [ - "UCLA_BHHBF2_LIVER_MALE", - "UCLA BHHBF2 Liver Male Only" - ], - [ - "UCLA_BHF2_LIVER_FEMALE", - "UCLA BHF2 Liver Female mlratio" - ], - [ - "UCLA_BHHBF2_LIVER_2005", - "UCLA BHHBF2 Liver (2005) mlratio **" - ], - [ - "UCLA_CTB6B6CTF2_LIVER_2005", - "UCLA CTB6/B6CTF2 Liver (2005) mlratio **" - ], - [ - "UCLA_BHF2_LIVER_0605", - "UCLA BHF2 Liver (June05) mlratio" - ], - [ - "UCLA_BDF2_LIVER_1999", - "UCLA BDF2 Liver (1999) mlratio" - ], - [ - "LVF2_M_0704_R", - "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) RMA" - ], - [ - "LVF2_M_0704_M", - "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) MAS5" - ], - [ - "HLCF_0311", - "GSE9588 Human Liver Normal (Mar11) Females" - ] - ], - "Peritoneal Fat": [ - [ - "FT_2A_0805_M", - "MDC/CAS/ICL Peritoneal Fat 230A (Aug05) MAS5" - ], - [ - "FT_2A_0605_Rz", - "MDC/CAS/ICL Peritoneal Fat 230A (Jun05) RMA 2z+8" - ] - ], - "Phenotypes": [ - [ - "HXBBXHPublish", - "HXBBXH Published Phenotypes" - ] - ] - }, - "SRxSHRSPF2": { - "Eye": [ - [ - "Eye_AXBXA_1008_RankInv", - "Eye AXBXA Illumina V6.2(Oct08) RankInv Beta" - ], - [ - "Eye_M2_0908_R", - "Eye M430v2 (Sep08) RMA" - ], - [ - "Eye_M2_0908_R_NB", - "Eye M430v2 Mutant Gpnmb (Sep08) RMA **" - ], - [ - "Eye_M2_0908_R_ND", - "Eye M430v2 WT Gpnmb (Sep08) RMA **" - ], - [ - "Eye_M2_0908_WTWT", - "Eye M430v2 WT WT (Sep08) RMA **" - ], - [ - "Eye_M2_0908_R_WT", - "Eye M430v2 WT Tyrp1 (Sep08) RMA **" - ], - [ - "Eye_M2_0908_R_MT", - "Eye M430v2 Mutant Tyrp1 (Sep08) RMA **" - ], - [ - "BXD_GLA_0911", - "BXD Glaucoma Affy M430 2.0 Trial (Sep11) RMA **" - ], - [ - "UIOWA_Eye_RMA_0906", - "UIOWA Eye mRNA RAE230v2 (Sep06) RMA" - ] - ], - "Genotypes": [ - [ - "SRxSHRSPF2Geno", - "SRxSHRSPF2 Genotypes" - ] - ], - "Phenotypes": [ - [ - "SRxSHRSPF2Publish", - "SRxSHRSPF2 Published Phenotypes" - ] - ] - } - }, - "soybean": { - "J12XJ58F2": { - "Genotypes": [ - [ - "J12XJ58F2Geno", - "J12XJ58F2 Genotypes" - ] - ], - "Phenotypes": [ - [ - "J12XJ58F2Publish", - "J12XJ58F2 Published Phenotypes" - ] - ] - } - }, - "tomato": { - "LXP": { - "Genotypes": [ - [ - "LXPGeno", - "LXP Genotypes" - ] - ], - "Phenotypes": [ - [ - "LXPPublish", - "LXP Published Phenotypes" - ] - ] - } - } - }, - "groups": { - "All Species": [ - [ - "All Groups", - "All Groups" - ] - ], - "arabidopsis": [ - [ - "BayXSha", - "BayXSha" - ], - [ - "ColXBur", - "ColXBur" - ], - [ - "ColXCvi", - "ColXCvi" - ] - ], - "barley": [ - [ - "QSM", - "QSM" - ], - [ - "SXM", - "SXM" - ] - ], - "drosophila": [ - [ - "DGRP", - "Drosophila Genetic Reference Panel" - ], - [ - "Oregon-R_x_2b3", - "Oregon-R x 2b3" - ] - ], - "human": [ - [ - "AD-cases-controls", - "AD Cases & Controls (Liang)" - ], - [ - "AD-cases-controls-Myers", - "AD Cases & Controls (Myers)" - ], - [ - "CANDLE", - "CANDLE" - ], - [ - "CEPH-2004", - "CEPH Families" - ], - [ - "HB", - "Harvard Brain Tissue Resource Center" - ], - [ - "HLC", - "Human Liver Cohort" - ], - [ - "HSB", - "KIN/YSM" - ] - ], - "macaque monkey": [ - [ - "Macaca-fasicularis", - "Macaca fasicularis (Cynomolgus monkey)" - ] - ], - "mouse": [ - [ - "AKXD", - "AKXD" - ], - [ - "AXBXA", - "AXB/BXA" - ], - [ - "B6BTBRF2", - "B6BTBRF2" - ], - [ - "B6D2F2", - "B6D2F2" - ], - [ - "BDF2-1999", - "BDF2 UCLA" - ], - [ - "BDF2-2005", - "BDF2-2005" - ], - [ - "BHF2", - "BHF2 (Apoe Null) UCLA" - ], - [ - "BHHBF2", - "BH/HB F2 UCLA" - ], - [ - "BXD", - "BXD" - ], - [ - "BXH", - "BXH" - ], - [ - "CTB6F2", - "CastB6/B6Cast F2 UCLA" - ], - [ - "CXB", - "CXB" - ], - [ - "HS", - "Heterogeneous Stock" - ], - [ - "HS-CC", - "Heterogeneous Stock Collaborative Cross" - ], - [ - "LXS", - "LXS" - ], - [ - "MDP", - "Mouse Diversity Panel" - ], - [ - "NZBXFVB-N2", - "NZB/FVB N2 NCI" - ] - ], - "rat": [ - [ - "HXBBXH", - "HXB/BXH" - ], - [ - "SRxSHRSPF2", - "UIOWA SRxSHRSP F2" - ] - ], - "soybean": [ - [ - "J12XJ58F2", - "J12XJ58F2" - ] - ], - "tomato": [ - [ - "LXP", - "LXP" - ] - ] - }, - "species": [ - [ - "human", - "Human" - ], - [ - "macaque monkey", - "Macaque monkey" - ], - [ - "mouse", - "Mouse" - ], - [ - "rat", - "Rat" - ], - [ - "drosophila", - "Drosophila" - ], - [ - "arabidopsis", - "Arabidopsis thaliana" - ], - [ - "barley", - "Barley" - ], - [ - "soybean", - "Soybean" - ], - [ - "tomato", - "Tomato" - ], - [ - "All Species", - "All Species" - ] - ], - "types": { - "All Species": { - "All Groups": [ - [ - "Phenotypes", - "Phenotypes" - ] - ] - }, - "arabidopsis": { - "BayXSha": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ] - ], - "ColXBur": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ] - ], - "ColXCvi": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ] - ] - }, - "barley": { - "QSM": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Leaf", - "Leaf mRNA" - ] - ], - "SXM": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Embryo", - "Embryo mRNA" - ], - [ - "Leaf", - "Leaf mRNA" - ] - ] - }, - "drosophila": { - "DGRP": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Whole Body", - "Whole Body mRNA" - ] - ], - "Oregon-R_x_2b3": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Whole Body", - "Whole Body mRNA" - ] - ] - }, - "human": { - "AD-cases-controls": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Brain", - "Brain mRNA" - ] - ], - "AD-cases-controls-Myers": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Brain", - "Brain mRNA" - ] - ], - "CANDLE": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Newborn Cord Blood", - "Newborn Cord Blood mRNA" - ] - ], - "CEPH-2004": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Lymphoblast B-cell", - "Lymphoblast B-cell mRNA" - ] - ], - "HB": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Cerebellum", - "Cerebellum mRNA" - ], - [ - "Prefrontal Cortex", - "Prefrontal Cortex mRNA" - ], - [ - "Primary Visual Cortex", - "Primary Visual Cortex mRNA" - ] - ], - "HLC": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Liver", - "Liver mRNA" - ] - ], - "HSB": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Amygdala", - "Amygdala mRNA" - ], - [ - "Caudal Ganglionic Eminence", - "Caudal Ganglionic Eminence mRNA" - ], - [ - "Cerebellar Cortex", - "Cerebellar Cortex mRNA" - ], - [ - "Diencephalon", - "Diencephalon mRNA" - ], - [ - "Dorsal Thalamus", - "Dorsal Thalamus mRNA" - ], - [ - "Dorsolateral Prefrontal Cortex", - "Dorsolateral Prefrontal Cortex mRNA" - ], - [ - "Frontal Cerebral Wall", - "Frontal Cerebral Wall mRNA" - ], - [ - "Hippocampus", - "Hippocampus mRNA" - ], - [ - "Inferior Temporal Cortex", - "Inferior Temporal Cortex mRNA" - ], - [ - "Lateral Ganglionic Eminence", - "Lateral Ganglionic Eminence mRNA" - ], - [ - "Medial Ganglionic Eminence", - "Medial Ganglionic Eminence mRNA" - ], - [ - "Medial Prefrontal Cortex", - "Medial Prefrontal Cortex mRNA" - ], - [ - "Mediodorsal Nucleus of Thalamus", - "Mediodorsal Nucleus of Thalamus mRNA" - ], - [ - "Occipital Cerebral Wall", - "Occipital Cerebral Wall mRNA" - ], - [ - "Orbital Prefrontal Cortex", - "Orbital Prefrontal Cortex mRNA" - ], - [ - "Parietal Cerebral Wall", - "Parietal Cerebral Wall mRNA" - ], - [ - "Posterior Inferior Parietal Cortex", - "Posterior Inferior Parietal Cortex mRNA" - ], - [ - "Posterior Superior Temporal Cortex", - "Posterior Superior Temporal Cortex mRNA" - ], - [ - "Primary Auditory (A1) Cortex", - "Primary Auditory (A1) Cortex mRNA" - ], - [ - "Primary Motor (M1) Cortex", - "Primary Motor (M1) Cortex mRNA" - ], - [ - "Primary Somatosensory (S1) Cortex", - "Primary Somatosensory (S1) Cortex mRNA" - ], - [ - "Primary Visual Cortex", - "Primary Visual Cortex mRNA" - ], - [ - "Striatum", - "Striatum mRNA" - ], - [ - "Temporal Cerebral Wall", - "Temporal Cerebral Wall mRNA" - ], - [ - "Upper (Rostral) Rhombic Lip", - "Upper (Rostral) Rhombic Lip mRNA" - ], - [ - "Ventral Forebrain", - "Ventral Forebrain mRNA" - ], - [ - "Ventrolateral Prefrontal Cortex", - "Ventrolateral Prefrontal Cortex mRNA" - ] - ] - }, - "macaque monkey": { - "Macaca-fasicularis": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Amygdala", - "Amygdala mRNA" - ], - [ - "Brain", - "Brain mRNA" - ], - [ - "Hippocampus", - "Hippocampus mRNA" - ], - [ - "Nucleus Accumbens", - "Nucleus Accumbens mRNA" - ], - [ - "Prefrontal Cortex", - "Prefrontal Cortex mRNA" - ] - ] - }, - "mouse": { - "AKXD": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Mammary Tumors", - "Mammary Tumors mRNA" - ] - ], - "AXBXA": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Eye", - "Eye mRNA" - ] - ], - "B6BTBRF2": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Liver", - "Liver mRNA" - ] - ], - "B6D2F2": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Brain", - "Brain mRNA" - ] - ], - "BDF2-1999": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Liver", - "Liver mRNA" - ] - ], - "BDF2-2005": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Striatum", - "Striatum mRNA" - ] - ], - "BHF2": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Adipose", - "Adipose mRNA" - ], - [ - "Brain", - "Brain mRNA" - ], - [ - "Liver", - "Liver mRNA" - ], - [ - "Muscle", - "Muscle mRNA" - ] - ], - "BHHBF2": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Adipose", - "Adipose mRNA" - ], - [ - "Brain", - "Brain mRNA" - ], - [ - "Liver", - "Liver mRNA" - ], - [ - "Muscle", - "Muscle mRNA" - ] - ], - "BXD": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Amygdala", - "Amygdala mRNA" - ], - [ - "Brain", - "Brain mRNA" - ], - [ - "Cartilage", - "Cartilage mRNA" - ], - [ - "Cerebellum", - "Cerebellum mRNA" - ], - [ - "Eye", - "Eye mRNA" - ], - [ - "Hematopoietic Cells", - "Hematopoietic Cells mRNA" - ], - [ - "Hippocampus", - "Hippocampus mRNA" - ], - [ - "Hypothalamus", - "Hypothalamus mRNA" - ], - [ - "Kidney", - "Kidney mRNA" - ], - [ - "Leucocytes", - "Leucocytes mRNA" - ], - [ - "Liver", - "Liver mRNA" - ], - [ - "Lung", - "Lung mRNA" - ], - [ - "Midbrain", - "Midbrain mRNA" - ], - [ - "Muscle", - "Muscle mRNA" - ], - [ - "Neocortex", - "Neocortex mRNA" - ], - [ - "Nucleus Accumbens", - "Nucleus Accumbens mRNA" - ], - [ - "Prefrontal Cortex", - "Prefrontal Cortex mRNA" - ], - [ - "Retina", - "Retina mRNA" - ], - [ - "Spleen", - "Spleen mRNA" - ], - [ - "Striatum", - "Striatum mRNA" - ], - [ - "T Cell (helper)", - "T Cell (helper) mRNA" - ], - [ - "T Cell (regulatory)", - "T Cell (regulatory) mRNA" - ], - [ - "Thymus", - "Thymus mRNA" - ], - [ - "Ventral Tegmental Area", - "Ventral Tegmental Area mRNA" - ] - ], - "BXH": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Cartilage", - "Cartilage mRNA" - ] - ], - "CTB6F2": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Adipose", - "Adipose mRNA" - ], - [ - "Brain", - "Brain mRNA" - ], - [ - "Liver", - "Liver mRNA" - ], - [ - "Muscle", - "Muscle mRNA" - ] - ], - "CXB": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Hippocampus", - "Hippocampus mRNA" - ], - [ - "Spleen", - "Spleen mRNA" - ] - ], - "HS": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Hippocampus", - "Hippocampus mRNA" - ], - [ - "Liver", - "Liver mRNA" - ], - [ - "Lung", - "Lung mRNA" - ] - ], - "HS-CC": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Striatum", - "Striatum mRNA" - ] - ], - "LXS": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Hippocampus", - "Hippocampus mRNA" - ], - [ - "Prefrontal Cortex", - "Prefrontal Cortex mRNA" - ] - ], - "MDP": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Hippocampus", - "Hippocampus mRNA" - ], - [ - "Liver", - "Liver mRNA" - ] - ], - "NZBXFVB-N2": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Mammary Tumors", - "Mammary Tumors mRNA" - ] - ] - }, - "rat": { - "HXBBXH": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Adrenal Gland", - "Adrenal Gland mRNA" - ], - [ - "Heart", - "Heart mRNA" - ], - [ - "Hippocampus", - "Hippocampus mRNA" - ], - [ - "Kidney", - "Kidney mRNA" - ], - [ - "Liver", - "Liver mRNA" - ], - [ - "Peritoneal Fat", - "Peritoneal Fat mRNA" - ] - ], - "SRxSHRSPF2": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ], - [ - "Eye", - "Eye mRNA" - ] - ] - }, - "soybean": { - "J12XJ58F2": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ] - ] - }, - "tomato": { - "LXP": [ - [ - "Phenotypes", - "Phenotypes" - ], - [ - "Genotypes", - "Genotypes" - ] - ] - } - } -} \ No newline at end of file diff --git a/wqflask/wqflask/static/new/javascript/dataset_select_menu.coffee b/wqflask/wqflask/static/new/javascript/dataset_select_menu.coffee index e2f11845..c2a9b11d 100644 --- a/wqflask/wqflask/static/new/javascript/dataset_select_menu.coffee +++ b/wqflask/wqflask/static/new/javascript/dataset_select_menu.coffee @@ -1,393 +1,449 @@ -# -#* function: based on different browser use, will have different initial actions; -#* Once the index.html page is loaded, this function will be called -# - $ -> - sArr = window.sArr # species - gArr = window.gArr # group - tArr = window.tArr - dArr = window.dArr - lArr = window.lArr - - console.log("sArr is now [jersey]:", sArr) - console.log("gArr is now [jersey]:", gArr) - - initialDatasetSelection = -> - defaultSpecies = getDefaultValue("species") - defaultSet = getDefaultValue("cross") - defaultType = getDefaultValue("tissue") - defaultDB = getDefaultValue("database") - if navigator.userAgent.indexOf("MSIE") >= 0 - sOptions = fillOptionsForIE(null, defaultSpecies) - menu0 = "" - document.getElementById("menu0").innerHTML = menu0 - gOptions = fillOptionsForIE("species", defaultSet) - menu1 = "" - document.getElementById("menu1").innerHTML = menu1 - tOptions = fillOptionsForIE("cross", defaultType) - menu2 = "" - document.getElementById("menu2").innerHTML = menu2 - dOptions = fillOptionsForIE("tissue", defaultDB) - menu3 = "" - document.getElementById("menu3").innerHTML = menu3 - else - fillOptions null - searchtip() - - - # - #* input: selectObjId (designated select menu, such as species, cross, etc... ) - #* defaultValue (default Value of species, cross,tissue or database) - #* function: special for IE browser,setting options value for select menu dynamically based on linkage array(lArr), - #* output: options string - # - fillOptionsForIE = (selectObjId, defaultValue) -> - options = "" - unless selectObjId? - len = sArr.length - i = 1 - - while i < len - - # setting Species' option - if sArr[i].val is defaultValue - options = options + "" - else - options = options + "" - i++ - else if selectObjId is "species" - speciesObj = document.getElementById("species") - len = lArr.length - arr = [] - idx = 0 - i = 1 - - while i < len - - #get group(cross) info from lArr - arr[idx++] = lArr[i][1] if lArr[i][0] is (getIndexByValue("species", speciesObj.value)).toString() and not Contains(arr, lArr[i][1]) - i++ - idx = 0 - len = arr.length - removeOptions "cross" - i = 0 - - while i < len - - # setting Group's option - if gArr[arr[i]].val is defaultValue - options = options + "" - else - options = options + "" - i++ - else if selectObjId is "cross" - speciesObj = document.getElementById("species") - groupObj = document.getElementById("cross") - len = lArr.length - arr = [] - idx = 0 - i = 1 - - while i < len - - #get type(tissue) info from lArr - arr[idx++] = lArr[i][2] if lArr[i][0] is (getIndexByValue("species", speciesObj.value)).toString() and lArr[i][1] is (getIndexByValue("cross", groupObj.value)).toString() and not Contains(arr, lArr[i][2]) - i++ - idx = 0 - len = arr.length - removeOptions "tissue" - i = 0 - - while i < len - - # setting Type's option - if tArr[arr[i]].val is defaultValue - options = options + "" - else - options = options + "" - i++ - else if selectObjId is "tissue" - speciesObj = document.getElementById("species") - groupObj = document.getElementById("cross") - typeObj = document.getElementById("tissue") - len = lArr.length - arr = [] - idx = 0 - i = 1 - - while i < len - - #get dataset(database) info from lArr - arr[idx++] = lArr[i][3] if lArr[i][0] is (getIndexByValue("species", speciesObj.value)).toString() and lArr[i][1] is (getIndexByValue("cross", groupObj.value)).toString() and lArr[i][2] is (getIndexByValue("tissue", typeObj.value)).toString() and not Contains(arr, lArr[i][3]) - i++ - idx = 0 - len = arr.length - removeOptions "database" - i = 0 - - while i < len - - # setting Database's option - if dArr[arr[i]].val is defaultValue - options = options + "" - else - options = options + "" - i++ - options - - # - #* input: selectObjId (designated select menu, such as species, cross, etc... ) - #* function: setting options value for select menu dynamically based on linkage array(lArr) - #* output: null - # - fillOptions = (selectObjId) -> - console.log("[vacuum] selectObjId:", selectObjId) - unless selectObjId? - speciesObj = document.getElementById("species") - console.log("speciesObj:", speciesObj) - len = sArr.length - i = 1 - - while i < len - - # setting Species' option - speciesObj.options[i - 1] = new Option(sArr[i].txt, sArr[i].val) - console.log("speciesObj.options:", speciesObj.options[i - 1]) - i++ - updateChoice "species" - else if selectObjId is "species" - speciesObj = document.getElementById("species") - console.log("speciesObj:", speciesObj) - groupObj = document.getElementById("cross") - console.log("groupObj:", groupObj) - len = lArr.length - arr = [] - idx = 0 - i = 1 - while i < len - #get group(cross) info from lArr - index_value = getIndexByValue("species", speciesObj.value).toString() - if lArr[i][0] is (index_value and not Contains(arr, lArr[i][1])) - arr[idx++] = lArr[i][1] - i++ - idx = 0 - len = arr.length - removeOptions "cross" - i = 0 - - while i < len - # setting Group's option - groupObj.options[idx++] = new Option(gArr[arr[i]].txt, gArr[arr[i]].val) - i++ - updateChoice "cross" - else if selectObjId is "cross" - speciesObj = document.getElementById("species") - groupObj = document.getElementById("cross") - typeObj = document.getElementById("tissue") - len = lArr.length - arr = [] - idx = 0 - i = 1 - - while i < len - - #get type(tissue) info from lArr - arr[idx++] = lArr[i][2] if lArr[i][0] is (getIndexByValue("species", speciesObj.value)).toString() and lArr[i][1] is (getIndexByValue("cross", groupObj.value)).toString() and not Contains(arr, lArr[i][2]) - i++ - idx = 0 - len = arr.length - removeOptions "tissue" - i = 0 - - while i < len - - # setting Type's option - typeObj.options[idx++] = new Option(tArr[arr[i]].txt, tArr[arr[i]].val) - i++ - updateChoice "tissue" - else if selectObjId is "tissue" - speciesObj = document.getElementById("species") - groupObj = document.getElementById("cross") - typeObj = document.getElementById("tissue") - databaseObj = document.getElementById("database") - len = lArr.length - arr = [] - idx = 0 - i = 1 - - while i < len - - #get dataset(database) info from lArr - arr[idx++] = lArr[i][3] if lArr[i][0] is (getIndexByValue("species", speciesObj.value)).toString() and lArr[i][1] is (getIndexByValue("cross", groupObj.value)).toString() and lArr[i][2] is (getIndexByValue("tissue", typeObj.value)).toString() and not Contains(arr, lArr[i][3]) - i++ - idx = 0 - len = arr.length - removeOptions "database" - i = 0 - - while i < len - - # setting Database's option - databaseObj.options[idx++] = new Option(dArr[arr[i]].txt, dArr[arr[i]].val) - i++ - updateChoice "database" - - # - #* input: arr (targeted array); obj (targeted value) - #* function: check whether targeted array contains targeted value or not - #* output: return true, if array contains targeted value, otherwise return false - # - Contains = (arr, obj) -> - i = arr.length - return true if arr[i] is obj while i-- - false - - # - #* input: selectObj (designated select menu, such as species, cross, etc... ) - #* function: clear designated select menu's option - #* output: null - # - removeOptions = (selectObj) -> - selectObj = document.getElementById(selectObj) unless typeof selectObj is "object" - len = selectObj.options.length - i = 0 - - while i < len - - # clear current selection - selectObj.options[0] = null - i++ - - # - #* input: selectObjId (designated select menu, such as species, cross, etc... ) - #* Value: target value - #* function: retrieve Index info of target value in designated array - #* output: index info - # - getIndexByValue = (selectObjId, val) -> - if selectObjId is "species" - i = 1 - - while i < sArr.length - return i if sArr[i].val is val - i++ - else if selectObjId is "cross" - i = 1 - - while i < gArr.length - return i if gArr[i].val is val - i++ - else if selectObjId is "tissue" - i = 1 - - while i < tArr.length - return i if tArr[i].val is val - i++ - else - return - - # - #* input: objId (designated select menu, such as species, cross, etc... ) - #* val(targeted value) - #* function: setting option's selected status for designated select menu based on target value, also update the following select menu in the main search page - #* output: return true if selected status has been set, otherwise return false. - # - setChoice = (objId, val) -> - console.log("objId:", objId) - console.log("val:", val) - Obj = document.getElementById(objId) - console.log("Obj:", Obj) - idx = -1 - i = 0 - while i < Obj.options.length - if Obj.options[i].value is val - idx = i - break - i++ - if idx >= 0 + process_json = (data) -> + window.jdata = data + populate_species() + + $.ajax '/static/new/javascript/dataset_menu_structure', + dataType: 'json' + success: process_json + + populate_species = -> + species_list = @jdata.species + redo_dropdown($('#species'), species_list) + populate_groups() + + populate_groups = -> + species = $('#species').val() + group_list = @jdata.groups[species] + redo_dropdown($('#group'), group_list) + populate_types() + + populate_types = -> + species = $('#species').val() + group = $('#group').val() + type_list = @jdata.types[species][group] + redo_dropdown($('#type'), type_list) + populate_datasets() + + populate_datasets = -> + species = $('#species').val() + group = $('#group').val() + type = $('#type').val() + dataset_list = @jdata.datasets[species][group][type] + redo_dropdown($('#dataset'), dataset_list) - #setting option's selected status - Obj.options[idx].selected = true - - #update the following select menu - fillOptions objId - else - Obj.options[0].selected = true - fillOptions objId - - # setting option's selected status based on default setting or cookie setting for Species, Group, Type and Database select menu in the main search page http://www.genenetwork.org/ - updateChoice = (selectObjId) -> - if selectObjId is "species" - defaultSpecies = getDefaultValue("species") - - #setting option's selected status - setChoice "species", defaultSpecies - else if selectObjId is "cross" - defaultSet = getDefaultValue("cross") - - #setting option's selected status - setChoice "cross", defaultSet - else if selectObjId is "tissue" - defaultType = getDefaultValue("tissue") - - #setting option's selected status - setChoice "tissue", defaultType - else if selectObjId is "database" - defaultDB = getDefaultValue("database") - - #setting option's selected status - setChoice "database", defaultDB - - #get default value;if cookie exists, then use cookie value, otherwise use default value - getDefaultValue = (selectObjId) -> + redo_dropdown = (dropdown, items) -> + dropdown.empty() + for item in items + dropdown.append($("" +# else +# options = options + "" +# i++ +# else if selectObjId is "species" +# speciesObj = document.getElementById("species") +# len = lArr.length +# arr = [] +# idx = 0 +# i = 1 +# +# while i < len +# +# #get group(cross) info from lArr +# arr[idx++] = lArr[i][1] if lArr[i][0] is (getIndexByValue("species", speciesObj.value)).toString() and not Contains(arr, lArr[i][1]) +# i++ +# idx = 0 +# len = arr.length +# removeOptions "cross" +# i = 0 +# +# while i < len +# +# # setting Group's option +# if gArr[arr[i]].val is defaultValue +# options = options + "" +# else +# options = options + "" +# i++ +# else if selectObjId is "cross" +# speciesObj = document.getElementById("species") +# groupObj = document.getElementById("cross") +# len = lArr.length +# arr = [] +# idx = 0 +# i = 1 +# +# while i < len +# +# #get type(tissue) info from lArr +# arr[idx++] = lArr[i][2] if lArr[i][0] is (getIndexByValue("species", speciesObj.value)).toString() and lArr[i][1] is (getIndexByValue("cross", groupObj.value)).toString() and not Contains(arr, lArr[i][2]) +# i++ +# idx = 0 +# len = arr.length +# removeOptions "tissue" +# i = 0 +# +# while i < len +# +# # setting Type's option +# if tArr[arr[i]].val is defaultValue +# options = options + "" +# else +# options = options + "" +# i++ +# else if selectObjId is "tissue" +# speciesObj = document.getElementById("species") +# groupObj = document.getElementById("cross") +# typeObj = document.getElementById("tissue") +# len = lArr.length +# arr = [] +# idx = 0 +# i = 1 +# +# while i < len +# +# #get dataset(database) info from lArr +# arr[idx++] = lArr[i][3] if lArr[i][0] is (getIndexByValue("species", speciesObj.value)).toString() and lArr[i][1] is (getIndexByValue("cross", groupObj.value)).toString() and lArr[i][2] is (getIndexByValue("tissue", typeObj.value)).toString() and not Contains(arr, lArr[i][3]) +# i++ +# idx = 0 +# len = arr.length +# removeOptions "database" +# i = 0 +# +# while i < len +# +# # setting Database's option +# if dArr[arr[i]].val is defaultValue +# options = options + "" +# else +# options = options + "" +# i++ +# options +# +# # +# #* input: selectObjId (designated select menu, such as species, cross, etc... ) +# #* function: setting options value for select menu dynamically based on linkage array(lArr) +# #* output: null +# # +# fillOptions = (selectObjId) -> +# console.log("[vacuum] selectObjId:", selectObjId) +# unless selectObjId? +# speciesObj = document.getElementById("species") +# console.log("speciesObj:", speciesObj) +# len = sArr.length +# i = 1 +# +# while i < len +# +# # setting Species' option +# speciesObj.options[i - 1] = new Option(sArr[i].txt, sArr[i].val) +# console.log("speciesObj.options:", speciesObj.options[i - 1]) +# i++ +# updateChoice "species" +# else if selectObjId is "species" +# speciesObj = document.getElementById("species") +# console.log("speciesObj:", speciesObj) +# groupObj = document.getElementById("cross") +# console.log("groupObj:", groupObj) +# len = lArr.length +# arr = [] +# idx = 0 +# i = 1 +# +# while i < len +# #get group(cross) info from lArr +# index_value = getIndexByValue("species", speciesObj.value).toString() +# if lArr[i][0] is (index_value and not Contains(arr, lArr[i][1])) +# arr[idx++] = lArr[i][1] +# i++ +# idx = 0 +# len = arr.length +# removeOptions "cross" +# i = 0 +# +# while i < len +# # setting Group's option +# groupObj.options[idx++] = new Option(gArr[arr[i]].txt, gArr[arr[i]].val) +# i++ +# updateChoice "cross" +# else if selectObjId is "cross" +# speciesObj = document.getElementById("species") +# groupObj = document.getElementById("cross") +# typeObj = document.getElementById("tissue") +# len = lArr.length +# arr = [] +# idx = 0 +# i = 1 +# +# while i < len +# +# #get type(tissue) info from lArr +# arr[idx++] = lArr[i][2] if lArr[i][0] is (getIndexByValue("species", speciesObj.value)).toString() and lArr[i][1] is (getIndexByValue("cross", groupObj.value)).toString() and not Contains(arr, lArr[i][2]) +# i++ +# idx = 0 +# len = arr.length +# removeOptions "tissue" +# i = 0 +# +# while i < len +# +# # setting Type's option +# typeObj.options[idx++] = new Option(tArr[arr[i]].txt, tArr[arr[i]].val) +# i++ +# updateChoice "tissue" +# else if selectObjId is "tissue" +# speciesObj = document.getElementById("species") +# groupObj = document.getElementById("cross") +# typeObj = document.getElementById("tissue") +# databaseObj = document.getElementById("database") +# len = lArr.length +# arr = [] +# idx = 0 +# i = 1 +# +# while i < len +# +# #get dataset(database) info from lArr +# arr[idx++] = lArr[i][3] if lArr[i][0] is (getIndexByValue("species", speciesObj.value)).toString() and lArr[i][1] is (getIndexByValue("cross", groupObj.value)).toString() and lArr[i][2] is (getIndexByValue("tissue", typeObj.value)).toString() and not Contains(arr, lArr[i][3]) +# i++ +# idx = 0 +# len = arr.length +# removeOptions "database" +# i = 0 +# +# while i < len +# +# # setting Database's option +# databaseObj.options[idx++] = new Option(dArr[arr[i]].txt, dArr[arr[i]].val) +# i++ +# updateChoice "database" +# +# # +# #* input: arr (targeted array); obj (targeted value) +# #* function: check whether targeted array contains targeted value or not +# #* output: return true, if array contains targeted value, otherwise return false +# # +# Contains = (arr, obj) -> +# i = arr.length +# return true if arr[i] is obj while i-- +# false +# +# # +# #* input: selectObj (designated select menu, such as species, cross, etc... ) +# #* function: clear designated select menu's option +# #* output: null +# # +# removeOptions = (selectObj) -> +# selectObj = document.getElementById(selectObj) unless typeof selectObj is "object" +# len = selectObj.options.length +# i = 0 +# +# while i < len +# +# # clear current selection +# selectObj.options[0] = null +# i++ +# +# # +# #* input: selectObjId (designated select menu, such as species, cross, etc... ) +# #* Value: target value +# #* function: retrieve Index info of target value in designated array +# #* output: index info +# # +# getIndexByValue = (selectObjId, val) -> +# if selectObjId is "species" +# i = 1 +# +# while i < sArr.length +# return i if sArr[i].val is val +# i++ +# else if selectObjId is "cross" +# i = 1 +# +# while i < gArr.length +# return i if gArr[i].val is val +# i++ +# else if selectObjId is "tissue" +# i = 1 +# +# while i < tArr.length +# return i if tArr[i].val is val +# i++ +# else +# return +# +# # +# #* input: objId (designated select menu, such as species, cross, etc... ) +# #* val(targeted value) +# #* function: setting option's selected status for designated select menu based on target value, also update the following select menu in the main search page +# #* output: return true if selected status has been set, otherwise return false. +# # +# setChoice = (objId, val) -> +# console.log("objId:", objId) +# console.log("val:", val) +# Obj = document.getElementById(objId) +# console.log("Obj:", Obj) +# idx = -1 +# i = 0 +# while i < Obj.options.length +# if Obj.options[i].value is val +# idx = i +# break +# i++ +# if idx >= 0 +# +# #setting option's selected status +# Obj.options[idx].selected = true +# +# #update the following select menu +# fillOptions objId +# else +# Obj.options[0].selected = true +# fillOptions objId +# +# # setting option's selected status based on default setting or cookie setting for Species, Group, Type and Database select menu in the main search page http://www.genenetwork.org/ +# updateChoice = (selectObjId) -> +# if selectObjId is "species" +# defaultSpecies = getDefaultValue("species") +# +# #setting option's selected status +# setChoice "species", defaultSpecies +# else if selectObjId is "cross" +# defaultSet = getDefaultValue("cross") +# +# #setting option's selected status +# setChoice "cross", defaultSet +# else if selectObjId is "tissue" +# defaultType = getDefaultValue("tissue") +# +# #setting option's selected status +# setChoice "tissue", defaultType +# else if selectObjId is "database" +# defaultDB = getDefaultValue("database") +# +# #setting option's selected status +# setChoice "database", defaultDB +# +# #get default value;if cookie exists, then use cookie value, otherwise use default value +# getDefaultValue = (selectObjId) -> +# +# #define default value +# defaultSpecies = "mouse" +# defaultSet = "BXD" +# defaultType = "Hippocampus" +# defaultDB = "HC_M2_0606_P" +# if selectObjId is "species" +# +# #if cookie exists, then use cookie value, otherwise use default value +# cookieSpecies = getCookie("defaultSpecies") +# defaultSpecies = cookieSpecies if cookieSpecies +# defaultSpecies +# else if selectObjId is "cross" +# cookieSet = getCookie("defaultSet") +# defaultSet = cookieSet if cookieSet +# defaultSet +# else if selectObjId is "tissue" +# cookieType = getCookie("defaultType") +# defaultType = cookieType if cookieType +# defaultType +# else if selectObjId is "database" +# cookieDB = getCookie("defaultDB") +# defaultDB = cookieDB if cookieDB +# defaultDB +# +# #setting default value into cookies for the dropdown menus: Species,Group, Type, and Database +# setDefault = (thisform) -> +# setCookie "cookieTest", "cookieTest", 1 +# cookieTest = getCookie("cookieTest") +# delCookie "cookieTest" +# if cookieTest +# defaultSpecies = thisform.species.value +# setCookie "defaultSpecies", defaultSpecies, 10 +# defaultSet = thisform.cross.value +# setCookie "defaultSet", defaultSet, 10 +# defaultType = thisform.tissue.value +# setCookie "defaultType", defaultType, 10 +# defaultDB = thisform.database.value +# setCookie "defaultDB", defaultDB, 10 +# updateChoice "species" +# updateChoice "cross" +# updateChoice "tissue" +# updateChoice "database" +# alert "The current settings are now your default" +# else +# alert "You need to enable Cookies in your browser." +# +# # run it +# initialDatasetSelection() \ No newline at end of file diff --git a/wqflask/wqflask/static/new/javascript/dataset_select_menu.js b/wqflask/wqflask/static/new/javascript/dataset_select_menu.js index eb04839c..8f684f6a 100644 --- a/wqflask/wqflask/static/new/javascript/dataset_select_menu.js +++ b/wqflask/wqflask/static/new/javascript/dataset_select_menu.js @@ -2,372 +2,64 @@ (function() { $(function() { - var Contains, dArr, fillOptions, fillOptionsForIE, gArr, getDefaultValue, getIndexByValue, initialDatasetSelection, lArr, removeOptions, sArr, setChoice, setDefault, tArr, updateChoice; - sArr = window.sArr; - gArr = window.gArr; - tArr = window.tArr; - dArr = window.dArr; - lArr = window.lArr; - console.log("sArr is now [jersey]:", sArr); - console.log("gArr is now [jersey]:", gArr); - initialDatasetSelection = function() { - var dOptions, defaultDB, defaultSet, defaultSpecies, defaultType, gOptions, menu0, menu1, menu2, menu3, sOptions, tOptions; - defaultSpecies = getDefaultValue("species"); - defaultSet = getDefaultValue("cross"); - defaultType = getDefaultValue("tissue"); - defaultDB = getDefaultValue("database"); - if (navigator.userAgent.indexOf("MSIE") >= 0) { - sOptions = fillOptionsForIE(null, defaultSpecies); - menu0 = ""; - document.getElementById("menu0").innerHTML = menu0; - gOptions = fillOptionsForIE("species", defaultSet); - menu1 = ""; - document.getElementById("menu1").innerHTML = menu1; - tOptions = fillOptionsForIE("cross", defaultType); - menu2 = ""; - document.getElementById("menu2").innerHTML = menu2; - dOptions = fillOptionsForIE("tissue", defaultDB); - menu3 = ""; - document.getElementById("menu3").innerHTML = menu3; - } else { - fillOptions(null); - } - return searchtip(); + var populate_datasets, populate_groups, populate_species, populate_types, process_json, redo_dropdown, + _this = this; + process_json = function(data) { + window.jdata = data; + return populate_species(); }; - fillOptionsForIE = function(selectObjId, defaultValue) { - var arr, groupObj, i, idx, len, options, speciesObj, typeObj; - options = ""; - if (selectObjId == null) { - len = sArr.length; - i = 1; - while (i < len) { - if (sArr[i].val === defaultValue) { - options = options + ""; - } else { - options = options + ""; - } - i++; - } - } else if (selectObjId === "species") { - speciesObj = document.getElementById("species"); - len = lArr.length; - arr = []; - idx = 0; - i = 1; - while (i < len) { - if (lArr[i][0] === (getIndexByValue("species", speciesObj.value)).toString() && !Contains(arr, lArr[i][1])) { - arr[idx++] = lArr[i][1]; - } - i++; - } - idx = 0; - len = arr.length; - removeOptions("cross"); - i = 0; - while (i < len) { - if (gArr[arr[i]].val === defaultValue) { - options = options + ""; - } else { - options = options + ""; - } - i++; - } - } else if (selectObjId === "cross") { - speciesObj = document.getElementById("species"); - groupObj = document.getElementById("cross"); - len = lArr.length; - arr = []; - idx = 0; - i = 1; - while (i < len) { - if (lArr[i][0] === (getIndexByValue("species", speciesObj.value)).toString() && lArr[i][1] === (getIndexByValue("cross", groupObj.value)).toString() && !Contains(arr, lArr[i][2])) { - arr[idx++] = lArr[i][2]; - } - i++; - } - idx = 0; - len = arr.length; - removeOptions("tissue"); - i = 0; - while (i < len) { - if (tArr[arr[i]].val === defaultValue) { - options = options + ""; - } else { - options = options + ""; - } - i++; - } - } else if (selectObjId === "tissue") { - speciesObj = document.getElementById("species"); - groupObj = document.getElementById("cross"); - typeObj = document.getElementById("tissue"); - len = lArr.length; - arr = []; - idx = 0; - i = 1; - while (i < len) { - if (lArr[i][0] === (getIndexByValue("species", speciesObj.value)).toString() && lArr[i][1] === (getIndexByValue("cross", groupObj.value)).toString() && lArr[i][2] === (getIndexByValue("tissue", typeObj.value)).toString() && !Contains(arr, lArr[i][3])) { - arr[idx++] = lArr[i][3]; - } - i++; - } - idx = 0; - len = arr.length; - removeOptions("database"); - i = 0; - while (i < len) { - if (dArr[arr[i]].val === defaultValue) { - options = options + ""; - } else { - options = options + ""; - } - i++; - } - } - return options; + $.ajax('/static/new/javascript/dataset_menu_structure', { + dataType: 'json', + success: process_json + }); + populate_species = function() { + var species_list; + species_list = this.jdata.species; + redo_dropdown($('#species'), species_list); + return populate_groups(); }; - fillOptions = function(selectObjId) { - var arr, databaseObj, groupObj, i, idx, index_value, len, speciesObj, typeObj; - console.log("[vacuum] selectObjId:", selectObjId); - if (selectObjId == null) { - speciesObj = document.getElementById("species"); - console.log("speciesObj:", speciesObj); - len = sArr.length; - i = 1; - while (i < len) { - speciesObj.options[i - 1] = new Option(sArr[i].txt, sArr[i].val); - console.log("speciesObj.options:", speciesObj.options[i - 1]); - i++; - } - return updateChoice("species"); - } else if (selectObjId === "species") { - speciesObj = document.getElementById("species"); - console.log("speciesObj:", speciesObj); - groupObj = document.getElementById("cross"); - console.log("groupObj:", groupObj); - len = lArr.length; - arr = []; - idx = 0; - i = 1; - while (i < len) { - index_value = getIndexByValue("species", speciesObj.value).toString(); - if (lArr[i][0] === (index_value && !Contains(arr, lArr[i][1]))) { - arr[idx++] = lArr[i][1]; - } - i++; - } - idx = 0; - len = arr.length; - removeOptions("cross"); - i = 0; - while (i < len) { - groupObj.options[idx++] = new Option(gArr[arr[i]].txt, gArr[arr[i]].val); - i++; - } - return updateChoice("cross"); - } else if (selectObjId === "cross") { - speciesObj = document.getElementById("species"); - groupObj = document.getElementById("cross"); - typeObj = document.getElementById("tissue"); - len = lArr.length; - arr = []; - idx = 0; - i = 1; - while (i < len) { - if (lArr[i][0] === (getIndexByValue("species", speciesObj.value)).toString() && lArr[i][1] === (getIndexByValue("cross", groupObj.value)).toString() && !Contains(arr, lArr[i][2])) { - arr[idx++] = lArr[i][2]; - } - i++; - } - idx = 0; - len = arr.length; - removeOptions("tissue"); - i = 0; - while (i < len) { - typeObj.options[idx++] = new Option(tArr[arr[i]].txt, tArr[arr[i]].val); - i++; - } - return updateChoice("tissue"); - } else if (selectObjId === "tissue") { - speciesObj = document.getElementById("species"); - groupObj = document.getElementById("cross"); - typeObj = document.getElementById("tissue"); - databaseObj = document.getElementById("database"); - len = lArr.length; - arr = []; - idx = 0; - i = 1; - while (i < len) { - if (lArr[i][0] === (getIndexByValue("species", speciesObj.value)).toString() && lArr[i][1] === (getIndexByValue("cross", groupObj.value)).toString() && lArr[i][2] === (getIndexByValue("tissue", typeObj.value)).toString() && !Contains(arr, lArr[i][3])) { - arr[idx++] = lArr[i][3]; - } - i++; - } - idx = 0; - len = arr.length; - removeOptions("database"); - i = 0; - while (i < len) { - databaseObj.options[idx++] = new Option(dArr[arr[i]].txt, dArr[arr[i]].val); - i++; - } - return updateChoice("database"); - } + populate_groups = function() { + var group_list, species; + species = $('#species').val(); + group_list = this.jdata.groups[species]; + redo_dropdown($('#group'), group_list); + return populate_types(); }; - Contains = function(arr, obj) { - var i; - i = arr.length; - if ((function() { - var _results; - _results = []; - while (i--) { - _results.push(arr[i] === obj); - } - return _results; - })()) { - return true; - } - return false; + populate_types = function() { + var group, species, type_list; + species = $('#species').val(); + group = $('#group').val(); + type_list = this.jdata.types[species][group]; + redo_dropdown($('#type'), type_list); + return populate_datasets(); }; - removeOptions = function(selectObj) { - var i, len, _results; - if (typeof selectObj !== "object") { - selectObj = document.getElementById(selectObj); - } - len = selectObj.options.length; - i = 0; + populate_datasets = function() { + var dataset_list, group, species, type; + species = $('#species').val(); + group = $('#group').val(); + type = $('#type').val(); + dataset_list = this.jdata.datasets[species][group][type]; + return redo_dropdown($('#dataset'), dataset_list); + }; + redo_dropdown = function(dropdown, items) { + var item, _i, _len, _results; + dropdown.empty(); _results = []; - while (i < len) { - selectObj.options[0] = null; - _results.push(i++); + for (_i = 0, _len = items.length; _i < _len; _i++) { + item = items[_i]; + _results.push(dropdown.append($("' -ctext += '' -ctext += '' -ctext += '' -ctext += '' -ctext += '' -ctext += '' +ctext = '' +ctext += '' +ctext += '' +ctext += '' +ctext += '' +ctext += '' +ctext += '' +ctext += '' document.write(ctext) \ No newline at end of file diff --git a/wqflask/base/webqtlDataset.py b/wqflask/base/webqtlDataset.py index 4f98e90c..933077fd 100755 --- a/wqflask/base/webqtlDataset.py +++ b/wqflask/base/webqtlDataset.py @@ -34,6 +34,7 @@ class webqtlDataset: """ Dataset class defines a dataset in webqtl, can be either Microarray, Published phenotype, genotype, or user input dataset(temp) + """ def __init__(self, dbName, cursor=None): @@ -42,7 +43,7 @@ class webqtlDataset: self.id = 0 self.name = '' self.type = '' - self.riset = '' + self.group = '' self.cursor = cursor #temporary storage @@ -81,14 +82,15 @@ class webqtlDataset: self.name = dbName if self.cursor and self.id == 0: self.retrieveName() - - def __str__(self): - return self.name - - __repr__ = __str__ + + + # Delete this eventually + @property + def riset(): + Weve_Renamed_This_As_Group - def getRISet(self): + def get_group(self): assert self.cursor if self.type == 'Publish': query = ''' @@ -124,12 +126,12 @@ class webqtlDataset: else: return "" self.cursor.execute(query) - RISet, RIID = self.cursor.fetchone() - if RISet == 'BXD300': - RISet = "BXD" - self.riset = RISet - self.risetid = RIID - return RISet + group, RIID = self.cursor.fetchone() + if group == 'BXD300': + group = "BXD" + self.group = group + self.group_id = RIID + return group def retrieveName(self): diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index 1b846771..2269b9e7 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -36,17 +36,9 @@ from wqflask import parser from utility import webqtlUtil from dbFunction import webqtlDatabaseFunction -#import logging -#logging.basicConfig(filename=app.config['LOGFILE'], level=logging.INFO) -# -#_log = logging.getLogger("search") -#_ch = logging.StreamHandler() -#_log.addHandler(_ch) - from utility import formatting import sys -#_log.info("sys.path is: %s" % (sys.path)) #from base.JinjaPage import JinjaEnv, JinjaPage @@ -64,116 +56,112 @@ class SearchResultPage(templatePage): import logging_tree logging_tree.printout() self.fd = fd - if not self.openMysql(): - print("ge0") - #return - - print("Start...") - print("Type of fd:", type(fd)) - print("Value of fd:", pf(fd)) - database = [fd['database']] - print("End...") - - # change back to self.database - if not self.database or self.database == 'spacer': - #Error, No database selected + templatePage.__init__(self, fd) + assert self.openMysql(), "Couldn't open MySQL" + + print("fd is:", pf(fd)) + self.dataset = fd['dataset'] + + # change back to self.dataset + if not self.dataset or self.dataset == 'spacer': + #Error, No dataset selected heading = "Search Result" - detail = ['''No database was selected for this search, please - go back and SELECT at least one database.'''] - print("ge0.6") - self.error(heading=heading,detail=detail,error="No Database Selected") - #return + detail = ['''No dataset was selected for this search, please + go back and SELECT at least one dataset.'''] + self.error(heading=heading,detail=detail,error="No dataset Selected") + return - print("ge1") ########################################### # Names and IDs of RISet / F2 set ########################################### - if self.database == ['_allPublish']: + if self.dataset == "All Phenotypes": self.cursor.execute(""" select PublishFreeze.Name, InbredSet.Name, InbredSet.Id from PublishFreeze, InbredSet where PublishFreeze.Name not like 'BXD300%' and InbredSet.Id = PublishFreeze.InbredSetId""") results = self.cursor.fetchall() - self.database = map(lambda x: webqtlDataset(x[0], self.cursor), results) - self.databaseCrosses = map(lambda x: x[1], results) - self.databaseCrossIds = map(lambda x: x[2], results) - self.singleCross = False + self.dataset = map(lambda x: webqtlDataset(x[0], self.cursor), results) + self.datasetGroups = map(lambda x: x[1], results) + self.datasetGroupIds = map(lambda x: x[2], results) + self.single_group = False else: - self.database = map(lambda x: webqtlDataset(x, self.cursor), self.database) + print("self.dataset is:", pf(self.dataset)) + self.dataset = webqtlDataset(self.dataset, self.cursor) + print("self.dataset is now:", pf(self.dataset)) + #self.dataset = map(lambda x: webqtlDataset(x, self.cursor), self.dataset) #currently, webqtl won't allow multiple crosses #for other than multiple publish db search - #so we can use the first database as example - if self.database[0].type=="Publish": - pass - elif self.database[0].type in ("Geno", "ProbeSet"): + #so we can use the first dataset as example + #if self.dataset.type=="Publish": + # pass + if self.dataset.type in ("Geno", "ProbeSet"): #userExist = None - - for individualDB in self.database: - # Can't use paramater substitution for table names apparently - db_type = self.database[0].type + "Freeze" - print("db_type [%s]: %s" % (type(db_type), db_type)) - - query = '''SELECT Id, Name, FullName, confidentiality, - AuthorisedUsers FROM %s WHERE Name = %%s''' % (db_type) - - self.cursor.execute(query, (individualDB,)) - - (indId, - indName, - indFullName, - confidential, - AuthorisedUsers) = self.cursor.fetchall()[0] - - if confidential: - access_to_confidential_dataset = 0 - - #for the dataset that confidentiality is 1 - #1. 'admin' and 'root' can see all of the dataset - #2. 'user' can see the dataset that AuthorisedUsers contains his id(stored in the Id field of User table) - if webqtlConfig.USERDICT[self.privilege] > webqtlConfig.USERDICT['user']: - access_to_confidential_dataset = 1 - else: - AuthorisedUsersList=AuthorisedUsers.split(',') - if AuthorisedUsersList.__contains__(self.userName): - access_to_confidential_dataset = 1 - - if not access_to_confidential_dataset: - #Error, No database selected - heading = "Search Result" - detail = ["The %s database you selected is not open to the public at this time, please go back and SELECT other database." % indFullName] - self.error(heading=heading,detail=detail,error="Confidential Database") - return - else: - heading = "Search Result" - detail = ['''The database has not been established yet, please - go back and SELECT at least one database.'''] - self.error(heading=heading,detail=detail,error="No Database Selected") - return - - print("ge2") - self.database[0].getRISet() - self.databaseCrosses = [self.database[0].riset] - self.databaseCrossIds = [self.database[0].risetid] - self.singleCross = True - #XZ, August 24,2010: Since self.singleCross = True, it's safe to assign one species Id. - self.speciesId = webqtlDatabaseFunction.retrieveSpeciesId(self.cursor, self.database[0].riset) + # Can't use paramater substitution for table names apparently + db_type = self.dataset.type + "Freeze" + print("db_type [%s]: %s" % (type(db_type), db_type)) + + query = '''SELECT Id, Name, FullName, confidentiality, + AuthorisedUsers FROM %s WHERE Name = %%s''' % (db_type) + + self.cursor.execute(query, self.dataset.name) + + (indId, + indName, + indFullName, + confidential, + AuthorisedUsers) = self.cursor.fetchall()[0] + + if confidential: + # Allow confidential data later + NoConfindetialDataForYouTodaySorry + #access_to_confidential_dataset = 0 + # + ##for the dataset that confidentiality is 1 + ##1. 'admin' and 'root' can see all of the dataset + ##2. 'user' can see the dataset that AuthorisedUsers contains his id(stored in the Id field of User table) + #if webqtlConfig.USERDICT[self.privilege] > webqtlConfig.USERDICT['user']: + # access_to_confidential_dataset = 1 + #else: + # AuthorisedUsersList=AuthorisedUsers.split(',') + # if AuthorisedUsersList.__contains__(self.userName): + # access_to_confidential_dataset = 1 + # + #if not access_to_confidential_dataset: + # #Error, No dataset selected + # heading = "Search Result" + # detail = ["The %s dataset you selected is not open to the public at this time, please go back and SELECT other dataset." % indFullName] + # self.error(heading=heading,detail=detail,error="Confidential dataset") + # return + #else: + # heading = "Search Result" + # detail = ['''The dataset has not been established yet, please + # go back and SELECT at least one dataset.'''] + # self.error(heading=heading,detail=detail,error="No dataset Selected") + # return + + self.dataset.get_group() + self.single_group = True + #XZ, August 24,2010: Since self.single_group = True, it's safe to assign one species Id. + self.species_id = webqtlDatabaseFunction.retrieveSpeciesId(self.cursor, + self.dataset.group) ########################################### - # make sure search from same type of databases + # make sure search from same type of datasets ########################################### - #dbTypes = map(lambda X: X.type, self.database) - dbTypes = [table.type for table in self.database] - self.dbType = dbTypes[0] - for item in dbTypes: - if item != self.dbType: - heading = "Search Result" - detail = ["Search can only be performed among the same type of databases"] - self.error(heading=heading,detail=detail,error="Error") - return - - print("ge3") - if self.dbType == "Publish": + #dbTypes = map(lambda X: X.type, self.dataset) + #db_types = [table.type for table in self.dataset] + #self.db_type = db_types[0] + #for item in dbTypes: + # if item != self.dbType: + # heading = "Search Result" + # detail = ["Search can only be performed among the same type of datasets"] + # self.error(heading=heading,detail=detail,error="Error") + # return + + + #self.db_type = self.dataset.type + if self.dataset.type == "Publish": self.searchField = ['Phenotype.Post_publication_description', 'Phenotype.Pre_publication_description', 'Phenotype.Pre_publication_abbreviation', @@ -185,7 +173,7 @@ class SearchResultPage(templatePage): 'Publication.Authors', 'PublishXRef.Id'] - elif self.dbType == "ProbeSet": + elif self.dataset.type == "ProbeSet": self.searchField = ['Name', 'Description', 'Probe_Target_Description', @@ -194,11 +182,12 @@ class SearchResultPage(templatePage): 'GenbankId', 'UniGeneId', 'RefSeq_TranscriptId'] - elif self.dbType == "Geno": + elif self.dataset.type == "Geno": self.searchField = ['Name','Chr'] - print("ge4") + self.do_search() + self.gen_search_result() ########################################### # Search Options @@ -272,11 +261,11 @@ class SearchResultPage(templatePage): # return #self.nresults = self.executeQuery() # - #if len(self.database) > 1: - # dbUrl = "Multiple phenotype databases" + #if len(self.dataset) > 1: + # dbUrl = "Multiple phenotype datasets" # dbUrlLink = " were" #else: - # dbUrl = self.database[0].genHTML() + # dbUrl = self.dataset[0].genHTML() # dbUrlLink = " was" #SearchText = HT.Blockquote('GeneNetwork searched the ', dbUrl, ' for all records ') @@ -355,17 +344,13 @@ class SearchResultPage(templatePage): #TD_LR.append(HT.Paragraph('Search Results', Class="title"), SearchText) - self.start_search() - self.genSearchResultTable() #self.dict['body'] = str(TD_LR) #self.dict['js1'] = '' #self.dict['js2'] = 'onLoad="pageOffset()"' #self.dict['layer'] = self.generateWarningLayer() - def start_search(self): - pass - def genSearchResultTable(self): + def gen_search_result(self): #pageTable = HT.TableLite(cellSpacing=2,cellPadding=0,width="100%",border=0) @@ -399,8 +384,8 @@ class SearchResultPage(templatePage): #tbl = HT.TableLite(cellSpacing=2,cellPadding=0,width="90%",border=0) #seq = self.pageNumber*self.NPerPage+1 //Edited out because we show all results in one page now - Zach 2/22/11 seq = 1 - RISet = self.databaseCrosses[i] - self.thisFormName = thisFormName = 'showDatabase'+RISet + group = self.databaseCrosses[i] + self.thisFormName = thisFormName = 'showDatabase'+group #selectall = HT.Href(url="#", onClick="checkAll(document.getElementsByName('%s')[0]);" % thisFormName) #selectall_img = HT.Image("/images/select_all2_final.jpg", name="selectall", alt="Select All", title="Select All", style="border:none;") #selectall.append(selectall_img) @@ -423,7 +408,7 @@ class SearchResultPage(templatePage): tblobj = {} mainfmName = thisFormName - species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, RISet=RISet) + species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, RISet=group) if thisTrait.db.type=="Geno": tblobj['header'] = self.getTableHeaderForGeno(worksheet=worksheet, newrow=newrow, headingStyle=headingStyle) @@ -480,7 +465,7 @@ class SearchResultPage(templatePage): #traitForm = HT.Form(cgi= os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), enctype='multipart/form-data', name=thisFormName, submit=HT.Input(type='hidden')) - hddn = {'FormID':'showDatabase','ProbeSetID':'_','database':'_','CellID':'_','RISet':RISet} + hddn = {'FormID':'showDatabase','ProbeSetID':'_','database':'_','CellID':'_','group':group} hddn['incparentsf1']='ON' # for key in hddn.keys(): # traitForm.append(HT.Input(name=key, value=hddn[key], type='hidden')) diff --git a/wqflask/wqflask/templates/index_page.html b/wqflask/wqflask/templates/index_page.html index db0b2d9e..695129a9 100644 --- a/wqflask/wqflask/templates/index_page.html +++ b/wqflask/wqflask/templates/index_page.html @@ -1,320 +1,423 @@ -{% extends "base.html" %} -{% block title %}GeneNetwork{% endblock %} -{% block content %} - - - - - - - -{% endblock %} +

To try them out copy these examples into the search field:

+ +
    +
  • POSITION=(chr1 25 30) finds genes, markers, or transcripts on + chromosome 1 between 25 and 30 Mb.
  • +
  • MEAN=(15 16) LRS=(23 46) in the Combined field finds + highly expressed genes (15 to 16 log2 units) AND with peak LRS + linkage between 23 and 46.
  • + +
  • RIF=mitochondrial searches RNA databases for + GeneRIF links.
  • + +
  • WIKI=nicotine searches + GeneWiki for genes that you or other users have annotated + with the word nicotine.
  • + +
  • GO:0045202 searches for synapse-associated genes listed in the + + Gene Ontology.
  • + +
  • GO:0045202 LRS=(9 99 Chr4 122 155) cisLRS=(9 999 10) + finds synapse-associated genes with + cis eQTL on Chr 4 from 122 and 155 Mb with LRS scores + between 9 and 999.
  • + +
  • RIF=diabetes LRS=(9 999 Chr2 100 105) transLRS=(9 999 10) + finds diabetes-associated transcripts with peak + trans eQTLs on Chr 2 between 100 and 105 Mb with LRS + scores between 9 and 999.
  • +
+ + +
+ + +

Thirty minute tour

+

+ Take the 30 minute + GeneNetwork tour that includes screen shots and + typical steps in the analysis. +

+ +

Even more info

+

+ For information about + resources and methods, select the Info buttons next to the Group + and Database fields above. +

+ +

The conditions + and contact + pages have information on the status of data sets + and advice on their use and citation.

+ +
+ +
+ +

Websites affiliated with GeneNetwork

+ +

Mirror and development sites

+ +

History and archive

+ +

The + + time machine + has earlier versions that correspond to specific publication dates. +

+ +

The next generation

+

Try the + development site to explore experimental data and features.

+
+ + + + + + + + + + + + + + + + + + diff --git a/wqflask/wqflask/templates/new_index_page.html b/wqflask/wqflask/templates/new_index_page.html deleted file mode 100644 index 695129a9..00000000 --- a/wqflask/wqflask/templates/new_index_page.html +++ /dev/null @@ -1,423 +0,0 @@ - - - - - GeneNetwork - - - - - - - - - - - - - - - - - -
-
-

GeneNetwork

-

Open source bioinformatics for systems genetics
- Brought to you by the University of Tennessee

-
-
- - -
-
- - -
- - -
- - -
    -
  1. Select Species (or All)
  2. - -
  3. Select Group (a specific sample)
  4. - -
  5. Select Type of data: - -
      -
    • Phenotype (traits)
    • - -
    • Genotype (markers)
    • - -
    • Expression (mRNAs)
    • -
    -
  6. - -
  7. Select a Database
  8. - -
  9. Enter terms in the search field: words, - genes, ID numbers, probes, advanced search commands
  10. - -
  11. Click the Search button
  12. - -
  13. Optional: Use the Make Default button to save your preferences
  14. -
- -

User Guide

-
Read the - - user guide.
- -
- - -
- - -

GeneNetwork supports a variety of advanced searches.

- -

To try them out copy these examples into the search field:

- -
    -
  • POSITION=(chr1 25 30) finds genes, markers, or transcripts on - chromosome 1 between 25 and 30 Mb.
  • - -
  • MEAN=(15 16) LRS=(23 46) in the Combined field finds - highly expressed genes (15 to 16 log2 units) AND with peak LRS - linkage between 23 and 46.
  • - -
  • RIF=mitochondrial searches RNA databases for - GeneRIF links.
  • - -
  • WIKI=nicotine searches - GeneWiki for genes that you or other users have annotated - with the word nicotine.
  • - -
  • GO:0045202 searches for synapse-associated genes listed in the - - Gene Ontology.
  • - -
  • GO:0045202 LRS=(9 99 Chr4 122 155) cisLRS=(9 999 10) - finds synapse-associated genes with - cis eQTL on Chr 4 from 122 and 155 Mb with LRS scores - between 9 and 999.
  • - -
  • RIF=diabetes LRS=(9 999 Chr2 100 105) transLRS=(9 999 10) - finds diabetes-associated transcripts with peak - trans eQTLs on Chr 2 between 100 and 105 Mb with LRS - scores between 9 and 999.
  • -
-
- -
- - -

Thirty minute tour

-

- Take the 30 minute - GeneNetwork tour that includes screen shots and - typical steps in the analysis. -

- -

Even more info

-

- For information about - resources and methods, select the Info buttons next to the Group - and Database fields above. -

- -

The conditions - and contact - pages have information on the status of data sets - and advice on their use and citation.

- -
- -
- -

Websites affiliated with GeneNetwork

- -

Mirror and development sites

- -

History and archive

- -

The - - time machine - has earlier versions that correspond to specific publication dates. -

- -

The next generation

-

Try the - development site to explore experimental data and features.

-
-
-
-
- - - - - - - - - - - - - - - diff --git a/wqflask/wqflask/templates/old_index_page.html b/wqflask/wqflask/templates/old_index_page.html new file mode 100644 index 00000000..db0b2d9e --- /dev/null +++ b/wqflask/wqflask/templates/old_index_page.html @@ -0,0 +1,320 @@ +{% extends "base.html" %} +{% block title %}GeneNetwork{% endblock %} +{% block content %} + + + + + + + +{% endblock %} + diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index d639ed07..629a5b15 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -33,13 +33,6 @@ def index_page(): print("Sending index_page") return render_template("index_page.html") - -@app.route("/new") -def new_index_page(): - print("Sending index_page") - - return render_template("new_index_page.html") - @app.route("/data_sharing") def data_sharing_page(): print("In data_sharing") -- cgit v1.2.3 From 5083b031f0041f6df3c99180bd06243625af728e Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Fri, 26 Oct 2012 17:02:42 -0500 Subject: Got search page working for mice with a single gene search --- wqflask/base/templatePage.py | 20 +- wqflask/base/webqtlTrait.py | 2 +- wqflask/wqflask/search_results.py | 370 ++++++++++++---------- wqflask/wqflask/templates/search_result_page.html | 52 ++- wqflask/wqflask/views.py | 3 +- 5 files changed, 231 insertions(+), 216 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/templatePage.py b/wqflask/base/templatePage.py index 7ef58a72..a94d5153 100755 --- a/wqflask/base/templatePage.py +++ b/wqflask/base/templatePage.py @@ -155,29 +155,29 @@ class templatePage: def openMysql(self): try: - self.con = MySQLdb.Connect(db=webqtlConfig.DB_NAME,host=webqtlConfig.MYSQL_SERVER, \ + self.db_conn = MySQLdb.Connect(db=webqtlConfig.DB_NAME,host=webqtlConfig.MYSQL_SERVER, \ user=webqtlConfig.DB_USER,passwd=webqtlConfig.DB_PASSWD) - self.cursor = self.con.cursor() - return 1 - except: + self.cursor = self.db_conn.cursor() + return True + except Exception: heading = "Connect MySQL Server" detail = ["Can't connect to MySQL server on '"+ webqtlConfig.MYSQL_SERVER+"':100061. \ The server may be down at this time"] self.error(heading=heading,detail=detail,error="Error 2003") - return 0 + return False def updMysql(self): try: - self.con = MySQLdb.Connect(db=webqtlConfig.DB_UPDNAME,host=webqtlConfig.MYSQL_UPDSERVER, \ + self.db_conn = MySQLdb.Connect(db=webqtlConfig.DB_UPDNAME,host=webqtlConfig.MYSQL_UPDSERVER, \ user=webqtlConfig.DB_UPDUSER,passwd=webqtlConfig.DB_UPDPASSWD) - self.cursor = self.con.cursor() - return 1 - except: + self.cursor = self.db_conn.cursor() + return True + except Exception: heading = "Connect MySQL Server" detail = ["update: Can't connect to MySQL server on '"+ webqtlConfig.MYSQL_UPDSERVER+"':100061. \ The server may be down at this time "] self.error(heading=heading,detail=detail,error="Error 2003") - return 0 + return False def error(self,heading="",intro=[],detail=[],title="Error",error="Error"): 'generating a WebQTL style error page' diff --git a/wqflask/base/webqtlTrait.py b/wqflask/base/webqtlTrait.py index d6d537b7..46af6683 100755 --- a/wqflask/base/webqtlTrait.py +++ b/wqflask/base/webqtlTrait.py @@ -67,7 +67,7 @@ class webqtlTrait: ''', self.name) self.riset = self.cursor.fetchone()[0] else: - self.riset = self.db.getRISet() + self.riset = self.db.get_group() # # In ProbeSet, there are maybe several annotations match one sequence diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index 2269b9e7..8fc12b16 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -81,8 +81,8 @@ class SearchResultPage(templatePage): PublishFreeze.InbredSetId""") results = self.cursor.fetchall() self.dataset = map(lambda x: webqtlDataset(x[0], self.cursor), results) - self.datasetGroups = map(lambda x: x[1], results) - self.datasetGroupIds = map(lambda x: x[2], results) + self.dataset_groups = map(lambda x: x[1], results) + self.dataset_group_ids = map(lambda x: x[2], results) self.single_group = False else: print("self.dataset is:", pf(self.dataset)) @@ -162,7 +162,7 @@ class SearchResultPage(templatePage): #self.db_type = self.dataset.type if self.dataset.type == "Publish": - self.searchField = ['Phenotype.Post_publication_description', + self.search_fields = ['Phenotype.Post_publication_description', 'Phenotype.Pre_publication_description', 'Phenotype.Pre_publication_abbreviation', 'Phenotype.Post_publication_abbreviation', @@ -174,7 +174,7 @@ class SearchResultPage(templatePage): 'PublishXRef.Id'] elif self.dataset.type == "ProbeSet": - self.searchField = ['Name', + self.search_fields = ['Name', 'Description', 'Probe_Target_Description', 'Symbol', @@ -183,7 +183,7 @@ class SearchResultPage(templatePage): 'UniGeneId', 'RefSeq_TranscriptId'] elif self.dataset.type == "Geno": - self.searchField = ['Name','Chr'] + self.search_fields = ['Name','Chr'] self.do_search() @@ -354,17 +354,23 @@ class SearchResultPage(templatePage): #pageTable = HT.TableLite(cellSpacing=2,cellPadding=0,width="100%",border=0) - lastone = False - for i, item in enumerate(self.results): - if not item: - continue - lastone = False + #last_result = False - self.traitList = [] - for k, item2 in enumerate(item): - j, ProbeSetID = item2[:2] - thisTrait = webqtlTrait(db=self.database[j], name=ProbeSetID, cursor=self.cursor) - self.traitList.append(thisTrait) + self.trait_list = [] + for result in self.results: + if not result: + continue + #last_result = False + + #for item in result: + print("foo locals are:", locals()) + probe_set_id = result[1] + print("probe_set_id is:", pf(probe_set_id)) + this_trait = webqtlTrait(db=self.dataset, name=probe_set_id, cursor=self.cursor) + this_trait.retrieveInfo(QTL=True) + print("this_trait is:", pf(this_trait)) + self.trait_list.append(this_trait) + print("self.trait_list is:", pf(self.trait_list)) ############## # Excel file # @@ -378,63 +384,45 @@ class SearchResultPage(templatePage): #headingStyle = workbook.add_format(align = 'center', bold = 1, border = 1, size=13, fg_color = 0x1E, color="white") #XZ, 3/18/2010: pay attention to the line number of header in this file. As of today, there are 7 lines. - #worksheet = self.createExcelFileWithTitleAndFooter(workbook=workbook, db=thisTrait.db, returnNumber=len(self.traitList)) + #worksheet = self.createExcelFileWithTitleAndFooter(workbook=workbook, db=this_trait.db, returnNumber=len(self.trait_list)) newrow = 7 + + #### Excel file stuff stops #tbl = HT.TableLite(cellSpacing=2,cellPadding=0,width="90%",border=0) #seq = self.pageNumber*self.NPerPage+1 //Edited out because we show all results in one page now - Zach 2/22/11 seq = 1 - group = self.databaseCrosses[i] - self.thisFormName = thisFormName = 'showDatabase'+group - #selectall = HT.Href(url="#", onClick="checkAll(document.getElementsByName('%s')[0]);" % thisFormName) - #selectall_img = HT.Image("/images/select_all2_final.jpg", name="selectall", alt="Select All", title="Select All", style="border:none;") - #selectall.append(selectall_img) - #reset = HT.Href(url="#", onClick="checkNone(document.getElementsByName('%s')[0]);" % thisFormName) - #reset_img = HT.Image("/images/select_none2_final.jpg", alt="Select None", title="Select None", style="border:none;") - #reset.append(reset_img) - #selectinvert = HT.Href(url="#", onClick="checkInvert(document.getElementsByName('%s')[0]);" % thisFormName) - #selectinvert_img = HT.Image("/images/invert_selection2_final.jpg", name="selectinvert", alt="Invert Selection", title="Invert Selection", style="border:none;") - #selectinvert.append(selectinvert_img) - #addselect = HT.Href(url="#") - #addselect_img = HT.Image("/images/add_collection1_final.jpg", name="addselect", alt="Add To Collection", title="Add To Collection", style="border:none;") - #addselect.append(addselect_img) - - #optionsTable = HT.TableLite(cellSpacing=2,cellPadding=0,width="20%",border=0) - #optionsRow = HT.TR(HT.TD(selectall, width="25%"), HT.TD(reset, width="25%"), HT.TD(selectinvert, width="25%"), HT.TD(addselect, width="25%")) - #labelsRow = HT.TR(HT.TD(" "*2,"Select", width="25%"), HT.TD(" ","Deselect", width="255"), HT.TD(" "*3,"Invert", width="25%"), HT.TD(" "*4,"Add", width="25%")) - #optionsTable.append(optionsRow, labelsRow) - - #pageTable.append(HT.TR(HT.TD(optionsTable)), HT.TR(HT.TD(xlsUrl, height=40))) + group = self.dataset.group + self.form_name = form_name = 'show_dataset_'+group tblobj = {} - mainfmName = thisFormName species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, RISet=group) - if thisTrait.db.type=="Geno": + if this_trait.db.type=="Geno": tblobj['header'] = self.getTableHeaderForGeno(worksheet=worksheet, newrow=newrow, headingStyle=headingStyle) newrow += 1 sortby = self.getSortByValue(datasetType="Geno") - tblobj['body'] = self.getTableBodyForGeno(traitList=self.traitList, formName=mainfmName, worksheet=worksheet, newrow=newrow) + #tblobj['body'] = self.getTableBodyForGeno(trait_list=self.trait_list, form_name=form_name, worksheet=worksheet, newrow=newrow) #workbook.close() - objfile = open('%s.obj' % (webqtlConfig.TMPDIR+filename), 'wb') - cPickle.dump(tblobj, objfile) - objfile.close() - - div = HT.Div(webqtlUtil.genTableObj(tblobj, filename, sortby), Id="sortable") + #objfile = open('%s.obj' % (webqtlConfig.TMPDIR+filename), 'wb') + #cPickle.dump(tblobj, objfile) + #objfile.close() - pageTable.append(HT.TR(HT.TD(div))) + #div = HT.Div(webqtlUtil.genTableObj(tblobj, filename, sortby), Id="sortable") + # + #pageTable.append(HT.TR(HT.TD(div))) - elif thisTrait.db.type=="Publish": + elif this_trait.db.type=="Publish": #tblobj['header'] = self.getTableHeaderForPublish(worksheet=worksheet, newrow=newrow, headingStyle=headingStyle) - newrow += 1 + #newrow += 1 sortby = self.getSortByValue(datasetType="Publish") - #tblobj['body'] = self.getTableBodyForPublish(traitList=self.traitList, formName=mainfmName, worksheet=worksheet, newrow=newrow, species=species) + #tblobj['body'] = self.getTableBodyForPublish(trait_list=self.trait_list, formName=mainfmName, worksheet=worksheet, newrow=newrow, species=species) #workbook.close() #objfile = open('%s.obj' % (webqtlConfig.TMPDIR+filename), 'wb') @@ -445,19 +433,19 @@ class SearchResultPage(templatePage): #pageTable.append(HT.TR(HT.TD(div))) - elif thisTrait.db.type=="ProbeSet": + elif this_trait.db.type=="ProbeSet": #tblobj['header'] = self.getTableHeaderForProbeSet(worksheet=worksheet, newrow=newrow, headingStyle=headingStyle) - newrow += 1 + #newrow += 1 sortby = self.getSortByValue(datasetType="ProbeSet") - tblobj['body'] = self.getTableBodyForProbeSet(traitList=self.traitList, formName=mainfmName, newrow=newrow, species=species) - + tblobj['body'] = self.getTableBodyForProbeSet(trait_list=self.trait_list, formName=self.form_name, newrow=newrow, species=species) + # #workbook.close() - objfile = open('%s.obj' % (webqtlConfig.TMPDIR+filename), 'wb') - cPickle.dump(tblobj, objfile) - objfile.close() + #objfile = open('%s.obj' % (webqtlConfig.TMPDIR+filename), 'wb') + #cPickle.dump(tblobj, objfile) + #objfile.close() #div = HT.Div(webqtlUtil.genTableObj(tblobj, filename, sortby), Id="sortable") @@ -474,8 +462,8 @@ class SearchResultPage(templatePage): # # TD_LR.append(traitForm) # if len(self.results) > 1 and i < len(self.results) - 1: - # lastone = True - #if lastone: + # last_result = True + #if last_result: # TD_LR.contents.pop() def executeQuery(self): @@ -571,7 +559,7 @@ class SearchResultPage(templatePage): if self.ANDQuery or self.ORQuery: clause = self.ORQuery[:] - for j, database in enumerate(self.database): + for j, database in enumerate(self.dataset): if self.ANDQuery: clause.append(" (%s) " % string.join(self.ANDQuery, " AND ")) @@ -594,7 +582,7 @@ class SearchResultPage(templatePage): PublishXRef.PhenotypeId = Phenotype.Id and PublishXRef.PublicationId = Publication.Id and PublishFreeze.Id = %d""" % (j, incGenoTbl, - self.databaseCrossIds[j], item, database.id)) + self.dataset_group_ids[j], item, database.id)) elif self.dbType == "ProbeSet": if item.find("GOgene") < 0: incGoTbl = "" @@ -667,51 +655,87 @@ class SearchResultPage(templatePage): #self.ORkeyword2 = re.sub(re.compile('\s*\([\s\S]*\)'), '', self.ORkeyword2) #self.ORkeyword2 = self.encregexp(self.ORkeyword2) - if self.ORkeyword2 or self.ANDkeyword2: - ANDFulltext = [] - ORFulltext = [] - for k, item in enumerate(self.ORkeyword2 + self.ANDkeyword2): - item = item['search_term'] - self.nkeywords += 1 - #ZS: If there are both AND and OR keywords, just use the OR keywords - if k >=len(self.ORkeyword2): - query = self.ANDQuery - DescriptionText = self.ANDDescriptionText - clausejoin = ' OR ' - fulltext = ANDFulltext - else: - query = self.ORQuery - DescriptionText = self.ORDescriptionText - clausejoin = ' OR ' - fulltext = ORFulltext - - if self.dbType == "ProbeSet" and item.find('.') < 0 and item.find('\'') < 0: - fulltext.append(item) - else: - if self.matchwhole and item.find("'") < 0: - item = "[[:<:]]"+ item+"[[:>:]]" - clause2 = [] - for field in self.searchField: - if self.dbType == "Publish": - clause2.append("%s REGEXP \"%s\"" % (field,item)) - else: - clause2.append("%s REGEXP \"%s\"" % ("%s.%s" % (self.dbType,field),item)) - clauseItem = "(%s)" % string.join(clause2, clausejoin) - query.append(" (%s) " % clauseItem) - if ANDFulltext: - clauseItem = """ MATCH (ProbeSet.Name,ProbeSet.description,ProbeSet.symbol, - alias,GenbankId, UniGeneId, Probe_Target_Description) - AGAINST ('+%s' IN BOOLEAN MODE) """ % string.join(ANDFulltext, " +") - self.ANDQuery.append(" (%s) " % clauseItem) - if ORFulltext: - clauseItem = """ MATCH (ProbeSet.Name,ProbeSet.description,ProbeSet.symbol,alias, - GenbankId, UniGeneId, Probe_Target_Description) AGAINST ('%s' IN BOOLEAN MODE) - """ % string.join(ORFulltext, " ") - self.ORQuery.append(" (%s) " % clauseItem) - else: - pass - return 1 - + #if self.search_terms: + #full_text = [] + #ANDFulltext = [] + #ORFulltext = [] + for item in self.search_terms: + search_term = item['search_term'] + # self.nkeywords += 1 + # #ZS: If there are both AND and OR keywords, just use the OR keywords + # if k >=len(self.ORkeyword2): + # query = self.ANDQuery + # DescriptionText = self.ANDDescriptionText + # clausejoin = ' OR ' + # fulltext = ANDFulltext + # else: + # query = self.ORQuery + # DescriptionText = self.ORDescriptionText + # clausejoin = ' OR ' + # fulltext = ORFulltext + + print("item is:", pf(search_term)) + + if self.dataset.type == "ProbeSet": + query = ( +"""SELECT distinct 0, ProbeSet.Name as TNAME, 0 as thistable, + ProbeSetXRef.Mean as TMEAN, + ProbeSetXRef.LRS as TLRS, + ProbeSetXRef.PVALUE as TPVALUE, + ProbeSet.Chr_num as TCHR_NUM, + ProbeSet.Mb as TMB, + ProbeSet.Symbol as TSYMBOL, + ProbeSet.name_num as TNAME_NUM FROM ProbeSetXRef, + ProbeSet WHERE (MATCH (ProbeSet.Name, ProbeSet.description, ProbeSet.symbol, + alias, GenbankId, UniGeneId, Probe_Target_Description) + AGAINST ('%s' IN BOOLEAN MODE)) + and ProbeSet.Id = ProbeSetXRef.ProbeSetId + and ProbeSetXRef.ProbeSetFreezeId = %s + """ % (self.db_conn.escape_string(search_term), + self.db_conn.escape_string(str(self.dataset.id)))) + + print("query is:", query) + self.cursor.execute(query) + #print("query is:", pf(self.query)) + + #self.cursor.execute(self.query) + self.results = self.cursor.fetchall() + + print("self.results is:", pf(self.results)) + + +#["(SELECT distinct 0, ProbeSet.Name as TNAME, 0 as thistable,\n\t\t\t\t\t\tProbeSetXRef.Mean as TMEAN, +# ProbeSetXRef.LRS as TLRS, ProbeSetXRef.PVALUE as TPVALUE,\n\t\t\t\t\t\tProbeSet.Chr_num as TCHR_NUM, +# Pr beSet.Mb as TMB, ProbeSet.Symbol as TSYMBOL,\n\t\t\t\t\t\tProbeSet.name_num as TNAME_NUM FROM +# ProbeSetXRef, ProbeSet \n\t\t\t\t\t\tWHERE ( MATCH (ProbeSet.Name,ProbeSet.description,ProbeSet.symbol, +# alias GenbankId, UniGeneId, Probe_Target_Description) +# AGAINST ('shh' IN BOOLEAN MODE) ) +# and ProbeSet.Id = ProbeSetXRef.ProbeSetId and ProbeSetXRef.ProbeSetFreezeId = 112\n\t\t\t\t\t\t)"] + + + #if self.dataset.type == "ProbeSet" and search_term.find('.') < 0 and search_term.find('\'') < 0: + # full_text.append(search_term) + #else: + # if self.matchwhole and search_term.find("'") < 0: + # search_term = "[[:<:]]"+ search_term+"[[:>:]]" + # clause2 = [] + # for field in self.search_fields: + # if self.dataset.type == "Publish": + # clause2.append("%s REGEXP \"%s\"" % (field,search_term)) + # else: + # clause2.append("%s REGEXP \"%s\"" % ("%s.%s" % (self.dataset.type,field),search_term)) + # clause_item = "(%s)" % string.join(clause2, clausejoin) + # query.append(" (%s) " % clause_item) + #if ANDFulltext: + # clauseItem = """ MATCH (ProbeSet.Name,ProbeSet.description,ProbeSet.symbol, + # alias,GenbankId, UniGeneId, Probe_Target_Description) + # AGAINST ('+%s' IN BOOLEAN MODE) """ % string.join(ANDFulltext, " +") + # self.ANDQuery.append(" (%s) " % clauseItem) + #if ORFulltext: + #clauseItem = """ MATCH (ProbeSet.Name,ProbeSet.description,ProbeSet.symbol,alias, + #GenbankId, UniGeneId, Probe_Target_Description) AGAINST ('%s' IN BOOLEAN MODE) + #""" % string.join(full_text, " ") + #self.query.append(" (%s) " % clauseItem) def encregexp(self,str): @@ -981,44 +1005,44 @@ class SearchResultPage(templatePage): return tblobj_header - def getTableBodyForGeno(self, traitList, formName=None, worksheet=None, newrow=None): + def getTableBodyForGeno(self, trait_list, formName=None, worksheet=None, newrow=None): tblobj_body = [] className = "fs12 fwn ffl b1 c222" - for thisTrait in traitList: + for this_trait in trait_list: tr = [] - if not thisTrait.haveinfo: - thisTrait.retrieveInfo() + if not this_trait.haveinfo: + this_trait.retrieveInfo() - trId = str(thisTrait) + trId = str(this_trait) tr.append(TDCell(HT.TD(HT.Input(type="checkbox", Class="checkbox", name="searchResult",value=trId, onClick="highlight(this)"), nowrap="on", Class=className), text=trId)) - tr.append(TDCell(HT.TD(HT.Href(text=thisTrait.name,url="javascript:showDatabase3('%s','%s','%s','')" % (formName, thisTrait.db.name, thisTrait.name), Class="fs12 fwn ffl"),align="left", Class=className), text=thisTrait.name, val=thisTrait.name.upper())) + tr.append(TDCell(HT.TD(HT.Href(text=this_trait.name,url="javascript:showDatabase3('%s','%s','%s','')" % (formName, this_trait.db.name, this_trait.name), Class="fs12 fwn ffl"),align="left", Class=className), text=this_trait.name, val=this_trait.name.upper())) #XZ: trait_location_value is used for sorting trait_location_repr = 'N/A' trait_location_value = 1000000 - if thisTrait.chr and thisTrait.mb: + if this_trait.chr and this_trait.mb: try: - trait_location_value = int(thisTrait.chr)*1000 + thisTrait.mb + trait_location_value = int(this_trait.chr)*1000 + this_trait.mb except: - if thisTrait.chr.upper() == 'X': - trait_location_value = 20*1000 + thisTrait.mb + if this_trait.chr.upper() == 'X': + trait_location_value = 20*1000 + this_trait.mb else: - trait_location_value = ord(str(thisTrait.chr).upper()[0])*1000 + thisTrait.mb + trait_location_value = ord(str(this_trait.chr).upper()[0])*1000 + this_trait.mb - trait_location_repr = 'Chr%s: %.6f' % (thisTrait.chr, float(thisTrait.mb) ) + trait_location_repr = 'Chr%s: %.6f' % (this_trait.chr, float(this_trait.mb) ) tr.append(TDCell(HT.TD(trait_location_repr, Class="fs12 fwn b1 c222", nowrap="on"), trait_location_repr, trait_location_value)) tblobj_body.append(tr) - for ncol, item in enumerate([thisTrait.name, trait_location_repr]): + for ncol, item in enumerate([this_trait.name, trait_location_repr]): worksheet.write([newrow, ncol], item) newrow += 1 @@ -1045,40 +1069,40 @@ class SearchResultPage(templatePage): return tblobj_header - def getTableBodyForPublish(self, traitList, formName=None, worksheet=None, newrow=None, species=''): + def getTableBodyForPublish(self, trait_list, formName=None, worksheet=None, newrow=None, species=''): tblobj_body = [] className = "fs12 fwn b1 c222" - for thisTrait in traitList: + for this_trait in trait_list: tr = [] - if not thisTrait.haveinfo: - thisTrait.retrieveInfo(QTL=1) + if not this_trait.haveinfo: + this_trait.retrieveInfo(QTL=1) - trId = str(thisTrait) + trId = str(this_trait) tr.append(TDCell(HT.TD(HT.Input(type="checkbox", Class="checkbox", name="searchResult",value=trId, onClick="highlight(this)"), nowrap="on", Class=className), text=trId)) - tr.append(TDCell(HT.TD(HT.Href(text=thisTrait.name,url="javascript:showDatabase3('%s','%s','%s','')" % (formName, thisTrait.db.name, thisTrait.name), Class="fs12 fwn"), nowrap="yes",align="center", Class=className),str(thisTrait.name), thisTrait.name)) + tr.append(TDCell(HT.TD(HT.Href(text=this_trait.name,url="javascript:showDatabase3('%s','%s','%s','')" % (formName, this_trait.db.name, this_trait.name), Class="fs12 fwn"), nowrap="yes",align="center", Class=className),str(this_trait.name), this_trait.name)) - PhenotypeString = thisTrait.post_publication_description - if thisTrait.confidential: - if not webqtlUtil.hasAccessToConfidentialPhenotypeTrait(privilege=self.privilege, userName=self.userName, authorized_users=thisTrait.authorized_users): - PhenotypeString = thisTrait.pre_publication_description + PhenotypeString = this_trait.post_publication_description + if this_trait.confidential: + if not webqtlUtil.hasAccessToConfidentialPhenotypeTrait(privilege=self.privilege, userName=self.userName, authorized_users=this_trait.authorized_users): + PhenotypeString = this_trait.pre_publication_description tr.append(TDCell(HT.TD(PhenotypeString, Class=className), PhenotypeString, PhenotypeString.upper())) - tr.append(TDCell(HT.TD(thisTrait.authors, Class="fs12 fwn b1 c222 fsI"),thisTrait.authors, thisTrait.authors.strip().upper())) + tr.append(TDCell(HT.TD(this_trait.authors, Class="fs12 fwn b1 c222 fsI"),this_trait.authors, this_trait.authors.strip().upper())) try: - PubMedLinkText = myear = repr = int(thisTrait.year) + PubMedLinkText = myear = repr = int(this_trait.year) except: PubMedLinkText = repr = "N/A" myear = 0 - if thisTrait.pubmed_id: - PubMedLink = HT.Href(text= repr,url= webqtlConfig.PUBMEDLINK_URL % thisTrait.pubmed_id,target='_blank', Class="fs12 fwn") + if this_trait.pubmed_id: + PubMedLink = HT.Href(text= repr,url= webqtlConfig.PUBMEDLINK_URL % this_trait.pubmed_id,target='_blank', Class="fs12 fwn") else: PubMedLink = repr @@ -1092,9 +1116,9 @@ class SearchResultPage(templatePage): LRS_flag = 1 - if thisTrait.lrs: - LRS_score_repr = '%3.1f' % thisTrait.lrs - LRS_score_value = thisTrait.lrs + if this_trait.lrs: + LRS_score_repr = '%3.1f' % this_trait.lrs + LRS_score_value = this_trait.lrs tr.append(TDCell(HT.TD(LRS_score_repr, Class=className), LRS_score_repr, LRS_score_value)) self.cursor.execute(""" @@ -1102,7 +1126,7 @@ class SearchResultPage(templatePage): where Species.Name = '%s' and Geno.Name = '%s' and Geno.SpeciesId = Species.Id - """ % (species, thisTrait.locus)) + """ % (species, this_trait.locus)) result = self.cursor.fetchone() if result: @@ -1130,7 +1154,7 @@ class SearchResultPage(templatePage): tblobj_body.append(tr) - for ncol, item in enumerate([thisTrait.name, PhenotypeString, thisTrait.authors, thisTrait.year, thisTrait.pubmed_id, LRS_score_repr, LRS_location_repr]): + for ncol, item in enumerate([this_trait.name, PhenotypeString, this_trait.authors, this_trait.year, this_trait.pubmed_id, LRS_score_repr, LRS_location_repr]): worksheet.write([newrow, ncol], item) newrow += 1 @@ -1158,54 +1182,54 @@ class SearchResultPage(templatePage): return tblobj_header - def getTableBodyForProbeSet(self, traitList=[], primaryTrait=None, formName=None, worksheet=None, newrow=None, species=''): - # Note: setting traitList to [] is probably not a great idea. + def getTableBodyForProbeSet(self, trait_list=[], primaryTrait=None, formName=None, worksheet=None, newrow=None, species=''): + # Note: setting trait_list to [] is probably not a great idea. tblobj_body = [] className = "fs12 fwn b1 c222" - for thisTrait in traitList: + for this_trait in trait_list: - if not thisTrait.haveinfo: - thisTrait.retrieveInfo(QTL=1) + if not this_trait.haveinfo: + this_trait.retrieveInfo(QTL=1) - if thisTrait.symbol: + if this_trait.symbol: pass else: - thisTrait.symbol = "N/A" + this_trait.symbol = "N/A" tr = [] - trId = str(thisTrait) + trId = str(this_trait) #XZ, 12/08/2008: checkbox #tr.append(TDCell(HT.TD(HT.Input(type="checkbox", Class="checkbox", name="searchResult",value=trId, onClick="highlight(this)"), nowrap="on", Class="fs12 fwn ffl b1 c222"), text=trId)) #XZ, 12/08/2008: probeset name - #if thisTrait.cellid: - # tr.append(TDCell(HT.TD(HT.Href(text=thisTrait.name, url="javascript:showDatabase3('%s','%s','%s','%s')" % (formName, thisTrait.db.name,thisTrait.name,thisTrait.cellid), Class="fs12 fwn"), Class=className), thisTrait.name, thisTrait.name.upper())) + #if this_trait.cellid: + # tr.append(TDCell(HT.TD(HT.Href(text=this_trait.name, url="javascript:showDatabase3('%s','%s','%s','%s')" % (formName, this_trait.db.name,this_trait.name,this_trait.cellid), Class="fs12 fwn"), Class=className), this_trait.name, this_trait.name.upper())) #else: - # tr.append(TDCell(HT.TD(HT.Href(text=thisTrait.name, url="javascript:showDatabase3('%s','%s','%s','')" % (formName, thisTrait.db.name,thisTrait.name), Class="fs12 fwn"), Class=className), thisTrait.name, thisTrait.name.upper())) + # tr.append(TDCell(HT.TD(HT.Href(text=this_trait.name, url="javascript:showDatabase3('%s','%s','%s','')" % (formName, this_trait.db.name,this_trait.name), Class="fs12 fwn"), Class=className), this_trait.name, this_trait.name.upper())) # - #if thisTrait.geneid: - # symbolurl = HT.Href(text=thisTrait.symbol,target='_blank',url="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=gene&cmd=Retrieve&dopt=Graphics&list_uids=%s" % thisTrait.geneid, Class="font_black fs12 fwn") + #if this_trait.geneid: + # symbolurl = HT.Href(text=this_trait.symbol,target='_blank',url="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=gene&cmd=Retrieve&dopt=Graphics&list_uids=%s" % this_trait.geneid, Class="font_black fs12 fwn") #else: - # symbolurl = HT.Href(text=thisTrait.symbol,target='_blank',url="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?CMD=search&DB=gene&term=%s" % thisTrait.symbol, Class="font_black fs12 fwn") + # symbolurl = HT.Href(text=this_trait.symbol,target='_blank',url="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?CMD=search&DB=gene&term=%s" % this_trait.symbol, Class="font_black fs12 fwn") # ##XZ, 12/08/2008: gene symbol - #tr.append(TDCell(HT.TD(symbolurl, Class="fs12 fwn b1 c222 fsI"),thisTrait.symbol, thisTrait.symbol.upper())) + #tr.append(TDCell(HT.TD(symbolurl, Class="fs12 fwn b1 c222 fsI"),this_trait.symbol, this_trait.symbol.upper())) #XZ, 12/08/2008: description #XZ, 06/05/2009: Rob asked to add probe target description - description_string = str(thisTrait.description).strip() - target_string = str(thisTrait.probe_target_description).strip() + description_string = str(this_trait.description).strip() + target_string = str(this_trait.probe_target_description).strip() description_display = '' if len(description_string) > 1 and description_string != 'None': description_display = description_string else: - description_display = thisTrait.symbol + description_display = this_trait.symbol if len(description_display) > 1 and description_display != 'N/A' and len(target_string) > 1 and target_string != 'None': description_display = description_display + '; ' + target_string.strip() @@ -1213,24 +1237,24 @@ class SearchResultPage(templatePage): #tr.append(TDCell(HT.TD(description_display, Class=className), description_display, description_display)) # Save it for the jinja2 tablet - thisTrait.description_display = description_display + this_trait.description_display = description_display #XZ: trait_location_value is used for sorting trait_location_repr = 'N/A' trait_location_value = 1000000 - if thisTrait.chr and thisTrait.mb: + if this_trait.chr and this_trait.mb: try: - trait_location_value = int(thisTrait.chr)*1000 + thisTrait.mb + trait_location_value = int(this_trait.chr)*1000 + this_trait.mb except: - if thisTrait.chr.upper() == 'X': - trait_location_value = 20*1000 + thisTrait.mb + if this_trait.chr.upper() == 'X': + trait_location_value = 20*1000 + this_trait.mb else: - trait_location_value = ord(str(thisTrait.chr).upper()[0])*1000 + thisTrait.mb + trait_location_value = ord(str(this_trait.chr).upper()[0])*1000 + this_trait.mb - trait_location_repr = 'Chr%s: %.6f' % (thisTrait.chr, float(thisTrait.mb) ) - thisTrait.trait_location_repr = trait_location_repr - #thisTrait.trait_location_value = trait_location_value + trait_location_repr = 'Chr%s: %.6f' % (this_trait.chr, float(this_trait.mb) ) + this_trait.trait_location_repr = trait_location_repr + #this_trait.trait_location_value = trait_location_value tr.append(TDCell(HT.TD(trait_location_repr, Class=className, nowrap="on"), trait_location_repr, trait_location_value)) #XZ, 01/12/08: This SQL query is much faster. @@ -1239,7 +1263,7 @@ class SearchResultPage(templatePage): where ProbeSetXRef.ProbeSetFreezeId = %d and ProbeSet.Id = ProbeSetXRef.ProbeSetId and ProbeSet.Name = '%s' - """ % (thisTrait.db.id, thisTrait.name)) + """ % (this_trait.db.id, this_trait.name)) result = self.cursor.fetchone() if result: if result[0]: @@ -1250,7 +1274,7 @@ class SearchResultPage(templatePage): mean = 0 #XZ, 06/05/2009: It is neccessary to turn on nowrap - thisTrait.mean = repr = "%2.3f" % mean + this_trait.mean = repr = "%2.3f" % mean tr.append(TDCell(HT.TD(repr, Class=className, align='right', nowrap='ON'),repr, mean)) #LRS and its location @@ -1261,13 +1285,13 @@ class SearchResultPage(templatePage): LRS_flag = 1 #Max LRS and its Locus location - if thisTrait.lrs and thisTrait.locus: + if this_trait.lrs and this_trait.locus: self.cursor.execute(""" select Geno.Chr, Geno.Mb from Geno, Species where Species.Name = '%s' and Geno.Name = '%s' and Geno.SpeciesId = Species.Id - """ % (species, thisTrait.locus)) + """ % (species, this_trait.locus)) result = self.cursor.fetchone() if result: @@ -1284,12 +1308,12 @@ class SearchResultPage(templatePage): else: LRS_location_value = ord(str(LRS_chr).upper()[0])*1000 + float(LRS_Mb) - thisTrait.LRS_score_repr = LRS_score_repr = '%3.1f' % thisTrait.lrs - thisTrait.LRS_score_value = LRS_score_value = thisTrait.lrs - thisTrait.LRS_location_repr = LRS_location_repr = 'Chr%s: %.6f' % (LRS_Chr, float(LRS_Mb) ) + this_trait.LRS_score_repr = LRS_score_repr = '%3.1f' % this_trait.lrs + this_trait.LRS_score_value = LRS_score_value = this_trait.lrs + this_trait.LRS_location_repr = LRS_location_repr = 'Chr%s: %.6f' % (LRS_Chr, float(LRS_Mb) ) LRS_flag = 0 - #tr.append(TDCell(HT.TD(HT.Href(text=LRS_score_repr,url="javascript:showIntervalMapping('%s', '%s : %s')" % (formName, thisTrait.db.shortname, thisTrait.name), Class="fs12 fwn"), Class=className, align='right', nowrap="on"),LRS_score_repr, LRS_score_value)) + #tr.append(TDCell(HT.TD(HT.Href(text=LRS_score_repr,url="javascript:showIntervalMapping('%s', '%s : %s')" % (formName, this_trait.db.shortname, this_trait.name), Class="fs12 fwn"), Class=className, align='right', nowrap="on"),LRS_score_repr, LRS_score_value)) tr.append(TDCell(HT.TD(LRS_score_repr, Class=className, align='right', nowrap="on"), LRS_score_repr, LRS_score_value)) tr.append(TDCell(HT.TD(LRS_location_repr, Class=className, nowrap="on"), LRS_location_repr, LRS_location_value)) @@ -1303,7 +1327,7 @@ class SearchResultPage(templatePage): tblobj_body.append(tr) - #for ncol, item in enumerate([thisTrait.name, thisTrait.geneid, thisTrait.homologeneid, thisTrait.symbol, description_display, trait_location_repr, mean, LRS_score_repr, LRS_location_repr]): + #for ncol, item in enumerate([this_trait.name, this_trait.geneid, this_trait.homologeneid, this_trait.symbol, description_display, trait_location_repr, mean, LRS_score_repr, LRS_location_repr]): # worksheet.write([newrow, ncol], item) diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html index c20efe40..06458818 100644 --- a/wqflask/wqflask/templates/search_result_page.html +++ b/wqflask/wqflask/templates/search_result_page.html @@ -8,32 +8,22 @@ - {% for thisTrait in traitList %} - + {% for this_trait in trait_list %} + - - - - - + + + + + {% endfor %}
SE
{{ loop.index }} -- cgit v1.2.3 From c3d33485e92db007155983aa0018b65d4e7e6cc4 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Fri, 28 Sep 2012 15:37:14 -0500 Subject: Finished getting extra attributes to display correctly in the trait data table --- wqflask/base/webqtlCaseData.py | 4 +- wqflask/wqflask/show_trait/DataEditingPage.py | 77 +++++++++------------- .../wqflask/templates/trait_data_and_analysis.html | 14 +++- 3 files changed, 46 insertions(+), 49 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/webqtlCaseData.py b/wqflask/base/webqtlCaseData.py index c805a95c..6352a083 100755 --- a/wqflask/base/webqtlCaseData.py +++ b/wqflask/base/webqtlCaseData.py @@ -36,6 +36,7 @@ class webqtlCaseData(object): self.value = value # Trait Value self.variance = variance # Trait Variance self.num_cases = num_cases # Number of individuals/cases + self.extra_attributes = None self.this_id = None # Set a sane default (can't be just "id" cause that's a reserved word) self.outlier = None # Not set to True/False until later @@ -70,5 +71,4 @@ class webqtlCaseData(object): return "%2.3f" % self.variance else: return "x" - - + diff --git a/wqflask/wqflask/show_trait/DataEditingPage.py b/wqflask/wqflask/show_trait/DataEditingPage.py index 24a37926..0f21a958 100755 --- a/wqflask/wqflask/show_trait/DataEditingPage.py +++ b/wqflask/wqflask/show_trait/DataEditingPage.py @@ -3,7 +3,6 @@ from __future__ import absolute_import, print_function, division import string import os import cPickle -from collections import OrderedDict #import pyXLWriter as xl import yaml @@ -1563,11 +1562,14 @@ class SampleList(object): else: sample.this_id = "Other_" + str(counter) - #### For extra attribute columns; currently only used by two human datasets - Zach + #### For extra attribute columns; currently only used by several datasets - Zach if self.this_trait and self.this_trait.db and self.this_trait.db.type == 'ProbeSet': - self.get_extra_attribute_values(sample_name) + sample.extra_attributes = self.get_extra_attribute_values(sample_name) + print("sample.extra_attributes is", pf(sample.extra_attributes)) self.sample_list.append(sample) + print("self.attributes is", pf(self.attributes)) + self.do_outliers() #do_outliers(the_samples) print("*the_samples are [%i]: %s" % (len(self.sample_list), pf(self.sample_list))) @@ -1603,8 +1605,6 @@ class SampleList(object): group by CaseAttributeXRef.CaseAttributeId''', (str(self.this_trait.db.id),)) - #self.attributes = {key, value in self.cursor.fetchall()} - #self.attributes = OrderedDict(self.attributes.iteritems()) self.attributes = {} for key, value in self.cursor.fetchall(): @@ -1621,51 +1621,36 @@ class SampleList(object): self.attributes[key].distinct_values.sort(key=natural_sort_key) - #try: - # # exclude_menu = HT.Select(name="exclude_menu") # dropdown_menus = [] #ZS: list of dropdown menus with the distinct values of each attribute (contained in DIVs so the style parameter can be edited and they can be hidden) - # - # for attribute in self.cursor.fetchall(): - # attribute_ids.append(attribute[0]) - # attribute_names.append(attribute[1]) # for this_attr_name in attribute_names: # exclude_menu.append((this_attr_name.capitalize(), this_attr_name)) - # self.cursor.execute("""SELECT DISTINCT CaseAttributeXRef.Value - # FROM CaseAttribute, CaseAttributeXRef - # WHERE CaseAttribute.Name = '%s' AND - # CaseAttributeXRef.CaseAttributeId = CaseAttribute.Id""" % (this_attr_name)) - # try: - # distinct_values = self.cursor.fetchall() - # attr_value_menu_div = HT.Div(style="display:none;", Class="attribute_values") #container used to show/hide dropdown menus - # attr_value_menu = HT.Select(name=this_attr_name) - # attr_value_menu.append(("None", "show_all")) - # for value in distinct_values: - # attr_value_menu.append((str(value[0]), value[0])) - # attr_value_menu_div.append(attr_value_menu) - # dropdown_menus.append(attr_value_menu_div) - # except: - # pass - #except: - # pass + # attr_value_menu_div = HT.Div(style="display:none;", Class="attribute_values") #container used to show/hide dropdown menus + # attr_value_menu = HT.Select(name=this_attr_name) + # attr_value_menu.append(("None", "show_all")) + # for value in distinct_values: + # attr_value_menu.append((str(value[0]), value[0])) + # attr_value_menu_div.append(attr_value_menu) + # dropdown_menus.append(attr_value_menu_div) def get_extra_attribute_values(self, sample_name): - if len(self.attributes) > 0: + attribute_values = {} + + if self.attributes: #ZS: Get StrainId value for the next query self.cursor.execute("""SELECT Strain.Id - FROM Strain, StrainXRef, InbredSet - WHERE Strain.Name = %s and - StrainXRef.StrainId = Strain.Id and - InbredSet.Id = StrainXRef.InbredSetId and - InbredSet.Name = %s""", (sample_name, self.fd.RISet)) + FROM Strain, StrainXRef, InbredSet + WHERE Strain.Name = %s and + StrainXRef.StrainId = Strain.Id and + InbredSet.Id = StrainXRef.InbredSetId and + InbredSet.Name = %s""", (sample_name, self.fd.RISet)) sample_id = self.cursor.fetchone()[0] - attr_counter = 1 # This is needed so the javascript can know which attribute type to associate this value with for the exported excel sheet (each attribute type being a column). - for attribute_id in self.attributes.keys(): + for attribute in self.attributes: #ZS: Add extra case attribute values (if any) self.cursor.execute("""SELECT Value @@ -1673,21 +1658,21 @@ class SampleList(object): WHERE ProbeSetFreezeId = '%s' AND StrainId = '%s' AND CaseAttributeId = '%s' - group by CaseAttributeXRef.CaseAttributeId""" % (self.this_trait.db.id, sample_id, str(attribute_id))) + group by CaseAttributeXRef.CaseAttributeId""" % ( + self.this_trait.db.id, sample_id, str(attribute))) - attributeValue = self.cursor.fetchone()[0] #Trait-specific attributes, if any + attribute_value = self.cursor.fetchone()[0] #Trait-specific attributes, if any - #ZS: If it's an int, turn it into one for sorting (for example, 101 would be lower than 80 if they're strings instead of ints) + #ZS: If it's an int, turn it into one for sorting + #(for example, 101 would be lower than 80 if they're strings instead of ints) try: - attributeValue = int(attributeValue) + attribute_value = int(attribute_value) except ValueError: pass - - #span_Id = samples+"_attribute"+str(attr_counter)+"_sample"+str(i+1) - #attr_container = HT.Span(attributeValue, Id=span_Id) - #attr_className = str(attributeValue) + " " + className - #table_row.append(HT.TD(attr_container, align='right', Class=attr_className)) - attr_counter += 1 + + attribute_values[self.attributes[attribute].name] = attribute_value + + return attribute_values def natural_sort_key(x): diff --git a/wqflask/wqflask/templates/trait_data_and_analysis.html b/wqflask/wqflask/templates/trait_data_and_analysis.html index 6a5a4a80..f227d780 100644 --- a/wqflask/wqflask/templates/trait_data_and_analysis.html +++ b/wqflask/wqflask/templates/trait_data_and_analysis.html @@ -1263,6 +1263,10 @@   SE{{ sample_type.attributes[attribute].name }}
+ {{ sample.extra_attributes[sample_type.attributes[attribute].name] }} +
 ' -ctext += ' ' -ctext += ' ' -ctext += ' ' -ctext += ' ' -ctext += ' ' -ctext += ' ' -ctext += '
' -ctext += ' ' -ctext += ' ' -ctext += ' ' -ctext += ' ' -ctext += ' ' -ctext += ' ' -ctext += ' ' -ctext += ' ' -ctext += ' WebQTL' -ctext += '
' -ctext += '
 
' -ctext += '' -ctext += '' -ctext += '' -ctext += '' -ctext += '' -ctext += '
' -ctext += '   |   ' -ctext += '' -ctext += 'Home' -ctext += '   |   ' -ctext += '' -ctext += 'Search' -ctext += '   |   ' -ctext += '' -ctext += 'Help' -ctext += '   |   ' -ctext += '' -ctext += '' -ctext += 'News' -ctext += '   |   ' -ctext += '' -ctext += '' -ctext += 'References' -ctext += '   |   ' -ctext += '' -ctext += 'Policies' -ctext += '   |   ' -ctext += '' -ctext += '' -ctext += 'Links' -ctext += '   |   ' -ctext += '' -ctext += '   ' -ctext += '
' -ctext += '
 ' +ctext += ' ' +ctext += ' ' +ctext += ' ' +ctext += ' ' +ctext += ' ' +ctext += ' ' +ctext += '
' +ctext += ' ' +ctext += ' ' +ctext += ' ' +ctext += ' ' +ctext += ' ' +ctext += ' ' +ctext += ' ' +ctext += ' ' +ctext += ' WebQTL' +ctext += '
' +ctext += '
 
' +ctext += '' +ctext += '' +ctext += '' +ctext += '' +ctext += '' +ctext += '
' +ctext += '   |   ' +ctext += '' +ctext += 'Home' +ctext += '   |   ' +ctext += '' +ctext += 'Search' +ctext += '   |   ' +ctext += '' +ctext += 'Help' +ctext += '   |   ' +ctext += '' +ctext += '' +ctext += 'News' +ctext += '   |   ' +ctext += '' +ctext += '' +ctext += 'References' +ctext += '   |   ' +ctext += '' +ctext += 'Policies' +ctext += '   |   ' +ctext += '' +ctext += '' +ctext += 'Links' +ctext += '   |   ' +ctext += '' +ctext += '   ' +ctext += '
' +ctext += '
- - - - + - - -
-

Select and - Search

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Species: - -
Group: - -
Type: - -
Database: - -
-

    Databases marked with ** - suffix are not public yet.
-     Access requires user login.

-
- Search:
-

    Enter terms, genes, ID numbers in the - Search field.
-     Use * or ? wildcards (Cyp*a?, - synap*).
-     Use quotes for terms such as "tyrosine - kinase".

-
         
- - -

 ______________________________________________________

- -

  Quick HELP - Examples and User's Guide

  You can also use advanced - commands. Copy these simple examples
-   into the Get Any or Combined search fields: - -
    -
  • POSITION=(chr1 25 30) finds genes, markers, or transcripts on - chromosome 1 between 25 and 30 Mb.
  • - -
  • MEAN=(15 16) LRS=(23 46) in the Combined field finds - highly expressed genes (15 to 16 log2 units) AND with peak LRS linkage between 23 and 46.
  • - -
  • RIF=mitochondrial searches RNA databases for GeneRIF links.
  • - -
  • WIKI=nicotine searches GeneWiki for genes that you or other users have annotated - with the word nicotine.
  • - -
  • GO:0045202 searches for synapse-associated genes listed in the - Gene Ontology.
  • - -
  • GO:0045202 LRS=(9 99 Chr4 122 155) cisLRS=(9 999 10)
    - in Combined finds synapse-associated genes with cis eQTL on Chr 4 from 122 and 155 Mb with LRS scores - between 9 and 999.
  • - -
  • RIF=diabetes LRS=(9 999 Chr2 100 105) transLRS=(9 999 10)
    - in Combined finds diabetes-associated transcripts with peak trans eQTLs on Chr 2 between 100 and 105 Mb with LRS - scores between 9 and 999.
  • + + + + + GeneNetwork + + + + + + + + + + + + + + + + + +
    +
    +

    GeneNetwork

    +

    Open source bioinformatics for systems genetics
    + Brought to you by the University of Tennessee

    +
    +
    + + +
-

Websites Affiliated with - GeneNetwork

+
+ -
  • Optional: Use the Make Default button to save your preferences
  • - +
    + -

    ____________________________

    +
      +
    1. Select Species (or All)
    2. -

      How to Use - GeneNetwork

      +
    3. Select Group (a specific sample)
    4. -
      -

      Take a 20-40 minute - GeneNetwork Tour that includes screen shots and - typical steps in the analysis.

      -
      +
    5. Select Type of data: -
      -

      For information about - resources and methods, select the INFO buttons.

      +
        +
      • Phenotype (traits)
      • -

        Try the Workstation site to explore data and features that are - being implemented.

        +
      • Genotype (markers)
      • -

        Review the Conditions - and Contacts pages for information on the status of data sets - and advice on their use and citation.

        -
      +
    6. Expression (mRNAs)
    7. + + -

      Mirror and Development - Sites

      +
    8. Select a Database
    9. -
    -
  • Germany at the HZI
  • +

    User Guide

    +
    Read the + + user guide.
    -
  • Netherlands at the Hubrecht - (Development)
  • +
    -
  • Memphis at the U of M
  • -
  • Singapore at the NUS
  • +
    + -
  • Switzerland at the EPFL
  • - +

    GeneNetwork supports a variety of advanced searches.

    -

    History and - Archive

    - -
    -

    GeneNetwork's Time - Machine links to earlier versions that correspond to specific - publication dates.

    -
    -
    -
    + + + + + + + +
    +

    Select and + Search

    + + + +

     ______________________________________________________

    + +

      Quick HELP + Examples and User's Guide

      You can also use advanced + commands. Copy these simple examples
    +   into the Get Any or Combined search fields: + +
      +
    • POSITION=(chr1 25 30) finds genes, markers, or transcripts on + chromosome 1 between 25 and 30 Mb.
    • + +
    • MEAN=(15 16) LRS=(23 46) in the Combined field finds + highly expressed genes (15 to 16 log2 units) AND with peak LRS linkage between 23 and 46.
    • + +
    • RIF=mitochondrial searches RNA databases for GeneRIF links.
    • + +
    • WIKI=nicotine searches GeneWiki for genes that you or other users have annotated + with the word nicotine.
    • + +
    • GO:0045202 searches for synapse-associated genes listed in the + Gene Ontology.
    • + +
    • GO:0045202 LRS=(9 99 Chr4 122 155) cisLRS=(9 999 10)
      + in Combined finds synapse-associated genes with cis eQTL on Chr 4 from 122 and 155 Mb with LRS scores + between 9 and 999.
    • + +
    • RIF=diabetes LRS=(9 999 Chr2 100 105) transLRS=(9 999 10)
      + in Combined finds diabetes-associated transcripts with peak trans eQTLs on Chr 2 between 100 and 105 Mb with LRS + scores between 9 and 999.
    • +
    +
    +

    Websites Affiliated with + GeneNetwork

    + +

    + + + +

    ____________________________

    + +

    Getting Started +   

    + +
      +
    1. Select Species (or select All)
    2. + +
    3. Select Group (a specific sample)
    4. + +
    5. Select Type of data: + +
        +
      • Phenotype (traits)
      • + +
      • Genotype (markers)
      • + +
      • Expression (mRNAs)
      • +
      +
    6. + +
    7. Select a Database
    8. + +
    9. Enter search terms in the Get Any or Combined field: words, + genes, ID numbers, probes, advanced search commands
    10. + +
    11. Click on the Search button
    12. + +
    13. Optional: Use the Make Default button to save your preferences
    14. +
    + +

    ____________________________

    + +

    How to Use + GeneNetwork

    + +
    +

    Take a 20-40 minute + GeneNetwork Tour that includes screen shots and + typical steps in the analysis.

    +
    + +
    +

    For information about + resources and methods, select the INFO buttons.

    + +

    Try the Workstation site to explore data and features that are + being implemented.

    + +

    Review the Conditions + and Contacts pages for information on the status of data sets + and advice on their use and citation.

    +
    + +

    Mirror and Development + Sites

    + + + +

    History and + Archive

    + +
    +

    GeneNetwork's Time + Machine links to earlier versions that correspond to specific + publication dates.

    +
    +
    +

    Search Results

    -
    GeneNetwork searched the following databases: - - +
    GeneNetwork searched: + {{ dataset.fullname }} +
    + For all records that match:
      - {% if ORkeyword2 %} -
    • - {% for word in ORkeyword2 %} - {{word}} {% if not loop.last %} or {% endif %} - {% endfor %} -
    • - {% endif %} - {% if ANDkeyword2 %} + {% if search_terms %}
    • - {% for word in ANDkeyword2 %} - {{word}} {% if not loop.last %} and {% endif %} + {% for word in search_terms %} + {{word.search_term}} {% if not loop.last %} or {% endif %} {% endfor %}
    • {% endif %}
    -

    GeneNetwork found {{ numify(nresults, "record", "records") }}.

    +

    GeneNetwork found {{ numify(results|count, "record", "records") }}.

    To study a record, click on its ID below.

    @@ -166,27 +156,27 @@
    {{ loop.index }} - + - {# - #} - - {{ thisTrait.name.upper() }} + {# - #} + + {{ this_trait.name.upper() }} - - {{ thisTrait.symbol }} + + {{ this_trait.symbol }} {{ thisTrait.description_display }}{{ thisTrait.trait_location_repr }}{{ thisTrait.mean }}{{ thisTrait.LRS_score_repr }}{{ thisTrait.LRS_location_repr }}{{ this_trait.description_display }}{{ this_trait.trait_location_repr }}{{ this_trait.mean }}{{ this_trait.LRS_score_repr }}{{ this_trait.LRS_location_repr }}
    diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 629a5b15..dd95f7ca 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -63,7 +63,8 @@ def search_page(): else: print("calling search_results.SearchResultPage") the_search = search_results.SearchResultPage(request.args) - print("done calling") + print("template_vars is:", pf(the_search.__dict__)) + print("trait_list is:", pf(the_search.__dict__['trait_list'][0].__dict__)) return render_template("search_result_page.html", **the_search.__dict__) -- cgit v1.2.3 From 45b6e6a5eea13dbd06045e8307e371994b8c3083 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Tue, 30 Oct 2012 18:22:27 -0500 Subject: Worked on search_result.py code related to adding clause item to queries Continued work on redesigning the trait data page design --- wqflask/base/webqtlTrait.py | 12 +- wqflask/wqflask/search_results.py | 249 ++++++++++++++++------------- wqflask/wqflask/templates/show_trait.html | 253 ++++-------------------------- 3 files changed, 177 insertions(+), 337 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/webqtlTrait.py b/wqflask/base/webqtlTrait.py index 46af6683..51d36ab2 100755 --- a/wqflask/base/webqtlTrait.py +++ b/wqflask/base/webqtlTrait.py @@ -226,7 +226,7 @@ class webqtlTrait: def retrieveData(self, samplelist=None): - + if samplelist == None: samplelist = [] assert self.db and self.cursor @@ -331,7 +331,7 @@ class webqtlTrait: self.cursor.execute(query) results = self.cursor.fetchall() self.data.clear() - + if results: self.mysqlid = results[0][-1] #if samplelist: @@ -345,7 +345,7 @@ class webqtlTrait: name = item[0] self.data[name] = webqtlCaseData(*item) #name, value, variance, num_cases) #end for - # else: + # else: # for item in results: # val = item[1] # if val != None: @@ -604,7 +604,7 @@ class webqtlTrait: formatted += "; " + self.probe_target_description else: formatted = "Not available" - return formatted + return formatted.capitalize() @property def alias_fmt(self): @@ -660,7 +660,7 @@ class webqtlTrait: else: return dict(name = self.db.fullname, url = webqtlConfig.INFOPAGEHREF % self.db.name) - + def calculate_correlation(self, values, method): """Calculate the correlation value and p value according to the method specified""" @@ -693,4 +693,4 @@ class webqtlTrait: else: ZValue = 0.5*log((1.0+self.correlation)/(1.0-self.correlation)) ZValue = ZValue*sqrt(self.overlap-3) - self.p_value = 2.0*(1.0 - reaper.normp(abs(ZValue))) + self.p_value = 2.0*(1.0 - reaper.normp(abs(ZValue))) diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index a2b0596c..29a497fa 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -365,114 +365,111 @@ class SearchResultPage(templatePage): #last_result = False self.trait_list = [] - for result in self.results: - if not result: - continue - #last_result = False - - #for item in result: - print("foo locals are:", locals()) - probe_set_id = result[1] - print("probe_set_id is:", pf(probe_set_id)) - this_trait = webqtlTrait(db=self.dataset, name=probe_set_id, cursor=self.cursor) - this_trait.retrieveInfo(QTL=True) - print("this_trait is:", pf(this_trait)) - self.trait_list.append(this_trait) - print("self.trait_list is:", pf(self.trait_list)) - - ############## - # Excel file # - ############## - - # Todo: Replace this with official Python temp file naming functions? - filename= webqtlUtil.genRandStr("Search_") - #xlsUrl = HT.Input(type='button', value = 'Download Table', onClick= "location.href='/tmp/%s.xls'" % filename, Class='button') - # Create a new Excel workbook - #workbook = xl.Writer('%s.xls' % (webqtlConfig.TMPDIR+filename)) - #headingStyle = workbook.add_format(align = 'center', bold = 1, border = 1, size=13, fg_color = 0x1E, color="white") - - #XZ, 3/18/2010: pay attention to the line number of header in this file. As of today, there are 7 lines. - #worksheet = self.createExcelFileWithTitleAndFooter(workbook=workbook, db=this_trait.db, returnNumber=len(self.trait_list)) - newrow = 7 - - #### Excel file stuff stops + # result_set represents the results for each search term; a search of + # "shh grin2b" would have two sets of results, one for each term + for result_set in self.results: + for result in result_set: + if not result: + continue + #last_result = False - #tbl = HT.TableLite(cellSpacing=2,cellPadding=0,width="90%",border=0) - #seq = self.pageNumber*self.NPerPage+1 //Edited out because we show all results in one page now - Zach 2/22/11 - seq = 1 - group = self.dataset.group - self.form_name = form_name = 'show_dataset_'+group + seq = 1 + group = self.dataset.group + self.form_name = form_name = 'show_dataset_'+group - tblobj = {} - species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, RISet=group) + tblobj = {} + species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, RISet=group) - if this_trait.db.type=="Geno": - tblobj['header'] = self.getTableHeaderForGeno(worksheet=worksheet, newrow=newrow, headingStyle=headingStyle) + #### Excel file - newrow += 1 - sortby = self.getSortByValue(datasetType="Geno") + # Todo: Replace this with official Python temp file naming functions? + filename= webqtlUtil.genRandStr("Search_") + #xlsUrl = HT.Input(type='button', value = 'Download Table', onClick= "location.href='/tmp/%s.xls'" % filename, Class='button') + # Create a new Excel workbook + #workbook = xl.Writer('%s.xls' % (webqtlConfig.TMPDIR+filename)) + #headingStyle = workbook.add_format(align = 'center', bold = 1, border = 1, size=13, fg_color = 0x1E, color="white") - #tblobj['body'] = self.getTableBodyForGeno(trait_list=self.trait_list, form_name=form_name, worksheet=worksheet, newrow=newrow) + #XZ, 3/18/2010: pay attention to the line number of header in this file. As of today, there are 7 lines. + #worksheet = self.createExcelFileWithTitleAndFooter(workbook=workbook, db=this_trait.db, returnNumber=len(self.trait_list)) + newrow = 7 - #workbook.close() - #objfile = open('%s.obj' % (webqtlConfig.TMPDIR+filename), 'wb') - #cPickle.dump(tblobj, objfile) - #objfile.close() + #### Excel file stuff stops - #div = HT.Div(webqtlUtil.genTableObj(tblobj, filename, sortby), Id="sortable") - # - #pageTable.append(HT.TR(HT.TD(div))) + if self.dataset.type == "ProbeSet": + #for item in result: + print("foo locals are:", locals()) + probe_set_id = result[1] + print("probe_set_id is:", pf(probe_set_id)) + this_trait = webqtlTrait(db=self.dataset, name=probe_set_id, cursor=self.cursor) + this_trait.retrieveInfo(QTL=True) + print("this_trait is:", pf(this_trait)) + self.trait_list.append(this_trait) + print("self.trait_list is:", pf(self.trait_list)) - elif this_trait.db.type=="Publish": - #tblobj['header'] = self.getTableHeaderForPublish(worksheet=worksheet, newrow=newrow, headingStyle=headingStyle) + #tblobj['header'] = self.getTableHeaderForProbeSet(worksheet=worksheet, newrow=newrow, headingStyle=headingStyle) - #newrow += 1 + #newrow += 1 - sortby = self.getSortByValue(datasetType="Publish") + sortby = self.getSortByValue(datasetType="ProbeSet") - #tblobj['body'] = self.getTableBodyForPublish(trait_list=self.trait_list, formName=mainfmName, worksheet=worksheet, newrow=newrow, species=species) + tblobj['body'] = self.getTableBodyForProbeSet(trait_list=self.trait_list, formName=self.form_name, newrow=newrow, species=species) - #workbook.close() - #objfile = open('%s.obj' % (webqtlConfig.TMPDIR+filename), 'wb') - #cPickle.dump(tblobj, objfile) - #objfile.close() + #workbook.close() + #objfile = open('%s.obj' % (webqtlConfig.TMPDIR+filename), 'wb') + #cPickle.dump(tblobj, objfile) + #objfile.close() - #div = HT.Div(webqtlUtil.genTableObj(tblobj, filename, sortby), Id="sortable") + #div = HT.Div(webqtlUtil.genTableObj(tblobj, filename, sortby), Id="sortable") - #pageTable.append(HT.TR(HT.TD(div))) + #pageTable.append(HT.TR(HT.TD(div))) + elif self.dataset.type == "Publish": + #tblobj['header'] = self.getTableHeaderForPublish(worksheet=worksheet, newrow=newrow, headingStyle=headingStyle) - elif this_trait.db.type=="ProbeSet": - #tblobj['header'] = self.getTableHeaderForProbeSet(worksheet=worksheet, newrow=newrow, headingStyle=headingStyle) + #newrow += 1 - #newrow += 1 + sortby = self.getSortByValue(datasetType="Publish") - sortby = self.getSortByValue(datasetType="ProbeSet") + #tblobj['body'] = self.getTableBodyForPublish(trait_list=self.trait_list, formName=mainfmName, worksheet=worksheet, newrow=newrow, species=species) - tblobj['body'] = self.getTableBodyForProbeSet(trait_list=self.trait_list, formName=self.form_name, newrow=newrow, species=species) - # - #workbook.close() - #objfile = open('%s.obj' % (webqtlConfig.TMPDIR+filename), 'wb') - #cPickle.dump(tblobj, objfile) - #objfile.close() + #workbook.close() + #objfile = open('%s.obj' % (webqtlConfig.TMPDIR+filename), 'wb') + #cPickle.dump(tblobj, objfile) + #objfile.close() - #div = HT.Div(webqtlUtil.genTableObj(tblobj, filename, sortby), Id="sortable") + #div = HT.Div(webqtlUtil.genTableObj(tblobj, filename, sortby), Id="sortable") - #pageTable.append(HT.TR(HT.TD(div))) + #pageTable.append(HT.TR(HT.TD(div))) + elif self.dataset.type == "Geno": + tblobj['header'] = self.getTableHeaderForGeno(worksheet=worksheet, newrow=newrow, headingStyle=headingStyle) + newrow += 1 + sortby = self.getSortByValue(datasetType="Geno") - #traitForm = HT.Form(cgi= os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), enctype='multipart/form-data', name=thisFormName, submit=HT.Input(type='hidden')) - hddn = {'FormID':'showDatabase','ProbeSetID':'_','database':'_','CellID':'_','group':group} - hddn['incparentsf1']='ON' - # for key in hddn.keys(): - # traitForm.append(HT.Input(name=key, value=hddn[key], type='hidden')) - # - # traitForm.append(HT.P(),pageTable) - # - # TD_LR.append(traitForm) - # if len(self.results) > 1 and i < len(self.results) - 1: - # last_result = True - #if last_result: - # TD_LR.contents.pop() + #tblobj['body'] = self.getTableBodyForGeno(trait_list=self.trait_list, form_name=form_name, worksheet=worksheet, newrow=newrow) + + #workbook.close() + #objfile = open('%s.obj' % (webqtlConfig.TMPDIR+filename), 'wb') + #cPickle.dump(tblobj, objfile) + #objfile.close() + + #div = HT.Div(webqtlUtil.genTableObj(tblobj, filename, sortby), Id="sortable") + # + #pageTable.append(HT.TR(HT.TD(div))) + + + #traitForm = HT.Form(cgi= os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), enctype='multipart/form-data', name=thisFormName, submit=HT.Input(type='hidden')) + hddn = {'FormID':'showDatabase','ProbeSetID':'_','database':'_','CellID':'_','group':group} + hddn['incparentsf1']='ON' + # for key in hddn.keys(): + # traitForm.append(HT.Input(name=key, value=hddn[key], type='hidden')) + # + # traitForm.append(HT.P(),pageTable) + # + # TD_LR.append(traitForm) + # if len(self.results) > 1 and i < len(self.results) - 1: + # last_result = True + #if last_result: + # TD_LR.contents.pop() def executeQuery(self): @@ -642,6 +639,8 @@ class SearchResultPage(templatePage): print("fd.search_terms:", self.fd['search_terms']) self.search_terms = parser.parse(self.fd['search_terms']) print("After parsing:", self.search_terms) + + #print("ORkeyword is:", pf(self.ORkeyword)) #self.ANDkeyword2 = parser.parse(self.ANDkeyword) #self.ORkeyword2 = parser.parse(self.ORkeyword) @@ -662,11 +661,8 @@ class SearchResultPage(templatePage): ###remove remain parethesis, could be input with syntax error #self.ORkeyword2 = re.sub(re.compile('\s*\([\s\S]*\)'), '', self.ORkeyword2) #self.ORkeyword2 = self.encregexp(self.ORkeyword2) - - #if self.search_terms: - #full_text = [] - #ANDFulltext = [] - #ORFulltext = [] + + self.results = [] for item in self.search_terms: search_term = item['search_term'] # self.nkeywords += 1 @@ -683,8 +679,19 @@ class SearchResultPage(templatePage): # fulltext = ORFulltext print("item is:", pf(search_term)) - + + + clause_item = ( +""" MATCH (ProbeSet.Name, + ProbeSet.description, + ProbeSet.symbol, + alias, + GenbankId, + UniGeneId, + Probe_Target_Description) + AGAINST ('%s' IN BOOLEAN MODE) """ % self.db_conn.escape_string(search_term)) if self.dataset.type == "ProbeSet": + query = ( """SELECT distinct 0, ProbeSet.Name as TNAME, 0 as thistable, ProbeSetXRef.Mean as TMEAN, @@ -693,31 +700,55 @@ class SearchResultPage(templatePage): ProbeSet.Chr_num as TCHR_NUM, ProbeSet.Mb as TMB, ProbeSet.Symbol as TSYMBOL, - ProbeSet.name_num as TNAME_NUM FROM ProbeSetXRef, - ProbeSet WHERE (MATCH (ProbeSet.Name, ProbeSet.description, ProbeSet.symbol, - alias, GenbankId, UniGeneId, Probe_Target_Description) - AGAINST ('%s' IN BOOLEAN MODE)) - and ProbeSet.Id = ProbeSetXRef.ProbeSetId - and ProbeSetXRef.ProbeSetFreezeId = %s + ProbeSet.name_num as TNAME_NUM + FROM ProbeSetXRef, ProbeSet + WHERE %s + and ProbeSet.Id = ProbeSetXRef.ProbeSetId + and ProbeSetXRef.ProbeSetFreezeId = %s """ % (self.db_conn.escape_string(search_term), + self.db_conn.escape_string(clause_item), self.db_conn.escape_string(str(self.dataset.id)))) + + elif self.dataset.type == "Publish": + include_geno = "" + if search_term.find("Geno.name") >= 0: + include_geno = " Geno, " + + query = ( +"""SELECT 0, PublishXRef.Id, PublishFreeze.createtime as thistable, + Publication.PubMed_ID as Publication_PubMed_ID, + Phenotype.Post_publication_description as Phenotype_Name + FROM %s PublishFreeze, Publication, PublishXRef, Phenotype + WHERE PublishXRef.InbredSetId = %s and %s and + PublishXRef.PhenotypeId = Phenotype.Id and + PublishXRef.PublicationId = Publication.Id and + PublishFreeze.Id = %s + """ % (include_geno, + self.db_conn.escape_string(str(self.dataset.group_id)), + self.db_conn.escape_string(clause_item), + self.db_conn.escape_string(str(self.dataset.id)))) + + elif self.dataset.type == "Geno": + query = ( +"""SELECT 0, Geno.Name, GenoFreeze.createtime as thistable, + Geno.Name as Geno_Name, + Geno.Source2 as Geno_Source2, + Geno.chr_num as Geno_chr_num, + Geno.Mb as Geno_Mb + FROM GenoXRef, GenoFreeze, Geno + WHERE %s and Geno.Id = GenoXRef.GenoId and + GenoXRef.GenoFreezeId = GenoFreeze.Id and + GenoFreeze.Id = %d + """% (self.db_conn.escape_string(clause_item), + self.db_conn.escape_string(str(self.dataset.id)))) - self.cursor.execute(query) - #print("query is:", pf(self.query)) - #self.cursor.execute(self.query) - self.results = self.cursor.fetchall() + self.cursor.execute(query) + self.results.append(self.cursor.fetchall()) print("self.results is:", pf(self.results)) -#["(SELECT distinct 0, ProbeSet.Name as TNAME, 0 as thistable,\n\t\t\t\t\t\tProbeSetXRef.Mean as TMEAN, -# ProbeSetXRef.LRS as TLRS, ProbeSetXRef.PVALUE as TPVALUE,\n\t\t\t\t\t\tProbeSet.Chr_num as TCHR_NUM, -# Pr beSet.Mb as TMB, ProbeSet.Symbol as TSYMBOL,\n\t\t\t\t\t\tProbeSet.name_num as TNAME_NUM FROM -# ProbeSetXRef, ProbeSet \n\t\t\t\t\t\tWHERE ( MATCH (ProbeSet.Name,ProbeSet.description,ProbeSet.symbol, -# alias GenbankId, UniGeneId, Probe_Target_Description) -# AGAINST ('shh' IN BOOLEAN MODE) ) -# and ProbeSet.Id = ProbeSetXRef.ProbeSetId and ProbeSetXRef.ProbeSetFreezeId = 112\n\t\t\t\t\t\t)"] #if self.dataset.type == "ProbeSet" and search_term.find('.') < 0 and search_term.find('\'') < 0: diff --git a/wqflask/wqflask/templates/show_trait.html b/wqflask/wqflask/templates/show_trait.html index ab662a77..d7b81562 100644 --- a/wqflask/wqflask/templates/show_trait.html +++ b/wqflask/wqflask/templates/show_trait.html @@ -48,240 +48,49 @@
    {{ "%i" % (this_trait.probe_set_blat_score) }}
    -
    - - - diff --git a/wqflask/wqflask/templates/show_trait.html b/wqflask/wqflask/templates/show_trait.html index 163be69c..28341186 100644 --- a/wqflask/wqflask/templates/show_trait.html +++ b/wqflask/wqflask/templates/show_trait.html @@ -18,7 +18,7 @@
    -
    - {# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #} - {% for key in hddn %} - - {% endfor %} -
    -
    - Trait Data and Analysis  for Record ID 1441186_at -
    -
    - -

      Details and Links

    - -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + {% for key in hddn %} + + {% endfor %} - - - +
    +
    + -
    - - - - - - + - - - + + - - - - - - - -
    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

    -- cgit v1.2.3 From 0931212bc692177cfc0ebcf016bc869dd4f88fd8 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Tue, 27 Nov 2012 14:44:14 -0600 Subject: Renamed webqtlDataSet.py to data_set.py Renamed the class webqtlDataset to DataSet Finished cisLRS and transLRS search types in d_search.py Fixed parent/f1 issue in show_trait.py --- wqflask/base/data_set.py | 162 +++++++++++++++++++++++++++++++ wqflask/base/webqtlDataset.py | 157 ------------------------------ wqflask/wqflask/do_search.py | 137 +++++++++++++------------- wqflask/wqflask/search_results.py | 34 ++----- wqflask/wqflask/show_trait/show_trait.py | 11 +-- 5 files changed, 247 insertions(+), 254 deletions(-) create mode 100755 wqflask/base/data_set.py delete mode 100755 wqflask/base/webqtlDataset.py (limited to 'wqflask/base') diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py new file mode 100755 index 00000000..992c673e --- /dev/null +++ b/wqflask/base/data_set.py @@ -0,0 +1,162 @@ +# Copyright (C) University of Tennessee Health Science Center, Memphis, TN. +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Affero General Public License for more details. +# +# This program is available from Source Forge: at GeneNetwork Project +# (sourceforge.net/projects/genenetwork/). +# +# Contact Drs. Robert W. Williams and Xiaodong Zhou (2010) +# at rwilliams@uthsc.edu and xzhou15@uthsc.edu +# +# +# +# This module is used by GeneNetwork project (www.genenetwork.org) +# +# Created by GeneNetwork Core Team 2010/08/10 +# +# Last updated by GeneNetwork Core Team 2010/10/20 + +from htmlgen import HTMLgen2 as HT + +import webqtlConfig + + + +class DataSet(object): + """ + Dataset class defines a dataset in webqtl, can be either Microarray, + Published phenotype, genotype, or user input dataset(temp) + + """ + + def __init__(self, dbName, cursor=None): + + assert dbName + self.id = 0 + self.name = '' + self.type = '' + self.group = '' + self.cursor = cursor + + #temporary storage + if dbName.find('Temp') >= 0: + self.searchfield = ['name','description'] + self.disfield = ['name','description'] + self.type = 'Temp' + self.id = 1 + self.fullname = 'Temporary Storage' + self.shortname = 'Temp' + elif dbName.find('Publish') >= 0: + pass + elif dbName.find('Geno') >= 0: + self.searchfield = ['name','chr'] + self.disfield = ['name','chr','mb', 'source2', 'sequence'] + self.type = 'Geno' + else: #ProbeSet + self.searchfield = ['name','description','probe_target_description', + 'symbol','alias','genbankid','unigeneid','omim', + 'refseq_transcriptid','probe_set_specificity', 'probe_set_blat_score'] + self.disfield = ['name','symbol','description','probe_target_description', + 'chr','mb','alias','geneid','genbankid', 'unigeneid', 'omim', + 'refseq_transcriptid','blatseq','targetseq','chipid', 'comments', + 'strand_probe','strand_gene','probe_set_target_region', + 'probe_set_specificity', 'probe_set_blat_score','probe_set_blat_mb_start', + 'probe_set_blat_mb_end', 'probe_set_strand', + 'probe_set_note_by_rw', 'flag'] + self.type = 'ProbeSet' + self.name = dbName + if self.cursor and self.id == 0: + self.retrieveName() + + + # Delete this eventually + @property + def riset(): + Weve_Renamed_This_As_Group + + + def get_group(self): + assert self.cursor + if self.type == 'Publish': + query = ''' + SELECT + InbredSet.Name, InbredSet.Id + FROM + InbredSet, PublishFreeze + WHERE + PublishFreeze.InbredSetId = InbredSet.Id AND + PublishFreeze.Name = "%s" + ''' % self.name + elif self.type == 'Geno': + query = ''' + SELECT + InbredSet.Name, InbredSet.Id + FROM + InbredSet, GenoFreeze + WHERE + GenoFreeze.InbredSetId = InbredSet.Id AND + GenoFreeze.Name = "%s" + ''' % self.name + elif self.type == 'ProbeSet': + query = ''' + SELECT + InbredSet.Name, InbredSet.Id + FROM + InbredSet, ProbeSetFreeze, ProbeFreeze + WHERE + ProbeFreeze.InbredSetId = InbredSet.Id AND + ProbeFreeze.Id = ProbeSetFreeze.ProbeFreezeId AND + ProbeSetFreeze.Name = "%s" + ''' % self.name + else: + return "" + self.cursor.execute(query) + group, RIID = self.cursor.fetchone() + if group == 'BXD300': + group = "BXD" + self.group = group + self.group_id = RIID + return group + + + def retrieveName(self): + assert self.id == 0 and self.cursor + query = ''' + SELECT + Id, Name, FullName, ShortName + FROM + %sFreeze + WHERE + public > %d AND + (Name = "%s" OR FullName = "%s" OR ShortName = "%s") + '''% (self.type, webqtlConfig.PUBLICTHRESH, self.name, self.name, self.name) + try: + self.cursor.execute(query) + self.id,self.name,self.fullname,self.shortname=self.cursor.fetchone() + except: + raise KeyError, `self.name`+' doesn\'t exist.' + + + def genHTML(self, Class='c0dd'): + return HT.Href(text = HT.Span('%s Database' % self.fullname, Class= "fwb " + Class), + url= webqtlConfig.INFOPAGEHREF % self.name,target="_blank") + +class PhenotypeDataSet(DataSet): + + def __init__(self): + self.searchfield = ['name','post_publication_description','abstract','title','authors'] + self.disfield = ['name','pubmed_id', + 'pre_publication_description', 'post_publication_description', 'original_description', + 'pre_publication_abbreviation', 'post_publication_abbreviation', + 'lab_code', 'submitter', 'owner', 'authorized_users', + 'authors','title','abstract', 'journal','volume','pages','month', + 'year','sequence', 'units', 'comments'] + self.type = 'Publish' \ No newline at end of file diff --git a/wqflask/base/webqtlDataset.py b/wqflask/base/webqtlDataset.py deleted file mode 100755 index 933077fd..00000000 --- a/wqflask/base/webqtlDataset.py +++ /dev/null @@ -1,157 +0,0 @@ -# Copyright (C) University of Tennessee Health Science Center, Memphis, TN. -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU Affero General Public License -# as published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the GNU Affero General Public License for more details. -# -# This program is available from Source Forge: at GeneNetwork Project -# (sourceforge.net/projects/genenetwork/). -# -# Contact Drs. Robert W. Williams and Xiaodong Zhou (2010) -# at rwilliams@uthsc.edu and xzhou15@uthsc.edu -# -# -# -# This module is used by GeneNetwork project (www.genenetwork.org) -# -# Created by GeneNetwork Core Team 2010/08/10 -# -# Last updated by GeneNetwork Core Team 2010/10/20 - -from htmlgen import HTMLgen2 as HT - -import webqtlConfig - - - -class webqtlDataset: - """ - Dataset class defines a dataset in webqtl, can be either Microarray, - Published phenotype, genotype, or user input dataset(temp) - - """ - - def __init__(self, dbName, cursor=None): - - assert dbName - self.id = 0 - self.name = '' - self.type = '' - self.group = '' - self.cursor = cursor - - #temporary storage - if dbName.find('Temp') >= 0: - self.searchfield = ['name','description'] - self.disfield = ['name','description'] - self.type = 'Temp' - self.id = 1 - self.fullname = 'Temporary Storage' - self.shortname = 'Temp' - elif dbName.find('Publish') >= 0: - self.searchfield = ['name','post_publication_description','abstract','title','authors'] - self.disfield = ['name','pubmed_id', - 'pre_publication_description', 'post_publication_description', 'original_description', - 'pre_publication_abbreviation', 'post_publication_abbreviation', - 'lab_code', 'submitter', 'owner', 'authorized_users', - 'authors','title','abstract', 'journal','volume','pages','month', - 'year','sequence', 'units', 'comments'] - self.type = 'Publish' - elif dbName.find('Geno') >= 0: - self.searchfield = ['name','chr'] - self.disfield = ['name','chr','mb', 'source2', 'sequence'] - self.type = 'Geno' - else: #ProbeSet - self.searchfield = ['name','description','probe_target_description', - 'symbol','alias','genbankid','unigeneid','omim', - 'refseq_transcriptid','probe_set_specificity', 'probe_set_blat_score'] - self.disfield = ['name','symbol','description','probe_target_description', - 'chr','mb','alias','geneid','genbankid', 'unigeneid', 'omim', - 'refseq_transcriptid','blatseq','targetseq','chipid', 'comments', - 'strand_probe','strand_gene','probe_set_target_region', - 'probe_set_specificity', 'probe_set_blat_score','probe_set_blat_mb_start', - 'probe_set_blat_mb_end', 'probe_set_strand', - 'probe_set_note_by_rw', 'flag'] - self.type = 'ProbeSet' - self.name = dbName - if self.cursor and self.id == 0: - self.retrieveName() - - - # Delete this eventually - @property - def riset(): - Weve_Renamed_This_As_Group - - - def get_group(self): - assert self.cursor - if self.type == 'Publish': - query = ''' - SELECT - InbredSet.Name, InbredSet.Id - FROM - InbredSet, PublishFreeze - WHERE - PublishFreeze.InbredSetId = InbredSet.Id AND - PublishFreeze.Name = "%s" - ''' % self.name - elif self.type == 'Geno': - query = ''' - SELECT - InbredSet.Name, InbredSet.Id - FROM - InbredSet, GenoFreeze - WHERE - GenoFreeze.InbredSetId = InbredSet.Id AND - GenoFreeze.Name = "%s" - ''' % self.name - elif self.type == 'ProbeSet': - query = ''' - SELECT - InbredSet.Name, InbredSet.Id - FROM - InbredSet, ProbeSetFreeze, ProbeFreeze - WHERE - ProbeFreeze.InbredSetId = InbredSet.Id AND - ProbeFreeze.Id = ProbeSetFreeze.ProbeFreezeId AND - ProbeSetFreeze.Name = "%s" - ''' % self.name - else: - return "" - self.cursor.execute(query) - group, RIID = self.cursor.fetchone() - if group == 'BXD300': - group = "BXD" - self.group = group - self.group_id = RIID - return group - - - def retrieveName(self): - assert self.id == 0 and self.cursor - query = ''' - SELECT - Id, Name, FullName, ShortName - FROM - %sFreeze - WHERE - public > %d AND - (Name = "%s" OR FullName = "%s" OR ShortName = "%s") - '''% (self.type, webqtlConfig.PUBLICTHRESH, self.name, self.name, self.name) - try: - self.cursor.execute(query) - self.id,self.name,self.fullname,self.shortname=self.cursor.fetchone() - except: - raise KeyError, `self.name`+' doesn\'t exist.' - - - def genHTML(self, Class='c0dd'): - return HT.Href(text = HT.Span('%s Database' % self.fullname, Class= "fwb " + Class), - url= webqtlConfig.INFOPAGEHREF % self.name,target="_blank") diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py index fd03f359..e2bafb3a 100644 --- a/wqflask/wqflask/do_search.py +++ b/wqflask/wqflask/do_search.py @@ -49,65 +49,6 @@ class DoSearch(object): return cls.search_types[search_type] -class ProbeSetSearch(DoSearch): - """A search within an mRNA expression dataset""" - - DoSearch.search_types['ProbeSet'] = "ProbeSetSearch" - - base_query = """SELECT ProbeSet.Name as TNAME, - 0 as thistable, - ProbeSetXRef.Mean as TMEAN, - ProbeSetXRef.LRS as TLRS, - ProbeSetXRef.PVALUE as TPVALUE, - ProbeSet.Chr_num as TCHR_NUM, - ProbeSet.Mb as TMB, - ProbeSet.Symbol as TSYMBOL, - ProbeSet.name_num as TNAME_NUM - FROM ProbeSetXRef, ProbeSet """ - - - def compile_final_query(self, from_clause = '', where_clause = ''): - """Generates the final query string""" - - from_clause = '' - from_clause = self.normalize_spaces(from_clause) - - query = (self.base_query + - """%s - WHERE %s - and ProbeSet.Id = ProbeSetXRef.ProbeSetId - and ProbeSetXRef.ProbeSetFreezeId = %s - """ % (self.escape(from_clause), - where_clause, - self.escape(self.dataset.id))) - - print("query is:", pf(query)) - - return query - - def run(self): - """Generates and runs a simple search of an mRNA expression dataset""" - - print("Running ProbeSetSearch") - query = (self.base_query + - """WHERE (MATCH (ProbeSet.Name, - ProbeSet.description, - ProbeSet.symbol, - alias, - GenbankId, - UniGeneId, - Probe_Target_Description) - AGAINST ('%s' IN BOOLEAN MODE)) - and ProbeSet.Id = ProbeSetXRef.ProbeSetId - and ProbeSetXRef.ProbeSetFreezeId = %s - """ % (self.escape(self.search_term), - self.escape(self.dataset.id))) - - print("final query is:", pf(query)) - - return self.execute(query) - - class PhenotypeSearch(DoSearch): """A search within a phenotype dataset""" @@ -212,6 +153,65 @@ class GenotypeSearch(DoSearch): return self.execute(query) + +class ProbeSetSearch(DoSearch): + """A search within an mRNA expression dataset""" + + DoSearch.search_types['ProbeSet'] = "ProbeSetSearch" + + base_query = """SELECT ProbeSet.Name as TNAME, + 0 as thistable, + ProbeSetXRef.Mean as TMEAN, + ProbeSetXRef.LRS as TLRS, + ProbeSetXRef.PVALUE as TPVALUE, + ProbeSet.Chr_num as TCHR_NUM, + ProbeSet.Mb as TMB, + ProbeSet.Symbol as TSYMBOL, + ProbeSet.name_num as TNAME_NUM + FROM ProbeSetXRef, ProbeSet """ + + + def compile_final_query(self, from_clause, where_clause): + """Generates the final query string""" + + from_clause = self.normalize_spaces(from_clause) + + query = (self.normalize_spaces(self.base_query) + + """%s + WHERE %s + and ProbeSet.Id = ProbeSetXRef.ProbeSetId + and ProbeSetXRef.ProbeSetFreezeId = %s + """ % (self.escape(from_clause), + where_clause, + self.escape(self.dataset.id))) + + print("query is:", pf(query)) + + return query + + def run(self): + """Generates and runs a simple search of an mRNA expression dataset""" + + print("Running ProbeSetSearch") + query = (self.base_query + + """WHERE (MATCH (ProbeSet.Name, + ProbeSet.description, + ProbeSet.symbol, + alias, + GenbankId, + UniGeneId, + Probe_Target_Description) + AGAINST ('%s' IN BOOLEAN MODE)) + and ProbeSet.Id = ProbeSetXRef.ProbeSetId + and ProbeSetXRef.ProbeSetFreezeId = %s + """ % (self.escape(self.search_term), + self.escape(self.dataset.id))) + + print("final query is:", pf(query)) + + return self.execute(query) + + class RifSearch(ProbeSetSearch): """Searches for traits with a Gene RIF entry including the search term.""" @@ -283,7 +283,7 @@ class LrsSearch(ProbeSetSearch): DoSearch.search_types['LRS'] = 'LrsSearch' -class CisLrsSearch(LrsSearch): +class CisLrsSearch(ProbeSetSearch): """Searches for genes on a particular chromosome with a cis-eQTL within the given LRS values A cisLRS search can take 2 forms: @@ -305,9 +305,12 @@ class CisLrsSearch(LrsSearch): DoSearch.search_types['CISLRS'] = "CisLrsSearch" def run(self): + + from_clause = ", Geno " + if len(self.search_term) == 3: lower_limit, upper_limit, min_threshold = [int(value) for value in self.search_term] - + where_clause = """ %sXRef.LRS > %s and %sXRef.LRS < %s and %sXRef.Locus = Geno.name and @@ -327,7 +330,7 @@ class CisLrsSearch(LrsSearch): else: NeedSomeErrorHere - query = self.compile_final_query(where_clause) + query = self.compile_final_query(from_clause, where_clause) return self.execute(query) @@ -353,6 +356,8 @@ class TransLrsSearch(LrsSearch): DoSearch.search_types['TRANSLRS'] = "TransLrsSearch" def run(self): + from_clause = ", Geno " + if len(self.search_term) == 3: lower_limit, upper_limit, min_threshold = [int(value) for value in self.search_term] @@ -374,9 +379,11 @@ class TransLrsSearch(LrsSearch): ) else: - NeedSomeErrorHere + NeedSomeErrorHere - return None + query = self.compile_final_query(from_clause, where_clause) + + return self.execute(query) #itemCmd = item[0] @@ -447,7 +454,7 @@ if __name__ == "__main__": #results = ProbeSetSearch("salt", dataset, cursor, db_conn).run() #results = RifSearch("diabetes", dataset, cursor, db_conn).run() #results = WikiSearch("nicotine", dataset, cursor, db_conn).run() - results = CisLrsSearch(['9','99','10'], dataset, cursor, db_conn).run() + results = TransLrsSearch(['25','99','10'], dataset, cursor, db_conn).run() #results = TransLrsSearch(['9', '999', '10'], dataset, cursor, db_conn).run() #results = PhenotypeSearch("brain", dataset, cursor, db_conn).run() #results = GenotypeSearch("rs13475699", dataset, cursor, db_conn).run() diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index dc3c72fc..05f062fc 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -84,16 +84,7 @@ class SearchResultPage(templatePage): print("self.dataset is:", pf(self.dataset)) self.dataset = webqtlDataset(self.dataset, self.cursor) print("self.dataset is now:", pf(self.dataset)) - #self.dataset = map(lambda x: webqtlDataset(x, self.cursor), self.dataset) - #currently, webqtl won't allow multiple crosses - #for other than multiple publish db search - #so we can use the first dataset as example - #if self.dataset.type=="Publish": - # pass if self.dataset.type in ("Geno", "ProbeSet"): - - #userExist = None - # Can't use paramater substitution for table names apparently db_type = self.dataset.type + "Freeze" print("db_type [%s]: %s" % (type(db_type), db_type)) @@ -124,11 +115,8 @@ class SearchResultPage(templatePage): # access_to_confidential_dataset = 1 # #if not access_to_confidential_dataset: - # #Error, No dataset selected - # heading = "Search Result" - # detail = ["The %s dataset you selected is not open to the public at this time, please go back and SELECT other dataset." % indFullName] - # self.error(heading=heading,detail=detail,error="Confidential dataset") - # return + # Some error + #else: # heading = "Search Result" # detail = ['''The dataset has not been established yet, please @@ -180,7 +168,8 @@ class SearchResultPage(templatePage): 'Max LRS', 'Max LRS Location'] elif self.dataset.type == "Geno": - self.search_fields = ['Name','Chr'] + self.search_fields = ['Name', + 'Chr'] self.header_fields = ['', 'ID', 'Location'] @@ -241,7 +230,6 @@ class SearchResultPage(templatePage): # This is throwing an error when a_search['key'] is None, so I changed above #search_type = string.upper(a_search['key']) #if not search_type: - # # We fall back to the dataset type as the key to get the right object # search_type = self.dataset.type search_ob = do_search.DoSearch.get_search(search_type) @@ -273,7 +261,6 @@ class SearchResultPage(templatePage): def getTraitInfoForGeno(self, trait_list): - for this_trait in trait_list: if not this_trait.haveinfo: this_trait.retrieveInfo() @@ -295,8 +282,7 @@ class SearchResultPage(templatePage): this_trait.location_value = trait_location_value - def getTraitInfoForPublish(self, trait_list, species=''): - + def getTraitInfoForPublish(self, trait_list, species = ''): for this_trait in trait_list: if not this_trait.haveinfo: this_trait.retrieveInfo(QTL=1) @@ -307,18 +293,16 @@ class SearchResultPage(templatePage): description = this_trait.pre_publication_description this_trait.description_display = description - try: - this_trait.pubmed_text = int(this_trait.year) - except: + if not this_trait.year.isdigit(): this_trait.pubmed_text = "N/A" if this_trait.pubmed_id: this_trait.pubmed_link = webqtlConfig.PUBMEDLINK_URL % this_trait.pubmed_id #LRS and its location - this_trait.LRS_score_repr = 'N/A' + this_trait.LRS_score_repr = "N/A" this_trait.LRS_score_value = 0 - this_trait.LRS_location_repr = 'N/A' + this_trait.LRS_location_repr = "N/A" this_trait.LRS_location_value = 1000000 if this_trait.lrs: @@ -408,7 +392,7 @@ class SearchResultPage(templatePage): ProbeSet.Name = '%s' """ % (self.db_conn.escape_string(str(this_trait.db.id)), self.db_conn.escape_string(this_trait.name))) - + print("query is:", pf(query)) self.cursor.execute(query) diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index 19e67c43..3dac5933 100755 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -1509,10 +1509,10 @@ class ShowTrait(templatePage): def make_sample_lists(self, fd, variance_data_page, this_trait): - if fd.genotype.type == "riset": - all_samples_ordered = fd.f1list + fd.samplelist - else: + if fd.parlist: all_samples_ordered = fd.parlist + fd.f1list + fd.samplelist + else: + all_samples_ordered = fd.f1list + fd.samplelist this_trait_samples = set(this_trait.data.keys()) @@ -1527,8 +1527,6 @@ class ShowTrait(templatePage): this_trait=this_trait, sample_group_type='primary', header="%s Only" % (fd.RISet)) - - print("primary_samples.attributes:", pf(primary_samples.attributes)) other_sample_names = [] for sample in this_trait.data.keys(): @@ -1538,8 +1536,7 @@ class ShowTrait(templatePage): 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] + par_f1_samples = fd.parlist + fd.f1list other_sample_names.sort() #Sort other samples other_sample_names = par_f1_samples + other_sample_names -- cgit v1.2.3 From 94dd9844fb55f4576d3a079e9d5e59ebbf911b8c Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Tue, 27 Nov 2012 17:59:17 -0600 Subject: Created subclass for each main data set type and moved the code for getting trait info that was in search_results.py into its respective class Renamed webqtlDataset to DataSet/create_dataset in webqtlTrait.py, webqtlDatabaseFunction.py, and CorrelationPage.py Got search page running again for mRNA assay data sets with these changes --- web/webqtl/search/SearchResultPage.py | 6 +- wqflask/base/data_set.py | 556 ++++++++++++++++++++----- wqflask/base/webqtlTrait.py | 25 +- wqflask/dbFunction/webqtlDatabaseFunction.py | 23 +- wqflask/wqflask/correlation/CorrelationPage.py | 4 +- wqflask/wqflask/do_search.py | 22 +- wqflask/wqflask/search_results.py | 325 +-------------- 7 files changed, 514 insertions(+), 447 deletions(-) (limited to 'wqflask/base') diff --git a/web/webqtl/search/SearchResultPage.py b/web/webqtl/search/SearchResultPage.py index 029a54c4..d62bb449 100755 --- a/web/webqtl/search/SearchResultPage.py +++ b/web/webqtl/search/SearchResultPage.py @@ -14,7 +14,7 @@ from htmlgen import HTMLgen2 as HT from base import webqtlConfig from utility.THCell import THCell from utility.TDCell import TDCell -from base.webqtlDataset import webqtlDataset +from base.data_set import DataSet from base.webqtlTrait import webqtlTrait from base.templatePage import templatePage from utility import webqtlUtil @@ -65,12 +65,12 @@ class SearchResultPage(templatePage): InbredSet where PublishFreeze.Name not like 'BXD300%' and InbredSet.Id = PublishFreeze.InbredSetId""") results = self.cursor.fetchall() - self.database = map(lambda x: webqtlDataset(x[0], self.cursor), results) + self.database = map(lambda x: DataSet(x[0], self.cursor), results) self.databaseCrosses = map(lambda x: x[1], results) self.databaseCrossIds = map(lambda x: x[2], results) self.singleCross = False else: - self.database = map(lambda x: webqtlDataset(x, self.cursor), self.database) + self.database = map(lambda x: DataSet(x, self.cursor), self.database) #currently, webqtl wouldn't allow multiple crosses #for other than multiple publish db search #so we can use the first database as example diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 992c673e..9e3e6d81 100755 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -19,64 +19,64 @@ # # # This module is used by GeneNetwork project (www.genenetwork.org) -# -# Created by GeneNetwork Core Team 2010/08/10 -# -# Last updated by GeneNetwork Core Team 2010/10/20 + +from __future__ import print_function, division from htmlgen import HTMLgen2 as HT import webqtlConfig +from pprint import pformat as pf +# Used by create_database to instantiate objects +DS_NAME_MAP = {} + +def create_dataset(db_conn, dataset_name): + cursor = db_conn.cursor() + cursor.execute(""" + SELECT DBType.Name + FROM DBList, DBType + WHERE DBList.Name = %s and + DBType.Id = DBList.DBTypeId + """, (dataset_name)) + print("dataset_name:", dataset_name) + dataset_type = cursor.fetchone()[0] + print("dataset_type:", pf(dataset_type)) + + dataset_ob = DS_NAME_MAP[dataset_type] + #dataset_class = getattr(data_set, dataset_ob) + + print("DS_NAME_MAP:", pf(DS_NAME_MAP)) + + dataset_class = globals()[dataset_ob] + return dataset_class(dataset_name, db_conn) class DataSet(object): """ - Dataset class defines a dataset in webqtl, can be either Microarray, + DataSet class defines a dataset in webqtl, can be either Microarray, Published phenotype, genotype, or user input dataset(temp) """ - def __init__(self, dbName, cursor=None): - - assert dbName - self.id = 0 - self.name = '' - self.type = '' - self.group = '' - self.cursor = cursor - - #temporary storage - if dbName.find('Temp') >= 0: - self.searchfield = ['name','description'] - self.disfield = ['name','description'] - self.type = 'Temp' - self.id = 1 - self.fullname = 'Temporary Storage' - self.shortname = 'Temp' - elif dbName.find('Publish') >= 0: - pass - elif dbName.find('Geno') >= 0: - self.searchfield = ['name','chr'] - self.disfield = ['name','chr','mb', 'source2', 'sequence'] - self.type = 'Geno' - else: #ProbeSet - self.searchfield = ['name','description','probe_target_description', - 'symbol','alias','genbankid','unigeneid','omim', - 'refseq_transcriptid','probe_set_specificity', 'probe_set_blat_score'] - self.disfield = ['name','symbol','description','probe_target_description', - 'chr','mb','alias','geneid','genbankid', 'unigeneid', 'omim', - 'refseq_transcriptid','blatseq','targetseq','chipid', 'comments', - 'strand_probe','strand_gene','probe_set_target_region', - 'probe_set_specificity', 'probe_set_blat_score','probe_set_blat_mb_start', - 'probe_set_blat_mb_end', 'probe_set_strand', - 'probe_set_note_by_rw', 'flag'] - self.type = 'ProbeSet' - self.name = dbName - if self.cursor and self.id == 0: - self.retrieveName() - - + def __init__(self, name, db_conn): + + assert name + self.name = name + self.db_conn = db_conn + self.cursor = self.db_conn.cursor() + self.id = None + self.type = None + self.group = None + + #if self.cursor and self.id == 0: + self.setup() + + self.check_confidentiality() + + self.retrieve_name() + self.get_group() + + # Delete this eventually @property def riset(): @@ -85,8 +85,93 @@ class DataSet(object): def get_group(self): assert self.cursor - if self.type == 'Publish': - query = ''' + self.cursor.execute(self.query) + self.group, self.group_id = self.cursor.fetchone() + if self.group == 'BXD300': + self.group = "BXD" + #return group + + + def retrieve_name(self): + """ + If the data set name parameter is not found in the 'Name' field of the data set table, + check if it is actually the FullName or ShortName instead. + + This is not meant to retrieve the data set info if no name at all is passed. + + """ + + query_args = tuple(self.db_conn.escape_string(x) for x in ( + (self.type + "Freeze"), + str(webqtlConfig.PUBLICTHRESH), + self.name, + self.name, + self.name)) + print("query_args are:", query_args) + + query = ''' + SELECT + Id, Name, FullName, ShortName + FROM + %s + WHERE + public > %s AND + (Name = "%s" OR FullName = "%s" OR ShortName = "%s") + ''' % (query_args) + + self.cursor.execute(query) + self.id, self.name, self.fullname, self.shortname = self.cursor.fetchone() + + + #def genHTML(self, Class='c0dd'): + # return HT.Href(text = HT.Span('%s Database' % self.fullname, Class= "fwb " + Class), + # url= webqtlConfig.INFOPAGEHREF % self.name,target="_blank") + +class PhenotypeDataSet(DataSet): + DS_NAME_MAP['Publish'] = 'PhenotypeDataSet' + + def setup(self): + # Fields in the database table + self.search_fields = ['Phenotype.Post_publication_description', + 'Phenotype.Pre_publication_description', + 'Phenotype.Pre_publication_abbreviation', + 'Phenotype.Post_publication_abbreviation', + 'Phenotype.Lab_code', + 'Publication.PubMed_ID', + 'Publication.Abstract', + 'Publication.Title', + 'Publication.Authors', + 'PublishXRef.Id'] + + # Figure out what display_fields is + self.display_fields = ['name', + 'pubmed_id', + 'pre_publication_description', + 'post_publication_description', + 'original_description', + 'pre_publication_abbreviation', + 'post_publication_abbreviation', + 'lab_code', + 'submitter', 'owner', + 'authorized_users', + 'authors', 'title', + 'abstract', 'journal', + 'volume', 'pages', + 'month', 'year', + 'sequence', 'units', 'comments'] + + # Fields displayed in the search results table header + self.header_fields = ['', + 'ID', + 'Description', + 'Authors', + 'Year', + 'Max LRS', + 'Max LRS Location'] + + self.type = 'Publish' + + self.query = ''' SELECT InbredSet.Name, InbredSet.Id FROM @@ -94,69 +179,336 @@ class DataSet(object): WHERE PublishFreeze.InbredSetId = InbredSet.Id AND PublishFreeze.Name = "%s" - ''' % self.name - elif self.type == 'Geno': - query = ''' - SELECT - InbredSet.Name, InbredSet.Id - FROM - InbredSet, GenoFreeze - WHERE - GenoFreeze.InbredSetId = InbredSet.Id AND - GenoFreeze.Name = "%s" - ''' % self.name - elif self.type == 'ProbeSet': - query = ''' - SELECT - InbredSet.Name, InbredSet.Id - FROM - InbredSet, ProbeSetFreeze, ProbeFreeze - WHERE - ProbeFreeze.InbredSetId = InbredSet.Id AND - ProbeFreeze.Id = ProbeSetFreeze.ProbeFreezeId AND - ProbeSetFreeze.Name = "%s" - ''' % self.name - else: - return "" - self.cursor.execute(query) - group, RIID = self.cursor.fetchone() - if group == 'BXD300': - group = "BXD" - self.group = group - self.group_id = RIID - return group + ''' % self.db_conn.escape_string(self.name) + + def check_confidentiality(self): + # (Urgently?) Need to write this + pass + + def get_trait_info(self, trait_list, species = ''): + for this_trait in trait_list: + if not this_trait.haveinfo: + this_trait.retrieveInfo(QTL=1) + + description = this_trait.post_publication_description + if this_trait.confidential: + if not webqtlUtil.hasAccessToConfidentialPhenotypeTrait(privilege=self.privilege, userName=self.userName, authorized_users=this_trait.authorized_users): + description = this_trait.pre_publication_description + this_trait.description_display = description + + if not this_trait.year.isdigit(): + this_trait.pubmed_text = "N/A" + + if this_trait.pubmed_id: + this_trait.pubmed_link = webqtlConfig.PUBMEDLINK_URL % this_trait.pubmed_id + + #LRS and its location + this_trait.LRS_score_repr = "N/A" + this_trait.LRS_score_value = 0 + this_trait.LRS_location_repr = "N/A" + this_trait.LRS_location_value = 1000000 + + if this_trait.lrs: + self.cursor.execute(""" + select Geno.Chr, Geno.Mb from Geno, Species + where Species.Name = '%s' and + Geno.Name = '%s' and + Geno.SpeciesId = Species.Id + """ % (species, this_trait.locus)) + result = self.cursor.fetchone() + if result: + if result[0] and result[1]: + LRS_Chr = result[0] + LRS_Mb = result[1] - def retrieveName(self): - assert self.id == 0 and self.cursor + #XZ: LRS_location_value is used for sorting + try: + LRS_location_value = int(LRS_Chr)*1000 + float(LRS_Mb) + except: + if LRS_Chr.upper() == 'X': + LRS_location_value = 20*1000 + float(LRS_Mb) + else: + LRS_location_value = ord(str(LRS_chr).upper()[0])*1000 + float(LRS_Mb) + + this_trait.LRS_score_repr = LRS_score_repr = '%3.1f' % this_trait.lrs + this_trait.LRS_score_value = LRS_score_value = this_trait.lrs + this_trait.LRS_location_repr = LRS_location_repr = 'Chr %s: %.4f Mb' % (LRS_Chr, float(LRS_Mb) ) + +class GenotypeDataSet(DataSet): + DS_NAME_MAP['Geno'] = 'GenotypeDataSet' + + def setup(self): + # Fields in the database table + self.search_fields = ['Name', + 'Chr'] + + # Find out what display_fields is + self.display_fields = ['name', + 'chr', + 'mb', + 'source2', + 'sequence'] + + # Fields displayed in the search results table header + self.header_fields = ['', + 'ID', + 'Location'] + + # Todo: Obsolete or rename this field + self.type = 'Geno' + query = ''' SELECT - Id, Name, FullName, ShortName + InbredSet.Name, InbredSet.Id FROM - %sFreeze + InbredSet, GenoFreeze WHERE - public > %d AND - (Name = "%s" OR FullName = "%s" OR ShortName = "%s") - '''% (self.type, webqtlConfig.PUBLICTHRESH, self.name, self.name, self.name) - try: + GenoFreeze.InbredSetId = InbredSet.Id AND + GenoFreeze.Name = "%s" + ''' % self.db_conn.escape_string(self.name) + + def check_confidentiality(self): + return geno_mrna_confidentiality(self) + + def get_trait_info(self, trait_list): + for this_trait in trait_list: + if not this_trait.haveinfo: + this_trait.retrieveInfo() + + #XZ: trait_location_value is used for sorting + trait_location_repr = 'N/A' + trait_location_value = 1000000 + + if this_trait.chr and this_trait.mb: + try: + trait_location_value = int(this_trait.chr)*1000 + this_trait.mb + except: + if this_trait.chr.upper() == 'X': + trait_location_value = 20*1000 + this_trait.mb + else: + trait_location_value = ord(str(this_trait.chr).upper()[0])*1000 + this_trait.mb + + this_trait.location_repr = 'Chr%s: %.4f' % (this_trait.chr, float(this_trait.mb) ) + this_trait.location_value = trait_location_value + + +class MrnaAssayDataSet(DataSet): + ''' + An mRNA Assay is a quantitative assessment (assay) associated with an mRNA trait + + This used to be called ProbeSet, but that term only refers specifically to the Affymetrix + platform and is far too specific. + + ''' + DS_NAME_MAP['ProbeSet'] = 'MrnaAssayDataSet' + + def setup(self): + # Fields in the database table + self.search_fields = ['Name', + 'Description', + 'Probe_Target_Description', + 'Symbol', + 'Alias', + 'GenbankId', + 'UniGeneId', + 'RefSeq_TranscriptId'] + + # Find out what display_fields is + self.display_fields = ['name', 'symbol', + 'description', 'probe_target_description', + 'chr', 'mb', + 'alias', 'geneid', + 'genbankid', 'unigeneid', + 'omim', 'refseq_transcriptid', + 'blatseq', 'targetseq', + 'chipid', 'comments', + 'strand_probe', 'strand_gene', + 'probe_set_target_region', + 'probe_set_specificity', + 'probe_set_blat_score', + 'probe_set_blat_mb_start', + 'probe_set_blat_mb_end', + 'probe_set_strand', + 'probe_set_note_by_rw', + 'flag'] + + # Fields displayed in the search results table header + self.header_fields = ['', + 'ID', + 'Symbol', + 'Description', + 'Location', + 'Mean Expr', + 'Max LRS', + 'Max LRS Location'] + + # Todo: Obsolete or rename this field + self.type = 'ProbeSet' + + self.query = ''' + SELECT + InbredSet.Name, InbredSet.Id + FROM + InbredSet, ProbeSetFreeze, ProbeFreeze + WHERE + ProbeFreeze.InbredSetId = InbredSet.Id AND + ProbeFreeze.Id = ProbeSetFreeze.ProbeFreezeId AND + ProbeSetFreeze.Name = "%s" + ''' % self.db_conn.escape_string(self.name) + + + def check_confidentiality(self): + return geno_mrna_confidentiality(self) + + def get_trait_info(self, trait_list=None, species=''): + + # Note: setting trait_list to [] is probably not a great idea. + if not trait_list: + trait_list = [] + + for this_trait in trait_list: + + if not this_trait.haveinfo: + this_trait.retrieveInfo(QTL=1) + + if this_trait.symbol: + pass + else: + this_trait.symbol = "N/A" + + #XZ, 12/08/2008: description + #XZ, 06/05/2009: Rob asked to add probe target description + description_string = str(this_trait.description).strip() + target_string = str(this_trait.probe_target_description).strip() + + description_display = '' + + if len(description_string) > 1 and description_string != 'None': + description_display = description_string + else: + description_display = this_trait.symbol + + if len(description_display) > 1 and description_display != 'N/A' and len(target_string) > 1 and target_string != 'None': + description_display = description_display + '; ' + target_string.strip() + + # Save it for the jinja2 tablet + this_trait.description_display = description_display + + #XZ: trait_location_value is used for sorting + trait_location_repr = 'N/A' + trait_location_value = 1000000 + + if this_trait.chr and this_trait.mb: + try: + trait_location_value = int(this_trait.chr)*1000 + this_trait.mb + except: + if this_trait.chr.upper() == 'X': + trait_location_value = 20*1000 + this_trait.mb + else: + trait_location_value = ord(str(this_trait.chr).upper()[0])*1000 + this_trait.mb + + this_trait.location_repr = 'Chr %s: %.4f Mb' % (this_trait.chr, float(this_trait.mb) ) + this_trait.location_value = trait_location_value + #this_trait.trait_location_value = trait_location_value + + #XZ, 01/12/08: This SQL query is much faster. + query = ( +"""select ProbeSetXRef.mean from ProbeSetXRef, ProbeSet + where ProbeSetXRef.ProbeSetFreezeId = %s and + ProbeSet.Id = ProbeSetXRef.ProbeSetId and + ProbeSet.Name = '%s' + """ % (self.db_conn.escape_string(str(this_trait.db.id)), + self.db_conn.escape_string(this_trait.name))) + + print("query is:", pf(query)) + self.cursor.execute(query) - self.id,self.name,self.fullname,self.shortname=self.cursor.fetchone() - except: - raise KeyError, `self.name`+' doesn\'t exist.' + result = self.cursor.fetchone() + if result: + if result[0]: + mean = result[0] + else: + mean=0 + else: + mean = 0 - def genHTML(self, Class='c0dd'): - return HT.Href(text = HT.Span('%s Database' % self.fullname, Class= "fwb " + Class), - url= webqtlConfig.INFOPAGEHREF % self.name,target="_blank") + #XZ, 06/05/2009: It is neccessary to turn on nowrap + this_trait.mean = repr = "%2.3f" % mean -class PhenotypeDataSet(DataSet): + #LRS and its location + this_trait.LRS_score_repr = 'N/A' + this_trait.LRS_score_value = 0 + this_trait.LRS_location_repr = 'N/A' + this_trait.LRS_location_value = 1000000 + + #Max LRS and its Locus location + if this_trait.lrs and this_trait.locus: + self.cursor.execute(""" + select Geno.Chr, Geno.Mb from Geno, Species + where Species.Name = '%s' and + Geno.Name = '%s' and + Geno.SpeciesId = Species.Id + """ % (species, this_trait.locus)) + result = self.cursor.fetchone() + + if result: + if result[0] and result[1]: + LRS_Chr = result[0] + LRS_Mb = result[1] + + #XZ: LRS_location_value is used for sorting + try: + LRS_location_value = int(LRS_Chr)*1000 + float(LRS_Mb) + except: + if LRS_Chr.upper() == 'X': + LRS_location_value = 20*1000 + float(LRS_Mb) + else: + LRS_location_value = ord(str(LRS_chr).upper()[0])*1000 + float(LRS_Mb) + + this_trait.LRS_score_repr = LRS_score_repr = '%3.1f' % this_trait.lrs + this_trait.LRS_score_value = LRS_score_value = this_trait.lrs + this_trait.LRS_location_repr = LRS_location_repr = 'Chr %s: %.4f Mb' % (LRS_Chr, float(LRS_Mb) ) + + +class TempDataSet(DataSet): + '''Temporary user-generated data set''' - def __init__(self): - self.searchfield = ['name','post_publication_description','abstract','title','authors'] - self.disfield = ['name','pubmed_id', - 'pre_publication_description', 'post_publication_description', 'original_description', - 'pre_publication_abbreviation', 'post_publication_abbreviation', - 'lab_code', 'submitter', 'owner', 'authorized_users', - 'authors','title','abstract', 'journal','volume','pages','month', - 'year','sequence', 'units', 'comments'] - self.type = 'Publish' \ No newline at end of file + def setup(self): + self.search_fields = ['name', + 'description'] + + self.display_fields = ['name', + 'description'] + + self.header_fields = ['Name', + 'Description'] + + self.type = 'Temp' + + # Need to double check later how these are used + self.id = 1 + self.fullname = 'Temporary Storage' + self.shortname = 'Temp' + + +def geno_mrna_confidentiality(ob): + dataset_table = ob.type + "Freeze" + print("dataset_table [%s]: %s" % (type(dataset_table), dataset_table)) + + query = '''SELECT Id, Name, FullName, confidentiality, + AuthorisedUsers FROM %s WHERE Name = %%s''' % (dataset_table) + + ob.cursor.execute(query, ob.name) + + (dataset_id, + name, + full_name, + confidential, + authorized_users) = ob.cursor.fetchall()[0] + + if confidential: + # Allow confidential data later + NoConfindetialDataForYouTodaySorry + \ No newline at end of file diff --git a/wqflask/base/webqtlTrait.py b/wqflask/base/webqtlTrait.py index 51d36ab2..29087721 100755 --- a/wqflask/base/webqtlTrait.py +++ b/wqflask/base/webqtlTrait.py @@ -6,7 +6,7 @@ from htmlgen import HTMLgen2 as HT import webqtlConfig from webqtlCaseData import webqtlCaseData -from webqtlDataset import webqtlDataset +from data_set import create_dataset from dbFunction import webqtlDatabaseFunction from utility import webqtlUtil @@ -20,9 +20,10 @@ class webqtlTrait: """ - def __init__(self, cursor = None, **kw): + def __init__(self, db_conn, **kw): print("in webqtlTrait") - self.cursor = cursor + self.db_conn = db_conn + self.cursor = self.db_conn.cursor() self.db = None # database object self.name = '' # Trait ID, ProbeSet ID, Published ID, etc. self.cellid = '' @@ -50,7 +51,7 @@ class webqtlTrait: if self.db and isinstance(self.db, basestring): assert self.cursor, "Don't have a cursor" - self.db = webqtlDataset(self.db, self.cursor) + self.db = create_dataset(self.db_conn, self.db) #if self.db == None, not from a database print("self.db is:", self.db, type(self.db)) @@ -396,8 +397,8 @@ class webqtlTrait: #XZ, 05/08/2009: Xiaodong add this block to use ProbeSet.Id to find the probeset instead of just using ProbeSet.Name #XZ, 05/08/2009: to avoid the problem of same probeset name from different platforms. elif self.db.type == 'ProbeSet': - disfieldString = string.join(self.db.disfield,',ProbeSet.') - disfieldString = 'ProbeSet.' + disfieldString + display_fields_string = ',ProbeSet.'.join(self.db.display_fields) + display_fields_string = 'ProbeSet.' + display_fields_string query = """ SELECT %s FROM ProbeSet, ProbeSetFreeze, ProbeSetXRef @@ -406,12 +407,12 @@ class webqtlTrait: ProbeSetXRef.ProbeSetId = ProbeSet.Id AND ProbeSetFreeze.Name = '%s' AND ProbeSet.Name = '%s' - """ % (disfieldString, self.db.name, self.name) + """ % (display_fields_string, self.db.name, self.name) #XZ, 05/08/2009: We also should use Geno.Id to find marker instead of just using Geno.Name # to avoid the problem of same marker name from different species. elif self.db.type == 'Geno': - disfieldString = string.join(self.db.disfield,',Geno.') - disfieldString = 'Geno.' + disfieldString + display_fields_string = string.join(self.db.display_fields,',Geno.') + display_fields_string = 'Geno.' + display_fields_string query = """ SELECT %s FROM Geno, GenoFreeze, GenoXRef @@ -420,10 +421,10 @@ class webqtlTrait: GenoXRef.GenoId = Geno.Id AND GenoFreeze.Name = '%s' AND Geno.Name = '%s' - """ % (disfieldString, self.db.name, self.name) + """ % (display_fields_string, self.db.name, self.name) else: #Temp type query = 'SELECT %s FROM %s WHERE Name = "%s"' % \ - (string.join(self.db.disfield,','), self.db.type, self.name) + (string.join(self.db.display_fields,','), self.db.type, self.name) self.cursor.execute(query) @@ -432,7 +433,7 @@ class webqtlTrait: self.haveinfo = 1 #XZ: assign SQL query result to trait attributes. - for i, field in enumerate(self.db.disfield): + for i, field in enumerate(self.db.display_fields): setattr(self, field, traitInfo[i]) if self.db.type == 'Publish': diff --git a/wqflask/dbFunction/webqtlDatabaseFunction.py b/wqflask/dbFunction/webqtlDatabaseFunction.py index 7e33da3f..8f923b8a 100755 --- a/wqflask/dbFunction/webqtlDatabaseFunction.py +++ b/wqflask/dbFunction/webqtlDatabaseFunction.py @@ -19,14 +19,7 @@ # # # This module is used by GeneNetwork project (www.genenetwork.org) -# -# Created by GeneNetwork Core Team 2010/08/10 -# -# Last updated by Xiaodong Zhou 2011/Jan/20 -#webqtlDatabaseFunction.py -# -#This file consists of various database related functions; the names are generally self-explanatory. import MySQLdb import string @@ -206,21 +199,21 @@ def getTissueCountByTissueProbeSetFreezeId(cursor=None, TissueProbeSetFreezeId=N ########################################################################### # input: cursor, TissueProbeSetFreezeId (int) -# output: DatasetName(string),DatasetFullName(string) -# function: retrieve DatasetName, DatasetFullName based on TissueProbeSetFreezeId +# output: DataSetName(string),DataSetFullName(string) +# function: retrieve DataSetName, DataSetFullName based on TissueProbeSetFreezeId ########################################################################### -def getDatasetNamesByTissueProbeSetFreezeId(cursor=None, TissueProbeSetFreezeId=None): +def getDataSetNamesByTissueProbeSetFreezeId(cursor=None, TissueProbeSetFreezeId=None): query ="select Name, FullName from TissueProbeSetFreeze where Id=%s" % TissueProbeSetFreezeId try: cursor.execute(query) result = cursor.fetchone() - DatasetName = result[0] - DatasetFullName =result[1] + DataSetName = result[0] + DataSetFullName =result[1] except: - DatasetName =None - DatasetFullName =None + DataSetName =None + DataSetFullName =None - return DatasetName, DatasetFullName + return DataSetName, DataSetFullName ########################################################################### # input: cursor, geneIdLst (list) diff --git a/wqflask/wqflask/correlation/CorrelationPage.py b/wqflask/wqflask/correlation/CorrelationPage.py index e48ea412..8af30d1e 100644 --- a/wqflask/wqflask/correlation/CorrelationPage.py +++ b/wqflask/wqflask/correlation/CorrelationPage.py @@ -47,7 +47,7 @@ from base import webqtlConfig from utility.THCell import THCell from utility.TDCell import TDCell from base.webqtlTrait import webqtlTrait -from base.webqtlDataset import webqtlDataset +from base.data_set import create_dataset from base.templatePage import templatePage from utility import webqtlUtil from dbFunction import webqtlDatabaseFunction @@ -310,7 +310,7 @@ class CorrelationPage(templatePage): #try: #print("target_db_name is:", target_db_name) - self.db = webqtlDataset(self.target_db_name, self.cursor) + self.db = create_dataset(self.db_conn, self.target_db_name) #except: # detail = ["The database you just requested has not been established yet."] # self.error(detail) diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py index e2bafb3a..73a72e00 100644 --- a/wqflask/wqflask/do_search.py +++ b/wqflask/wqflask/do_search.py @@ -147,7 +147,7 @@ class GenotypeSearch(DoSearch): """WHERE %s and Geno.Id = GenoXRef.GenoId and GenoXRef.GenoFreezeId = GenoFreeze.Id and - GenoFreeze.Id = %s"""% ( + GenoFreeze.Id = %s""" % ( self.get_where_clause(), self.escape(self.dataset.id))) @@ -257,7 +257,7 @@ class GoSearch(ProbeSetSearch): statements = ("""%s.symbol=GOgene_product.symbol and GOassociation.gene_product_id=GOgene_product.id and GOterm.id=GOassociation.term_id""" % ( - self.db_conn.escape_string(self.dataset.type))) + self.escape(self.dataset.type))) where_clause = " %s = '%s' and %s " % (field, go_id, statements) @@ -317,14 +317,14 @@ class CisLrsSearch(ProbeSetSearch): Geno.SpeciesId = %s and %s.Chr = Geno.Chr and ABS(%s.Mb-Geno.Mb) < %s """ % ( - self.dataset.type, + self.escape(self.dataset.type), min(lower_limit, upper_limit), - self.dataset.type, + self.escape(self.dataset.type), max(lower_limit, upper_limit), - self.dataset.type, + self.escape(self.dataset.type), self.species_id, - self.dataset.type, - self.dataset.type, + self.escape(self.dataset.type), + self.escape(self.dataset.type), min_threshold ) else: @@ -437,7 +437,7 @@ if __name__ == "__main__": from base import webqtlConfig - from base.webqtlDataset import webqtlDataset + from base.data_set import create_dataset from base.templatePage import templatePage from utility import webqtlUtil from dbFunction import webqtlDatabaseFunction @@ -449,13 +449,13 @@ if __name__ == "__main__": cursor = db_conn.cursor() dataset_name = "HC_M2_0606_P" - dataset = webqtlDataset(dataset_name, cursor) + dataset = create_dataset(db_conn, dataset_name) #results = ProbeSetSearch("salt", dataset, cursor, db_conn).run() #results = RifSearch("diabetes", dataset, cursor, db_conn).run() #results = WikiSearch("nicotine", dataset, cursor, db_conn).run() - results = TransLrsSearch(['25','99','10'], dataset, cursor, db_conn).run() - #results = TransLrsSearch(['9', '999', '10'], dataset, cursor, db_conn).run() + results = CisLrsSearch(['25','99','10'], dataset, cursor, db_conn).run() + #results = TransLrsSearch(['25', '999', '10'], dataset, cursor, db_conn).run() #results = PhenotypeSearch("brain", dataset, cursor, db_conn).run() #results = GenotypeSearch("rs13475699", dataset, cursor, db_conn).run() #results = GoSearch("0045202", dataset, cursor, db_conn).run() diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index 05f062fc..b50e45d5 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -10,7 +10,7 @@ from flask import render_template # # ################################################### -import string +#import string import os import cPickle import re @@ -29,7 +29,7 @@ from htmlgen import HTMLgen2 as HT from base import webqtlConfig from utility.THCell import THCell from utility.TDCell import TDCell -from base.webqtlDataset import webqtlDataset +from base.data_set import create_dataset from base.webqtlTrait import webqtlTrait from base.templatePage import templatePage from wqflask import parser @@ -43,14 +43,13 @@ from utility import formatting class SearchResultPage(templatePage): + #maxReturn = 3000 - maxReturn = 3000 - nkeywords = 0 def __init__(self, fd): print("initing SearchResultPage") - import logging_tree - logging_tree.printout() + #import logging_tree + #logging_tree.printout() self.fd = fd templatePage.__init__(self, fd) assert self.openMysql(), "Couldn't open MySQL" @@ -59,127 +58,40 @@ class SearchResultPage(templatePage): self.dataset = fd['dataset'] # change back to self.dataset - if not self.dataset or self.dataset == 'spacer': - #Error, No dataset selected - heading = "Search Result" - detail = ['''No dataset was selected for this search, please - go back and SELECT at least one dataset.'''] - self.error(heading=heading,detail=detail,error="No dataset Selected") - return + #if not self.dataset or self.dataset == 'spacer': + # #Error, No dataset selected + # heading = "Search Result" + # detail = ['''No dataset was selected for this search, please + # go back and SELECT at least one dataset.'''] + # self.error(heading=heading,detail=detail,error="No dataset Selected") + # return ########################################### # Names and IDs of RISet / F2 set ########################################### + + # All Phenotypes is a special case we'll deal with later if self.dataset == "All Phenotypes": self.cursor.execute(""" select PublishFreeze.Name, InbredSet.Name, InbredSet.Id from PublishFreeze, InbredSet where PublishFreeze.Name not like 'BXD300%' and InbredSet.Id = PublishFreeze.InbredSetId""") results = self.cursor.fetchall() - self.dataset = map(lambda x: webqtlDataset(x[0], self.cursor), results) + self.dataset = map(lambda x: DataSet(x[0], self.cursor), results) self.dataset_groups = map(lambda x: x[1], results) self.dataset_group_ids = map(lambda x: x[2], results) - self.single_group = False else: print("self.dataset is:", pf(self.dataset)) - self.dataset = webqtlDataset(self.dataset, self.cursor) + self.dataset = create_dataset(self.db_conn, self.dataset) print("self.dataset is now:", pf(self.dataset)) - if self.dataset.type in ("Geno", "ProbeSet"): - db_type = self.dataset.type + "Freeze" - print("db_type [%s]: %s" % (type(db_type), db_type)) - - query = '''SELECT Id, Name, FullName, confidentiality, - AuthorisedUsers FROM %s WHERE Name = %%s''' % (db_type) - - self.cursor.execute(query, self.dataset.name) - - (indId, - indName, - indFullName, - confidential, - AuthorisedUsers) = self.cursor.fetchall()[0] - - if confidential: - # Allow confidential data later - NoConfindetialDataForYouTodaySorry - #access_to_confidential_dataset = 0 - # - ##for the dataset that confidentiality is 1 - ##1. 'admin' and 'root' can see all of the dataset - ##2. 'user' can see the dataset that AuthorisedUsers contains his id(stored in the Id field of User table) - #if webqtlConfig.USERDICT[self.privilege] > webqtlConfig.USERDICT['user']: - # access_to_confidential_dataset = 1 - #else: - # AuthorisedUsersList=AuthorisedUsers.split(',') - # if AuthorisedUsersList.__contains__(self.userName): - # access_to_confidential_dataset = 1 - # - #if not access_to_confidential_dataset: - # Some error - - #else: - # heading = "Search Result" - # detail = ['''The dataset has not been established yet, please - # go back and SELECT at least one dataset.'''] - # self.error(heading=heading,detail=detail,error="No dataset Selected") - # return - - self.dataset.get_group() - self.single_group = True - #XZ, August 24,2010: Since self.single_group = True, it's safe to assign one species Id. - self.species_id = webqtlDatabaseFunction.retrieveSpeciesId(self.cursor, - self.dataset.group) - - #self.db_type = self.dataset.type - if self.dataset.type == "Publish": - self.search_fields = ['Phenotype.Post_publication_description', - 'Phenotype.Pre_publication_description', - 'Phenotype.Pre_publication_abbreviation', - 'Phenotype.Post_publication_abbreviation', - 'Phenotype.Lab_code', - 'Publication.PubMed_ID', - 'Publication.Abstract', - 'Publication.Title', - 'Publication.Authors', - 'PublishXRef.Id'] - self.header_fields = ['', - 'ID', - 'Description', - 'Authors', - 'Year', - 'Max LRS', - 'Max LRS Location'] - - elif self.dataset.type == "ProbeSet": - self.search_fields = ['Name', - 'Description', - 'Probe_Target_Description', - 'Symbol', - 'Alias', - 'GenbankId', - 'UniGeneId', - 'RefSeq_TranscriptId'] - self.header_fields = ['', - 'ID', - 'Symbol', - 'Description', - 'Location', - 'Mean Expr', - 'Max LRS', - 'Max LRS Location'] - elif self.dataset.type == "Geno": - self.search_fields = ['Name', - 'Chr'] - self.header_fields = ['', - 'ID', - 'Location'] - + self.search() self.gen_search_result() def gen_search_result(self): - """Get the info displayed in the search result table from the set of results computed in + """ + Get the info displayed in the search result table from the set of results computed in the "search" function """ @@ -191,26 +103,19 @@ class SearchResultPage(templatePage): if not result: continue - seq = 1 group = self.dataset.group - species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, RISet=group) #### Excel file needs to be generated #### print("foo locals are:", locals()) trait_id = result[0] - this_trait = webqtlTrait(db=self.dataset, name=trait_id, cursor=self.cursor) + this_trait = webqtlTrait(self.db_conn, db=self.dataset, name=trait_id) this_trait.retrieveInfo(QTL=True) print("this_trait is:", pf(this_trait)) self.trait_list.append(this_trait) - - if self.dataset.type == "ProbeSet": - self.getTraitInfoForProbeSet(trait_list=self.trait_list, species=species) - elif self.dataset.type == "Publish": - self.getTraitInfoForPublish(trait_list=self.trait_list, species=species) - elif self.dataset.type == "Geno": - self.getTraitInfoForGeno(trait_list=self.trait_list) + + self.dataset.get_trait_info(self.trait_list, species) def search(self): @@ -222,7 +127,7 @@ class SearchResultPage(templatePage): print("[kodak] item is:", pf(a_search)) search_term = a_search['search_term'] if a_search['key']: - search_type = string.upper(a_search['key']) + search_type = a_search['key'].upper() else: # We fall back to the dataset type as the key to get the right object search_type = self.dataset.type @@ -258,187 +163,3 @@ class SearchResultPage(templatePage): keyword = string.replace(keyword,"?",".") wildcardkeyword[i] = keyword#'[[:<:]]'+ keyword+'[[:>:]]' return wildcardkeyword - - - def getTraitInfoForGeno(self, trait_list): - for this_trait in trait_list: - if not this_trait.haveinfo: - this_trait.retrieveInfo() - - #XZ: trait_location_value is used for sorting - trait_location_repr = 'N/A' - trait_location_value = 1000000 - - if this_trait.chr and this_trait.mb: - try: - trait_location_value = int(this_trait.chr)*1000 + this_trait.mb - except: - if this_trait.chr.upper() == 'X': - trait_location_value = 20*1000 + this_trait.mb - else: - trait_location_value = ord(str(this_trait.chr).upper()[0])*1000 + this_trait.mb - - this_trait.location_repr = 'Chr%s: %.4f' % (this_trait.chr, float(this_trait.mb) ) - this_trait.location_value = trait_location_value - - - def getTraitInfoForPublish(self, trait_list, species = ''): - for this_trait in trait_list: - if not this_trait.haveinfo: - this_trait.retrieveInfo(QTL=1) - - description = this_trait.post_publication_description - if this_trait.confidential: - if not webqtlUtil.hasAccessToConfidentialPhenotypeTrait(privilege=self.privilege, userName=self.userName, authorized_users=this_trait.authorized_users): - description = this_trait.pre_publication_description - this_trait.description_display = description - - if not this_trait.year.isdigit(): - this_trait.pubmed_text = "N/A" - - if this_trait.pubmed_id: - this_trait.pubmed_link = webqtlConfig.PUBMEDLINK_URL % this_trait.pubmed_id - - #LRS and its location - this_trait.LRS_score_repr = "N/A" - this_trait.LRS_score_value = 0 - this_trait.LRS_location_repr = "N/A" - this_trait.LRS_location_value = 1000000 - - if this_trait.lrs: - self.cursor.execute(""" - select Geno.Chr, Geno.Mb from Geno, Species - where Species.Name = '%s' and - Geno.Name = '%s' and - Geno.SpeciesId = Species.Id - """ % (species, this_trait.locus)) - result = self.cursor.fetchone() - - if result: - if result[0] and result[1]: - LRS_Chr = result[0] - LRS_Mb = result[1] - - #XZ: LRS_location_value is used for sorting - try: - LRS_location_value = int(LRS_Chr)*1000 + float(LRS_Mb) - except: - if LRS_Chr.upper() == 'X': - LRS_location_value = 20*1000 + float(LRS_Mb) - else: - LRS_location_value = ord(str(LRS_chr).upper()[0])*1000 + float(LRS_Mb) - - this_trait.LRS_score_repr = LRS_score_repr = '%3.1f' % this_trait.lrs - this_trait.LRS_score_value = LRS_score_value = this_trait.lrs - this_trait.LRS_location_repr = LRS_location_repr = 'Chr %s: %.4f Mb' % (LRS_Chr, float(LRS_Mb) ) - - - def getTraitInfoForProbeSet(self, trait_list=None, species=''): - - # Note: setting trait_list to [] is probably not a great idea. - if not trait_list: - trait_list = [] - - for this_trait in trait_list: - - if not this_trait.haveinfo: - this_trait.retrieveInfo(QTL=1) - - if this_trait.symbol: - pass - else: - this_trait.symbol = "N/A" - - #XZ, 12/08/2008: description - #XZ, 06/05/2009: Rob asked to add probe target description - description_string = str(this_trait.description).strip() - target_string = str(this_trait.probe_target_description).strip() - - description_display = '' - - if len(description_string) > 1 and description_string != 'None': - description_display = description_string - else: - description_display = this_trait.symbol - - if len(description_display) > 1 and description_display != 'N/A' and len(target_string) > 1 and target_string != 'None': - description_display = description_display + '; ' + target_string.strip() - - # Save it for the jinja2 tablet - this_trait.description_display = description_display - - #XZ: trait_location_value is used for sorting - trait_location_repr = 'N/A' - trait_location_value = 1000000 - - if this_trait.chr and this_trait.mb: - try: - trait_location_value = int(this_trait.chr)*1000 + this_trait.mb - except: - if this_trait.chr.upper() == 'X': - trait_location_value = 20*1000 + this_trait.mb - else: - trait_location_value = ord(str(this_trait.chr).upper()[0])*1000 + this_trait.mb - - this_trait.location_repr = 'Chr %s: %.4f Mb' % (this_trait.chr, float(this_trait.mb) ) - this_trait.location_value = trait_location_value - #this_trait.trait_location_value = trait_location_value - - #XZ, 01/12/08: This SQL query is much faster. - query = ( -"""select ProbeSetXRef.mean from ProbeSetXRef, ProbeSet - where ProbeSetXRef.ProbeSetFreezeId = %s and - ProbeSet.Id = ProbeSetXRef.ProbeSetId and - ProbeSet.Name = '%s' - """ % (self.db_conn.escape_string(str(this_trait.db.id)), - self.db_conn.escape_string(this_trait.name))) - - print("query is:", pf(query)) - - self.cursor.execute(query) - result = self.cursor.fetchone() - - if result: - if result[0]: - mean = result[0] - else: - mean=0 - else: - mean = 0 - - #XZ, 06/05/2009: It is neccessary to turn on nowrap - this_trait.mean = repr = "%2.3f" % mean - - #LRS and its location - this_trait.LRS_score_repr = 'N/A' - this_trait.LRS_score_value = 0 - this_trait.LRS_location_repr = 'N/A' - this_trait.LRS_location_value = 1000000 - - #Max LRS and its Locus location - if this_trait.lrs and this_trait.locus: - self.cursor.execute(""" - select Geno.Chr, Geno.Mb from Geno, Species - where Species.Name = '%s' and - Geno.Name = '%s' and - Geno.SpeciesId = Species.Id - """ % (species, this_trait.locus)) - result = self.cursor.fetchone() - - if result: - if result[0] and result[1]: - LRS_Chr = result[0] - LRS_Mb = result[1] - - #XZ: LRS_location_value is used for sorting - try: - LRS_location_value = int(LRS_Chr)*1000 + float(LRS_Mb) - except: - if LRS_Chr.upper() == 'X': - LRS_location_value = 20*1000 + float(LRS_Mb) - else: - LRS_location_value = ord(str(LRS_chr).upper()[0])*1000 + float(LRS_Mb) - - this_trait.LRS_score_repr = LRS_score_repr = '%3.1f' % this_trait.lrs - this_trait.LRS_score_value = LRS_score_value = this_trait.lrs - this_trait.LRS_location_repr = LRS_location_repr = 'Chr %s: %.4f Mb' % (LRS_Chr, float(LRS_Mb) ) -- cgit v1.2.3 From d1f2863c15f62ae37833fa1311870d7b1aab3355 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Wed, 28 Nov 2012 14:30:04 -0600 Subject: Made some small changes to get code working for genotype searches --- wqflask/base/data_set.py | 2 +- wqflask/wqflask/parser.py | 2 ++ wqflask/wqflask/search_results.py | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 9e3e6d81..d9d3a52b 100755 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -258,7 +258,7 @@ class GenotypeDataSet(DataSet): # Todo: Obsolete or rename this field self.type = 'Geno' - query = ''' + self.query = ''' SELECT InbredSet.Name, InbredSet.Id FROM diff --git a/wqflask/wqflask/parser.py b/wqflask/wqflask/parser.py index dc33fc52..7711942a 100644 --- a/wqflask/wqflask/parser.py +++ b/wqflask/wqflask/parser.py @@ -15,6 +15,8 @@ Both square brackets and parentheses can be used interchangeably. Both can also encapsulate a single value; "cisLRS=[9 999 10)" would be acceptable.] +NEED TO DEAL WITH WILDCARD CHARACTER '*' + """ from __future__ import print_function, division diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index b50e45d5..96350f22 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -55,6 +55,7 @@ class SearchResultPage(templatePage): assert self.openMysql(), "Couldn't open MySQL" print("fd is:", pf(fd)) + print("fd.dict is:", pf(fd['dataset'])) self.dataset = fd['dataset'] # change back to self.dataset @@ -93,7 +94,7 @@ class SearchResultPage(templatePage): """ Get the info displayed in the search result table from the set of results computed in the "search" function - + """ self.trait_list = [] # result_set represents the results for each search term; a search of @@ -114,7 +115,7 @@ class SearchResultPage(templatePage): this_trait.retrieveInfo(QTL=True) print("this_trait is:", pf(this_trait)) self.trait_list.append(this_trait) - + self.dataset.get_trait_info(self.trait_list, species) -- cgit v1.2.3 From 94300b4488aa334ced34981981ad5d0ecdec01d6 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Thu, 29 Nov 2012 18:44:01 -0600 Subject: Changed a number of variables (riset to group, db to dataset) Put most of the code for cisLRS and transLRS searches into the class CisTransLrsSearch (might change this name to something else later) Simplified escape code for searches in do_search.py Got search_results working again after some changes --- wqflask/base/data_set.py | 5 +- wqflask/base/webqtlFormData.py | 26 +-- wqflask/base/webqtlTrait.py | 146 ++++++------- wqflask/dbFunction/webqtlDatabaseFunction.py | 4 +- wqflask/wqflask/do_search.py | 237 +++++++++------------- wqflask/wqflask/search_results.py | 18 +- wqflask/wqflask/show_trait/show_trait.py | 83 ++++---- wqflask/wqflask/templates/index_page.html | 4 +- wqflask/wqflask/templates/search_result_page.html | 2 +- wqflask/wqflask/views.py | 3 + 10 files changed, 241 insertions(+), 287 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index d9d3a52b..633f7545 100755 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -392,8 +392,9 @@ class MrnaAssayDataSet(DataSet): if len(description_display) > 1 and description_display != 'N/A' and len(target_string) > 1 and target_string != 'None': description_display = description_display + '; ' + target_string.strip() - # Save it for the jinja2 tablet + # Save it for the jinja2 template this_trait.description_display = description_display + #print(" xxxxdd [%s]: %s" % (type(this_trait.description_display), description_display)) #XZ: trait_location_value is used for sorting trait_location_repr = 'N/A' @@ -418,7 +419,7 @@ class MrnaAssayDataSet(DataSet): where ProbeSetXRef.ProbeSetFreezeId = %s and ProbeSet.Id = ProbeSetXRef.ProbeSetId and ProbeSet.Name = '%s' - """ % (self.db_conn.escape_string(str(this_trait.db.id)), + """ % (self.db_conn.escape_string(str(this_trait.dataset.id)), self.db_conn.escape_string(this_trait.name))) print("query is:", pf(query)) diff --git a/wqflask/base/webqtlFormData.py b/wqflask/base/webqtlFormData.py index ff1db0e8..a3537c87 100755 --- a/wqflask/base/webqtlFormData.py +++ b/wqflask/base/webqtlFormData.py @@ -47,7 +47,7 @@ from utility import webqtlUtil class webqtlFormData(object): 'Represents data from a WebQTL form page, needed to generate the next page' - attrs = ('formID','RISet','genotype','samplelist','allsamplelist', 'display_variance' + attrs = ('formID','group','genotype','samplelist','allsamplelist', 'display_variance' 'suggestive','significance','submitID','identification', 'enablevariance', 'nperm','nboot','email','incparentsf1','genotype_1','genotype_2','traitInfo') @@ -104,11 +104,11 @@ class webqtlFormData(object): self.ppolar = None self.mpolar = None - print("[yellow] self.RISet is:", self.RISet) - if self.RISet: + print("[yellow] self.group is:", self.group) + if self.group: #try: # # NL, 07/27/2010. ParInfo has been moved from webqtlForm.py to webqtlUtil.py; - _f1, _f12, self.mpolar, self.ppolar = webqtlUtil.ParInfo[self.RISet] + _f1, _f12, self.mpolar, self.ppolar = webqtlUtil.ParInfo[self.group] #except: # f1 = f12 = self.mpolar = self.ppolar = None @@ -129,8 +129,8 @@ class webqtlFormData(object): #self.readGenotype() #self.readData() - if self.RISet == 'BXD300': - self.RISet = 'BXD' + if self.group == 'BXD300': + self.group = 'BXD' def __getitem__(self, key): @@ -153,17 +153,17 @@ class webqtlFormData(object): def readGenotype(self): '''read genotype from .geno file''' - if self.RISet == 'BXD300': - self.RISet = 'BXD' + if self.group == 'BXD300': + self.group = 'BXD' - assert self.RISet, "self.RISet needs to be set" + assert self.group, "self.group needs to be set" #genotype_1 is Dataset Object without parents and f1 #genotype_2 is Dataset Object with parents and f1 (not for intercross) self.genotype_1 = reaper.Dataset() - full_filename = os.path.join(webqtlConfig.GENODIR, self.RISet + '.geno') + full_filename = os.path.join(webqtlConfig.GENODIR, self.group + '.geno') # reaper barfs on unicode filenames, so here we ensure it's a string full_filename = str(full_filename) @@ -173,12 +173,12 @@ class webqtlFormData(object): try: # NL, 07/27/2010. ParInfo has been moved from webqtlForm.py to webqtlUtil.py; - _f1, _f12, _mat, _pat = webqtlUtil.ParInfo[self.RISet] + _f1, _f12, _mat, _pat = webqtlUtil.ParInfo[self.group] except KeyError: _f1 = _f12 = _mat = _pat = None self.genotype_2 = self.genotype_1 - if self.genotype_1.type == "riset" and _mat and _pat: + if self.genotype_1.type == "group" and _mat and _pat: self.genotype_2 = self.genotype_1.add(Mat=_mat, Pat=_pat) #, F1=_f1) #determine default genotype object @@ -333,7 +333,7 @@ class webqtlFormData(object): def Sample(self): 'Create some dummy data for testing' - self.RISet = 'BXD' + self.group = 'BXD' self.incparentsf1 = 'on' #self.display = 9.2 #self.significance = 16.1 diff --git a/wqflask/base/webqtlTrait.py b/wqflask/base/webqtlTrait.py index 29087721..cc0e2321 100755 --- a/wqflask/base/webqtlTrait.py +++ b/wqflask/base/webqtlTrait.py @@ -24,11 +24,11 @@ class webqtlTrait: print("in webqtlTrait") self.db_conn = db_conn self.cursor = self.db_conn.cursor() - self.db = None # database object + self.dataset = None # database object self.name = '' # Trait ID, ProbeSet ID, Published ID, etc. self.cellid = '' self.identification = 'un-named trait' - self.riset = '' + self.group = '' self.haveinfo = 0 self.sequence = '' # Blat sequence, available for ProbeSet self.data = {} @@ -41,22 +41,22 @@ class webqtlTrait: elif name == 'fullname': name2 = value.split("::") if len(name2) == 2: - self.db, self.name = name2 + self.dataset, self.name = name2 elif len(name2) == 3: - self.db, self.name, self.cellid = name2 + self.dataset, self.name, self.cellid = name2 else: raise KeyError, repr(value) + ' parameter format error.' else: raise KeyError, repr(name) + ' not a valid parameter for this class.' - if self.db and isinstance(self.db, basestring): + if self.dataset and isinstance(self.dataset, basestring): assert self.cursor, "Don't have a cursor" - self.db = create_dataset(self.db_conn, self.db) + self.dataset = create_dataset(self.db_conn, self.dataset) - #if self.db == None, not from a database - print("self.db is:", self.db, type(self.db)) - if self.db: - if self.db.type == "Temp": + #if self.dataset == None, not from a database + print("self.dataset is:", self.dataset, type(self.dataset)) + if self.dataset: + if self.dataset.type == "Temp": self.cursor.execute(''' SELECT InbredSet.Name @@ -66,9 +66,11 @@ class webqtlTrait: Temp.InbredSetId = InbredSet.Id AND Temp.Name = "%s" ''', self.name) - self.riset = self.cursor.fetchone()[0] + self.group = self.cursor.fetchone()[0] else: - self.riset = self.db.get_group() + self.group = self.dataset.get_group() + + print("trinity, self.group is:", self.group) # # In ProbeSet, there are maybe several annotations match one sequence @@ -82,8 +84,8 @@ class webqtlTrait: # The variable self.sequence should be changed to self.BlatSeq # It also should be changed in other places where it are used. - if self.db: - if self.db.type == 'ProbeSet': + if self.dataset: + if self.dataset.type == 'ProbeSet': print("Doing ProbeSet Query") query = ''' SELECT @@ -95,7 +97,7 @@ class webqtlTrait: ProbeSetFreeze.Id = ProbeSetXRef.ProbeSetFreezeId and ProbeSet.Name = %s and ProbeSetFreeze.Name = %s - ''', (self.name, self.db.name) + ''', (self.name, self.dataset.name) print("query is:", query) self.cursor.execute(*query) self.sequence = self.cursor.fetchone()[0] @@ -104,8 +106,8 @@ class webqtlTrait: def getName(self): str = "" - if self.db and self.name: - str = "%s::%s" % (self.db, self.name) + if self.dataset and self.name: + str = "%s::%s" % (self.dataset, self.name) if self.cellid: str += "::" + self.cellid else: @@ -124,8 +126,8 @@ class webqtlTrait: # def getGivenName(self): str = self.name - if self.db and self.name: - if self.db.type=='Temp': + if self.dataset and self.name: + if self.dataset.type=='Temp': self.cursor.execute('SELECT description FROM Temp WHERE Name=%s', self.name) desc = self.cursor.fetchone()[0] if desc.__contains__('PCA'): @@ -137,16 +139,16 @@ class webqtlTrait: def displayName(self): str = "" - if self.db and self.name: - if self.db.type=='Temp': + if self.dataset and self.name: + if self.dataset.type=='Temp': desc = self.description if desc.__contains__('PCA'): desc = desc[desc.rindex(':')+1:].strip() else: desc = desc[:desc.index('entered')].strip() - str = "%s::%s" % (self.db, desc) + str = "%s::%s" % (self.dataset, desc) else: - str = "%s::%s" % (self.db, self.name) + str = "%s::%s" % (self.dataset, self.name) if self.cellid: str += "::" + self.cellid else: @@ -156,7 +158,7 @@ class webqtlTrait: #def __str__(self): - # #return "%s %s" % (self.getName(), self.riset) + # #return "%s %s" % (self.getName(), self.group) # return self.getName() #__str__ = getName #__repr__ = __str__ @@ -207,7 +209,7 @@ class webqtlTrait: # def getSequence(self): assert self.cursor - if self.db.type == 'ProbeSet': + if self.dataset.type == 'ProbeSet': self.cursor.execute(''' SELECT ProbeSet.BlatSeq @@ -218,7 +220,7 @@ class webqtlTrait: ProbeSetFreeze.Id = ProbeSetXRef.ProbSetFreezeId and ProbeSet.Name = %s ProbeSetFreeze.Name = %s - ''', self.name, self.db.name) + ''', self.name, self.dataset.name) #self.cursor.execute(query) results = self.fetchone() @@ -230,9 +232,9 @@ class webqtlTrait: if samplelist == None: samplelist = [] - assert self.db and self.cursor + assert self.dataset and self.cursor - if self.db.type == 'Temp': + if self.dataset.type == 'Temp': query = ''' SELECT Strain.Name, TempData.value, TempData.SE, TempData.NStrain, TempData.Id @@ -246,7 +248,7 @@ class webqtlTrait: Strain.Name ''' % self.name #XZ, 03/02/2009: Xiaodong changed Data to PublishData, SE to PublishSE - elif self.db.type == 'Publish': + elif self.dataset.type == 'Publish': query = ''' SELECT Strain.Name, PublishData.value, PublishSE.error, NStrain.count, PublishData.Id @@ -263,7 +265,7 @@ class webqtlTrait: PublishFreeze.Id = %d AND PublishData.StrainId = Strain.Id Order BY Strain.Name - ''' % (self.name, self.db.id) + ''' % (self.name, self.dataset.id) #XZ, 03/02/2009: Xiaodong changed Data to ProbeData, SE to ProbeSE elif self.cellid: @@ -287,9 +289,9 @@ class webqtlTrait: ProbeData.StrainId = Strain.Id Order BY Strain.Name - ''' % (self.cellid, self.name, self.db.name) + ''' % (self.cellid, self.name, self.dataset.name) #XZ, 03/02/2009: Xiaodong added this block for ProbeSetData and ProbeSetSE - elif self.db.type == 'ProbeSet': + elif self.dataset.type == 'ProbeSet': #ProbeSet Data query = ''' SELECT @@ -306,7 +308,7 @@ class webqtlTrait: ProbeSetData.StrainId = Strain.Id Order BY Strain.Name - ''' % (self.name, self.db.name) + ''' % (self.name, self.dataset.name) #XZ, 03/02/2009: Xiaodong changeded Data to GenoData, SE to GenoSE else: #Geno Data @@ -326,7 +328,7 @@ class webqtlTrait: GenoData.StrainId = Strain.Id Order BY Strain.Name - ''' % (webqtlDatabaseFunction.retrieveSpeciesId(self.cursor, self.db.riset), self.name, self.db.name) + ''' % (webqtlDatabaseFunction.retrieveSpeciesId(self.cursor, self.dataset.group), self.name, self.dataset.name) self.cursor.execute(query) @@ -341,7 +343,7 @@ class webqtlTrait: if not samplelist or (samplelist and name in samplelist): #if value != None: # num_cases = None - # if self.db.type in ('Publish', 'Temp'): + # if self.dataset.type in ('Publish', 'Temp'): # ndata = item[3] name = item[0] self.data[name] = webqtlCaseData(*item) #name, value, variance, num_cases) @@ -352,7 +354,7 @@ class webqtlTrait: # if val != None: # var = item[2] # ndata = None - # if self.db.type in ('Publish', 'Temp'): + # if self.dataset.type in ('Publish', 'Temp'): # ndata = item[3] # self.data[item[0]] = webqtlCaseData(val, var, ndata) # #end for @@ -370,9 +372,9 @@ class webqtlTrait: # return self.__dict__.items() def retrieveInfo(self, QTL = None): - assert self.db and self.cursor - if self.db.type == 'Publish': - #self.db.DisField = ['Name','PubMed_ID','Phenotype','Abbreviation','Authors','Title',\ + assert self.dataset and self.cursor + if self.dataset.type == 'Publish': + #self.dataset.DisField = ['Name','PubMed_ID','Phenotype','Abbreviation','Authors','Title',\ # 'Abstract', 'Journal','Volume','Pages','Month','Year','Sequence',\ # 'Units', 'comments'] query = ''' @@ -393,11 +395,11 @@ class webqtlTrait: Publication.Id = PublishXRef.PublicationId AND PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND PublishFreeze.Id =%s - ''' % (self.name, self.db.id) + ''' % (self.name, self.dataset.id) #XZ, 05/08/2009: Xiaodong add this block to use ProbeSet.Id to find the probeset instead of just using ProbeSet.Name #XZ, 05/08/2009: to avoid the problem of same probeset name from different platforms. - elif self.db.type == 'ProbeSet': - display_fields_string = ',ProbeSet.'.join(self.db.display_fields) + elif self.dataset.type == 'ProbeSet': + display_fields_string = ',ProbeSet.'.join(self.dataset.display_fields) display_fields_string = 'ProbeSet.' + display_fields_string query = """ SELECT %s @@ -407,11 +409,11 @@ class webqtlTrait: ProbeSetXRef.ProbeSetId = ProbeSet.Id AND ProbeSetFreeze.Name = '%s' AND ProbeSet.Name = '%s' - """ % (display_fields_string, self.db.name, self.name) + """ % (display_fields_string, self.dataset.name, self.name) #XZ, 05/08/2009: We also should use Geno.Id to find marker instead of just using Geno.Name # to avoid the problem of same marker name from different species. - elif self.db.type == 'Geno': - display_fields_string = string.join(self.db.display_fields,',Geno.') + elif self.dataset.type == 'Geno': + display_fields_string = string.join(self.dataset.display_fields,',Geno.') display_fields_string = 'Geno.' + display_fields_string query = """ SELECT %s @@ -421,10 +423,10 @@ class webqtlTrait: GenoXRef.GenoId = Geno.Id AND GenoFreeze.Name = '%s' AND Geno.Name = '%s' - """ % (display_fields_string, self.db.name, self.name) + """ % (display_fields_string, self.dataset.name, self.name) else: #Temp type query = 'SELECT %s FROM %s WHERE Name = "%s"' % \ - (string.join(self.db.display_fields,','), self.db.type, self.name) + (string.join(self.dataset.display_fields,','), self.dataset.type, self.name) self.cursor.execute(query) @@ -433,16 +435,16 @@ class webqtlTrait: self.haveinfo = 1 #XZ: assign SQL query result to trait attributes. - for i, field in enumerate(self.db.display_fields): + for i, field in enumerate(self.dataset.display_fields): setattr(self, field, traitInfo[i]) - if self.db.type == 'Publish': + if self.dataset.type == 'Publish': self.confidential = 0 if self.pre_publication_description and not self.pubmed_id: self.confidential = 1 self.homologeneid = None - if self.db.type == 'ProbeSet' and self.riset and self.geneid: + if self.dataset.type == 'ProbeSet' and self.group and self.geneid: #XZ, 05/26/2010: From time to time, this query get error message because some geneid values in database are not number. #XZ: So I have to test if geneid is number before execute the query. #XZ: The geneid values in database should be cleaned up. @@ -463,7 +465,7 @@ class webqtlTrait: InbredSet.Name = '%s' AND InbredSet.SpeciesId = Species.Id AND Species.TaxonomyId = Homologene.TaxonomyId - """ % (self.geneid, self.riset) + """ % (self.geneid, self.group) self.cursor.execute(query) result = self.cursor.fetchone() else: @@ -473,7 +475,7 @@ class webqtlTrait: self.homologeneid = result[0] if QTL: - if self.db.type == 'ProbeSet' and not self.cellid: + if self.dataset.type == 'ProbeSet' and not self.cellid: query = ''' SELECT ProbeSetXRef.Locus, ProbeSetXRef.LRS, ProbeSetXRef.pValue, ProbeSetXRef.mean @@ -483,14 +485,14 @@ class webqtlTrait: ProbeSetXRef.ProbeSetId = ProbeSet.Id AND ProbeSet.Name = "%s" AND ProbeSetXRef.ProbeSetFreezeId =%s - ''' % (self.name, self.db.id) + ''' % (self.name, self.dataset.id) self.cursor.execute(query) traitQTL = self.cursor.fetchone() if traitQTL: self.locus, self.lrs, self.pvalue, self.mean = traitQTL else: self.locus = self.lrs = self.pvalue = self.mean = "" - if self.db.type == 'Publish': + if self.dataset.type == 'Publish': query = ''' SELECT PublishXRef.Locus, PublishXRef.LRS @@ -500,7 +502,7 @@ class webqtlTrait: PublishXRef.Id = %s AND PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND PublishFreeze.Id =%s - ''' % (self.name, self.db.id) + ''' % (self.name, self.dataset.id) self.cursor.execute(query) traitQTL = self.cursor.fetchone() if traitQTL: @@ -514,7 +516,7 @@ class webqtlTrait: if not self.haveinfo: self.retrieveInfo() - if self.db.type == 'Publish': + if self.dataset.type == 'Publish': PubMedLink = "" if self.pubmed_id: PubMedLink = HT.Href(text="PubMed %d : " % self.pubmed_id, @@ -524,10 +526,10 @@ class webqtlTrait: if formName: setDescription2 = HT.Href(url="javascript:showDatabase3('%s','%s','%s','')" % - (formName, self.db.name, self.name), Class = "fs14") + (formName, self.dataset.name, self.name), Class = "fs14") else: setDescription2 = HT.Href(url="javascript:showDatabase2('%s','%s','')" % - (self.db.name,self.name), Class = "fs14") + (self.dataset.name,self.name), Class = "fs14") if self.confidential and not webqtlUtil.hasAccessToConfidentialPhenotypeTrait(privilege=privilege, userName=userName, authorized_users=authorized_users): setDescription2.append('RecordID/%s - %s' % (self.name, self.pre_publication_description)) @@ -545,20 +547,20 @@ class webqtlTrait: setDescription2.append(HT.Italic('%s, and colleagues' % a1)) setDescription = HT.Span(PubMedLink, setDescription2) - elif self.db.type == 'Temp': + elif self.dataset.type == 'Temp': setDescription = HT.Href(text="%s" % (self.description),url="javascript:showDatabase2\ - ('%s','%s','')" % (self.db.name,self.name), Class = "fs14") + ('%s','%s','')" % (self.dataset.name,self.name), Class = "fs14") setDescription = HT.Span(setDescription) - elif self.db.type == 'Geno': # Genome DB only available for single search + elif self.dataset.type == 'Geno': # Genome DB only available for single search if formName: setDescription = HT.Href(text="Locus %s [Chr %s @ %s Mb]" % (self.name,self.chr,\ '%2.3f' % self.mb),url="javascript:showDatabase3('%s','%s','%s','')" % \ - (formName, self.db.name, self.name), Class = "fs14") + (formName, self.dataset.name, self.name), Class = "fs14") else: setDescription = HT.Href(text="Locus %s [Chr %s @ %s Mb]" % (self.name,self.chr,\ '%2.3f' % self.mb),url="javascript:showDatabase2('%s','%s','')" % \ - (self.db.name,self.name), Class = "fs14") + (self.dataset.name,self.name), Class = "fs14") setDescription = HT.Span(setDescription) @@ -566,20 +568,20 @@ class webqtlTrait: if self.cellid: if formName: setDescription = HT.Href(text="ProbeSet/%s/%s" % (self.name, self.cellid),url=\ - "javascript:showDatabase3('%s','%s','%s','%s')" % (formName, self.db.name,self.name,self.cellid), \ + "javascript:showDatabase3('%s','%s','%s','%s')" % (formName, self.dataset.name,self.name,self.cellid), \ Class = "fs14") else: setDescription = HT.Href(text="ProbeSet/%s/%s" % (self.name,self.cellid),url=\ - "javascript:showDatabase2('%s','%s','%s')" % (self.db.name,self.name,self.cellid), \ + "javascript:showDatabase2('%s','%s','%s')" % (self.dataset.name,self.name,self.cellid), \ Class = "fs14") else: if formName: setDescription = HT.Href(text="ProbeSet/%s" % self.name, url=\ - "javascript:showDatabase3('%s','%s','%s','')" % (formName, self.db.name,self.name), \ + "javascript:showDatabase3('%s','%s','%s','')" % (formName, self.dataset.name,self.name), \ Class = "fs14") else: setDescription = HT.Href(text="ProbeSet/%s" % self.name, url=\ - "javascript:showDatabase2('%s','%s','')" % (self.db.name,self.name), \ + "javascript:showDatabase2('%s','%s','')" % (self.dataset.name,self.name), \ Class = "fs14") if self.symbol and self.chr and self.mb: setDescription.append(' [') @@ -591,9 +593,9 @@ class webqtlTrait: setDescription.append('; %s' % self.probe_target_description) setDescription = HT.Span(setDescription) - if self.db.type != 'Temp' and dispFromDatabase: + if self.dataset.type != 'Temp' and dispFromDatabase: setDescription.append( ' --- FROM : ') - setDescription.append(self.db.genHTML(Class='cori')) + setDescription.append(self.dataset.genHTML(Class='cori')) return setDescription @property @@ -654,13 +656,13 @@ class webqtlTrait: select ProbeFreeze.Name from ProbeFreeze, ProbeSetFreeze where ProbeFreeze.Id = ProbeSetFreeze.ProbeFreezeId AND - ProbeSetFreeze.Id = %d""" % thisTrait.db.id) + ProbeSetFreeze.Id = %d""" % thisTrait.dataset.id) probeDBName = self.cursor.fetchone()[0] return dict(name = probeDBName, url = None) else: - return dict(name = self.db.fullname, - url = webqtlConfig.INFOPAGEHREF % self.db.name) + return dict(name = self.dataset.fullname, + url = webqtlConfig.INFOPAGEHREF % self.dataset.name) def calculate_correlation(self, values, method): """Calculate the correlation value and p value according to the method specified""" diff --git a/wqflask/dbFunction/webqtlDatabaseFunction.py b/wqflask/dbFunction/webqtlDatabaseFunction.py index 8f923b8a..1e028ecc 100755 --- a/wqflask/dbFunction/webqtlDatabaseFunction.py +++ b/wqflask/dbFunction/webqtlDatabaseFunction.py @@ -80,9 +80,9 @@ def getAllSpecies(cursor=None): #function: retrieve specie's name info based on RISet ########################################################################### -def retrieveSpecies(cursor=None, RISet=None): +def retrieveSpecies(cursor=None, group=None): try: - cursor.execute("select Species.Name from Species, InbredSet where InbredSet.Name = '%s' and InbredSet.SpeciesId = Species.Id" % RISet) + cursor.execute("select Species.Name from Species, InbredSet where InbredSet.Name = '%s' and InbredSet.SpeciesId = Species.Id" % group) return cursor.fetchone()[0] except: return None diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py index 2b8efd68..92a754e3 100644 --- a/wqflask/wqflask/do_search.py +++ b/wqflask/wqflask/do_search.py @@ -20,7 +20,7 @@ class DoSearch(object): def __init__(self, search_term, search_operator, dataset, cursor, db_conn): self.search_term = search_term # Make sure search_operator is something we expect - assert search_operator in ("=", "<", ">", "<=", ">="), "Bad search operator" + assert search_operator in (None, "=", "<", ">", "<=", ">="), "Bad search operator" self.search_operator = search_operator self.dataset = dataset self.db_conn = db_conn @@ -41,6 +41,12 @@ class DoSearch(object): def escape(self, stringy): """Shorter name than self.db_conn.escape_string""" return self.db_conn.escape_string(str(stringy)) + + def mescape(self, *items): + """Multiple escape""" + escaped = [self.escape(item) for item in items] + print("escaped is:", escaped) + return tuple(escaped) def normalize_spaces(self, stringy): """Strips out newlines/extra spaces and replaces them with just spaces""" @@ -91,8 +97,7 @@ class ProbeSetSearch(DoSearch): """Generates and runs a simple search of an mRNA expression dataset""" print("Running ProbeSetSearch") - query = (self.base_query + - """WHERE (MATCH (ProbeSet.Name, + query = self.base_query + """WHERE (MATCH (ProbeSet.Name, ProbeSet.description, ProbeSet.symbol, alias, @@ -102,8 +107,8 @@ class ProbeSetSearch(DoSearch): AGAINST ('%s' IN BOOLEAN MODE)) and ProbeSet.Id = ProbeSetXRef.ProbeSetId and ProbeSetXRef.ProbeSetFreezeId = %s - """ % (self.escape(self.search_term), - self.escape(self.dataset.id))) + """ % (self.escape(self.search_term[0]), + self.escape(self.dataset.id)) print("final query is:", pf(query)) @@ -275,7 +280,8 @@ class GoSearch(ProbeSetSearch): class LrsSearch(ProbeSetSearch): """Searches for genes with a QTL within the given LRS values - LRS searches can take 2 different forms: + LRS searches can take 3 different forms: + - LRS > (or <) min/max_LRS - LRS=(min_LRS max_LRS) - LRS=(min_LRS max_LRS chromosome start_Mb end_Mb) where min/max_LRS represent the range of LRS scores and start/end_Mb represent @@ -289,129 +295,128 @@ class LrsSearch(ProbeSetSearch): self.search_term = [float(value) for value in self.search_term] - from_clause = ", Geno" + self.from_clause = ", Geno" if self.search_operator == "=": - if len(self.search_term) >= 2: - if len(self.search_term) == 2: - lrs_min, lrs_max = self.search_term - elif len(self.search_term) == 5: - lrs_min, lrs_max, chr_num, mb_low, mb_high = self.search_term - else: - SomeError - - sub_clause = """ %sXRef.LRS > %s and - %sXRef.LRS < %s and """ % (self.escape(self.dataset.type), - self.escape(min(lrs_min, lrs_max)), - self.escape(self.dataset.type), - self.escape(max(lrs_min, lrs_max))) - + assert isinstance(self.search_term, (list, tuple)) + self.lrs_min, self.lrs_max = self.search_term[:2] + + self.sub_clause = """ %sXRef.LRS > %s and + %sXRef.LRS < %s and """ % self.mescape(self.dataset.type, + min(self.lrs_min, self.lrs_max), + self.dataset.type, + max(self.lrs_min, self.lrs_max)) + + if len(self.search_term) > 2: + self.chr_num = self.search_term[2] + self.sub_clause += """ Geno.Chr = %s and """ % (self.escape(self.chr_num)) if len(self.search_term) == 5: - sub_clause = sub_clause + """ Geno.Mb > %s and + self.mb_low, self.mb_high = self.search_term[3:] + self.sub_clause += """ Geno.Mb > %s and Geno.Mb < %s and - Geno.Chr = %s and - """ % (self.escape(min(mb_low, mb_high)), - self.escape(max(mb_low, mb_high)), - self.escape(chr_num)) + """ % self.mescape(min(self.mb_low, self.mb_high), + max(self.mb_low, self.mb_high)) + print("self.sub_clause is:", pf(self.sub_clause)) else: # Deal with >, <, >=, and <= - sub_clause = """ %sXRef.LRS %s %s and """ % (self.escape(self.dataset.type), - self.escape(self.search_operator), - self.escape(self.search_term[0])) + self.sub_clause = """ %sXRef.LRS %s %s and """ % self.mescape(self.dataset.type, + self.search_operator, + self.search_term[0]) - where_clause = sub_clause + """ %sXRef.Locus = Geno.name and + self.where_clause = self.sub_clause + """ %sXRef.Locus = Geno.name and Geno.SpeciesId = %s and %s.Chr = Geno.Chr - """ % (self.escape(self.dataset.type), - self.escape(self.species_id), - self.escape(self.dataset.type)) + """ % self.mescape(self.dataset.type, + self.species_id, + self.dataset.type) - print("where_clause is:", pf(where_clause)) + print("where_clause is:", pf(self.where_clause)) - query = self.compile_final_query(from_clause, where_clause) + self.query = self.compile_final_query(self.from_clause, self.where_clause) - return self.execute(query) - -class CisLrsSearch(LrsSearch): - """Searches for genes on a particular chromosome with a cis-eQTL within the given LRS values + return self.execute(self.query) - A cisLRS search can take 3 forms: - - cisLRS=(min_LRS max_LRS) - - cisLRS=(min_LRS max_LRS mb_buffer) - - cisLRS>min_LRS - where min/max_LRS represent the range of LRS scores and the mb_buffer is the range around - a particular QTL where its eQTL would be considered "cis". If there is no third parameter, - mb_buffer will default to 5 megabases. - A QTL is a cis-eQTL if a gene's expression is regulated by a QTL in roughly the same area - (where the area is determined by the mb_buffer that the user can choose). +class CisTransLrsSearch(LrsSearch): - """ - - # This is tentatively a child of LrsSearch; I'll need to check what code, if any, overlaps - # between this and the LrsSearch code. In the original code, commands are divided by - # the number of inputs they take, so these commands are completely separate - - DoSearch.search_types['CISLRS'] = "CisLrsSearch" - - def run(self): + def real_run(self, the_operator): #if isinstance(self.search_term, basestring): # self.search_term = [self.search_term] print("self.search_term is:", self.search_term) self.search_term = [float(value) for value in self.search_term] - mb_buffer = 5 # default - - from_clause = ", Geno " - + self.mb_buffer = 5 # default + self.from_clause = ", Geno " + if self.search_operator == "=": if len(self.search_term) == 2: - lower_limit, upper_limit = self.search_term + self.lrs_min, self.lrs_max = self.search_term #[int(value) for value in self.search_term] elif len(self.search_term) == 3: - lower_limit, upper_limit, mb_buffer = self.search_term + self.lrs_min, self.lrs_max, self.mb_buffer = self.search_term else: SomeError - sub_clause = """ %sXRef.LRS > %s and - %sXRef.LRS < %s and - ABS(%s.Mb-Geno.Mb) < %s and """ % ( - self.escape(self.dataset.type), - self.escape(min(lower_limit, upper_limit)), + self.sub_clause = """ %sXRef.LRS > %s and + %sXRef.LRS < %s and """ % ( self.escape(self.dataset.type), - self.escape(max(lower_limit, upper_limit)), + self.escape(min(self.lrs_min, self.lrs_max)), self.escape(self.dataset.type), - self.escape(mb_buffer) + self.escape(max(self.lrs_min, self.lrs_max)) ) - else: # Deal with >, <, >=, and <= - sub_clause = """ %sXRef.LRS %s %s and - ABS(%s.Mb-Geno.Mb) < %s and """ % ( + self.sub_clause = """ %sXRef.LRS %s %s and """ % ( self.escape(self.dataset.type), self.escape(self.search_operator), - self.escape(self.search_term[0]), - self.escape(self.dataset.type), - self.escape(mb_buffer) + self.escape(self.search_term[0]) ) - - where_clause = sub_clause + """%sXRef.Locus = Geno.name and + + self.where_clause = self.sub_clause + """ + ABS(%s.Mb-Geno.Mb) %s %s and + %sXRef.Locus = Geno.name and Geno.SpeciesId = %s and %s.Chr = Geno.Chr""" % ( + self.escape(self.dataset.type), + the_operator, + self.escape(self.mb_buffer), self.escape(self.dataset.type), self.escape(self.species_id), self.escape(self.dataset.type) ) - print("where_clause is:", pf(where_clause)) + print("where_clause is:", pf(self.where_clause)) - query = self.compile_final_query(from_clause, where_clause) + self.query = self.compile_final_query(self.from_clause, self.where_clause) - return self.execute(query) + return self.execute(self.query) + + +class CisLrsSearch(CisTransLrsSearch): + """Searches for genes on a particular chromosome with a cis-eQTL within the given LRS values + + A cisLRS search can take 3 forms: + - cisLRS=(min_LRS max_LRS) + - cisLRS=(min_LRS max_LRS mb_buffer) + - cisLRS>min_LRS + where min/max_LRS represent the range of LRS scores and the mb_buffer is the range around + a particular QTL where its eQTL would be considered "cis". If there is no third parameter, + mb_buffer will default to 5 megabases. + + A QTL is a cis-eQTL if a gene's expression is regulated by a QTL in roughly the same area + (where the area is determined by the mb_buffer that the user can choose). + + """ + + DoSearch.search_types['CISLRS'] = "CisLrsSearch" + + def run(self): + return self.real_run("<") + -class TransLrsSearch(LrsSearch): +class TransLrsSearch(CisTransLrsSearch): """Searches for genes on a particular chromosome with a cis-eQTL within the given LRS values A transLRS search can take 2 forms: @@ -425,70 +430,11 @@ class TransLrsSearch(LrsSearch): (where the area is determined by the mb_buffer that the user can choose). Opposite of cis-eQTL. """ - - # This is tentatively a child of LrsSearch; I'll need to check what code, if any, overlaps - # between this and the LrsSearch code. In the original code, commands are divided by - # the number of inputs they take, so these commands are completely separate DoSearch.search_types['TRANSLRS'] = "TransLrsSearch" def run(self): - if len(self.search_term) == 3: - lower_limit, upper_limit, min_threshold = [int(value) for value in self.search_term] - - where_clause = """ %sXRef.LRS > %s and - %sXRef.LRS < %s and - %sXRef.Locus = Geno.name and - Geno.SpeciesId = %s and - (%s.Chr != Geno.Chr or - ABS(%s.Mb-Geno.Mb) > %s) """ % ( - self.dataset.type, - min(lower_limit, upper_limit), - self.dataset.type, - max(lower_limit, upper_limit), - self.dataset.type, - self.species_id, - self.dataset.type, - self.dataset.type, - min_threshold - ) - - else: - NeedSomeErrorHere - - return None - - -#itemCmd = item[0] -#lowerLimit = float(item[1]) -#upperLimit = float(item[2]) -# -#if itemCmd.upper() in ("TRANSLRS", "CISLRS"): -# if item[3]: -# mthresh = float(item[3]) -# clauseItem = " %sXRef.LRS > %2.7f and %sXRef.LRS < %2.7f " % \ -# (self.dbType, min(lowerLimit, upperLimit), self.dbType, max(lowerLimit, upperLimit)) -# if itemCmd.upper() == "CISLRS": -# clauseItem += """ and %sXRef.Locus = Geno.name and Geno.SpeciesId = %s and %s.Chr = Geno.Chr and ABS(%s.Mb-Geno.Mb) < %2.7f """ % (self.dbType, self.speciesId, self.dbType, self.dbType, mthresh) -# DescriptionText.append(HT.Span(' with a ', HT.U('cis-QTL'), ' having an LRS between %g and %g using a %g Mb exclusion buffer' % (min(lowerLimit, upperLimit), max(lowerLimit, upperLimit), mthresh))) -# else: -# clauseItem += """ and %sXRef.Locus = Geno.name and Geno.SpeciesId = %s and (%s.Chr != Geno.Chr or (%s.Chr != Geno.Chr and ABS(%s.Mb-Geno.Mb) > %2.7f)) """ % (self.dbType, self.speciesId, self.dbType, self.dbType, self.dbType, mthresh) -# DescriptionText.append(HT.Span(' with a ', HT.U('trans-QTL'), ' having an LRS between %g and %g using a %g Mb exclusion buffer' % (min(lowerLimit, upperLimit), max(lowerLimit, upperLimit), mthresh))) -# query.append(" (%s) " % clauseItem) -# self.orderByDefalut = "LRS" -# else: -# pass -#elif itemCmd.upper() in ("RANGE"): -# #XZ, 03/05/2009: Xiaodong changed Data to ProbeSetData -# clauseItem = " (select Pow(2, max(value) -min(value)) from ProbeSetData where Id = ProbeSetXRef.dataId) > %2.7f and (select Pow(2, max(value) -min(value)) from ProbeSetData where Id = ProbeSetXRef.dataId) < %2.7f " % (min(lowerLimit, upperLimit), max(lowerLimit, upperLimit)) -# query.append(" (%s) " % clauseItem) -# DescriptionText.append(HT.Span(' with a range of expression that varied between %g and %g' % (min(lowerLimit, upperLimit), max(lowerLimit, upperLimit)), " (fold difference)")) -#else: -# clauseItem = " %sXRef.%s > %2.7f and %sXRef.%s < %2.7f " % \ -# (self.dbType, itemCmd, min(lowerLimit, upperLimit), self.dbType, itemCmd, max(lowerLimit, upperLimit)) -# query.append(" (%s) " % clauseItem) -# self.orderByDefalut = itemCmd -# DescriptionText.append(HT.Span(' with ', HT.U(itemCmd), ' between %g and %g' % (min(lowerLimit, upperLimit), max(lowerLimit, upperLimit)))) + return self.real_run(">") class MeanSearch(ProbeSetSearch): @@ -508,7 +454,6 @@ if __name__ == "__main__": import MySQLdb import sys - from base import webqtlConfig from base.data_set import create_dataset from base.templatePage import templatePage @@ -540,11 +485,11 @@ if __name__ == "__main__": ProbeSetXRef.ProbeSetFreezeId = 112""") #print(pf(cursor.fetchall())) - #results = ProbeSetSearch("salt", dataset, cursor, db_conn).run() + results = ProbeSetSearch("shh", None, dataset, cursor, db_conn).run() #results = RifSearch("diabetes", dataset, cursor, db_conn).run() #results = WikiSearch("nicotine", dataset, cursor, db_conn).run() - results = CisLrsSearch(['99'], '>', dataset, cursor, db_conn).run() # cisLRS > 99 - #results = LrsSearch('9', '99', '1', '50', '150', '=', dataset, cursor, db_conn).run() + #results = CisLrsSearch(['99'], '>', dataset, cursor, db_conn).run() # cisLRS > 99 + #results = LrsSearch('99', '>', dataset, cursor, db_conn).run() #results = TransLrsSearch(['9', '999', '10'], dataset, cursor, db_conn).run() #results = PhenotypeSearch("brain", dataset, cursor, db_conn).run() #results = GenotypeSearch("rs13475699", dataset, cursor, db_conn).run() diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index fe091f97..63e0153d 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -68,7 +68,7 @@ class SearchResultPage(templatePage): # return ########################################### - # Names and IDs of RISet / F2 set + # Names and IDs of group / F2 set ########################################### # All Phenotypes is a special case we'll deal with later @@ -97,23 +97,23 @@ class SearchResultPage(templatePage): """ self.trait_list = [] + + group = self.dataset.group + species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, group=group) + # result_set represents the results for each search term; a search of # "shh grin2b" would have two sets of results, one for each term print("self.results is:", pf(self.results)) for result in self.results: if not result: continue - - group = self.dataset.group - species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, RISet=group) - + #### Excel file needs to be generated #### print("foo locals are:", locals()) trait_id = result[0] - this_trait = webqtlTrait(self.db_conn, db=self.dataset, name=trait_id) + this_trait = webqtlTrait(self.db_conn, dataset=self.dataset, name=trait_id) this_trait.retrieveInfo(QTL=True) - print("this_trait is:", pf(this_trait)) self.trait_list.append(this_trait) self.dataset.get_trait_info(self.trait_list, species) @@ -134,6 +134,8 @@ class SearchResultPage(templatePage): # We fall back to the dataset type as the key to get the right object search_type = self.dataset.type + print("search_type is:", pf(search_type)) + # This is throwing an error when a_search['key'] is None, so I changed above #search_type = string.upper(a_search['key']) #if not search_type: @@ -146,7 +148,7 @@ class SearchResultPage(templatePage): self.dataset, self.cursor, self.db_conn).run()) - + print("in the search results are:", self.results) diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index 3dac5933..db2636bc 100755 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -35,12 +35,12 @@ class ShowTrait(templatePage): self.fd = fd templatePage.__init__(self, fd) - assert self.openMysql(), "No datbase!" + assert self.openMysql(), "No database!" this_trait = self.get_this_trait() ##read genotype file - fd.RISet = this_trait.riset + fd.group = this_trait.group fd.readGenotype() if not fd.genotype: @@ -62,7 +62,7 @@ class ShowTrait(templatePage): # 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, + group = fd.group, submitID = '', scale = 'physic', additiveCheck = 'ON', @@ -120,7 +120,7 @@ class ShowTrait(templatePage): hddn['attribute_names'] = "" hddn['mappingMethodId'] = webqtlDatabaseFunction.getMappingMethod (cursor=self.cursor, - groupName=fd.RISet) + groupName=fd.group) if fd.identification: hddn['identification'] = fd.identification @@ -159,8 +159,8 @@ class ShowTrait(templatePage): self.hddn = hddn self.sample_group_types = OrderedDict() - self.sample_group_types['samples_primary'] = fd.RISet + " Only" - self.sample_group_types['samples_other'] = "Non-" + fd.RISet + self.sample_group_types['samples_primary'] = fd.group + " Only" + self.sample_group_types['samples_other'] = "Non-" + fd.group self.sample_group_types['samples_all'] = "All Cases" sample_lists = [group.sample_list for group in self.sample_groups] print("sample_lists is:", pf(sample_lists)) @@ -180,12 +180,12 @@ class ShowTrait(templatePage): trait_id = self.fd['trait_id'] cell_id = self.fd.get('CellID') - this_trait = webqtlTrait(db=dataset, name=trait_id, cellid=cell_id, cursor=self.cursor) + this_trait = webqtlTrait(self.db_conn, db=dataset, name=trait_id, cellid=cell_id) ##identification, etc. self.fd.identification = '%s : %s' % (this_trait.db.shortname, trait_id) this_trait.returnURL = webqtlConfig.CGIDIR + webqtlConfig.SCRIPTFILE + '?FormID=showDatabase&database=%s\ - &ProbeSetID=%s&RISet=%s&parentsf1=on' %(dataset, trait_id, self.fd['RISet']) + &ProbeSetID=%s&group=%s&parentsf1=on' %(dataset, trait_id, self.fd['group']) if cell_id: self.fd.identification = '%s/%s'%(self.fd.identification, cell_id) @@ -198,7 +198,7 @@ class ShowTrait(templatePage): def dispTraitInformation(self, fd, title1Body, hddn, this_trait): - _Species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, RISet=fd.RISet) + _Species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, group=fd.group) #tbl = HT.TableLite(cellpadding=2, Class="collap", style="margin-left:20px;", width="840", valign="top", id="target1") @@ -245,9 +245,9 @@ class ShowTrait(templatePage): else: pass - self.cursor.execute('SELECT Name FROM InbredSet WHERE Name="%s"' % fd.RISet) + self.cursor.execute('SELECT Name FROM InbredSet WHERE Name="%s"' % fd.group) if this_trait: - addSelectionButton = HT.Href(url="#redirect", onClick="addRmvSelection('%s', document.getElementsByName('%s')[0], 'addToSelection');" % (fd.RISet, 'dataInput')) + addSelectionButton = HT.Href(url="#redirect", onClick="addRmvSelection('%s', document.getElementsByName('%s')[0], 'addToSelection');" % (fd.group, '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" @@ -403,8 +403,8 @@ class ShowTrait(templatePage): 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) + probeurl = "%s?FormID=showProbeInfo&database=%s&ProbeSetID=%s&CellID=%s&group=%s&incparentsf1=ON" \ + % (os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), this_trait.db, this_trait.name, this_trait.cellid, fd.group) 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) @@ -430,7 +430,7 @@ class ShowTrait(templatePage): # )) #tSpan = HT.Span(Class="fs13") - #tSpan.append(str(_Species).capitalize(), ", ", fd.RISet) + #tSpan.append(str(_Species).capitalize(), ", ", fd.group) # #tbl.append(HT.TR( # HT.TD('Species and Group: ', Class="fwb fs13", valign="top", nowrap="on"), @@ -805,6 +805,7 @@ class ShowTrait(templatePage): #stats_row = HT.TR() #stats_cell = HT.TD() + # This should still be riset here - Sam - Nov. 2012 if fd.genotype.type == "riset": samplelist = fd.f1list + fd.samplelist else: @@ -839,15 +840,15 @@ class ShowTrait(templatePage): 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')) + self.MDP_menu.append(('%s Only' % fd.group, '1')) + self.MDP_menu.append(('Non-%s Only' % fd.group, '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')) + self.MDP_menu.append(('%s Only' % fd.group,'1')) + self.MDP_menu.append(('Non-%s Only' % fd.group,'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 @@ -895,7 +896,7 @@ class ShowTrait(templatePage): # for sampleNameOrig in all_samples]] # - #Using just the RISet sample + #Using just the group sample for sampleNameOrig in primary_samples: sampleName = sampleNameOrig.replace("_2nd_", "") @@ -908,7 +909,7 @@ class ShowTrait(templatePage): vals2.append(thisValFull) - #Using all non-RISet samples only + #Using all non-group samples only for sampleNameOrig in other_samples: sampleName = sampleNameOrig.replace("_2nd_", "") @@ -951,10 +952,10 @@ class ShowTrait(templatePage): break elif (i == 1 and len(primary_samples) < 4): stats_container = HT.Div(id="stats_tabs%s" % i, Class="ui-tabs") - #stats_container.append(HT.Div(HT.Italic("Fewer than 4 " + fd.RISet + " case data were entered. No statistical analysis has been attempted."))) + #stats_container.append(HT.Div(HT.Italic("Fewer than 4 " + fd.group + " 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_container.append(HT.Div(HT.Italic("Fewer than 4 non-" + fd.group + " case data were entered. No statistical analysis has been attempted."))) #stats_script_text = """$(function() { $("#stats_tabs0").tabs(); $("#stats_tabs1").tabs(); $("#stats_tabs2").tabs();});""" else: continue @@ -995,7 +996,7 @@ class ShowTrait(templatePage): except: plotTitle = str(this_trait.name) - #normalplot_img = BasicStatisticsFunctions.plotNormalProbability(vals=vals, RISet=fd.RISet, title=plotTitle, specialStrains=specialStrains) + #normalplot_img = BasicStatisticsFunctions.plotNormalProbability(vals=vals, group=fd.group, 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(), @@ -1018,7 +1019,7 @@ class ShowTrait(templatePage): #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_img = BasicStatisticsFunctions.plotBarGraph(identification=fd.identification, group=fd.group, vals=vals, type="name") #barName.append(HT.TR(HT.TD(barName_img))) #barName_container.append(barName) #barName_div.append(barName_container) @@ -1027,7 +1028,7 @@ class ShowTrait(templatePage): #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_img = BasicStatisticsFunctions.plotBarGraph(identification=fd.identification, group=fd.group, vals=vals, type="rank") #barRank.append(HT.TR(HT.TD(barRank_img))) #barRank_container.append(barRank) #barRank_div.append(barRank_container) @@ -1048,16 +1049,16 @@ class ShowTrait(templatePage): def build_correlation_tools(self, fd, this_trait): - #species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, RISet=fd.RISet) + #species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, group=fd.group) - RISetgp = fd.RISet + this_group = fd.group # We're checking a string here! - assert isinstance(RISetgp, basestring), "We need a string type thing here" - if RISetgp[:3] == 'BXD': - RISetgp = 'BXD' + assert isinstance(this_group, basestring), "We need a string type thing here" + if this_group[:3] == 'BXD': + this_group = 'BXD' - if RISetgp: + if this_group: #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") @@ -1074,7 +1075,7 @@ class ShowTrait(templatePage): 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)) + (this_group, webqtlConfig.PUBLICTHRESH)) for item in self.cursor.fetchall(): dataset_menu.append(dict(tissue=None, datasets=[item])) @@ -1082,7 +1083,7 @@ class ShowTrait(templatePage): 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)) + (this_group, webqtlConfig.PUBLICTHRESH)) for item in self.cursor.fetchall(): dataset_menu.append(dict(tissue=None, datasets=[item])) @@ -1098,7 +1099,7 @@ class ShowTrait(templatePage): 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 + "%")) + (tissue_id, webqtlConfig.PUBLICTHRESH, "%" + this_group + "%")) print("phun8") dataset_sub_menu = [item for item in self.cursor.fetchall() if item] #for item2 in self.cursor.fetchall(): @@ -1257,11 +1258,11 @@ class ShowTrait(templatePage): def dispMappingTools(self, fd, title4Body, this_trait): - _Species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, RISet=fd.RISet) + _Species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, group=fd.group) - RISetgp = fd.RISet - if RISetgp[:3] == 'BXD': - RISetgp = 'BXD' + this_group = fd.group + if this_group[:3] == 'BXD': + this_group = 'BXD' #check boxes - one for regular interval mapping, the other for composite permCheck1= HT.Input(type='checkbox', Class='checkbox', name='permCheck1',checked="on") @@ -1454,7 +1455,7 @@ class ShowTrait(templatePage): # 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) + mappingMethodId = webqtlDatabaseFunction.getMappingMethod(cursor=self.cursor, groupName=this_group) mapping_script = HT.Script(language="Javascript") mapping_script_text = """$(function() { $("#mapping_tabs").tabs(); });""" @@ -1526,7 +1527,7 @@ class ShowTrait(templatePage): sample_names=primary_sample_names, this_trait=this_trait, sample_group_type='primary', - header="%s Only" % (fd.RISet)) + header="%s Only" % (fd.group)) other_sample_names = [] for sample in this_trait.data.keys(): @@ -1547,7 +1548,7 @@ class ShowTrait(templatePage): sample_names=other_sample_names, this_trait=this_trait, sample_group_type='other', - header="Non-%s" % (fd.RISet)) + header="Non-%s" % (fd.group)) self.sample_groups = (primary_samples, other_samples) else: diff --git a/wqflask/wqflask/templates/index_page.html b/wqflask/wqflask/templates/index_page.html index a113bc15..c01898b3 100644 --- a/wqflask/wqflask/templates/index_page.html +++ b/wqflask/wqflask/templates/index_page.html @@ -92,8 +92,8 @@ "btn" value="Advanced Search" onclick= "javascript:window.open('/index3.html', '_self');"> - + +
    diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html index e393ced6..54cdd42b 100644 --- a/wqflask/wqflask/templates/search_result_page.html +++ b/wqflask/wqflask/templates/search_result_page.html @@ -23,7 +23,7 @@ {% if search_terms %}
  • {% for word in search_terms %} - {{word.search_term}} {% if not loop.last %} or {% endif %} + {{word.search_term[0]}} {% if not loop.last %} or {% endif %} {% endfor %}
  • {% endif %} diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 41d1d714..fb93af53 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -65,6 +65,9 @@ def search_page(): the_search = search_results.SearchResultPage(request.args) print("template_vars is:", pf(the_search.__dict__)) #print("trait_list is:", pf(the_search.__dict__['trait_list'][0].__dict__)) + #for trait in the_search.trait_list: + # print(" -", trait.description_display) + return render_template("search_result_page.html", **the_search.__dict__) -- cgit v1.2.3 From 43f69f26507d934a15d8e8d20f0ac3023fdb7691 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Fri, 30 Nov 2012 18:03:52 -0600 Subject: Started switching to using basic sqlalchemy to handle db connection/queries Began fixing bugs related to this fix, still in progress --- wqflask/base/data_set.py | 33 ++++++++------- wqflask/base/webqtlConfigLocal.py | 4 +- wqflask/base/webqtlTrait.py | 69 ++++++++++++++++++-------------- wqflask/cfg/zach_settings.py | 3 ++ wqflask/wqflask/do_search.py | 24 ++++++++--- wqflask/wqflask/search_results.py | 3 +- wqflask/wqflask/show_trait/show_trait.py | 25 ++++++------ wqflask/wqflask/views.py | 14 +++++-- 8 files changed, 106 insertions(+), 69 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 633f7545..015b2623 100755 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -22,6 +22,8 @@ from __future__ import print_function, division +from flask import Flask, g + from htmlgen import HTMLgen2 as HT import webqtlConfig @@ -31,25 +33,28 @@ from pprint import pformat as pf # Used by create_database to instantiate objects DS_NAME_MAP = {} -def create_dataset(db_conn, dataset_name): - cursor = db_conn.cursor() - cursor.execute(""" +def create_dataset(dataset_name): + #cursor = db_conn.cursor() + print("dataset_name:", dataset_name) + + dataset_type = g.db.execute(""" SELECT DBType.Name FROM DBList, DBType WHERE DBList.Name = %s and DBType.Id = DBList.DBTypeId - """, (dataset_name)) - print("dataset_name:", dataset_name) - dataset_type = cursor.fetchone()[0] - print("dataset_type:", pf(dataset_type)) + """, (dataset_name)).fetchone().Name + + #dataset_type = cursor.fetchone()[0] + print("[blubber] dataset_type:", pf(dataset_type)) dataset_ob = DS_NAME_MAP[dataset_type] #dataset_class = getattr(data_set, dataset_ob) - + print("dataset_ob:", dataset_ob) print("DS_NAME_MAP:", pf(DS_NAME_MAP)) dataset_class = globals()[dataset_ob] - return dataset_class(dataset_name, db_conn) + return dataset_class(dataset_name) + class DataSet(object): """ @@ -58,12 +63,12 @@ class DataSet(object): """ - def __init__(self, name, db_conn): + def __init__(self, name): assert name self.name = name - self.db_conn = db_conn - self.cursor = self.db_conn.cursor() + #self.db_conn = db_conn + #self.cursor = self.db_conn.cursor() self.id = None self.type = None self.group = None @@ -271,7 +276,7 @@ class GenotypeDataSet(DataSet): def check_confidentiality(self): return geno_mrna_confidentiality(self) - def get_trait_info(self, trait_list): + def get_trait_info(self, trait_list, species=None): for this_trait in trait_list: if not this_trait.haveinfo: this_trait.retrieveInfo() @@ -355,7 +360,7 @@ class MrnaAssayDataSet(DataSet): ProbeFreeze.InbredSetId = InbredSet.Id AND ProbeFreeze.Id = ProbeSetFreeze.ProbeFreezeId AND ProbeSetFreeze.Name = "%s" - ''' % self.db_conn.escape_string(self.name) + ''' % g.db.escape_string(self.name) def check_confidentiality(self): diff --git a/wqflask/base/webqtlConfigLocal.py b/wqflask/base/webqtlConfigLocal.py index 5aab48ac..84686234 100755 --- a/wqflask/base/webqtlConfigLocal.py +++ b/wqflask/base/webqtlConfigLocal.py @@ -4,12 +4,12 @@ MYSQL_SERVER = 'localhost' DB_NAME = 'db_webqtl_zas1024' -DB_USER = 'webqtlupd' +DB_USER = 'webqtl' DB_PASSWD = 'webqtl' MYSQL_UPDSERVER = 'localhost' DB_UPDNAME = 'db_webqtl_zas1024' -DB_UPDUSER = 'webqtlupd' +DB_UPDUSER = 'webqtl' DB_UPDPASSWD = 'webqtl' GNROOT = '/home/zas1024/gn/' diff --git a/wqflask/base/webqtlTrait.py b/wqflask/base/webqtlTrait.py index cc0e2321..1dceba08 100755 --- a/wqflask/base/webqtlTrait.py +++ b/wqflask/base/webqtlTrait.py @@ -12,6 +12,7 @@ from utility import webqtlUtil from pprint import pformat as pf +from flask import Flask, g class webqtlTrait: """ @@ -20,38 +21,46 @@ class webqtlTrait: """ - def __init__(self, db_conn, **kw): + def __init__(self, **kw): print("in webqtlTrait") - self.db_conn = db_conn - self.cursor = self.db_conn.cursor() - self.dataset = None # database object - self.name = '' # Trait ID, ProbeSet ID, Published ID, etc. - self.cellid = '' - self.identification = 'un-named trait' - self.group = '' - self.haveinfo = 0 - self.sequence = '' # Blat sequence, available for ProbeSet - self.data = {} - print("foo") - print("kw in webqtlTrait are:", pf(kw)) - print("printed\n\n") - for name, value in kw.items(): - if self.__dict__.has_key(name): - setattr(self, name, value) - elif name == 'fullname': - name2 = value.split("::") - if len(name2) == 2: - self.dataset, self.name = name2 - elif len(name2) == 3: - self.dataset, self.name, self.cellid = name2 - else: - raise KeyError, repr(value) + ' parameter format error.' - else: - raise KeyError, repr(name) + ' not a valid parameter for this class.' + #self.db_conn = db_conn + #self.cursor = self.db_conn.cursor() + self.dataset = kw.get('dataset', None) # database object + self.name = kw.get('name', None) # Trait ID, ProbeSet ID, Published ID, etc. + self.cellid = kw.get('cellid', None) + self.identification = kw.get('identification', 'un-named trait') + self.group = kw.get('group', None) + self.haveinfo = kw.get(haveinfo, False) + self.sequence = kw.get(sequence, None) # Blat sequence, available for ProbeSet + self.data = kw.get(data, {}) + + if kw.get('fullname'): + name2 = value.split("::") + if len(name2) == 2: + self.dataset, self.name = name2 + elif len(name2) == 3: + self.dataset, self.name, self.cellid = name2 + + #print("foo") + #print("kw in webqtlTrait are:", pf(kw)) + #print("printed\n\n") + #for name, value in kw.items(): + # if self.__dict__.has_key(name): + # setattr(self, name, value) + # elif name == 'fullname': + # name2 = value.split("::") + # if len(name2) == 2: + # self.dataset, self.name = name2 + # elif len(name2) == 3: + # self.dataset, self.name, self.cellid = name2 + # else: + # raise KeyError, repr(value) + ' parameter format error.' + # else: + # raise KeyError, repr(name) + ' not a valid parameter for this class.' if self.dataset and isinstance(self.dataset, basestring): - assert self.cursor, "Don't have a cursor" - self.dataset = create_dataset(self.db_conn, self.dataset) + #assert self.cursor, "Don't have a cursor" + self.dataset = create_dataset(self.dataset) #if self.dataset == None, not from a database print("self.dataset is:", self.dataset, type(self.dataset)) @@ -432,7 +441,7 @@ class webqtlTrait: self.cursor.execute(query) traitInfo = self.cursor.fetchone() if traitInfo: - self.haveinfo = 1 + self.haveinfo = True #XZ: assign SQL query result to trait attributes. for i, field in enumerate(self.dataset.display_fields): diff --git a/wqflask/cfg/zach_settings.py b/wqflask/cfg/zach_settings.py index ed97f222..8d3bf4ab 100644 --- a/wqflask/cfg/zach_settings.py +++ b/wqflask/cfg/zach_settings.py @@ -1,2 +1,5 @@ LOGFILE = """/tmp/flask_gn_log""" + TRAP_BAD_REQUEST_ERRORS = True + +DB_URI = """mysql://webqtl:webqtl@localhost/db_webqtl_zas1024""" \ No newline at end of file diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py index 17078802..bae3df08 100644 --- a/wqflask/wqflask/do_search.py +++ b/wqflask/wqflask/do_search.py @@ -144,14 +144,22 @@ class PhenotypeSearch(DoSearch): 'Publication.Title', 'Publication.Authors', 'PublishXRef.Id') + + header_fields = ['', + 'Record ID', + 'Description', + 'Authors', + 'Year', + 'Max LRS', + 'Max LRS Location'] def get_where_clause(self): """Generate clause for WHERE portion of query""" #Todo: Zach will figure out exactly what both these lines mean #and comment here - if "'" not in self.search_term: - search_term = "[[:<:]]" + self.search_term + "[[:>:]]" + if "'" not in self.search_term[0]: + search_term = "[[:<:]]" + self.search_term[0] + "[[:>:]]" # This adds a clause to the query that matches the search term # against each field in the search_fields tuple @@ -195,6 +203,10 @@ class GenotypeSearch(DoSearch): FROM GenoXRef, GenoFreeze, Geno """ search_fields = ('Name', 'Chr') + + header_fields = ['', + 'Record ID', + 'Location'] def get_fields_clause(self): """Generate clause for part of the WHERE portion of query""" @@ -203,13 +215,13 @@ class GenotypeSearch(DoSearch): # against each field in search_fields (above) fields_clause = [] - if "'" not in self.search_term: - self.search_term = "[[:<:]]" + self.search_term + "[[:>:]]" + if "'" not in self.search_term[0]: + self.search_term = "[[:<:]]" + self.search_term[0] + "[[:>:]]" for field in self.search_fields: fields_clause.append('''%s REGEXP "%s"''' % ("%s.%s" % self.mescape(self.dataset.type, - field, - self.search_term))) + field), + self.search_term)) print("hello ;where_clause is:", pf(fields_clause)) fields_clause = "(%s)" % ' OR '.join(fields_clause) diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index c7bbdaf2..04b14e8f 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -83,7 +83,8 @@ class SearchResultPage(templatePage): self.dataset_group_ids = map(lambda x: x[2], results) else: print("self.dataset is:", pf(self.dataset)) - self.dataset = create_dataset(self.db_conn, self.dataset) + # Replaces a string with an object + self.dataset = create_dataset(self.dataset) print("self.dataset is now:", pf(self.dataset)) self.search() diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index e8ad0b1d..7060f2ea 100755 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -31,16 +31,15 @@ from pprint import pformat as pf class ShowTrait(templatePage): - def __init__(self, fd): - self.fd = fd + def __init__(self, args): + print("in ShowTrait, args are:", args) + self.group = args.group + self.trait_id = trait_id + self.dataset = dataset - print("red1 fd.group:", fd.group) - templatePage.__init__(self, fd) + #assert self.openMysql(), "No database!" - print("red2 fd.group:", fd.group) - assert self.openMysql(), "No database!" - - print("red3 fd.group:", fd.group) + #print("red3 fd.group:", fd.group) this_trait = self.get_this_trait() print("red4 fd.group:", fd.group) @@ -183,11 +182,13 @@ class ShowTrait(templatePage): #if traitInfos: # database, ProbeSetID, CellID = traitInfos #else: - dataset = self.fd['dataset'] - trait_id = self.fd['trait_id'] - cell_id = self.fd.get('CellID') + #dataset = self.fd['dataset'] + #trait_id = self.fd['trait_id'] + #cell_id = self.fd.get('CellID') - this_trait = webqtlTrait(self.db_conn, dataset=dataset, name=trait_id, cellid=cell_id) + this_trait = webqtlTrait(dataset=dataset, + name=trait_id, + cellid=cell_id) ##identification, etc. self.fd.identification = '%s : %s' % (this_trait.dataset.shortname, trait_id) diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index cdc3379f..17dc42fb 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -7,10 +7,12 @@ import simplejson as json import yaml import flask +import sqlalchemy +#import config from wqflask import app -from flask import render_template, request, make_response, Response +from flask import render_template, request, make_response, Response, Flask, g, config from wqflask import search_results from wqflask.show_trait import show_trait @@ -27,6 +29,10 @@ from pprint import pformat as pf #logging.basicConfig(filename="/tmp/gn_log", level=logging.INFO) #_log = logging.getLogger("correlation") +@app.before_request +def connect_db(): + print("blue app.config:", app.config, pf(vars(app.config))) + g.db = sqlalchemy.create_engine(app.config['DB_URI']) @app.route("/") def index_page(): @@ -86,9 +92,9 @@ def whats_new_page(): @app.route("/show_trait") def show_trait_page(): # Here it's currently too complicated not to use an fd that is a webqtlFormData - fd = webqtlFormData.webqtlFormData(request.args) - print("stp y1:", pf(vars(fd))) - template_vars = show_trait.ShowTrait(fd) + #fd = webqtlFormData.webqtlFormData(request.args) + #print("stp y1:", pf(vars(fd))) + template_vars = show_trait.ShowTrait(request.args) template_vars.js_data = json.dumps(template_vars.js_data, default=json_default_handler, indent=" ", -- cgit v1.2.3 From 21253f4424fbcdf76212a55011e657ebeb87da82 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Fri, 30 Nov 2012 18:27:59 -0600 Subject: Added example of escaping strings now that trasitioning to simple SQLAlchemy --- wqflask/base/data_set.py | 88 ++++++++++++++++++++++++------------------------ 1 file changed, 44 insertions(+), 44 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 015b2623..34e5eaa1 100755 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -28,6 +28,7 @@ from htmlgen import HTMLgen2 as HT import webqtlConfig +from MySQLdb import escape_string as escape from pprint import pformat as pf # Used by create_database to instantiate objects @@ -36,22 +37,22 @@ DS_NAME_MAP = {} def create_dataset(dataset_name): #cursor = db_conn.cursor() print("dataset_name:", dataset_name) - + dataset_type = g.db.execute(""" SELECT DBType.Name FROM DBList, DBType WHERE DBList.Name = %s and DBType.Id = DBList.DBTypeId """, (dataset_name)).fetchone().Name - + #dataset_type = cursor.fetchone()[0] print("[blubber] dataset_type:", pf(dataset_type)) - + dataset_ob = DS_NAME_MAP[dataset_type] #dataset_class = getattr(data_set, dataset_ob) print("dataset_ob:", dataset_ob) print("DS_NAME_MAP:", pf(DS_NAME_MAP)) - + dataset_class = globals()[dataset_ob] return dataset_class(dataset_name) @@ -75,12 +76,12 @@ class DataSet(object): #if self.cursor and self.id == 0: self.setup() - + self.check_confidentiality() - + self.retrieve_name() self.get_group() - + # Delete this eventually @property @@ -101,9 +102,9 @@ class DataSet(object): """ If the data set name parameter is not found in the 'Name' field of the data set table, check if it is actually the FullName or ShortName instead. - + This is not meant to retrieve the data set info if no name at all is passed. - + """ query_args = tuple(self.db_conn.escape_string(x) for x in ( @@ -113,7 +114,7 @@ class DataSet(object): self.name, self.name)) print("query_args are:", query_args) - + query = ''' SELECT Id, Name, FullName, ShortName @@ -123,7 +124,7 @@ class DataSet(object): public > %s AND (Name = "%s" OR FullName = "%s" OR ShortName = "%s") ''' % (query_args) - + self.cursor.execute(query) self.id, self.name, self.fullname, self.shortname = self.cursor.fetchone() @@ -147,7 +148,7 @@ class PhenotypeDataSet(DataSet): 'Publication.Title', 'Publication.Authors', 'PublishXRef.Id'] - + # Figure out what display_fields is self.display_fields = ['name', 'pubmed_id', @@ -172,10 +173,10 @@ class PhenotypeDataSet(DataSet): 'Authors', 'Year', 'Max LRS', - 'Max LRS Location'] + 'Max LRS Location'] self.type = 'Publish' - + self.query = ''' SELECT InbredSet.Name, InbredSet.Id @@ -185,11 +186,11 @@ class PhenotypeDataSet(DataSet): PublishFreeze.InbredSetId = InbredSet.Id AND PublishFreeze.Name = "%s" ''' % self.db_conn.escape_string(self.name) - + def check_confidentiality(self): # (Urgently?) Need to write this pass - + def get_trait_info(self, trait_list, species = ''): for this_trait in trait_list: if not this_trait.haveinfo: @@ -238,31 +239,31 @@ class PhenotypeDataSet(DataSet): this_trait.LRS_score_repr = LRS_score_repr = '%3.1f' % this_trait.lrs this_trait.LRS_score_value = LRS_score_value = this_trait.lrs - this_trait.LRS_location_repr = LRS_location_repr = 'Chr %s: %.4f Mb' % (LRS_Chr, float(LRS_Mb) ) - + this_trait.LRS_location_repr = LRS_location_repr = 'Chr %s: %.4f Mb' % (LRS_Chr, float(LRS_Mb) ) + class GenotypeDataSet(DataSet): DS_NAME_MAP['Geno'] = 'GenotypeDataSet' - + def setup(self): # Fields in the database table self.search_fields = ['Name', 'Chr'] - + # Find out what display_fields is self.display_fields = ['name', 'chr', 'mb', 'source2', 'sequence'] - + # Fields displayed in the search results table header self.header_fields = ['', 'ID', - 'Location'] - + 'Location'] + # Todo: Obsolete or rename this field self.type = 'Geno' - + self.query = ''' SELECT InbredSet.Name, InbredSet.Id @@ -272,10 +273,10 @@ class GenotypeDataSet(DataSet): GenoFreeze.InbredSetId = InbredSet.Id AND GenoFreeze.Name = "%s" ''' % self.db_conn.escape_string(self.name) - + def check_confidentiality(self): return geno_mrna_confidentiality(self) - + def get_trait_info(self, trait_list, species=None): for this_trait in trait_list: if not this_trait.haveinfo: @@ -295,16 +296,16 @@ class GenotypeDataSet(DataSet): trait_location_value = ord(str(this_trait.chr).upper()[0])*1000 + this_trait.mb this_trait.location_repr = 'Chr%s: %.4f' % (this_trait.chr, float(this_trait.mb) ) - this_trait.location_value = trait_location_value - - + this_trait.location_value = trait_location_value + + class MrnaAssayDataSet(DataSet): ''' An mRNA Assay is a quantitative assessment (assay) associated with an mRNA trait - + This used to be called ProbeSet, but that term only refers specifically to the Affymetrix platform and is far too specific. - + ''' DS_NAME_MAP['ProbeSet'] = 'MrnaAssayDataSet' @@ -346,7 +347,7 @@ class MrnaAssayDataSet(DataSet): 'Location', 'Mean Expr', 'Max LRS', - 'Max LRS Location'] + 'Max LRS Location'] # Todo: Obsolete or rename this field self.type = 'ProbeSet' @@ -360,12 +361,12 @@ class MrnaAssayDataSet(DataSet): ProbeFreeze.InbredSetId = InbredSet.Id AND ProbeFreeze.Id = ProbeSetFreeze.ProbeFreezeId AND ProbeSetFreeze.Name = "%s" - ''' % g.db.escape_string(self.name) + ''' % escape(self.name) def check_confidentiality(self): return geno_mrna_confidentiality(self) - + def get_trait_info(self, trait_list=None, species=''): # Note: setting trait_list to [] is probably not a great idea. @@ -428,7 +429,7 @@ class MrnaAssayDataSet(DataSet): self.db_conn.escape_string(this_trait.name))) print("query is:", pf(query)) - + self.cursor.execute(query) result = self.cursor.fetchone() @@ -475,30 +476,30 @@ class MrnaAssayDataSet(DataSet): this_trait.LRS_score_repr = LRS_score_repr = '%3.1f' % this_trait.lrs this_trait.LRS_score_value = LRS_score_value = this_trait.lrs - this_trait.LRS_location_repr = LRS_location_repr = 'Chr %s: %.4f Mb' % (LRS_Chr, float(LRS_Mb) ) + this_trait.LRS_location_repr = LRS_location_repr = 'Chr %s: %.4f Mb' % (LRS_Chr, float(LRS_Mb) ) class TempDataSet(DataSet): '''Temporary user-generated data set''' - + def setup(self): self.search_fields = ['name', 'description'] - + self.display_fields = ['name', 'description'] - + self.header_fields = ['Name', 'Description'] - + self.type = 'Temp' - + # Need to double check later how these are used self.id = 1 self.fullname = 'Temporary Storage' self.shortname = 'Temp' - - + + def geno_mrna_confidentiality(ob): dataset_table = ob.type + "Freeze" print("dataset_table [%s]: %s" % (type(dataset_table), dataset_table)) @@ -517,4 +518,3 @@ def geno_mrna_confidentiality(ob): if confidential: # Allow confidential data later NoConfindetialDataForYouTodaySorry - \ No newline at end of file -- cgit v1.2.3 From 0e17939e123ec80c4da3f665004b08347aa9480b Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Tue, 4 Dec 2012 16:19:46 -0600 Subject: Began changing references to cursor/db_conn to use sqlalchemy Wrote function for phenotype author searches --- wqflask/base/data_set.py | 34 +++++++------ wqflask/base/webqtlTrait.py | 15 +++--- wqflask/wqflask/do_search.py | 101 ++++++++++++++++++++++++++++---------- wqflask/wqflask/search_results.py | 2 +- 4 files changed, 103 insertions(+), 49 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 34e5eaa1..cd9e810e 100755 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -90,9 +90,7 @@ class DataSet(object): def get_group(self): - assert self.cursor - self.cursor.execute(self.query) - self.group, self.group_id = self.cursor.fetchone() + self.group, self.group_id = g.db.execute(self.query).fetchone() if self.group == 'BXD300': self.group = "BXD" #return group @@ -107,7 +105,7 @@ class DataSet(object): """ - query_args = tuple(self.db_conn.escape_string(x) for x in ( + query_args = tuple(escape(x) for x in ( (self.type + "Freeze"), str(webqtlConfig.PUBLICTHRESH), self.name, @@ -115,18 +113,22 @@ class DataSet(object): self.name)) print("query_args are:", query_args) - query = ''' - SELECT - Id, Name, FullName, ShortName - FROM - %s - WHERE - public > %s AND - (Name = "%s" OR FullName = "%s" OR ShortName = "%s") - ''' % (query_args) + print(""" + SELECT Id, Name, FullName, ShortName + FROM %s + WHERE public > %s AND + (Name = '%s' OR FullName = '%s' OR ShortName = '%s') + """ % (query_args)) + + self.id, self.name, self.fullname, self.shortname = g.db.execute(""" + SELECT Id, Name, FullName, ShortName + FROM %s + WHERE public > %s AND + (Name = '%s' OR FullName = '%s' OR ShortName = '%s') + """ % (query_args)).fetchone() - self.cursor.execute(query) - self.id, self.name, self.fullname, self.shortname = self.cursor.fetchone() + #self.cursor.execute(query) + #self.id, self.name, self.fullname, self.shortname = self.cursor.fetchone() #def genHTML(self, Class='c0dd'): @@ -185,7 +187,7 @@ class PhenotypeDataSet(DataSet): WHERE PublishFreeze.InbredSetId = InbredSet.Id AND PublishFreeze.Name = "%s" - ''' % self.db_conn.escape_string(self.name) + ''' % escape(self.name) def check_confidentiality(self): # (Urgently?) Need to write this diff --git a/wqflask/base/webqtlTrait.py b/wqflask/base/webqtlTrait.py index 1dceba08..9763e441 100755 --- a/wqflask/base/webqtlTrait.py +++ b/wqflask/base/webqtlTrait.py @@ -30,9 +30,9 @@ class webqtlTrait: self.cellid = kw.get('cellid', None) self.identification = kw.get('identification', 'un-named trait') self.group = kw.get('group', None) - self.haveinfo = kw.get(haveinfo, False) - self.sequence = kw.get(sequence, None) # Blat sequence, available for ProbeSet - self.data = kw.get(data, {}) + self.haveinfo = kw.get('haveinfo', False) + self.sequence = kw.get('sequence', None) # Blat sequence, available for ProbeSet + self.data = kw.get('data', {}) if kw.get('fullname'): name2 = value.split("::") @@ -381,7 +381,7 @@ class webqtlTrait: # return self.__dict__.items() def retrieveInfo(self, QTL = None): - assert self.dataset and self.cursor + assert self.dataset if self.dataset.type == 'Publish': #self.dataset.DisField = ['Name','PubMed_ID','Phenotype','Abbreviation','Authors','Title',\ # 'Abstract', 'Journal','Volume','Pages','Month','Year','Sequence',\ @@ -434,10 +434,11 @@ class webqtlTrait: Geno.Name = '%s' """ % (display_fields_string, self.dataset.name, self.name) else: #Temp type - query = 'SELECT %s FROM %s WHERE Name = "%s"' % \ - (string.join(self.dataset.display_fields,','), self.dataset.type, self.name) - + traitInfo = g.db.execute("""SELECT %s FROM %s WHERE Name = '%s' + """, (string.join(self.dataset.display_fields,','), + self.dataset.type, self.name)).fetchone() + self.cursor.execute(query) traitInfo = self.cursor.fetchone() if traitInfo: diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py index bae3df08..802cbea5 100644 --- a/wqflask/wqflask/do_search.py +++ b/wqflask/wqflask/do_search.py @@ -3,6 +3,9 @@ from __future__ import print_function, division +from flask import Flask, g + +from MySQLdb import escape_string as escape from pprint import pformat as pf import sys @@ -34,13 +37,13 @@ class DoSearch(object): """Executes query and returns results""" query = self.normalize_spaces(query) print("in do_search query is:", pf(query)) - self.cursor.execute(query) + g.db.execute(query) results = self.cursor.fetchall() return results def escape(self, stringy): """Shorter name than self.db_conn.escape_string""" - return self.db_conn.escape_string(str(stringy)) + return escape(str(stringy)) def mescape(self, *items): """Multiple escape""" @@ -153,7 +156,7 @@ class PhenotypeSearch(DoSearch): 'Max LRS', 'Max LRS Location'] - def get_where_clause(self): + def get_fields_clause(self): """Generate clause for WHERE portion of query""" #Todo: Zach will figure out exactly what both these lines mean @@ -163,15 +166,17 @@ class PhenotypeSearch(DoSearch): # This adds a clause to the query that matches the search term # against each field in the search_fields tuple - where_clause = [] + fields_clause = [] for field in self.search_fields: - where_clause.append('''%s REGEXP "%s"''' % (field, search_term)) - where_clause = "(%s)" % ' OR '.join(where_clause) + fields_clause.append('''%s REGEXP "%s"''' % (field, search_term)) + fields_clause = "(%s)" % ' OR '.join(fields_clause) - return where_clause + return fields_clause - def run(self): - """Generates and runs a simple search of a phenotype dataset""" + def compile_final_query(self, from_clause = '', where_clause = ''): + """Generates the final query string""" + + from_clause = self.normalize_spaces(from_clause) #Get group information for dataset self.dataset.get_group() @@ -182,12 +187,42 @@ class PhenotypeSearch(DoSearch): PublishXRef.PhenotypeId = Phenotype.Id and PublishXRef.PublicationId = Publication.Id and PublishFreeze.Id = %s""" % ( - self.get_where_clause(), + self.get_fields_clause(), self.escape(self.dataset.group_id), self.escape(self.dataset.id))) - return self.execute(query) + print("query is:", pf(query)) + return query + + def run(self): + """Generates and runs a simple search of a phenotype dataset""" + + self.query = self.compile_final_query(where_clause = self.get_fields_clause()) + +# self.query = """SELECT PublishXRef.Id, +#PublishFreeze.createtime as thistable, +#Publication.PubMed_ID as Publication_PubMed_ID, +#Phenotype.Post_publication_description as Phenotype_Name FROM Phenotype, +#PublishFreeze, Publication, PublishXRef WHERE (Phenotype.Post_publication_description +#REGEXP "[[:<:]]brain[[:>:]]" OR Phenotype.Pre_publication_description REGEXP "[[:<:]]brain[[:>:]]" +#OR Phenotype.Pre_publication_abbreviation REGEXP "[[:<:]]brain[[:>:]]" +#OR Phenotype.Post_publication_abbreviation REGEXP "[[:<:]]brain[[:>:]]" +#OR Phenotype.Lab_code REGEXP "[[:<:]]brain[[:>:]]" +#OR Publication.PubMed_ID REGEXP "[[:<:]]brain[[:>:]]" +#OR Publication.Abstract REGEXP "[[:<:]]brain[[:>:]]" +#OR Publication.Title REGEXP "[[:<:]]brain[[:>:]]" +#OR Publication.Authors REGEXP "[[:<:]]brain[[:>:]]" +#OR PublishXRef.Id REGEXP "[[:<:]]brain[[:>:]]") +#and PublishXRef.InbredSetId = 1 +#and PublishXRef.PhenotypeId = Phenotype.Id +#and PublishXRef.PublicationId = Publication.Id +#and PublishFreeze.Id = 1;""" + + + results = g.db.execute(self.query, no_parameters=True).fetchall() + print("in [df] run results are:", results) + return results class GenotypeSearch(DoSearch): """A search within a genotype dataset""" @@ -606,6 +641,22 @@ class PvalueSearch(ProbeSetSearch): return self.execute(self.query) +class AuthorSearch(PhenotypeSearch): + """Searches for phenotype traits with specified author(s)""" + + DoSearch.search_types["NAME"] = "AuthorSearch" + + def run(self): + + self.search_term = [float(value) for value in self.search_term] + + self.where_clause = """ Publication.Authors LIKE %s and + """ % (self.escape(self.search_term[0])) + + self.query = self.compile_final_query(where_clause = self.where_clause) + + return self.execute(self.query) + if __name__ == "__main__": @@ -630,20 +681,20 @@ if __name__ == "__main__": dataset_name = "HC_M2_0606_P" dataset = create_dataset(db_conn, dataset_name) - cursor.execute(""" - SELECT ProbeSet.Name as TNAME, 0 as thistable, - ProbeSetXRef.Mean as TMEAN, ProbeSetXRef.LRS as TLRS, - ProbeSetXRef.PVALUE as TPVALUE, ProbeSet.Chr_num as TCHR_NUM, - ProbeSet.Mb as TMB, ProbeSet.Symbol as TSYMBOL, - ProbeSet.name_num as TNAME_NUM - FROM ProbeSetXRef, ProbeSet, Geno - WHERE ProbeSetXRef.LRS > 99.0 and - ABS(ProbeSet.Mb-Geno.Mb) < 5 and - ProbeSetXRef.Locus = Geno.name and - Geno.SpeciesId = 1 and - ProbeSet.Chr = Geno.Chr and - ProbeSet.Id = ProbeSetXRef.ProbeSetId and - ProbeSetXRef.ProbeSetFreezeId = 112""") + #cursor.execute(""" + # SELECT ProbeSet.Name as TNAME, 0 as thistable, + # ProbeSetXRef.Mean as TMEAN, ProbeSetXRef.LRS as TLRS, + # ProbeSetXRef.PVALUE as TPVALUE, ProbeSet.Chr_num as TCHR_NUM, + # ProbeSet.Mb as TMB, ProbeSet.Symbol as TSYMBOL, + # ProbeSet.name_num as TNAME_NUM + # FROM ProbeSetXRef, ProbeSet, Geno + # WHERE ProbeSetXRef.LRS > 99.0 and + # ABS(ProbeSet.Mb-Geno.Mb) < 5 and + # ProbeSetXRef.Locus = Geno.name and + # Geno.SpeciesId = 1 and + # ProbeSet.Chr = Geno.Chr and + # ProbeSet.Id = ProbeSetXRef.ProbeSetId and + # ProbeSetXRef.ProbeSetFreezeId = 112""") #print(pf(cursor.fetchall())) #results = ProbeSetSearch("shh", None, dataset, cursor, db_conn).run() diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index 04b14e8f..52f628f6 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -113,7 +113,7 @@ class SearchResultPage(templatePage): print("foo locals are:", locals()) trait_id = result[0] - this_trait = webqtlTrait(self.db_conn, dataset=self.dataset, name=trait_id) + this_trait = webqtlTrait(dataset=self.dataset, name=trait_id) this_trait.retrieveInfo(QTL=True) self.trait_list.append(this_trait) -- cgit v1.2.3 From 01785471d63de156fa9787a0fb38c9df09824183 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Tue, 4 Dec 2012 18:08:09 -0600 Subject: Changed parser to allow quotes (i.e. name="rw williams") Renamed webqtlTrait to GeneralTrait and began rewriting parts Changed database code in many places to use simple sqlalchemy --- wqflask/base/data_set.py | 18 ++- wqflask/base/webqtlTrait.py | 166 +++++++++++++-------------- wqflask/dbFunction/webqtlDatabaseFunction.py | 26 ++--- wqflask/wqflask/do_search.py | 78 ++++++------- wqflask/wqflask/parser.py | 4 +- wqflask/wqflask/search_results.py | 7 +- 6 files changed, 138 insertions(+), 161 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index cd9e810e..7833f5c1 100755 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -68,13 +68,10 @@ class DataSet(object): assert name self.name = name - #self.db_conn = db_conn - #self.cursor = self.db_conn.cursor() self.id = None self.type = None self.group = None - #if self.cursor and self.id == 0: self.setup() self.check_confidentiality() @@ -200,6 +197,7 @@ class PhenotypeDataSet(DataSet): description = this_trait.post_publication_description if this_trait.confidential: + continue # for now if not webqtlUtil.hasAccessToConfidentialPhenotypeTrait(privilege=self.privilege, userName=self.userName, authorized_users=this_trait.authorized_users): description = this_trait.pre_publication_description this_trait.description_display = description @@ -217,13 +215,13 @@ class PhenotypeDataSet(DataSet): this_trait.LRS_location_value = 1000000 if this_trait.lrs: - self.cursor.execute(""" + result = g.db.execute(""" select Geno.Chr, Geno.Mb from Geno, Species - where Species.Name = '%s' and - Geno.Name = '%s' and + where Species.Name = %s and + Geno.Name = %s and Geno.SpeciesId = Species.Id - """ % (species, this_trait.locus)) - result = self.cursor.fetchone() + """, (species, this_trait.locus)).fetchone() + #result = self.cursor.fetchone() if result: if result[0] and result[1]: @@ -509,13 +507,13 @@ def geno_mrna_confidentiality(ob): query = '''SELECT Id, Name, FullName, confidentiality, AuthorisedUsers FROM %s WHERE Name = %%s''' % (dataset_table) - ob.cursor.execute(query, ob.name) + result = g.db.execute(query, ob.name) (dataset_id, name, full_name, confidential, - authorized_users) = ob.cursor.fetchall()[0] + authorized_users) = result.fetchall()[0] if confidential: # Allow confidential data later diff --git a/wqflask/base/webqtlTrait.py b/wqflask/base/webqtlTrait.py index 9763e441..dec5fa00 100755 --- a/wqflask/base/webqtlTrait.py +++ b/wqflask/base/webqtlTrait.py @@ -14,7 +14,7 @@ from pprint import pformat as pf from flask import Flask, g -class webqtlTrait: +class GeneralTrait: """ Trait class defines a trait in webqtl, can be either Microarray, Published phenotype, genotype, or user input trait @@ -22,9 +22,7 @@ class webqtlTrait: """ def __init__(self, **kw): - print("in webqtlTrait") - #self.db_conn = db_conn - #self.cursor = self.db_conn.cursor() + print("in GeneralTrait") self.dataset = kw.get('dataset', None) # database object self.name = kw.get('name', None) # Trait ID, ProbeSet ID, Published ID, etc. self.cellid = kw.get('cellid', None) @@ -41,45 +39,31 @@ class webqtlTrait: elif len(name2) == 3: self.dataset, self.name, self.cellid = name2 - #print("foo") - #print("kw in webqtlTrait are:", pf(kw)) - #print("printed\n\n") - #for name, value in kw.items(): - # if self.__dict__.has_key(name): - # setattr(self, name, value) - # elif name == 'fullname': - # name2 = value.split("::") - # if len(name2) == 2: - # self.dataset, self.name = name2 - # elif len(name2) == 3: - # self.dataset, self.name, self.cellid = name2 - # else: - # raise KeyError, repr(value) + ' parameter format error.' - # else: - # raise KeyError, repr(name) + ' not a valid parameter for this class.' - - if self.dataset and isinstance(self.dataset, basestring): - #assert self.cursor, "Don't have a cursor" - self.dataset = create_dataset(self.dataset) + #if self.dataset and isinstance(self.dataset, basestring): + self.dataset = create_dataset(self.dataset) + + - #if self.dataset == None, not from a database print("self.dataset is:", self.dataset, type(self.dataset)) - if self.dataset: - if self.dataset.type == "Temp": - self.cursor.execute(''' - SELECT - InbredSet.Name - FROM - InbredSet, Temp - WHERE - Temp.InbredSetId = InbredSet.Id AND - Temp.Name = "%s" - ''', self.name) - self.group = self.cursor.fetchone()[0] - else: - self.group = self.dataset.get_group() + #if self.dataset: + + self.dataset.get_group() + + if self.dataset.type == "Temp": + self.cursor.execute(''' + SELECT + InbredSet.Name + FROM + InbredSet, Temp + WHERE + Temp.InbredSetId = InbredSet.Id AND + Temp.Name = "%s" + ''', self.name) + self.group = self.cursor.fetchone()[0] + else: + self.group = self.dataset.get_group() - print("trinity, self.group is:", self.group) + print("trinity, self.group is:", self.group) # # In ProbeSet, there are maybe several annotations match one sequence @@ -93,24 +77,24 @@ class webqtlTrait: # The variable self.sequence should be changed to self.BlatSeq # It also should be changed in other places where it are used. - if self.dataset: - if self.dataset.type == 'ProbeSet': - print("Doing ProbeSet Query") - query = ''' - SELECT - ProbeSet.BlatSeq - FROM - ProbeSet, ProbeSetFreeze, ProbeSetXRef - WHERE - ProbeSet.Id=ProbeSetXRef.ProbeSetId and - ProbeSetFreeze.Id = ProbeSetXRef.ProbeSetFreezeId and - ProbeSet.Name = %s and - ProbeSetFreeze.Name = %s - ''', (self.name, self.dataset.name) - print("query is:", query) - self.cursor.execute(*query) - self.sequence = self.cursor.fetchone()[0] - print("self.sequence is:", self.sequence) + #if self.dataset: + if self.dataset.type == 'ProbeSet': + print("Doing ProbeSet Query") + query = ''' + SELECT + ProbeSet.BlatSeq + FROM + ProbeSet, ProbeSetFreeze, ProbeSetXRef + WHERE + ProbeSet.Id=ProbeSetXRef.ProbeSetId and + ProbeSetFreeze.Id = ProbeSetXRef.ProbeSetFreezeId and + ProbeSet.Name = %s and + ProbeSetFreeze.Name = %s + ''', (self.name, self.dataset.name) + print("query is:", query) + self.sequence = g.db.execute(*query).fetchone()[0] + #self.sequence = self.cursor.fetchone()[0] + print("self.sequence is:", self.sequence) def getName(self): @@ -380,13 +364,10 @@ class webqtlTrait: #def items(self): # return self.__dict__.items() - def retrieveInfo(self, QTL = None): - assert self.dataset + def retrieve_info(self, QTL=False): + assert self.dataset, "Dataset doesn't exist" if self.dataset.type == 'Publish': - #self.dataset.DisField = ['Name','PubMed_ID','Phenotype','Abbreviation','Authors','Title',\ - # 'Abstract', 'Journal','Volume','Pages','Month','Year','Sequence',\ - # 'Units', 'comments'] - query = ''' + traitInfo = g.db.execute(""" SELECT PublishXRef.Id, Publication.PubMed_ID, Phenotype.Pre_publication_description, Phenotype.Post_publication_description, Phenotype.Original_description, @@ -404,43 +385,50 @@ class webqtlTrait: Publication.Id = PublishXRef.PublicationId AND PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND PublishFreeze.Id =%s - ''' % (self.name, self.dataset.id) + """, (self.name, self.dataset.id)).fetchone() #XZ, 05/08/2009: Xiaodong add this block to use ProbeSet.Id to find the probeset instead of just using ProbeSet.Name #XZ, 05/08/2009: to avoid the problem of same probeset name from different platforms. elif self.dataset.type == 'ProbeSet': display_fields_string = ',ProbeSet.'.join(self.dataset.display_fields) display_fields_string = 'ProbeSet.' + display_fields_string - query = """ + traitInfo = g.db.execute(""" SELECT %s FROM ProbeSet, ProbeSetFreeze, ProbeSetXRef WHERE ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id AND ProbeSetXRef.ProbeSetId = ProbeSet.Id AND - ProbeSetFreeze.Name = '%s' AND - ProbeSet.Name = '%s' - """ % (display_fields_string, self.dataset.name, self.name) + ProbeSetFreeze.Name = %s AND + ProbeSet.Name = %s + """, (display_fields_string, self.dataset.name, self.name)).fetchone() #XZ, 05/08/2009: We also should use Geno.Id to find marker instead of just using Geno.Name # to avoid the problem of same marker name from different species. elif self.dataset.type == 'Geno': display_fields_string = string.join(self.dataset.display_fields,',Geno.') display_fields_string = 'Geno.' + display_fields_string - query = """ + traitInfo = g.db.execute(""" SELECT %s FROM Geno, GenoFreeze, GenoXRef WHERE GenoXRef.GenoFreezeId = GenoFreeze.Id AND GenoXRef.GenoId = Geno.Id AND - GenoFreeze.Name = '%s' AND - Geno.Name = '%s' - """ % (display_fields_string, self.dataset.name, self.name) + GenoFreeze.Name = %s AND + Geno.Name = %s + """, (display_fields_string, self.dataset.name, self.name)).fetchone() else: #Temp type - traitInfo = g.db.execute("""SELECT %s FROM %s WHERE Name = '%s' + traitInfo = g.db.execute("""SELECT %s FROM %s WHERE Name = %s """, (string.join(self.dataset.display_fields,','), self.dataset.type, self.name)).fetchone() + + query = """SELECT %s FROM %s WHERE Name = %s + """ % (string.join(self.dataset.display_fields,','), + self.dataset.type, self.name) + + print("query is:", pf(query)) + print("traitInfo is: ", pf(traitInfo)) - - self.cursor.execute(query) - traitInfo = self.cursor.fetchone() + + #self.cursor.execute(query) + #traitInfo = self.cursor.fetchone() if traitInfo: self.haveinfo = True @@ -465,7 +453,7 @@ class webqtlTrait: geneidIsNumber = 0 if geneidIsNumber: - query = """ + result = g.db.execute(""" SELECT HomologeneId FROM @@ -475,9 +463,9 @@ class webqtlTrait: InbredSet.Name = '%s' AND InbredSet.SpeciesId = Species.Id AND Species.TaxonomyId = Homologene.TaxonomyId - """ % (self.geneid, self.group) - self.cursor.execute(query) - result = self.cursor.fetchone() + """, (self.geneid, self.group)).fetchone() + #self.cursor.execute(query) + #result = self.cursor.fetchone() else: result = None @@ -486,7 +474,7 @@ class webqtlTrait: if QTL: if self.dataset.type == 'ProbeSet' and not self.cellid: - query = ''' + traitQTL = g.db.execute(""" SELECT ProbeSetXRef.Locus, ProbeSetXRef.LRS, ProbeSetXRef.pValue, ProbeSetXRef.mean FROM @@ -495,15 +483,15 @@ class webqtlTrait: ProbeSetXRef.ProbeSetId = ProbeSet.Id AND ProbeSet.Name = "%s" AND ProbeSetXRef.ProbeSetFreezeId =%s - ''' % (self.name, self.dataset.id) - self.cursor.execute(query) - traitQTL = self.cursor.fetchone() + """, (self.name, self.dataset.id)).fetchone() + #self.cursor.execute(query) + #traitQTL = self.cursor.fetchone() if traitQTL: self.locus, self.lrs, self.pvalue, self.mean = traitQTL else: self.locus = self.lrs = self.pvalue = self.mean = "" if self.dataset.type == 'Publish': - query = ''' + traitQTL = g.db.execute(""" SELECT PublishXRef.Locus, PublishXRef.LRS FROM @@ -512,9 +500,9 @@ class webqtlTrait: PublishXRef.Id = %s AND PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND PublishFreeze.Id =%s - ''' % (self.name, self.dataset.id) - self.cursor.execute(query) - traitQTL = self.cursor.fetchone() + """, (self.name, self.dataset.id)).fetchone() + #self.cursor.execute(query) + #traitQTL = self.cursor.fetchone() if traitQTL: self.locus, self.lrs = traitQTL else: diff --git a/wqflask/dbFunction/webqtlDatabaseFunction.py b/wqflask/dbFunction/webqtlDatabaseFunction.py index 1e028ecc..299114b4 100755 --- a/wqflask/dbFunction/webqtlDatabaseFunction.py +++ b/wqflask/dbFunction/webqtlDatabaseFunction.py @@ -21,6 +21,8 @@ # This module is used by GeneNetwork project (www.genenetwork.org) +from flask import Flask, g + import MySQLdb import string from base import webqtlConfig @@ -80,25 +82,15 @@ def getAllSpecies(cursor=None): #function: retrieve specie's name info based on RISet ########################################################################### -def retrieveSpecies(cursor=None, group=None): - try: - cursor.execute("select Species.Name from Species, InbredSet where InbredSet.Name = '%s' and InbredSet.SpeciesId = Species.Id" % group) - return cursor.fetchone()[0] - except: - return None +def retrieve_species(group): + return g.db.execute("""select Species.Name + from Species, InbredSet + where InbredSet.Name = %s and + InbredSet.SpeciesId = Species.Id""", (group)).fetchone()[0] -########################################################################### -#input: cursor, RISet (string) -#output: specie's Id (string), value will be None or else -#function: retrieve specie's Id info based on RISet -########################################################################### +def retrieve_species_id(group): + return g.db.execute("select SpeciesId from InbredSet where Name = %s", (group)).fetchone()[0] -def retrieveSpeciesId(cursor=None, RISet=None): - try: - cursor.execute("select SpeciesId from InbredSet where Name = '%s'" % RISet) - return cursor.fetchone()[0] - except: - return None ########################################################################### # input: cursor diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py index 802cbea5..2094ed14 100644 --- a/wqflask/wqflask/do_search.py +++ b/wqflask/wqflask/do_search.py @@ -20,34 +20,32 @@ class DoSearch(object): # Used to translate search phrases into classes search_types = dict() - def __init__(self, search_term, search_operator, dataset, cursor, db_conn): + def __init__(self, search_term, search_operator, dataset): self.search_term = search_term # Make sure search_operator is something we expect assert search_operator in (None, "=", "<", ">", "<=", ">="), "Bad search operator" self.search_operator = search_operator self.dataset = dataset - self.db_conn = db_conn - self.cursor = cursor #Get group information for dataset and the species id self.dataset.get_group() - self.species_id = webqtlDatabaseFunction.retrieveSpeciesId(self.cursor, self.dataset.group) + self.species_id = webqtlDatabaseFunction.retrieve_species_id(self.dataset.group) def execute(self, query): """Executes query and returns results""" query = self.normalize_spaces(query) print("in do_search query is:", pf(query)) - g.db.execute(query) - results = self.cursor.fetchall() + results = g.db.execute(query).fetchall() + #results = self.cursor.fetchall() return results - def escape(self, stringy): - """Shorter name than self.db_conn.escape_string""" - return escape(str(stringy)) + #def escape(self, stringy): + # """Shorter name than self.db_conn.escape_string""" + # return escape(str(stringy)) def mescape(self, *items): """Multiple escape""" - escaped = [self.escape(item) for item in items] + escaped = [escape(item) for item in items] print("escaped is:", escaped) return tuple(escaped) @@ -96,9 +94,9 @@ class ProbeSetSearch(DoSearch): WHERE %s and ProbeSet.Id = ProbeSetXRef.ProbeSetId and ProbeSetXRef.ProbeSetFreezeId = %s - """ % (self.escape(from_clause), + """ % (escape(from_clause), where_clause, - self.escape(self.dataset.id))) + escape(self.dataset.id))) print("query is:", pf(query)) @@ -118,8 +116,8 @@ class ProbeSetSearch(DoSearch): AGAINST ('%s' IN BOOLEAN MODE)) and ProbeSet.Id = ProbeSetXRef.ProbeSetId and ProbeSetXRef.ProbeSetFreezeId = %s - """ % (self.escape(self.search_term[0]), - self.escape(self.dataset.id)) + """ % (escape(self.search_term[0]), + escape(str(self.dataset.id))) print("final query is:", pf(query)) @@ -182,14 +180,16 @@ class PhenotypeSearch(DoSearch): self.dataset.get_group() query = (self.base_query + - """WHERE %s and + """%s + WHERE %s PublishXRef.InbredSetId = %s and PublishXRef.PhenotypeId = Phenotype.Id and PublishXRef.PublicationId = Publication.Id and PublishFreeze.Id = %s""" % ( - self.get_fields_clause(), - self.escape(self.dataset.group_id), - self.escape(self.dataset.id))) + from_clause, + where_clause, + escape(str(self.dataset.group_id)), + escape(str(self.dataset.id)))) print("query is:", pf(query)) @@ -272,7 +272,7 @@ class GenotypeSearch(DoSearch): Geno.Id = GenoXRef.GenoId and GenoXRef.GenoFreezeId = GenoFreeze.Id and GenoFreeze.Id = %s"""% (where_clause, - self.escape(self.dataset.id))) + escape(self.dataset.id))) print("query is:", pf(query)) @@ -332,7 +332,7 @@ class GoSearch(ProbeSetSearch): statements = ("""%s.symbol=GOgene_product.symbol and GOassociation.gene_product_id=GOgene_product.id and GOterm.id=GOassociation.term_id""" % ( - self.db_conn.escape_string(self.dataset.type))) + escape(self.dataset.type))) where_clause = " %s = '%s' and %s " % (field, go_id, statements) @@ -377,7 +377,7 @@ class LrsSearch(ProbeSetSearch): if len(self.search_term) > 2: self.chr_num = self.search_term[2] - self.sub_clause += """ Geno.Chr = %s and """ % (self.escape(self.chr_num)) + self.sub_clause += """ Geno.Chr = %s and """ % (escape(self.chr_num)) if len(self.search_term) == 5: self.mb_low, self.mb_high = self.search_term[3:] self.sub_clause += """ Geno.Mb > %s and @@ -429,17 +429,17 @@ class CisTransLrsSearch(LrsSearch): self.sub_clause = """ %sXRef.LRS > %s and %sXRef.LRS < %s and """ % ( - self.escape(self.dataset.type), - self.escape(min(self.lrs_min, self.lrs_max)), - self.escape(self.dataset.type), - self.escape(max(self.lrs_min, self.lrs_max)) + escape(self.dataset.type), + escape(min(self.lrs_min, self.lrs_max)), + escape(self.dataset.type), + escape(max(self.lrs_min, self.lrs_max)) ) else: # Deal with >, <, >=, and <= self.sub_clause = """ %sXRef.LRS %s %s and """ % ( - self.escape(self.dataset.type), - self.escape(self.search_operator), - self.escape(self.search_term[0]) + escape(self.dataset.type), + escape(self.search_operator), + escape(self.search_term[0]) ) self.where_clause = self.sub_clause + """ @@ -447,12 +447,12 @@ class CisTransLrsSearch(LrsSearch): %sXRef.Locus = Geno.name and Geno.SpeciesId = %s and %s.Chr = Geno.Chr""" % ( - self.escape(self.dataset.type), + escape(self.dataset.type), the_operator, - self.escape(self.mb_buffer), - self.escape(self.dataset.type), - self.escape(self.species_id), - self.escape(self.dataset.type) + escape(self.mb_buffer), + escape(self.dataset.type), + escape(self.species_id), + escape(self.dataset.type) ) print("where_clause is:", pf(self.where_clause)) @@ -559,7 +559,7 @@ class RangeSearch(ProbeSetSearch): self.where_clause = """ (SELECT Pow(2, max(value) -min(value)) FROM ProbeSetData WHERE ProbeSetData.Id = ProbeSetXRef.dataId) > %s - """ % (self.escape(self.search_term[0])) + """ % (escape(self.search_term[0])) print("where_clause is:", pf(self.where_clause)) @@ -647,16 +647,14 @@ class AuthorSearch(PhenotypeSearch): DoSearch.search_types["NAME"] = "AuthorSearch" def run(self): - - self.search_term = [float(value) for value in self.search_term] - - self.where_clause = """ Publication.Authors LIKE %s and - """ % (self.escape(self.search_term[0])) + + self.where_clause = """ Publication.Authors REGEXP "[[:<:]]%s[[:>:]]" and + """ % (self.search_term[0]) self.query = self.compile_final_query(where_clause = self.where_clause) return self.execute(self.query) - + if __name__ == "__main__": diff --git a/wqflask/wqflask/parser.py b/wqflask/wqflask/parser.py index efe479e6..f991d8c7 100644 --- a/wqflask/wqflask/parser.py +++ b/wqflask/wqflask/parser.py @@ -28,7 +28,7 @@ def parse(pstring): returned item serach_term is always a list, even if only one element """ - pstring = re.split(r"""(?:(\w+\s*=\s*[\(\[][^)]*[\)\]]) | # LRS=(1 2 3), cisLRS=[4 5 6], etc + pstring = re.split(r"""(?:(\w+\s*=\s*[\('"\[][^)'"]*[\)\]'"]) | # LRS=(1 2 3), cisLRS=[4 5 6], etc (\w+\s*[=:\>\<][\w\*]+) | # wiki=bar, GO:foobar, etc ([\w\*]+)) # shh, brain, etc """, pstring, flags=re.VERBOSE) @@ -78,6 +78,8 @@ if __name__ == '__main__': parse("WIKI=ho*") parse("LRS>9") parse("LRS>=18") + parse("NAME='rw williams'") + parse('NAME="rw williams"') parse("foo <= 2") parse("cisLRS<20") parse("foo=[3 2 1)") diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index 52f628f6..efa1c5cc 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -100,7 +100,7 @@ class SearchResultPage(templatePage): self.trait_list = [] group = self.dataset.group - species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, group=group) + species = webqtlDatabaseFunction.retrieve_species(group=group) # result_set represents the results for each search term; a search of # "shh grin2b" would have two sets of results, one for each term @@ -114,7 +114,7 @@ class SearchResultPage(templatePage): print("foo locals are:", locals()) trait_id = result[0] this_trait = webqtlTrait(dataset=self.dataset, name=trait_id) - this_trait.retrieveInfo(QTL=True) + this_trait.retrieve_info(QTL=True) self.trait_list.append(this_trait) self.dataset.get_trait_info(self.trait_list, species) @@ -147,8 +147,7 @@ class SearchResultPage(templatePage): the_search = search_class(search_term, search_operator, self.dataset, - self.cursor, - self.db_conn) + ) self.results.extend(the_search.run()) print("in the search results are:", self.results) -- cgit v1.2.3 From 292d177f768e8f949bc50f8896b560879aaae178 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Wed, 5 Dec 2012 14:33:02 -0600 Subject: Continued to make changes related to getting rid of cursor/db_conn and using simple sqlalchemy Got Pheno/MrnaAssay dataset searches working again --- misc/new_variable_names.txt | 1 + wqflask/base/data_set.py | 9 ++--- wqflask/base/webqtlTrait.py | 46 +++++++++++----------- wqflask/wqflask/correlation/CorrelationPage.py | 2 +- wqflask/wqflask/correlation/correlationFunction.py | 2 +- wqflask/wqflask/do_search.py | 10 ++--- wqflask/wqflask/search_results.py | 4 +- wqflask/wqflask/show_trait/SampleList.py | 2 +- wqflask/wqflask/show_trait/show_trait.py | 2 +- 9 files changed, 38 insertions(+), 40 deletions(-) (limited to 'wqflask/base') diff --git a/misc/new_variable_names.txt b/misc/new_variable_names.txt index 2b10c07e..c11c160e 100644 --- a/misc/new_variable_names.txt +++ b/misc/new_variable_names.txt @@ -3,3 +3,4 @@ webqtlDataset.py -> data_set.py webqtlDataset (class object) -> DataSet database/db -> dataset/data_set DataEditingPage -> show_trait.py/show_trait.html +webqtlTrait -> GeneralTrait \ No newline at end of file diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 7833f5c1..70b33014 100755 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -272,7 +272,7 @@ class GenotypeDataSet(DataSet): WHERE GenoFreeze.InbredSetId = InbredSet.Id AND GenoFreeze.Name = "%s" - ''' % self.db_conn.escape_string(self.name) + ''' % escape(self.name) def check_confidentiality(self): return geno_mrna_confidentiality(self) @@ -425,13 +425,12 @@ class MrnaAssayDataSet(DataSet): where ProbeSetXRef.ProbeSetFreezeId = %s and ProbeSet.Id = ProbeSetXRef.ProbeSetId and ProbeSet.Name = '%s' - """ % (self.db_conn.escape_string(str(this_trait.dataset.id)), - self.db_conn.escape_string(this_trait.name))) + """ % (escape(str(this_trait.dataset.id)), + escape(this_trait.name))) print("query is:", pf(query)) - self.cursor.execute(query) - result = self.cursor.fetchone() + result = g.db.execute(query).fetchone() if result: if result[0]: diff --git a/wqflask/base/webqtlTrait.py b/wqflask/base/webqtlTrait.py index dec5fa00..5367b41f 100755 --- a/wqflask/base/webqtlTrait.py +++ b/wqflask/base/webqtlTrait.py @@ -10,6 +10,7 @@ from data_set import create_dataset from dbFunction import webqtlDatabaseFunction from utility import webqtlUtil +from MySQLdb import escape_string as escape from pprint import pformat as pf from flask import Flask, g @@ -40,9 +41,7 @@ class GeneralTrait: self.dataset, self.name, self.cellid = name2 #if self.dataset and isinstance(self.dataset, basestring): - self.dataset = create_dataset(self.dataset) - - + self.dataset = create_dataset(self.dataset.name) print("self.dataset is:", self.dataset, type(self.dataset)) #if self.dataset: @@ -367,7 +366,7 @@ class GeneralTrait: def retrieve_info(self, QTL=False): assert self.dataset, "Dataset doesn't exist" if self.dataset.type == 'Publish': - traitInfo = g.db.execute(""" + query = """ SELECT PublishXRef.Id, Publication.PubMed_ID, Phenotype.Pre_publication_description, Phenotype.Post_publication_description, Phenotype.Original_description, @@ -384,47 +383,46 @@ class GeneralTrait: Phenotype.Id = PublishXRef.PhenotypeId AND Publication.Id = PublishXRef.PublicationId AND PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND - PublishFreeze.Id =%s - """, (self.name, self.dataset.id)).fetchone() + PublishFreeze.Id = %s + """ % (self.name, self.dataset.id) + traitInfo = g.db.execute(query).fetchone() #XZ, 05/08/2009: Xiaodong add this block to use ProbeSet.Id to find the probeset instead of just using ProbeSet.Name #XZ, 05/08/2009: to avoid the problem of same probeset name from different platforms. elif self.dataset.type == 'ProbeSet': - display_fields_string = ',ProbeSet.'.join(self.dataset.display_fields) + display_fields_string = ', ProbeSet.'.join(self.dataset.display_fields) display_fields_string = 'ProbeSet.' + display_fields_string - traitInfo = g.db.execute(""" + query = """ SELECT %s FROM ProbeSet, ProbeSetFreeze, ProbeSetXRef WHERE ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id AND ProbeSetXRef.ProbeSetId = ProbeSet.Id AND - ProbeSetFreeze.Name = %s AND - ProbeSet.Name = %s - """, (display_fields_string, self.dataset.name, self.name)).fetchone() + ProbeSetFreeze.Name = '%s' AND + ProbeSet.Name = '%s' + """ % (display_fields_string, self.dataset.name, self.name) + traitInfo = g.db.execute(query).fetchone() + print("traitInfo is: ", pf(traitInfo)) #XZ, 05/08/2009: We also should use Geno.Id to find marker instead of just using Geno.Name # to avoid the problem of same marker name from different species. elif self.dataset.type == 'Geno': display_fields_string = string.join(self.dataset.display_fields,',Geno.') display_fields_string = 'Geno.' + display_fields_string - traitInfo = g.db.execute(""" + query = """ SELECT %s FROM Geno, GenoFreeze, GenoXRef WHERE GenoXRef.GenoFreezeId = GenoFreeze.Id AND GenoXRef.GenoId = Geno.Id AND - GenoFreeze.Name = %s AND - Geno.Name = %s - """, (display_fields_string, self.dataset.name, self.name)).fetchone() + GenoFreeze.Name = '%s' AND + Geno.Name = '%s' + """ % (display_fields_string, self.dataset.name, self.name) + traitInfo = g.db.execute(query).fetchone() + print("traitInfo is: ", pf(traitInfo)) else: #Temp type - traitInfo = g.db.execute("""SELECT %s FROM %s WHERE Name = %s - """, (string.join(self.dataset.display_fields,','), - self.dataset.type, self.name)).fetchone() - - query = """SELECT %s FROM %s WHERE Name = %s + query = """SELECT %s FROM %s WHERE Name = %s """ % (string.join(self.dataset.display_fields,','), - self.dataset.type, self.name) - - print("query is:", pf(query)) - print("traitInfo is: ", pf(traitInfo)) + self.dataset.type, self.name) + traitInfo = g.db.execute(query).fetchone() #self.cursor.execute(query) diff --git a/wqflask/wqflask/correlation/CorrelationPage.py b/wqflask/wqflask/correlation/CorrelationPage.py index 8af30d1e..f1dd96ef 100644 --- a/wqflask/wqflask/correlation/CorrelationPage.py +++ b/wqflask/wqflask/correlation/CorrelationPage.py @@ -46,7 +46,7 @@ import reaper from base import webqtlConfig from utility.THCell import THCell from utility.TDCell import TDCell -from base.webqtlTrait import webqtlTrait +from base.webqtlTrait import GeneralTrait from base.data_set import create_dataset from base.templatePage import templatePage from utility import webqtlUtil diff --git a/wqflask/wqflask/correlation/correlationFunction.py b/wqflask/wqflask/correlation/correlationFunction.py index 4d62a468..8638cb1e 100644 --- a/wqflask/wqflask/correlation/correlationFunction.py +++ b/wqflask/wqflask/correlation/correlationFunction.py @@ -31,7 +31,7 @@ import pp import string from utility import webqtlUtil -from base.webqtlTrait import webqtlTrait +from base.webqtlTrait import GeneralTrait from dbFunction import webqtlDatabaseFunction diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py index 2094ed14..4301fb50 100644 --- a/wqflask/wqflask/do_search.py +++ b/wqflask/wqflask/do_search.py @@ -35,7 +35,7 @@ class DoSearch(object): """Executes query and returns results""" query = self.normalize_spaces(query) print("in do_search query is:", pf(query)) - results = g.db.execute(query).fetchall() + results = g.db.execute(query, no_parameters=True).fetchall() #results = self.cursor.fetchall() return results @@ -167,7 +167,7 @@ class PhenotypeSearch(DoSearch): fields_clause = [] for field in self.search_fields: fields_clause.append('''%s REGEXP "%s"''' % (field, search_term)) - fields_clause = "(%s)" % ' OR '.join(fields_clause) + fields_clause = "(%s) and " % ' OR '.join(fields_clause) return fields_clause @@ -198,7 +198,7 @@ class PhenotypeSearch(DoSearch): def run(self): """Generates and runs a simple search of a phenotype dataset""" - self.query = self.compile_final_query(where_clause = self.get_fields_clause()) + query = self.compile_final_query(where_clause = self.get_fields_clause()) # self.query = """SELECT PublishXRef.Id, #PublishFreeze.createtime as thistable, @@ -220,7 +220,7 @@ class PhenotypeSearch(DoSearch): #and PublishFreeze.Id = 1;""" - results = g.db.execute(self.query, no_parameters=True).fetchall() + results = self.execute(query) print("in [df] run results are:", results) return results @@ -272,7 +272,7 @@ class GenotypeSearch(DoSearch): Geno.Id = GenoXRef.GenoId and GenoXRef.GenoFreezeId = GenoFreeze.Id and GenoFreeze.Id = %s"""% (where_clause, - escape(self.dataset.id))) + escape(str(self.dataset.id)))) print("query is:", pf(query)) diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index efa1c5cc..cd478110 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -30,7 +30,7 @@ from base import webqtlConfig from utility.THCell import THCell from utility.TDCell import TDCell from base.data_set import create_dataset -from base.webqtlTrait import webqtlTrait +from base.webqtlTrait import GeneralTrait from base.templatePage import templatePage from wqflask import parser from wqflask import do_search @@ -113,7 +113,7 @@ class SearchResultPage(templatePage): print("foo locals are:", locals()) trait_id = result[0] - this_trait = webqtlTrait(dataset=self.dataset, name=trait_id) + this_trait = GeneralTrait(dataset=self.dataset, name=trait_id) this_trait.retrieve_info(QTL=True) self.trait_list.append(this_trait) diff --git a/wqflask/wqflask/show_trait/SampleList.py b/wqflask/wqflask/show_trait/SampleList.py index df0dc61e..25877521 100644 --- a/wqflask/wqflask/show_trait/SampleList.py +++ b/wqflask/wqflask/show_trait/SampleList.py @@ -2,7 +2,7 @@ from __future__ import absolute_import, print_function, division from base import webqtlCaseData from utility import webqtlUtil, Plot, Bunch -from base.webqtlTrait import webqtlTrait +from base.webqtlTrait import GeneralTrait from pprint import pformat as pf diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index 7060f2ea..aef9219f 100755 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -13,7 +13,7 @@ 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 base.webqtlTrait import GeneralTrait from dbFunction import webqtlDatabaseFunction from base.templatePage import templatePage from basicStatistics import BasicStatisticsFunctions -- cgit v1.2.3 From a7cc1119ebfbfab3ba5260be75c87cd4496f09b7 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Wed, 5 Dec 2012 18:03:23 -0600 Subject: Renamed webqtlTrait.py to trait.py Renamed webqtlTrait class to GeneralTrait Began process of removing fd from show_trait.py Created DatasetGroup object in data_set.py (this may end up becoming its own file later if it becomes big enough) --- misc/notes.txt | 10 +- misc/todo.txt | 4 +- wqflask/base/data_set.py | 221 +++++++++- wqflask/base/trait.py | 708 +++++++++++++++++++++++++++++++ wqflask/base/webqtlTrait.py | 695 ------------------------------ wqflask/wqflask/do_search.py | 5 +- wqflask/wqflask/search_results.py | 5 +- wqflask/wqflask/show_trait/show_trait.py | 295 ++++++++----- 8 files changed, 1129 insertions(+), 814 deletions(-) create mode 100755 wqflask/base/trait.py delete mode 100755 wqflask/base/webqtlTrait.py (limited to 'wqflask/base') diff --git a/misc/notes.txt b/misc/notes.txt index 59ab79cb..b0c0762c 100644 --- a/misc/notes.txt +++ b/misc/notes.txt @@ -14,6 +14,9 @@ export TERM=screen To search for commands in history if necessary: history | grep "(whatever is being searched for)" +Run web server: +/usr/local/nginx/sbin/nginx + Run server: python runserver.py @@ -63,11 +66,16 @@ Classes should always inherit "object" htop: Gives information on processes, cpu/memory load, etc dstat: Also gives various system information, resource usage, etc df: Reports file system disk space usage - +d =========================================== tidyp - Improves/beautifies html code tidyp -m -i -w 100 index_page.html +=========================================== + +ps -ax - View processes + +kill (process #) diff --git a/misc/todo.txt b/misc/todo.txt index 609e053f..60655a71 100644 --- a/misc/todo.txt +++ b/misc/todo.txt @@ -1 +1,3 @@ -- Read about grep/locate/find \ No newline at end of file +- Check about using trait id instead of trait name in queries in data_set.py + +- Ask Rob about Probe/cellid traits \ No newline at end of file diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 70b33014..68f5e5ed 100755 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -21,12 +21,16 @@ # This module is used by GeneNetwork project (www.genenetwork.org) from __future__ import print_function, division +import os from flask import Flask, g from htmlgen import HTMLgen2 as HT +import reaper + import webqtlConfig +from utility import webqtlUtil from MySQLdb import escape_string as escape from pprint import pformat as pf @@ -57,6 +61,74 @@ def create_dataset(dataset_name): return dataset_class(dataset_name) +class DatasetGroup(object): + """ + Each group has multiple datasets; each species has multiple groups. + + For example, Mouse has multiple groups (BXD, BXA, etc), and each group + has multiple datasets associated with it. + + """ + def __init__(self, dataset): + """This sets self.group and self.group_id""" + self.name, self.group_id = g.db.execute(dataset.query).fetchone() + if self.name == 'BXD300': + self.name = "BXD" + + self.incparentsf1 = False + + + #def read_genotype(self): + # self.read_genotype_file() + # + # if not self.genotype: # Didn'd succeed, so we try method 2 + # self.read_genotype_data() + + def read_genotype_file(self): + '''read genotype from .geno file instead of database''' + #if self.group == 'BXD300': + # self.group = 'BXD' + # + #assert self.group, "self.group needs to be set" + + #genotype_1 is Dataset Object without parents and f1 + #genotype_2 is Dataset Object with parents and f1 (not for intercross) + + self.genotype_1 = reaper.Dataset() + + # reaper barfs on unicode filenames, so here we ensure it's a string + full_filename = str(os.path.join(webqtlConfig.GENODIR, self.name + '.geno')) + self.genotype_1.read(full_filename) + + print("Got to after read") + + try: + # NL, 07/27/2010. ParInfo has been moved from webqtlForm.py to webqtlUtil.py; + _f1, _f12, _mat, _pat = webqtlUtil.ParInfo[self.name] + except KeyError: + _f1 = _f12 = _mat = _pat = None + + self.genotype_2 = self.genotype_1 + if self.genotype_1.type == "group" and _mat and _pat: + self.genotype_2 = self.genotype_1.add(Mat=_mat, Pat=_pat) #, F1=_f1) + + #determine default genotype object + if self.incparentsf1 and self.genotype_1.type != "intercross": + self.genotype = self.genotype_2 + else: + self.incparentsf1 = 0 + self.genotype = self.genotype_1 + + self.samplelist = list(self.genotype.prgy) + self.f1list = [] + self.parlist = [] + + if _f1 and _f12: + self.f1list = [_f1, _f12] + if _mat and _pat: + self.parlist = [_mat, _pat] + + class DataSet(object): """ DataSet class defines a dataset in webqtl, can be either Microarray, @@ -70,27 +142,35 @@ class DataSet(object): self.name = name self.id = None self.type = None - self.group = None self.setup() self.check_confidentiality() self.retrieve_name() - self.get_group() + self.group = DatasetGroup(self) # sets self.group and self.group_id + + + def get_desc(self): + """Gets overridden later, at least for Temp...used by trait's get_given_name""" + return None # Delete this eventually @property def riset(): Weve_Renamed_This_As_Group + + + #@property + #def group(self): + # if not self._group: + # self.get_group() + # + # return self._group + - def get_group(self): - self.group, self.group_id = g.db.execute(self.query).fetchone() - if self.group == 'BXD300': - self.group = "BXD" - #return group def retrieve_name(self): @@ -176,7 +256,7 @@ class PhenotypeDataSet(DataSet): self.type = 'Publish' - self.query = ''' + self.query_for_group = ''' SELECT InbredSet.Name, InbredSet.Id FROM @@ -239,7 +319,29 @@ class PhenotypeDataSet(DataSet): this_trait.LRS_score_repr = LRS_score_repr = '%3.1f' % this_trait.lrs this_trait.LRS_score_value = LRS_score_value = this_trait.lrs - this_trait.LRS_location_repr = LRS_location_repr = 'Chr %s: %.4f Mb' % (LRS_Chr, float(LRS_Mb) ) + this_trait.LRS_location_repr = LRS_location_repr = 'Chr %s: %.4f Mb' % (LRS_Chr, float(LRS_Mb)) + + def retrieve_sample_data(self, trait): + query = """ + SELECT + Strain.Name, PublishData.value, PublishSE.error, NStrain.count, PublishData.Id + FROM + (PublishData, Strain, PublishXRef, PublishFreeze) + left join PublishSE on + (PublishSE.DataId = PublishData.Id AND PublishSE.StrainId = PublishData.StrainId) + left join NStrain on + (NStrain.DataId = PublishData.Id AND + NStrain.StrainId = PublishData.StrainId) + WHERE + PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND + PublishData.Id = PublishXRef.DataId AND PublishXRef.Id = %s AND + PublishFreeze.Id = %d AND PublishData.StrainId = Strain.Id + Order BY + Strain.Name + """ % (self.trait.name, self.id) + results = g.db.execute(query).fetchall() + return results + class GenotypeDataSet(DataSet): DS_NAME_MAP['Geno'] = 'GenotypeDataSet' @@ -297,6 +399,26 @@ class GenotypeDataSet(DataSet): this_trait.location_repr = 'Chr%s: %.4f' % (this_trait.chr, float(this_trait.mb) ) this_trait.location_value = trait_location_value + + def retrieve_sample_data(self, trait): + query = """ + SELECT + Strain.Name, GenoData.value, GenoSE.error, GenoData.Id + FROM + (GenoData, GenoFreeze, Strain, Geno, GenoXRef) + left join GenoSE on + (GenoSE.DataId = GenoData.Id AND GenoSE.StrainId = GenoData.StrainId) + WHERE + Geno.SpeciesId = %s AND Geno.Name = '%s' AND GenoXRef.GenoId = Geno.Id AND + GenoXRef.GenoFreezeId = GenoFreeze.Id AND + GenoFreeze.Name = '%s' AND + GenoXRef.DataId = GenoData.Id AND + GenoData.StrainId = Strain.Id + Order BY + Strain.Name + """ % (webqtlDatabaseFunction.retrieve_species_id(self.group), trait.name, self.name) + results = g.db.execute(query).fetchall() + return results class MrnaAssayDataSet(DataSet): @@ -476,6 +598,42 @@ class MrnaAssayDataSet(DataSet): this_trait.LRS_score_repr = LRS_score_repr = '%3.1f' % this_trait.lrs this_trait.LRS_score_value = LRS_score_value = this_trait.lrs this_trait.LRS_location_repr = LRS_location_repr = 'Chr %s: %.4f Mb' % (LRS_Chr, float(LRS_Mb) ) + + def get_sequence(self): + query = """ + SELECT + ProbeSet.BlatSeq + FROM + ProbeSet, ProbeSetFreeze, ProbeSetXRef + WHERE + ProbeSet.Id=ProbeSetXRef.ProbeSetId and + ProbeSetFreeze.Id = ProbeSetXRef.ProbSetFreezeId and + ProbeSet.Name = %s + ProbeSetFreeze.Name = %s + """ % (escape(self.name), escape(self.dataset.name)) + results = g.db.execute(query).fetchone() + + return results[0] + + def retrieve_sample_data(self, trait): + query = """ + SELECT + Strain.Name, ProbeSetData.value, ProbeSetSE.error, ProbeSetData.Id + FROM + (ProbeSetData, ProbeSetFreeze, Strain, ProbeSet, ProbeSetXRef) + left join ProbeSetSE on + (ProbeSetSE.DataId = ProbeSetData.Id AND ProbeSetSE.StrainId = ProbeSetData.StrainId) + WHERE + ProbeSet.Name = '%s' AND ProbeSetXRef.ProbeSetId = ProbeSet.Id AND + ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id AND + ProbeSetFreeze.Name = '%s' AND + ProbeSetXRef.DataId = ProbeSetData.Id AND + ProbeSetData.StrainId = Strain.Id + Order BY + Strain.Name + """ % (escape(trait.name), escape(self.name)) + results = g.db.execute(query).fetchall() + return results class TempDataSet(DataSet): @@ -497,6 +655,51 @@ class TempDataSet(DataSet): self.id = 1 self.fullname = 'Temporary Storage' self.shortname = 'Temp' + + + @staticmethod + def handle_pca(desc): + if 'PCA' in desc: + # Todo: Modernize below lines + desc = desc[desc.rindex(':')+1:].strip() + else: + desc = desc[:desc.index('entered')].strip() + return desc + + def get_desc(self): + g.db.execute('SELECT description FROM Temp WHERE Name=%s', self.name) + desc = g.db.fetchone()[0] + desc = self.handle_pca(desc) + return desc + + def get_group(self): + self.cursor.execute(""" + SELECT + InbredSet.Name, InbredSet.Id + FROM + InbredSet, Temp + WHERE + Temp.InbredSetId = InbredSet.Id AND + Temp.Name = "%s" + """, self.name) + self.group, self.group_id = self.cursor.fetchone() + #return self.group + + def retrieve_sample_data(self, trait): + query = """ + SELECT + Strain.Name, TempData.value, TempData.SE, TempData.NStrain, TempData.Id + FROM + TempData, Temp, Strain + WHERE + TempData.StrainId = Strain.Id AND + TempData.Id = Temp.DataId AND + Temp.name = '%s' + Order BY + Strain.Name + """ % escape(trait.name) + + results = g.db.execute(query).fetchall() def geno_mrna_confidentiality(ob): diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py new file mode 100755 index 00000000..d3753fc1 --- /dev/null +++ b/wqflask/base/trait.py @@ -0,0 +1,708 @@ +from __future__ import division, print_function + +import string + +from htmlgen import HTMLgen2 as HT + +import webqtlConfig +from webqtlCaseData import webqtlCaseData +from data_set import create_dataset +from dbFunction import webqtlDatabaseFunction +from utility import webqtlUtil + +from MySQLdb import escape_string as escape +from pprint import pformat as pf + +from flask import Flask, g + +class GeneralTrait: + """ + Trait class defines a trait in webqtl, can be either Microarray, + Published phenotype, genotype, or user input trait + + """ + + def __init__(self, **kw): + print("in GeneralTrait") + self.dataset = kw.get('dataset', None) # database object + self.name = kw.get('name', None) # Trait ID, ProbeSet ID, Published ID, etc. + self.cellid = kw.get('cellid', None) + self.identification = kw.get('identification', 'un-named trait') + #self.group = kw.get('group', None) + self.haveinfo = kw.get('haveinfo', False) + self.sequence = kw.get('sequence', None) # Blat sequence, available for ProbeSet + self.data = kw.get('data', {}) + + if kw.get('fullname'): + name2 = value.split("::") + if len(name2) == 2: + self.dataset, self.name = name2 + elif len(name2) == 3: + self.dataset, self.name, self.cellid = name2 + + #if self.dataset and isinstance(self.dataset, basestring): + self.dataset = create_dataset(self.dataset) + + print("self.dataset is:", self.dataset, type(self.dataset)) + #if self.dataset: + + #self.dataset.get_group() + + #if self.dataset.type == "Temp": + # self.cursor.execute(''' + # SELECT + # InbredSet.Name + # FROM + # InbredSet, Temp + # WHERE + # Temp.InbredSetId = InbredSet.Id AND + # Temp.Name = "%s" + # ''', self.name) + # self.group = self.cursor.fetchone()[0] + #else: + # self.group = self.dataset.get_group() + + #print("trinity, self.group is:", self.group) + + # + # In ProbeSet, there are maybe several annotations match one sequence + # so we need use sequence(BlatSeq) as the identification, when we update + # one annotation, we update the others who match the sequence also. + # + # Hongqiang Li, 3/3/2008 + # + + #XZ, 05/08/2009: This block is not neccessary. We can add 'BlatSeq' into disfield. + # The variable self.sequence should be changed to self.BlatSeq + # It also should be changed in other places where it are used. + + #if self.dataset: + #if self.dataset.type == 'ProbeSet': + # print("Doing ProbeSet Query") + # query = ''' + # SELECT + # ProbeSet.BlatSeq + # FROM + # ProbeSet, ProbeSetFreeze, ProbeSetXRef + # WHERE + # ProbeSet.Id=ProbeSetXRef.ProbeSetId and + # ProbeSetFreeze.Id = ProbeSetXRef.ProbeSetFreezeId and + # ProbeSet.Name = %s and + # ProbeSetFreeze.Name = %s + # ''', (self.name, self.dataset.name) + # print("query is:", query) + # self.sequence = g.db.execute(*query).fetchone()[0] + # #self.sequence = self.cursor.fetchone()[0] + # print("self.sequence is:", self.sequence) + + + def get_name(self): + stringy = "" + if self.dataset and self.name: + stringy = "%s::%s" % (self.dataset, self.name) + if self.cellid: + stringy += "::" + self.cellid + else: + stringy = self.description + return stringy + + + def get_given_name(self): + """ + when user enter a trait or GN generate a trait, user want show the name + not the name that generated by GN randomly, the two follow function are + used to give the real name and the database. displayName() will show the + database also, getGivenName() just show the name. + For other trait, displayName() as same as getName(), getGivenName() as + same as self.name + + Hongqiang 11/29/07 + + """ + stringy = self.name + if self.dataset and self.name: + desc = self.dataset.get_desc() + if desc: + #desc = self.handle_pca(desc) + stringy = desc + return stringy + + + + def display_name(self): + stringy = "" + if self.dataset and self.name: + desc = self.dataset.get_desc() + #desc = self.handle_pca(desc) + if desc: + #desc = self.handle_pca(desc) + #stringy = desc + #if desc.__contains__('PCA'): + # desc = desc[desc.rindex(':')+1:].strip() + #else: + # desc = desc[:desc.index('entered')].strip() + #desc = self.handle_pca(desc) + stringy = "%s::%s" % (self.dataset, desc) + else: + stringy = "%s::%s" % (self.dataset, self.name) + if self.cellid: + stringy += "::" + self.cellid + else: + stringy = self.description + + return stringy + + + #def __str__(self): + # #return "%s %s" % (self.getName(), self.group) + # return self.getName() + #__str__ = getName + #__repr__ = __str__ + + def export_data(self, samplelist, the_type="val"): + """ + export data according to samplelist + mostly used in calculating correlation + + """ + result = [] + for sample in samplelist: + if self.data.has_key(sample): + if the_type=='val': + result.append(self.data[sample].val) + elif the_type=='var': + result.append(self.data[sample].var) + elif the_type=='N': + result.append(self.data[sample].N) + else: + raise KeyError, `the_type`+' the_type is incorrect.' + else: + result.append(None) + return result + + def export_informative(self, incVar=0): + """ + export informative sample + mostly used in qtl regression + + """ + samples = [] + vals = [] + the_vars = [] + for sample, value in self.data.items(): + if value.val != None: + if not incVar or value.var != None: + samples.append(sample) + vals.append(value.val) + the_vars.append(value.var) + return samples, vals, the_vars + + + # + # In ProbeSet, there are maybe several annotations match one sequence + # so we need use sequence(BlatSeq) as the identification, when we update + # one annotation, we update the others who match the sequence also. + # + # Hongqiang Li, 3/3/2008 + # + #def getSequence(self): + # assert self.cursor + # if self.dataset.type == 'ProbeSet': + # self.cursor.execute(''' + # SELECT + # ProbeSet.BlatSeq + # FROM + # ProbeSet, ProbeSetFreeze, ProbeSetXRef + # WHERE + # ProbeSet.Id=ProbeSetXRef.ProbeSetId and + # ProbeSetFreeze.Id = ProbeSetXRef.ProbSetFreezeId and + # ProbeSet.Name = %s + # ProbeSetFreeze.Name = %s + # ''', self.name, self.dataset.name) + # #self.cursor.execute(query) + # results = self.fetchone() + # + # return results[0] + + + + def retrieve_sample_data(self, samplelist=None): + if samplelist == None: + samplelist = [] + + assert self.dataset + + #if self.cellid: + # #Probe Data + # query = ''' + # SELECT + # Strain.Name, ProbeData.value, ProbeSE.error, ProbeData.Id + # FROM + # (ProbeData, ProbeFreeze, ProbeSetFreeze, ProbeXRef, + # Strain, Probe, ProbeSet) + # left join ProbeSE on + # (ProbeSE.DataId = ProbeData.Id AND ProbeSE.StrainId = ProbeData.StrainId) + # WHERE + # Probe.Name = '%s' AND ProbeSet.Name = '%s' AND + # Probe.ProbeSetId = ProbeSet.Id AND + # ProbeXRef.ProbeId = Probe.Id AND + # ProbeXRef.ProbeFreezeId = ProbeFreeze.Id AND + # ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id AND + # ProbeSetFreeze.Name = '%s' AND + # ProbeXRef.DataId = ProbeData.Id AND + # ProbeData.StrainId = Strain.Id + # Order BY + # Strain.Name + # ''' % (self.cellid, self.name, self.dataset.name) + # + #else: + results = self.dataset.retrieve_sample_data(self) + + #if self.dataset.type == 'Temp': + # query = ''' + # SELECT + # Strain.Name, TempData.value, TempData.SE, TempData.NStrain, TempData.Id + # FROM + # TempData, Temp, Strain + # WHERE + # TempData.StrainId = Strain.Id AND + # TempData.Id = Temp.DataId AND + # Temp.name = '%s' + # Order BY + # Strain.Name + # ''' % self.name + ##XZ, 03/02/2009: Xiaodong changed Data to PublishData, SE to PublishSE + #elif self.dataset.type == 'Publish': + # query = ''' + # SELECT + # Strain.Name, PublishData.value, PublishSE.error, NStrain.count, PublishData.Id + # FROM + # (PublishData, Strain, PublishXRef, PublishFreeze) + # left join PublishSE on + # (PublishSE.DataId = PublishData.Id AND PublishSE.StrainId = PublishData.StrainId) + # left join NStrain on + # (NStrain.DataId = PublishData.Id AND + # NStrain.StrainId = PublishData.StrainId) + # WHERE + # PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND + # PublishData.Id = PublishXRef.DataId AND PublishXRef.Id = %s AND + # PublishFreeze.Id = %d AND PublishData.StrainId = Strain.Id + # Order BY + # Strain.Name + # ''' % (self.name, self.dataset.id) + + #XZ, 03/02/2009: Xiaodong changed Data to ProbeData, SE to ProbeSE + #elif self.cellid: + + #XZ, 03/02/2009: Xiaodong added this block for ProbeSetData and ProbeSetSE + #elif self.dataset.type == 'ProbeSet': + # #ProbeSet Data + # query = ''' + # SELECT + # Strain.Name, ProbeSetData.value, ProbeSetSE.error, ProbeSetData.Id + # FROM + # (ProbeSetData, ProbeSetFreeze, Strain, ProbeSet, ProbeSetXRef) + # left join ProbeSetSE on + # (ProbeSetSE.DataId = ProbeSetData.Id AND ProbeSetSE.StrainId = ProbeSetData.StrainId) + # WHERE + # ProbeSet.Name = '%s' AND ProbeSetXRef.ProbeSetId = ProbeSet.Id AND + # ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id AND + # ProbeSetFreeze.Name = '%s' AND + # ProbeSetXRef.DataId = ProbeSetData.Id AND + # ProbeSetData.StrainId = Strain.Id + # Order BY + # Strain.Name + # ''' % (self.name, self.dataset.name) + ##XZ, 03/02/2009: Xiaodong changeded Data to GenoData, SE to GenoSE + #else: + # #Geno Data + # #XZ: The SpeciesId is not necessary, but it's nice to keep it to speed up database search. + # query = ''' + # SELECT + # Strain.Name, GenoData.value, GenoSE.error, GenoData.Id + # FROM + # (GenoData, GenoFreeze, Strain, Geno, GenoXRef) + # left join GenoSE on + # (GenoSE.DataId = GenoData.Id AND GenoSE.StrainId = GenoData.StrainId) + # WHERE + # Geno.SpeciesId = %s AND Geno.Name = '%s' AND GenoXRef.GenoId = Geno.Id AND + # GenoXRef.GenoFreezeId = GenoFreeze.Id AND + # GenoFreeze.Name = '%s' AND + # GenoXRef.DataId = GenoData.Id AND + # GenoData.StrainId = Strain.Id + # Order BY + # Strain.Name + # ''' % (webqtlDatabaseFunction.retrieveSpeciesId(self.cursor, self.dataset.group), self.name, self.dataset.name) + + + #self.cursor.execute(query) + #results = self.cursor.fetchall() + + # Todo: is this necessary? If not remove + self.data.clear() + + if results: + #self.mysqlid = results[0][-1] + #if samplelist: + for item in results: + #name, value, variance, num_cases = item + if not samplelist or (samplelist and name in samplelist): + #if value != None: + # num_cases = None + # if self.dataset.type in ('Publish', 'Temp'): + # ndata = item[3] + name = item[0] + self.data[name] = webqtlCaseData(*item) #name, value, variance, num_cases) + #end for + # else: + # for item in results: + # val = item[1] + # if val != None: + # var = item[2] + # ndata = None + # if self.dataset.type in ('Publish', 'Temp'): + # ndata = item[3] + # self.data[item[0]] = webqtlCaseData(val, var, ndata) + # #end for + # #end if + + #def keys(self): + # return self.__dict__.keys() + # + #def has_key(self, key): + # return self.__dict__.has_key(key) + # + #def items(self): + # return self.__dict__.items() + + def retrieve_info(self, QTL=False): + assert self.dataset, "Dataset doesn't exist" + if self.dataset.type == 'Publish': + query = """ + SELECT + PublishXRef.Id, Publication.PubMed_ID, + Phenotype.Pre_publication_description, Phenotype.Post_publication_description, Phenotype.Original_description, + Phenotype.Pre_publication_abbreviation, Phenotype.Post_publication_abbreviation, + Phenotype.Lab_code, Phenotype.Submitter, Phenotype.Owner, Phenotype.Authorized_Users, + Publication.Authors, Publication.Title, Publication.Abstract, + Publication.Journal, Publication.Volume, Publication.Pages, + Publication.Month, Publication.Year, PublishXRef.Sequence, + Phenotype.Units, PublishXRef.comments + FROM + PublishXRef, Publication, Phenotype, PublishFreeze + WHERE + PublishXRef.Id = %s AND + Phenotype.Id = PublishXRef.PhenotypeId AND + Publication.Id = PublishXRef.PublicationId AND + PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND + PublishFreeze.Id = %s + """ % (self.name, self.dataset.id) + traitInfo = g.db.execute(query).fetchone() + #XZ, 05/08/2009: Xiaodong add this block to use ProbeSet.Id to find the probeset instead of just using ProbeSet.Name + #XZ, 05/08/2009: to avoid the problem of same probeset name from different platforms. + elif self.dataset.type == 'ProbeSet': + display_fields_string = ', ProbeSet.'.join(self.dataset.display_fields) + display_fields_string = 'ProbeSet.' + display_fields_string + query = """ + SELECT %s + FROM ProbeSet, ProbeSetFreeze, ProbeSetXRef + WHERE + ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id AND + ProbeSetXRef.ProbeSetId = ProbeSet.Id AND + ProbeSetFreeze.Name = '%s' AND + ProbeSet.Name = '%s' + """ % (escape(display_fields_string), + escape(self.dataset.name), + escape(self.name)) + traitInfo = g.db.execute(query).fetchone() + print("traitInfo is: ", pf(traitInfo)) + #XZ, 05/08/2009: We also should use Geno.Id to find marker instead of just using Geno.Name + # to avoid the problem of same marker name from different species. + elif self.dataset.type == 'Geno': + display_fields_string = string.join(self.dataset.display_fields,',Geno.') + display_fields_string = 'Geno.' + display_fields_string + query = """ + SELECT %s + FROM Geno, GenoFreeze, GenoXRef + WHERE + GenoXRef.GenoFreezeId = GenoFreeze.Id AND + GenoXRef.GenoId = Geno.Id AND + GenoFreeze.Name = '%s' AND + Geno.Name = '%s' + """ % (escape(display_fields_string), escape(self.dataset.name), escape(self.name)) + traitInfo = g.db.execute(query).fetchone() + print("traitInfo is: ", pf(traitInfo)) + else: #Temp type + query = """SELECT %s FROM %s WHERE Name = %s + """ % (string.join(self.dataset.display_fields,','), + self.dataset.type, self.name) + traitInfo = g.db.execute(query).fetchone() + + + #self.cursor.execute(query) + #traitInfo = self.cursor.fetchone() + if traitInfo: + self.haveinfo = True + + #XZ: assign SQL query result to trait attributes. + for i, field in enumerate(self.dataset.display_fields): + setattr(self, field, traitInfo[i]) + + if self.dataset.type == 'Publish': + self.confidential = 0 + if self.pre_publication_description and not self.pubmed_id: + self.confidential = 1 + + self.homologeneid = None + if self.dataset.type == 'ProbeSet' and self.dataset.group and self.geneid: + #XZ, 05/26/2010: From time to time, this query get error message because some geneid values in database are not number. + #XZ: So I have to test if geneid is number before execute the query. + #XZ: The geneid values in database should be cleaned up. + try: + junk = float(self.geneid) + geneidIsNumber = 1 + except: + geneidIsNumber = 0 + + if geneidIsNumber: + query = """ + SELECT + HomologeneId + FROM + Homologene, Species, InbredSet + WHERE + Homologene.GeneId =%s AND + InbredSet.Name = '%s' AND + InbredSet.SpeciesId = Species.Id AND + Species.TaxonomyId = Homologene.TaxonomyId + """ % (escape(str(self.geneid)), escape(self.dataset.group.name)) + result = g.db.execute(query).fetchone() + else: + result = None + + if result: + self.homologeneid = result[0] + + if QTL: + if self.dataset.type == 'ProbeSet' and not self.cellid: + traitQTL = g.db.execute(""" + SELECT + ProbeSetXRef.Locus, ProbeSetXRef.LRS, ProbeSetXRef.pValue, ProbeSetXRef.mean + FROM + ProbeSetXRef, ProbeSet + WHERE + ProbeSetXRef.ProbeSetId = ProbeSet.Id AND + ProbeSet.Name = "%s" AND + ProbeSetXRef.ProbeSetFreezeId =%s + """, (self.name, self.dataset.id)).fetchone() + #self.cursor.execute(query) + #traitQTL = self.cursor.fetchone() + if traitQTL: + self.locus, self.lrs, self.pvalue, self.mean = traitQTL + else: + self.locus = self.lrs = self.pvalue = self.mean = "" + if self.dataset.type == 'Publish': + traitQTL = g.db.execute(""" + SELECT + PublishXRef.Locus, PublishXRef.LRS + FROM + PublishXRef, PublishFreeze + WHERE + PublishXRef.Id = %s AND + PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND + PublishFreeze.Id =%s + """, (self.name, self.dataset.id)).fetchone() + #self.cursor.execute(query) + #traitQTL = self.cursor.fetchone() + if traitQTL: + self.locus, self.lrs = traitQTL + else: + self.locus = self.lrs = "" + else: + raise KeyError, `self.name`+' information is not found in the database.' + + def genHTML(self, formName = "", dispFromDatabase=0, privilege="guest", userName="Guest", authorized_users=""): + if not self.haveinfo: + self.retrieveInfo() + + if self.dataset.type == 'Publish': + PubMedLink = "" + if self.pubmed_id: + PubMedLink = HT.Href(text="PubMed %d : " % self.pubmed_id, + target = "_blank", url = webqtlConfig.PUBMEDLINK_URL % self.pubmed_id) + else: + PubMedLink = HT.Span("Unpublished : ", Class="fs15") + + if formName: + setDescription2 = HT.Href(url="javascript:showDatabase3('%s','%s','%s','')" % + (formName, self.dataset.name, self.name), Class = "fs14") + else: + setDescription2 = HT.Href(url="javascript:showDatabase2('%s','%s','')" % + (self.dataset.name,self.name), Class = "fs14") + + if self.confidential and not webqtlUtil.hasAccessToConfidentialPhenotypeTrait(privilege=privilege, userName=userName, authorized_users=authorized_users): + setDescription2.append('RecordID/%s - %s' % (self.name, self.pre_publication_description)) + else: + setDescription2.append('RecordID/%s - %s' % (self.name, self.post_publication_description)) + + #XZ 03/26/2011: Xiaodong comment out the following two lins as Rob asked. Need to check with Rob why in PublishXRef table, there are few row whose Sequence > 1. + #if self.sequence > 1: + # setDescription2.append(' btach %d' % self.sequence) + if self.authors: + a1 = string.split(self.authors,',')[0] + while a1[0] == '"' or a1[0] == "'" : + a1 = a1[1:] + setDescription2.append(' by ') + setDescription2.append(HT.Italic('%s, and colleagues' % a1)) + setDescription = HT.Span(PubMedLink, setDescription2) + + elif self.dataset.type == 'Temp': + setDescription = HT.Href(text="%s" % (self.description),url="javascript:showDatabase2\ + ('%s','%s','')" % (self.dataset.name,self.name), Class = "fs14") + setDescription = HT.Span(setDescription) + + elif self.dataset.type == 'Geno': # Genome DB only available for single search + if formName: + setDescription = HT.Href(text="Locus %s [Chr %s @ %s Mb]" % (self.name,self.chr,\ + '%2.3f' % self.mb),url="javascript:showDatabase3('%s','%s','%s','')" % \ + (formName, self.dataset.name, self.name), Class = "fs14") + else: + setDescription = HT.Href(text="Locus %s [Chr %s @ %s Mb]" % (self.name,self.chr,\ + '%2.3f' % self.mb),url="javascript:showDatabase2('%s','%s','')" % \ + (self.dataset.name,self.name), Class = "fs14") + + setDescription = HT.Span(setDescription) + + else: + if self.cellid: + if formName: + setDescription = HT.Href(text="ProbeSet/%s/%s" % (self.name, self.cellid),url=\ + "javascript:showDatabase3('%s','%s','%s','%s')" % (formName, self.dataset.name,self.name,self.cellid), \ + Class = "fs14") + else: + setDescription = HT.Href(text="ProbeSet/%s/%s" % (self.name,self.cellid),url=\ + "javascript:showDatabase2('%s','%s','%s')" % (self.dataset.name,self.name,self.cellid), \ + Class = "fs14") + else: + if formName: + setDescription = HT.Href(text="ProbeSet/%s" % self.name, url=\ + "javascript:showDatabase3('%s','%s','%s','')" % (formName, self.dataset.name,self.name), \ + Class = "fs14") + else: + setDescription = HT.Href(text="ProbeSet/%s" % self.name, url=\ + "javascript:showDatabase2('%s','%s','')" % (self.dataset.name,self.name), \ + Class = "fs14") + if self.symbol and self.chr and self.mb: + setDescription.append(' [') + setDescription.append(HT.Italic('%s' % self.symbol,Class="cdg fwb")) + setDescription.append(' on Chr %s @ %s Mb]' % (self.chr,self.mb)) + if self.description: + setDescription.append(': %s' % self.description) + if self.probe_target_description: + setDescription.append('; %s' % self.probe_target_description) + setDescription = HT.Span(setDescription) + + if self.dataset.type != 'Temp' and dispFromDatabase: + setDescription.append( ' --- FROM : ') + setDescription.append(self.dataset.genHTML(Class='cori')) + return setDescription + + @property + def description_fmt(self): + '''Return a text formated description''' + if self.description: + formatted = self.description + if self.probe_target_description: + formatted += "; " + self.probe_target_description + else: + formatted = "Not available" + return formatted.capitalize() + + @property + def alias_fmt(self): + '''Return a text formatted alias''' + if self.alias: + alias = string.replace(self.alias, ";", " ") + alias = string.join(string.split(alias), ", ") + return alias + + + @property + def location_fmt(self): + '''Return a text formatted location + + While we're at it we set self.location in case we need it later (do we?) + + ''' + + if self.chr and self.mb: + self.location = 'Chr %s @ %s Mb' % (self.chr,self.mb) + elif self.chr: + self.location = 'Chr %s @ Unknown position' % (self.chr) + else: + self.location = 'Not available' + + fmt = self.location + ##XZ: deal with direction + if self.strand_probe == '+': + fmt += (' on the plus strand ') + elif self.strand_probe == '-': + fmt += (' on the minus strand ') + + return fmt + + + def get_database(self): + """ + Returns the database, and the url referring to the database if it exists + + We're going to to return two values here, and we don't want to have to call this twice from + the template. So it's not a property called from the template, but instead is called from the view + + """ + if self.cellid: + self.cursor.execute(""" + select ProbeFreeze.Name from ProbeFreeze, ProbeSetFreeze + where + ProbeFreeze.Id = ProbeSetFreeze.ProbeFreezeId AND + ProbeSetFreeze.Id = %d""" % thisTrait.dataset.id) + probeDBName = self.cursor.fetchone()[0] + return dict(name = probeDBName, + url = None) + else: + return dict(name = self.dataset.fullname, + url = webqtlConfig.INFOPAGEHREF % self.dataset.name) + + def calculate_correlation(self, values, method): + """Calculate the correlation value and p value according to the method specified""" + + #ZS: This takes the list of values of the trait our selected trait is being correlated against and removes the values of the samples our trait has no value for + #There's probably a better way of dealing with this, but I'll have to ask Christian + updated_raw_values = [] + updated_values = [] + for i in range(len(values)): + if values[i] != "None": + updated_raw_values.append(self.raw_values[i]) + updated_values.append(values[i]) + + self.raw_values = updated_raw_values + values = updated_values + + if method == METHOD_SAMPLE_PEARSON or method == METHOD_LIT or method == METHOD_TISSUE_PEARSON: + corr, nOverlap = webqtlUtil.calCorrelation(self.raw_values, values, len(values)) + else: + corr, nOverlap = webqtlUtil.calCorrelationRank(self.raw_values, values, len(values)) + + self.correlation = corr + self.overlap = nOverlap + + if self.overlap < 3: + self.p_value = 1.0 + else: + #ZS - This is probably the wrong way to deal with this. Correlation values of 1.0 definitely exist (the trait correlated against itself), so zero division needs to br prevented. + if abs(self.correlation) >= 1.0: + self.p_value = 0.0 + else: + ZValue = 0.5*log((1.0+self.correlation)/(1.0-self.correlation)) + ZValue = ZValue*sqrt(self.overlap-3) + self.p_value = 2.0*(1.0 - reaper.normp(abs(ZValue))) diff --git a/wqflask/base/webqtlTrait.py b/wqflask/base/webqtlTrait.py deleted file mode 100755 index 5367b41f..00000000 --- a/wqflask/base/webqtlTrait.py +++ /dev/null @@ -1,695 +0,0 @@ -from __future__ import division, print_function - -import string - -from htmlgen import HTMLgen2 as HT - -import webqtlConfig -from webqtlCaseData import webqtlCaseData -from data_set import create_dataset -from dbFunction import webqtlDatabaseFunction -from utility import webqtlUtil - -from MySQLdb import escape_string as escape -from pprint import pformat as pf - -from flask import Flask, g - -class GeneralTrait: - """ - Trait class defines a trait in webqtl, can be either Microarray, - Published phenotype, genotype, or user input trait - - """ - - def __init__(self, **kw): - print("in GeneralTrait") - self.dataset = kw.get('dataset', None) # database object - self.name = kw.get('name', None) # Trait ID, ProbeSet ID, Published ID, etc. - self.cellid = kw.get('cellid', None) - self.identification = kw.get('identification', 'un-named trait') - self.group = kw.get('group', None) - self.haveinfo = kw.get('haveinfo', False) - self.sequence = kw.get('sequence', None) # Blat sequence, available for ProbeSet - self.data = kw.get('data', {}) - - if kw.get('fullname'): - name2 = value.split("::") - if len(name2) == 2: - self.dataset, self.name = name2 - elif len(name2) == 3: - self.dataset, self.name, self.cellid = name2 - - #if self.dataset and isinstance(self.dataset, basestring): - self.dataset = create_dataset(self.dataset.name) - - print("self.dataset is:", self.dataset, type(self.dataset)) - #if self.dataset: - - self.dataset.get_group() - - if self.dataset.type == "Temp": - self.cursor.execute(''' - SELECT - InbredSet.Name - FROM - InbredSet, Temp - WHERE - Temp.InbredSetId = InbredSet.Id AND - Temp.Name = "%s" - ''', self.name) - self.group = self.cursor.fetchone()[0] - else: - self.group = self.dataset.get_group() - - print("trinity, self.group is:", self.group) - - # - # In ProbeSet, there are maybe several annotations match one sequence - # so we need use sequence(BlatSeq) as the identification, when we update - # one annotation, we update the others who match the sequence also. - # - # Hongqiang Li, 3/3/2008 - # - - #XZ, 05/08/2009: This block is not neccessary. We can add 'BlatSeq' into disfield. - # The variable self.sequence should be changed to self.BlatSeq - # It also should be changed in other places where it are used. - - #if self.dataset: - if self.dataset.type == 'ProbeSet': - print("Doing ProbeSet Query") - query = ''' - SELECT - ProbeSet.BlatSeq - FROM - ProbeSet, ProbeSetFreeze, ProbeSetXRef - WHERE - ProbeSet.Id=ProbeSetXRef.ProbeSetId and - ProbeSetFreeze.Id = ProbeSetXRef.ProbeSetFreezeId and - ProbeSet.Name = %s and - ProbeSetFreeze.Name = %s - ''', (self.name, self.dataset.name) - print("query is:", query) - self.sequence = g.db.execute(*query).fetchone()[0] - #self.sequence = self.cursor.fetchone()[0] - print("self.sequence is:", self.sequence) - - - def getName(self): - str = "" - if self.dataset and self.name: - str = "%s::%s" % (self.dataset, self.name) - if self.cellid: - str += "::" + self.cellid - else: - str = self.description - return str - - # - # when user enter a trait or GN generate a trait, user want show the name - # not the name that generated by GN randomly, the two follow function are - # used to give the real name and the database. displayName() will show the - # database also, getGivenName() just show the name. - # For other trait, displayName() as same as getName(), getGivenName() as - # same as self.name - # - # Hongqiang 11/29/07 - # - def getGivenName(self): - str = self.name - if self.dataset and self.name: - if self.dataset.type=='Temp': - self.cursor.execute('SELECT description FROM Temp WHERE Name=%s', self.name) - desc = self.cursor.fetchone()[0] - if desc.__contains__('PCA'): - desc = desc[desc.rindex(':')+1:].strip() - else: - desc = desc[:desc.index('entered')].strip() - str = desc - return str - - def displayName(self): - str = "" - if self.dataset and self.name: - if self.dataset.type=='Temp': - desc = self.description - if desc.__contains__('PCA'): - desc = desc[desc.rindex(':')+1:].strip() - else: - desc = desc[:desc.index('entered')].strip() - str = "%s::%s" % (self.dataset, desc) - else: - str = "%s::%s" % (self.dataset, self.name) - if self.cellid: - str += "::" + self.cellid - else: - str = self.description - - return str - - - #def __str__(self): - # #return "%s %s" % (self.getName(), self.group) - # return self.getName() - #__str__ = getName - #__repr__ = __str__ - - def exportData(self, samplelist, type="val"): - """ - export data according to samplelist - mostly used in calculating correlation - """ - result = [] - for sample in samplelist: - if self.data.has_key(sample): - if type=='val': - result.append(self.data[sample].val) - elif type=='var': - result.append(self.data[sample].var) - elif type=='N': - result.append(self.data[sample].N) - else: - raise KeyError, `type`+' type is incorrect.' - else: - result.append(None) - return result - - def exportInformative(self, incVar=0): - """ - export informative sample - mostly used in qtl regression - """ - samples = [] - vals = [] - vars = [] - for sample, value in self.data.items(): - if value.val != None: - if not incVar or value.var != None: - samples.append(sample) - vals.append(value.val) - vars.append(value.var) - return samples, vals, vars - - - # - # In ProbeSet, there are maybe several annotations match one sequence - # so we need use sequence(BlatSeq) as the identification, when we update - # one annotation, we update the others who match the sequence also. - # - # Hongqiang Li, 3/3/2008 - # - def getSequence(self): - assert self.cursor - if self.dataset.type == 'ProbeSet': - self.cursor.execute(''' - SELECT - ProbeSet.BlatSeq - FROM - ProbeSet, ProbeSetFreeze, ProbeSetXRef - WHERE - ProbeSet.Id=ProbeSetXRef.ProbeSetId and - ProbeSetFreeze.Id = ProbeSetXRef.ProbSetFreezeId and - ProbeSet.Name = %s - ProbeSetFreeze.Name = %s - ''', self.name, self.dataset.name) - #self.cursor.execute(query) - results = self.fetchone() - - return results[0] - - - - def retrieveData(self, samplelist=None): - - if samplelist == None: - samplelist = [] - assert self.dataset and self.cursor - - if self.dataset.type == 'Temp': - query = ''' - SELECT - Strain.Name, TempData.value, TempData.SE, TempData.NStrain, TempData.Id - FROM - TempData, Temp, Strain - WHERE - TempData.StrainId = Strain.Id AND - TempData.Id = Temp.DataId AND - Temp.name = '%s' - Order BY - Strain.Name - ''' % self.name - #XZ, 03/02/2009: Xiaodong changed Data to PublishData, SE to PublishSE - elif self.dataset.type == 'Publish': - query = ''' - SELECT - Strain.Name, PublishData.value, PublishSE.error, NStrain.count, PublishData.Id - FROM - (PublishData, Strain, PublishXRef, PublishFreeze) - left join PublishSE on - (PublishSE.DataId = PublishData.Id AND PublishSE.StrainId = PublishData.StrainId) - left join NStrain on - (NStrain.DataId = PublishData.Id AND - NStrain.StrainId = PublishData.StrainId) - WHERE - PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND - PublishData.Id = PublishXRef.DataId AND PublishXRef.Id = %s AND - PublishFreeze.Id = %d AND PublishData.StrainId = Strain.Id - Order BY - Strain.Name - ''' % (self.name, self.dataset.id) - - #XZ, 03/02/2009: Xiaodong changed Data to ProbeData, SE to ProbeSE - elif self.cellid: - #Probe Data - query = ''' - SELECT - Strain.Name, ProbeData.value, ProbeSE.error, ProbeData.Id - FROM - (ProbeData, ProbeFreeze, ProbeSetFreeze, ProbeXRef, - Strain, Probe, ProbeSet) - left join ProbeSE on - (ProbeSE.DataId = ProbeData.Id AND ProbeSE.StrainId = ProbeData.StrainId) - WHERE - Probe.Name = '%s' AND ProbeSet.Name = '%s' AND - Probe.ProbeSetId = ProbeSet.Id AND - ProbeXRef.ProbeId = Probe.Id AND - ProbeXRef.ProbeFreezeId = ProbeFreeze.Id AND - ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id AND - ProbeSetFreeze.Name = '%s' AND - ProbeXRef.DataId = ProbeData.Id AND - ProbeData.StrainId = Strain.Id - Order BY - Strain.Name - ''' % (self.cellid, self.name, self.dataset.name) - #XZ, 03/02/2009: Xiaodong added this block for ProbeSetData and ProbeSetSE - elif self.dataset.type == 'ProbeSet': - #ProbeSet Data - query = ''' - SELECT - Strain.Name, ProbeSetData.value, ProbeSetSE.error, ProbeSetData.Id - FROM - (ProbeSetData, ProbeSetFreeze, Strain, ProbeSet, ProbeSetXRef) - left join ProbeSetSE on - (ProbeSetSE.DataId = ProbeSetData.Id AND ProbeSetSE.StrainId = ProbeSetData.StrainId) - WHERE - ProbeSet.Name = '%s' AND ProbeSetXRef.ProbeSetId = ProbeSet.Id AND - ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id AND - ProbeSetFreeze.Name = '%s' AND - ProbeSetXRef.DataId = ProbeSetData.Id AND - ProbeSetData.StrainId = Strain.Id - Order BY - Strain.Name - ''' % (self.name, self.dataset.name) - #XZ, 03/02/2009: Xiaodong changeded Data to GenoData, SE to GenoSE - else: - #Geno Data - #XZ: The SpeciesId is not necessary, but it's nice to keep it to speed up database search. - query = ''' - SELECT - Strain.Name, GenoData.value, GenoSE.error, GenoData.Id - FROM - (GenoData, GenoFreeze, Strain, Geno, GenoXRef) - left join GenoSE on - (GenoSE.DataId = GenoData.Id AND GenoSE.StrainId = GenoData.StrainId) - WHERE - Geno.SpeciesId = %s AND Geno.Name = '%s' AND GenoXRef.GenoId = Geno.Id AND - GenoXRef.GenoFreezeId = GenoFreeze.Id AND - GenoFreeze.Name = '%s' AND - GenoXRef.DataId = GenoData.Id AND - GenoData.StrainId = Strain.Id - Order BY - Strain.Name - ''' % (webqtlDatabaseFunction.retrieveSpeciesId(self.cursor, self.dataset.group), self.name, self.dataset.name) - - - self.cursor.execute(query) - results = self.cursor.fetchall() - self.data.clear() - - if results: - self.mysqlid = results[0][-1] - #if samplelist: - for item in results: - #name, value, variance, num_cases = item - if not samplelist or (samplelist and name in samplelist): - #if value != None: - # num_cases = None - # if self.dataset.type in ('Publish', 'Temp'): - # ndata = item[3] - name = item[0] - self.data[name] = webqtlCaseData(*item) #name, value, variance, num_cases) - #end for - # else: - # for item in results: - # val = item[1] - # if val != None: - # var = item[2] - # ndata = None - # if self.dataset.type in ('Publish', 'Temp'): - # ndata = item[3] - # self.data[item[0]] = webqtlCaseData(val, var, ndata) - # #end for - # #end if - #else: - # pass - - #def keys(self): - # return self.__dict__.keys() - # - #def has_key(self, key): - # return self.__dict__.has_key(key) - # - #def items(self): - # return self.__dict__.items() - - def retrieve_info(self, QTL=False): - assert self.dataset, "Dataset doesn't exist" - if self.dataset.type == 'Publish': - query = """ - SELECT - PublishXRef.Id, Publication.PubMed_ID, - Phenotype.Pre_publication_description, Phenotype.Post_publication_description, Phenotype.Original_description, - Phenotype.Pre_publication_abbreviation, Phenotype.Post_publication_abbreviation, - Phenotype.Lab_code, Phenotype.Submitter, Phenotype.Owner, Phenotype.Authorized_Users, - Publication.Authors, Publication.Title, Publication.Abstract, - Publication.Journal, Publication.Volume, Publication.Pages, - Publication.Month, Publication.Year, PublishXRef.Sequence, - Phenotype.Units, PublishXRef.comments - FROM - PublishXRef, Publication, Phenotype, PublishFreeze - WHERE - PublishXRef.Id = %s AND - Phenotype.Id = PublishXRef.PhenotypeId AND - Publication.Id = PublishXRef.PublicationId AND - PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND - PublishFreeze.Id = %s - """ % (self.name, self.dataset.id) - traitInfo = g.db.execute(query).fetchone() - #XZ, 05/08/2009: Xiaodong add this block to use ProbeSet.Id to find the probeset instead of just using ProbeSet.Name - #XZ, 05/08/2009: to avoid the problem of same probeset name from different platforms. - elif self.dataset.type == 'ProbeSet': - display_fields_string = ', ProbeSet.'.join(self.dataset.display_fields) - display_fields_string = 'ProbeSet.' + display_fields_string - query = """ - SELECT %s - FROM ProbeSet, ProbeSetFreeze, ProbeSetXRef - WHERE - ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id AND - ProbeSetXRef.ProbeSetId = ProbeSet.Id AND - ProbeSetFreeze.Name = '%s' AND - ProbeSet.Name = '%s' - """ % (display_fields_string, self.dataset.name, self.name) - traitInfo = g.db.execute(query).fetchone() - print("traitInfo is: ", pf(traitInfo)) - #XZ, 05/08/2009: We also should use Geno.Id to find marker instead of just using Geno.Name - # to avoid the problem of same marker name from different species. - elif self.dataset.type == 'Geno': - display_fields_string = string.join(self.dataset.display_fields,',Geno.') - display_fields_string = 'Geno.' + display_fields_string - query = """ - SELECT %s - FROM Geno, GenoFreeze, GenoXRef - WHERE - GenoXRef.GenoFreezeId = GenoFreeze.Id AND - GenoXRef.GenoId = Geno.Id AND - GenoFreeze.Name = '%s' AND - Geno.Name = '%s' - """ % (display_fields_string, self.dataset.name, self.name) - traitInfo = g.db.execute(query).fetchone() - print("traitInfo is: ", pf(traitInfo)) - else: #Temp type - query = """SELECT %s FROM %s WHERE Name = %s - """ % (string.join(self.dataset.display_fields,','), - self.dataset.type, self.name) - traitInfo = g.db.execute(query).fetchone() - - - #self.cursor.execute(query) - #traitInfo = self.cursor.fetchone() - if traitInfo: - self.haveinfo = True - - #XZ: assign SQL query result to trait attributes. - for i, field in enumerate(self.dataset.display_fields): - setattr(self, field, traitInfo[i]) - - if self.dataset.type == 'Publish': - self.confidential = 0 - if self.pre_publication_description and not self.pubmed_id: - self.confidential = 1 - - self.homologeneid = None - if self.dataset.type == 'ProbeSet' and self.group and self.geneid: - #XZ, 05/26/2010: From time to time, this query get error message because some geneid values in database are not number. - #XZ: So I have to test if geneid is number before execute the query. - #XZ: The geneid values in database should be cleaned up. - try: - junk = float(self.geneid) - geneidIsNumber = 1 - except: - geneidIsNumber = 0 - - if geneidIsNumber: - result = g.db.execute(""" - SELECT - HomologeneId - FROM - Homologene, Species, InbredSet - WHERE - Homologene.GeneId =%s AND - InbredSet.Name = '%s' AND - InbredSet.SpeciesId = Species.Id AND - Species.TaxonomyId = Homologene.TaxonomyId - """, (self.geneid, self.group)).fetchone() - #self.cursor.execute(query) - #result = self.cursor.fetchone() - else: - result = None - - if result: - self.homologeneid = result[0] - - if QTL: - if self.dataset.type == 'ProbeSet' and not self.cellid: - traitQTL = g.db.execute(""" - SELECT - ProbeSetXRef.Locus, ProbeSetXRef.LRS, ProbeSetXRef.pValue, ProbeSetXRef.mean - FROM - ProbeSetXRef, ProbeSet - WHERE - ProbeSetXRef.ProbeSetId = ProbeSet.Id AND - ProbeSet.Name = "%s" AND - ProbeSetXRef.ProbeSetFreezeId =%s - """, (self.name, self.dataset.id)).fetchone() - #self.cursor.execute(query) - #traitQTL = self.cursor.fetchone() - if traitQTL: - self.locus, self.lrs, self.pvalue, self.mean = traitQTL - else: - self.locus = self.lrs = self.pvalue = self.mean = "" - if self.dataset.type == 'Publish': - traitQTL = g.db.execute(""" - SELECT - PublishXRef.Locus, PublishXRef.LRS - FROM - PublishXRef, PublishFreeze - WHERE - PublishXRef.Id = %s AND - PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND - PublishFreeze.Id =%s - """, (self.name, self.dataset.id)).fetchone() - #self.cursor.execute(query) - #traitQTL = self.cursor.fetchone() - if traitQTL: - self.locus, self.lrs = traitQTL - else: - self.locus = self.lrs = "" - else: - raise KeyError, `self.name`+' information is not found in the database.' - - def genHTML(self, formName = "", dispFromDatabase=0, privilege="guest", userName="Guest", authorized_users=""): - if not self.haveinfo: - self.retrieveInfo() - - if self.dataset.type == 'Publish': - PubMedLink = "" - if self.pubmed_id: - PubMedLink = HT.Href(text="PubMed %d : " % self.pubmed_id, - target = "_blank", url = webqtlConfig.PUBMEDLINK_URL % self.pubmed_id) - else: - PubMedLink = HT.Span("Unpublished : ", Class="fs15") - - if formName: - setDescription2 = HT.Href(url="javascript:showDatabase3('%s','%s','%s','')" % - (formName, self.dataset.name, self.name), Class = "fs14") - else: - setDescription2 = HT.Href(url="javascript:showDatabase2('%s','%s','')" % - (self.dataset.name,self.name), Class = "fs14") - - if self.confidential and not webqtlUtil.hasAccessToConfidentialPhenotypeTrait(privilege=privilege, userName=userName, authorized_users=authorized_users): - setDescription2.append('RecordID/%s - %s' % (self.name, self.pre_publication_description)) - else: - setDescription2.append('RecordID/%s - %s' % (self.name, self.post_publication_description)) - - #XZ 03/26/2011: Xiaodong comment out the following two lins as Rob asked. Need to check with Rob why in PublishXRef table, there are few row whose Sequence > 1. - #if self.sequence > 1: - # setDescription2.append(' btach %d' % self.sequence) - if self.authors: - a1 = string.split(self.authors,',')[0] - while a1[0] == '"' or a1[0] == "'" : - a1 = a1[1:] - setDescription2.append(' by ') - setDescription2.append(HT.Italic('%s, and colleagues' % a1)) - setDescription = HT.Span(PubMedLink, setDescription2) - - elif self.dataset.type == 'Temp': - setDescription = HT.Href(text="%s" % (self.description),url="javascript:showDatabase2\ - ('%s','%s','')" % (self.dataset.name,self.name), Class = "fs14") - setDescription = HT.Span(setDescription) - - elif self.dataset.type == 'Geno': # Genome DB only available for single search - if formName: - setDescription = HT.Href(text="Locus %s [Chr %s @ %s Mb]" % (self.name,self.chr,\ - '%2.3f' % self.mb),url="javascript:showDatabase3('%s','%s','%s','')" % \ - (formName, self.dataset.name, self.name), Class = "fs14") - else: - setDescription = HT.Href(text="Locus %s [Chr %s @ %s Mb]" % (self.name,self.chr,\ - '%2.3f' % self.mb),url="javascript:showDatabase2('%s','%s','')" % \ - (self.dataset.name,self.name), Class = "fs14") - - setDescription = HT.Span(setDescription) - - else: - if self.cellid: - if formName: - setDescription = HT.Href(text="ProbeSet/%s/%s" % (self.name, self.cellid),url=\ - "javascript:showDatabase3('%s','%s','%s','%s')" % (formName, self.dataset.name,self.name,self.cellid), \ - Class = "fs14") - else: - setDescription = HT.Href(text="ProbeSet/%s/%s" % (self.name,self.cellid),url=\ - "javascript:showDatabase2('%s','%s','%s')" % (self.dataset.name,self.name,self.cellid), \ - Class = "fs14") - else: - if formName: - setDescription = HT.Href(text="ProbeSet/%s" % self.name, url=\ - "javascript:showDatabase3('%s','%s','%s','')" % (formName, self.dataset.name,self.name), \ - Class = "fs14") - else: - setDescription = HT.Href(text="ProbeSet/%s" % self.name, url=\ - "javascript:showDatabase2('%s','%s','')" % (self.dataset.name,self.name), \ - Class = "fs14") - if self.symbol and self.chr and self.mb: - setDescription.append(' [') - setDescription.append(HT.Italic('%s' % self.symbol,Class="cdg fwb")) - setDescription.append(' on Chr %s @ %s Mb]' % (self.chr,self.mb)) - if self.description: - setDescription.append(': %s' % self.description) - if self.probe_target_description: - setDescription.append('; %s' % self.probe_target_description) - setDescription = HT.Span(setDescription) - - if self.dataset.type != 'Temp' and dispFromDatabase: - setDescription.append( ' --- FROM : ') - setDescription.append(self.dataset.genHTML(Class='cori')) - return setDescription - - @property - def description_fmt(self): - '''Return a text formated description''' - if self.description: - formatted = self.description - if self.probe_target_description: - formatted += "; " + self.probe_target_description - else: - formatted = "Not available" - return formatted.capitalize() - - @property - def alias_fmt(self): - '''Return a text formatted alias''' - if self.alias: - alias = string.replace(self.alias, ";", " ") - alias = string.join(string.split(alias), ", ") - return alias - - - @property - def location_fmt(self): - '''Return a text formatted location - - While we're at it we set self.location in case we need it later (do we?) - - ''' - - if self.chr and self.mb: - self.location = 'Chr %s @ %s Mb' % (self.chr,self.mb) - elif self.chr: - self.location = 'Chr %s @ Unknown position' % (self.chr) - else: - self.location = 'Not available' - - fmt = self.location - ##XZ: deal with direction - if self.strand_probe == '+': - fmt += (' on the plus strand ') - elif self.strand_probe == '-': - fmt += (' on the minus strand ') - - return fmt - - - def get_database(self): - """ - Returns the database, and the url referring to the database if it exists - - We're going to to return two values here, and we don't want to have to call this twice from - the template. So it's not a property called from the template, but instead is called from the view - - """ - if self.cellid: - self.cursor.execute(""" - select ProbeFreeze.Name from ProbeFreeze, ProbeSetFreeze - where - ProbeFreeze.Id = ProbeSetFreeze.ProbeFreezeId AND - ProbeSetFreeze.Id = %d""" % thisTrait.dataset.id) - probeDBName = self.cursor.fetchone()[0] - return dict(name = probeDBName, - url = None) - else: - return dict(name = self.dataset.fullname, - url = webqtlConfig.INFOPAGEHREF % self.dataset.name) - - def calculate_correlation(self, values, method): - """Calculate the correlation value and p value according to the method specified""" - - #ZS: This takes the list of values of the trait our selected trait is being correlated against and removes the values of the samples our trait has no value for - #There's probably a better way of dealing with this, but I'll have to ask Christian - updated_raw_values = [] - updated_values = [] - for i in range(len(values)): - if values[i] != "None": - updated_raw_values.append(self.raw_values[i]) - updated_values.append(values[i]) - - self.raw_values = updated_raw_values - values = updated_values - - if method == METHOD_SAMPLE_PEARSON or method == METHOD_LIT or method == METHOD_TISSUE_PEARSON: - corr, nOverlap = webqtlUtil.calCorrelation(self.raw_values, values, len(values)) - else: - corr, nOverlap = webqtlUtil.calCorrelationRank(self.raw_values, values, len(values)) - - self.correlation = corr - self.overlap = nOverlap - - if self.overlap < 3: - self.p_value = 1.0 - else: - #ZS - This is probably the wrong way to deal with this. Correlation values of 1.0 definitely exist (the trait correlated against itself), so zero division needs to br prevented. - if abs(self.correlation) >= 1.0: - self.p_value = 0.0 - else: - ZValue = 0.5*log((1.0+self.correlation)/(1.0-self.correlation)) - ZValue = ZValue*sqrt(self.overlap-3) - self.p_value = 2.0*(1.0 - reaper.normp(abs(ZValue))) diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py index 4301fb50..69602748 100644 --- a/wqflask/wqflask/do_search.py +++ b/wqflask/wqflask/do_search.py @@ -26,10 +26,11 @@ class DoSearch(object): assert search_operator in (None, "=", "<", ">", "<=", ">="), "Bad search operator" self.search_operator = search_operator self.dataset = dataset + print("self.dataset is boo: ", type(self.dataset), pf(self.dataset)) + print("self.dataset.group is: ", pf(self.dataset.group)) #Get group information for dataset and the species id - self.dataset.get_group() - self.species_id = webqtlDatabaseFunction.retrieve_species_id(self.dataset.group) + self.species_id = webqtlDatabaseFunction.retrieve_species_id(self.dataset.group.name) def execute(self, query): """Executes query and returns results""" diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index cd478110..7c50dfeb 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -30,7 +30,7 @@ from base import webqtlConfig from utility.THCell import THCell from utility.TDCell import TDCell from base.data_set import create_dataset -from base.webqtlTrait import GeneralTrait +from base.trait import GeneralTrait from base.templatePage import templatePage from wqflask import parser from wqflask import do_search @@ -99,8 +99,7 @@ class SearchResultPage(templatePage): """ self.trait_list = [] - group = self.dataset.group - species = webqtlDatabaseFunction.retrieve_species(group=group) + species = webqtlDatabaseFunction.retrieve_species(self.dataset.group.name) # result_set represents the results for each search term; a search of # "shh grin2b" would have two sets of results, one for each term diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index aef9219f..2bc4fc9c 100755 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -13,7 +13,8 @@ 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 GeneralTrait +from base.trait import GeneralTrait +from base.data_set import create_dataset from dbFunction import webqtlDatabaseFunction from base.templatePage import templatePage from basicStatistics import BasicStatisticsFunctions @@ -33,105 +34,111 @@ class ShowTrait(templatePage): def __init__(self, args): print("in ShowTrait, args are:", args) - self.group = args.group - self.trait_id = trait_id - self.dataset = dataset + #self.group = args.group + self.trait_id = args['trait_id'] + self.dataset = create_dataset(args['dataset']) + self.cell_id = None #assert self.openMysql(), "No database!" #print("red3 fd.group:", fd.group) this_trait = self.get_this_trait() - print("red4 fd.group:", fd.group) + #print("red4 fd.group:", fd.group) ##read genotype file - fd.group = this_trait.group + #fd.group = this_trait.group - print("[red5] fd.group is:", fd.group) - fd.readGenotype() + #print("[red5] fd.group is:", fd.group) + self.dataset.group.read_genotype_file() + #fd.readGenotype() - if not fd.genotype: - fd.readData(incf1=1) + if not self.dataset.group.genotype: + self.read_data(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, - group = fd.group, - 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 = '_', - export_data = None - ) - - 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.dataset and this_trait.dataset.type and this_trait.dataset.type == 'ProbeSet': - hddn['trait_type'] = this_trait.dataset.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.group) - - if fd.identification: - hddn['identification'] = fd.identification - else: - hddn['identification'] = "Un-named trait" #If no identification, set identification to un-named + ## 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' + + # Todo: Add back in the ones we actually need from below, as we discover we need them + hddn = OrderedDict() + + + ## Some fields, like method, are defaulted to None; otherwise in IE the field can't be changed using jquery + #hddn = OrderedDict( + # FormID = fmID, + # group = fd.group, + # 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 = '_', + # export_data = None + # ) + + #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.dataset and this_trait.dataset.type and this_trait.dataset.type == 'ProbeSet': + # hddn['trait_type'] = this_trait.dataset.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.group) + # + #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 @@ -186,27 +193,109 @@ class ShowTrait(templatePage): #trait_id = self.fd['trait_id'] #cell_id = self.fd.get('CellID') - this_trait = webqtlTrait(dataset=dataset, - name=trait_id, - cellid=cell_id) + this_trait = GeneralTrait(dataset=self.dataset.name, + name=self.trait_id, + cellid=self.cell_id) ##identification, etc. - self.fd.identification = '%s : %s' % (this_trait.dataset.shortname, trait_id) + self.identification = '%s : %s' % (self.dataset.shortname, self.trait_id) this_trait.returnURL = webqtlConfig.CGIDIR + webqtlConfig.SCRIPTFILE + '?FormID=showDatabase&database=%s\ - &ProbeSetID=%s&group=%s&parentsf1=on' %(dataset, trait_id, self.fd['group']) + &ProbeSetID=%s&group=%s&parentsf1=on' %(self.dataset, self.trait_id, self.dataset.group.name) - if cell_id: - self.fd.identification = '%s/%s'%(self.fd.identification, cell_id) - this_trait.returnURL = '%s&CellID=%s' % (this_trait.returnURL, cell_id) + if self.cell_id: + self.identification = '%s/%s'%(self.identification, self.cell_id) + this_trait.returnURL = '%s&CellID=%s' % (this_trait.returnURL, self.cell_id) - print("yellow1:", self.group) - this_trait.retrieveInfo() - print("yellow2:", self.group) - this_trait.retrieveData() - print("yellow3:", self.group) + print("yellow1:", self.dataset.group) + this_trait.retrieve_info() + print("yellow2:", self.dataset.group) + this_trait.retrieve_sample_data() + print("yellow3:", self.dataset.group) return this_trait + def read_data(self): + '''read user input data or from trait data and analysis form''' + + if incf1 == None: + incf1 = [] + + if not self.genotype: + self.readGenotype() + if not samplelist: + if incf1: + samplelist = self.f1list + self.samplelist + else: + samplelist = self.samplelist + + #print("before traitfiledata self.traitfile is:", pf(self.traitfile)) + + traitfiledata = getattr(self, "traitfile", None) + traitpastedata = getattr(self, "traitpaste", None) + variancefiledata = getattr(self, "variancefile", None) + variancepastedata = getattr(self, "variancepaste", None) + Nfiledata = getattr(self, "Nfile", None) + + #### Todo: Rewrite below when we get to someone submitting their own trait ##### + + def to_float(item): + try: + return float(item) + except ValueError: + return None + + print("bottle samplelist is:", samplelist) + if traitfiledata: + tt = traitfiledata.split() + values = map(webqtlUtil.StringAsFloat, tt) + elif traitpastedata: + tt = traitpastedata.split() + values = map(webqtlUtil.StringAsFloat, tt) + else: + print("mapping formdataasfloat") + #values = map(self.FormDataAsFloat, samplelist) + values = [to_float(getattr(self, key)) for key in samplelist] + print("rocket values is:", values) + + + if len(values) < len(samplelist): + values += [None] * (len(samplelist) - len(values)) + elif len(values) > len(samplelist): + values = values[:len(samplelist)] + print("now values is:", values) + + + if variancefiledata: + tt = variancefiledata.split() + variances = map(webqtlUtil.StringAsFloat, tt) + elif variancepastedata: + tt = variancepastedata.split() + variances = map(webqtlUtil.StringAsFloat, tt) + else: + variances = map(self.FormVarianceAsFloat, samplelist) + + if len(variances) < len(samplelist): + variances += [None]*(len(samplelist) - len(variances)) + elif len(variances) > len(samplelist): + variances = variances[:len(samplelist)] + + if Nfiledata: + tt = string.split(Nfiledata) + nsamples = map(webqtlUtil.IntAsFloat, tt) + if len(nsamples) < len(samplelist): + nsamples += [None]*(len(samplelist) - len(nsamples)) + else: + nsamples = map(self.FormNAsFloat, samplelist) + + ##values, variances, nsamples is obsolete + self.allTraitData = {} + for i, _sample in enumerate(samplelist): + if values[i] != None: + self.allTraitData[_sample] = webqtlCaseData( + _sample, values[i], variances[i], nsamples[i]) + print("allTraitData is:", pf(self.allTraitData)) + + def dispTraitInformation(self, fd, title1Body, hddn, this_trait): _Species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, group=fd.group) -- cgit v1.2.3 From 6749d3c9be414ad15b9c39b2d1817ca27566d959 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Thu, 6 Dec 2012 14:27:53 -0600 Subject: Made many small changes to show_trait/data_set/search_results/trait to remove use of the formData object and cursor --- wqflask/base/data_set.py | 7 +- wqflask/base/trait.py | 4 +- wqflask/wqflask/search_results.py | 4 +- wqflask/wqflask/show_trait/SampleList.py | 8 +- wqflask/wqflask/show_trait/show_trait.py | 129 ++++++++++++++++--------------- 5 files changed, 78 insertions(+), 74 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 68f5e5ed..14e4055e 100755 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -42,12 +42,13 @@ def create_dataset(dataset_name): #cursor = db_conn.cursor() print("dataset_name:", dataset_name) - dataset_type = g.db.execute(""" + query = """ SELECT DBType.Name FROM DBList, DBType - WHERE DBList.Name = %s and + WHERE DBList.Name = '%s' and DBType.Id = DBList.DBTypeId - """, (dataset_name)).fetchone().Name + """ % (escape(dataset_name)) + dataset_type = g.db.execute(query).fetchone().Name #dataset_type = cursor.fetchone()[0] print("[blubber] dataset_type:", pf(dataset_type)) diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py index d3753fc1..d0158ebd 100755 --- a/wqflask/base/trait.py +++ b/wqflask/base/trait.py @@ -24,7 +24,7 @@ class GeneralTrait: def __init__(self, **kw): print("in GeneralTrait") - self.dataset = kw.get('dataset', None) # database object + self.dataset = kw.get('dataset', None) # database name self.name = kw.get('name', None) # Trait ID, ProbeSet ID, Published ID, etc. self.cellid = kw.get('cellid', None) self.identification = kw.get('identification', 'un-named trait') @@ -230,7 +230,7 @@ class GeneralTrait: if samplelist == None: samplelist = [] - assert self.dataset + #assert self.dataset #if self.cellid: # #Probe Data diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index 7c50dfeb..b518ab99 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -112,11 +112,11 @@ class SearchResultPage(templatePage): print("foo locals are:", locals()) trait_id = result[0] - this_trait = GeneralTrait(dataset=self.dataset, name=trait_id) + this_trait = GeneralTrait(dataset=self.dataset.name, name=trait_id) this_trait.retrieve_info(QTL=True) self.trait_list.append(this_trait) - self.dataset.get_trait_info(self.trait_list, species) + self.dataset.get_trait_info(self.trait_list, species) def search(self): diff --git a/wqflask/wqflask/show_trait/SampleList.py b/wqflask/wqflask/show_trait/SampleList.py index 25877521..53bb24fb 100644 --- a/wqflask/wqflask/show_trait/SampleList.py +++ b/wqflask/wqflask/show_trait/SampleList.py @@ -9,7 +9,7 @@ from pprint import pformat as pf class SampleList(object): def __init__(self, cursor, - fd, + dataset, variance_data_page, sample_names, this_trait, @@ -17,7 +17,7 @@ class SampleList(object): header): self.cursor = cursor - self.fd = fd + self.dataset = dataset self.this_trait = this_trait self.sample_group_type = sample_group_type # primary or other self.header = header @@ -42,7 +42,7 @@ class SampleList(object): #if fd.RISet == 'AXBXA' and sampleName in ('AXB18/19/20','AXB13/14','BXA8/17'): # sampleNameAdd = HT.Href(url='/mouseCross.html#AXB/BXA', text=HT.Sup('#'), Class='fs12', target="_blank") sample.extra_info = {} - if self.fd.RISet == 'AXBXA' and sample_name in ('AXB18/19/20','AXB13/14','BXA8/17'): + if self.dataset.group.name == 'AXBXA' and sample_name in ('AXB18/19/20','AXB13/14','BXA8/17'): sample.extra_info['url'] = "/mouseCross.html#AXB/BXA" sample.extra_info['css_class'] = "fs12" @@ -124,7 +124,7 @@ class SampleList(object): WHERE Strain.Name = %s and StrainXRef.StrainId = Strain.Id and InbredSet.Id = StrainXRef.InbredSetId and - InbredSet.Name = %s""", (sample_name, self.fd.RISet)) + InbredSet.Name = %s""", (sample_name, self.dataset.group.name)) sample_id = self.cursor.fetchone()[0] diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index 2bc4fc9c..73b438d0 100755 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -7,6 +7,8 @@ import cPickle from collections import OrderedDict +from flask import Flask, g + from htmlgen import HTMLgen2 as HT from base import webqtlConfig @@ -140,10 +142,10 @@ class ShowTrait(templatePage): #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 + self.dispTraitInformation(args, "", hddn, this_trait) #Display trait information + function buttons if this_trait == None: - this_trait = webqtlTrait(data=fd.allTraitData, dataset=None) + this_trait = webqtlTrait(data=args['allTraitData'], dataset=None) ## Variance submit page only #if fd.enablevariance and not variance_data_page: @@ -156,15 +158,14 @@ class ShowTrait(templatePage): # print("Calling dispBasicStatistics") # self.dispBasicStatistics(fd, this_trait) - self.build_correlation_tools(fd, this_trait) - + self.build_correlation_tools(args, this_trait) - self.make_sample_lists(fd, variance_data_page, this_trait) + self.make_sample_lists(args, variance_data_page, this_trait) - if fd.allsamplelist: - hddn['allsamplelist'] = string.join(fd.allsamplelist, ' ') + if args['allsamplelist']: + hddn['allsamplelist'] = string.join(args['allsamplelist'], ' ') - if fd.varianceDispName != 'Variance': + if args['varianceDispName'] != 'Variance': hddn['isSE'] = "yes" # We'll need access to this_trait and hddn in the Jinja2 Template, so we put it inside self @@ -172,8 +173,8 @@ class ShowTrait(templatePage): self.hddn = hddn self.sample_group_types = OrderedDict() - self.sample_group_types['samples_primary'] = fd.group + " Only" - self.sample_group_types['samples_other'] = "Non-" + fd.group + self.sample_group_types['samples_primary'] = self.dataset.group.name + " Only" + self.sample_group_types['samples_other'] = "Non-" + self.dataset.group.name self.sample_group_types['samples_all'] = "All Cases" sample_lists = [group.sample_list for group in self.sample_groups] print("sample_lists is:", pf(sample_lists)) @@ -221,7 +222,7 @@ class ShowTrait(templatePage): incf1 = [] if not self.genotype: - self.readGenotype() + self.dataset.read_genotype_file() if not samplelist: if incf1: samplelist = self.f1list + self.samplelist @@ -296,9 +297,9 @@ class ShowTrait(templatePage): print("allTraitData is:", pf(self.allTraitData)) - def dispTraitInformation(self, fd, title1Body, hddn, this_trait): + def dispTraitInformation(self, args, title1Body, hddn, this_trait): - _Species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, group=fd.group) + _Species = webqtlDatabaseFunction.retrieve_species(group=self.dataset.group.name) #tbl = HT.TableLite(cellpadding=2, Class="collap", style="margin-left:20px;", width="840", valign="top", id="target1") @@ -323,31 +324,31 @@ class ShowTrait(templatePage): snpBrowserText = "" updateText = "" - if webqtlConfig.USERDICT[self.privilege] >= webqtlConfig.USERDICT['user']: - - if this_trait==None or this_trait.dataset.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.dataset.type != 'Temp': - if this_trait.dataset.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 + #if webqtlConfig.USERDICT[self.privilege] >= webqtlConfig.USERDICT['user']: + # + # if this_trait==None or this_trait.dataset.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.dataset.type != 'Temp': + # if this_trait.dataset.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.group) + g.db.execute("SELECT Name FROM InbredSet WHERE Name=%s", self.dataset.group.name) if this_trait: - addSelectionButton = HT.Href(url="#redirect", onClick="addRmvSelection('%s', document.getElementsByName('%s')[0], 'addToSelection');" % (fd.group, 'dataInput')) + addSelectionButton = HT.Href(url="#redirect", onClick="addRmvSelection('%s', document.getElementsByName('%s')[0], 'addToSelection');" % (self.dataset.group.name, '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" @@ -373,8 +374,7 @@ class ShowTrait(templatePage): 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() + geneName = g.db.execute("SELECT geneSymbol FROM GeneList WHERE geneSymbol = %s", this_trait.symbol).fetchone() if geneName: snpurl = os.path.join(webqtlConfig.CGIDIR, "main.py?FormID=SnpBrowserResultPage&submitStatus=1&diffAlleles=True&customStrain=True") + "&geneName=%s" % geneName[0] else: @@ -496,15 +496,14 @@ class ShowTrait(templatePage): if this_trait.dataset.name.find('Liver') >= 0 and this_trait.dataset.name.find('F2') < 0: pass else: + query = """SELECT count(*) + FROM Probe, ProbeSet + WHERE ProbeSet.Name = '%s' AND Probe.ProbeSetId = ProbeSet.Id""" % (this_trait.name) #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() + probeResult = g.db.execute(query).fetchone() if probeResult[0] > 0: probeurl = "%s?FormID=showProbeInfo&database=%s&ProbeSetID=%s&CellID=%s&group=%s&incparentsf1=ON" \ - % (os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), this_trait.dataset, this_trait.name, this_trait.cellid, fd.group) + % (os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), this_trait.dataset, this_trait.name, this_trait.cellid, self.dataset.group.name) 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) @@ -632,18 +631,21 @@ class ShowTrait(templatePage): #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 + #try: + this_chr, txst, txen = g.db.execute("SELECT chromosome,txStart,txEnd FROM GeneList WHERE geneSymbol = %s", (this_trait.symbol)).fetchone() + if this_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, + # this_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",\ @@ -1147,11 +1149,11 @@ class ShowTrait(templatePage): #title2Body.append(submitTable) - def build_correlation_tools(self, fd, this_trait): + def build_correlation_tools(self, this_trait): #species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, group=fd.group) - this_group = fd.group + this_group = self.dataset.group.name # We're checking a string here! assert isinstance(this_group, basestring), "We need a string type thing here" @@ -1172,6 +1174,7 @@ class ShowTrait(templatePage): dataset_menu = [] print("[tape4] webqtlConfig.PUBLICTHRESH:", webqtlConfig.PUBLICTHRESH) print("[tape4] type webqtlConfig.PUBLICTHRESH:", type(webqtlConfig.PUBLICTHRESH)) + query = self.cursor.execute('''SELECT PublishFreeze.FullName,PublishFreeze.Name FROM PublishFreeze,InbredSet WHERE PublishFreeze.InbredSetId = InbredSet.Id and InbredSet.Name = %s and PublishFreeze.public > %s''', @@ -1610,10 +1613,10 @@ class ShowTrait(templatePage): def make_sample_lists(self, fd, variance_data_page, this_trait): - if fd.parlist: - all_samples_ordered = fd.parlist + fd.f1list + fd.samplelist + if args['parlist']: + all_samples_ordered = args['parlist'] + args['f1list'] + args['samplelist'] else: - all_samples_ordered = fd.f1list + fd.samplelist + all_samples_ordered = args['f1list'] + args['samplelist'] this_trait_samples = set(this_trait.data.keys()) @@ -1622,12 +1625,12 @@ class ShowTrait(templatePage): print("-*- primary_samplelist is:", pf(primary_sample_names)) primary_samples = SampleList(self.cursor, - fd=fd, + args=args, variance_data_page=variance_data_page, sample_names=primary_sample_names, this_trait=this_trait, sample_group_type='primary', - header="%s Only" % (fd.group)) + header="%s Only" % (self.dataset.group.name)) other_sample_names = [] for sample in this_trait.data.keys(): -- cgit v1.2.3 From 2ec627563efa9fdf4fc74cb4764bfebb5ab90933 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Thu, 6 Dec 2012 15:39:28 -0600 Subject: Got show_trait running again for MrnaAssay traits --- wqflask/base/data_set.py | 37 +++++++------- wqflask/wqflask/show_trait/SampleList.py | 48 +++++++++--------- wqflask/wqflask/show_trait/show_trait.py | 81 ++++++++++++++----------------- wqflask/wqflask/templates/show_trait.html | 2 +- 4 files changed, 80 insertions(+), 88 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 14e4055e..9f0f3fac 100755 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -77,6 +77,9 @@ class DatasetGroup(object): self.name = "BXD" self.incparentsf1 = False + self.f1list = None + self.parlist = None + self.allsamples = None #def read_genotype(self): @@ -95,39 +98,39 @@ class DatasetGroup(object): #genotype_1 is Dataset Object without parents and f1 #genotype_2 is Dataset Object with parents and f1 (not for intercross) - self.genotype_1 = reaper.Dataset() + genotype_1 = reaper.Dataset() # reaper barfs on unicode filenames, so here we ensure it's a string full_filename = str(os.path.join(webqtlConfig.GENODIR, self.name + '.geno')) - self.genotype_1.read(full_filename) + genotype_1.read(full_filename) print("Got to after read") try: # NL, 07/27/2010. ParInfo has been moved from webqtlForm.py to webqtlUtil.py; - _f1, _f12, _mat, _pat = webqtlUtil.ParInfo[self.name] + f1, f12, maternal, paternal = webqtlUtil.ParInfo[self.name] except KeyError: - _f1 = _f12 = _mat = _pat = None + f1 = f12 = maternal = paternal = None - self.genotype_2 = self.genotype_1 - if self.genotype_1.type == "group" and _mat and _pat: - self.genotype_2 = self.genotype_1.add(Mat=_mat, Pat=_pat) #, F1=_f1) + + if genotype_1.type == "group" and maternal and paternal: + genotype_2 = genotype_1.add(Mat=maternal, Pat=paternal) #, F1=_f1) + else: + genotype_2 = genotype_1 #determine default genotype object - if self.incparentsf1 and self.genotype_1.type != "intercross": - self.genotype = self.genotype_2 + if self.incparentsf1 and genotype_1.type != "intercross": + self.genotype = genotype_2 else: self.incparentsf1 = 0 - self.genotype = self.genotype_1 + self.genotype = genotype_1 self.samplelist = list(self.genotype.prgy) - self.f1list = [] - self.parlist = [] - if _f1 and _f12: - self.f1list = [_f1, _f12] - if _mat and _pat: - self.parlist = [_mat, _pat] + if f1 and f12: + self.f1list = [f1, f12] + if maternal and paternal: + self.parlist = [maternal, paternal] class DataSet(object): @@ -169,8 +172,6 @@ class DataSet(object): # self.get_group() # # return self._group - - diff --git a/wqflask/wqflask/show_trait/SampleList.py b/wqflask/wqflask/show_trait/SampleList.py index 53bb24fb..0c752617 100644 --- a/wqflask/wqflask/show_trait/SampleList.py +++ b/wqflask/wqflask/show_trait/SampleList.py @@ -1,5 +1,7 @@ from __future__ import absolute_import, print_function, division +from flask import Flask, g + from base import webqtlCaseData from utility import webqtlUtil, Plot, Bunch from base.webqtlTrait import GeneralTrait @@ -8,22 +10,19 @@ from pprint import pformat as pf class SampleList(object): def __init__(self, - cursor, dataset, - variance_data_page, sample_names, this_trait, sample_group_type, header): - - self.cursor = cursor + self.dataset = dataset self.this_trait = this_trait self.sample_group_type = sample_group_type # primary or other self.header = header self.sample_list = [] # The actual list - + self.get_attributes() print("camera: attributes are:", pf(self.attributes)) @@ -54,7 +53,7 @@ class SampleList(object): sample.this_id = "Other_" + str(counter) #### For extra attribute columns; currently only used by several datasets - Zach - if self.this_trait and self.this_trait.db and self.this_trait.db.type == 'ProbeSet': + if self.this_trait and self.dataset and self.dataset.type == 'ProbeSet': sample.extra_attributes = self.get_extra_attribute_values(sample_name) print("sample.extra_attributes is", pf(sample.extra_attributes)) self.sample_list.append(sample) @@ -88,27 +87,27 @@ class SampleList(object): def get_attributes(self): """Finds which extra attributes apply to this dataset""" - #ZS: Id and name values for this trait's extra attributes - self.cursor.execute('''SELECT CaseAttribute.Id, CaseAttribute.Name + #ZS: Id and name values for this trait's extra attributes + case_attributes = g.db.execute('''SELECT CaseAttribute.Id, CaseAttribute.Name FROM CaseAttribute, CaseAttributeXRef WHERE CaseAttributeXRef.ProbeSetFreezeId = %s AND CaseAttribute.Id = CaseAttributeXRef.CaseAttributeId group by CaseAttributeXRef.CaseAttributeId''', - (str(self.this_trait.db.id),)) + (str(self.dataset.id),)) self.attributes = {} - for key, value in self.cursor.fetchall(): + for key, value in case_attributes.fetchall(): print("radish: %s - %s" % (key, value)) self.attributes[key] = Bunch() self.attributes[key].name = value - self.cursor.execute('''SELECT DISTINCT CaseAttributeXRef.Value - FROM CaseAttribute, CaseAttributeXRef - WHERE CaseAttribute.Name = %s AND - CaseAttributeXRef.CaseAttributeId = CaseAttribute.Id''', (value,)) + attribute_values = g.db.execute('''SELECT DISTINCT CaseAttributeXRef.Value + FROM CaseAttribute, CaseAttributeXRef + WHERE CaseAttribute.Name = %s AND + CaseAttributeXRef.CaseAttributeId = CaseAttribute.Id''', (value,)) - self.attributes[key].distinct_values = [item[0] for item in self.cursor.fetchall()] + self.attributes[key].distinct_values = [item[0] for item in attribute_values.fetchall()] self.attributes[key].distinct_values.sort(key=natural_sort_key) @@ -119,27 +118,28 @@ class SampleList(object): if self.attributes: #ZS: Get StrainId value for the next query - self.cursor.execute("""SELECT Strain.Id + result = g.db.execute("""SELECT Strain.Id FROM Strain, StrainXRef, InbredSet WHERE Strain.Name = %s and StrainXRef.StrainId = Strain.Id and InbredSet.Id = StrainXRef.InbredSetId and - InbredSet.Name = %s""", (sample_name, self.dataset.group.name)) + InbredSet.Name = %s""", (sample_name, + self.dataset.group.name)) - sample_id = self.cursor.fetchone()[0] + sample_id = result.fetchone().Id for attribute in self.attributes: #ZS: Add extra case attribute values (if any) - self.cursor.execute("""SELECT Value + result = g.db.execute("""SELECT Value FROM CaseAttributeXRef - WHERE ProbeSetFreezeId = '%s' AND - StrainId = '%s' AND - CaseAttributeId = '%s' - group by CaseAttributeXRef.CaseAttributeId""" % ( + WHERE ProbeSetFreezeId = %s AND + StrainId = %s AND + CaseAttributeId = %s + group by CaseAttributeXRef.CaseAttributeId""", ( self.this_trait.db.id, sample_id, str(attribute))) - attribute_value = self.cursor.fetchone()[0] #Trait-specific attributes, if any + attribute_value = result.fetchone().Value #Trait-specific attributes, if any #ZS: If it's an int, turn it into one for sorting #(for example, 101 would be lower than 80 if they're strings instead of ints) diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index 73b438d0..cd61d70c 100755 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -55,7 +55,7 @@ class ShowTrait(templatePage): #fd.readGenotype() if not self.dataset.group.genotype: - self.read_data(incf1=1) + self.read_data(include_f1=True) #incf1=1) ## determine data editing page format #variance_data_page = 0 @@ -158,15 +158,15 @@ class ShowTrait(templatePage): # print("Calling dispBasicStatistics") # self.dispBasicStatistics(fd, this_trait) - self.build_correlation_tools(args, this_trait) + self.build_correlation_tools(this_trait) - self.make_sample_lists(args, variance_data_page, this_trait) + self.make_sample_lists(this_trait) - if args['allsamplelist']: - hddn['allsamplelist'] = string.join(args['allsamplelist'], ' ') + if self.dataset.group.allsamples: + hddn['allsamples'] = string.join(self.dataset.group.allsamples, ' ') - if args['varianceDispName'] != 'Variance': - hddn['isSE'] = "yes" + #if args['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 @@ -215,22 +215,20 @@ class ShowTrait(templatePage): return this_trait - def read_data(self): + def read_data(self, include_f1=False): '''read user input data or from trait data and analysis form''' - if incf1 == None: - incf1 = [] + #if incf1 == None: + # incf1 = [] if not self.genotype: self.dataset.read_genotype_file() if not samplelist: - if incf1: + if include_f1: samplelist = self.f1list + self.samplelist else: samplelist = self.samplelist - #print("before traitfiledata self.traitfile is:", pf(self.traitfile)) - traitfiledata = getattr(self, "traitfile", None) traitpastedata = getattr(self, "traitpaste", None) variancefiledata = getattr(self, "variancefile", None) @@ -1174,39 +1172,34 @@ class ShowTrait(templatePage): dataset_menu = [] print("[tape4] webqtlConfig.PUBLICTHRESH:", webqtlConfig.PUBLICTHRESH) print("[tape4] type webqtlConfig.PUBLICTHRESH:", type(webqtlConfig.PUBLICTHRESH)) - query = - self.cursor.execute('''SELECT PublishFreeze.FullName,PublishFreeze.Name FROM + results = g.db.execute("""SELECT PublishFreeze.FullName,PublishFreeze.Name FROM PublishFreeze,InbredSet WHERE PublishFreeze.InbredSetId = InbredSet.Id - and InbredSet.Name = %s and PublishFreeze.public > %s''', + and InbredSet.Name = %s and PublishFreeze.public > %s""", (this_group, webqtlConfig.PUBLICTHRESH)) - for item in self.cursor.fetchall(): + for item in results.fetchall(): dataset_menu.append(dict(tissue=None, datasets=[item])) - self.cursor.execute('''SELECT GenoFreeze.FullName,GenoFreeze.Name FROM GenoFreeze, + results = g.db.execute("""SELECT GenoFreeze.FullName,GenoFreeze.Name FROM GenoFreeze, InbredSet WHERE GenoFreeze.InbredSetId = InbredSet.Id and InbredSet.Name = - %s and GenoFreeze.public > %s''', + %s and GenoFreeze.public > %s""", (this_group, webqtlConfig.PUBLICTHRESH)) - for item in self.cursor.fetchall(): + for item in results.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(): + tissues = g.db.execute("SELECT Id, Name FROM Tissue order by Name") + for item in tissues.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, + data_sets = g.db.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, "%" + this_group + "%")) - 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) + dataset_sub_menu = [item for item in data_sets.fetchall() if item] if dataset_sub_menu: dataset_menu.append(dict(tissue=tissue_name, datasets=dataset_sub_menu)) @@ -1612,11 +1605,13 @@ class ShowTrait(templatePage): title4Body.append(submitTable) - def make_sample_lists(self, fd, variance_data_page, this_trait): - if args['parlist']: - all_samples_ordered = args['parlist'] + args['f1list'] + args['samplelist'] + def make_sample_lists(self, this_trait): + if self.dataset.group.parlist: + all_samples_ordered = (self.dataset.group.parlist + + self.dataset.group.f1list + + self.dataset.group.samplelist) else: - all_samples_ordered = args['f1list'] + args['samplelist'] + all_samples_ordered = self.dataset.group.f1list + self.dataset.group.samplelist this_trait_samples = set(this_trait.data.keys()) @@ -1624,9 +1619,7 @@ class ShowTrait(templatePage): print("-*- primary_samplelist is:", pf(primary_sample_names)) - primary_samples = SampleList(self.cursor, - args=args, - variance_data_page=variance_data_page, + primary_samples = SampleList(dataset = self.dataset, sample_names=primary_sample_names, this_trait=this_trait, sample_group_type='primary', @@ -1640,18 +1633,16 @@ class ShowTrait(templatePage): other_sample_names.append(sample) if other_sample_names: - par_f1_samples = fd.parlist + fd.f1list + parent_f1_samples = self.dataset.group.parlist + self.dataset.group.f1list other_sample_names.sort() #Sort other samples - other_sample_names = par_f1_samples + other_sample_names + other_sample_names = parent_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.group)) + other_samples = SampleList(dataset=self.dataset, + sample_names=other_sample_names, + this_trait=this_trait, + sample_group_type='other', + header="Non-%s" % (self.dataset.group.name)) self.sample_groups = (primary_samples, other_samples) else: @@ -1661,4 +1652,4 @@ class ShowTrait(templatePage): #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 + self.dataset.group.allsamples = all_samples_ordered diff --git a/wqflask/wqflask/templates/show_trait.html b/wqflask/wqflask/templates/show_trait.html index b5c1d6ac..163be69c 100644 --- a/wqflask/wqflask/templates/show_trait.html +++ b/wqflask/wqflask/templates/show_trait.html @@ -19,7 +19,7 @@
    -- cgit v1.2.3 From 41721f0d386c034470fe68e0017295474242ab48 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Thu, 6 Dec 2012 16:50:20 -0600 Subject: Added minimum/maximum to basic statistics table Continued bug-shooting related to getting show_trait running with phenotype traits --- wqflask/base/data_set.py | 32 +++++--- wqflask/wqflask/do_search.py | 5 +- wqflask/wqflask/search_results.py | 7 -- wqflask/wqflask/show_trait/show_trait.py | 7 +- .../static/new/javascript/show_trait.coffee | 86 ++++++++++++---------- .../wqflask/static/new/javascript/show_trait.js | 10 ++- wqflask/wqflask/static/new/javascript/stats.coffee | 31 +++++--- wqflask/wqflask/static/new/javascript/stats.js | 18 ++++- wqflask/wqflask/templates/search_result_page.html | 4 +- wqflask/wqflask/templates/show_trait.html | 2 +- wqflask/wqflask/templates/show_trait_details.html | 2 +- .../wqflask/templates/show_trait_edit_data.html | 2 +- 12 files changed, 122 insertions(+), 84 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 9f0f3fac..2182fe9e 100755 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -30,6 +30,7 @@ from htmlgen import HTMLgen2 as HT import reaper import webqtlConfig +from dbFunction import webqtlDatabaseFunction from utility import webqtlUtil from MySQLdb import escape_string as escape @@ -72,10 +73,12 @@ class DatasetGroup(object): """ def __init__(self, dataset): """This sets self.group and self.group_id""" - self.name, self.group_id = g.db.execute(dataset.query).fetchone() + self.name, self.id = g.db.execute(dataset.query_for_group).fetchone() if self.name == 'BXD300': self.name = "BXD" + self.species = webqtlDatabaseFunction.retrieve_species(self.name) + self.incparentsf1 = False self.f1list = None self.parlist = None @@ -151,14 +154,25 @@ class DataSet(object): self.check_confidentiality() - self.retrieve_name() + self.retrieve_other_names() self.group = DatasetGroup(self) # sets self.group and self.group_id def get_desc(self): """Gets overridden later, at least for Temp...used by trait's get_given_name""" return None - + + #@staticmethod + #def get_by_trait_id(trait_id): + # """Gets the dataset object given the trait id""" + # + # + # + # name = g.db.execute(""" SELECT + # + # """) + # + # return DataSet(name) # Delete this eventually @property @@ -175,7 +189,7 @@ class DataSet(object): - def retrieve_name(self): + def retrieve_other_names(self): """ If the data set name parameter is not found in the 'Name' field of the data set table, check if it is actually the FullName or ShortName instead. @@ -326,7 +340,7 @@ class PhenotypeDataSet(DataSet): def retrieve_sample_data(self, trait): query = """ SELECT - Strain.Name, PublishData.value, PublishSE.error, NStrain.count, PublishData.Id + Strain.Name, PublishData.value, PublishSE.error, NStrain.count FROM (PublishData, Strain, PublishXRef, PublishFreeze) left join PublishSE on @@ -340,7 +354,7 @@ class PhenotypeDataSet(DataSet): PublishFreeze.Id = %d AND PublishData.StrainId = Strain.Id Order BY Strain.Name - """ % (self.trait.name, self.id) + """ % (trait.name, self.id) results = g.db.execute(query).fetchall() return results @@ -368,7 +382,7 @@ class GenotypeDataSet(DataSet): # Todo: Obsolete or rename this field self.type = 'Geno' - self.query = ''' + self.query_for_group = ''' SELECT InbredSet.Name, InbredSet.Id FROM @@ -418,7 +432,7 @@ class GenotypeDataSet(DataSet): GenoData.StrainId = Strain.Id Order BY Strain.Name - """ % (webqtlDatabaseFunction.retrieve_species_id(self.group), trait.name, self.name) + """ % (webqtlDatabaseFunction.retrieve_species_id(self.group.name), trait.name, self.name) results = g.db.execute(query).fetchall() return results @@ -476,7 +490,7 @@ class MrnaAssayDataSet(DataSet): # Todo: Obsolete or rename this field self.type = 'ProbeSet' - self.query = ''' + self.query_for_group = ''' SELECT InbredSet.Name, InbredSet.Id FROM diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py index 69602748..403f1b5e 100644 --- a/wqflask/wqflask/do_search.py +++ b/wqflask/wqflask/do_search.py @@ -177,9 +177,6 @@ class PhenotypeSearch(DoSearch): from_clause = self.normalize_spaces(from_clause) - #Get group information for dataset - self.dataset.get_group() - query = (self.base_query + """%s WHERE %s @@ -189,7 +186,7 @@ class PhenotypeSearch(DoSearch): PublishFreeze.Id = %s""" % ( from_clause, where_clause, - escape(str(self.dataset.group_id)), + escape(str(self.dataset.group.id)), escape(str(self.dataset.id)))) print("query is:", pf(query)) diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index b518ab99..5cb8e314 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -4,13 +4,6 @@ from wqflask import app from flask import render_template -################################################### -# # -# This file uses only spaces for indentation # -# # -################################################### - -#import string import os import cPickle import re diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index cd61d70c..d1c60877 100755 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -32,13 +32,16 @@ from pprint import pformat as pf -class ShowTrait(templatePage): +class ShowTrait(object): def __init__(self, args): print("in ShowTrait, args are:", args) #self.group = args.group self.trait_id = args['trait_id'] + self.dataset = create_dataset(args['dataset']) + + #self.dataset = create_dataset(args['dataset']) self.cell_id = None #assert self.openMysql(), "No database!" @@ -817,7 +820,7 @@ class ShowTrait(templatePage): # )) pass - menuTable = HT.TableLite(cellpadding=2, Class="collap", width="150", id="target1") + #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;")) diff --git a/wqflask/wqflask/static/new/javascript/show_trait.coffee b/wqflask/wqflask/static/new/javascript/show_trait.coffee index 6e22119f..3d9fcd5a 100644 --- a/wqflask/wqflask/static/new/javascript/show_trait.coffee +++ b/wqflask/wqflask/static/new/javascript/show_trait.coffee @@ -23,15 +23,15 @@ $ -> id = "#" + process_id(category, value_type) console.log("the_id:", id) in_box = $(id).html - + current_value = parseFloat($(in_box)).toFixed(decimal_places) - + console.log("urgh:", category, value_type) the_value = sample_sets[category][value_type]() console.log("After running sample_sets, the_value is:", the_value) if decimal_places > 0 the_value = the_value.toFixed(decimal_places) - + console.log("*-* the_value:", the_value) console.log("*-* current_value:", current_value) if the_value != current_value @@ -40,16 +40,16 @@ $ -> update_stat_values = (sample_sets)-> for category in ['samples_primary', 'samples_other', 'samples_all'] change_stats_value(sample_sets, category, "n_of_samples", 0) - for stat in ["mean", "median", "std_dev", "std_error"] + for stat in ["mean", "median", "std_dev", "std_error", "min", "max"] console.log("Calling change_stats_value") change_stats_value(sample_sets, category, stat, 2) - edit_data_change = -> + edit_data_change = -> sample_sets = samples_primary: new Stats([]) samples_other: new Stats([]) samples_all: new Stats([]) - + console.log("at beginning:", sample_sets) # ########## @@ -114,6 +114,14 @@ $ -> { vn: "std_dev" pretty: "Standard Deviation (SD)" + }, + { + vn: "min" + pretty: "Minimum" + }, + { + vn: "max" + pretty: "Maximum" } ] @@ -150,8 +158,8 @@ $ -> processed += "-" processed += value return processed - - + + show_hide_outliers = -> console.log("FOOBAR in beginning of show_hide_outliers") label = $('#show_hide_outliers').val() @@ -163,10 +171,10 @@ $ -> $('#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() @@ -179,15 +187,15 @@ $ -> $("#corr_sample_method_options").show() $('select[name=corr_method]').change(on_corr_method_change) - - + + ##End Calculate Correlations Code - + ##Populate Samples Attribute Values Code - + create_value_dropdown = (value) -> return """""" - + populate_sample_attributes_values_dropdown = -> console.log("in beginning of psavd") $('#attribute_values').empty() @@ -205,14 +213,14 @@ $ -> if js_data.attribute_names.length > 0 populate_sample_attributes_values_dropdown() $('#exclude_menu').change(populate_sample_attributes_values_dropdown) - + ##End Populate Samples Attribute Values Codess ##Block Samples By Attribute Value Code block_by_attribute_value = -> attribute_name = $('#exclude_menu').val() exclude_by_value = $('#attribute_values').val() - + cell_class = ".column_name-#{attribute_name}" $(cell_class).each (index, element) => if $.trim($(element).text()) == exclude_by_value @@ -220,11 +228,11 @@ $ -> $(row).find(".trait_value_input").val("x") $('#exclude_group').click(block_by_attribute_value) - + ##End Block Samples By Attribute Value Code - + ##Block Samples By Index Code - + block_by_index = -> index_string = $('#remove_samples_field').val() index_list = [] @@ -241,7 +249,7 @@ $ -> index = parseInt(index_set) console.log("index:", index) index_list.push(index) - #catch(erro) + #catch(erro) # alert("Syntax error") console.log("index_list:", index_list) for index in index_list @@ -251,33 +259,33 @@ $ -> $('#Primary_'+index.toString()).find('.trait_value_input').val("x") else if $('#block_group').val() == "other" console.log("block_group:", $('#block_group').val()) - console.log("row:", $('#Other_'+index.toString())) + console.log("row:", $('#Other_'+index.toString())) $('#Other_'+index.toString()).find('.trait_value_input').val("x") - + $('#block_by_index').click(block_by_index) ##End Block Samples By Index Code - + ##Hide Sample Rows With No Value (value of 'x') Code - + hide_no_value = -> $('.value_se').each (_index, element) => if $(element).find('.trait_value_input').val() == 'x' $(element).hide() - + $('#hide_no_value').click(hide_no_value) ##End Hide Sample Rows With No Value Code - + ##Block Outliers Code block_outliers = -> $('.outlier').each (_index, element) => $(element).find('.trait_value_input').val('x') - + $('#block_outliers').click(block_outliers) - + ##End Block Outliers Code - + ##Reset Table Values Code reset_samples_table = -> $('.trait_value_input').each (_index, element) => @@ -289,9 +297,9 @@ $ -> $('#reset').click(reset_samples_table) ##End Reset Table Values Code - + ##Get Sample Data From Table Code - + get_sample_table_data = -> samples = {} primary_samples = [] @@ -315,27 +323,27 @@ $ -> ##End Get Sample Data from Table Code ##Export Sample Table Data Code - + export_sample_table_data = -> sample_data = get_sample_table_data() console.log("sample_data is:", sample_data) json_sample_data = JSON.stringify(sample_data) console.log("json_sample_data is:", json_sample_data) - + $('input[name=export_data]').val(json_sample_data) console.log("export_data is", $('input[name=export_data]').val()) - + format = $('#export_format').val() if format == "excel" $('#trait_data_form').attr('action', '/export_trait_excel') else $('#trait_data_form').attr('action', '/export_trait_csv') console.log("action is:", $('#trait_data_form').attr('action')) - + $('#trait_data_form').submit() $('#export').click(export_sample_table_data) - + ##End Export Sample Table Data Code @@ -344,7 +352,7 @@ $ -> console.log("after registering block_outliers") _.mixin(_.str.exports()); # Add string fuctions directly to underscore - $('#value_table').change(edit_data_change) + $('#edit_sample_lists').change(edit_data_change) console.log("loaded") #console.log("basic_table is:", basic_table) # Add back following two lines later diff --git a/wqflask/wqflask/static/new/javascript/show_trait.js b/wqflask/wqflask/static/new/javascript/show_trait.js index 919bc766..84282aef 100644 --- a/wqflask/wqflask/static/new/javascript/show_trait.js +++ b/wqflask/wqflask/static/new/javascript/show_trait.js @@ -53,7 +53,7 @@ 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"]; + _ref1 = ["mean", "median", "std_dev", "std_error", "min", "max"]; _results1 = []; for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { stat = _ref1[_j]; @@ -126,6 +126,12 @@ }, { vn: "std_dev", pretty: "Standard Deviation (SD)" + }, { + vn: "min", + pretty: "Minimum" + }, { + vn: "max", + pretty: "Maximum" } ]; console.log("rows are:", rows); @@ -362,7 +368,7 @@ $('#block_outliers').click(block_outliers); console.log("after registering block_outliers"); _.mixin(_.str.exports()); - $('#value_table').change(edit_data_change); + $('#edit_sample_lists').change(edit_data_change); console.log("loaded"); make_table(); edit_data_change(); diff --git a/wqflask/wqflask/static/new/javascript/stats.coffee b/wqflask/wqflask/static/new/javascript/stats.coffee index 677dc258..118ee7a8 100644 --- a/wqflask/wqflask/static/new/javascript/stats.coffee +++ b/wqflask/wqflask/static/new/javascript/stats.coffee @@ -1,20 +1,20 @@ class Stats constructor: (@the_values) -> - + add_value: (value) -> @the_values.push(value) - + n_of_samples: -> return @the_values.length - + sum: -> total = 0 total += value for value in @the_values return total - + mean: -> return @sum() / @n_of_samples() - + median: -> is_odd = @the_values.length % 2 median_position = Math.floor(@the_values.length / 2) @@ -24,7 +24,7 @@ class Stats else return (the_values_sorted[median_position] + the_values_sorted[median_position - 1]) / 2 - + std_dev: -> sum = 0 for value in @the_values @@ -32,15 +32,22 @@ class Stats sum += step_a step_b = sum / @the_values.length return Math.sqrt(step_b) - + std_error: -> return @std_dev() / Math.sqrt(@n_of_samples()) + min: -> + return Math.min(@the_values...) + + max: -> + return Math.max(@the_values...) + bxd_only = new Stats([3, 5, 7, 8]) -console.log("[red] bxd_only mean:", bxd_only.mean()) -console.log("[green] bxd_only median:", bxd_only.median()) -console.log("[purple] bxd_only std_dev:", bxd_only.std_dev()) -console.log("[magenta] bxd_only std_error:", bxd_only.std_error()) +console.log("[xred] bxd_only mean:", bxd_only.mean()) +console.log("[xgreen] bxd_only median:", bxd_only.median()) +console.log("[xpurple] bxd_only std_dev:", bxd_only.std_dev()) +console.log("[xmagenta] bxd_only std_error:", bxd_only.std_error()) +console.log("[xyellow] bxd_only min:", bxd_only.min()) -window.Stats = Stats \ No newline at end of file +window.Stats = Stats diff --git a/wqflask/wqflask/static/new/javascript/stats.js b/wqflask/wqflask/static/new/javascript/stats.js index f95d03d4..620f7d5d 100644 --- a/wqflask/wqflask/static/new/javascript/stats.js +++ b/wqflask/wqflask/static/new/javascript/stats.js @@ -62,19 +62,29 @@ return this.std_dev() / Math.sqrt(this.n_of_samples()); }; + Stats.prototype.min = function() { + return Math.min.apply(Math, this.the_values); + }; + + Stats.prototype.max = function() { + return Math.max.apply(Math, this.the_values); + }; + return Stats; })(); bxd_only = new Stats([3, 5, 7, 8]); - console.log("[red] bxd_only mean:", bxd_only.mean()); + console.log("[xred] bxd_only mean:", bxd_only.mean()); + + console.log("[xgreen] bxd_only median:", bxd_only.median()); - console.log("[green] bxd_only median:", bxd_only.median()); + console.log("[xpurple] bxd_only std_dev:", bxd_only.std_dev()); - console.log("[purple] bxd_only std_dev:", bxd_only.std_dev()); + console.log("[xmagenta] bxd_only std_error:", bxd_only.std_error()); - console.log("[magenta] bxd_only std_error:", bxd_only.std_error()); + console.log("[xyellow] bxd_only min:", bxd_only.min()); window.Stats = Stats; diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html index 35ff4e8e..11f68bba 100644 --- a/wqflask/wqflask/templates/search_result_page.html +++ b/wqflask/wqflask/templates/search_result_page.html @@ -51,9 +51,9 @@
    + dataset = dataset.name + )}}"> {{ this_trait.name }}
    -
    +
    {% for sample_type in sample_groups %}

    {{ sample_type.header }}

    -- cgit v1.2.3 From ef26532ba2792afdcca65d5f5f3c03f93a33f1ae Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Fri, 7 Dec 2012 15:04:44 -0600 Subject: Got basic statistics in show_trait to display the correct number of samples for each group Got show_trait page to display for genotype traits --- wqflask/base/trait.py | 102 +-------------------- wqflask/wqflask/do_search.py | 18 ++-- wqflask/wqflask/parser.py | 17 ++++ wqflask/wqflask/search_results.py | 23 ----- wqflask/wqflask/show_trait/show_trait.py | 50 +++++----- .../static/new/javascript/show_trait.coffee | 22 ++--- .../wqflask/static/new/javascript/show_trait.js | 12 ++- 7 files changed, 72 insertions(+), 172 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py index d0158ebd..8c9e3b10 100755 --- a/wqflask/base/trait.py +++ b/wqflask/base/trait.py @@ -258,113 +258,15 @@ class GeneralTrait: #else: results = self.dataset.retrieve_sample_data(self) - #if self.dataset.type == 'Temp': - # query = ''' - # SELECT - # Strain.Name, TempData.value, TempData.SE, TempData.NStrain, TempData.Id - # FROM - # TempData, Temp, Strain - # WHERE - # TempData.StrainId = Strain.Id AND - # TempData.Id = Temp.DataId AND - # Temp.name = '%s' - # Order BY - # Strain.Name - # ''' % self.name - ##XZ, 03/02/2009: Xiaodong changed Data to PublishData, SE to PublishSE - #elif self.dataset.type == 'Publish': - # query = ''' - # SELECT - # Strain.Name, PublishData.value, PublishSE.error, NStrain.count, PublishData.Id - # FROM - # (PublishData, Strain, PublishXRef, PublishFreeze) - # left join PublishSE on - # (PublishSE.DataId = PublishData.Id AND PublishSE.StrainId = PublishData.StrainId) - # left join NStrain on - # (NStrain.DataId = PublishData.Id AND - # NStrain.StrainId = PublishData.StrainId) - # WHERE - # PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND - # PublishData.Id = PublishXRef.DataId AND PublishXRef.Id = %s AND - # PublishFreeze.Id = %d AND PublishData.StrainId = Strain.Id - # Order BY - # Strain.Name - # ''' % (self.name, self.dataset.id) - - #XZ, 03/02/2009: Xiaodong changed Data to ProbeData, SE to ProbeSE - #elif self.cellid: - - #XZ, 03/02/2009: Xiaodong added this block for ProbeSetData and ProbeSetSE - #elif self.dataset.type == 'ProbeSet': - # #ProbeSet Data - # query = ''' - # SELECT - # Strain.Name, ProbeSetData.value, ProbeSetSE.error, ProbeSetData.Id - # FROM - # (ProbeSetData, ProbeSetFreeze, Strain, ProbeSet, ProbeSetXRef) - # left join ProbeSetSE on - # (ProbeSetSE.DataId = ProbeSetData.Id AND ProbeSetSE.StrainId = ProbeSetData.StrainId) - # WHERE - # ProbeSet.Name = '%s' AND ProbeSetXRef.ProbeSetId = ProbeSet.Id AND - # ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id AND - # ProbeSetFreeze.Name = '%s' AND - # ProbeSetXRef.DataId = ProbeSetData.Id AND - # ProbeSetData.StrainId = Strain.Id - # Order BY - # Strain.Name - # ''' % (self.name, self.dataset.name) - ##XZ, 03/02/2009: Xiaodong changeded Data to GenoData, SE to GenoSE - #else: - # #Geno Data - # #XZ: The SpeciesId is not necessary, but it's nice to keep it to speed up database search. - # query = ''' - # SELECT - # Strain.Name, GenoData.value, GenoSE.error, GenoData.Id - # FROM - # (GenoData, GenoFreeze, Strain, Geno, GenoXRef) - # left join GenoSE on - # (GenoSE.DataId = GenoData.Id AND GenoSE.StrainId = GenoData.StrainId) - # WHERE - # Geno.SpeciesId = %s AND Geno.Name = '%s' AND GenoXRef.GenoId = Geno.Id AND - # GenoXRef.GenoFreezeId = GenoFreeze.Id AND - # GenoFreeze.Name = '%s' AND - # GenoXRef.DataId = GenoData.Id AND - # GenoData.StrainId = Strain.Id - # Order BY - # Strain.Name - # ''' % (webqtlDatabaseFunction.retrieveSpeciesId(self.cursor, self.dataset.group), self.name, self.dataset.name) - - - #self.cursor.execute(query) - #results = self.cursor.fetchall() - # Todo: is this necessary? If not remove self.data.clear() if results: - #self.mysqlid = results[0][-1] - #if samplelist: for item in results: #name, value, variance, num_cases = item if not samplelist or (samplelist and name in samplelist): - #if value != None: - # num_cases = None - # if self.dataset.type in ('Publish', 'Temp'): - # ndata = item[3] name = item[0] self.data[name] = webqtlCaseData(*item) #name, value, variance, num_cases) - #end for - # else: - # for item in results: - # val = item[1] - # if val != None: - # var = item[2] - # ndata = None - # if self.dataset.type in ('Publish', 'Temp'): - # ndata = item[3] - # self.data[item[0]] = webqtlCaseData(val, var, ndata) - # #end for - # #end if #def keys(self): # return self.__dict__.keys() @@ -429,7 +331,9 @@ class GeneralTrait: GenoXRef.GenoId = Geno.Id AND GenoFreeze.Name = '%s' AND Geno.Name = '%s' - """ % (escape(display_fields_string), escape(self.dataset.name), escape(self.name)) + """ % (escape(display_fields_string), + escape(self.dataset.name), + escape(self.name)) traitInfo = g.db.execute(query).fetchone() print("traitInfo is: ", pf(traitInfo)) else: #Temp type diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py index 3ce613e9..fc45395c 100644 --- a/wqflask/wqflask/do_search.py +++ b/wqflask/wqflask/do_search.py @@ -60,7 +60,7 @@ class DoSearch(object): return cls.search_types[search_type] -class ProbeSetSearch(DoSearch): +class MrnaAssaySearch(DoSearch): """A search within an mRNA expression dataset""" DoSearch.search_types['ProbeSet'] = "ProbeSetSearch" @@ -265,7 +265,7 @@ class GenotypeSearch(DoSearch): return self.execute(self.query) -class RifSearch(ProbeSetSearch): +class RifSearch(MrnaAssaySearch): """Searches for traits with a Gene RIF entry including the search term.""" DoSearch.search_types['RIF'] = "RifSearch" @@ -280,7 +280,7 @@ class RifSearch(ProbeSetSearch): return self.execute(query) -class WikiSearch(ProbeSetSearch): +class WikiSearch(MrnaAssaySearch): """Searches GeneWiki for traits other people have annotated""" DoSearch.search_types['WIKI'] = "WikiSearch" @@ -298,7 +298,7 @@ class WikiSearch(ProbeSetSearch): return self.execute(query) -class GoSearch(ProbeSetSearch): +class GoSearch(MrnaAssaySearch): """Searches for synapse-associated genes listed in the Gene Ontology.""" DoSearch.search_types['GO'] = "GoSearch" @@ -323,7 +323,7 @@ class GoSearch(ProbeSetSearch): return self.execute(query) #ZS: Not sure what the best way to deal with LRS searches is -class LrsSearch(ProbeSetSearch): +class LrsSearch(MrnaAssaySearch): """Searches for genes with a QTL within the given LRS values LRS searches can take 3 different forms: @@ -484,7 +484,7 @@ class TransLrsSearch(CisTransLrsSearch): return self.real_run(">") -class MeanSearch(ProbeSetSearch): +class MeanSearch(MrnaAssaySearch): """Searches for genes expressed within an interval (log2 units) determined by the user""" DoSearch.search_types['MEAN'] = "MeanSearch" @@ -514,7 +514,7 @@ class MeanSearch(ProbeSetSearch): return self.execute(self.query) -class RangeSearch(ProbeSetSearch): +class RangeSearch(MrnaAssaySearch): """Searches for genes with a range of expression varying between two values""" DoSearch.search_types['RANGE'] = "RangeSearch" @@ -571,7 +571,7 @@ class PositionSearch(DoSearch): return self.execute(self.query) -class MrnaPositionSearch(ProbeSetSearch, PositionSearch): +class MrnaPositionSearch(MrnaAssaySearch, PositionSearch): """Searches for genes located within a specified range on a specified chromosome""" def run(self): @@ -591,7 +591,7 @@ class GenotypePositionSearch(GenotypeSearch, PositionSearch): return self.execute(self.query) -class PvalueSearch(ProbeSetSearch): +class PvalueSearch(MrnaAssaySearch): """Searches for traits with a permutationed p-value between low and high""" def run(self): diff --git a/wqflask/wqflask/parser.py b/wqflask/wqflask/parser.py index f991d8c7..be92014d 100644 --- a/wqflask/wqflask/parser.py +++ b/wqflask/wqflask/parser.py @@ -73,6 +73,23 @@ def parse(pstring): print("* items are:", pf(items) + "\n") return(items) + #def encregexp(self,str): + # if not str: + # return [] + # else: + # wildcardkeyword = str.strip() + # wildcardkeyword = string.replace(wildcardkeyword,',',' ') + # wildcardkeyword = string.replace(wildcardkeyword,';',' ') + # wildcardkeyword = wildcardkeyword.split() + # NNN = len(wildcardkeyword) + # for i in range(NNN): + # keyword = wildcardkeyword[i] + # keyword = string.replace(keyword,"*",".*") + # keyword = string.replace(keyword,"?",".") + # wildcardkeyword[i] = keyword#'[[:<:]]'+ keyword+'[[:>:]]' + # return wildcardkeyword + + if __name__ == '__main__': parse("foo=[3 2 1]") parse("WIKI=ho*") diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index 5cb8e314..d986a2e0 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -54,11 +54,6 @@ class SearchResultPage(templatePage): # change back to self.dataset #if not self.dataset or self.dataset == 'spacer': # #Error, No dataset selected - # heading = "Search Result" - # detail = ['''No dataset was selected for this search, please - # go back and SELECT at least one dataset.'''] - # self.error(heading=heading,detail=detail,error="No dataset Selected") - # return ########################################### # Names and IDs of group / F2 set @@ -144,21 +139,3 @@ class SearchResultPage(templatePage): print("in the search results are:", self.results) self.header_fields = the_search.header_fields - - - #ZS: This should be handled in the parser - def encregexp(self,str): - if not str: - return [] - else: - wildcardkeyword = str.strip() - wildcardkeyword = string.replace(wildcardkeyword,',',' ') - wildcardkeyword = string.replace(wildcardkeyword,';',' ') - wildcardkeyword = wildcardkeyword.split() - NNN = len(wildcardkeyword) - for i in range(NNN): - keyword = wildcardkeyword[i] - keyword = string.replace(keyword,"*",".*") - keyword = string.replace(keyword,"?",".") - wildcardkeyword[i] = keyword#'[[:<:]]'+ keyword+'[[:>:]]' - return wildcardkeyword diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index 0f593216..836d37ea 100755 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -828,35 +828,34 @@ class ShowTrait(object): elif this_trait and this_trait.dataset and this_trait.dataset.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" + #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", @@ -872,7 +871,7 @@ class ShowTrait(object): # valign="top", width=740) # )) - menuTable = HT.TableLite(cellpadding=2, Class="collap", width="275", id="target1") + #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;")) @@ -1629,7 +1628,6 @@ class ShowTrait(object): header="%s Only" % (self.dataset.group.name)) print("primary_samples is: ", pf(primary_samples)) - other_sample_names = [] for sample in this_trait.data.keys(): if sample not in all_samples_ordered: diff --git a/wqflask/wqflask/static/new/javascript/show_trait.coffee b/wqflask/wqflask/static/new/javascript/show_trait.coffee index 278a134b..04d55be7 100644 --- a/wqflask/wqflask/static/new/javascript/show_trait.coffee +++ b/wqflask/wqflask/static/new/javascript/show_trait.coffee @@ -110,6 +110,7 @@ $ -> change_stats_value(sample_sets, category, row.vn, row.digits) edit_data_change = -> + already_seen = {} sample_sets = samples_primary: new Stats([]) samples_other: new Stats([]) @@ -117,21 +118,14 @@ $ -> console.log("at beginning:", sample_sets) - # ########## - # Bug here #value_table doesn't exist and why is it a class? - # ########## - - #values = $('.value_table').find(".edit_sample_value") - - tables = ['samples_primary', 'samples_other'] for table in tables rows = $("#" + table).find('tr') console.log("[fuji3] rows:", rows) for row in rows + name = $(row).find('.edit_sample_sample_name').html() + name = $.trim(name) real_value = $(row).find('.edit_sample_value').val() - #row = $(value).closest("tr") - #category = row[0].id console.log("real_value:", real_value) checkbox = $(row).find(".edit_sample_checkbox") checked = $(checkbox).attr('checked') @@ -139,11 +133,13 @@ $ -> if checked and is_number(real_value) and real_value != "" console.log("in the iffy if") real_value = parseFloat(real_value) - #if _(category).startsWith("Primary") + sample_sets[table].add_value(real_value) - #else if _(category).startsWith("Other") - # sample_sets.other_only.add_value(real_value) - sample_sets['samples_all'].add_value(real_value) + console.log("checking name of:", name) + if not (name of already_seen) + console.log("haven't seen") + sample_sets['samples_all'].add_value(real_value) + already_seen[name] = true console.log("towards end:", sample_sets) update_stat_values(sample_sets) diff --git a/wqflask/wqflask/static/new/javascript/show_trait.js b/wqflask/wqflask/static/new/javascript/show_trait.js index 3a7bc387..1037c890 100644 --- a/wqflask/wqflask/static/new/javascript/show_trait.js +++ b/wqflask/wqflask/static/new/javascript/show_trait.js @@ -115,7 +115,8 @@ return _results; }; edit_data_change = function() { - var checkbox, checked, real_value, row, rows, sample_sets, table, tables, _i, _j, _len, _len1; + var already_seen, checkbox, checked, name, real_value, row, rows, sample_sets, table, tables, _i, _j, _len, _len1; + already_seen = {}; sample_sets = { samples_primary: new Stats([]), samples_other: new Stats([]), @@ -129,6 +130,8 @@ console.log("[fuji3] rows:", rows); for (_j = 0, _len1 = rows.length; _j < _len1; _j++) { row = rows[_j]; + name = $(row).find('.edit_sample_sample_name').html(); + name = $.trim(name); real_value = $(row).find('.edit_sample_value').val(); console.log("real_value:", real_value); checkbox = $(row).find(".edit_sample_checkbox"); @@ -137,7 +140,12 @@ console.log("in the iffy if"); real_value = parseFloat(real_value); sample_sets[table].add_value(real_value); - sample_sets['samples_all'].add_value(real_value); + console.log("checking name of:", name); + if (!(name in already_seen)) { + console.log("haven't seen"); + sample_sets['samples_all'].add_value(real_value); + already_seen[name] = true; + } } } } -- cgit v1.2.3 From daea7eb0eb4eef445140275522703e7e2214154b Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Tue, 18 Dec 2012 17:15:09 -0600 Subject: Created new file species.py and species class object TheSpecies Converted html for the mapping tabs to bootstrap and redid html inside of the Interval Mapping tab Added text input for # of permutation tests and bootstrap tests --- wqflask/base/data_set.py | 8 +- wqflask/base/species.py | 16 + wqflask/wqflask/show_trait/show_trait.py | 3 +- .../templates/show_trait_mapping_tools.html | 551 +++++++-------------- wqflask/wqflask/views.py | 8 + 5 files changed, 218 insertions(+), 368 deletions(-) create mode 100644 wqflask/base/species.py (limited to 'wqflask/base') diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 2182fe9e..612b9209 100755 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -30,6 +30,7 @@ from htmlgen import HTMLgen2 as HT import reaper import webqtlConfig +from base import species from dbFunction import webqtlDatabaseFunction from utility import webqtlUtil @@ -145,7 +146,7 @@ class DataSet(object): def __init__(self, name): - assert name + assert name, "Need a name" self.name = name self.id = None self.type = None @@ -155,7 +156,10 @@ class DataSet(object): self.check_confidentiality() self.retrieve_other_names() - self.group = DatasetGroup(self) # sets self.group and self.group_id + + self.species = species.TheSpecies(self) + self.group = DatasetGroup(self) # sets self.group and self.group_id and gets genotype + def get_desc(self): diff --git a/wqflask/base/species.py b/wqflask/base/species.py new file mode 100644 index 00000000..98941ce5 --- /dev/null +++ b/wqflask/base/species.py @@ -0,0 +1,16 @@ +from __future__ import print_function, division + + +class TheSpecies(object): + def __init__(self, dataset): + self.dataset = dataset + + @property + def chromosomes(self): + chromosomes = [("All", -1)] + + for counter, genotype in enumerate(self.dataset.group.genotype): + if len(genotype) > 1: + chromosomes.append((genotype.name, counter)) + + return chromosomes diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index 836d37ea..c605cb58 100755 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -1354,7 +1354,8 @@ class ShowTrait(object): return_results_menu_selected = return_results_menu_selected,) - def dispMappingTools(self, fd, title4Body, this_trait): + def build_mapping_tools(self, this_trait): + _Species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, group=fd.group) diff --git a/wqflask/wqflask/templates/show_trait_mapping_tools.html b/wqflask/wqflask/templates/show_trait_mapping_tools.html index 90498e9a..1109ded3 100644 --- a/wqflask/wqflask/templates/show_trait_mapping_tools.html +++ b/wqflask/wqflask/templates/show_trait_mapping_tools.html @@ -1,382 +1,203 @@ -

      Mapping Tools

    - -

    - - - -
    -
    - - -
    - - - - - - +
    +

    Mapping Tools

    + +
    + + +
    +
    + + +
    + {% if dataset.group.genotype.Mbmap %} + + + {% endif %} +
    + + + + +
    + + +
    + +
    +
    +
    - - - - - - - - - - - - -
    Chromosome:
    Mapping Scale:

    - Permutation Test (n=2000)
    - Bootstrap Test (n=2000)
    - Use Parents
    - Use Weighted
    -
    -
    -
    -
    + + + + + + + +
    + + + + + + + + + + + + + + + + + + +
    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.

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

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

    +
    +
    + + + + diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 70d8cd20..503b0972 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -160,6 +160,14 @@ def corr_compute_page(): print("Made it to rendering") return render_template("correlation_page.html", **template_vars.__dict__) +@app.route("/int_mapping", methods=('POST',)) +def interval_mapping_page(): + fd = webqtlFormData.webqtlFormData(request.form) + print("Have fd") + template_vars = CorrelationPage.CorrelationPage(fd) + print("Made it to rendering") + return render_template("correlation_page.html", **template_vars.__dict__) + # Todo: Can we simplify this? -Sam def sharing_info_page(): -- cgit v1.2.3 From 25fccfb3447012c3f2a75e3f54520e700d801487 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Thu, 3 Jan 2013 15:54:53 -0600 Subject: Created template for marek regression page and made the compute button direct to it added asbolute_import in data_set.py and trait.py Made several minor changes and deleted commented out code in trait.py --- wqflask/base/data_set.py | 7 +- wqflask/base/trait.py | 78 +++--------- wqflask/wqflask/do_search.py | 2 +- wqflask/wqflask/show_trait/show_trait.py | 133 +++++---------------- .../new/javascript/show_trait_mapping_tools.coffee | 18 ++- .../new/javascript/show_trait_mapping_tools.js | 15 ++- wqflask/wqflask/templates/marker_regression.html | 51 ++++++++ .../templates/show_trait_mapping_tools.html | 8 +- wqflask/wqflask/views.py | 63 +++++----- 9 files changed, 160 insertions(+), 215 deletions(-) create mode 100644 wqflask/wqflask/templates/marker_regression.html (limited to 'wqflask/base') diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 612b9209..36d4acaf 100755 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -16,11 +16,11 @@ # Contact Drs. Robert W. Williams and Xiaodong Zhou (2010) # at rwilliams@uthsc.edu and xzhou15@uthsc.edu # -# +#we # # This module is used by GeneNetwork project (www.genenetwork.org) -from __future__ import print_function, division +from __future__ import absolute_import, print_function, division import os from flask import Flask, g @@ -29,7 +29,7 @@ from htmlgen import HTMLgen2 as HT import reaper -import webqtlConfig +from base import webqtlConfig from base import species from dbFunction import webqtlDatabaseFunction from utility import webqtlUtil @@ -50,6 +50,7 @@ def create_dataset(dataset_name): WHERE DBList.Name = '%s' and DBType.Id = DBList.DBTypeId """ % (escape(dataset_name)) + print("query is: ", pf(query)) dataset_type = g.db.execute(query).fetchone().Name #dataset_type = cursor.fetchone()[0] diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py index 8c9e3b10..241bf2ab 100755 --- a/wqflask/base/trait.py +++ b/wqflask/base/trait.py @@ -1,12 +1,12 @@ -from __future__ import division, print_function +from __future__ import absolute_import, division, print_function import string from htmlgen import HTMLgen2 as HT -import webqtlConfig -from webqtlCaseData import webqtlCaseData -from data_set import create_dataset +from base import webqtlConfig +from base.webqtlCaseData import webqtlCaseData +from base.data_set import create_dataset from dbFunction import webqtlDatabaseFunction from utility import webqtlUtil @@ -24,76 +24,28 @@ class GeneralTrait: def __init__(self, **kw): print("in GeneralTrait") - self.dataset = kw.get('dataset', None) # database name - self.name = kw.get('name', None) # Trait ID, ProbeSet ID, Published ID, etc. - self.cellid = kw.get('cellid', None) + self.dataset = kw.get('dataset') # database name + self.name = kw.get('name') # Trait ID, ProbeSet ID, Published ID, etc. + self.cellid = kw.get('cellid') self.identification = kw.get('identification', 'un-named trait') - #self.group = kw.get('group', None) self.haveinfo = kw.get('haveinfo', False) - self.sequence = kw.get('sequence', None) # Blat sequence, available for ProbeSet + self.sequence = kw.get('sequence') # Blat sequence, available for ProbeSet self.data = kw.get('data', {}) - + if kw.get('fullname'): name2 = value.split("::") if len(name2) == 2: self.dataset, self.name = name2 + # self.cellid is set to None above elif len(name2) == 3: self.dataset, self.name, self.cellid = name2 - - #if self.dataset and isinstance(self.dataset, basestring): - self.dataset = create_dataset(self.dataset) - print("self.dataset is:", self.dataset, type(self.dataset)) - #if self.dataset: - - #self.dataset.get_group() + self.dataset = create_dataset(self.dataset) - #if self.dataset.type == "Temp": - # self.cursor.execute(''' - # SELECT - # InbredSet.Name - # FROM - # InbredSet, Temp - # WHERE - # Temp.InbredSetId = InbredSet.Id AND - # Temp.Name = "%s" - # ''', self.name) - # self.group = self.cursor.fetchone()[0] - #else: - # self.group = self.dataset.get_group() - - #print("trinity, self.group is:", self.group) - - # - # In ProbeSet, there are maybe several annotations match one sequence - # so we need use sequence(BlatSeq) as the identification, when we update - # one annotation, we update the others who match the sequence also. - # - # Hongqiang Li, 3/3/2008 - # - - #XZ, 05/08/2009: This block is not neccessary. We can add 'BlatSeq' into disfield. - # The variable self.sequence should be changed to self.BlatSeq - # It also should be changed in other places where it are used. - - #if self.dataset: - #if self.dataset.type == 'ProbeSet': - # print("Doing ProbeSet Query") - # query = ''' - # SELECT - # ProbeSet.BlatSeq - # FROM - # ProbeSet, ProbeSetFreeze, ProbeSetXRef - # WHERE - # ProbeSet.Id=ProbeSetXRef.ProbeSetId and - # ProbeSetFreeze.Id = ProbeSetXRef.ProbeSetFreezeId and - # ProbeSet.Name = %s and - # ProbeSetFreeze.Name = %s - # ''', (self.name, self.dataset.name) - # print("query is:", query) - # self.sequence = g.db.execute(*query).fetchone()[0] - # #self.sequence = self.cursor.fetchone()[0] - # print("self.sequence is:", self.sequence) + # Todo: These two lines are necessary most of the time, but perhaps not all of the time + # So we could add a simple if statement to short-circuit this if necessary + self.retrieve_info() + self.retrieve_sample_data() def get_name(self): diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py index fc45395c..a2eddfc6 100644 --- a/wqflask/wqflask/do_search.py +++ b/wqflask/wqflask/do_search.py @@ -63,7 +63,7 @@ class DoSearch(object): class MrnaAssaySearch(DoSearch): """A search within an mRNA expression dataset""" - DoSearch.search_types['ProbeSet'] = "ProbeSetSearch" + DoSearch.search_types['ProbeSet'] = "MrnaAssaySearch" base_query = """SELECT ProbeSet.Name as TNAME, 0 as thistable, diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index c605cb58..807761a2 100755 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -34,45 +34,26 @@ from pprint import pformat as pf class ShowTrait(object): - def __init__(self, args): - print("in ShowTrait, args are:", args) - #self.group = args.group - self.trait_id = args['trait_id'] + def __init__(self, kw): + print("in ShowTrait, kw are:", kw) + self.trait_id = kw['trait_id'] - self.dataset = create_dataset(args['dataset']) - - #self.dataset = create_dataset(args['dataset']) - self.cell_id = None + self.dataset = create_dataset(kw['dataset']) + + #self.cell_id = None - #assert self.openMysql(), "No database!" - #print("red3 fd.group:", fd.group) - this_trait = self.get_this_trait() + this_trait = GeneralTrait(dataset=self.dataset.name, + name=self.trait_id, + cellid=None) - #print("red4 fd.group:", fd.group) - ##read genotype file - #fd.group = this_trait.group - #print("[red5] fd.group is:", fd.group) self.dataset.group.read_genotype_file() - #fd.readGenotype() if not self.dataset.group.genotype: - self.read_data(include_f1=True) #incf1=1) + self.read_data(include_f1=True) - ## 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' - + # Todo: Add back in the ones we actually need from below, as we discover we need them hddn = OrderedDict() @@ -111,55 +92,19 @@ class ShowTrait(object): # export_data = None # ) - #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.dataset and this_trait.dataset.type and this_trait.dataset.type == 'ProbeSet': - # hddn['trait_type'] = this_trait.dataset.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.group) - # - #if fd.identification: - # hddn['identification'] = fd.identification - #else: - # hddn['identification'] = "Un-named trait" #If no identification, set identification to un-named - - self.dispTraitInformation(args, "", hddn, this_trait) #Display trait information + function buttons - if this_trait == None: - this_trait = webqtlTrait(data=args['allTraitData'], dataset=None) + self.dispTraitInformation(kw, "", hddn, this_trait) #Display trait information + function buttons - ## 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) + #if this_trait == None: + # this_trait = webqtlTrait(data=kw['allTraitData'], dataset=None) self.build_correlation_tools(this_trait) @@ -168,9 +113,6 @@ class ShowTrait(object): if self.dataset.group.allsamples: hddn['allsamples'] = string.join(self.dataset.group.allsamples, ' ') - #if args['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 @@ -188,34 +130,23 @@ class ShowTrait(object): self.js_data = js_data - def get_this_trait(self): - # When is traitInfos used? - #if traitInfos: - # database, ProbeSetID, CellID = traitInfos - #else: - #dataset = self.fd['dataset'] - #trait_id = self.fd['trait_id'] - #cell_id = self.fd.get('CellID') - - this_trait = GeneralTrait(dataset=self.dataset.name, - name=self.trait_id, - cellid=self.cell_id) - - ##identification, etc. - self.identification = '%s : %s' % (self.dataset.shortname, self.trait_id) - this_trait.returnURL = webqtlConfig.CGIDIR + webqtlConfig.SCRIPTFILE + '?FormID=showDatabase&database=%s\ - &ProbeSetID=%s&group=%s&parentsf1=on' %(self.dataset, self.trait_id, self.dataset.group.name) - - if self.cell_id: - self.identification = '%s/%s'%(self.identification, self.cell_id) - this_trait.returnURL = '%s&CellID=%s' % (this_trait.returnURL, self.cell_id) - - print("yellow1:", self.dataset.group) - this_trait.retrieve_info() - print("yellow2:", self.dataset.group) - this_trait.retrieve_sample_data() - print("yellow3:", self.dataset.group) - return this_trait + #def get_this_trait(self): + # this_trait = GeneralTrait(dataset=self.dataset.name, + # name=self.trait_id, + # cellid=self.cell_id) + # + # ###identification, etc. + # #self.identification = '%s : %s' % (self.dataset.shortname, self.trait_id) + # #this_trait.returnURL = webqtlConfig.CGIDIR + webqtlConfig.SCRIPTFILE + '?FormID=showDatabase&database=%s\ + # # &ProbeSetID=%s&group=%s&parentsf1=on' %(self.dataset, self.trait_id, self.dataset.group.name) + # # + # #if self.cell_id: + # # self.identification = '%s/%s'%(self.identification, self.cell_id) + # # this_trait.returnURL = '%s&CellID=%s' % (this_trait.returnURL, self.cell_id) + # + # this_trait.retrieve_info() + # this_trait.retrieve_sample_data() + # return this_trait def read_data(self, include_f1=False): diff --git a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.coffee b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.coffee index b1f5b186..d0fc869d 100644 --- a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.coffee +++ b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.coffee @@ -1,11 +1,17 @@ $ -> - run_marker_regression = -> - console.log("In marker regression") - url = "/marker_regression" + submit_special = -> + # Add submit_special class plus a data-url field to any button + # And it will submit to that url + # No js changes necessary + console.log("In submit_special") + console.log("this is:", this) + console.log("$(this) is:", $(this)) + url = $(this).data("url") + console.log("url is:", url) $("#trait_data_form").attr("action", url); $("#trait_data_form").submit() - $("#do_marker_regression").click(run_marker_regression) + $(".submit_special").click(submit_special) composite_mapping_fields = -> @@ -14,10 +20,10 @@ $ -> $("#use_composite_choice").change(composite_mapping_fields) + #### Todo: Redo below so its like submit_special and requires no js hardcoding toggle_enable_disable = (elem) -> - $(elem).prop("disabled", !$(elem.prop("disabled"))) + $(elem).prop("disabled", !$(elem).prop("disabled")) - $("#choose_closet_control").change(-> toggle_enable_disable("#control_locus") ) diff --git a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js index c8328498..c6766288 100644 --- a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js +++ b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js @@ -2,21 +2,24 @@ (function() { $(function() { - var composite_mapping_fields, run_marker_regression, toggle_enable_disable; - run_marker_regression = function() { + var composite_mapping_fields, submit_special, toggle_enable_disable; + submit_special = function() { var url; - console.log("In marker regression"); - url = "/marker_regression"; + console.log("In submit_special"); + console.log("this is:", this); + console.log("$(this) is:", $(this)); + url = $(this).data("url"); + console.log("url is:", url); $("#trait_data_form").attr("action", url); return $("#trait_data_form").submit(); }; - $("#do_marker_regression").click(run_marker_regression); + $(".submit_special").click(submit_special); composite_mapping_fields = function() { return $(".composite_fields").toggle(); }; $("#use_composite_choice").change(composite_mapping_fields); toggle_enable_disable = function(elem) { - return $(elem).prop("disabled", !$(elem.prop("disabled"))); + return $(elem).prop("disabled", !$(elem).prop("disabled")); }; $("#choose_closet_control").change(function() { return toggle_enable_disable("#control_locus"); diff --git a/wqflask/wqflask/templates/marker_regression.html b/wqflask/wqflask/templates/marker_regression.html new file mode 100644 index 00000000..db2de604 --- /dev/null +++ b/wqflask/wqflask/templates/marker_regression.html @@ -0,0 +1,51 @@ +{% extends "base.html" %} +{% block title %}Marker Regression{% endblock %} +{% block content %} + +
    +
    +

    Marker Regression

    +

    + {{ this_trait.name }}: {{ this_trait.description_fmt }} +

    +
    +
    + +
    +
    Aliases
    +
    {{ this_trait.alias_fmt }}
    + +
    Location
    +
    {{ this_trait.location_fmt }}
    + +
    Database
    +
    + + {{ dataset.name }} + +
    + + {% if this_trait.probe_set_specificity %} +
    + + BLAT Specifity + +
    +
    {{ "%.1f" % (this_trait.probe_set_specificity) }}
    + {% endif %} + {% if this_trait.probe_set_blat_score %} +
    BLAT Score
    +
    {{ "%i" % (this_trait.probe_set_blat_score) }}
    + {% endif %} +
    + + + +{% endblock %} + +{% block js %} + +{% endblock %} \ No newline at end of file diff --git a/wqflask/wqflask/templates/show_trait_mapping_tools.html b/wqflask/wqflask/templates/show_trait_mapping_tools.html index 8436703d..72b152fa 100644 --- a/wqflask/wqflask/templates/show_trait_mapping_tools.html +++ b/wqflask/wqflask/templates/show_trait_mapping_tools.html @@ -101,7 +101,8 @@
    - @@ -135,8 +136,9 @@
    -
    diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 503b0972..f6c0dfb0 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -18,6 +18,7 @@ from flask import render_template, request, make_response, Response, Flask, g, c from wqflask import search_results from wqflask.show_trait import show_trait from wqflask.show_trait import export_trait_data +from wqflask.marker_regression import marker_regression from wqflask.correlation import CorrelationPage from wqflask.dataSharing import SharingInfo, SharingInfoPage @@ -89,27 +90,6 @@ def whats_new_page(): print("\nnews_item is: %s\n" % (news_item)) return render_template("whats_new.html", news_items=news_items) - -@app.route("/show_trait") -def show_trait_page(): - # Here it's currently too complicated not to use an fd that is a webqtlFormData - #fd = webqtlFormData.webqtlFormData(request.args) - #print("stp y1:", pf(vars(fd))) - template_vars = show_trait.ShowTrait(request.args) - - print("js_data before dump:", template_vars.js_data) - - template_vars.js_data = json.dumps(template_vars.js_data, - default=json_default_handler, - indent=" ") - # Sorting the keys messes up the ordered dictionary, so don't do that - #sort_keys=True) - - print("js_data after dump:", template_vars.js_data) - - print("show_trait template_vars:", pf(template_vars.__dict__)) - return render_template("show_trait.html", **template_vars.__dict__) - @app.route('/export_trait_csv', methods=('POST',)) def export_trait_excel(): """Excel file consisting of the sample data from the trait data and analysis page""" @@ -150,33 +130,52 @@ def export_trait_csv(): mimetype='text/csv', headers={"Content-Disposition":"attachment;filename=test.csv"}) +@app.route("/show_trait") +def show_trait_page(): + # Here it's currently too complicated not to use an fd that is a webqtlFormData + #fd = webqtlFormData.webqtlFormData(request.args) + #print("stp y1:", pf(vars(fd))) + template_vars = show_trait.ShowTrait(request.args) + print("js_data before dump:", template_vars.js_data) + template_vars.js_data = json.dumps(template_vars.js_data, + default=json_default_handler, + indent=" ") + # Sorting the keys messes up the ordered dictionary, so don't do that + #sort_keys=True) + + print("js_data after dump:", template_vars.js_data) + print("show_trait template_vars:", pf(template_vars.__dict__)) + return render_template("show_trait.html", **template_vars.__dict__) + +@app.route("/marker_regression", methods=('POST',)) +def marker_regression_page(): + template_vars = marker_regression.MarkerRegression(request.form) + #print("js_data before dump:", template_vars.js_data) + #template_vars.js_data = json.dumps(template_vars.js_data, + # default=json_default_handler, + # indent=" ") + #print("js_data after dump:", template_vars.js_data) + print("marker_regression template_vars:", pf(template_vars.__dict__)) + return render_template("marker_regression.html", **template_vars.__dict__) @app.route("/corr_compute", methods=('POST',)) def corr_compute_page(): - #print("In corr_compute, request.args is:", pf(request.form)) + print("In corr_compute, request.args is:", pf(request.form)) fd = webqtlFormData.webqtlFormData(request.form) - print("Have fd") template_vars = CorrelationPage.CorrelationPage(fd) - print("Made it to rendering") return render_template("correlation_page.html", **template_vars.__dict__) @app.route("/int_mapping", methods=('POST',)) def interval_mapping_page(): - fd = webqtlFormData.webqtlFormData(request.form) - print("Have fd") - template_vars = CorrelationPage.CorrelationPage(fd) - print("Made it to rendering") - return render_template("correlation_page.html", **template_vars.__dict__) - + template_vars = interval_mapping.IntervalMapping(request.args) + return render_template("interval_mapping.html", **template_vars.__dict__) # Todo: Can we simplify this? -Sam def sharing_info_page(): """Info page displayed when the user clicks the "Info" button next to the dataset selection""" print("In sharing_info_page") fd = webqtlFormData.webqtlFormData(request.args) - print("2Have fd") template_vars = SharingInfoPage.SharingInfoPage(fd) - print("2 Made it to rendering") return template_vars -- cgit v1.2.3 From 91ed29ef68e8ad29b728f7f574ccc83730d9f7ab Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Thu, 3 Jan 2013 18:15:32 -0600 Subject: Began working on marker_regression.py and created Chromosomes class in species.py --- wqflask/base/data_set.py | 6 +- wqflask/base/species.py | 52 +- wqflask/wqflask/interval_analyst/GeneUtil.py | 124 ++ .../interval_analyst/IntervalAnalystPage.py | 405 +++++ wqflask/wqflask/interval_analyst/__init__.py | 0 .../marker_regression/MarkerRegressionPage.py | 1648 ++++++++++++++++++++ wqflask/wqflask/marker_regression/__init__.py | 0 .../wqflask/marker_regression/marker_regression.py | 1648 ++++++++++++++++++++ 8 files changed, 3870 insertions(+), 13 deletions(-) create mode 100755 wqflask/wqflask/interval_analyst/GeneUtil.py create mode 100755 wqflask/wqflask/interval_analyst/IntervalAnalystPage.py create mode 100644 wqflask/wqflask/interval_analyst/__init__.py create mode 100644 wqflask/wqflask/marker_regression/MarkerRegressionPage.py create mode 100644 wqflask/wqflask/marker_regression/__init__.py create mode 100755 wqflask/wqflask/marker_regression/marker_regression.py (limited to 'wqflask/base') diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 36d4acaf..50ef8f57 100755 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -85,8 +85,8 @@ class DatasetGroup(object): self.f1list = None self.parlist = None self.allsamples = None - - + + #def read_genotype(self): # self.read_genotype_file() # @@ -158,8 +158,8 @@ class DataSet(object): self.retrieve_other_names() - self.species = species.TheSpecies(self) self.group = DatasetGroup(self) # sets self.group and self.group_id and gets genotype + self.species = species.TheSpecies(self) diff --git a/wqflask/base/species.py b/wqflask/base/species.py index 98941ce5..1fd76772 100644 --- a/wqflask/base/species.py +++ b/wqflask/base/species.py @@ -1,16 +1,48 @@ -from __future__ import print_function, division +from __future__ import absolute_import, print_function, division +import collections + +from flask import Flask, g + +#from MySQLdb import escape_string as escape + +from pprint import pformat as pf class TheSpecies(object): def __init__(self, dataset): self.dataset = dataset + print("self.dataset is:", pf(self.dataset.__dict__)) + self.chromosomes = Chromosomes(self.dataset.group.name) + + #@property + #def chromosomes(self): + # chromosomes = [("All", -1)] + # + # for counter, genotype in enumerate(self.dataset.group.genotype): + # if len(genotype) > 1: + # chromosomes.append((genotype.name, counter)) + # + # print("chromosomes is: ", pf(chromosomes)) + # + # return chromosomes + + + +class Chromosomes(object): + def __init__(self, group_name): + self.chromosomes = collections.OrderedDict() + + results = g.db.execute(""" + Select + Chr_Length.Name, Length from Chr_Length, InbredSet + where + Chr_Length.SpeciesId = InbredSet.SpeciesId AND + InbredSet.Name = %s + Order by OrderId + """, group_name).fetchall() + print("bike:", results) + + for item in results: + self.chromosomes[item.Name] = item.Length - @property - def chromosomes(self): - chromosomes = [("All", -1)] - - for counter, genotype in enumerate(self.dataset.group.genotype): - if len(genotype) > 1: - chromosomes.append((genotype.name, counter)) - - return chromosomes + print("self.chromosomes:", self.chromosomes) diff --git a/wqflask/wqflask/interval_analyst/GeneUtil.py b/wqflask/wqflask/interval_analyst/GeneUtil.py new file mode 100755 index 00000000..43008ecf --- /dev/null +++ b/wqflask/wqflask/interval_analyst/GeneUtil.py @@ -0,0 +1,124 @@ +# Copyright (C) University of Tennessee Health Science Center, Memphis, TN. +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Affero General Public License for more details. +# +# This program is available from Source Forge: at GeneNetwork Project +# (sourceforge.net/projects/genenetwork/). +# +# Contact Drs. Robert W. Williams and Xiaodong Zhou (2010) +# at rwilliams@uthsc.edu and xzhou15@uthsc.edu +# +# +# +# This module is used by GeneNetwork project (www.genenetwork.org) +# +# Created by GeneNetwork Core Team 2010/08/10 +# +# Last updated by GeneNetwork Core Team 2010/10/20 + +import string + +#Just return a list of dictionaries +#each dictionary contains sub-dictionary +def loadGenes(cursor, chrName, diffCol, startMb, endMb, webqtlDb =None, species='mouse'): + #cursor.execute("desc GeneList") + #results = cursor.fetchall() + #fetchFields = map(lambda X:X[0], results) + fetchFields = ['SpeciesId', 'Id', 'GeneSymbol', 'GeneDescription', 'Chromosome', 'TxStart', 'TxEnd', + 'Strand', 'GeneID', 'NM_ID', 'kgID', 'GenBankID', 'UnigenID', 'ProteinID', 'AlignID', + 'exonCount', 'exonStarts', 'exonEnds', 'cdsStart', 'cdsEnd'] + + ##List All Species in the Gene Table + speciesDict = {} + cursor.execute("select Species.Name, GeneList.SpeciesId from Species, GeneList where \ + GeneList.SpeciesId = Species.Id group by GeneList.SpeciesId") + results = cursor.fetchall() + for item in results: + speciesDict[item[0]] = item[1] + + ##List current Species and other Species + speciesId = speciesDict[species] + otherSpecies = map(lambda X: [X, speciesDict[X]], speciesDict.keys()) + otherSpecies.remove([species, speciesId]) + + cursor.execute("""SELECT %s from GeneList + where + SpeciesId = %d AND Chromosome = '%s' AND + ((TxStart > %f and TxStart <= %f) OR (TxEnd > %f and TxEnd <= %f)) + order by txStart + """ + % (string.join(fetchFields, ", "), speciesId, chrName, startMb, endMb, startMb, endMb)) + results = cursor.fetchall() + GeneList = [] + + if results: + for result in results: + newdict = {} + for j, item in enumerate(fetchFields): + newdict[item] = result[j] + #count SNPs if possible + if diffCol and species=='mouse': + cursor.execute(""" + select + count(*) from BXDSnpPosition + where + Chr = '%s' AND Mb >= %2.6f AND Mb < %2.6f AND + StrainId1 = %d AND StrainId2 = %d + """ % (chrName, newdict["TxStart"], newdict["TxEnd"], diffCol[0], diffCol[1])) + newdict["snpCount"] = cursor.fetchone()[0] + newdict["snpDensity"] = newdict["snpCount"]/(newdict["TxEnd"]-newdict["TxStart"])/1000.0 + else: + newdict["snpDensity"] = newdict["snpCount"] = 0 + + try: + newdict['GeneLength'] = 1000.0*(newdict['TxEnd'] - newdict['TxStart']) + except: + pass + + #load gene from other Species by the same name + for item in otherSpecies: + othSpec, othSpecId = item + newdict2 = {} + + cursor.execute("SELECT %s from GeneList where SpeciesId = %d and geneSymbol= '%s' limit 1" % + (string.join(fetchFields, ", "), othSpecId, newdict["GeneSymbol"])) + resultsOther = cursor.fetchone() + if resultsOther: + for j, item in enumerate(fetchFields): + newdict2[item] = resultsOther[j] + + #count SNPs if possible, could be a separate function + if diffCol and othSpec == 'mouse': + cursor.execute(""" + select + count(*) from BXDSnpPosition + where + Chr = '%s' AND Mb >= %2.6f AND Mb < %2.6f AND + StrainId1 = %d AND StrainId2 = %d + """ % (chrName, newdict["TxStart"], newdict["TxEnd"], diffCol[0], diffCol[1])) + + newdict2["snpCount"] = cursor.fetchone()[0] + newdict2["snpDensity"] = newdict2["snpCount"]/(newdict2["TxEnd"]-newdict2["TxStart"])/1000.0 + else: + newdict2["snpDensity"] = newdict2["snpCount"] = 0 + + try: + newdict2['GeneLength'] = 1000.0*(newdict2['TxEnd'] - newdict2['TxStart']) + except: + pass + + newdict['%sGene' % othSpec] = newdict2 + + GeneList.append(newdict) + + return GeneList + + diff --git a/wqflask/wqflask/interval_analyst/IntervalAnalystPage.py b/wqflask/wqflask/interval_analyst/IntervalAnalystPage.py new file mode 100755 index 00000000..ec9aa29c --- /dev/null +++ b/wqflask/wqflask/interval_analyst/IntervalAnalystPage.py @@ -0,0 +1,405 @@ +# Copyright (C) University of Tennessee Health Science Center, Memphis, TN. +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Affero General Public License for more details. +# +# This program is available from Source Forge: at GeneNetwork Project +# (sourceforge.net/projects/genenetwork/). +# +# Contact Drs. Robert W. Williams and Xiaodong Zhou (2010) +# at rwilliams@uthsc.edu and xzhou15@uthsc.edu +# +# +# +# This module is used by GeneNetwork project (www.genenetwork.org) +# +# Created by GeneNetwork Core Team 2010/08/10 +# +# Last updated by GeneNetwork Core Team 2010/10/20 + +from mod_python import apache, util, Cookie +import os +import time +import pyXLWriter as xl + +from htmlgen import HTMLgen2 as HT + +import GeneUtil +from base.templatePage import templatePage +from utility import webqtlUtil +from base import webqtlConfig + + +class IntervalAnalystPage(templatePage): + filename = webqtlUtil.genRandStr("Itan_") + + _scriptfile = "main.py?FormID=intervalAnalyst" + + #A dictionary that lets us map the html form names "txStart_mm6" -> "Mb Start (mm8)" + #the first item is the short name (column headers) and the second item is the long name (dropdown list) + # [short name, long name, category] + columnNames = {"GeneSymbol" : ["Gene", "Gene Name", 'gene'], + "GeneDescription" : ["Description", "Gene Description", 'species'], + 'GeneNeighborsCount' : ["Neighbors", "Gene Neighbors", 'gene'], + 'GeneNeighborsRange' : ["Neighborhood", "Gene Neighborhood (Mb)", 'gene'], + 'GeneNeighborsDensity' : ["Gene Density", "Gene Density (Neighbors/Mb)", 'gene'], + "ProteinID" : ["Prot ID", "Protein ID", 'protein'], + "Chromosome" : ["Chr", "Chromosome", 'species'], + "TxStart" : ["Start", "Mb Start", 'species'], + "TxEnd" : ["End", "Mb End", 'species'], + "GeneLength" : ["Length", "Kb Length", 'species'], + "cdsStart" : ["CDS Start", "Mb CDS Start", 'species'], + "cdsEnd" : ["CDS End", "Mb CDS End", 'species'], + "exonCount" : ["Num Exons", "Exon Count", 'species'], + "exonStarts" : ["Exon Starts", "Exon Starts", 'species'], + "exonEnds" : ["Exon Ends", "Exon Ends", 'species'], + "Strand" : ["Strand", "Strand", 'species'], + "GeneID" : ["Gene ID", "Gene ID", 'species'], + "GenBankID" : ["GenBank", "GenBank ID", 'species'], + "UnigenID" : ["Unigen", "Unigen ID", 'species'], + "NM_ID" : ["NM ID", "NM ID", 'species'], + "kgID" : ["kg ID", "kg ID", 'species'], + "snpCount" : ["SNPs", "SNP Count", 'species'], + "snpDensity" : ["SNP Density", "SNP Density", 'species'], + "lrs" : ["LRS", "Likelihood Ratio Statistic", 'misc'], + "lod" : ["LOD", "Likelihood Odds Ratio", 'misc'], + "pearson" : ["Pearson", "Pearson Product Moment", 'misc'], + "literature" : ["Lit Corr", "Literature Correlation", 'misc'], + } + + ###Species Freeze + speciesFreeze = {'mouse':'mm9', 'rat':'rn3', 'human':'hg19'} + for key in speciesFreeze.keys(): + speciesFreeze[speciesFreeze[key]] = key + + def __init__(self, fd): + + templatePage.__init__(self, fd) + + fd.formdata['remote_ip'] = fd.remote_ip + if not self.openMysql(): + return + + self.species = fd.formdata.getvalue("species", "mouse") + try: + self.startMb = float(fd.formdata.getvalue("startMb")) + except: + self.startMb = 10 + try: + self.endMb = float(fd.formdata.getvalue("endMb")) + except: + self.endMb = self.startMb + 10 + + self.Chr = fd.formdata.getvalue("chromosome", "1") + self.xls = fd.formdata.getvalue("xls", "1") + try: + s1 = int(fd.formdata.getvalue("s1")) + s2 = int(fd.formdata.getvalue("s2")) + self.diffColDefault = self.diffCol = [s1, s2] + except: + self.diffColDefault = self.diffCol = [] + if self.species != 'mouse': + self.diffColDefault = [2, 3]#default is B6 and D2 for other species + + controlFrm, dispFields = self.genControlForm(fd) + geneTable, filename = self.genGeneTable(fd, dispFields) + + infoTD = HT.TD(width=400, valign= "top") + infoTD.append(HT.Paragraph("Interval Analyst : Chr %s" % self.Chr, Class="title"), + HT.Strong("Species : "), self.species.title(), HT.BR(), + HT.Strong("Database : "), "UCSC %s" % self.speciesFreeze[self.species], HT.BR(), + HT.Strong("Range : "), "%2.6f Mb - %2.6f Mb" % (self.startMb, self.endMb), HT.BR(), + ) + if filename: + infoTD.append(HT.BR(), HT.BR(), HT.Href(text="Download", url = "/tmp/" + filename, Class="normalsize") + , " output in MS excel format.") + + mainTable = HT.TableLite(HT.TR(infoTD, HT.TD(controlFrm, Class="doubleBorder", width=400), HT.TD(" ", width="")), cellpadding=10) + mainTable.append(HT.TR(HT.TD(geneTable, colspan=3))) + self.dict['body'] = HT.TD(mainTable) + self.dict['title'] = "Interval Analyst" + + def genGeneTable(self, fd, dispFields): + filename = "" + if self.xls: + #import pyXLWriter as xl + filename = "IntAn_Chr%s_%2.6f-%2.6f" % (self.Chr, self.startMb, self.endMb) + filename += ".xls" + + # Create a new Excel workbook + workbook = xl.Writer(os.path.join(webqtlConfig.TMPDIR, filename)) + worksheet = workbook.add_worksheet() + titleStyle = workbook.add_format(align = 'left', bold = 0, size=18, border = 1, border_color="gray") + headingStyle = workbook.add_format(align = 'center', bold = 1, size=13, fg_color = 0x1E, color="white", border = 1, border_color="gray") + + ##Write title Info + worksheet.write([0, 0], "GeneNetwork Interval Analyst Table", titleStyle) + worksheet.write([1, 0], "%s%s" % (webqtlConfig.PORTADDR, os.path.join(webqtlConfig.CGIDIR, self._scriptfile))) + # + worksheet.write([2, 0], "Date : %s" % time.strftime("%B %d, %Y", time.gmtime())) + worksheet.write([3, 0], "Time : %s GMT" % time.strftime("%H:%M ", time.gmtime())) + worksheet.write([4, 0], "Search by : %s" % fd.formdata['remote_ip']) + worksheet.write([5, 0], "view region : Chr %s %2.6f - %2.6f Mb" % (self.Chr, self.startMb, self.endMb)) + nTitleRow = 7 + + geneTable = HT.TableLite(Class="collap", cellpadding=5) + headerRow = HT.TR(HT.TD(" ", Class="fs13 fwb ffl b1 cw cbrb", width="1")) + if self.xls: + worksheet.write([nTitleRow, 0], "Index", headingStyle) + + for ncol, column in enumerate(dispFields): + if len(column) == 1: + headerRow.append(HT.TD(self.columnNames[column[0]][0], Class="fs13 fwb ffl b1 cw cbrb", NOWRAP=1,align="Center")) + if self.xls: + colTitle = self.columnNames[column[0]][0] + worksheet.write([nTitleRow, ncol+1], colTitle, headingStyle) + worksheet.set_column([ncol+1, ncol+1], 2*len(colTitle)) + else: + headerRow.append(HT.TD(self.columnNames[column[0]][0], HT.BR(), " (%s)" % self.speciesFreeze[column[1]], + Class="fs13 fwb ffl b1 cw cbrb", NOWRAP=1, align="Center")) + if self.xls: + colTitle = self.columnNames[column[0]][0] + " (%s)" % self.speciesFreeze[column[1]] + worksheet.write([nTitleRow, ncol+1], colTitle, headingStyle) + worksheet.set_column([ncol+1, ncol+1], 2*len(colTitle)) + #headerRow.append(HT.TD(self.columnNames[column[0]][0], HT.BR(), + # "(%s %s)" % (column[1].title(), self.speciesFreeze[column[1]]), + # Class="colorBlue", NOWRAP=1, align="Center")) + geneTable.append(headerRow) + + geneCol = GeneUtil.loadGenes(self.cursor, self.Chr, self.diffColDefault, self.startMb, self.endMb, species=self.species) + for gIndex, theGO in enumerate(geneCol): + geneRow = HT.TR(HT.TD(gIndex+1, Class="fs12 fwn b1", align="right")) + if self.xls: + nTitleRow += 1 + worksheet.write([nTitleRow, 0], gIndex + 1) + + for ncol, column in enumerate(dispFields): + if len(column) == 1 or column[1]== self.species: + keyValue = "" + fieldName = column[0] + curSpecies = self.species + curGO = theGO + if theGO.has_key(fieldName): + keyValue = theGO[fieldName] + else: + fieldName , othSpec = column + curSpecies = othSpec + subGO = '%sGene' % othSpec + keyValue = "" + curGO = theGO[subGO] + if theGO[subGO].has_key(fieldName): + keyValue = theGO[subGO][fieldName] + + if self.xls: + worksheet.write([nTitleRow, ncol+1], keyValue) + geneRow.append(self.formatTD(keyValue, fieldName, curSpecies, curGO)) + + geneTable.append(geneRow) + + if self.xls: + workbook.close() + return geneTable, filename + + def formatTD(self, keyValue, fieldName, Species, theGO): + if keyValue is None: + keyValue = "" + if keyValue != "": + if fieldName in ("exonStarts", "exonEnds"): + keyValue = string.replace(keyValue, ',', ' ') + return HT.TD(HT.Span(keyValue, Class="code", Id="green"), width=350, Class="fs12 fwn b1") + elif fieldName in ("GeneDescription"): + if keyValue == "---": + keyValue = "" + return HT.TD(keyValue, Class="fs12 fwn b1", width=300) + elif fieldName in ("GeneSymbol"): + webqtlLink = HT.Href("./%s?cmd=sch&gene=%s&alias=1&species=%s" % (webqtlConfig.SCRIPTFILE, keyValue, Species), + HT.Image("/images/webqtl_search.gif", border=0, valign="top"), target="_blank") + if theGO['GeneID']: + geneSymbolLink = HT.Href(webqtlConfig.NCBI_LOCUSID % theGO['GeneID'], keyValue, Class="normalsize", target="_blank") + else: + geneSymbolLink = keyValue + return HT.TD(webqtlLink, geneSymbolLink, Class="fs12 fwn b1",NOWRAP=1) + elif fieldName == 'UnigenID': + try: + gurl = HT.Href(webqtlConfig.UNIGEN_ID % tuple(string.split(keyValue,'.')[:2]), keyValue, Class="normalsize", target="_blank") + except: + gurl = keyValue + return HT.TD(gurl, Class="fs12 fwn b1",NOWRAP=1) + elif fieldName in ("exonCount", "Chromosome"): + return HT.TD(keyValue, Class="fs12 fwn b1",align="right") + elif fieldName in ("snpCount"): + if keyValue: + snpString = HT.Href(url="%s&chr=%s&start=%s&end=%s&geneName=%s&s1=%d&s2=%d" % (os.path.join(webqtlConfig.CGIDIR, 'main.py?FormID=snpBrowser'), + theGO["Chromosome"], theGO["TxStart"], theGO["TxEnd"], theGO["GeneSymbol"], self.diffColDefault[0], self.diffColDefault[1]), + text=theGO["snpCount"], target="_blank", Class="normalsize") + else: + snpString = keyValue + return HT.TD(snpString, Class="fs12 fwn b1",align="right") + elif fieldName in ("snpDensity", "GeneLength"): + if keyValue: keyValue = "%2.3f" % keyValue + else: keyValue = "" + return HT.TD(keyValue, Class="fs12 fwn b1",align="right") + elif fieldName in ("TxStart", "TxEnd"): + return HT.TD("%2.6f" % keyValue, Class="fs12 fwn b1",align="right") + else: + return HT.TD(keyValue, Class="fs12 fwn b1",NOWRAP=1) + else: + return HT.TD(keyValue, Class="fs12 fwn b1",NOWRAP=1,align="right") + + def genControlForm(self, fd): + ##desc GeneList + self.cursor.execute("Desc GeneList") + GeneListFields = self.cursor.fetchall() + GeneListFields = map(lambda X: X[0], GeneListFields) + + #group columns by category--used for creating the dropdown list of possible columns + categories = {} + for item in self.columnNames.keys(): + category = self.columnNames[item] + if category[-1] not in categories.keys(): + categories[category[-1]] = [item ] + else: + categories[category[-1]] = categories[category[-1]]+[item] + + ##List All Species in the Gene Table + speciesDict = {} + self.cursor.execute("select Species.Name, GeneList.SpeciesId from Species, GeneList where \ + GeneList.SpeciesId = Species.Id group by GeneList.SpeciesId order by Species.Id") + results = self.cursor.fetchall() + speciesField = categories.pop('species', []) + categoriesOrder = ['gene', 'protein'] + for item in results: + specName, specId = item + categoriesOrder.append(specName) + speciesDict[specName] = specId + AppliedField = [] + for item2 in speciesField: + if item2 in GeneListFields: + self.cursor.execute("select %s from GeneList where SpeciesId = %d and %s is not NULL limit 1 " % (item2, specId, item2)) + columnApply = self.cursor.fetchone() + if not columnApply: + continue + elif specName != 'mouse' and item2 in ('snpCount', 'snpDensity'): + continue + else: + pass + AppliedField.append(item2) + categories[specName] = AppliedField + + categoriesOrder += ['misc'] + + ############################################################ + ## Create the list of possible columns for the dropdown list + ############################################################ + allColumnsList = HT.Select(name="allColumns", Class="snpBrowserDropBox") + + for category in categoriesOrder: + allFields = categories[category] + if allFields: + geneOpt = HT.Optgroup(label=category.title()) + for item in allFields: + if category in self.speciesFreeze.keys(): + geneOpt.append(("%s (%s %s)" % (self.columnNames[item][1], category.title(), self.speciesFreeze[category]), + "%s__%s" % (item, self.speciesFreeze[category]))) + else: + geneOpt.append((self.columnNames[item][1], item)) + geneOpt.sort() + allColumnsList.append(geneOpt) + + ###################################### + ## Create the list of selected columns + ###################################### + + #cols contains the value of all the selected columns + submitCols = cols = fd.formdata.getvalue("columns", "default") + + if cols == "default": + if self.species=="mouse": #these are the same columns that are shown on intervalPage.py + cols = ['GeneSymbol', 'GeneDescription', 'Chromosome', 'TxStart', 'Strand', 'GeneLength', 'GeneID', 'NM_ID', 'snpCount', 'snpDensity'] + elif self.species=="rat": + cols = ['GeneSymbol', 'GeneDescription', 'Chromosome', 'TxStart', 'GeneLength', 'Strand', 'GeneID', 'UnigenID'] + else: + #should not happen + cols = [] + else: + if type(cols)==type(""): + cols = [cols] + + colsLst = [] + dispFields = [] + for column in cols: + if submitCols == "default" and column not in ('GeneSymbol') and (column in GeneListFields or column in speciesField): + colsLst.append(("%s (%s %s)" % (self.columnNames[column][1], self.species.title(), self.speciesFreeze[self.species]), + "%s__%s" % (column, self.speciesFreeze[self.species]))) + dispFields.append([column, self.species]) + else: + column2 = column.split("__") + if len(column2) == 1: + colsLst.append((self.columnNames[column2[0]][1], column)) + dispFields.append([column]) + else: + thisSpecies = self.speciesFreeze[column2[1]] + colsLst.append(("%s (%s %s)" % (self.columnNames[column2[0]][1], thisSpecies.title(), column2[1]), + column)) + dispFields.append((column2[0], thisSpecies)) + selectedColumnsList = HT.Select(name="columns", Class="snpBrowserSelectBox", multiple="true", data=colsLst, size=6) + + ########################## + ## Create the columns form + ########################## + columnsForm = HT.Form(name="columnsForm", submit=HT.Input(type='hidden'), cgi=os.path.join(webqtlConfig.CGIDIR, self._scriptfile), enctype="multipart/form-data") + columnsForm.append(HT.Input(type="hidden", name="fromdatabase", value= fd.formdata.getvalue("fromdatabase", "unknown"))) + columnsForm.append(HT.Input(type="hidden", name="species", value=self.species)) + if self.diffCol: + columnsForm.append(HT.Input(type="hidden", name="s1", value=self.diffCol[0])) + columnsForm.append(HT.Input(type="hidden", name="s2", value=self.diffCol[1])) + startBox = HT.Input(type="text", name="startMb", value=self.startMb, size=10) + endBox = HT.Input(type="text", name="endMb", value=self.endMb, size=10) + addButton = HT.Input(type="button", name="add", value="Add", Class="button", onClick="addToList(this.form.allColumns.options[this.form.allColumns.selectedIndex].text, this.form.allColumns.options[this.form.allColumns.selectedIndex].value, this.form.columns)") + removeButton = HT.Input(type="button", name="remove", value="Remove", Class="button", onClick="removeFromList(this.form.columns.selectedIndex, this.form.columns)") + upButton = HT.Input(type="button", name="up", value="Up", Class="button", onClick="swapOptions(this.form.columns.selectedIndex, this.form.columns.selectedIndex-1, this.form.columns)") + downButton = HT.Input(type="button", name="down", value="Down", Class="button", onClick="swapOptions(this.form.columns.selectedIndex, this.form.columns.selectedIndex+1, this.form.columns)") + clearButton = HT.Input(type="button", name="clear", value="Clear", Class="button", onClick="deleteAllElements(this.form.columns)") + submitButton = HT.Input(type="submit", value="Refresh", Class="button", onClick="selectAllElements(this.form.columns)") + + selectChrBox = HT.Select(name="chromosome") + self.cursor.execute(""" + Select + Chr_Length.Name, Length from Chr_Length, Species + where + Chr_Length.SpeciesId = Species.Id AND + Species.Name = '%s' + Order by + Chr_Length.OrderId + """ % self.species) + + results = self.cursor.fetchall() + for chrInfo in results: + selectChrBox.append((chrInfo[0], chrInfo[0])) + selectChrBox.selected.append(self.Chr) + + innerColumnsTable = HT.TableLite(border=0, Class="collap", cellpadding = 2) + innerColumnsTable.append(HT.TR(HT.TD(selectedColumnsList)), + HT.TR(HT.TD(clearButton, removeButton, upButton, downButton))) + columnsTable = HT.TableLite(border=0, cellpadding=2, cellspacing=0) + columnsTable.append(HT.TR(HT.TD(HT.Font("Chr: ", size=-1)), + HT.TD(selectChrBox, submitButton)), + HT.TR(HT.TD(HT.Font("View: ", size=-1)), + HT.TD(startBox, HT.Font("Mb to ", size=-1), endBox, HT.Font("Mb", size=-1))), + HT.TR(HT.TD(HT.Font("Show: ", size=-1)), + HT.TD(allColumnsList, addButton)), + HT.TR(HT.TD(""), + HT.TD(innerColumnsTable))) + columnsForm.append(columnsTable) + #columnsForm.append(HT.Input(type="hidden", name="sort", value=diffCol), + # HT.Input(type="hidden", name="identification", value=identification), + # HT.Input(type="hidden", name="traitInfo", value=traitInfo)) + + return columnsForm, dispFields diff --git a/wqflask/wqflask/interval_analyst/__init__.py b/wqflask/wqflask/interval_analyst/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/wqflask/wqflask/marker_regression/MarkerRegressionPage.py b/wqflask/wqflask/marker_regression/MarkerRegressionPage.py new file mode 100644 index 00000000..d02d80b3 --- /dev/null +++ b/wqflask/wqflask/marker_regression/MarkerRegressionPage.py @@ -0,0 +1,1648 @@ +# Copyright (C) University of Tennessee Health Science Center, Memphis, TN. +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Affero General Public License for more details. +# +# This program is available from Source Forge: at GeneNetwork Project +# (sourceforge.net/projects/genenetwork/). +# +# Contact Drs. Robert W. Williams and Xiaodong Zhou (2010) +# at rwilliams@uthsc.edu and xzhou15@uthsc.edu +# +# This module is used by GeneNetwork project (www.genenetwork.org) +# +# Created by GeneNetwork Core Team 2010/08/10 +# +# Last updated by GeneNetwork Core Team 2010/10/20 + +import time +import string +import math +from math import * +import piddle as pid +import sys,os +import httplib, urllib + +from htmlgen import HTMLgen2 as HT +from utility import Plot +from intervalAnalyst import GeneUtil +from base.webqtlTrait import webqtlTrait +from base.templatePage import templatePage +from utility import webqtlUtil +from base import webqtlConfig +from dbFunction import webqtlDatabaseFunction +from base.GeneralObject import GeneralObject + +import reaper +import cPickle +from utility.THCell import THCell +from utility.TDCell import TDCell + +class MarkerRegressionPage(templatePage): + + def __init__(self, fd): + + templatePage.__init__(self, fd) + + if not self.openMysql(): + return + + self.initializeParameters(fd) + + filename= webqtlUtil.genRandStr("Itvl_") + ChrList,ChrNameOrderIdDict,ChrOrderIdNameDict,ChrLengthMbList= self.getChrNameOrderIdLength(RISet=fd.RISet) + + if self.mappingMethodId == '4': # For PLINK + + traitInfoList = string.split(string.strip(fd.identification),':') + probesetName = string.strip(traitInfoList[-1]) + plinkOutputFileName= webqtlUtil.genRandStr("%s_%s_"%(fd.RISet,probesetName)) + + # get related values from fd.allTraitData; the format of 'allTraitValueDict'is {strainName1: value=-0.2...} + fd.readData() + allTraitValueDict = fd.allTraitData + + #automatically generate pheno txt file for PLINK + self.genPhenoTxtFileForPlink(phenoFileName=plinkOutputFileName,RISetName=fd.RISet,probesetName=probesetName, valueDict=allTraitValueDict) + # os.system full path is required for input and output files; specify missing value is -9999 + plink_command = '%splink/plink --noweb --ped %splink/%s.ped --no-fid --no-parents --no-sex --no-pheno --map %splink/%s.map --pheno %s/%s.txt --pheno-name %s --missing-phenotype -9999 --out %s%s --assoc ' % (webqtlConfig.HTMLPATH, webqtlConfig.HTMLPATH, fd.RISet, webqtlConfig.HTMLPATH, fd.RISet, webqtlConfig.TMPDIR, plinkOutputFileName, probesetName, webqtlConfig.TMPDIR, plinkOutputFileName) + + os.system(plink_command) + + if fd.identification: + heading2 = HT.Paragraph('Trait ID: %s' % fd.identification) + heading2.__setattr__("class","subtitle") + self.dict['title'] = '%s: Genome Association' % fd.identification + else: + heading2 = "" + self.dict['title'] = 'Genome Association' + + if fd.traitInfo: + symbol,chromosome,MB = string.split(fd.traitInfo,'\t') + heading3 = HT.Paragraph('[ ',HT.Strong(HT.Italic('%s' % symbol,id="green")),' on Chr %s @ %s Mb ]' % (chromosome,MB)) + else: + heading3 = "" + + heading = HT.Paragraph('Trait Data Entered for %s Set' % fd.RISet) + heading.__setattr__("class","title") + + # header info part:Trait Data Entered for HLC Set & Trait ID: + headerdiv = HT.TR(HT.TD(heading, heading2,heading3, width='45%',valign='top', align='left', bgColor='#eeeeee')) + + self.ChrList=ChrList # get chr name from '1' to 'X' + self.ChrLengthMbList = ChrLengthMbList + + # build plink result dict based on chr, key is chr name, value is in list type including Snpname, bp and pvalue info + plinkResultDict={} + count,minPvalue,plinkResultDict =self.getPlinkResultDict(outputFileName=plinkOutputFileName,thresholdPvalue=self.pValue,ChrOrderIdNameDict=ChrOrderIdNameDict) + + # if can not find results which are matched with assigned p-value, system info will show up + if count >0: + + #for genome association report table + reportTable="" + # sortable table object + resultstable,tblobj,bottomInfo = self.GenReportForPLINK(ChrNameOrderIdDict=ChrNameOrderIdDict, RISet=fd.RISet,plinkResultDict=plinkResultDict,thresholdPvalue=self.pValue,chrList=self.ChrList) + + # creat object for result table for sort function + objfile = open('%s.obj' % (webqtlConfig.TMPDIR+filename), 'wb') + cPickle.dump(tblobj, objfile) + objfile.close() + + sortby = ("Index", "up") + reportTable =HT.Div(webqtlUtil.genTableObj(tblobj=tblobj, file=filename, sortby=sortby, tableID = "sortable", addIndex = "0"), Id="sortable") + + descriptionTable = HT.TableLite(border=0, cellpadding=0, cellspacing=0) + descriptionTable.append(HT.TR(HT.TD(reportTable, colspan=3))) + descriptionTable.append(HT.TR(HT.TD(HT.BR(),HT.BR()))) + descriptionTable.append(bottomInfo) + + # get each chr's length + self.ChrLengthMbList = map(lambda x: x/1000000.0, self.ChrLengthMbList) # change unit from bp to mb + self.ChrLengthMbSum = reduce(lambda x, y:x+y, self.ChrLengthMbList, 0.0)# get total length of all chrs + if self.ChrLengthMbList: + self.GraphInterval = self.ChrLengthMbSum/(len(self.ChrLengthMbList)*12) #Empirical Mb interval + else: + self.GraphInterval = 1 + + # for human data, there's no CM value + self.ChrLengthCMList = [] + self.ChrLengthCMSum = 0 + + # begin: common part with human data + intCanvas = pid.PILCanvas(size=(self.graphWidth,self.graphHeight)) + gifmap = self.plotIntMappingForPLINK(fd, intCanvas, startMb = self.startMb, endMb = self.endMb, plinkResultDict=plinkResultDict) + + intCanvas.save(os.path.join(webqtlConfig.IMGDIR, filename), format='png') + intImg=HT.Image('/image/'+filename+'.png', border=0, usemap='#WebQTLImageMap') + + TD_LR = HT.TR(HT.TD(HT.Blockquote(gifmap,intImg, HT.P()), bgColor='#eeeeee', height = 200)) + self.dict['body'] = str(headerdiv)+str(TD_LR)+str(resultstable)+str(HT.TR(HT.TD(descriptionTable))) + + else: + heading = "Genome Association" + detail = ['There is no association with marker that meets this criteria. Please provide a less stringend threshold. The minimun p-value is %s.'%minPvalue] + self.error(heading=heading,detail=detail) + return + + elif self.mappingMethodId == '1': # QTLreaper result + if not fd.genotype: + fd.readData() + + fd.parentsf14regression = fd.formdata.getvalue('parentsf14regression') + weightedRegression = fd.formdata.getvalue('applyVarianceSE') + + if fd.parentsf14regression and fd.genotype_2: + _genotype = fd.genotype_2 + else: + _genotype = fd.genotype_1 + + _strains, _vals, _vars, N = fd.informativeStrains(_genotype.prgy, weightedRegression) + + if fd.identification: + heading2 = HT.Paragraph('Trait ID: %s' % fd.identification) + heading2.__setattr__("class","subtitle") + self.dict['title'] = '%s: Genome Association' % fd.identification + else: + heading2 = "" + self.dict['title'] = 'Genome Association' + + if fd.traitInfo: + symbol,chromosome,MB = string.split(fd.traitInfo,'\t') + heading3 = HT.Paragraph('[ ',HT.Strong(HT.Italic('%s' % symbol,id="green")),' on Chr %s @ %s Mb ]' % (chromosome,MB)) + else: + heading3 = "" + + if N < webqtlConfig.KMININFORMATIVE: + heading = "Genome Association" + detail = ['Fewer than %d strain data were entered for %s data set. No mapping attempted.' % (webqtlConfig.KMININFORMATIVE, fd.RISet)] + self.error(heading=heading,detail=detail) + return + else: + heading = HT.Paragraph('Trait Data Entered for %s Set' % fd.RISet) + heading.__setattr__("class","title") + + datadiv = HT.TD(heading, heading2,heading3, width='45%',valign='top', align='left', bgColor='#eeeeee') + resultstable,tblobj,bottomInfo = self.GenReport(ChrNameOrderIdDict,fd, _genotype, _strains, _vals, _vars) + #resultstable = self.GenReport(fd, _genotype, _strains, _vals, _vars) + + # creat object for result table for sort function + objfile = open('%s.obj' % (webqtlConfig.TMPDIR+filename), 'wb') + cPickle.dump(tblobj, objfile) + objfile.close() + + sortby = ("Index", "up") + reportTable =HT.Div(webqtlUtil.genTableObj(tblobj=tblobj, file=filename, sortby=sortby, tableID = "sortable", addIndex = "0"), Id="sortable") + + descriptionTable = HT.TableLite(border=0, cellpadding=0, cellspacing=0) + descriptionTable.append(HT.TR(HT.TD(reportTable, colspan=3))) + descriptionTable.append(HT.TR(HT.TD(HT.BR(),HT.BR()))) + descriptionTable.append(bottomInfo) + + self.traitList=_vals + + ##########################plot####################### + + ################################################################ + # Generate Chr list and Retrieve Length Information + ################################################################ + self.genotype= _genotype + self.ChrList = [("All", -1)] + + for i, indChr in enumerate(self.genotype): + self.ChrList.append((indChr.name, i)) + + self.cursor.execute(""" + Select + Length from Chr_Length, InbredSet + where + Chr_Length.SpeciesId = InbredSet.SpeciesId AND + InbredSet.Name = '%s' AND + Chr_Length.Name in (%s) + Order by + OrderId + """ % (fd.RISet, string.join(map(lambda X: "'%s'" % X[0], self.ChrList[1:]), ", "))) + + self.ChrLengthMbList = self.cursor.fetchall() + self.ChrLengthMbList = map(lambda x: x[0]/1000000.0, self.ChrLengthMbList) + self.ChrLengthMbSum = reduce(lambda x, y:x+y, self.ChrLengthMbList, 0.0) + if self.ChrLengthMbList: + self.MbGraphInterval = self.ChrLengthMbSum/(len(self.ChrLengthMbList)*12) #Empirical Mb interval + else: + self.MbGraphInterval = 1 + + self.ChrLengthCMList = [] + for i, _chr in enumerate(self.genotype): + self.ChrLengthCMList.append(_chr[-1].cM - _chr[0].cM) + self.ChrLengthCMSum = reduce(lambda x, y:x+y, self.ChrLengthCMList, 0.0)# used for calculate plot scale + + self.GraphInterval = self.MbGraphInterval #Mb + + # begin: common part with human data + intCanvas = pid.PILCanvas(size=(self.graphWidth,self.graphHeight)) + gifmap = self.plotIntMapping(fd, intCanvas, startMb = self.startMb, endMb = self.endMb, showLocusForm= "") + filename= webqtlUtil.genRandStr("Itvl_") + intCanvas.save(os.path.join(webqtlConfig.IMGDIR, filename), format='png') + intImg=HT.Image('/image/'+filename+'.png', border=0, usemap='#WebQTLImageMap') + + ################################################################ + # footnote goes here + ################################################################ + btminfo = HT.Paragraph(Id="smallsize") #Small('More information about this graph is available here.') + + if (self.additiveChecked): + btminfo.append(HT.BR(), 'A positive additive coefficient (', HT.Font('green', color='green'), ' line) indicates that %s alleles increase trait values. In contrast, a negative additive coefficient (' % fd.ppolar, HT.Font('red', color='red'), ' line) indicates that %s alleles increase trait values.' % fd.mpolar) + + + TD_LR = HT.TR(HT.TD(HT.Blockquote(gifmap,intImg, HT.P()), bgColor='#eeeeee', height = 200)) + + self.dict['body'] = str(datadiv)+str(TD_LR)+str(resultstable)+str(HT.TR(HT.TD(descriptionTable))) + + # end: common part with human data + + else: + pass + + + # add by NL 10-2-2011 + def initializeParameters(self, fd): + """ + Initializes all of the MarkerRegressionPage class parameters, + acquiring most values from the formdata (fd) + """ + ################################### + # manhattam plot parameters + ################################### + + self.graphHeight = 600 + self.graphWidth = 1280 + self.plotScale = 'physic' + self.selectedChr = -1 + self.GRAPH_BACK_DARK_COLOR = pid.HexColor(0xF1F1F9) + self.GRAPH_BACK_LIGHT_COLOR = pid.HexColor(0xFBFBFF) + self.LRS_COLOR = pid.HexColor(0x0000FF) + self.LRS_LOD ='LRS' + self.lrsMax = float(fd.formdata.getvalue('lrsMax', 0)) + self.startMb = fd.formdata.getvalue('startMb', "-1") + self.endMb = fd.formdata.getvalue('endMb', "-1") + self.mappingMethodId = fd.formdata.getvalue('mappingMethodId', "0") + self.permChecked=True + self.multipleInterval=False + self.SIGNIFICANT_WIDTH = 5 + self.SUGGESTIVE_WIDTH = 5 + self.SIGNIFICANT_COLOR = pid.HexColor(0xEBC7C7) + self.SUGGESTIVE_COLOR = pid.gainsboro + self.colorCollection = [self.LRS_COLOR] + self.additiveChecked= True + self.ADDITIVE_COLOR_POSITIVE = pid.green + self.legendChecked =False + self.pValue=float(fd.formdata.getvalue('pValue',-1)) + + # allow user to input p-value greater than 1, + # in this case, the value will be treated as -lgP value. so the input value needs to be transferred to power of 10 format + if self.pValue >1: + self.pValue =10**-(self.pValue) + + try: + self.startMb = float(self.startMb) + self.endMb = float(self.endMb) + if self.startMb > self.endMb: + temp = self.startMb + self.startMb = self.endMb + self.endMb = temp + #minimal distance 10bp + if self.endMb - self.startMb < 0.00001: + self.endMb = self.startMb + 0.00001 + except: + self.startMb = self.endMb = -1 + + def GenReportForPLINK(self, ChrNameOrderIdDict={},RISet='',plinkResultDict= {},thresholdPvalue=-1,chrList=[]): + + 'Create an HTML division which reports any loci which are significantly associated with the submitted trait data.' + ######################################### + # Genome Association report + ######################################### + locusFormName = webqtlUtil.genRandStr("fm_") + locusForm = HT.Form(cgi = os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), \ + enctype='multipart/form-data', name=locusFormName, submit=HT.Input(type='hidden')) + hddn = {'FormID':'showDatabase','ProbeSetID':'_','database':RISet+"Geno",'CellID':'_', \ + 'RISet':RISet, 'incparentsf1':'on'} + for key in hddn.keys(): + locusForm.append(HT.Input(name=key, value=hddn[key], type='hidden')) + + regressionHeading = HT.Paragraph('Genome Association Report') + regressionHeading.__setattr__("class","title") + + filename= webqtlUtil.genRandStr("GenomeAsscociation_") + fpText = open('%s.txt' % (webqtlConfig.TMPDIR+filename), 'wb') + fpText.write('The loci meet the criteria of P-Value <= %3.6f.\n'%thresholdPvalue) + pValueInfo =HT.Paragraph('The loci meet the criteria of P-Value <= %3.6f.\n'%thresholdPvalue) + + textUrl = HT.Href(text = 'Download', url= '/tmp/'+filename+'.txt', target = "_blank", Class='fs12 fwn') + bottomInfo = HT.TR(HT.TD(HT.Paragraph(textUrl, ' result in tab-delimited text format.', HT.BR(), HT.BR(),Class="fs12 fwn"), colspan=3)) + + tblobj={} # build dict for genTableObj function; keys include header and body + tblobj_header = [] # value of key 'header' + tblobj_body=[] # value of key 'body' + reportHeaderRow=[] # header row list for tblobj_header (html part) + headerList=['Index','SNP Name','Chr','Mb','-log(P)'] + headerStyle="fs14 fwb ffl b1 cw cbrb" # style of the header + cellColorStyle = "fs13 b1 fwn c222" # style of the cells + + if headerList: + for ncol, item in enumerate(headerList): + reportHeaderRow.append(THCell(HT.TD(item, Class=headerStyle, valign='bottom',nowrap='ON'),text=item, idx=ncol)) + #download file for table headers' names + fpText.write('SNP_Name\tChromosome\tMb\t-log(P)\n') + + tblobj_header.append(reportHeaderRow) + tblobj['header']=tblobj_header + + index=1 + for chr in chrList: + + if plinkResultDict.has_key(chr): + if chr in ChrNameOrderIdDict.keys(): + chrOrderId =ChrNameOrderIdDict[chr] + else: + chrOrderId=chr + + valueList=plinkResultDict[chr] + + for value in valueList: + reportBodyRow=[] # row list for tblobj_body (html part) + snpName=value[0] + bp=value[1] + mb=int(bp)/1000000.0 + + try: + pValue =float(value[2]) + except: + pValue =1 + formattedPvalue = -math.log10(pValue) + + formattedPvalue = webqtlUtil.SciFloat(formattedPvalue) + dbSnprs=snpName.replace('rs','') + SnpHref = HT.Href(text=snpName, url="http://www.ncbi.nlm.nih.gov/projects/SNP/snp_ref.cgi?rs=%s"%dbSnprs, target="_blank") + + selectCheck=HT.Input(type="checkbox", Class="checkbox", name="index",value=index, onClick="highlight(this)") + reportBodyRow.append(TDCell(HT.TD(str(index),selectCheck, align='right',Class=cellColorStyle,nowrap='ON'),str(index),index)) + reportBodyRow.append(TDCell(HT.TD(SnpHref, Class=cellColorStyle,nowrap='ON'),snpName, snpName)) + reportBodyRow.append(TDCell(HT.TD(chr, Class=cellColorStyle, align="center",nowrap='ON'),chr, chrOrderId)) + reportBodyRow.append(TDCell(HT.TD('%3.6f'%mb, Class=cellColorStyle, align="center",nowrap='ON'),mb, mb)) + reportBodyRow.append(TDCell(HT.TD(formattedPvalue, Class=cellColorStyle, align="center",nowrap='ON'),formattedPvalue, float(formattedPvalue))) + + fpText.write('%s\t%s\t%3.6f\t%s\n' % (snpName, str(chr), mb, formattedPvalue)) + index+=1 + + tblobj_body.append(reportBodyRow) + + tblobj['body']=tblobj_body + rv=HT.TR(HT.TD(regressionHeading,pValueInfo, locusForm, HT.P(), width='55%',valign='top', align='left',bgColor='#eeeeee')) + + return rv, tblobj,bottomInfo + + + def GenReport(self, ChrNameOrderIdDict,fd, _genotype, _strains, _vals, _vars= []): + 'Create an HTML division which reports any loci which are significantly associated with the submitted trait data.' + #calculate QTL for each trait + self.qtlresults = [] + if webqtlUtil.ListNotNull(_vars): + qtlresults = _genotype.regression(strains = _strains, trait = _vals, variance = _vars) + LRSArray = _genotype.permutation(strains = _strains, trait = _vals, variance = _vars, nperm=fd.nperm) + else: + qtlresults = _genotype.regression(strains = _strains, trait = _vals) + LRSArray = _genotype.permutation(strains = _strains, trait = _vals,nperm=fd.nperm) + + self.qtlresults.append(qtlresults) + + filename= webqtlUtil.genRandStr("GenomeAsscociation_") + + # set suggestive, significant and highly significant LRS + if fd.suggestive == None: + fd.suggestive = LRSArray[int(fd.nperm*0.37-1)] + else: + fd.suggestive = float(fd.suggestive) + if fd.significance == None: + fd.significance = LRSArray[int(fd.nperm*0.95-1)] + else: + fd.significance = float(fd.significance) + + self.significance =fd.significance + self.suggestive = fd.suggestive + self.highlysignificant = LRSArray[int(fd.nperm*0.99-1)] + _dispAllLRS = 0 + if fd.formdata.getvalue('displayAllLRS'): + _dispAllLRS = 1 + qtlresults2 = [] + if _dispAllLRS: + filtered = qtlresults[:] + else: + filtered = filter(lambda x, y=fd.suggestive: x.lrs > y, qtlresults) + if len(filtered) == 0: + qtlresults2 = qtlresults[:] + qtlresults2.sort() + filtered = qtlresults2[-10:] + + ######################################### + # Permutation Graph + ######################################### + myCanvas = pid.PILCanvas(size=(400,300)) + #plotBar(myCanvas,10,10,390,290,LRSArray,XLabel='LRS',YLabel='Frequency',title=' Histogram of Permutation Test',identification=fd.identification) + Plot.plotBar(myCanvas, LRSArray,XLabel='LRS',YLabel='Frequency',title=' Histogram of Permutation Test') + filename= webqtlUtil.genRandStr("Reg_") + myCanvas.save(webqtlConfig.IMGDIR+filename, format='gif') + img=HT.Image('/image/'+filename+'.gif',border=0,alt='Histogram of Permutation Test') + + if fd.suggestive == None: + fd.suggestive = LRSArray[int(fd.nperm*0.37-1)] + else: + fd.suggestive = float(fd.suggestive) + if fd.significance == None: + fd.significance = LRSArray[int(fd.nperm*0.95-1)] + else: + fd.significance = float(fd.significance) + + permutationHeading = HT.Paragraph('Histogram of Permutation Test') + permutationHeading.__setattr__("class","title") + + permutation = HT.TableLite() + permutation.append(HT.TR(HT.TD(img))) + + + ######################################### + # Genome Association report + ######################################### + locusFormName = webqtlUtil.genRandStr("fm_") + locusForm = HT.Form(cgi = os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), \ + enctype='multipart/form-data', name=locusFormName, submit=HT.Input(type='hidden')) + hddn = {'FormID':'showDatabase','ProbeSetID':'_','database':fd.RISet+"Geno",'CellID':'_', \ + 'RISet':fd.RISet, 'incparentsf1':'on'} + for key in hddn.keys(): + locusForm.append(HT.Input(name=key, value=hddn[key], type='hidden')) + + regressionHeading = HT.Paragraph('Genome Association Report') + regressionHeading.__setattr__("class","title") + # report is the info part above report table + if qtlresults2 != []: + report = HT.Blockquote(HT.Font('No association ',color="#FF0000"),HT.Font('with a likelihood ratio statistic greater than %3.1f was found. Here are the top 10 LRSs.' % fd.suggestive,color="#000000")) + else: + report = HT.Blockquote('The following loci in the %s data set have associations with the above trait data.\n' % fd.RISet, HT.P()) + report.__setattr__("class","normalsize") + + fpText = open('%s.txt' % (webqtlConfig.TMPDIR+filename), 'wb') + fpText.write('Suggestive LRS =%3.2f\n'%self.suggestive) + fpText.write('Significant LRS =%3.2f\n'%self.significance) + fpText.write('Highly Significant LRS =%3.2f\n'%self.highlysignificant) + LRSInfo =HT.Paragraph('    Suggestive LRS =%3.2f\n'%fd.suggestive, HT.BR(), '    Significant LRS =%3.2f\n'%fd.significance,HT.BR(),'    Highly Significant LRS =%3.2f\n' % self.highlysignificant) + + textUrl = HT.Href(text = 'Download', url= '/tmp/'+filename+'.txt', target = "_blank", Class='fs12 fwn') + + bottomInfo = HT.TR(HT.TD(HT.Paragraph(textUrl, ' result in tab-delimited text format.', HT.BR(), HT.BR(),'LRS values marked with',HT.Font(' * ',color="red"), 'are greater than the significance threshold (specified by you or by permutation test). ' , HT.BR(), HT.BR(), HT.Strong('Additive Effect'), ' is half the difference in the mean phenotype of all cases that are homozygous for one parental allel at this marker minus the mean of all cases that are homozygous for the other parental allele at this marker. ','In the case of %s strains, for example,' % fd.RISet,' A positive additive effect indicates that %s alleles increase trait values. Negative additive effect indicates that %s alleles increase trait values.'% (fd.ppolar,fd.mpolar),Class="fs12 fwn"))) + + tblobj={} # build dict for genTableObj function; keys include header and body + tblobj_header = [] # value of key 'header' + tblobj_body=[] # value of key 'body' + reportHeaderRow=[] # header row list for tblobj_header (html part) + headerStyle="fs14 fwb ffl b1 cw cbrb" # style of the header + cellColorStyle = "fs13 b1 fwn c222" # style of the cells + + headerList=['Index','LRS','Chr','Mb','Locus','Additive Effect'] + for ncol, item in enumerate(headerList): + reportHeaderRow.append(THCell(HT.TD(item, Class=headerStyle, valign='bottom',nowrap='ON'),text=item, idx=ncol)) + + if fd.genotype.type == 'intercross': + ncol =len(headerList) + reportHeaderRow.append(THCell(HT.TD('Dominance Effect', Class=headerStyle, valign='bottom',nowrap='ON'),text='Dominance Effect', idx=ncol)) + + #download file for table headers' names + fpText.write('LRS\tChromosome\tMb\tLocus\tAdditive Effect\tDominance Effect\n') + + index=1 + for ii in filtered: + #add by NL 06-20-2011: set LRS to 460 when LRS is infinite, + if ii.lrs==float('inf') or ii.lrs>webqtlConfig.MAXLRS: + LRS=webqtlConfig.MAXLRS #maximum LRS value + else: + LRS=ii.lrs + + if LRS > fd.significance: + lrs = HT.TD(HT.Font('%3.3f*' % LRS, color='#FF0000'),Class=cellColorStyle) + else: + lrs = HT.TD('%3.3f' % LRS,Class=cellColorStyle) + + if ii.locus.chr in ChrNameOrderIdDict.keys(): + chrOrderId =ChrNameOrderIdDict[ii.locus.chr] + else: + chrOrderId=ii.locus.chr + + reportBodyRow=[] # row list for tblobj_body (html part) + selectCheck=HT.Input(type="checkbox", Class="checkbox", name="index",value=index, onClick="highlight(this)") + reportBodyRow.append(TDCell(HT.TD(str(index),selectCheck, align='right',Class=cellColorStyle,nowrap='ON'),str(index),index)) + reportBodyRow.append(TDCell(lrs,LRS, LRS)) + reportBodyRow.append(TDCell(HT.TD(ii.locus.chr, Class=cellColorStyle, align="center",nowrap='ON'),ii.locus.chr, chrOrderId)) + reportBodyRow.append(TDCell(HT.TD('%3.6f'%ii.locus.Mb, Class=cellColorStyle, align="center",nowrap='ON'),ii.locus.Mb, ii.locus.Mb)) + reportBodyRow.append(TDCell(HT.TD(HT.Href(text=ii.locus.name, url = "javascript:showTrait('%s','%s');" % (locusFormName, ii.locus.name), Class='normalsize'), Class=cellColorStyle, align="center",nowrap='ON'),ii.locus.name, ii.locus.name)) + reportBodyRow.append(TDCell(HT.TD('%3.3f' % ii.additive, Class=cellColorStyle, align="center",nowrap='ON'),ii.additive, ii.additive)) + reportBodyRow.append(TDCell(HT.TD('%3.3f' % ii.dominance, Class=cellColorStyle, align="center",nowrap='ON'),ii.dominance, ii.dominance)) + + fpText.write('%2.3f\t%s\t%3.6f\t%s\t%2.3f\t%2.3f\n' % (LRS, ii.locus.chr, ii.locus.Mb, ii.locus.name, ii.additive, ii.dominance)) + index+=1 + tblobj_body.append(reportBodyRow) + else: + #download file for table headers' names + fpText.write('LRS\tChromosome\tMb\tLocus\tAdditive Effect\n') + + index=1 + for ii in filtered: + #add by NL 06-20-2011: set LRS to 460 when LRS is infinite, + if ii.lrs==float('inf') or ii.lrs>webqtlConfig.MAXLRS: + LRS=webqtlConfig.MAXLRS #maximum LRS value + else: + LRS=ii.lrs + + if LRS > fd.significance: + lrs = HT.TD(HT.Font('%3.3f*' % LRS, color='#FF0000'),Class=cellColorStyle) + else: + lrs = HT.TD('%3.3f' % LRS,Class=cellColorStyle) + + if ii.locus.chr in ChrNameOrderIdDict.keys(): + chrOrderId =ChrNameOrderIdDict[ii.locus.chr] + else: + chrOrderId=ii.locus.chr + + reportBodyRow=[] # row list for tblobj_body (html part) + selectCheck=HT.Input(type="checkbox", Class="checkbox", name="index",value=index, onClick="highlight(this)") + reportBodyRow.append(TDCell(HT.TD(str(index),selectCheck, align='right',Class=cellColorStyle,nowrap='ON'),str(index),index)) + reportBodyRow.append(TDCell(lrs,LRS, LRS)) + reportBodyRow.append(TDCell(HT.TD(ii.locus.chr, Class=cellColorStyle, align="center",nowrap='ON'),ii.locus.chr, chrOrderId)) + reportBodyRow.append(TDCell(HT.TD('%3.6f'%ii.locus.Mb, Class=cellColorStyle, align="center",nowrap='ON'),ii.locus.Mb, ii.locus.Mb)) + reportBodyRow.append(TDCell(HT.TD(HT.Href(text=ii.locus.name, url = "javascript:showTrait('%s','%s');" % (locusFormName, ii.locus.name), Class='normalsize'), Class=cellColorStyle, align="center",nowrap='ON'),ii.locus.name, ii.locus.name)) + reportBodyRow.append(TDCell(HT.TD('%3.3f' % ii.additive, Class=cellColorStyle, align="center",nowrap='ON'),ii.additive, ii.additive)) + + fpText.write('%2.3f\t%s\t%3.6f\t%s\t%2.3f\n' % (LRS, ii.locus.chr, ii.locus.Mb, ii.locus.name, ii.additive)) + index+=1 + tblobj_body.append(reportBodyRow) + + tblobj_header.append(reportHeaderRow) + tblobj['header']=tblobj_header + tblobj['body']=tblobj_body + + rv=HT.TD(regressionHeading,LRSInfo,report, locusForm, HT.P(),width='55%',valign='top', align='left', bgColor='#eeeeee') + if fd.genotype.type == 'intercross': + bottomInfo.append(HT.BR(), HT.BR(), HT.Strong('Dominance Effect'),' is the difference between the mean trait value of cases heterozygous at a marker and the average mean for the two groups homozygous at this marker: e.g., BD - (BB+DD)/2]. A positive dominance effect indicates that the average phenotype of BD heterozygotes exceeds the mean of BB and DD homozygotes. No dominance deviation can be computed for a set of recombinant inbred strains or for a backcross.') + return rv,tblobj,bottomInfo + + return rv,tblobj,bottomInfo + + def plotIntMappingForPLINK(self, fd, canvas, offset= (80, 120, 20, 80), zoom = 1, startMb = None, endMb = None, showLocusForm = "",plinkResultDict={}): + #calculating margins + xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset + + fontZoom = zoom + if zoom == 2: + fontZoom = 1.5 + + xLeftOffset = int(xLeftOffset*fontZoom) + xRightOffset = int(xRightOffset*fontZoom) + yBottomOffset = int(yBottomOffset*fontZoom) + + cWidth = canvas.size[0] + cHeight = canvas.size[1] + plotWidth = cWidth - xLeftOffset - xRightOffset + plotHeight = cHeight - yTopOffset - yBottomOffset + startPixelX = xLeftOffset + endPixelX = (xLeftOffset + plotWidth) + + #Drawing Area Height + drawAreaHeight = plotHeight + if self.plotScale == 'physic' and self.selectedChr > -1: # for single chr + drawAreaHeight -= self.ENSEMBL_BAND_HEIGHT + self.UCSC_BAND_HEIGHT+ self.WEBQTL_BAND_HEIGHT + 3*self.BAND_SPACING+ 10*zoom + if self.geneChecked: + drawAreaHeight -= self.NUM_GENE_ROWS*self.EACH_GENE_HEIGHT + 3*self.BAND_SPACING + 10*zoom + else: + if self.selectedChr > -1: + drawAreaHeight -= 20 + else:# for all chrs + drawAreaHeight -= 30 + + #Image map + gifmap = HT.Map(name='WebQTLImageMap') + + newoffset = (xLeftOffset, xRightOffset, yTopOffset, yBottomOffset) + # Draw the alternating-color background first and get plotXScale + plotXScale = self.drawGraphBackgroundForPLINK(canvas, gifmap, offset=newoffset, zoom= zoom, startMb=startMb, endMb = endMb,plinkResultDict=plinkResultDict) + + # Draw X axis + self.drawXAxisForPLINK(fd, canvas, drawAreaHeight, gifmap, plotXScale, showLocusForm, offset=newoffset, zoom= zoom, startMb=startMb, endMb = endMb) + # Draw manhattam plot + self.drawManhattanPlotForPLINK(canvas, drawAreaHeight, gifmap, plotXScale, offset=newoffset, zoom= zoom, startMb=startMb, endMb = endMb,plinkResultDict=plinkResultDict,thresholdPvalue=self.pValue) + + return gifmap + + + def plotIntMapping(self, fd, canvas, offset= (80, 120, 20, 80), zoom = 1, startMb = None, endMb = None, showLocusForm = ""): + #calculating margins + xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset + + fontZoom = zoom + if zoom == 2: + fontZoom = 1.5 + + xLeftOffset = int(xLeftOffset*fontZoom) + xRightOffset = int(xRightOffset*fontZoom) + yBottomOffset = int(yBottomOffset*fontZoom) + + cWidth = canvas.size[0] + cHeight = canvas.size[1] + plotWidth = cWidth - xLeftOffset - xRightOffset + plotHeight = cHeight - yTopOffset - yBottomOffset + startPixelX = xLeftOffset + endPixelX = (xLeftOffset + plotWidth) + + #Drawing Area Height + drawAreaHeight = plotHeight + if self.plotScale == 'physic' and self.selectedChr > -1: # for single chr + drawAreaHeight -= self.ENSEMBL_BAND_HEIGHT + self.UCSC_BAND_HEIGHT+ self.WEBQTL_BAND_HEIGHT + 3*self.BAND_SPACING+ 10*zoom + if self.geneChecked: + drawAreaHeight -= self.NUM_GENE_ROWS*self.EACH_GENE_HEIGHT + 3*self.BAND_SPACING + 10*zoom + else:# for all chrs + if self.selectedChr > -1: + drawAreaHeight -= 20 + else: + drawAreaHeight -= 30 + + #Image map + gifmap = HT.Map(name='WebQTLImageMap') + + newoffset = (xLeftOffset, xRightOffset, yTopOffset, yBottomOffset) + # Draw the alternating-color background first and get plotXScale + plotXScale = self.drawGraphBackground(canvas, gifmap, offset=newoffset, zoom= zoom, startMb=startMb, endMb = endMb) + + # Draw X axis + self.drawXAxis(fd, canvas, drawAreaHeight, gifmap, plotXScale, showLocusForm, offset=newoffset, zoom= zoom, startMb=startMb, endMb = endMb) + # Draw QTL curve + self.drawQTL(canvas, drawAreaHeight, gifmap, plotXScale, offset=newoffset, zoom= zoom, startMb=startMb, endMb = endMb) + + #draw legend + if self.multipleInterval: + self.drawMultiTraitName(fd, canvas, gifmap, showLocusForm, offset=newoffset) + elif self.legendChecked: + self.drawLegendPanel(fd, canvas, offset=newoffset) + else: + pass + + #draw position, no need to use a separate function + if fd.genotype.Mbmap: + self.drawProbeSetPosition(canvas, plotXScale, offset=newoffset) + + return gifmap + + + # functions for manhattam plot of markers + def drawManhattanPlotForPLINK(self, canvas, drawAreaHeight, gifmap, plotXScale, offset= (40, 120, 80, 10), zoom = 1, startMb = None, endMb = None,plinkResultDict={},thresholdPvalue=-1): + + xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset + plotWidth = canvas.size[0] - xLeftOffset - xRightOffset + plotHeight = canvas.size[1] - yTopOffset - yBottomOffset + fontZoom = zoom + if zoom == 2: + fontZoom = 1.5 + + # INTERCROSS = (self.genotype.type=="intercross") + INTERCROSS ='' #?????? + + ChrLengthDistList = self.ChrLengthMbList + drawRegionDistance = self.ChrLengthMbSum + GraphInterval=self.GraphInterval + pvalueHeightThresh = drawAreaHeight - 80 #ZS: Otherwise the plot gets very close to the chromosome labels + + #draw the pvalue scale + #We first determine whether or not we are using a sliding scale. + #If so, we need to compute the maximum pvalue value to determine where the max y-value should be, and call this pvalueMax. + #pvalueTop is then defined to be above the pvalueMax by enough to add one additional pvalueScale increment. + #if we are using a set-scale, then we set pvalueTop to be the user's value, and pvalueMax doesn't matter. + + # for human data we use p value instead of lrs + pValueList=[] + for key in plinkResultDict: + valueList = plinkResultDict[key] + for item in valueList: + pValue = item[-1] + pValueList.append(pValue) + + formattedPValueList=[] + for pValue in pValueList: + try: + pValue=float(pValue) + except: + pValue =1 + formattedpValue = -math.log10(pValue) + formattedPValueList.append(formattedpValue) + + #sliding scale + pvalueMax = max(formattedPValueList) + #pvalueMax =pvalueMax +1 + # no permutation result for plink func: GenReport() + pvalueMin = int(-math.log10(thresholdPvalue)) + + if pvalueMax> 100: + pvalueScale = 20.0 + elif pvalueMax > 20: + pvalueScale = 5.0 + elif pvalueMax > 7.5: + pvalueScale = 2.5 + else: + pvalueScale = 1.0 + + # the base line for x-axis is -log(thresholdPvalue) + pvalueAxisList = Plot.frange(pvalueMin, pvalueMax, pvalueScale) + #make sure the user's value appears on the y-axis + #ZS: There is no way to do this without making the position of the points not directly proportional to a given distance on the y-axis + #tempPvalueMax=round(pvalueMax) + tempPvalueMax = pvalueAxisList[len(pvalueAxisList)-1] + pvalueScale + pvalueAxisList.append(tempPvalueMax) + + #ZS: I don't understand this; the if statement will be true for any number that isn't exactly X.5. + #if abs(tempPvalueMax-pvalueMax) <0.5: + # tempPvalueMax=tempPvalueMax+1 + # pvalueAxisList.append(tempPvalueMax) + + #draw the "pvalue" string to the left of the axis + pvalueScaleFont=pid.Font(ttf="verdana", size=14*fontZoom, bold=0) + pvalueLODFont=pid.Font(ttf="verdana", size=14*zoom*1.5, bold=0) + yZero = yTopOffset + plotHeight + + #yAxis label display area + yAxis_label ='-log(P)' + canvas.drawString(yAxis_label, xLeftOffset - canvas.stringWidth("999.99", font=pvalueScaleFont) - 10*zoom, \ + yZero - 150, font=pvalueLODFont, color=pid.black, angle=90) + + for i,item in enumerate(pvalueAxisList): + ypvalue = yZero - (float(i)/float(len(pvalueAxisList) - 1)) * pvalueHeightThresh + canvas.drawLine(xLeftOffset, ypvalue, xLeftOffset - 4, ypvalue, color=self.LRS_COLOR, width=1*zoom) + scaleStr = "%2.1f" % item + #added by NL 6-24-2011:Y-axis scale display + canvas.drawString(scaleStr, xLeftOffset-4-canvas.stringWidth(scaleStr, font=pvalueScaleFont)-5, ypvalue+3, font=pvalueScaleFont, color=self.LRS_COLOR) + + ChrList=self.ChrList + startPosX = xLeftOffset + + for i, chr in enumerate(ChrList): + + if plinkResultDict.has_key(chr): + plinkresultList = plinkResultDict[chr] + + m = 0 + #add by NL 06-24-2011: for mahanttam plot + symbolFont = pid.Font(ttf="fnt_bs", size=5,bold=0) + # color for point in each chr + chrCount=len(ChrList) + chrColorDict =self.getColorForMarker(chrCount=chrCount,flag=1) + for j, item in enumerate(plinkresultList): + try : + mb=float(item[1])/1000000.0 + except: + mb=0 + + try : + pvalue =float(item[-1]) + except: + pvalue =1 + + try: + snpName = item[0] + except: + snpName='' + + formattedPvalue = -math.log10(pvalue) + + Xc = startPosX + (mb-startMb)*plotXScale + Yc = yZero - (formattedPvalue-pvalueMin)*pvalueHeightThresh/(tempPvalueMax - pvalueMin) + canvas.drawString("5", Xc-canvas.stringWidth("5",font=symbolFont)/2+1,Yc+2,color=chrColorDict[i], font=symbolFont) + m += 1 + + startPosX += (ChrLengthDistList[i]+GraphInterval)*plotXScale + + canvas.drawLine(xLeftOffset, yZero, xLeftOffset, yTopOffset, color=self.LRS_COLOR, width=1*zoom) #the blue line running up the y axis + + def drawQTL(self, canvas, drawAreaHeight, gifmap, plotXScale, offset= (40, 120, 80, 10), zoom = 1, startMb = None, endMb = None): + + xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset + plotWidth = canvas.size[0] - xLeftOffset - xRightOffset + plotHeight = canvas.size[1] - yTopOffset - yBottomOffset + fontZoom = zoom + if zoom == 2: + fontZoom = 1.5 + + INTERCROSS = (self.genotype.type=="intercross") + + ChrLengthDistList = self.ChrLengthMbList + GraphInterval=self.GraphInterval + LRSHeightThresh = drawAreaHeight + AdditiveHeightThresh = drawAreaHeight/2 + DominanceHeightThresh = drawAreaHeight/2 + + #draw the LRS scale + #We first determine whether or not we are using a sliding scale. + #If so, we need to compute the maximum LRS value to determine where the max y-value should be, and call this LRSMax. + #LRSTop is then defined to be above the LRSMax by enough to add one additional LRSScale increment. + #if we are using a set-scale, then we set LRSTop to be the user's value, and LRSMax doesn't matter. + + if self.LRS_LOD == 'LOD': + lodm = self.LODFACTOR + else: + lodm = 1.0 + + if self.lrsMax <= 0: #sliding scale + LRSMax = max(map(max, self.qtlresults)).lrs + #genotype trait will give infinite LRS + LRSMax = min(LRSMax, webqtlConfig.MAXLRS) + LRSMax = max(self.significance, LRSMax) + else: + LRSMax = self.lrsMax*lodm + + if LRSMax/lodm > 100: + LRSScale = 20.0 + elif LRSMax/lodm > 20: + LRSScale = 5.0 + elif LRSMax/lodm > 7.5: + LRSScale = 2.5 + else: + LRSScale = 1.0 + + LRSAxisList = Plot.frange(LRSScale, LRSMax/lodm, LRSScale) + #make sure the user's value appears on the y-axis + #update by NL 6-21-2011: round the LOD value to 100 when LRSMax is equal to 460 + LRSAxisList.append(round(LRSMax/lodm)) + + #draw the "LRS" or "LOD" string to the left of the axis + LRSScaleFont=pid.Font(ttf="verdana", size=14*fontZoom, bold=0) + LRSLODFont=pid.Font(ttf="verdana", size=14*zoom*1.5, bold=0) + yZero = yTopOffset + plotHeight + + #yAxis label display area + canvas.drawString(self.LRS_LOD, xLeftOffset - canvas.stringWidth("999.99", font=LRSScaleFont) - 10*zoom, \ + yZero - 150, font=LRSLODFont, color=pid.black, angle=90) + + for item in LRSAxisList: + yLRS = yZero - (item*lodm/LRSMax) * LRSHeightThresh + canvas.drawLine(xLeftOffset, yLRS, xLeftOffset - 4, yLRS, color=self.LRS_COLOR, width=1*zoom) + scaleStr = "%2.1f" % item + #added by NL 6-24-2011:Y-axis scale display + canvas.drawString(scaleStr, xLeftOffset-4-canvas.stringWidth(scaleStr, font=LRSScaleFont)-5, yLRS+3, font=LRSScaleFont, color=self.LRS_COLOR) + + + #"Significant" and "Suggestive" Drawing Routine + # ======= Draw the thick lines for "Significant" and "Suggestive" ===== (crowell: I tried to make the SNPs draw over these lines, but piddle wouldn't have it...) + if self.permChecked and not self.multipleInterval: + significantY = yZero - self.significance*LRSHeightThresh/LRSMax + suggestiveY = yZero - self.suggestive*LRSHeightThresh/LRSMax + + + startPosX = xLeftOffset + for i, _chr in enumerate(self.genotype): + rightEdge = int(startPosX + self.ChrLengthDistList[i]*plotXScale - self.SUGGESTIVE_WIDTH/1.5) + #added by NL 6-24-2011:draw suggestive line (grey one) + canvas.drawLine(startPosX+self.SUGGESTIVE_WIDTH/1.5, suggestiveY, rightEdge, suggestiveY, color=self.SUGGESTIVE_COLOR, + width=self.SUGGESTIVE_WIDTH*zoom, clipX=(xLeftOffset, xLeftOffset + plotWidth-2)) + #added by NL 6-24-2011:draw significant line (pink one) + canvas.drawLine(startPosX+self.SUGGESTIVE_WIDTH/1.5, significantY, rightEdge, significantY, color=self.SIGNIFICANT_COLOR, + width=self.SIGNIFICANT_WIDTH*zoom, clipX=(xLeftOffset, xLeftOffset + plotWidth-2)) + sugg_coords = "%d, %d, %d, %d" % (startPosX, suggestiveY-2, rightEdge + 2*zoom, suggestiveY+2) + sig_coords = "%d, %d, %d, %d" % (startPosX, significantY-2, rightEdge + 2*zoom, significantY+2) + if self.LRS_LOD == 'LRS': + sugg_title = "Suggestive LRS = %0.2f" % self.suggestive + sig_title = "Significant LRS = %0.2f" % self.significance + else: + sugg_title = "Suggestive LOD = %0.2f" % (self.suggestive/4.61) + sig_title = "Significant LOD = %0.2f" % (self.significance/4.61) + Areas1 = HT.Area(shape='rect',coords=sugg_coords,title=sugg_title) + Areas2 = HT.Area(shape='rect',coords=sig_coords,title=sig_title) + gifmap.areas.append(Areas1) + gifmap.areas.append(Areas2) + + startPosX += (self.ChrLengthDistList[i]+self.GraphInterval)*plotXScale + + + if self.multipleInterval: + lrsEdgeWidth = 1 + else: + additiveMax = max(map(lambda X : abs(X.additive), self.qtlresults[0])) + if INTERCROSS: + dominanceMax = max(map(lambda X : abs(X.dominance), self.qtlresults[0])) + else: + dominanceMax = -1 + lrsEdgeWidth = 2 + for i, qtlresult in enumerate(self.qtlresults): + m = 0 + startPosX = xLeftOffset + thisLRSColor = self.colorCollection[i] + + #add by NL 06-24-2011: for mahanttam plot + symbolFont = pid.Font(ttf="fnt_bs", size=5,bold=0) + + for j, _chr in enumerate(self.genotype): + chrCount=len(self.genotype) + chrColorDict =self.getColorForMarker(chrCount=chrCount,flag=1) + LRSCoordXY = [] + AdditiveCoordXY = [] + DominanceCoordXY = [] + for k, _locus in enumerate(_chr): + if self.plotScale == 'physic': + Xc = startPosX + (_locus.Mb-startMb)*plotXScale + else: + Xc = startPosX + (_locus.cM-_chr[0].cM)*plotXScale + # updated by NL 06-18-2011: + # fix the over limit LRS graph issue since genotype trait may give infinite LRS; + # for any lrs is over than 460(LRS max in this system), it will be reset to 460 + if qtlresult[m].lrs> 460 or qtlresult[m].lrs=='inf': + Yc = yZero - webqtlConfig.MAXLRS*LRSHeightThresh/LRSMax + else: + Yc = yZero - qtlresult[m].lrs*LRSHeightThresh/LRSMax + + LRSCoordXY.append((Xc, Yc)) + #add by NL 06-24-2011: for mahanttam plot + #self.significance/4.61 consider chr and LOD + # significantY = yZero - self.significance*LRSHeightThresh/LRSMax + # if Yc >significantY: + # canvas.drawString(":", Xc-canvas.stringWidth(":",font=symbolFont)/2+1,Yc+2,color=pid.black, font=symbolFont) + # else: + # canvas.drawString(":", Xc-canvas.stringWidth(":",font=symbolFont)/2+1,Yc+2,color=pid.black, font=symbolFont) + + # add by NL 06-27-2011: eliminate imputed value when locus name is equal to '-' + if (qtlresult[m].locus.name) and (qtlresult[m].locus.name!=' - '): + canvas.drawString("5", Xc-canvas.stringWidth("5",font=symbolFont)/2+1,Yc+2,color=chrColorDict[j], font=symbolFont) + + if not self.multipleInterval and self.additiveChecked: + Yc = yZero - qtlresult[m].additive*AdditiveHeightThresh/additiveMax + AdditiveCoordXY.append((Xc, Yc)) + if not self.multipleInterval and INTERCROSS and self.additiveChecked: + Yc = yZero - qtlresult[m].dominance*DominanceHeightThresh/dominanceMax + DominanceCoordXY.append((Xc, Yc)) + m += 1 + + startPosX += (ChrLengthDistList[j]+GraphInterval)*plotXScale + + + ###draw additive scale + if not self.multipleInterval and self.additiveChecked: + additiveScaleFont=pid.Font(ttf="verdana",size=12*fontZoom,bold=0) + additiveScale = Plot.detScaleOld(0,additiveMax) + additiveStep = (additiveScale[1]-additiveScale[0])/additiveScale[2] + additiveAxisList = Plot.frange(0, additiveScale[1], additiveStep) + maxAdd = additiveScale[1] + addPlotScale = AdditiveHeightThresh/additiveMax + + additiveAxisList.append(additiveScale[1]) + for item in additiveAxisList: + additiveY = yZero - item*addPlotScale + canvas.drawLine(xLeftOffset + plotWidth,additiveY,xLeftOffset+4+ plotWidth,additiveY,color=self.ADDITIVE_COLOR_POSITIVE, width=1*zoom) + scaleStr = "%2.3f" % item + canvas.drawString(scaleStr,xLeftOffset + plotWidth +6,additiveY+5,font=additiveScaleFont,color=self.ADDITIVE_COLOR_POSITIVE) + + canvas.drawLine(xLeftOffset+plotWidth,additiveY,xLeftOffset+plotWidth,yZero,color=self.ADDITIVE_COLOR_POSITIVE, width=1*zoom) + + canvas.drawLine(xLeftOffset, yZero, xLeftOffset, yTopOffset, color=self.LRS_COLOR, width=1*zoom) #the blue line running up the y axis + + def drawGraphBackgroundForPLINK(self, canvas, gifmap, offset= (80, 120, 80, 50), zoom = 1, startMb = None, endMb = None,plinkResultDict={} ): + + xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset + plotWidth = canvas.size[0] - xLeftOffset - xRightOffset + plotHeight = canvas.size[1] - yTopOffset - yBottomOffset + fontZoom = zoom + if zoom == 2: + fontZoom = 1.5 + + #calculate plot scale + #XZ: all of these global variables should be passed from function signiture + ChrLengthDistList = self.ChrLengthMbList + drawRegionDistance = self.ChrLengthMbSum + GraphInterval=self.GraphInterval + ChrList =self.ChrList + + #multiple chromosome view + plotXScale = plotWidth / ((len(ChrList)-1)*GraphInterval + drawRegionDistance) + + startPosX = xLeftOffset + chrLabelFont=pid.Font(ttf="verdana",size=24*fontZoom,bold=0) + + for i, _chr in enumerate(ChrList): + + if (i % 2 == 0): + theBackColor = self.GRAPH_BACK_DARK_COLOR + else: + theBackColor = self.GRAPH_BACK_LIGHT_COLOR + # NL:resize chr width for drawing + if float(ChrLengthDistList[i])<90: + ChrLengthDistList[i]=90 + #draw the shaded boxes and the sig/sug thick lines + canvas.drawRect(startPosX, yTopOffset, startPosX + ChrLengthDistList[i]*plotXScale, \ + yTopOffset+plotHeight, edgeColor=pid.gainsboro,fillColor=theBackColor) + + chrNameWidth = canvas.stringWidth(_chr, font=chrLabelFont) + chrStartPix = startPosX + (ChrLengthDistList[i]*plotXScale -chrNameWidth)/2 + chrEndPix = startPosX + (ChrLengthDistList[i]*plotXScale +chrNameWidth)/2 + + canvas.drawString(_chr, chrStartPix, yTopOffset +20,font = chrLabelFont,color=pid.dimgray) + COORDS = "%d,%d,%d,%d" %(chrStartPix, yTopOffset, chrEndPix,yTopOffset +20) + + #add by NL 09-03-2010 + HREF = "javascript:changeView(%d,%s);" % (i,ChrLengthDistList) + Areas = HT.Area(shape='rect',coords=COORDS,href=HREF) + gifmap.areas.append(Areas) + startPosX += (ChrLengthDistList[i]+GraphInterval)*plotXScale + + return plotXScale + + + def drawGraphBackground(self, canvas, gifmap, offset= (80, 120, 80, 50), zoom = 1, startMb = None, endMb = None): + ##conditions + ##multiple Chromosome view + ##single Chromosome Physical + ##single Chromosome Genetic + xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset + plotWidth = canvas.size[0] - xLeftOffset - xRightOffset + plotHeight = canvas.size[1] - yTopOffset - yBottomOffset + fontZoom = zoom + if zoom == 2: + fontZoom = 1.5 + + #calculate plot scale + if self.plotScale != 'physic': + self.ChrLengthDistList = self.ChrLengthCMList + drawRegionDistance = self.ChrLengthCMSum + else: + self.ChrLengthDistList = self.ChrLengthMbList + drawRegionDistance = self.ChrLengthMbSum + + if self.selectedChr > -1: #single chromosome view + spacingAmt = plotWidth/13.5 + i = 0 + for startPix in Plot.frange(xLeftOffset, xLeftOffset+plotWidth, spacingAmt): + if (i % 2 == 0): + theBackColor = self.GRAPH_BACK_DARK_COLOR + else: + theBackColor = self.GRAPH_BACK_LIGHT_COLOR + i += 1 + canvas.drawRect(startPix, yTopOffset, min(startPix+spacingAmt, xLeftOffset+plotWidth), \ + yTopOffset+plotHeight, edgeColor=theBackColor, fillColor=theBackColor) + + drawRegionDistance = self.ChrLengthDistList[self.selectedChr] + self.ChrLengthDistList = [drawRegionDistance] + if self.plotScale == 'physic': + plotXScale = plotWidth / (endMb-startMb) + else: + plotXScale = plotWidth / drawRegionDistance + + else: #multiple chromosome view + plotXScale = plotWidth / ((len(self.genotype)-1)*self.GraphInterval + drawRegionDistance) + + startPosX = xLeftOffset + chrLabelFont=pid.Font(ttf="verdana",size=24*fontZoom,bold=0) + + for i, _chr in enumerate(self.genotype): + + if (i % 2 == 0): + theBackColor = self.GRAPH_BACK_DARK_COLOR + else: + theBackColor = self.GRAPH_BACK_LIGHT_COLOR + + #draw the shaded boxes and the sig/sug thick lines + canvas.drawRect(startPosX, yTopOffset, startPosX + self.ChrLengthDistList[i]*plotXScale, \ + yTopOffset+plotHeight, edgeColor=pid.gainsboro,fillColor=theBackColor) + + chrNameWidth = canvas.stringWidth(_chr.name, font=chrLabelFont) + chrStartPix = startPosX + (self.ChrLengthDistList[i]*plotXScale -chrNameWidth)/2 + chrEndPix = startPosX + (self.ChrLengthDistList[i]*plotXScale +chrNameWidth)/2 + + canvas.drawString(_chr.name, chrStartPix, yTopOffset +20,font = chrLabelFont,color=pid.dimgray) + COORDS = "%d,%d,%d,%d" %(chrStartPix, yTopOffset, chrEndPix,yTopOffset +20) + + #add by NL 09-03-2010 + HREF = "javascript:changeView(%d,%s);" % (i,self.ChrLengthMbList) + Areas = HT.Area(shape='rect',coords=COORDS,href=HREF) + gifmap.areas.append(Areas) + startPosX += (self.ChrLengthDistList[i]+self.GraphInterval)*plotXScale + + return plotXScale + + # XZ: The only difference of function drawXAxisForPLINK and function drawXAxis are the function name and the self.plotScale condition. + def drawXAxisForPLINK(self, fd, canvas, drawAreaHeight, gifmap, plotXScale, showLocusForm, offset= (40, 120, 80, 10), zoom = 1, startMb = None, endMb = None): + xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset + plotWidth = canvas.size[0] - xLeftOffset - xRightOffset + plotHeight = canvas.size[1] - yTopOffset - yBottomOffset + yZero = canvas.size[1] - yBottomOffset + fontZoom = zoom + if zoom == 2: + fontZoom = 1.5 + + #Parameters + ChrLengthDistList = self.ChrLengthMbList + GraphInterval=self.GraphInterval + + NUM_MINOR_TICKS = 5 # Number of minor ticks between major ticks + X_MAJOR_TICK_THICKNESS = 2 + X_MINOR_TICK_THICKNESS = 1 + X_AXIS_THICKNESS = 1*zoom + + # ======= Alex: Draw the X-axis labels (megabase location) + MBLabelFont = pid.Font(ttf="verdana", size=12*fontZoom, bold=0) + xMajorTickHeight = 15 # How high the tick extends below the axis + xMinorTickHeight = 5*zoom + xAxisTickMarkColor = pid.black + xAxisLabelColor = pid.black + fontHeight = 12*fontZoom # How tall the font that we're using is + spacingFromLabelToAxis = 20 + spacingFromLineToLabel = 3 + + if self.plotScale == 'physic': + strYLoc = yZero + spacingFromLabelToAxis + canvas.fontHeight(MBLabelFont) + ###Physical single chromosome view + if self.selectedChr > -1: + graphMbWidth = endMb - startMb + XScale = Plot.detScale(startMb, endMb) + XStart, XEnd, XStep = XScale + if XStep < 8: + XStep *= 2 + spacingAmtX = spacingAmt = (XEnd-XStart)/XStep + + j = 0 + while abs(spacingAmtX -int(spacingAmtX)) >= spacingAmtX/100.0 and j < 6: + j += 1 + spacingAmtX *= 10 + + formatStr = '%%2.%df' % j + + for counter, _Mb in enumerate(Plot.frange(XStart, XEnd, spacingAmt / NUM_MINOR_TICKS)): + if _Mb < startMb or _Mb > endMb: + continue + Xc = xLeftOffset + plotXScale*(_Mb - startMb) + if counter % NUM_MINOR_TICKS == 0: # Draw a MAJOR mark, not just a minor tick mark + canvas.drawLine(Xc, yZero, Xc, yZero+xMajorTickHeight, color=xAxisTickMarkColor, width=X_MAJOR_TICK_THICKNESS) # Draw the MAJOR tick mark + labelStr = str(formatStr % _Mb) # What Mbase location to put on the label + strWidth = canvas.stringWidth(labelStr, font=MBLabelFont) + drawStringXc = (Xc - (strWidth / 2.0)) + canvas.drawString(labelStr, drawStringXc, strYLoc, font=MBLabelFont, color=xAxisLabelColor, angle=0) + else: + canvas.drawLine(Xc, yZero, Xc, yZero+xMinorTickHeight, color=xAxisTickMarkColor, width=X_MINOR_TICK_THICKNESS) # Draw the MINOR tick mark + # end else + + ###Physical genome wide view + else: + distScale = 0 + startPosX = xLeftOffset + for i, distLen in enumerate(ChrLengthDistList): + if distScale == 0: #universal scale in whole genome mapping + if distLen > 75: + distScale = 25 + elif distLen > 30: + distScale = 10 + else: + distScale = 5 + for tickdists in range(distScale, ceil(distLen), distScale): + canvas.drawLine(startPosX + tickdists*plotXScale, yZero, startPosX + tickdists*plotXScale, yZero + 7, color=pid.black, width=1*zoom) + canvas.drawString(str(tickdists), startPosX+tickdists*plotXScale, yZero + 10*zoom, color=pid.black, font=MBLabelFont, angle=270) + startPosX += (ChrLengthDistList[i]+GraphInterval)*plotXScale + + megabaseLabelFont = pid.Font(ttf="verdana", size=14*zoom*1.5, bold=0) + canvas.drawString("Megabases", xLeftOffset + (plotWidth -canvas.stringWidth("Megabases", font=megabaseLabelFont))/2, + strYLoc + canvas.fontHeight(MBLabelFont) + 5*zoom, font=megabaseLabelFont, color=pid.black) + pass + + canvas.drawLine(xLeftOffset, yZero, xLeftOffset+plotWidth, yZero, color=pid.black, width=X_AXIS_THICKNESS) # Draw the X axis itself + + def drawXAxis(self, fd, canvas, drawAreaHeight, gifmap, plotXScale, showLocusForm, offset= (40, 120, 80, 10), zoom = 1, startMb = None, endMb = None): + xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset + plotWidth = canvas.size[0] - xLeftOffset - xRightOffset + plotHeight = canvas.size[1] - yTopOffset - yBottomOffset + yZero = canvas.size[1] - yBottomOffset + fontZoom = zoom + if zoom == 2: + fontZoom = 1.5 + + #Parameters + NUM_MINOR_TICKS = 5 # Number of minor ticks between major ticks + X_MAJOR_TICK_THICKNESS = 2 + X_MINOR_TICK_THICKNESS = 1 + X_AXIS_THICKNESS = 1*zoom + + # ======= Alex: Draw the X-axis labels (megabase location) + MBLabelFont = pid.Font(ttf="verdana", size=12*fontZoom, bold=0) + xMajorTickHeight = 15 # How high the tick extends below the axis + xMinorTickHeight = 5*zoom + xAxisTickMarkColor = pid.black + xAxisLabelColor = pid.black + fontHeight = 12*fontZoom # How tall the font that we're using is + spacingFromLabelToAxis = 20 + spacingFromLineToLabel = 3 + + if self.plotScale == 'physic': + strYLoc = yZero + spacingFromLabelToAxis + canvas.fontHeight(MBLabelFont) + ###Physical single chromosome view + if self.selectedChr > -1: + graphMbWidth = endMb - startMb + XScale = Plot.detScale(startMb, endMb) + XStart, XEnd, XStep = XScale + if XStep < 8: + XStep *= 2 + spacingAmtX = spacingAmt = (XEnd-XStart)/XStep + + j = 0 + while abs(spacingAmtX -int(spacingAmtX)) >= spacingAmtX/100.0 and j < 6: + j += 1 + spacingAmtX *= 10 + + formatStr = '%%2.%df' % j + + for counter, _Mb in enumerate(Plot.frange(XStart, XEnd, spacingAmt / NUM_MINOR_TICKS)): + if _Mb < startMb or _Mb > endMb: + continue + Xc = xLeftOffset + plotXScale*(_Mb - startMb) + if counter % NUM_MINOR_TICKS == 0: # Draw a MAJOR mark, not just a minor tick mark + canvas.drawLine(Xc, yZero, Xc, yZero+xMajorTickHeight, color=xAxisTickMarkColor, width=X_MAJOR_TICK_THICKNESS) # Draw the MAJOR tick mark + labelStr = str(formatStr % _Mb) # What Mbase location to put on the label + strWidth = canvas.stringWidth(labelStr, font=MBLabelFont) + drawStringXc = (Xc - (strWidth / 2.0)) + canvas.drawString(labelStr, drawStringXc, strYLoc, font=MBLabelFont, color=xAxisLabelColor, angle=0) + else: + canvas.drawLine(Xc, yZero, Xc, yZero+xMinorTickHeight, color=xAxisTickMarkColor, width=X_MINOR_TICK_THICKNESS) # Draw the MINOR tick mark + # end else + + ###Physical genome wide view + else: + distScale = 0 + startPosX = xLeftOffset + for i, distLen in enumerate(self.ChrLengthDistList): + if distScale == 0: #universal scale in whole genome mapping + if distLen > 75: + distScale = 25 + elif distLen > 30: + distScale = 10 + else: + distScale = 5 + for tickdists in range(distScale, ceil(distLen), distScale): + canvas.drawLine(startPosX + tickdists*plotXScale, yZero, startPosX + tickdists*plotXScale, yZero + 7, color=pid.black, width=1*zoom) + canvas.drawString(str(tickdists), startPosX+tickdists*plotXScale, yZero + 10*zoom, color=pid.black, font=MBLabelFont, angle=270) + startPosX += (self.ChrLengthDistList[i]+self.GraphInterval)*plotXScale + + megabaseLabelFont = pid.Font(ttf="verdana", size=14*zoom*1.5, bold=0) + canvas.drawString("Megabases", xLeftOffset + (plotWidth -canvas.stringWidth("Megabases", font=megabaseLabelFont))/2, + strYLoc + canvas.fontHeight(MBLabelFont) + 5*zoom, font=megabaseLabelFont, color=pid.black) + pass + else: + ChrAInfo = [] + preLpos = -1 + distinctCount = 0.0 + if len(self.genotype) > 1: + for i, _chr in enumerate(self.genotype): + thisChr = [] + Locus0CM = _chr[0].cM + nLoci = len(_chr) + if nLoci <= 8: + for _locus in _chr: + if _locus.name != ' - ': + if _locus.cM != preLpos: + distinctCount += 1 + preLpos = _locus.cM + thisChr.append([_locus.name, _locus.cM-Locus0CM]) + else: + for j in (0, nLoci/4, nLoci/2, nLoci*3/4, -1): + while _chr[j].name == ' - ': + j += 1 + if _chr[j].cM != preLpos: + distinctCount += 1 + preLpos = _chr[j].cM + thisChr.append([_chr[j].name, _chr[j].cM-Locus0CM]) + ChrAInfo.append(thisChr) + else: + for i, _chr in enumerate(self.genotype): + thisChr = [] + Locus0CM = _chr[0].cM + for _locus in _chr: + if _locus.name != ' - ': + if _locus.cM != preLpos: + distinctCount += 1 + preLpos = _locus.cM + thisChr.append([_locus.name, _locus.cM-Locus0CM]) + ChrAInfo.append(thisChr) + + stepA = (plotWidth+0.0)/distinctCount + + LRectWidth = 10 + LRectHeight = 3 + offsetA = -stepA + lineColor = pid.lightblue + startPosX = xLeftOffset + for j, ChrInfo in enumerate(ChrAInfo): + preLpos = -1 + for i, item in enumerate(ChrInfo): + Lname,Lpos = item + if Lpos != preLpos: + offsetA += stepA + differ = 1 + else: + differ = 0 + preLpos = Lpos + Lpos *= plotXScale + if self.selectedChr > -1: + Zorder = i % 5 + else: + Zorder = 0 + if differ: + canvas.drawLine(startPosX+Lpos,yZero,xLeftOffset+offsetA,\ + yZero+25, color=lineColor) + canvas.drawLine(xLeftOffset+offsetA,yZero+25,xLeftOffset+offsetA,\ + yZero+40+Zorder*(LRectWidth+3),color=lineColor) + rectColor = pid.orange + else: + canvas.drawLine(xLeftOffset+offsetA, yZero+40+Zorder*(LRectWidth+3)-3,\ + xLeftOffset+offsetA, yZero+40+Zorder*(LRectWidth+3),color=lineColor) + rectColor = pid.deeppink + canvas.drawRect(xLeftOffset+offsetA, yZero+40+Zorder*(LRectWidth+3),\ + xLeftOffset+offsetA-LRectHeight,yZero+40+Zorder*(LRectWidth+3)+LRectWidth,\ + edgeColor=rectColor,fillColor=rectColor,edgeWidth = 0) + COORDS="%d,%d,%d,%d"%(xLeftOffset+offsetA-LRectHeight, yZero+40+Zorder*(LRectWidth+3),\ + xLeftOffset+offsetA,yZero+40+Zorder*(LRectWidth+3)+LRectWidth) + HREF="javascript:showDatabase3('%s','%s','%s','');" % (showLocusForm,fd.RISet+"Geno", Lname) + Areas=HT.Area(shape='rect',coords=COORDS,href=HREF, title="Locus : " + Lname) + gifmap.areas.append(Areas) + ##piddle bug + if j == 0: + canvas.drawLine(startPosX,yZero,startPosX,yZero+40, color=lineColor) + startPosX += (self.ChrLengthDistList[j]+self.GraphInterval)*plotXScale + + canvas.drawLine(xLeftOffset, yZero, xLeftOffset+plotWidth, yZero, color=pid.black, width=X_AXIS_THICKNESS) # Draw the X axis itself + + def getColorForMarker(self, chrCount,flag):# no change is needed + chrColorDict={} + for i in range(chrCount): + if flag==1: # display blue and lightblue intercross + chrColorDict[i]=pid.black + elif flag==0: + if (i%2==0): + chrColorDict[i]=pid.blue + else: + chrColorDict[i]=pid.lightblue + else:#display different color for different chr + if i in [0,8,16]: + chrColorDict[i]=pid.black + elif i in [1,9,17]: + chrColorDict[i]=pid.red + elif i in [2,10,18]: + chrColorDict[i]=pid.lightgreen + elif i in [3,11,19]: + chrColorDict[i]=pid.blue + elif i in [4,12]: + chrColorDict[i]=pid.lightblue + elif i in [5,13]: + chrColorDict[i]=pid.hotpink + elif i in [6,14]: + chrColorDict[i]=pid.gold + elif i in [7,15]: + chrColorDict[i]=pid.grey + + return chrColorDict + + + def drawProbeSetPosition(self, canvas, plotXScale, offset= (40, 120, 80, 10), zoom = 1, startMb = None, endMb = None): + if len(self.traitList) != 1: + return + + xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset + plotWidth = canvas.size[0] - xLeftOffset - xRightOffset + plotHeight = canvas.size[1] - yTopOffset - yBottomOffset + yZero = canvas.size[1] - yBottomOffset + fontZoom = zoom + if zoom == 2: + fontZoom = 1.5 + + try: + Chr = self.traitList[0].chr # self.traitListChr =self.traitList[0].chr=_vals need to change to chrList and mbList + Mb = self.traitList[0].mb # self.traitListMb =self.traitList[0].mb=_vals + except: + return + + if self.plotScale == 'physic': + if self.selectedChr > -1: + if self.genotype[0].name != Chr or Mb < self.startMb or Mb > self.endMb: + return + else: + locPixel = xLeftOffset + (Mb-self.startMb)*plotXScale + else: + locPixel = xLeftOffset + for i, _chr in enumerate(self.genotype): + if _chr.name != Chr: + locPixel += (self.ChrLengthDistList[i] + self.GraphInterval)*plotXScale + else: + locPixel += Mb*plotXScale + break + else: + if self.selectedChr > -1: + if self.genotype[0].name != Chr: + return + else: + for i, _locus in enumerate(self.genotype[0]): + #the trait's position is on the left of the first genotype + if i==0 and _locus.Mb >= Mb: + locPixel=-1 + break + + #the trait's position is between two traits + if i > 0 and self.genotype[0][i-1].Mb < Mb and _locus.Mb >= Mb: + locPixel = xLeftOffset + plotXScale*(self.genotype[0][i-1].cM+(_locus.cM-self.genotype[0][i-1].cM)*(Mb -self.genotype[0][i-1].Mb)/(_locus.Mb-self.genotype[0][i-1].Mb)) + break + + #the trait's position is on the right of the last genotype + if i==len(self.genotype[0]) and Mb>=_locus.Mb: + locPixel = -1 + else: + locPixel = xLeftOffset + for i, _chr in enumerate(self.genotype): + if _chr.name != Chr: + locPixel += (self.ChrLengthDistList[i] + self.GraphInterval)*plotXScale + else: + locPixel += (Mb*(_chr[-1].cM-_chr[0].cM)/self.ChrLengthCMList[i])*plotXScale + break + if locPixel >= 0: + traitPixel = ((locPixel, yZero), (locPixel-6, yZero+12), (locPixel+6, yZero+12)) + canvas.drawPolygon(traitPixel, edgeColor=pid.black, fillColor=self.TRANSCRIPT_LOCATION_COLOR, closed=1) + + if self.legendChecked: + startPosY = 15 + nCol = 2 + smallLabelFont = pid.Font(ttf="trebuc", size=12, bold=1) + leftOffset = xLeftOffset+(nCol-1)*200 + canvas.drawPolygon(((leftOffset+6, startPosY-6), (leftOffset, startPosY+6), (leftOffset+12, startPosY+6)), edgeColor=pid.black, fillColor=self.TRANSCRIPT_LOCATION_COLOR, closed=1) + canvas.drawString("Sequence Site", (leftOffset+15), (startPosY+5), smallLabelFont, self.TOP_RIGHT_INFO_COLOR) + + # build dict based on plink result, key is chr, value is list of [snp,BP,pValue] + def getPlinkResultDict(self,outputFileName='',thresholdPvalue=-1,ChrOrderIdNameDict={}): + + ChrList =self.ChrList + plinkResultDict={} + + plinkResultfp = open("%s%s.qassoc"% (webqtlConfig.TMPDIR, outputFileName), "rb") + + headerLine=plinkResultfp.readline()# read header line + line = plinkResultfp.readline() + + valueList=[] # initialize value list, this list will include snp, bp and pvalue info + pValueList=[] + count=0 + + while line: + #convert line from str to list + lineList=self.buildLineList(line=line) + + # only keep the records whose chromosome name is in db + if ChrOrderIdNameDict.has_key(int(lineList[0])) and lineList[-1] and lineList[-1].strip()!='NA': + + chrName=ChrOrderIdNameDict[int(lineList[0])] + snp = lineList[1] + BP = lineList[2] + pValue = float(lineList[-1]) + pValueList.append(pValue) + + if plinkResultDict.has_key(chrName): + valueList=plinkResultDict[chrName] + + # pvalue range is [0,1] + if thresholdPvalue >=0 and thresholdPvalue<=1: + if pValue < thresholdPvalue: + valueList.append((snp,BP,pValue)) + count+=1 + + plinkResultDict[chrName]=valueList + valueList=[] + else: + if thresholdPvalue>=0 and thresholdPvalue<=1: + if pValue < thresholdPvalue: + valueList.append((snp,BP,pValue)) + count+=1 + + if valueList: + plinkResultDict[chrName]=valueList + + valueList=[] + + + line =plinkResultfp.readline() + else: + line=plinkResultfp.readline() + + if pValueList: + minPvalue= min(pValueList) + else: + minPvalue=0 + + return count,minPvalue,plinkResultDict + + + ###################################################### + # input: line: str,one line read from file + # function: convert line from str to list; + # output: lineList list + ####################################################### + def buildLineList(self,line=None): + + lineList = string.split(string.strip(line),' ')# irregular number of whitespaces between columns + lineList =[ item for item in lineList if item <>''] + lineList = map(string.strip, lineList) + + return lineList + + #added by NL: automatically generate pheno txt file for PLINK based on strainList passed from dataEditing page + def genPhenoTxtFileForPlink(self,phenoFileName='', RISetName='', probesetName='', valueDict={}): + pedFileStrainList=self.getStrainNameFromPedFile(RISetName=RISetName) + outputFile = open("%s%s.txt"%(webqtlConfig.TMPDIR,phenoFileName),"wb") + headerLine = 'FID\tIID\t%s\n'%probesetName + outputFile.write(headerLine) + + newValueList=[] + + #if valueDict does not include some strain, value will be set to -9999 as missing value + for item in pedFileStrainList: + try: + value=valueDict[item] + value=str(value).replace('value=','') + value=value.strip() + except: + value=-9999 + + newValueList.append(value) + + + newLine='' + for i, strain in enumerate(pedFileStrainList): + j=i+1 + value=newValueList[i] + newLine+='%s\t%s\t%s\n'%(strain, strain, value) + + if j%1000==0: + outputFile.write(newLine) + newLine='' + + if newLine: + outputFile.write(newLine) + + outputFile.close() + + # get strain name from ped file in order + def getStrainNameFromPedFile(self, RISetName=''): + pedFileopen= open("%splink/%s.ped"%(webqtlConfig.HTMLPATH, RISetName),"r") + line =pedFileopen.readline() + strainNameList=[] + + while line: + lineList=string.split(string.strip(line),'\t') + lineList=map(string.strip,lineList) + + strainName=lineList[0] + strainNameList.append(strainName) + + line =pedFileopen.readline() + + return strainNameList + + ################################################################ + # Generate Chr list, Chr OrderId and Retrieve Length Information + ################################################################ + def getChrNameOrderIdLength(self,RISet=''): + + try: + query = """ + Select + Chr_Length.Name,Chr_Length.OrderId,Length from Chr_Length, InbredSet + where + Chr_Length.SpeciesId = InbredSet.SpeciesId AND + InbredSet.Name = '%s' + Order by OrderId + """ % (RISet) + self.cursor.execute(query) + + results =self.cursor.fetchall() + ChrList=[] + ChrLengthMbList=[] + ChrNameOrderIdDict={} + ChrOrderIdNameDict={} + + for item in results: + ChrList.append(item[0]) + ChrNameOrderIdDict[item[0]]=item[1] # key is chr name, value is orderId + ChrOrderIdNameDict[item[1]]=item[0] # key is orderId, value is chr name + ChrLengthMbList.append(item[2]) + + except: + ChrList=[] + ChrNameOrderIdDict={} + ChrLengthMbList=[] + + return ChrList,ChrNameOrderIdDict,ChrOrderIdNameDict,ChrLengthMbList diff --git a/wqflask/wqflask/marker_regression/__init__.py b/wqflask/wqflask/marker_regression/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py new file mode 100755 index 00000000..ed01a3fa --- /dev/null +++ b/wqflask/wqflask/marker_regression/marker_regression.py @@ -0,0 +1,1648 @@ +from __future__ import absolute_import, print_function, division + +from base.trait import GeneralTrait +from base import data_set #import create_dataset + +from pprint import pformat as pf + +import time +import string +import math +#from math import * +#import piddle +import sys +import os +import httplib +import urllib + +from htmlgen import HTMLgen2 as HT +from utility import Plot +from wqflask.interval_analyst import GeneUtil +from base.trait import GeneralTrait +from base.data_set import create_dataset +from base.templatePage import templatePage +from utility import webqtlUtil +from base import webqtlConfig +from dbFunction import webqtlDatabaseFunction +from base.GeneralObject import GeneralObject + +import reaper +import cPickle +from utility.THCell import THCell +from utility.TDCell import TDCell + + +class MarkerRegression(object): + + #def __init__(self, start_vars): + # + # print("[mike] Now start_vars is:", pf(start_vars)) + # + # self.dataset = data_set.create_dataset(start_vars['dataset_name']) + # self.this_trait = GeneralTrait(dataset=self.dataset.name, + # name=start_vars['trait_id'], + # cellid=None) + # + # print("self.this_trait is: ", pf(self.this_trait)) + # print("self.dataset is: ", pf(self.dataset)) + + def __init__(self, start_vars): + #templatePage.__init__(self, fd) + + #if not self.openMysql(): + # return + + self.dataset = create_dataset(start_vars['dataset_name']) + + #self.initializeParameters(start_vars) + + #filename= webqtlUtil.genRandStr("Itvl_") + #ChrList,ChrNameOrderIdDict,ChrOrderIdNameDict,ChrtLengthMbList= self.getChrNameOrderIdLength(RISet=fd.RISet) + + if False: # For PLINK + + traitInfoList = string.split(string.strip(fd.identification),':') + probesetName = string.strip(traitInfoList[-1]) + plinkOutputFileName= webqtlUtil.genRandStr("%s_%s_"%(fd.RISet,probesetName)) + + # get related values from fd.allTraitData; the format of 'allTraitValueDict'is {strainName1: value=-0.2...} + fd.readData() + allTraitValueDict = fd.allTraitData + + #automatically generate pheno txt file for PLINK + self.genPhenoTxtFileForPlink(phenoFileName=plinkOutputFileName,RISetName=fd.RISet,probesetName=probesetName, valueDict=allTraitValueDict) + # os.system full path is required for input and output files; specify missing value is -9999 + plink_command = '%splink/plink --noweb --ped %splink/%s.ped --no-fid --no-parents --no-sex --no-pheno --map %splink/%s.map --pheno %s/%s.txt --pheno-name %s --missing-phenotype -9999 --out %s%s --assoc ' % (webqtlConfig.HTMLPATH, webqtlConfig.HTMLPATH, fd.RISet, webqtlConfig.HTMLPATH, fd.RISet, webqtlConfig.TMPDIR, plinkOutputFileName, probesetName, webqtlConfig.TMPDIR, plinkOutputFileName) + + os.system(plink_command) + + if fd.identification: + heading2 = HT.Paragraph('Trait ID: %s' % fd.identification) + heading2.__setattr__("class","subtitle") + self.dict['title'] = '%s: Genome Association' % fd.identification + else: + heading2 = "" + self.dict['title'] = 'Genome Association' + + if fd.traitInfo: + symbol,chromosome,MB = string.split(fd.traitInfo,'\t') + heading3 = HT.Paragraph('[ ',HT.Strong(HT.Italic('%s' % symbol,id="green")),' on Chr %s @ %s Mb ]' % (chromosome,MB)) + else: + heading3 = "" + + heading = HT.Paragraph('Trait Data Entered for %s Set' % fd.RISet) + heading.__setattr__("class","title") + + # header info part:Trait Data Entered for HLC Set & Trait ID: + headerdiv = HT.TR(HT.TD(heading, heading2,heading3, width='45%',valign='top', align='left', bgColor='#eeeeee')) + + self.ChrList=ChrList # get chr name from '1' to 'X' + self.ChrLengthMbList = ChrLengthMbList + + # build plink result dict based on chr, key is chr name, value is in list type including Snpname, bp and pvalue info + plinkResultDict={} + count,minPvalue,plinkResultDict =self.getPlinkResultDict(outputFileName=plinkOutputFileName,thresholdPvalue=self.pValue,ChrOrderIdNameDict=ChrOrderIdNameDict) + + # if can not find results which are matched with assigned p-value, system info will show up + if count >0: + + #for genome association report table + reportTable="" + # sortable table object + resultstable,tblobj,bottomInfo = self.GenReportForPLINK(ChrNameOrderIdDict=ChrNameOrderIdDict, RISet=fd.RISet,plinkResultDict=plinkResultDict,thresholdPvalue=self.pValue,chrList=self.ChrList) + + # creat object for result table for sort function + objfile = open('%s.obj' % (webqtlConfig.TMPDIR+filename), 'wb') + cPickle.dump(tblobj, objfile) + objfile.close() + + sortby = ("Index", "up") + reportTable =HT.Div(webqtlUtil.genTableObj(tblobj=tblobj, file=filename, sortby=sortby, tableID = "sortable", addIndex = "0"), Id="sortable") + + descriptionTable = HT.TableLite(border=0, cellpadding=0, cellspacing=0) + descriptionTable.append(HT.TR(HT.TD(reportTable, colspan=3))) + descriptionTable.append(HT.TR(HT.TD(HT.BR(),HT.BR()))) + descriptionTable.append(bottomInfo) + + # get each chr's length + self.ChrLengthMbList = map(lambda x: x/1000000.0, self.ChrLengthMbList) # change unit from bp to mb + self.ChrLengthMbSum = reduce(lambda x, y:x+y, self.ChrLengthMbList, 0.0)# get total length of all chrs + if self.ChrLengthMbList: + self.GraphInterval = self.ChrLengthMbSum/(len(self.ChrLengthMbList)*12) #Empirical Mb interval + else: + self.GraphInterval = 1 + + # for human data, there's no CM value + self.ChrLengthCMList = [] + self.ChrLengthCMSum = 0 + + # begin: common part with human data + intCanvas = pid.PILCanvas(size=(self.graphWidth,self.graphHeight)) + gifmap = self.plotIntMappingForPLINK(fd, intCanvas, startMb = self.startMb, endMb = self.endMb, plinkResultDict=plinkResultDict) + + intCanvas.save(os.path.join(webqtlConfig.IMGDIR, filename), format='png') + intImg=HT.Image('/image/'+filename+'.png', border=0, usemap='#WebQTLImageMap') + + TD_LR = HT.TR(HT.TD(HT.Blockquote(gifmap,intImg, HT.P()), bgColor='#eeeeee', height = 200)) + self.dict['body'] = str(headerdiv)+str(TD_LR)+str(resultstable)+str(HT.TR(HT.TD(descriptionTable))) + + else: + heading = "Genome Association" + detail = ['There is no association with marker that meets this criteria. Please provide a less stringend threshold. The minimun p-value is %s.'%minPvalue] + self.error(heading=heading,detail=detail) + return + + else: # QTLreaper result + #if not fd.genotype: + # fd.readData() + # + #fd.parentsf14regression = fd.formdata.getvalue('parentsf14regression') + #weightedRegression = fd.formdata.getvalue('applyVarianceSE') + + #if fd.parentsf14regression and fd.genotype_2: + # _genotype = fd.genotype_2 + #else: + genotype = self.dataset.group.read_genotype_file() + print("[black]:", genotype) + + _strains, _vals, _vars, N = fd.informativeStrains(_genotype.prgy, weightedRegression) + + if fd.identification: + heading2 = HT.Paragraph('Trait ID: %s' % fd.identification) + heading2.__setattr__("class","subtitle") + self.dict['title'] = '%s: Genome Association' % fd.identification + else: + heading2 = "" + self.dict['title'] = 'Genome Association' + + if fd.traitInfo: + symbol,chromosome,MB = string.split(fd.traitInfo,'\t') + heading3 = HT.Paragraph('[ ',HT.Strong(HT.Italic('%s' % symbol,id="green")),' on Chr %s @ %s Mb ]' % (chromosome,MB)) + else: + heading3 = "" + + if N < webqtlConfig.KMININFORMATIVE: + heading = "Genome Association" + detail = ['Fewer than %d strain data were entered for %s data set. No mapping attempted.' % (webqtlConfig.KMININFORMATIVE, fd.RISet)] + self.error(heading=heading,detail=detail) + return + else: + heading = HT.Paragraph('Trait Data Entered for %s Set' % fd.RISet) + heading.__setattr__("class","title") + + datadiv = HT.TD(heading, heading2,heading3, width='45%',valign='top', align='left', bgColor='#eeeeee') + resultstable,tblobj,bottomInfo = self.GenReport(ChrNameOrderIdDict,fd, _genotype, _strains, _vals, _vars) + #resultstable = self.GenReport(fd, _genotype, _strains, _vals, _vars) + + # creat object for result table for sort function + objfile = open('%s.obj' % (webqtlConfig.TMPDIR+filename), 'wb') + cPickle.dump(tblobj, objfile) + objfile.close() + + sortby = ("Index", "up") + reportTable =HT.Div(webqtlUtil.genTableObj(tblobj=tblobj, file=filename, sortby=sortby, tableID = "sortable", addIndex = "0"), Id="sortable") + + descriptionTable = HT.TableLite(border=0, cellpadding=0, cellspacing=0) + descriptionTable.append(HT.TR(HT.TD(reportTable, colspan=3))) + descriptionTable.append(HT.TR(HT.TD(HT.BR(),HT.BR()))) + descriptionTable.append(bottomInfo) + + self.traitList=_vals + + ##########################plot####################### + + ################################################################ + # Generate Chr list and Retrieve Length Information + ################################################################ + self.genotype= _genotype + self.ChrList = [("All", -1)] + + for i, indChr in enumerate(self.genotype): + self.ChrList.append((indChr.name, i)) + + self.cursor.execute(""" + Select + Length from Chr_Length, InbredSet + where + Chr_Length.SpeciesId = InbredSet.SpeciesId AND + InbredSet.Name = '%s' AND + Chr_Length.Name in (%s) + Order by + OrderId + """ % (fd.RISet, string.join(map(lambda X: "'%s'" % X[0], self.ChrList[1:]), ", "))) + + self.ChrLengthMbList = self.cursor.fetchall() + self.ChrLengthMbList = map(lambda x: x[0]/1000000.0, self.ChrLengthMbList) + self.ChrLengthMbSum = reduce(lambda x, y:x+y, self.ChrLengthMbList, 0.0) + if self.ChrLengthMbList: + self.MbGraphInterval = self.ChrLengthMbSum/(len(self.ChrLengthMbList)*12) #Empirical Mb interval + else: + self.MbGraphInterval = 1 + + self.ChrLengthCMList = [] + for i, _chr in enumerate(self.genotype): + self.ChrLengthCMList.append(_chr[-1].cM - _chr[0].cM) + self.ChrLengthCMSum = reduce(lambda x, y:x+y, self.ChrLengthCMList, 0.0)# used for calculate plot scale + + self.GraphInterval = self.MbGraphInterval #Mb + + # begin: common part with human data + intCanvas = pid.PILCanvas(size=(self.graphWidth,self.graphHeight)) + gifmap = self.plotIntMapping(fd, intCanvas, startMb = self.startMb, endMb = self.endMb, showLocusForm= "") + filename= webqtlUtil.genRandStr("Itvl_") + intCanvas.save(os.path.join(webqtlConfig.IMGDIR, filename), format='png') + intImg=HT.Image('/image/'+filename+'.png', border=0, usemap='#WebQTLImageMap') + + ################################################################ + # footnote goes here + ################################################################ + btminfo = HT.Paragraph(Id="smallsize") #Small('More information about this graph is available here.') + + if (self.additiveChecked): + btminfo.append(HT.BR(), 'A positive additive coefficient (', HT.Font('green', color='green'), ' line) indicates that %s alleles increase trait values. In contrast, a negative additive coefficient (' % fd.ppolar, HT.Font('red', color='red'), ' line) indicates that %s alleles increase trait values.' % fd.mpolar) + + + TD_LR = HT.TR(HT.TD(HT.Blockquote(gifmap,intImg, HT.P()), bgColor='#eeeeee', height = 200)) + + self.dict['body'] = str(datadiv)+str(TD_LR)+str(resultstable)+str(HT.TR(HT.TD(descriptionTable))) + + # end: common part with human data + + + + + # add by NL 10-2-2011 + def initializeParameters(self, fd): + """ + Initializes all of the MarkerRegressionPage class parameters, + acquiring most values from the formdata (fd) + """ + ################################### + # manhattam plot parameters + ################################### + + self.graphHeight = 600 + self.graphWidth = 1280 + self.plotScale = 'physic' + self.selectedChr = -1 + self.GRAPH_BACK_DARK_COLOR = pid.HexColor(0xF1F1F9) + self.GRAPH_BACK_LIGHT_COLOR = pid.HexColor(0xFBFBFF) + self.LRS_COLOR = pid.HexColor(0x0000FF) + self.LRS_LOD ='LRS' + self.lrsMax = float(fd.formdata.getvalue('lrsMax', 0)) + self.startMb = fd.formdata.getvalue('startMb', "-1") + self.endMb = fd.formdata.getvalue('endMb', "-1") + self.mappingMethodId = fd.formdata.getvalue('mappingMethodId', "0") + self.permChecked=True + self.multipleInterval=False + self.SIGNIFICANT_WIDTH = 5 + self.SUGGESTIVE_WIDTH = 5 + self.SIGNIFICANT_COLOR = pid.HexColor(0xEBC7C7) + self.SUGGESTIVE_COLOR = pid.gainsboro + self.colorCollection = [self.LRS_COLOR] + self.additiveChecked= True + self.ADDITIVE_COLOR_POSITIVE = pid.green + self.legendChecked =False + self.pValue=float(fd.formdata.getvalue('pValue',-1)) + + # allow user to input p-value greater than 1, + # in this case, the value will be treated as -lgP value. so the input value needs to be transferred to power of 10 format + if self.pValue >1: + self.pValue =10**-(self.pValue) + + try: + self.startMb = float(self.startMb) + self.endMb = float(self.endMb) + if self.startMb > self.endMb: + temp = self.startMb + self.startMb = self.endMb + self.endMb = temp + #minimal distance 10bp + if self.endMb - self.startMb < 0.00001: + self.endMb = self.startMb + 0.00001 + except: + self.startMb = self.endMb = -1 + + def GenReportForPLINK(self, ChrNameOrderIdDict={},RISet='',plinkResultDict= {},thresholdPvalue=-1,chrList=[]): + + 'Create an HTML division which reports any loci which are significantly associated with the submitted trait data.' + ######################################### + # Genome Association report + ######################################### + locusFormName = webqtlUtil.genRandStr("fm_") + locusForm = HT.Form(cgi = os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), \ + enctype='multipart/form-data', name=locusFormName, submit=HT.Input(type='hidden')) + hddn = {'FormID':'showDatabase','ProbeSetID':'_','database':RISet+"Geno",'CellID':'_', \ + 'RISet':RISet, 'incparentsf1':'on'} + for key in hddn.keys(): + locusForm.append(HT.Input(name=key, value=hddn[key], type='hidden')) + + regressionHeading = HT.Paragraph('Genome Association Report') + regressionHeading.__setattr__("class","title") + + filename= webqtlUtil.genRandStr("GenomeAsscociation_") + fpText = open('%s.txt' % (webqtlConfig.TMPDIR+filename), 'wb') + fpText.write('The loci meet the criteria of P-Value <= %3.6f.\n'%thresholdPvalue) + pValueInfo =HT.Paragraph('The loci meet the criteria of P-Value <= %3.6f.\n'%thresholdPvalue) + + textUrl = HT.Href(text = 'Download', url= '/tmp/'+filename+'.txt', target = "_blank", Class='fs12 fwn') + bottomInfo = HT.TR(HT.TD(HT.Paragraph(textUrl, ' result in tab-delimited text format.', HT.BR(), HT.BR(),Class="fs12 fwn"), colspan=3)) + + tblobj={} # build dict for genTableObj function; keys include header and body + tblobj_header = [] # value of key 'header' + tblobj_body=[] # value of key 'body' + reportHeaderRow=[] # header row list for tblobj_header (html part) + headerList=['Index','SNP Name','Chr','Mb','-log(P)'] + headerStyle="fs14 fwb ffl b1 cw cbrb" # style of the header + cellColorStyle = "fs13 b1 fwn c222" # style of the cells + + if headerList: + for ncol, item in enumerate(headerList): + reportHeaderRow.append(THCell(HT.TD(item, Class=headerStyle, valign='bottom',nowrap='ON'),text=item, idx=ncol)) + #download file for table headers' names + fpText.write('SNP_Name\tChromosome\tMb\t-log(P)\n') + + tblobj_header.append(reportHeaderRow) + tblobj['header']=tblobj_header + + index=1 + for chr in chrList: + + if plinkResultDict.has_key(chr): + if chr in ChrNameOrderIdDict.keys(): + chrOrderId =ChrNameOrderIdDict[chr] + else: + chrOrderId=chr + + valueList=plinkResultDict[chr] + + for value in valueList: + reportBodyRow=[] # row list for tblobj_body (html part) + snpName=value[0] + bp=value[1] + mb=int(bp)/1000000.0 + + try: + pValue =float(value[2]) + except: + pValue =1 + formattedPvalue = -math.log10(pValue) + + formattedPvalue = webqtlUtil.SciFloat(formattedPvalue) + dbSnprs=snpName.replace('rs','') + SnpHref = HT.Href(text=snpName, url="http://www.ncbi.nlm.nih.gov/projects/SNP/snp_ref.cgi?rs=%s"%dbSnprs, target="_blank") + + selectCheck=HT.Input(type="checkbox", Class="checkbox", name="index",value=index, onClick="highlight(this)") + reportBodyRow.append(TDCell(HT.TD(str(index),selectCheck, align='right',Class=cellColorStyle,nowrap='ON'),str(index),index)) + reportBodyRow.append(TDCell(HT.TD(SnpHref, Class=cellColorStyle,nowrap='ON'),snpName, snpName)) + reportBodyRow.append(TDCell(HT.TD(chr, Class=cellColorStyle, align="center",nowrap='ON'),chr, chrOrderId)) + reportBodyRow.append(TDCell(HT.TD('%3.6f'%mb, Class=cellColorStyle, align="center",nowrap='ON'),mb, mb)) + reportBodyRow.append(TDCell(HT.TD(formattedPvalue, Class=cellColorStyle, align="center",nowrap='ON'),formattedPvalue, float(formattedPvalue))) + + fpText.write('%s\t%s\t%3.6f\t%s\n' % (snpName, str(chr), mb, formattedPvalue)) + index+=1 + + tblobj_body.append(reportBodyRow) + + tblobj['body']=tblobj_body + rv=HT.TR(HT.TD(regressionHeading,pValueInfo, locusForm, HT.P(), width='55%',valign='top', align='left',bgColor='#eeeeee')) + + return rv, tblobj,bottomInfo + + + def GenReport(self, ChrNameOrderIdDict,fd, _genotype, _strains, _vals, _vars= []): + 'Create an HTML division which reports any loci which are significantly associated with the submitted trait data.' + #calculate QTL for each trait + self.qtlresults = [] + if webqtlUtil.ListNotNull(_vars): + qtlresults = _genotype.regression(strains = _strains, trait = _vals, variance = _vars) + LRSArray = _genotype.permutation(strains = _strains, trait = _vals, variance = _vars, nperm=fd.nperm) + else: + qtlresults = _genotype.regression(strains = _strains, trait = _vals) + LRSArray = _genotype.permutation(strains = _strains, trait = _vals,nperm=fd.nperm) + + self.qtlresults.append(qtlresults) + + filename= webqtlUtil.genRandStr("GenomeAsscociation_") + + # set suggestive, significant and highly significant LRS + if fd.suggestive == None: + fd.suggestive = LRSArray[int(fd.nperm*0.37-1)] + else: + fd.suggestive = float(fd.suggestive) + if fd.significance == None: + fd.significance = LRSArray[int(fd.nperm*0.95-1)] + else: + fd.significance = float(fd.significance) + + self.significance =fd.significance + self.suggestive = fd.suggestive + self.highlysignificant = LRSArray[int(fd.nperm*0.99-1)] + _dispAllLRS = 0 + if fd.formdata.getvalue('displayAllLRS'): + _dispAllLRS = 1 + qtlresults2 = [] + if _dispAllLRS: + filtered = qtlresults[:] + else: + filtered = filter(lambda x, y=fd.suggestive: x.lrs > y, qtlresults) + if len(filtered) == 0: + qtlresults2 = qtlresults[:] + qtlresults2.sort() + filtered = qtlresults2[-10:] + + ######################################### + # Permutation Graph + ######################################### + myCanvas = pid.PILCanvas(size=(400,300)) + #plotBar(myCanvas,10,10,390,290,LRSArray,XLabel='LRS',YLabel='Frequency',title=' Histogram of Permutation Test',identification=fd.identification) + Plot.plotBar(myCanvas, LRSArray, XLabel='LRS',YLabel='Frequency',title=' Histogram of Permutation Test') + filename= webqtlUtil.genRandStr("Reg_") + myCanvas.save(webqtlConfig.IMGDIR+filename, format='gif') + img=HT.Image('/image/'+filename+'.gif',border=0,alt='Histogram of Permutation Test') + + if fd.suggestive == None: + fd.suggestive = LRSArray[int(fd.nperm*0.37-1)] + else: + fd.suggestive = float(fd.suggestive) + if fd.significance == None: + fd.significance = LRSArray[int(fd.nperm*0.95-1)] + else: + fd.significance = float(fd.significance) + + permutationHeading = HT.Paragraph('Histogram of Permutation Test') + permutationHeading.__setattr__("class","title") + + permutation = HT.TableLite() + permutation.append(HT.TR(HT.TD(img))) + + + ######################################### + # Genome Association report + ######################################### + locusFormName = webqtlUtil.genRandStr("fm_") + locusForm = HT.Form(cgi = os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), \ + enctype='multipart/form-data', name=locusFormName, submit=HT.Input(type='hidden')) + hddn = {'FormID':'showDatabase','ProbeSetID':'_','database':fd.RISet+"Geno",'CellID':'_', \ + 'RISet':fd.RISet, 'incparentsf1':'on'} + for key in hddn.keys(): + locusForm.append(HT.Input(name=key, value=hddn[key], type='hidden')) + + regressionHeading = HT.Paragraph('Genome Association Report') + regressionHeading.__setattr__("class","title") + # report is the info part above report table + if qtlresults2 != []: + report = HT.Blockquote(HT.Font('No association ',color="#FF0000"),HT.Font('with a likelihood ratio statistic greater than %3.1f was found. Here are the top 10 LRSs.' % fd.suggestive,color="#000000")) + else: + report = HT.Blockquote('The following loci in the %s data set have associations with the above trait data.\n' % fd.RISet, HT.P()) + report.__setattr__("class","normalsize") + + fpText = open('%s.txt' % (webqtlConfig.TMPDIR+filename), 'wb') + fpText.write('Suggestive LRS =%3.2f\n'%self.suggestive) + fpText.write('Significant LRS =%3.2f\n'%self.significance) + fpText.write('Highly Significant LRS =%3.2f\n'%self.highlysignificant) + LRSInfo =HT.Paragraph('    Suggestive LRS =%3.2f\n'%fd.suggestive, HT.BR(), '    Significant LRS =%3.2f\n'%fd.significance,HT.BR(),'    Highly Significant LRS =%3.2f\n' % self.highlysignificant) + + textUrl = HT.Href(text = 'Download', url= '/tmp/'+filename+'.txt', target = "_blank", Class='fs12 fwn') + + bottomInfo = HT.TR(HT.TD(HT.Paragraph(textUrl, ' result in tab-delimited text format.', HT.BR(), HT.BR(),'LRS values marked with',HT.Font(' * ',color="red"), 'are greater than the significance threshold (specified by you or by permutation test). ' , HT.BR(), HT.BR(), HT.Strong('Additive Effect'), ' is half the difference in the mean phenotype of all cases that are homozygous for one parental allel at this marker minus the mean of all cases that are homozygous for the other parental allele at this marker. ','In the case of %s strains, for example,' % fd.RISet,' A positive additive effect indicates that %s alleles increase trait values. Negative additive effect indicates that %s alleles increase trait values.'% (fd.ppolar,fd.mpolar),Class="fs12 fwn"))) + + tblobj={} # build dict for genTableObj function; keys include header and body + tblobj_header = [] # value of key 'header' + tblobj_body=[] # value of key 'body' + reportHeaderRow=[] # header row list for tblobj_header (html part) + headerStyle="fs14 fwb ffl b1 cw cbrb" # style of the header + cellColorStyle = "fs13 b1 fwn c222" # style of the cells + + headerList=['Index','LRS','Chr','Mb','Locus','Additive Effect'] + for ncol, item in enumerate(headerList): + reportHeaderRow.append(THCell(HT.TD(item, Class=headerStyle, valign='bottom',nowrap='ON'),text=item, idx=ncol)) + + if fd.genotype.type == 'intercross': + ncol =len(headerList) + reportHeaderRow.append(THCell(HT.TD('Dominance Effect', Class=headerStyle, valign='bottom',nowrap='ON'),text='Dominance Effect', idx=ncol)) + + #download file for table headers' names + fpText.write('LRS\tChromosome\tMb\tLocus\tAdditive Effect\tDominance Effect\n') + + index=1 + for ii in filtered: + #add by NL 06-20-2011: set LRS to 460 when LRS is infinite, + if ii.lrs==float('inf') or ii.lrs>webqtlConfig.MAXLRS: + LRS=webqtlConfig.MAXLRS #maximum LRS value + else: + LRS=ii.lrs + + if LRS > fd.significance: + lrs = HT.TD(HT.Font('%3.3f*' % LRS, color='#FF0000'),Class=cellColorStyle) + else: + lrs = HT.TD('%3.3f' % LRS,Class=cellColorStyle) + + if ii.locus.chr in ChrNameOrderIdDict.keys(): + chrOrderId =ChrNameOrderIdDict[ii.locus.chr] + else: + chrOrderId=ii.locus.chr + + reportBodyRow=[] # row list for tblobj_body (html part) + selectCheck=HT.Input(type="checkbox", Class="checkbox", name="index",value=index, onClick="highlight(this)") + reportBodyRow.append(TDCell(HT.TD(str(index),selectCheck, align='right',Class=cellColorStyle,nowrap='ON'),str(index),index)) + reportBodyRow.append(TDCell(lrs,LRS, LRS)) + reportBodyRow.append(TDCell(HT.TD(ii.locus.chr, Class=cellColorStyle, align="center",nowrap='ON'),ii.locus.chr, chrOrderId)) + reportBodyRow.append(TDCell(HT.TD('%3.6f'%ii.locus.Mb, Class=cellColorStyle, align="center",nowrap='ON'),ii.locus.Mb, ii.locus.Mb)) + reportBodyRow.append(TDCell(HT.TD(HT.Href(text=ii.locus.name, url = "javascript:showTrait('%s','%s');" % (locusFormName, ii.locus.name), Class='normalsize'), Class=cellColorStyle, align="center",nowrap='ON'),ii.locus.name, ii.locus.name)) + reportBodyRow.append(TDCell(HT.TD('%3.3f' % ii.additive, Class=cellColorStyle, align="center",nowrap='ON'),ii.additive, ii.additive)) + reportBodyRow.append(TDCell(HT.TD('%3.3f' % ii.dominance, Class=cellColorStyle, align="center",nowrap='ON'),ii.dominance, ii.dominance)) + + fpText.write('%2.3f\t%s\t%3.6f\t%s\t%2.3f\t%2.3f\n' % (LRS, ii.locus.chr, ii.locus.Mb, ii.locus.name, ii.additive, ii.dominance)) + index+=1 + tblobj_body.append(reportBodyRow) + else: + #download file for table headers' names + fpText.write('LRS\tChromosome\tMb\tLocus\tAdditive Effect\n') + + index=1 + for ii in filtered: + #add by NL 06-20-2011: set LRS to 460 when LRS is infinite, + if ii.lrs==float('inf') or ii.lrs>webqtlConfig.MAXLRS: + LRS=webqtlConfig.MAXLRS #maximum LRS value + else: + LRS=ii.lrs + + if LRS > fd.significance: + lrs = HT.TD(HT.Font('%3.3f*' % LRS, color='#FF0000'),Class=cellColorStyle) + else: + lrs = HT.TD('%3.3f' % LRS,Class=cellColorStyle) + + if ii.locus.chr in ChrNameOrderIdDict.keys(): + chrOrderId =ChrNameOrderIdDict[ii.locus.chr] + else: + chrOrderId=ii.locus.chr + + reportBodyRow=[] # row list for tblobj_body (html part) + selectCheck=HT.Input(type="checkbox", Class="checkbox", name="index",value=index, onClick="highlight(this)") + reportBodyRow.append(TDCell(HT.TD(str(index),selectCheck, align='right',Class=cellColorStyle,nowrap='ON'),str(index),index)) + reportBodyRow.append(TDCell(lrs,LRS, LRS)) + reportBodyRow.append(TDCell(HT.TD(ii.locus.chr, Class=cellColorStyle, align="center",nowrap='ON'),ii.locus.chr, chrOrderId)) + reportBodyRow.append(TDCell(HT.TD('%3.6f'%ii.locus.Mb, Class=cellColorStyle, align="center",nowrap='ON'),ii.locus.Mb, ii.locus.Mb)) + reportBodyRow.append(TDCell(HT.TD(HT.Href(text=ii.locus.name, url = "javascript:showTrait('%s','%s');" % (locusFormName, ii.locus.name), Class='normalsize'), Class=cellColorStyle, align="center",nowrap='ON'),ii.locus.name, ii.locus.name)) + reportBodyRow.append(TDCell(HT.TD('%3.3f' % ii.additive, Class=cellColorStyle, align="center",nowrap='ON'),ii.additive, ii.additive)) + + fpText.write('%2.3f\t%s\t%3.6f\t%s\t%2.3f\n' % (LRS, ii.locus.chr, ii.locus.Mb, ii.locus.name, ii.additive)) + index+=1 + tblobj_body.append(reportBodyRow) + + tblobj_header.append(reportHeaderRow) + tblobj['header']=tblobj_header + tblobj['body']=tblobj_body + + rv=HT.TD(regressionHeading,LRSInfo,report, locusForm, HT.P(),width='55%',valign='top', align='left', bgColor='#eeeeee') + if fd.genotype.type == 'intercross': + bottomInfo.append(HT.BR(), HT.BR(), HT.Strong('Dominance Effect'),' is the difference between the mean trait value of cases heterozygous at a marker and the average mean for the two groups homozygous at this marker: e.g., BD - (BB+DD)/2]. A positive dominance effect indicates that the average phenotype of BD heterozygotes exceeds the mean of BB and DD homozygotes. No dominance deviation can be computed for a set of recombinant inbred strains or for a backcross.') + return rv,tblobj,bottomInfo + + return rv,tblobj,bottomInfo + + def plotIntMappingForPLINK(self, fd, canvas, offset= (80, 120, 20, 80), zoom = 1, startMb = None, endMb = None, showLocusForm = "",plinkResultDict={}): + #calculating margins + xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset + + fontZoom = zoom + if zoom == 2: + fontZoom = 1.5 + + xLeftOffset = int(xLeftOffset*fontZoom) + xRightOffset = int(xRightOffset*fontZoom) + yBottomOffset = int(yBottomOffset*fontZoom) + + cWidth = canvas.size[0] + cHeight = canvas.size[1] + plotWidth = cWidth - xLeftOffset - xRightOffset + plotHeight = cHeight - yTopOffset - yBottomOffset + startPixelX = xLeftOffset + endPixelX = (xLeftOffset + plotWidth) + + #Drawing Area Height + drawAreaHeight = plotHeight + if self.plotScale == 'physic' and self.selectedChr > -1: # for single chr + drawAreaHeight -= self.ENSEMBL_BAND_HEIGHT + self.UCSC_BAND_HEIGHT+ self.WEBQTL_BAND_HEIGHT + 3*self.BAND_SPACING+ 10*zoom + if self.geneChecked: + drawAreaHeight -= self.NUM_GENE_ROWS*self.EACH_GENE_HEIGHT + 3*self.BAND_SPACING + 10*zoom + else: + if self.selectedChr > -1: + drawAreaHeight -= 20 + else:# for all chrs + drawAreaHeight -= 30 + + #Image map + gifmap = HT.Map(name='WebQTLImageMap') + + newoffset = (xLeftOffset, xRightOffset, yTopOffset, yBottomOffset) + # Draw the alternating-color background first and get plotXScale + plotXScale = self.drawGraphBackgroundForPLINK(canvas, gifmap, offset=newoffset, zoom= zoom, startMb=startMb, endMb = endMb,plinkResultDict=plinkResultDict) + + # Draw X axis + self.drawXAxisForPLINK(fd, canvas, drawAreaHeight, gifmap, plotXScale, showLocusForm, offset=newoffset, zoom= zoom, startMb=startMb, endMb = endMb) + # Draw manhattam plot + self.drawManhattanPlotForPLINK(canvas, drawAreaHeight, gifmap, plotXScale, offset=newoffset, zoom= zoom, startMb=startMb, endMb = endMb,plinkResultDict=plinkResultDict,thresholdPvalue=self.pValue) + + return gifmap + + + def plotIntMapping(self, fd, canvas, offset= (80, 120, 20, 80), zoom = 1, startMb = None, endMb = None, showLocusForm = ""): + #calculating margins + xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset + + fontZoom = zoom + if zoom == 2: + fontZoom = 1.5 + + xLeftOffset = int(xLeftOffset*fontZoom) + xRightOffset = int(xRightOffset*fontZoom) + yBottomOffset = int(yBottomOffset*fontZoom) + + cWidth = canvas.size[0] + cHeight = canvas.size[1] + plotWidth = cWidth - xLeftOffset - xRightOffset + plotHeight = cHeight - yTopOffset - yBottomOffset + startPixelX = xLeftOffset + endPixelX = (xLeftOffset + plotWidth) + + #Drawing Area Height + drawAreaHeight = plotHeight + if self.plotScale == 'physic' and self.selectedChr > -1: # for single chr + drawAreaHeight -= self.ENSEMBL_BAND_HEIGHT + self.UCSC_BAND_HEIGHT+ self.WEBQTL_BAND_HEIGHT + 3*self.BAND_SPACING+ 10*zoom + if self.geneChecked: + drawAreaHeight -= self.NUM_GENE_ROWS*self.EACH_GENE_HEIGHT + 3*self.BAND_SPACING + 10*zoom + else:# for all chrs + if self.selectedChr > -1: + drawAreaHeight -= 20 + else: + drawAreaHeight -= 30 + + #Image map + gifmap = HT.Map(name='WebQTLImageMap') + + newoffset = (xLeftOffset, xRightOffset, yTopOffset, yBottomOffset) + # Draw the alternating-color background first and get plotXScale + plotXScale = self.drawGraphBackground(canvas, gifmap, offset=newoffset, zoom= zoom, startMb=startMb, endMb = endMb) + + # Draw X axis + self.drawXAxis(fd, canvas, drawAreaHeight, gifmap, plotXScale, showLocusForm, offset=newoffset, zoom= zoom, startMb=startMb, endMb = endMb) + # Draw QTL curve + self.drawQTL(canvas, drawAreaHeight, gifmap, plotXScale, offset=newoffset, zoom= zoom, startMb=startMb, endMb = endMb) + + #draw legend + if self.multipleInterval: + self.drawMultiTraitName(fd, canvas, gifmap, showLocusForm, offset=newoffset) + elif self.legendChecked: + self.drawLegendPanel(fd, canvas, offset=newoffset) + else: + pass + + #draw position, no need to use a separate function + if fd.genotype.Mbmap: + self.drawProbeSetPosition(canvas, plotXScale, offset=newoffset) + + return gifmap + + + # functions for manhattam plot of markers + def drawManhattanPlotForPLINK(self, canvas, drawAreaHeight, gifmap, plotXScale, offset= (40, 120, 80, 10), zoom = 1, startMb = None, endMb = None,plinkResultDict={},thresholdPvalue=-1): + + xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset + plotWidth = canvas.size[0] - xLeftOffset - xRightOffset + plotHeight = canvas.size[1] - yTopOffset - yBottomOffset + fontZoom = zoom + if zoom == 2: + fontZoom = 1.5 + + # INTERCROSS = (self.genotype.type=="intercross") + INTERCROSS ='' #?????? + + ChrLengthDistList = self.ChrLengthMbList + drawRegionDistance = self.ChrLengthMbSum + GraphInterval=self.GraphInterval + pvalueHeightThresh = drawAreaHeight - 80 #ZS: Otherwise the plot gets very close to the chromosome labels + + #draw the pvalue scale + #We first determine whether or not we are using a sliding scale. + #If so, we need to compute the maximum pvalue value to determine where the max y-value should be, and call this pvalueMax. + #pvalueTop is then defined to be above the pvalueMax by enough to add one additional pvalueScale increment. + #if we are using a set-scale, then we set pvalueTop to be the user's value, and pvalueMax doesn't matter. + + # for human data we use p value instead of lrs + pValueList=[] + for key in plinkResultDict: + valueList = plinkResultDict[key] + for item in valueList: + pValue = item[-1] + pValueList.append(pValue) + + formattedPValueList=[] + for pValue in pValueList: + try: + pValue=float(pValue) + except: + pValue =1 + formattedpValue = -math.log10(pValue) + formattedPValueList.append(formattedpValue) + + #sliding scale + pvalueMax = max(formattedPValueList) + #pvalueMax =pvalueMax +1 + # no permutation result for plink func: GenReport() + pvalueMin = int(-math.log10(thresholdPvalue)) + + if pvalueMax> 100: + pvalueScale = 20.0 + elif pvalueMax > 20: + pvalueScale = 5.0 + elif pvalueMax > 7.5: + pvalueScale = 2.5 + else: + pvalueScale = 1.0 + + # the base line for x-axis is -log(thresholdPvalue) + pvalueAxisList = Plot.frange(pvalueMin, pvalueMax, pvalueScale) + #make sure the user's value appears on the y-axis + #ZS: There is no way to do this without making the position of the points not directly proportional to a given distance on the y-axis + #tempPvalueMax=round(pvalueMax) + tempPvalueMax = pvalueAxisList[len(pvalueAxisList)-1] + pvalueScale + pvalueAxisList.append(tempPvalueMax) + + #ZS: I don't understand this; the if statement will be true for any number that isn't exactly X.5. + #if abs(tempPvalueMax-pvalueMax) <0.5: + # tempPvalueMax=tempPvalueMax+1 + # pvalueAxisList.append(tempPvalueMax) + + #draw the "pvalue" string to the left of the axis + pvalueScaleFont=pid.Font(ttf="verdana", size=14*fontZoom, bold=0) + pvalueLODFont=pid.Font(ttf="verdana", size=14*zoom*1.5, bold=0) + yZero = yTopOffset + plotHeight + + #yAxis label display area + yAxis_label ='-log(P)' + canvas.drawString(yAxis_label, xLeftOffset - canvas.stringWidth("999.99", font=pvalueScaleFont) - 10*zoom, \ + yZero - 150, font=pvalueLODFont, color=pid.black, angle=90) + + for i,item in enumerate(pvalueAxisList): + ypvalue = yZero - (float(i)/float(len(pvalueAxisList) - 1)) * pvalueHeightThresh + canvas.drawLine(xLeftOffset, ypvalue, xLeftOffset - 4, ypvalue, color=self.LRS_COLOR, width=1*zoom) + scaleStr = "%2.1f" % item + #added by NL 6-24-2011:Y-axis scale display + canvas.drawString(scaleStr, xLeftOffset-4-canvas.stringWidth(scaleStr, font=pvalueScaleFont)-5, ypvalue+3, font=pvalueScaleFont, color=self.LRS_COLOR) + + ChrList=self.ChrList + startPosX = xLeftOffset + + for i, chr in enumerate(ChrList): + + if plinkResultDict.has_key(chr): + plinkresultList = plinkResultDict[chr] + + m = 0 + #add by NL 06-24-2011: for mahanttam plot + symbolFont = pid.Font(ttf="fnt_bs", size=5,bold=0) + # color for point in each chr + chrCount=len(ChrList) + chrColorDict =self.getColorForMarker(chrCount=chrCount,flag=1) + for j, item in enumerate(plinkresultList): + try : + mb=float(item[1])/1000000.0 + except: + mb=0 + + try : + pvalue =float(item[-1]) + except: + pvalue =1 + + try: + snpName = item[0] + except: + snpName='' + + formattedPvalue = -math.log10(pvalue) + + Xc = startPosX + (mb-startMb)*plotXScale + Yc = yZero - (formattedPvalue-pvalueMin)*pvalueHeightThresh/(tempPvalueMax - pvalueMin) + canvas.drawString("5", Xc-canvas.stringWidth("5",font=symbolFont)/2+1,Yc+2,color=chrColorDict[i], font=symbolFont) + m += 1 + + startPosX += (ChrLengthDistList[i]+GraphInterval)*plotXScale + + canvas.drawLine(xLeftOffset, yZero, xLeftOffset, yTopOffset, color=self.LRS_COLOR, width=1*zoom) #the blue line running up the y axis + + def drawQTL(self, canvas, drawAreaHeight, gifmap, plotXScale, offset= (40, 120, 80, 10), zoom = 1, startMb = None, endMb = None): + + xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset + plotWidth = canvas.size[0] - xLeftOffset - xRightOffset + plotHeight = canvas.size[1] - yTopOffset - yBottomOffset + fontZoom = zoom + if zoom == 2: + fontZoom = 1.5 + + INTERCROSS = (self.genotype.type=="intercross") + + ChrLengthDistList = self.ChrLengthMbList + GraphInterval=self.GraphInterval + LRSHeightThresh = drawAreaHeight + AdditiveHeightThresh = drawAreaHeight/2 + DominanceHeightThresh = drawAreaHeight/2 + + #draw the LRS scale + #We first determine whether or not we are using a sliding scale. + #If so, we need to compute the maximum LRS value to determine where the max y-value should be, and call this LRSMax. + #LRSTop is then defined to be above the LRSMax by enough to add one additional LRSScale increment. + #if we are using a set-scale, then we set LRSTop to be the user's value, and LRSMax doesn't matter. + + if self.LRS_LOD == 'LOD': + lodm = self.LODFACTOR + else: + lodm = 1.0 + + if self.lrsMax <= 0: #sliding scale + LRSMax = max(map(max, self.qtlresults)).lrs + #genotype trait will give infinite LRS + LRSMax = min(LRSMax, webqtlConfig.MAXLRS) + LRSMax = max(self.significance, LRSMax) + else: + LRSMax = self.lrsMax*lodm + + if LRSMax/lodm > 100: + LRSScale = 20.0 + elif LRSMax/lodm > 20: + LRSScale = 5.0 + elif LRSMax/lodm > 7.5: + LRSScale = 2.5 + else: + LRSScale = 1.0 + + LRSAxisList = Plot.frange(LRSScale, LRSMax/lodm, LRSScale) + #make sure the user's value appears on the y-axis + #update by NL 6-21-2011: round the LOD value to 100 when LRSMax is equal to 460 + LRSAxisList.append(round(LRSMax/lodm)) + + #draw the "LRS" or "LOD" string to the left of the axis + LRSScaleFont=pid.Font(ttf="verdana", size=14*fontZoom, bold=0) + LRSLODFont=pid.Font(ttf="verdana", size=14*zoom*1.5, bold=0) + yZero = yTopOffset + plotHeight + + #yAxis label display area + canvas.drawString(self.LRS_LOD, xLeftOffset - canvas.stringWidth("999.99", font=LRSScaleFont) - 10*zoom, \ + yZero - 150, font=LRSLODFont, color=pid.black, angle=90) + + for item in LRSAxisList: + yLRS = yZero - (item*lodm/LRSMax) * LRSHeightThresh + canvas.drawLine(xLeftOffset, yLRS, xLeftOffset - 4, yLRS, color=self.LRS_COLOR, width=1*zoom) + scaleStr = "%2.1f" % item + #added by NL 6-24-2011:Y-axis scale display + canvas.drawString(scaleStr, xLeftOffset-4-canvas.stringWidth(scaleStr, font=LRSScaleFont)-5, yLRS+3, font=LRSScaleFont, color=self.LRS_COLOR) + + + #"Significant" and "Suggestive" Drawing Routine + # ======= Draw the thick lines for "Significant" and "Suggestive" ===== (crowell: I tried to make the SNPs draw over these lines, but piddle wouldn't have it...) + if self.permChecked and not self.multipleInterval: + significantY = yZero - self.significance*LRSHeightThresh/LRSMax + suggestiveY = yZero - self.suggestive*LRSHeightThresh/LRSMax + + + startPosX = xLeftOffset + for i, _chr in enumerate(self.genotype): + rightEdge = int(startPosX + self.ChrLengthDistList[i]*plotXScale - self.SUGGESTIVE_WIDTH/1.5) + #added by NL 6-24-2011:draw suggestive line (grey one) + canvas.drawLine(startPosX+self.SUGGESTIVE_WIDTH/1.5, suggestiveY, rightEdge, suggestiveY, color=self.SUGGESTIVE_COLOR, + width=self.SUGGESTIVE_WIDTH*zoom, clipX=(xLeftOffset, xLeftOffset + plotWidth-2)) + #added by NL 6-24-2011:draw significant line (pink one) + canvas.drawLine(startPosX+self.SUGGESTIVE_WIDTH/1.5, significantY, rightEdge, significantY, color=self.SIGNIFICANT_COLOR, + width=self.SIGNIFICANT_WIDTH*zoom, clipX=(xLeftOffset, xLeftOffset + plotWidth-2)) + sugg_coords = "%d, %d, %d, %d" % (startPosX, suggestiveY-2, rightEdge + 2*zoom, suggestiveY+2) + sig_coords = "%d, %d, %d, %d" % (startPosX, significantY-2, rightEdge + 2*zoom, significantY+2) + if self.LRS_LOD == 'LRS': + sugg_title = "Suggestive LRS = %0.2f" % self.suggestive + sig_title = "Significant LRS = %0.2f" % self.significance + else: + sugg_title = "Suggestive LOD = %0.2f" % (self.suggestive/4.61) + sig_title = "Significant LOD = %0.2f" % (self.significance/4.61) + Areas1 = HT.Area(shape='rect',coords=sugg_coords,title=sugg_title) + Areas2 = HT.Area(shape='rect',coords=sig_coords,title=sig_title) + gifmap.areas.append(Areas1) + gifmap.areas.append(Areas2) + + startPosX += (self.ChrLengthDistList[i]+self.GraphInterval)*plotXScale + + + if self.multipleInterval: + lrsEdgeWidth = 1 + else: + additiveMax = max(map(lambda X : abs(X.additive), self.qtlresults[0])) + if INTERCROSS: + dominanceMax = max(map(lambda X : abs(X.dominance), self.qtlresults[0])) + else: + dominanceMax = -1 + lrsEdgeWidth = 2 + for i, qtlresult in enumerate(self.qtlresults): + m = 0 + startPosX = xLeftOffset + thisLRSColor = self.colorCollection[i] + + #add by NL 06-24-2011: for mahanttam plot + symbolFont = pid.Font(ttf="fnt_bs", size=5,bold=0) + + for j, _chr in enumerate(self.genotype): + chrCount=len(self.genotype) + chrColorDict =self.getColorForMarker(chrCount=chrCount,flag=1) + LRSCoordXY = [] + AdditiveCoordXY = [] + DominanceCoordXY = [] + for k, _locus in enumerate(_chr): + if self.plotScale == 'physic': + Xc = startPosX + (_locus.Mb-startMb)*plotXScale + else: + Xc = startPosX + (_locus.cM-_chr[0].cM)*plotXScale + # updated by NL 06-18-2011: + # fix the over limit LRS graph issue since genotype trait may give infinite LRS; + # for any lrs is over than 460(LRS max in this system), it will be reset to 460 + if qtlresult[m].lrs> 460 or qtlresult[m].lrs=='inf': + Yc = yZero - webqtlConfig.MAXLRS*LRSHeightThresh/LRSMax + else: + Yc = yZero - qtlresult[m].lrs*LRSHeightThresh/LRSMax + + LRSCoordXY.append((Xc, Yc)) + #add by NL 06-24-2011: for mahanttam plot + #self.significance/4.61 consider chr and LOD + # significantY = yZero - self.significance*LRSHeightThresh/LRSMax + # if Yc >significantY: + # canvas.drawString(":", Xc-canvas.stringWidth(":",font=symbolFont)/2+1,Yc+2,color=pid.black, font=symbolFont) + # else: + # canvas.drawString(":", Xc-canvas.stringWidth(":",font=symbolFont)/2+1,Yc+2,color=pid.black, font=symbolFont) + + # add by NL 06-27-2011: eliminate imputed value when locus name is equal to '-' + if (qtlresult[m].locus.name) and (qtlresult[m].locus.name!=' - '): + canvas.drawString("5", Xc-canvas.stringWidth("5",font=symbolFont)/2+1,Yc+2,color=chrColorDict[j], font=symbolFont) + + if not self.multipleInterval and self.additiveChecked: + Yc = yZero - qtlresult[m].additive*AdditiveHeightThresh/additiveMax + AdditiveCoordXY.append((Xc, Yc)) + if not self.multipleInterval and INTERCROSS and self.additiveChecked: + Yc = yZero - qtlresult[m].dominance*DominanceHeightThresh/dominanceMax + DominanceCoordXY.append((Xc, Yc)) + m += 1 + + startPosX += (ChrLengthDistList[j]+GraphInterval)*plotXScale + + + ###draw additive scale + if not self.multipleInterval and self.additiveChecked: + additiveScaleFont=pid.Font(ttf="verdana",size=12*fontZoom,bold=0) + additiveScale = Plot.detScaleOld(0,additiveMax) + additiveStep = (additiveScale[1]-additiveScale[0])/additiveScale[2] + additiveAxisList = Plot.frange(0, additiveScale[1], additiveStep) + maxAdd = additiveScale[1] + addPlotScale = AdditiveHeightThresh/additiveMax + + additiveAxisList.append(additiveScale[1]) + for item in additiveAxisList: + additiveY = yZero - item*addPlotScale + canvas.drawLine(xLeftOffset + plotWidth,additiveY,xLeftOffset+4+ plotWidth,additiveY,color=self.ADDITIVE_COLOR_POSITIVE, width=1*zoom) + scaleStr = "%2.3f" % item + canvas.drawString(scaleStr,xLeftOffset + plotWidth +6,additiveY+5,font=additiveScaleFont,color=self.ADDITIVE_COLOR_POSITIVE) + + canvas.drawLine(xLeftOffset+plotWidth,additiveY,xLeftOffset+plotWidth,yZero,color=self.ADDITIVE_COLOR_POSITIVE, width=1*zoom) + + canvas.drawLine(xLeftOffset, yZero, xLeftOffset, yTopOffset, color=self.LRS_COLOR, width=1*zoom) #the blue line running up the y axis + + def drawGraphBackgroundForPLINK(self, canvas, gifmap, offset= (80, 120, 80, 50), zoom = 1, startMb = None, endMb = None,plinkResultDict={} ): + + xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset + plotWidth = canvas.size[0] - xLeftOffset - xRightOffset + plotHeight = canvas.size[1] - yTopOffset - yBottomOffset + fontZoom = zoom + if zoom == 2: + fontZoom = 1.5 + + #calculate plot scale + #XZ: all of these global variables should be passed from function signiture + ChrLengthDistList = self.ChrLengthMbList + drawRegionDistance = self.ChrLengthMbSum + GraphInterval=self.GraphInterval + ChrList =self.ChrList + + #multiple chromosome view + plotXScale = plotWidth / ((len(ChrList)-1)*GraphInterval + drawRegionDistance) + + startPosX = xLeftOffset + chrLabelFont=pid.Font(ttf="verdana",size=24*fontZoom,bold=0) + + for i, _chr in enumerate(ChrList): + + if (i % 2 == 0): + theBackColor = self.GRAPH_BACK_DARK_COLOR + else: + theBackColor = self.GRAPH_BACK_LIGHT_COLOR + # NL:resize chr width for drawing + if float(ChrLengthDistList[i])<90: + ChrLengthDistList[i]=90 + #draw the shaded boxes and the sig/sug thick lines + canvas.drawRect(startPosX, yTopOffset, startPosX + ChrLengthDistList[i]*plotXScale, \ + yTopOffset+plotHeight, edgeColor=pid.gainsboro,fillColor=theBackColor) + + chrNameWidth = canvas.stringWidth(_chr, font=chrLabelFont) + chrStartPix = startPosX + (ChrLengthDistList[i]*plotXScale -chrNameWidth)/2 + chrEndPix = startPosX + (ChrLengthDistList[i]*plotXScale +chrNameWidth)/2 + + canvas.drawString(_chr, chrStartPix, yTopOffset +20,font = chrLabelFont,color=pid.dimgray) + COORDS = "%d,%d,%d,%d" %(chrStartPix, yTopOffset, chrEndPix,yTopOffset +20) + + #add by NL 09-03-2010 + HREF = "javascript:changeView(%d,%s);" % (i,ChrLengthDistList) + Areas = HT.Area(shape='rect',coords=COORDS,href=HREF) + gifmap.areas.append(Areas) + startPosX += (ChrLengthDistList[i]+GraphInterval)*plotXScale + + return plotXScale + + + def drawGraphBackground(self, canvas, gifmap, offset= (80, 120, 80, 50), zoom = 1, startMb = None, endMb = None): + ##conditions + ##multiple Chromosome view + ##single Chromosome Physical + ##single Chromosome Genetic + xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset + plotWidth = canvas.size[0] - xLeftOffset - xRightOffset + plotHeight = canvas.size[1] - yTopOffset - yBottomOffset + fontZoom = zoom + if zoom == 2: + fontZoom = 1.5 + + #calculate plot scale + if self.plotScale != 'physic': + self.ChrLengthDistList = self.ChrLengthCMList + drawRegionDistance = self.ChrLengthCMSum + else: + self.ChrLengthDistList = self.ChrLengthMbList + drawRegionDistance = self.ChrLengthMbSum + + if self.selectedChr > -1: #single chromosome view + spacingAmt = plotWidth/13.5 + i = 0 + for startPix in Plot.frange(xLeftOffset, xLeftOffset+plotWidth, spacingAmt): + if (i % 2 == 0): + theBackColor = self.GRAPH_BACK_DARK_COLOR + else: + theBackColor = self.GRAPH_BACK_LIGHT_COLOR + i += 1 + canvas.drawRect(startPix, yTopOffset, min(startPix+spacingAmt, xLeftOffset+plotWidth), \ + yTopOffset+plotHeight, edgeColor=theBackColor, fillColor=theBackColor) + + drawRegionDistance = self.ChrLengthDistList[self.selectedChr] + self.ChrLengthDistList = [drawRegionDistance] + if self.plotScale == 'physic': + plotXScale = plotWidth / (endMb-startMb) + else: + plotXScale = plotWidth / drawRegionDistance + + else: #multiple chromosome view + plotXScale = plotWidth / ((len(self.genotype)-1)*self.GraphInterval + drawRegionDistance) + + startPosX = xLeftOffset + chrLabelFont=pid.Font(ttf="verdana",size=24*fontZoom,bold=0) + + for i, _chr in enumerate(self.genotype): + + if (i % 2 == 0): + theBackColor = self.GRAPH_BACK_DARK_COLOR + else: + theBackColor = self.GRAPH_BACK_LIGHT_COLOR + + #draw the shaded boxes and the sig/sug thick lines + canvas.drawRect(startPosX, yTopOffset, startPosX + self.ChrLengthDistList[i]*plotXScale, \ + yTopOffset+plotHeight, edgeColor=pid.gainsboro,fillColor=theBackColor) + + chrNameWidth = canvas.stringWidth(_chr.name, font=chrLabelFont) + chrStartPix = startPosX + (self.ChrLengthDistList[i]*plotXScale -chrNameWidth)/2 + chrEndPix = startPosX + (self.ChrLengthDistList[i]*plotXScale +chrNameWidth)/2 + + canvas.drawString(_chr.name, chrStartPix, yTopOffset +20,font = chrLabelFont,color=pid.dimgray) + COORDS = "%d,%d,%d,%d" %(chrStartPix, yTopOffset, chrEndPix,yTopOffset +20) + + #add by NL 09-03-2010 + HREF = "javascript:changeView(%d,%s);" % (i,self.ChrLengthMbList) + Areas = HT.Area(shape='rect',coords=COORDS,href=HREF) + gifmap.areas.append(Areas) + startPosX += (self.ChrLengthDistList[i]+self.GraphInterval)*plotXScale + + return plotXScale + + # XZ: The only difference of function drawXAxisForPLINK and function drawXAxis are the function name and the self.plotScale condition. + def drawXAxisForPLINK(self, fd, canvas, drawAreaHeight, gifmap, plotXScale, showLocusForm, offset= (40, 120, 80, 10), zoom = 1, startMb = None, endMb = None): + xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset + plotWidth = canvas.size[0] - xLeftOffset - xRightOffset + plotHeight = canvas.size[1] - yTopOffset - yBottomOffset + yZero = canvas.size[1] - yBottomOffset + fontZoom = zoom + if zoom == 2: + fontZoom = 1.5 + + #Parameters + ChrLengthDistList = self.ChrLengthMbList + GraphInterval=self.GraphInterval + + NUM_MINOR_TICKS = 5 # Number of minor ticks between major ticks + X_MAJOR_TICK_THICKNESS = 2 + X_MINOR_TICK_THICKNESS = 1 + X_AXIS_THICKNESS = 1*zoom + + # ======= Alex: Draw the X-axis labels (megabase location) + MBLabelFont = pid.Font(ttf="verdana", size=12*fontZoom, bold=0) + xMajorTickHeight = 15 # How high the tick extends below the axis + xMinorTickHeight = 5*zoom + xAxisTickMarkColor = pid.black + xAxisLabelColor = pid.black + fontHeight = 12*fontZoom # How tall the font that we're using is + spacingFromLabelToAxis = 20 + spacingFromLineToLabel = 3 + + if self.plotScale == 'physic': + strYLoc = yZero + spacingFromLabelToAxis + canvas.fontHeight(MBLabelFont) + ###Physical single chromosome view + if self.selectedChr > -1: + graphMbWidth = endMb - startMb + XScale = Plot.detScale(startMb, endMb) + XStart, XEnd, XStep = XScale + if XStep < 8: + XStep *= 2 + spacingAmtX = spacingAmt = (XEnd-XStart)/XStep + + j = 0 + while abs(spacingAmtX -int(spacingAmtX)) >= spacingAmtX/100.0 and j < 6: + j += 1 + spacingAmtX *= 10 + + formatStr = '%%2.%df' % j + + for counter, _Mb in enumerate(Plot.frange(XStart, XEnd, spacingAmt / NUM_MINOR_TICKS)): + if _Mb < startMb or _Mb > endMb: + continue + Xc = xLeftOffset + plotXScale*(_Mb - startMb) + if counter % NUM_MINOR_TICKS == 0: # Draw a MAJOR mark, not just a minor tick mark + canvas.drawLine(Xc, yZero, Xc, yZero+xMajorTickHeight, color=xAxisTickMarkColor, width=X_MAJOR_TICK_THICKNESS) # Draw the MAJOR tick mark + labelStr = str(formatStr % _Mb) # What Mbase location to put on the label + strWidth = canvas.stringWidth(labelStr, font=MBLabelFont) + drawStringXc = (Xc - (strWidth / 2.0)) + canvas.drawString(labelStr, drawStringXc, strYLoc, font=MBLabelFont, color=xAxisLabelColor, angle=0) + else: + canvas.drawLine(Xc, yZero, Xc, yZero+xMinorTickHeight, color=xAxisTickMarkColor, width=X_MINOR_TICK_THICKNESS) # Draw the MINOR tick mark + # end else + + ###Physical genome wide view + else: + distScale = 0 + startPosX = xLeftOffset + for i, distLen in enumerate(ChrLengthDistList): + if distScale == 0: #universal scale in whole genome mapping + if distLen > 75: + distScale = 25 + elif distLen > 30: + distScale = 10 + else: + distScale = 5 + for tickdists in range(distScale, ceil(distLen), distScale): + canvas.drawLine(startPosX + tickdists*plotXScale, yZero, startPosX + tickdists*plotXScale, yZero + 7, color=pid.black, width=1*zoom) + canvas.drawString(str(tickdists), startPosX+tickdists*plotXScale, yZero + 10*zoom, color=pid.black, font=MBLabelFont, angle=270) + startPosX += (ChrLengthDistList[i]+GraphInterval)*plotXScale + + megabaseLabelFont = pid.Font(ttf="verdana", size=14*zoom*1.5, bold=0) + canvas.drawString("Megabases", xLeftOffset + (plotWidth -canvas.stringWidth("Megabases", font=megabaseLabelFont))/2, + strYLoc + canvas.fontHeight(MBLabelFont) + 5*zoom, font=megabaseLabelFont, color=pid.black) + pass + + canvas.drawLine(xLeftOffset, yZero, xLeftOffset+plotWidth, yZero, color=pid.black, width=X_AXIS_THICKNESS) # Draw the X axis itself + + def drawXAxis(self, fd, canvas, drawAreaHeight, gifmap, plotXScale, showLocusForm, offset= (40, 120, 80, 10), zoom = 1, startMb = None, endMb = None): + xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset + plotWidth = canvas.size[0] - xLeftOffset - xRightOffset + plotHeight = canvas.size[1] - yTopOffset - yBottomOffset + yZero = canvas.size[1] - yBottomOffset + fontZoom = zoom + if zoom == 2: + fontZoom = 1.5 + + #Parameters + NUM_MINOR_TICKS = 5 # Number of minor ticks between major ticks + X_MAJOR_TICK_THICKNESS = 2 + X_MINOR_TICK_THICKNESS = 1 + X_AXIS_THICKNESS = 1*zoom + + # ======= Alex: Draw the X-axis labels (megabase location) + MBLabelFont = pid.Font(ttf="verdana", size=12*fontZoom, bold=0) + xMajorTickHeight = 15 # How high the tick extends below the axis + xMinorTickHeight = 5*zoom + xAxisTickMarkColor = pid.black + xAxisLabelColor = pid.black + fontHeight = 12*fontZoom # How tall the font that we're using is + spacingFromLabelToAxis = 20 + spacingFromLineToLabel = 3 + + if self.plotScale == 'physic': + strYLoc = yZero + spacingFromLabelToAxis + canvas.fontHeight(MBLabelFont) + ###Physical single chromosome view + if self.selectedChr > -1: + graphMbWidth = endMb - startMb + XScale = Plot.detScale(startMb, endMb) + XStart, XEnd, XStep = XScale + if XStep < 8: + XStep *= 2 + spacingAmtX = spacingAmt = (XEnd-XStart)/XStep + + j = 0 + while abs(spacingAmtX -int(spacingAmtX)) >= spacingAmtX/100.0 and j < 6: + j += 1 + spacingAmtX *= 10 + + formatStr = '%%2.%df' % j + + for counter, _Mb in enumerate(Plot.frange(XStart, XEnd, spacingAmt / NUM_MINOR_TICKS)): + if _Mb < startMb or _Mb > endMb: + continue + Xc = xLeftOffset + plotXScale*(_Mb - startMb) + if counter % NUM_MINOR_TICKS == 0: # Draw a MAJOR mark, not just a minor tick mark + canvas.drawLine(Xc, yZero, Xc, yZero+xMajorTickHeight, color=xAxisTickMarkColor, width=X_MAJOR_TICK_THICKNESS) # Draw the MAJOR tick mark + labelStr = str(formatStr % _Mb) # What Mbase location to put on the label + strWidth = canvas.stringWidth(labelStr, font=MBLabelFont) + drawStringXc = (Xc - (strWidth / 2.0)) + canvas.drawString(labelStr, drawStringXc, strYLoc, font=MBLabelFont, color=xAxisLabelColor, angle=0) + else: + canvas.drawLine(Xc, yZero, Xc, yZero+xMinorTickHeight, color=xAxisTickMarkColor, width=X_MINOR_TICK_THICKNESS) # Draw the MINOR tick mark + # end else + + ###Physical genome wide view + else: + distScale = 0 + startPosX = xLeftOffset + for i, distLen in enumerate(self.ChrLengthDistList): + if distScale == 0: #universal scale in whole genome mapping + if distLen > 75: + distScale = 25 + elif distLen > 30: + distScale = 10 + else: + distScale = 5 + for tickdists in range(distScale, ceil(distLen), distScale): + canvas.drawLine(startPosX + tickdists*plotXScale, yZero, startPosX + tickdists*plotXScale, yZero + 7, color=pid.black, width=1*zoom) + canvas.drawString(str(tickdists), startPosX+tickdists*plotXScale, yZero + 10*zoom, color=pid.black, font=MBLabelFont, angle=270) + startPosX += (self.ChrLengthDistList[i]+self.GraphInterval)*plotXScale + + megabaseLabelFont = pid.Font(ttf="verdana", size=14*zoom*1.5, bold=0) + canvas.drawString("Megabases", xLeftOffset + (plotWidth -canvas.stringWidth("Megabases", font=megabaseLabelFont))/2, + strYLoc + canvas.fontHeight(MBLabelFont) + 5*zoom, font=megabaseLabelFont, color=pid.black) + pass + else: + ChrAInfo = [] + preLpos = -1 + distinctCount = 0.0 + if len(self.genotype) > 1: + for i, _chr in enumerate(self.genotype): + thisChr = [] + Locus0CM = _chr[0].cM + nLoci = len(_chr) + if nLoci <= 8: + for _locus in _chr: + if _locus.name != ' - ': + if _locus.cM != preLpos: + distinctCount += 1 + preLpos = _locus.cM + thisChr.append([_locus.name, _locus.cM-Locus0CM]) + else: + for j in (0, nLoci/4, nLoci/2, nLoci*3/4, -1): + while _chr[j].name == ' - ': + j += 1 + if _chr[j].cM != preLpos: + distinctCount += 1 + preLpos = _chr[j].cM + thisChr.append([_chr[j].name, _chr[j].cM-Locus0CM]) + ChrAInfo.append(thisChr) + else: + for i, _chr in enumerate(self.genotype): + thisChr = [] + Locus0CM = _chr[0].cM + for _locus in _chr: + if _locus.name != ' - ': + if _locus.cM != preLpos: + distinctCount += 1 + preLpos = _locus.cM + thisChr.append([_locus.name, _locus.cM-Locus0CM]) + ChrAInfo.append(thisChr) + + stepA = (plotWidth+0.0)/distinctCount + + LRectWidth = 10 + LRectHeight = 3 + offsetA = -stepA + lineColor = pid.lightblue + startPosX = xLeftOffset + for j, ChrInfo in enumerate(ChrAInfo): + preLpos = -1 + for i, item in enumerate(ChrInfo): + Lname,Lpos = item + if Lpos != preLpos: + offsetA += stepA + differ = 1 + else: + differ = 0 + preLpos = Lpos + Lpos *= plotXScale + if self.selectedChr > -1: + Zorder = i % 5 + else: + Zorder = 0 + if differ: + canvas.drawLine(startPosX+Lpos,yZero,xLeftOffset+offsetA,\ + yZero+25, color=lineColor) + canvas.drawLine(xLeftOffset+offsetA,yZero+25,xLeftOffset+offsetA,\ + yZero+40+Zorder*(LRectWidth+3),color=lineColor) + rectColor = pid.orange + else: + canvas.drawLine(xLeftOffset+offsetA, yZero+40+Zorder*(LRectWidth+3)-3,\ + xLeftOffset+offsetA, yZero+40+Zorder*(LRectWidth+3),color=lineColor) + rectColor = pid.deeppink + canvas.drawRect(xLeftOffset+offsetA, yZero+40+Zorder*(LRectWidth+3),\ + xLeftOffset+offsetA-LRectHeight,yZero+40+Zorder*(LRectWidth+3)+LRectWidth,\ + edgeColor=rectColor,fillColor=rectColor,edgeWidth = 0) + COORDS="%d,%d,%d,%d"%(xLeftOffset+offsetA-LRectHeight, yZero+40+Zorder*(LRectWidth+3),\ + xLeftOffset+offsetA,yZero+40+Zorder*(LRectWidth+3)+LRectWidth) + HREF="javascript:showDatabase3('%s','%s','%s','');" % (showLocusForm,fd.RISet+"Geno", Lname) + Areas=HT.Area(shape='rect',coords=COORDS,href=HREF, title="Locus : " + Lname) + gifmap.areas.append(Areas) + ##piddle bug + if j == 0: + canvas.drawLine(startPosX,yZero,startPosX,yZero+40, color=lineColor) + startPosX += (self.ChrLengthDistList[j]+self.GraphInterval)*plotXScale + + canvas.drawLine(xLeftOffset, yZero, xLeftOffset+plotWidth, yZero, color=pid.black, width=X_AXIS_THICKNESS) # Draw the X axis itself + + def getColorForMarker(self, chrCount,flag):# no change is needed + chrColorDict={} + for i in range(chrCount): + if flag==1: # display blue and lightblue intercross + chrColorDict[i]=pid.black + elif flag==0: + if (i%2==0): + chrColorDict[i]=pid.blue + else: + chrColorDict[i]=pid.lightblue + else:#display different color for different chr + if i in [0,8,16]: + chrColorDict[i]=pid.black + elif i in [1,9,17]: + chrColorDict[i]=pid.red + elif i in [2,10,18]: + chrColorDict[i]=pid.lightgreen + elif i in [3,11,19]: + chrColorDict[i]=pid.blue + elif i in [4,12]: + chrColorDict[i]=pid.lightblue + elif i in [5,13]: + chrColorDict[i]=pid.hotpink + elif i in [6,14]: + chrColorDict[i]=pid.gold + elif i in [7,15]: + chrColorDict[i]=pid.grey + + return chrColorDict + + + def drawProbeSetPosition(self, canvas, plotXScale, offset= (40, 120, 80, 10), zoom = 1, startMb = None, endMb = None): + if len(self.traitList) != 1: + return + + xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset + plotWidth = canvas.size[0] - xLeftOffset - xRightOffset + plotHeight = canvas.size[1] - yTopOffset - yBottomOffset + yZero = canvas.size[1] - yBottomOffset + fontZoom = zoom + if zoom == 2: + fontZoom = 1.5 + + try: + Chr = self.traitList[0].chr # self.traitListChr =self.traitList[0].chr=_vals need to change to chrList and mbList + Mb = self.traitList[0].mb # self.traitListMb =self.traitList[0].mb=_vals + except: + return + + if self.plotScale == 'physic': + if self.selectedChr > -1: + if self.genotype[0].name != Chr or Mb < self.startMb or Mb > self.endMb: + return + else: + locPixel = xLeftOffset + (Mb-self.startMb)*plotXScale + else: + locPixel = xLeftOffset + for i, _chr in enumerate(self.genotype): + if _chr.name != Chr: + locPixel += (self.ChrLengthDistList[i] + self.GraphInterval)*plotXScale + else: + locPixel += Mb*plotXScale + break + else: + if self.selectedChr > -1: + if self.genotype[0].name != Chr: + return + else: + for i, _locus in enumerate(self.genotype[0]): + #the trait's position is on the left of the first genotype + if i==0 and _locus.Mb >= Mb: + locPixel=-1 + break + + #the trait's position is between two traits + if i > 0 and self.genotype[0][i-1].Mb < Mb and _locus.Mb >= Mb: + locPixel = xLeftOffset + plotXScale*(self.genotype[0][i-1].cM+(_locus.cM-self.genotype[0][i-1].cM)*(Mb -self.genotype[0][i-1].Mb)/(_locus.Mb-self.genotype[0][i-1].Mb)) + break + + #the trait's position is on the right of the last genotype + if i==len(self.genotype[0]) and Mb>=_locus.Mb: + locPixel = -1 + else: + locPixel = xLeftOffset + for i, _chr in enumerate(self.genotype): + if _chr.name != Chr: + locPixel += (self.ChrLengthDistList[i] + self.GraphInterval)*plotXScale + else: + locPixel += (Mb*(_chr[-1].cM-_chr[0].cM)/self.ChrLengthCMList[i])*plotXScale + break + if locPixel >= 0: + traitPixel = ((locPixel, yZero), (locPixel-6, yZero+12), (locPixel+6, yZero+12)) + canvas.drawPolygon(traitPixel, edgeColor=pid.black, fillColor=self.TRANSCRIPT_LOCATION_COLOR, closed=1) + + if self.legendChecked: + startPosY = 15 + nCol = 2 + smallLabelFont = pid.Font(ttf="trebuc", size=12, bold=1) + leftOffset = xLeftOffset+(nCol-1)*200 + canvas.drawPolygon(((leftOffset+6, startPosY-6), (leftOffset, startPosY+6), (leftOffset+12, startPosY+6)), edgeColor=pid.black, fillColor=self.TRANSCRIPT_LOCATION_COLOR, closed=1) + canvas.drawString("Sequence Site", (leftOffset+15), (startPosY+5), smallLabelFont, self.TOP_RIGHT_INFO_COLOR) + + # build dict based on plink result, key is chr, value is list of [snp,BP,pValue] + def getPlinkResultDict(self,outputFileName='',thresholdPvalue=-1,ChrOrderIdNameDict={}): + + ChrList =self.ChrList + plinkResultDict={} + + plinkResultfp = open("%s%s.qassoc"% (webqtlConfig.TMPDIR, outputFileName), "rb") + + headerLine=plinkResultfp.readline()# read header line + line = plinkResultfp.readline() + + valueList=[] # initialize value list, this list will include snp, bp and pvalue info + pValueList=[] + count=0 + + while line: + #convert line from str to list + lineList=self.buildLineList(line=line) + + # only keep the records whose chromosome name is in db + if ChrOrderIdNameDict.has_key(int(lineList[0])) and lineList[-1] and lineList[-1].strip()!='NA': + + chrName=ChrOrderIdNameDict[int(lineList[0])] + snp = lineList[1] + BP = lineList[2] + pValue = float(lineList[-1]) + pValueList.append(pValue) + + if plinkResultDict.has_key(chrName): + valueList=plinkResultDict[chrName] + + # pvalue range is [0,1] + if thresholdPvalue >=0 and thresholdPvalue<=1: + if pValue < thresholdPvalue: + valueList.append((snp,BP,pValue)) + count+=1 + + plinkResultDict[chrName]=valueList + valueList=[] + else: + if thresholdPvalue>=0 and thresholdPvalue<=1: + if pValue < thresholdPvalue: + valueList.append((snp,BP,pValue)) + count+=1 + + if valueList: + plinkResultDict[chrName]=valueList + + valueList=[] + + + line =plinkResultfp.readline() + else: + line=plinkResultfp.readline() + + if pValueList: + minPvalue= min(pValueList) + else: + minPvalue=0 + + return count,minPvalue,plinkResultDict + + + ###################################################### + # input: line: str,one line read from file + # function: convert line from str to list; + # output: lineList list + ####################################################### + def buildLineList(self,line=None): + + lineList = string.split(string.strip(line),' ')# irregular number of whitespaces between columns + lineList =[ item for item in lineList if item <>''] + lineList = map(string.strip, lineList) + + return lineList + + #added by NL: automatically generate pheno txt file for PLINK based on strainList passed from dataEditing page + def genPhenoTxtFileForPlink(self,phenoFileName='', RISetName='', probesetName='', valueDict={}): + pedFileStrainList=self.getStrainNameFromPedFile(RISetName=RISetName) + outputFile = open("%s%s.txt"%(webqtlConfig.TMPDIR,phenoFileName),"wb") + headerLine = 'FID\tIID\t%s\n'%probesetName + outputFile.write(headerLine) + + newValueList=[] + + #if valueDict does not include some strain, value will be set to -9999 as missing value + for item in pedFileStrainList: + try: + value=valueDict[item] + value=str(value).replace('value=','') + value=value.strip() + except: + value=-9999 + + newValueList.append(value) + + + newLine='' + for i, strain in enumerate(pedFileStrainList): + j=i+1 + value=newValueList[i] + newLine+='%s\t%s\t%s\n'%(strain, strain, value) + + if j%1000==0: + outputFile.write(newLine) + newLine='' + + if newLine: + outputFile.write(newLine) + + outputFile.close() + + # get strain name from ped file in order + def getStrainNameFromPedFile(self, RISetName=''): + pedFileopen= open("%splink/%s.ped"%(webqtlConfig.HTMLPATH, RISetName),"r") + line =pedFileopen.readline() + strainNameList=[] + + while line: + lineList=string.split(string.strip(line),'\t') + lineList=map(string.strip,lineList) + + strainName=lineList[0] + strainNameList.append(strainName) + + line =pedFileopen.readline() + + return strainNameList + + ################################################################# + ## Generate Chr list, Chr OrderId and Retrieve Length Information + ################################################################# + #def getChrNameOrderIdLength(self,RISet=''): + # + # try: + # query = """ + # Select + # Chr_Length.Name,Chr_Length.OrderId,Length from Chr_Length, InbredSet + # where + # Chr_Length.SpeciesId = InbredSet.SpeciesId AND + # InbredSet.Name = '%s' + # Order by OrderId + # """ % (RISet) + # self.cursor.execute(query) + # + # results =self.cursor.fetchall() + # ChrList=[] + # ChrLengthMbList=[] + # ChrNameOrderIdDict={} + # ChrOrderIdNameDict={} + # + # for item in results: + # ChrList.append(item[0]) + # ChrNameOrderIdDict[item[0]]=item[1] # key is chr name, value is orderId + # ChrOrderIdNameDict[item[1]]=item[0] # key is orderId, value is chr name + # ChrLengthMbList.append(item[2]) + # + # except: + # ChrList=[] + # ChrNameOrderIdDict={} + # ChrLengthMbList=[] + # + # return ChrList,ChrNameOrderIdDict,ChrOrderIdNameDict,ChrLengthMbList -- cgit v1.2.3 From c8a4719a83e3ee65a8c03b0b600a3cfea9ff17bf Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Tue, 8 Jan 2013 14:46:07 -0600 Subject: Deleted some unnecessary code in marker_regression.py and fixed some bugs Added a couple utility functions to the Chromosomes class in species.py --- wqflask/base/species.py | 22 +++++++- .../wqflask/marker_regression/marker_regression.py | 66 ++++------------------ 2 files changed, 30 insertions(+), 58 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/species.py b/wqflask/base/species.py index 1fd76772..85f076ca 100644 --- a/wqflask/base/species.py +++ b/wqflask/base/species.py @@ -13,7 +13,8 @@ class TheSpecies(object): self.dataset = dataset print("self.dataset is:", pf(self.dataset.__dict__)) self.chromosomes = Chromosomes(self.dataset.group.name) - + self.genome_length = self.chromosomes.get_genome_length() + #@property #def chromosomes(self): # chromosomes = [("All", -1)] @@ -31,7 +32,7 @@ class TheSpecies(object): class Chromosomes(object): def __init__(self, group_name): self.chromosomes = collections.OrderedDict() - + results = g.db.execute(""" Select Chr_Length.Name, Length from Chr_Length, InbredSet @@ -46,3 +47,20 @@ class Chromosomes(object): self.chromosomes[item.Name] = item.Length print("self.chromosomes:", self.chromosomes) + + + def get_mb_length(self): + """Gets the chromosome length in megabases""" + + mb_lengths = chr_length/1000000.0 for name, chr_length in self.chromosomes + + return mb_lengths + + def get_genome_length(self): + """Gets the sum of each chromosome's length""" + + genome_length = 0 + for name, value in self.chromosomes.items(): + genome_length += value + + return genome_length \ No newline at end of file diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py index ace76411..0aad4e54 100755 --- a/wqflask/wqflask/marker_regression/marker_regression.py +++ b/wqflask/wqflask/marker_regression/marker_regression.py @@ -67,11 +67,9 @@ class MarkerRegression(object): self.dataset.group.read_genotype_file() self.genotype = self.dataset.group.genotype - assert start_vars['display_all_vars'] in ('True', 'False') + assert start_vars['display_all_lrs'] in ('True', 'False') self.display_all_lrs = True if start_vars['display_all_lrs'] == 'True' else False - print("self.display_all_lrs is:", pf(self.display_all_lrs)) - for sample in self.dataset.group.samplelist: value = start_vars['value:' + sample] variance = start_vars['variance:' + sample] @@ -314,6 +312,7 @@ class MarkerRegression(object): """ Initializes all of the MarkerRegressionPage class parameters, acquiring most values from the formdata (fd) + """ ################################### # manhattam plot parameters @@ -448,70 +447,23 @@ class MarkerRegression(object): return rv, tblobj,bottomInfo - #def GenReport(self, ChrNameOrderIdDict,fd, _genotype, _strains, _vals, _vars= []): def gen_data(self): """Todo: Fill this in here""" - #'Create an HTML division which reports any loci which are significantly associated with the submitted trait data.' - + #calculate QTL for each trait - #self.qtlresults = [] - #if webqtlUtil.ListNotNull(_vars): - - #strains = - #vals = - #variances = - - #if any(self.variances): - # self.qtl_results = self.genotype.regression(strains = self.samples, - # trait = self.vals, - # variance = self.variances) - # self.lrs_array = self.genotype.permutation(strains = self.samples, - # trait = self.vals, - # variance = self.variances, - # nperm = self.num_perm) - #else: self.qtl_results = self.genotype.regression(strains = self.samples, trait = self.vals) self.lrs_array = self.genotype.permutation(strains = self.samples, trait = self.vals, nperm=self.num_perm) - #print("[yellow] self.__dict__ is:", pf(self.__dict__)) - - #self.qtlresults.append(qtlresults) - - #filename= webqtlUtil.genRandStr("GenomeAsscociation_") - - - - # set suggestive, significant and highly significant LRS - #if fd.suggestive == None: - #self.suggestive = self.lrs_array[int(self.num_perm*0.37-1)] - ##else: - ## fd.suggestive = float(fd.suggestive) - ##if fd.significance == None: - #self.significance = self.lrs_array[int(self.num_perm*0.95-1)] - ##else: - ## fd.significance = float(fd.significance) - # - ##self.significance =fd.significance - ##self.suggestive = fd.suggestive - #self.highlysignificant = LRSArray[int(fd.nperm*0.99-1)] - self.lrs_thresholds = Bunch( suggestive = self.lrs_array[int(self.num_perm*0.37-1)], significant = self.lrs_array[int(self.num_perm*0.95-1)], - highly_significant = self.lrs_array[int(fd.nperm*0.99-1)] + highly_significant = self.lrs_array[int(self.num_perm*0.99-1)] ) - - #disp_all_lrs = False - #if fd.formdata.getvalue('displayAllLRS'): - # disp_all_lrs = True - - #if not self.disp_all_lrs: - - if self.disp_all_lrs: + if self.display_all_lrs: filtered_results = self.qtl_results else: suggestive_results = [] @@ -587,7 +539,9 @@ class MarkerRegression(object): # report = HT.Blockquote(HT.Font('No association ',color="#FF0000"),HT.Font('with a likelihood ratio statistic greater than %3.1f was found. Here are the top 10 LRSs.' % fd.suggestive,color="#000000")) #else: # report = HT.Blockquote('The following loci in the %s data set have associations with the above trait data.\n' % fd.RISet, HT.P()) - report.__setattr__("class","normalsize") + + + #report.__setattr__("class","normalsize") #fpText = open('%s.txt' % (webqtlConfig.TMPDIR+filename), 'wb') #fpText.write('Suggestive LRS =%3.2f\n'%self.suggestive) @@ -610,11 +564,11 @@ class MarkerRegression(object): #for ncol, item in enumerate(headerList): # reportHeaderRow.append(THCell(HT.TD(item, Class=headerStyle, valign='bottom',nowrap='ON'),text=item, idx=ncol)) - for marker in filtered: + for marker in filtered_results: if marker.lrs > webqtlConfig.MAXLRS: marker.lrs = webqtlConfig.MAXLRS - self.filtered = filtered + self.filtered_results = filtered_results #if fd.genotype.type == 'intercross': # ncol =len(headerList) -- cgit v1.2.3 From 34b0cc3a931e266b6382c961d6321ccc9b3ac430 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Tue, 8 Jan 2013 17:16:45 -0600 Subject: Created IndChromosome class in species.py and wrote functions for chromosome-related attributes Began to try and pass qtlreaper results as js_data to use when drawing graphs --- wqflask/base/species.py | 83 +++++++++++++++++----- .../wqflask/marker_regression/marker_regression.py | 81 +++++++++++---------- wqflask/wqflask/views.py | 11 +-- 3 files changed, 119 insertions(+), 56 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/species.py b/wqflask/base/species.py index 85f076ca..9d4cac4c 100644 --- a/wqflask/base/species.py +++ b/wqflask/base/species.py @@ -6,14 +6,17 @@ from flask import Flask, g #from MySQLdb import escape_string as escape +from utility import Bunch + from pprint import pformat as pf class TheSpecies(object): def __init__(self, dataset): self.dataset = dataset print("self.dataset is:", pf(self.dataset.__dict__)) - self.chromosomes = Chromosomes(self.dataset.group.name) - self.genome_length = self.chromosomes.get_genome_length() + self.chromosomes = Chromosomes(self.dataset) + self.genome_mb_length = self.chromosomes.get_genome_mb_length() + #@property #def chromosomes(self): @@ -27,10 +30,22 @@ class TheSpecies(object): # # return chromosomes +class IndChromosome(object): + def __init__(self, length): + self.length = length + + @property + def mb_length(self): + """Chromosome length in megabases""" + return self.length / 1000000 + + def set_cm_length(self, genofile_chr): + self.cm_length = genofile_chr[-1].cM - genofile_chr[0].cM class Chromosomes(object): - def __init__(self, group_name): + def __init__(self, dataset): + self.dataset = dataset self.chromosomes = collections.OrderedDict() results = g.db.execute(""" @@ -40,27 +55,63 @@ class Chromosomes(object): Chr_Length.SpeciesId = InbredSet.SpeciesId AND InbredSet.Name = %s Order by OrderId - """, group_name).fetchall() + """, self.dataset.group.name).fetchall() print("bike:", results) for item in results: - self.chromosomes[item.Name] = item.Length + self.chromosomes[item.Name] = IndChromosome(item.Length) + + self.set_mb_graph_interval() + self.get_cm_length_list() + + + def set_mb_graph_interval(self): + """Empirical megabase interval""" + + #if self.chromosomes: + assert self.chromosomes, "Have to add some code back in apparently to set it to 1" + self.mb_graph_interval = self.get_genome_mb_length()/(len(self.chromosomes)*12) + #else: + #self.mb_graph_interval = 1 - print("self.chromosomes:", self.chromosomes) + def get_genome_mb_length(self): + """Gets the sum of each chromosome's length in megabases""" - def get_mb_length(self): - """Gets the chromosome length in megabases""" + return sum([ind_chromosome.mb_length for ind_chromosome in self.chromosomes.values()]) - mb_lengths = chr_length/1000000.0 for name, chr_length in self.chromosomes - return mb_lengths + def get_genome_cm_length(self): + """Gets the sum of each chromosome's length in centimorgans""" - def get_genome_length(self): - """Gets the sum of each chromosome's length""" + return sum([ind_chromosome.cm_length for ind_chromosome in self.chromosomes.values()]) - genome_length = 0 - for name, value in self.chromosomes.items(): - genome_length += value + def get_cm_length_list(self): + """Chromosome length in centimorgans + + Calculates the length in centimorgans by subtracting the centimorgan position + of the last marker in a chromosome by the position of the first marker + + """ + + self.dataset.group.read_genotype_file() + + self.cm_length_list = [] + + for chromosome in self.dataset.group.genotype: + self.cm_length_list.append(chromosome[-1].cM - chromosome[0].cM) + + print("self.cm_length_list:", pf(self.cm_length_list)) + + assert len(self.cm_length_list) == len(self.chromosomes), "Uh-oh lengths should be equal!" + for counter, chromosome in enumerate(self.chromosomes.values()): + chromosome.cm_length = self.cm_length_list[counter] + #self.chromosomes[counter].cm_length = item + + for key, value in self.chromosomes.items(): + print("bread - %s: %s" % (key, pf(vars(value)))) + - return genome_length \ No newline at end of file +# Testing +#if __name__ == '__main__': +# foo = dict(bar=dict(length)) \ No newline at end of file diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py index 0aad4e54..73f1246f 100755 --- a/wqflask/wqflask/marker_regression/marker_regression.py +++ b/wqflask/wqflask/marker_regression/marker_regression.py @@ -256,54 +256,58 @@ class MarkerRegression(object): #for i, indChr in enumerate(self.genotype): # self.ChrList.append((indChr.name, i)) - self.cursor.execute(""" - Select - Length from Chr_Length, InbredSet - where - Chr_Length.SpeciesId = InbredSet.SpeciesId AND - InbredSet.Name = '%s' AND - Chr_Length.Name in (%s) - Order by - OrderId - """ % (fd.RISet, string.join(map(lambda X: "'%s'" % X[0], self.ChrList[1:]), ", "))) - - self.ChrLengthMbList = self.cursor.fetchall() - self.ChrLengthMbList = map(lambda x: x[0]/1000000.0, self.ChrLengthMbList) - self.ChrLengthMbSum = reduce(lambda x, y:x+y, self.ChrLengthMbList, 0.0) - if self.ChrLengthMbList: - self.MbGraphInterval = self.ChrLengthMbSum/(len(self.ChrLengthMbList)*12) #Empirical Mb interval - else: - self.MbGraphInterval = 1 - - self.ChrLengthCMList = [] - for i, _chr in enumerate(self.genotype): - self.ChrLengthCMList.append(_chr[-1].cM - _chr[0].cM) - self.ChrLengthCMSum = reduce(lambda x, y:x+y, self.ChrLengthCMList, 0.0)# used for calculate plot scale + #self.cursor.execute(""" + # Select + # Length from Chr_Length, InbredSet + # where + # Chr_Length.SpeciesId = InbredSet.SpeciesId AND + # InbredSet.Name = '%s' AND + # Chr_Length.Name in (%s) + # Order by + # OrderId + # """ % (fd.RISet, string.join(map(lambda X: "'%s'" % X[0], self.ChrList[1:]), ", "))) + # + #self.ChrLengthMbList = self.cursor.fetchall() + #self.ChrLengthMbList = map(lambda x: x[0]/1000000.0, self.ChrLengthMbList) + #self.ChrLengthMbSum = reduce(lambda x, y:x+y, self.ChrLengthMbList, 0.0) + #if self.ChrLengthMbList: + # self.MbGraphInterval = self.ChrLengthMbSum/(len(self.ChrLengthMbList)*12) #Empirical Mb interval + #else: + # self.MbGraphInterval = 1 + # + #self.ChrLengthCMList = [] + #for i, _chr in enumerate(self.genotype): + # self.ChrLengthCMList.append(_chr[-1].cM - _chr[0].cM) + #self.ChrLengthCMSum = reduce(lambda x, y:x+y, self.ChrLengthCMList, 0.0)# used for calculate plot scale - self.GraphInterval = self.MbGraphInterval #Mb + #self.GraphInterval = self.MbGraphInterval #Mb # begin: common part with human data - intCanvas = pid.PILCanvas(size=(self.graphWidth,self.graphHeight)) - gifmap = self.plotIntMapping(fd, intCanvas, startMb = self.startMb, endMb = self.endMb, showLocusForm= "") - filename= webqtlUtil.genRandStr("Itvl_") - intCanvas.save(os.path.join(webqtlConfig.IMGDIR, filename), format='png') - intImg=HT.Image('/image/'+filename+'.png', border=0, usemap='#WebQTLImageMap') + #intCanvas = pid.PILCanvas(size=(self.graphWidth,self.graphHeight)) + #gifmap = self.plotIntMapping(fd, intCanvas, startMb = self.startMb, endMb = self.endMb, showLocusForm= "") + #filename= webqtlUtil.genRandStr("Itvl_") + #intCanvas.save(os.path.join(webqtlConfig.IMGDIR, filename), format='png') + #intImg=HT.Image('/image/'+filename+'.png', border=0, usemap='#WebQTLImageMap') ################################################################ # footnote goes here ################################################################ - btminfo = HT.Paragraph(Id="smallsize") #Small('More information about this graph is available here.') - - if (self.additiveChecked): - btminfo.append(HT.BR(), 'A positive additive coefficient (', HT.Font('green', color='green'), ' line) indicates that %s alleles increase trait values. In contrast, a negative additive coefficient (' % fd.ppolar, HT.Font('red', color='red'), ' line) indicates that %s alleles increase trait values.' % fd.mpolar) + #btminfo = HT.Paragraph(Id="smallsize") #Small('More information about this graph is available here.') + #if (self.additiveChecked): + # btminfo.append(HT.BR(), 'A positive additive coefficient (', HT.Font('green', color='green'), ' line) indicates that %s alleles increase trait values. In contrast, a negative additive coefficient (' % fd.ppolar, HT.Font('red', color='red'), ' line) indicates that %s alleles increase trait values.' % fd.mpolar) - TD_LR = HT.TR(HT.TD(HT.Blockquote(gifmap,intImg, HT.P()), bgColor='#eeeeee', height = 200)) - self.dict['body'] = str(datadiv)+str(TD_LR)+str(resultstable)+str(HT.TR(HT.TD(descriptionTable))) + #TD_LR = HT.TR(HT.TD(HT.Blockquote(gifmap,intImg, HT.P()), bgColor='#eeeeee', height = 200)) + # + #self.dict['body'] = str(datadiv)+str(TD_LR)+str(resultstable)+str(HT.TR(HT.TD(descriptionTable))) # end: common part with human data - + + self.js_data = dict( + qtl_results = self.pure_qtl_results, + #lrs_array = vars(self.lrs_array), + ) @@ -467,7 +471,12 @@ class MarkerRegression(object): filtered_results = self.qtl_results else: suggestive_results = [] + self.pure_qtl_results = [] for result in self.qtl_results: + self.pure_qtl_results.append(dict(locus=dict(cM=result.locus.cM, + chromosome=result.locus.chr), + lrs=result.lrs, + additive=result.additive)) if result.lrs > self.lrs_thresholds.suggestive: suggestive_results.append(result) filtered_results = suggestive_results diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index f6c0dfb0..fc628d77 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -151,10 +151,10 @@ def show_trait_page(): def marker_regression_page(): template_vars = marker_regression.MarkerRegression(request.form) #print("js_data before dump:", template_vars.js_data) - #template_vars.js_data = json.dumps(template_vars.js_data, - # default=json_default_handler, - # indent=" ") - #print("js_data after dump:", template_vars.js_data) + template_vars.js_data = json.dumps(template_vars.js_data, + default=json_default_handler, + indent=" ") + print("[dub] js_data after dump:", template_vars.js_data) print("marker_regression template_vars:", pf(template_vars.__dict__)) return render_template("marker_regression.html", **template_vars.__dict__) @@ -190,6 +190,9 @@ def json_default_handler(obj): # Handle custom objects if hasattr(obj, '__dict__'): return obj.__dict__ + #elif type(obj) == "Dataset": + # print("Not going to serialize Dataset") + # return None else: raise TypeError, 'Object of type %s with value of %s is not JSON serializable' % ( type(obj), repr(obj)) -- cgit v1.2.3