aboutsummaryrefslogtreecommitdiff
path: root/wqflask/base
diff options
context:
space:
mode:
authorAlexander Kabui2021-04-20 01:38:26 +0300
committerAlexander Kabui2021-04-20 01:38:26 +0300
commit34e4933de5a1cd444abe618fcfd93b424bf3442e (patch)
treea623ba0663e71d86447b660948401ee16989433e /wqflask/base
parent50c0ee93a59eecd40a6fbd19139671c94003c21b (diff)
downloadgenenetwork2-34e4933de5a1cd444abe618fcfd93b424bf3442e.tar.gz
refactor code for iterating mrna tissue data
Diffstat (limited to 'wqflask/base')
-rw-r--r--wqflask/base/mrna_assay_tissue_data.py39
1 files changed, 34 insertions, 5 deletions
diff --git a/wqflask/base/mrna_assay_tissue_data.py b/wqflask/base/mrna_assay_tissue_data.py
index f1929518..0220d73b 100644
--- a/wqflask/base/mrna_assay_tissue_data.py
+++ b/wqflask/base/mrna_assay_tissue_data.py
@@ -6,6 +6,7 @@ from utility import db_tools
from utility import Bunch
from utility.db_tools import escape
+from gn3.db_utils import database_connector
from utility.logger import getLogger
@@ -44,16 +45,42 @@ class MrnaAssayTissueData(object):
and t.Mean = x.maxmean;
'''.format(in_clause)
- results = g.db.execute(query).fetchall()
- lower_symbols = []
+ # lower_symbols = []
+ lower_symbols = {}
for gene_symbol in gene_symbols:
+ # lower_symbols[gene_symbol.lower()] = True
if gene_symbol != None:
- lower_symbols.append(gene_symbol.lower())
-
+ lower_symbols[gene_symbol.lower()] = True
+
+ import time
+ # initial_time = time.time()
+ # conn,cursor = database_connector()
+ # cursor.execute(query)
+ # for result in cursor.fetchall():
+ # symbol = result[0]
+ # self.data[symbol].gene_id = result[1]
+ # self.data[symbol].data_id = result[2]
+ # self.data[symbol].chr = result[3]
+ # self.data[symbol].mb = result[4]
+ # self.data[symbol].description = result[5]
+ # self.data[symbol].probe_target_description = result[6]
+
+
+ # print("my loop takes>>>>",time.time()-initial_time)
+ # conn.close()
+ # r
+
+ # takes 5 seconds
+ initial_time = time.time()
+ results = list(g.db.execute(query).fetchall())
for result in results:
symbol = result[0]
- if symbol.lower() in lower_symbols:
+ # if symbol is not None
+ # exists = lower_symbols.get(symbol.lower())
+ # if symbol.lower() in lower_symbols:
+ if symbol is not None and lower_symbols.get(symbol.lower()):
+
symbol = symbol.lower()
self.data[symbol].gene_id = result.GeneId
@@ -62,6 +89,7 @@ class MrnaAssayTissueData(object):
self.data[symbol].mb = result.Mb
self.data[symbol].description = result.description
self.data[symbol].probe_target_description = result.Probe_Target_Description
+ print("time taken in the loop is",time.time()-initial_time)
###########################################################################
#Input: cursor, symbolList (list), dataIdDict(Dict)
@@ -82,6 +110,7 @@ class MrnaAssayTissueData(object):
WHERE TissueProbeSetData.Id IN {} and
TissueProbeSetXRef.DataId = TissueProbeSetData.Id""".format(db_tools.create_in_clause(id_list))
+
results = g.db.execute(query).fetchall()
for result in results:
if result.Symbol.lower() not in symbol_values_dict: