diff options
author | root | 2012-05-08 18:39:56 -0500 |
---|---|---|
committer | root | 2012-05-08 18:39:56 -0500 |
commit | ea46f42ee640928b92947bfb204c41a482d80937 (patch) | |
tree | 9b27a4eb852d12539b543c3efee9d2a47ef470f3 /web/webqtl/snpBrowser/snpDetails.py | |
parent | 056b5253fc3857b0444382aa39944f6344dc1ceb (diff) | |
download | genenetwork2-ea46f42ee640928b92947bfb204c41a482d80937.tar.gz |
Add all the source codes into the github.
Diffstat (limited to 'web/webqtl/snpBrowser/snpDetails.py')
-rwxr-xr-x | web/webqtl/snpBrowser/snpDetails.py | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/web/webqtl/snpBrowser/snpDetails.py b/web/webqtl/snpBrowser/snpDetails.py new file mode 100755 index 00000000..43100ba9 --- /dev/null +++ b/web/webqtl/snpBrowser/snpDetails.py @@ -0,0 +1,101 @@ +# 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 + +######################################### +# A class for the information of SNPs ONLY. This is for the 'extra' page when you click on a SNP that doesn't have an RS# +# This is where the information populating +# The table is gathered. This is where you determine what variables you will display in the table +######################################### + +import string +from htmlgen import HTMLgen2 as HT + +import snpBrowserUtils +from base.templatePage import templatePage +from snpBrowserPage import snpBrowserPage + +class snpDetails(templatePage): + + def __init__(self, fd, snpId): + + templatePage.__init__(self, fd) + + snpCols = "snpname, chromosome, mb, domain, rs, function, type, majorAllele, majorCount, minorAllele, minorCount, class, flanking5, flanking3, blatScore, sourceId, gene, ncbi".split(", ") + #get the details from the database if search the SNP variants by the "gene/snp" field + if snpId: + self.openMysql() + + mysqlField = ['snpname','rs', 'chromosome', 'mb', 'function', 'type', 'class', 'flanking5', 'flanking3', 'blatscore', 'domain', 'gene', 'ncbi'] + query = """ + SELECT + %s, c.Name,b.* + from + SnpAll a, SnpPattern b, SnpSource c + where + a.Id =%s AND a.Id = b.SnpId AND a.SourceId =c.Id + """ % (string.join(mysqlField, ", "), snpId) + + self.cursor.execute(query) + results = self.cursor.fetchone() + result =results[:14] + mysqlField.append('sourceName') + snpDict = {} + + for i, item in enumerate(result): + snpDict[mysqlField[i]] = item + alleleList =results[15:] + objSnpBrowserPage =snpBrowserPage(fd) + flag =0 + majAllele,minAllele,majAlleleCount,minAlleleCount= objSnpBrowserPage.getMajMinAlleles(alleleList,flag) + snpDict['majorAllele'] = majAllele + snpDict['minorAllele'] = minAllele + snpDict['majorCount'] = majAlleleCount + snpDict['minorCount'] = minAlleleCount + else: + return + + # Creates the table for the SNP data + snpTable = HT.TableLite(border=0, cellspacing=5, cellpadding=3, Class="collap") + for item in snpCols: + thisTR = HT.TR(HT.TD(snpBrowserUtils.columnNames[item], Class="fs14 fwb ffl b1 cw cbrb", NOWRAP = 1)) + if item in ('flanking5', 'flanking3'): + seq0 = snpDict[item] + seq = "" + i = 0 + if seq0: + while i < len(seq0): + seq += seq0[i:i+5] + " " + i += 5 + thisTR.append(HT.TD(HT.Span(seq, Class="code", Id="green"), Class='fs13 b1 cbw c222')) + elif item in snpDict.keys() and snpDict[item]: + thisTR.append(HT.TD(snpDict[item], Class='fs13 b1 cbw c222')) + else: + thisTR.append(HT.TD("", Class='fs13 b1 cbw c222')) + + snpTable.append(thisTR) + + self.dict['body'] = HT.TD(HT.Paragraph("Details for %s" % snpDict['snpname'], Class="title"), HT.Blockquote(snpTable)) + self.dict['title'] = "Details for %s" % snpDict['snpname']
\ No newline at end of file |