aboutsummaryrefslogtreecommitdiff
path: root/wqflask/base
diff options
context:
space:
mode:
authorzsloan2018-04-06 15:50:29 +0000
committerzsloan2018-04-06 15:50:29 +0000
commit07c0daa04b2693f55dd69cae43c254ebb5c9a35b (patch)
tree6fa0210fd7725b55334cd2602878feba9ecb1977 /wqflask/base
parente246822f359938be6af7e3f5587dea635ff5f9df (diff)
downloadgenenetwork2-07c0daa04b2693f55dd69cae43c254ebb5c9a35b.tar.gz
Mapping figure output now gives more accurate information
Committing partway through removing a bunch of unused code/files just in case something necessary gets removed
Diffstat (limited to 'wqflask/base')
-rw-r--r--wqflask/base/data_set.py147
-rw-r--r--wqflask/base/mrna_assay_tissue_data.py1
-rw-r--r--wqflask/base/species.py80
-rw-r--r--wqflask/base/template.py123
-rw-r--r--wqflask/base/trait.py206
5 files changed, 4 insertions, 553 deletions
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py
index a4eaaa2e..9ca880d0 100644
--- a/wqflask/base/data_set.py
+++ b/wqflask/base/data_set.py
@@ -29,7 +29,6 @@ import json
import gzip
import cPickle as pickle
import itertools
-from operator import itemgetter
from redis import Redis
Redis = Redis()
@@ -316,9 +315,6 @@ class DatasetGroup(object):
return mapping_id, mapping_names
- def get_specified_markers(self, markers = []):
- self.markers = HumanMarkers(self.name, markers)
-
def get_markers(self):
logger.debug("self.species is:", self.species)
@@ -449,7 +445,6 @@ def datasets(group_name, this_group = None):
group_name, webqtlConfig.PUBLICTHRESH,
"'" + group_name + "'", webqtlConfig.PUBLICTHRESH))
- #for tissue_name, dataset in itertools.groupby(the_results, itemgetter(0)):
for dataset_item in the_results:
tissue_name = dataset_item[0]
dataset = dataset_item[1]
@@ -457,14 +452,10 @@ def datasets(group_name, this_group = None):
if tissue_name in ['#PublishFreeze', '#GenoFreeze']:
dataset_menu.append(dict(tissue=None, datasets=[(dataset, dataset_short)]))
else:
- dataset_sub_menu = [item[1:] for item in dataset]
-
tissue_already_exists = False
- tissue_position = None
for i, tissue_dict in enumerate(dataset_menu):
if tissue_dict['tissue'] == tissue_name:
tissue_already_exists = True
- tissue_position = i
break
if tissue_already_exists:
@@ -719,20 +710,6 @@ class PhenotypeDataSet(DataSet):
# (Urgently?) Need to write this
pass
- def get_trait_list(self):
- query = """
- select PublishXRef.Id
- from PublishXRef, PublishFreeze
- where PublishFreeze.InbredSetId=PublishXRef.InbredSetId
- and PublishFreeze.Id = {}
- """.format(escape(str(self.id)))
- logger.sql(query)
- results = g.db.execute(query).fetchall()
- trait_data = {}
- for trait in results:
- trait_data[trait[0]] = self.retrieve_sample_data(trait[0])
- return trait_data
-
def get_trait_info(self, trait_list, species = ''):
for this_trait in trait_list:
@@ -746,7 +723,7 @@ class PhenotypeDataSet(DataSet):
#of the post-publication description
if this_trait.confidential:
this_trait.description_display = ""
- continue # for now
+ continue # for now, because no authorization features
if not webqtlUtil.hasAccessToConfidentialPhenotypeTrait(
privilege=self.privilege,
@@ -770,9 +747,7 @@ 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
if this_trait.lrs:
query = """
@@ -789,17 +764,7 @@ class PhenotypeDataSet(DataSet):
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: %.6f' % (LRS_Chr, float(LRS_Mb))
def retrieve_sample_data(self, trait):
@@ -861,40 +826,13 @@ class GenotypeDataSet(DataSet):
def check_confidentiality(self):
return geno_mrna_confidentiality(self)
- def get_trait_list(self):
- query = """
- select Geno.Name
- from Geno, GenoXRef
- where GenoXRef.GenoId = Geno.Id
- and GenoFreezeId = {}
- """.format(escape(str(self.id)))
- logger.sql(query)
- results = g.db.execute(query).fetchall()
- trait_data = {}
- for trait in results:
- trait_data[trait[0]] = self.retrieve_sample_data(trait[0])
- return trait_data
-
def get_trait_info(self, trait_list, species=None):
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: %.6f' % (this_trait.chr, float(this_trait.mb) )
- this_trait.location_value = trait_location_value
def retrieve_sample_data(self, trait):
query = """
@@ -989,20 +927,6 @@ class MrnaAssayDataSet(DataSet):
def check_confidentiality(self):
return geno_mrna_confidentiality(self)
- def get_trait_list_1(self):
- query = """
- select ProbeSet.Name
- from ProbeSet, ProbeSetXRef
- where ProbeSetXRef.ProbeSetId = ProbeSet.Id
- and ProbeSetFreezeId = {}
- """.format(escape(str(self.id)))
- logger.sql(query)
- results = g.db.execute(query).fetchall()
- trait_data = {}
- for trait in results:
- trait_data[trait[0]] = self.retrieve_sample_data(trait[0])
- return trait_data
-
def get_trait_info(self, trait_list=None, species=''):
# Note: setting trait_list to [] is probably not a great idea.
@@ -1034,27 +958,8 @@ class MrnaAssayDataSet(DataSet):
# Save it for the jinja2 template
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:
- #Checks if the chromosome number can be cast to an int (i.e. isn't "X" or "Y")
- #This is so we can convert the location to a number used for sorting
- trait_location_value = self.convert_location_to_value(this_trait.chr, this_trait.mb)
- #try:
- # trait_location_value = int(this_trait.chr)*1000 + this_trait.mb
- #except ValueError:
- # 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)
-
- #ZS: Put this in function currently called "convert_location_to_value"
- this_trait.location_repr = 'Chr%s: %.6f' % (this_trait.chr,
- float(this_trait.mb))
- this_trait.location_value = trait_location_value
+ this_trait.location_repr = 'Chr%s: %.6f' % (this_trait.chr, float(this_trait.mb))
#Get mean expression value
query = (
@@ -1076,9 +981,7 @@ class MrnaAssayDataSet(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:
@@ -1093,40 +996,10 @@ class MrnaAssayDataSet(DataSet):
if result:
lrs_chr, lrs_mb = result
- #XZ: LRS_location_value is used for sorting
- lrs_location_value = self.convert_location_to_value(lrs_chr, lrs_mb)
this_trait.LRS_score_repr = '%3.1f' % this_trait.lrs
- this_trait.LRS_score_value = this_trait.lrs
this_trait.LRS_location_repr = 'Chr%s: %.6f' % (lrs_chr, float(lrs_mb))
-
- def convert_location_to_value(self, chromosome, mb):
- try:
- location_value = int(chromosome)*1000 + float(mb)
- except ValueError:
- if chromosome.upper() == 'X':
- location_value = 20*1000 + float(mb)
- else:
- location_value = (ord(str(chromosome).upper()[0])*1000 +
- float(mb))
-
- return location_value
-
- 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))
- logger.sql(query)
- results = g.db.execute(query).fetchone()
- return results[0]
+ return trait_list
def retrieve_sample_data(self, trait):
query = """
@@ -1150,7 +1023,6 @@ class MrnaAssayDataSet(DataSet):
#logger.debug("RETRIEVED RESULTS HERE:", results)
return results
-
def retrieve_genes(self, column_name):
query = """
select ProbeSet.Name, ProbeSet.%s
@@ -1204,19 +1076,6 @@ class TempDataSet(DataSet):
desc = self.handle_pca(desc)
return desc
- def get_group(self):
- query = """
- SELECT
- InbredSet.Name, InbredSet.Id
- FROM
- InbredSet, Temp
- WHERE
- Temp.InbredSetId = InbredSet.Id AND
- Temp.Name = "%s"
- """ % self.name
- logger.sql(query)
- self.group, self.group_id = g.db.execute(query).fetchone()
-
def retrieve_sample_data(self, trait):
query = """
SELECT
diff --git a/wqflask/base/mrna_assay_tissue_data.py b/wqflask/base/mrna_assay_tissue_data.py
index eb836e6c..53f7c16a 100644
--- a/wqflask/base/mrna_assay_tissue_data.py
+++ b/wqflask/base/mrna_assay_tissue_data.py
@@ -18,7 +18,6 @@ class MrnaAssayTissueData(object):
def __init__(self, gene_symbols=None):
self.gene_symbols = gene_symbols
- self.have_data = False
if self.gene_symbols == None:
self.gene_symbols = []
diff --git a/wqflask/base/species.py b/wqflask/base/species.py
index ce763fc3..4ac2213c 100644
--- a/wqflask/base/species.py
+++ b/wqflask/base/species.py
@@ -18,19 +18,6 @@ class TheSpecies(object):
self.dataset = dataset
#print("self.dataset is:", pf(self.dataset.__dict__))
self.chromosomes = Chromosomes(self.dataset)
- self.genome_mb_length = self.chromosomes.get_genome_mb_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))
- #
- # print("chromosomes is: ", pf(chromosomes))
- #
- # return chromosomes
class IndChromosome(object):
def __init__(self, name, length):
@@ -42,16 +29,11 @@ class IndChromosome(object):
"""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, dataset):
self.dataset = dataset
self.chromosomes = collections.OrderedDict()
-
query = """
Select
Chr_Length.Name, Chr_Length.OrderId, Length from Chr_Length, InbredSet
@@ -64,64 +46,4 @@ class Chromosomes(object):
results = g.db.execute(query).fetchall()
for item in results:
- self.chromosomes[item.OrderId] = IndChromosome(item.Name, item.Length)
-
- self.set_mb_graph_interval()
- #self.get_cm_length_list()
-
-
- def set_mb_graph_interval(self):
- """Empirical megabase interval"""
-
- if self.chromosomes:
- self.mb_graph_interval = self.get_genome_mb_length()/(len(self.chromosomes)*12)
- else:
- self.mb_graph_interval = 1
-
- #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
-
-
- def get_genome_mb_length(self):
- """Gets the sum of each chromosome's length in megabases"""
-
- return sum([ind_chromosome.mb_length for ind_chromosome in self.chromosomes.values()])
-
-
- def get_genome_cm_length(self):
- """Gets the sum of each chromosome's length in centimorgans"""
-
- return sum([ind_chromosome.cm_length for ind_chromosome in self.chromosomes.values()])
-
- 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))))
-
-
-# Testing
-#if __name__ == '__main__':
-# foo = dict(bar=dict(length))
+ self.chromosomes[item.OrderId] = IndChromosome(item.Name, item.Length) \ No newline at end of file
diff --git a/wqflask/base/template.py b/wqflask/base/template.py
deleted file mode 100644
index aa8f90dc..00000000
--- a/wqflask/base/template.py
+++ /dev/null
@@ -1,123 +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
-
-template = """
-<?XML VERSION="1.0" ENCODING="UTF-8">
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<HTML>
-<HEAD>
-<TITLE>%s</TITLE>
-
-<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
-<META NAME="keywords" CONTENT="genetics, bioinformatics, genome, phenome, gene expression, complex trait analysis, gene mapping, SNP, quantitative trait locus QTL, expression eQTL, WebQTL, Traitnet, Traitnetwork, personalized medicine">
-<META NAME="description" CONTENT ="GeneNetwork is a free scientific web resource used to study relationships between differences in genes, environmental factors, phenotypes, and disease risk." >
-<META NAME="author" CONTENT ="GeneNetwork developers" >
-<META NAME="geo.placename" CONTENT ="Memphis, TN" >
-<META NAME="geo.region" CONTENT="US-TN">
-%s
-<LINK REL="stylesheet" TYPE="text/css" HREF='/css/general.css'>
-<LINK REL="stylesheet" TYPE="text/css" HREF='/css/menu.css'>
-<link rel="stylesheet" media="all" type="text/css" href="/css/tabbed_pages.css" />
-<LINK REL="apple-touch-icon" href="/images/ipad_icon3.png" />
-<link type="text/css" href='/css/custom-theme/jquery-ui-1.8.12.custom.css' rel='Stylesheet' />
-<link type="text/css" href='/css/tab_style.css' rel='Stylesheet' />
-
-<script type="text/javascript" src="/javascript/jquery-1.5.2.min.js"></script>
-<SCRIPT SRC="/javascript/webqtl.js"></SCRIPT>
-<SCRIPT SRC="/javascript/dhtml.js"></SCRIPT>
-<SCRIPT SRC="/javascript/tablesorter.js"></SCRIPT>
-<SCRIPT SRC="/javascript/jqueryFunction.js"></SCRIPT>
-<script src="/javascript/tabbed_pages.js" type="text/javascript"></script>
-<script src="/javascript/jquery-ui-1.8.12.custom.min.js" type="text/javascript"></script>
-%s
-
-<script type="text/javascript">
- var _gaq = _gaq || [];
- _gaq.push(['_setAccount', 'UA-3782271-1']);
- _gaq.push(['_trackPageview']);
- (function() {
- var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
- ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
- var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
- })();
-</script>
-</HEAD>
-<BODY bottommargin="2" leftmargin="2" rightmargin="2" topmargin="2" text=#000000 bgColor=#ffffff %s>
-%s
-<TABLE cellSpacing=5 cellPadding=4 width="100%%" border=0>
- <TBODY>
- <!-- Start of header -->
- <TR>
- %s
- </TR>
- <!-- End of header -->
-
- <!-- Start of body -->
- <TR>
- <TD bgColor=#eeeeee class="solidBorder">
- <Table width= "100%%" cellSpacing=0 cellPadding=5>
- <TR>
- %s
- </TR>
- </TABLE>
- </TD>
- </TR>
- <!-- End of body -->
-
- <!-- Start of footer -->
- <TR>
- <TD align=center bgColor=#ddddff class="solidBorder">
- <TABLE width="90%%">%s</table>
- </td>
- </TR>
- <!-- End of footer -->
-</TABLE>
-
-<!-- menu script itself. you should not modify this file -->
-<script language="JavaScript" src="/javascript/menu_new.js"></script>
-<!-- items structure. menu hierarchy and links are stored there -->
-<script language="JavaScript" src="/javascript/menu_items.js"></script>
-<!-- files with geometry and styles structures -->
-<script language="JavaScript" src="/javascript/menu_tpl.js"></script>
-<script language="JavaScript">
- <!--//
- // Note where menu initialization block is located in HTML document.
- // Don't try to position menu locating menu initialization block in
- // some table cell or other HTML element. Always put it before </body>
- // each menu gets two parameters (see demo files)
- // 1. items structure
- // 2. geometry structure
- new menu (MENU_ITEMS, MENU_POS);
- // make sure files containing definitions for these variables are linked to the document
- // if you got some javascript error like "MENU_POS is not defined", then you've made syntax
- // error in menu_tpl.js file or that file isn't linked properly.
-
- // also take a look at stylesheets loaded in header in order to set styles
- //-->
-</script>
-</BODY>
-</HTML>
-"""
diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py
index acc055d8..b71dacf6 100644
--- a/wqflask/base/trait.py
+++ b/wqflask/base/trait.py
@@ -25,10 +25,6 @@ logger = getLogger(__name__ )
from wqflask import user_manager
-def print_mem(stage=""):
- mem = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
- print("{}: {}".format(stage, mem/1024))
-
class GeneralTrait(object):
"""
Trait class defines a trait in webqtl, can be either Microarray,
@@ -63,9 +59,7 @@ class GeneralTrait(object):
self.symbol = None
self.LRS_score_repr = "N/A"
- self.LRS_score_value = 0
self.LRS_location_repr = "N/A"
- self.LRS_location_value = 1000000
if kw.get('fullname'):
name2 = value.split("::")
@@ -82,90 +76,6 @@ class GeneralTrait(object):
if get_sample_info != False:
self = retrieve_sample_data(self, self.dataset)
-
- 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, include_variance=0):
"""
export informative sample
@@ -185,19 +95,6 @@ class GeneralTrait(object):
sample_aliases.append(sample_data.name2)
return samples, vals, the_vars, sample_aliases
-
- @property
- def name_header_fmt(self):
- '''Return a human-readable name for use in page header'''
- if self.dataset.type == 'ProbeSet':
- return self.symbol
- elif self.dataset.type == 'Geno':
- return self.name
- elif self.dataset.type == 'Publish':
- return self.post_publication_abbreviation
- else:
- return "unnamed"
-
@property
def description_fmt(self):
'''Return a text formated description'''
@@ -252,29 +149,6 @@ class GeneralTrait(object):
fmt += (' on the minus strand ')
return fmt
-
-# In ProbeSet, there are maybe several annotations match one sequence
-# so we need use sequence(BlatSeq) as the identification, when we update
-# one annotation, we update the others who match the sequence also.
-#
-# Hongqiang Li, 3/3/2008
-def getSequence(trait, dataset_name):
- dataset = create_dataset(dataset_name)
-
- if dataset.type == 'ProbeSet':
- results = g.db.execute('''
- SELECT
- ProbeSet.BlatSeq
- FROM
- ProbeSet, ProbeSetFreeze, ProbeSetXRef
- WHERE
- ProbeSet.Id=ProbeSetXRef.ProbeSetId and
- ProbeSetFreeze.Id = ProbeSetXRef.ProbSetFreezeId and
- ProbeSet.Name = %s
- ProbeSetFreeze.Name = %s
- ''', trait.name, dataset.name).fetchone()
-
- return results[0]
def retrieve_sample_data(trait, dataset, samplelist=None):
if samplelist == None:
@@ -293,18 +167,6 @@ def retrieve_sample_data(trait, dataset, samplelist=None):
if not samplelist or (samplelist and name in samplelist):
trait.data[name] = webqtlCaseData(*item) #name, value, variance, num_cases)
return trait
-
-def convert_location_to_value(chromosome, mb):
- try:
- location_value = int(chromosome)*1000 + float(mb)
- except ValueError:
- if chromosome.upper() == 'X':
- location_value = 20*1000 + float(mb)
- else:
- location_value = (ord(str(chromosome).upper()[0])*1000 +
- float(mb))
-
- return location_value
@app.route("/trait/get_sample_data")
def get_sample_data():
@@ -542,38 +404,7 @@ def retrieve_trait_info(trait, dataset, get_qtl_info=False):
if trait.pubmed_id:
trait.pubmed_link = webqtlConfig.PUBMEDLINK_URL % trait.pubmed_id
-
- trait.homologeneid = None
if dataset.type == 'ProbeSet' and dataset.group:
- if trait.geneid:
- #XZ, 05/26/2010: From time to time, this query get error message because some geneid values in database are not number.
- #XZ: So I have to test if geneid is number before execute the query.
- #XZ: The geneid values in database should be cleaned up.
- #try:
- # float(self.geneid)
- # geneidIsNumber = True
- #except ValueError:
- # geneidIsNumber = False
- #if geneidIsNumber:
- query = """
- SELECT
- HomologeneId
- FROM
- Homologene, Species, InbredSet
- WHERE
- Homologene.GeneId ='%s' AND
- InbredSet.Name = '%s' AND
- InbredSet.SpeciesId = Species.Id AND
- Species.TaxonomyId = Homologene.TaxonomyId
- """ % (escape(str(trait.geneid)), escape(dataset.group.name))
- logger.sql(query)
- result = g.db.execute(query).fetchone()
- #else:
- # result = None
-
- if result:
- trait.homologeneid = result[0]
-
description_string = unicode(str(trait.description).strip(codecs.BOM_UTF8), 'utf-8')
target_string = unicode(str(trait.probe_target_description).strip(codecs.BOM_UTF8), 'utf-8')
@@ -589,46 +420,19 @@ def retrieve_trait_info(trait, dataset, get_qtl_info=False):
# Save it for the jinja2 template
trait.description_display = description_display
- #XZ: trait_location_value is used for sorting
trait.location_repr = 'N/A'
- trait.location_value = 1000000
-
if trait.chr and trait.mb:
- #Checks if the chromosome number can be cast to an int (i.e. isn't "X" or "Y")
- #This is so we can convert the location to a number used for sorting
- trait_location_value = convert_location_to_value(trait.chr, trait.mb)
- #try:
- # trait_location_value = int(self.chr)*1000 + self.mb
- #except ValueError:
- # if self.chr.upper() == 'X':
- # trait_location_value = 20*1000 + self.mb
- # else:
- # trait_location_value = (ord(str(self.chr).upper()[0])*1000 +
- # self.mb)
-
- #ZS: Put this in function currently called "convert_location_to_value"
trait.location_repr = 'Chr%s: %.6f' % (trait.chr, float(trait.mb))
- trait.location_value = trait_location_value
elif dataset.type == "Geno":
trait.location_repr = 'N/A'
- trait.location_value = 1000000
-
if trait.chr and trait.mb:
- #Checks if the chromosome number can be cast to an int (i.e. isn't "X" or "Y")
- #This is so we can convert the location to a number used for sorting
- trait_location_value = convert_location_to_value(trait.chr, trait.mb)
-
- #ZS: Put this in function currently called "convert_location_to_value"
trait.location_repr = 'Chr%s: %.6f' % (trait.chr, float(trait.mb))
- trait.location_value = trait_location_value
if get_qtl_info:
#LRS and its location
trait.LRS_score_repr = "N/A"
- trait.LRS_score_value = 0
trait.LRS_location_repr = "N/A"
- trait.LRS_location_value = 1000000
if dataset.type == 'ProbeSet' and not trait.cellid:
query = """
SELECT
@@ -699,19 +503,9 @@ def retrieve_trait_info(trait, dataset, get_qtl_info=False):
trait.locus = trait.lrs = trait.additive = ""
if (dataset.type == 'Publish' or dataset.type == "ProbeSet") and trait.locus_chr != "" and trait.locus_mb != "":
- #XZ: LRS_location_value is used for sorting
- try:
- LRS_location_value = int(trait.locus_chr)*1000 + float(trait.locus_mb)
- except:
- if trait.locus_chr.upper() == 'X':
- LRS_location_value = 20*1000 + float(trait.locus_mb)
- else:
- LRS_location_value = ord(str(trait.locus_chr).upper()[0])*1000 + float(trait.locus_mb)
-
trait.LRS_location_repr = LRS_location_repr = 'Chr%s: %.6f' % (trait.locus_chr, float(trait.locus_mb))
if trait.lrs != "":
trait.LRS_score_repr = LRS_score_repr = '%3.1f' % trait.lrs
- trait.LRS_score_value = LRS_score_value = trait.lrs
else:
raise KeyError, `trait.name`+' information is not found in the database.'