aboutsummaryrefslogtreecommitdiff
path: root/wqflask/base/trait.py
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask/base/trait.py')
-rw-r--r--wqflask/base/trait.py33
1 files changed, 13 insertions, 20 deletions
diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py
index 7666348e..6950cf11 100644
--- a/wqflask/base/trait.py
+++ b/wqflask/base/trait.py
@@ -1,12 +1,9 @@
-from __future__ import absolute_import, division, print_function
-
import os
import string
import resource
import codecs
import requests
import random
-import urllib
from base import webqtlConfig
from base.webqtlCaseData import webqtlCaseData
@@ -22,7 +19,7 @@ Redis = get_redis_conn()
from wqflask import app
import simplejson as json
-from MySQLdb import escape_string as escape
+from utility.db_tools import escape
from pprint import pformat as pf
from flask import Flask, g, request, url_for, redirect, make_response, render_template
@@ -118,7 +115,7 @@ class GeneralTrait(object):
vals = []
the_vars = []
sample_aliases = []
- for sample_name, sample_data in self.data.items():
+ for sample_name, sample_data in list(self.data.items()):
if sample_data.value != None:
if not include_variance or sample_data.variance != None:
samples.append(sample_name)
@@ -153,8 +150,8 @@ class GeneralTrait(object):
alias = 'Not available'
if getattr(self, "alias", None):
- alias = string.replace(self.alias, ";", " ")
- alias = string.join(string.split(alias), ", ")
+ alias = self.alias.replace(";", " ")
+ alias = ", ".join(alias.split())
return alias
@@ -193,7 +190,7 @@ class GeneralTrait(object):
'''
if self.chr and self.mb:
- self.location = 'Chr %s @ %s Mb' % (self.chr,self.mb)
+ self.location = 'Chr %s @ %s Mb' % (self.chr, self.mb)
elif self.chr:
self.location = 'Chr %s @ Unknown position' % (self.chr)
else:
@@ -260,7 +257,7 @@ def get_sample_data():
trait_dict['pubmed_link'] = trait_ob.pubmed_link
trait_dict['pubmed_text'] = trait_ob.pubmed_text
- return json.dumps([trait_dict, {key: value.value for key, value in trait_ob.data.iteritems() }])
+ return json.dumps([trait_dict, {key: value.value for key, value in list(trait_ob.data.items()) }])
else:
return None
@@ -440,7 +437,7 @@ def retrieve_trait_info(trait, dataset, get_qtl_info=False):
#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 dataset.type == 'Geno':
- display_fields_string = string.join(dataset.display_fields,',Geno.')
+ display_fields_string = ',Geno.'.join(dataset.display_fields)
display_fields_string = 'Geno.' + display_fields_string
query = """
SELECT %s
@@ -459,8 +456,8 @@ def retrieve_trait_info(trait, dataset, get_qtl_info=False):
query = """SELECT %s FROM %s WHERE Name = %s"""
logger.sql(query)
trait_info = g.db.execute(query,
- (string.join(dataset.display_fields,','),
- dataset.type, trait.name)).fetchone()
+ ','.join(dataset.display_fields),
+ dataset.type, trait.name).fetchone()
if trait_info:
trait.haveinfo = True
@@ -491,10 +488,6 @@ def retrieve_trait_info(trait, dataset, get_qtl_info=False):
else:
trait.description_display = ""
- trait.abbreviation = unicode(str(trait.abbreviation).strip(codecs.BOM_UTF8), 'utf-8', errors="replace")
- trait.description_display = unicode(str(trait.description_display).strip(codecs.BOM_UTF8), 'utf-8', errors="replace")
- trait.authors = unicode(str(trait.authors).strip(codecs.BOM_UTF8), 'utf-8', errors="replace")
-
if not trait.year.isdigit():
trait.pubmed_text = "N/A"
else:
@@ -504,8 +497,8 @@ def retrieve_trait_info(trait, dataset, get_qtl_info=False):
trait.pubmed_link = webqtlConfig.PUBMEDLINK_URL % trait.pubmed_id
if dataset.type == 'ProbeSet' and dataset.group:
- 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')
+ description_string = trait.description
+ target_string = trait.probe_target_description
if len(description_string) > 1 and description_string != 'None':
description_display = description_string
@@ -605,6 +598,6 @@ def retrieve_trait_info(trait, dataset, get_qtl_info=False):
if trait.lrs != "":
trait.LRS_score_repr = LRS_score_repr = '%3.1f' % trait.lrs
else:
- raise KeyError, `trait.name`+' information is not found in the database.'
+ raise KeyError(repr(trait.name)+' information is not found in the database.')
- return trait \ No newline at end of file
+ return trait