aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorBonfaceKilz2020-08-19 02:31:31 +0300
committerBonfaceKilz2020-08-19 02:34:42 +0300
commitba123e1e0fe693f9778993c3f8e5a70a28658a4c (patch)
tree6d02bac212da1bfeeb8330b94971383cde053602 /wqflask
parentbafbb5b7a4b7db2ca230f292eb45be7e67985259 (diff)
downloadgenenetwork2-ba123e1e0fe693f9778993c3f8e5a70a28658a4c.tar.gz
Fix dictionary iteration methods
Run `2to3-3.8 -f dict -w .` See: <https://docs.python.org/2/library/2to3.html#2to3fixer-dict> and <https://stackoverflow.com/questions/17695456/why-does-python-3-need-dict-items-to-be-wrapped-with-list>
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/base/GeneralObject.py8
-rw-r--r--wqflask/base/trait.py4
-rw-r--r--wqflask/maintenance/gen_select_dataset.py6
-rw-r--r--wqflask/maintenance/generate_probesetfreeze_file.py2
-rw-r--r--wqflask/utility/__init__.py4
-rw-r--r--wqflask/utility/benchmark.py4
-rw-r--r--wqflask/utility/gen_geno_ob.py2
-rw-r--r--wqflask/utility/helper_functions.py2
-rw-r--r--wqflask/utility/svg.py14
-rw-r--r--wqflask/utility/temp_data.py2
-rw-r--r--wqflask/utility/tools.py2
-rw-r--r--wqflask/wqflask/api/correlation.py16
-rw-r--r--wqflask/wqflask/api/gen_menu.py6
-rw-r--r--wqflask/wqflask/correlation/corr_scatter_plot.py6
-rw-r--r--wqflask/wqflask/correlation/show_corr_results.py30
-rw-r--r--wqflask/wqflask/ctl/ctl_analysis.py2
-rw-r--r--wqflask/wqflask/export_traits.py4
-rw-r--r--wqflask/wqflask/heatmap/heatmap.py4
-rw-r--r--wqflask/wqflask/interval_analyst/GeneUtil.py2
-rw-r--r--wqflask/wqflask/marker_regression/display_mapping_results.py38
-rw-r--r--wqflask/wqflask/marker_regression/run_mapping.py24
-rw-r--r--wqflask/wqflask/resource_manager.py2
-rw-r--r--wqflask/wqflask/show_trait/export_trait_data.py2
-rw-r--r--wqflask/wqflask/show_trait/show_trait.py8
-rw-r--r--wqflask/wqflask/views.py6
25 files changed, 100 insertions, 100 deletions
diff --git a/wqflask/base/GeneralObject.py b/wqflask/base/GeneralObject.py
index 0fccaab3..707569db 100644
--- a/wqflask/base/GeneralObject.py
+++ b/wqflask/base/GeneralObject.py
@@ -33,7 +33,7 @@ class GeneralObject:
def __init__(self, *args, **kw):
self.contents = list(args)
- for name, value in kw.items():
+ for name, value in list(kw.items()):
setattr(self, name, value)
def __setitem__(self, key, value):
@@ -50,16 +50,16 @@ class GeneralObject:
def __str__(self):
s = ''
- for key in self.__dict__.keys():
+ for key in list(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():
+ for key in list(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()))
+ return len(list(self.__dict__.keys())).__cmp__(len(list(other.__dict__.keys())))
diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py
index 7666348e..e82df226 100644
--- a/wqflask/base/trait.py
+++ b/wqflask/base/trait.py
@@ -118,7 +118,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)
@@ -260,7 +260,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
diff --git a/wqflask/maintenance/gen_select_dataset.py b/wqflask/maintenance/gen_select_dataset.py
index 647e58a2..78217587 100644
--- a/wqflask/maintenance/gen_select_dataset.py
+++ b/wqflask/maintenance/gen_select_dataset.py
@@ -108,7 +108,7 @@ def get_types(groups):
"""Build types list"""
types = {}
#print("Groups: ", pf(groups))
- for species, group_dict in groups.iteritems():
+ for species, group_dict in list(groups.items()):
types[species] = {}
for group_name, _group_full_name in group_dict:
# make group an alias to shorten the code
@@ -195,9 +195,9 @@ def build_types(species, group):
def get_datasets(types):
"""Build datasets list"""
datasets = {}
- for species, group_dict in types.iteritems():
+ for species, group_dict in list(types.items()):
datasets[species] = {}
- for group, type_list in group_dict.iteritems():
+ for group, type_list in list(group_dict.items()):
datasets[species][group] = {}
for type_name in type_list:
these_datasets = build_datasets(species, group, type_name[0])
diff --git a/wqflask/maintenance/generate_probesetfreeze_file.py b/wqflask/maintenance/generate_probesetfreeze_file.py
index b7b2dc8e..4231cc7c 100644
--- a/wqflask/maintenance/generate_probesetfreeze_file.py
+++ b/wqflask/maintenance/generate_probesetfreeze_file.py
@@ -82,7 +82,7 @@ def get_probeset_vals(cursor, dataset_name):
def trim_strains(strains, probeset_vals):
trimmed_strains = []
#print("probeset_vals is:", pf(probeset_vals))
- first_probeset = list(probeset_vals.itervalues())[0]
+ first_probeset = list(probeset_vals.values())[0]
print("\n**** first_probeset is:", pf(first_probeset))
for strain in strains:
print("\n**** strain is:", pf(strain))
diff --git a/wqflask/utility/__init__.py b/wqflask/utility/__init__.py
index d9856eed..204ff59a 100644
--- a/wqflask/utility/__init__.py
+++ b/wqflask/utility/__init__.py
@@ -19,7 +19,7 @@ class Struct(object):
'''
def __init__(self, obj):
- for k, v in obj.iteritems():
+ for k, v in list(obj.items()):
if isinstance(v, dict):
setattr(self, k, Struct(v))
else:
@@ -30,6 +30,6 @@ class Struct(object):
def __repr__(self):
return '{%s}' % str(', '.join('%s : %s' % (k, repr(v)) for
- (k, v) in self.__dict__.iteritems()))
+ (k, v) in list(self.__dict__.items())))
diff --git a/wqflask/utility/benchmark.py b/wqflask/utility/benchmark.py
index 8f1c916b..221e5151 100644
--- a/wqflask/utility/benchmark.py
+++ b/wqflask/utility/benchmark.py
@@ -38,9 +38,9 @@ class Bench(object):
@classmethod
def report(cls):
- total_time = sum((time_taken for time_taken in cls.entries.itervalues()))
+ total_time = sum((time_taken for time_taken in list(cls.entries.values())))
print("\nTiming report\n")
- for name, time_taken in cls.entries.iteritems():
+ for name, time_taken in list(cls.entries.items()):
percent = int(round((time_taken/total_time) * 100))
print("[{}%] {}: {}".format(percent, name, time_taken))
print()
diff --git a/wqflask/utility/gen_geno_ob.py b/wqflask/utility/gen_geno_ob.py
index 23b0b650..ae42f834 100644
--- a/wqflask/utility/gen_geno_ob.py
+++ b/wqflask/utility/gen_geno_ob.py
@@ -175,7 +175,7 @@ class Locus(object):
start_pos = 3
for allele in marker_row[start_pos:]:
- if allele in geno_table.keys():
+ if allele in list(geno_table.keys()):
self.genotype.append(geno_table[allele])
else: #ZS: Some genotype appears that isn't specified in the metadata, make it unknown
self.genotype.append("U") \ No newline at end of file
diff --git a/wqflask/utility/helper_functions.py b/wqflask/utility/helper_functions.py
index 9ce809b6..9a4a235a 100644
--- a/wqflask/utility/helper_functions.py
+++ b/wqflask/utility/helper_functions.py
@@ -13,7 +13,7 @@ logger = logging.getLogger(__name__ )
def get_species_dataset_trait(self, start_vars):
#assert type(read_genotype) == type(bool()), "Expecting boolean value for read_genotype"
- if "temp_trait" in start_vars.keys():
+ if "temp_trait" in list(start_vars.keys()):
if start_vars['temp_trait'] == "True":
self.dataset = data_set.create_dataset(dataset_name = "Temp", dataset_type = "Temp", group_name = start_vars['group'])
else:
diff --git a/wqflask/utility/svg.py b/wqflask/utility/svg.py
index d66c954e..c6a5c260 100644
--- a/wqflask/utility/svg.py
+++ b/wqflask/utility/svg.py
@@ -133,7 +133,7 @@ def _escape(data, entities={}):
# data = data.replace("&", "&amp;")
data = data.replace("<", "&lt;")
data = data.replace(">", "&gt;")
- for chars, entity in entities.items():
+ for chars, entity in list(entities.items()):
data = data.replace(chars, entity)
return data
@@ -299,7 +299,7 @@ class SVGelement:
self.text = text
self.namespace = namespace
self.cdata = cdata
- for arg in args.keys():
+ for arg in list(args.keys()):
arg2 = arg.replace("__", ":")
arg2 = arg2.replace("_", "-")
self.attributes[arg2] = args[arg]
@@ -314,7 +314,7 @@ class SVGelement:
def toXml(self, level, f):
f.write('\t'*level)
f.write('<'+self.type)
- for attkey in self.attributes.keys():
+ for attkey in list(self.attributes.keys()):
f.write(' '+_escape(str(attkey))+'=' +
_quoteattr(str(self.attributes[attkey])))
if self.namespace:
@@ -365,7 +365,7 @@ class tspan(SVGelement):
def __repr__(self):
s = "<tspan"
- for key, value in self.attributes.items():
+ for key, value in list(self.attributes.items()):
s += ' %s="%s"' % (key, value)
s += '>'
s += self.text
@@ -390,7 +390,7 @@ class tref(SVGelement):
def __repr__(self):
s = "<tref"
- for key, value in self.attributes.items():
+ for key, value in list(self.attributes.items()):
s += ' %s="%s"' % (key, value)
s += '/>'
return s
@@ -963,7 +963,7 @@ class drawing:
xml.write("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.0//EN\" \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\"")
if self.entity:
xml.write(" [\n")
- for item in self.entity.keys():
+ for item in list(self.entity.keys()):
xml.write("<!ENTITY %s \"%s\">\n" % (item, self.entity[item]))
xml.write("]")
xml.write(">\n")
@@ -1015,7 +1015,7 @@ class drawing:
if element.text:
textnode=root.createTextNode(element.text)
e.appendChild(textnode)
- for attribute in element.attributes.keys(): #in element.attributes is supported from python 2.2
+ for attribute in list(element.attributes.keys()): #in element.attributes is supported from python 2.2
e.setAttribute(attribute,str(element.attributes[attribute]))
if element.elements:
for el in element.elements:
diff --git a/wqflask/utility/temp_data.py b/wqflask/utility/temp_data.py
index 5bf700c9..2f2726c6 100644
--- a/wqflask/utility/temp_data.py
+++ b/wqflask/utility/temp_data.py
@@ -20,6 +20,6 @@ class TempData(object):
if __name__ == "__main__":
redis = Redis()
- for key in redis.keys():
+ for key in list(redis.keys()):
for field in redis.hkeys(key):
print("{}.{}={}".format(key, field, redis.hget(key, field)))
diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py
index f790d424..51a87fe1 100644
--- a/wqflask/utility/tools.py
+++ b/wqflask/utility/tools.py
@@ -220,7 +220,7 @@ def show_settings():
logger.info(OVERRIDES)
logger.info(BLUE+"Mr. Mojo Risin 2"+ENDC)
- keylist = app.config.keys()
+ keylist = list(app.config.keys())
print("runserver.py: ****** Webserver configuration - k,v pairs from app.config ******")
keylist.sort()
for k in keylist:
diff --git a/wqflask/wqflask/api/correlation.py b/wqflask/wqflask/api/correlation.py
index 7f5312c1..eb05645e 100644
--- a/wqflask/wqflask/api/correlation.py
+++ b/wqflask/wqflask/api/correlation.py
@@ -36,7 +36,7 @@ def do_correlation(start_vars):
#corr_results = collections.OrderedDict(sorted(corr_results.items(), key=lambda t: -abs(t[1][0])))
final_results = []
- for _trait_counter, trait in enumerate(corr_results.keys()[:corr_params['return_count']]):
+ for _trait_counter, trait in enumerate(list(corr_results.keys())[:corr_params['return_count']]):
if corr_params['type'] == "tissue":
[sample_r, num_overlap, sample_p, symbol] = corr_results[trait]
result_dict = {
@@ -76,20 +76,20 @@ def calculate_results(this_trait, this_dataset, target_dataset, corr_params):
if corr_params['type'] == "tissue":
trait_symbol_dict = this_dataset.retrieve_genes("Symbol")
corr_results = do_tissue_correlation_for_all_traits(this_trait, trait_symbol_dict, corr_params)
- sorted_results = collections.OrderedDict(sorted(corr_results.items(),
+ sorted_results = collections.OrderedDict(sorted(list(corr_results.items()),
key=lambda t: -abs(t[1][1])))
elif corr_params['type'] == "literature" or corr_params['type'] == "lit": #ZS: Just so a user can use either "lit" or "literature"
trait_geneid_dict = this_dataset.retrieve_genes("GeneId")
corr_results = do_literature_correlation_for_all_traits(this_trait, this_dataset, trait_geneid_dict, corr_params)
- sorted_results = collections.OrderedDict(sorted(corr_results.items(),
+ sorted_results = collections.OrderedDict(sorted(list(corr_results.items()),
key=lambda t: -abs(t[1][1])))
else:
- for target_trait, target_vals in target_dataset.trait_data.iteritems():
+ for target_trait, target_vals in list(target_dataset.trait_data.items()):
result = get_sample_r_and_p_values(this_trait, this_dataset, target_vals, target_dataset, corr_params['type'])
if result is not None:
corr_results[target_trait] = result
- sorted_results = collections.OrderedDict(sorted(corr_results.items(), key=lambda t: -abs(t[1][0])))
+ sorted_results = collections.OrderedDict(sorted(list(corr_results.items()), key=lambda t: -abs(t[1][0])))
return sorted_results
@@ -100,10 +100,10 @@ def do_tissue_correlation_for_all_traits(this_trait, trait_symbol_dict, corr_par
if this_trait.symbol.lower() in primary_trait_tissue_vals_dict:
primary_trait_tissue_values = primary_trait_tissue_vals_dict[this_trait.symbol.lower()]
- corr_result_tissue_vals_dict = correlation_functions.get_trait_symbol_and_tissue_values(symbol_list=trait_symbol_dict.values())
+ corr_result_tissue_vals_dict = correlation_functions.get_trait_symbol_and_tissue_values(symbol_list=list(trait_symbol_dict.values()))
tissue_corr_data = {}
- for trait, symbol in trait_symbol_dict.iteritems():
+ for trait, symbol in list(trait_symbol_dict.items()):
if symbol and symbol.lower() in corr_result_tissue_vals_dict:
this_trait_tissue_values = corr_result_tissue_vals_dict[symbol.lower()]
@@ -119,7 +119,7 @@ def do_literature_correlation_for_all_traits(this_trait, target_dataset, trait_g
input_trait_mouse_gene_id = convert_to_mouse_gene_id(target_dataset.group.species.lower(), this_trait.geneid)
lit_corr_data = {}
- for trait, gene_id in trait_geneid_dict.iteritems():
+ for trait, gene_id in list(trait_geneid_dict.items()):
mouse_gene_id = convert_to_mouse_gene_id(target_dataset.group.species.lower(), gene_id)
if mouse_gene_id and str(mouse_gene_id).find(";") == -1:
diff --git a/wqflask/wqflask/api/gen_menu.py b/wqflask/wqflask/api/gen_menu.py
index cc11e14b..71d9ee03 100644
--- a/wqflask/wqflask/api/gen_menu.py
+++ b/wqflask/wqflask/api/gen_menu.py
@@ -61,7 +61,7 @@ def get_types(groups):
"""Build types list"""
types = {}
- for species, group_dict in groups.iteritems():
+ for species, group_dict in list(groups.items()):
types[species] = {}
for group_name, _group_full_name, _family_name in group_dict:
if phenotypes_exist(group_name):
@@ -136,9 +136,9 @@ def build_types(species, group):
def get_datasets(types):
"""Build datasets list"""
datasets = {}
- for species, group_dict in types.iteritems():
+ for species, group_dict in list(types.items()):
datasets[species] = {}
- for group, type_list in group_dict.iteritems():
+ for group, type_list in list(group_dict.items()):
datasets[species][group] = {}
for type_name in type_list:
these_datasets = build_datasets(species, group, type_name[0])
diff --git a/wqflask/wqflask/correlation/corr_scatter_plot.py b/wqflask/wqflask/correlation/corr_scatter_plot.py
index 819836b1..57a8d85f 100644
--- a/wqflask/wqflask/correlation/corr_scatter_plot.py
+++ b/wqflask/wqflask/correlation/corr_scatter_plot.py
@@ -36,13 +36,13 @@ class CorrScatterPlot(object):
samples_1, samples_2, num_overlap = corr_result_helpers.normalize_values_with_samples(self.trait_1.data, self.trait_2.data)
self.data = []
- self.indIDs = samples_1.keys()
+ self.indIDs = list(samples_1.keys())
vals_1 = []
- for sample in samples_1.keys():
+ for sample in list(samples_1.keys()):
vals_1.append(samples_1[sample].value)
self.data.append(vals_1)
vals_2 = []
- for sample in samples_2.keys():
+ for sample in list(samples_2.keys()):
vals_2.append(samples_2[sample].value)
self.data.append(vals_2)
diff --git a/wqflask/wqflask/correlation/show_corr_results.py b/wqflask/wqflask/correlation/show_corr_results.py
index de7a1c0c..15a21ee6 100644
--- a/wqflask/wqflask/correlation/show_corr_results.py
+++ b/wqflask/wqflask/correlation/show_corr_results.py
@@ -145,10 +145,10 @@ class CorrelationResults(object):
if corr_samples_group == 'samples_other':
primary_samples = [x for x in primary_samples if x not in (
self.dataset.group.parlist + self.dataset.group.f1list)]
- self.process_samples(start_vars, self.this_trait.data.keys(), primary_samples)
+ self.process_samples(start_vars, list(self.this_trait.data.keys()), primary_samples)
self.target_dataset = data_set.create_dataset(start_vars['corr_dataset'])
- self.target_dataset.get_trait_data(self.sample_data.keys())
+ self.target_dataset.get_trait_data(list(self.sample_data.keys()))
self.header_fields = get_header_fields(self.target_dataset.type, self.corr_method)
@@ -168,41 +168,41 @@ class CorrelationResults(object):
tissue_corr_data = self.do_tissue_correlation_for_all_traits()
if tissue_corr_data != None:
- for trait in tissue_corr_data.keys()[:self.return_number]:
+ for trait in list(tissue_corr_data.keys())[:self.return_number]:
self.get_sample_r_and_p_values(trait, self.target_dataset.trait_data[trait])
else:
- for trait, values in self.target_dataset.trait_data.iteritems():
+ for trait, values in list(self.target_dataset.trait_data.items()):
self.get_sample_r_and_p_values(trait, values)
elif self.corr_type == "lit":
self.trait_geneid_dict = self.dataset.retrieve_genes("GeneId")
lit_corr_data = self.do_lit_correlation_for_all_traits()
- for trait in lit_corr_data.keys()[:self.return_number]:
+ for trait in list(lit_corr_data.keys())[:self.return_number]:
self.get_sample_r_and_p_values(trait, self.target_dataset.trait_data[trait])
elif self.corr_type == "sample":
- for trait, values in self.target_dataset.trait_data.iteritems():
+ for trait, values in list(self.target_dataset.trait_data.items()):
self.get_sample_r_and_p_values(trait, values)
- self.correlation_data = collections.OrderedDict(sorted(self.correlation_data.items(),
+ self.correlation_data = collections.OrderedDict(sorted(list(self.correlation_data.items()),
key=lambda t: -abs(t[1][0])))
if self.target_dataset.type == "ProbeSet" or self.target_dataset.type == "Geno":
#ZS: Convert min/max chromosome to an int for the location range option
range_chr_as_int = None
- for order_id, chr_info in self.dataset.species.chromosomes.chromosomes.iteritems():
+ for order_id, chr_info in list(self.dataset.species.chromosomes.chromosomes.items()):
if 'loc_chr' in start_vars:
if chr_info.name == self.location_chr:
range_chr_as_int = order_id
- for _trait_counter, trait in enumerate(self.correlation_data.keys()[:self.return_number]):
+ for _trait_counter, trait in enumerate(list(self.correlation_data.keys())[:self.return_number]):
trait_object = create_trait(dataset=self.target_dataset, name=trait, get_qtl_info=True, get_sample_info=False)
if self.target_dataset.type == "ProbeSet" or self.target_dataset.type == "Geno":
#ZS: Convert trait chromosome to an int for the location range option
chr_as_int = 0
- for order_id, chr_info in self.dataset.species.chromosomes.chromosomes.iteritems():
+ for order_id, chr_info in list(self.dataset.species.chromosomes.chromosomes.items()):
if chr_info.name == trait_object.chr:
chr_as_int = order_id
@@ -297,14 +297,14 @@ class CorrelationResults(object):
#print("trait_gene_symbols: ", pf(trait_gene_symbols.values()))
corr_result_tissue_vals_dict= correlation_functions.get_trait_symbol_and_tissue_values(
- symbol_list=self.trait_symbol_dict.values())
+ symbol_list=list(self.trait_symbol_dict.values()))
#print("corr_result_tissue_vals: ", pf(corr_result_tissue_vals_dict))
#print("trait_gene_symbols: ", pf(trait_gene_symbols))
tissue_corr_data = {}
- for trait, symbol in self.trait_symbol_dict.iteritems():
+ for trait, symbol in list(self.trait_symbol_dict.items()):
if symbol and symbol.lower() in corr_result_tissue_vals_dict:
this_trait_tissue_values = corr_result_tissue_vals_dict[symbol.lower()]
@@ -314,7 +314,7 @@ class CorrelationResults(object):
tissue_corr_data[trait] = [symbol, result[0], result[2]]
- tissue_corr_data = collections.OrderedDict(sorted(tissue_corr_data.items(),
+ tissue_corr_data = collections.OrderedDict(sorted(list(tissue_corr_data.items()),
key=lambda t: -abs(t[1][1])))
return tissue_corr_data
@@ -359,7 +359,7 @@ class CorrelationResults(object):
input_trait_mouse_gene_id = self.convert_to_mouse_gene_id(self.dataset.group.species.lower(), self.this_trait.geneid)
lit_corr_data = {}
- for trait, gene_id in self.trait_geneid_dict.iteritems():
+ for trait, gene_id in list(self.trait_geneid_dict.items()):
mouse_gene_id = self.convert_to_mouse_gene_id(self.dataset.group.species.lower(), gene_id)
if mouse_gene_id and str(mouse_gene_id).find(";") == -1:
@@ -387,7 +387,7 @@ class CorrelationResults(object):
else:
lit_corr_data[trait] = [gene_id, 0]
- lit_corr_data = collections.OrderedDict(sorted(lit_corr_data.items(),
+ lit_corr_data = collections.OrderedDict(sorted(list(lit_corr_data.items()),
key=lambda t: -abs(t[1][1])))
return lit_corr_data
diff --git a/wqflask/wqflask/ctl/ctl_analysis.py b/wqflask/wqflask/ctl/ctl_analysis.py
index 35067036..f0be7a98 100644
--- a/wqflask/wqflask/ctl/ctl_analysis.py
+++ b/wqflask/wqflask/ctl/ctl_analysis.py
@@ -125,7 +125,7 @@ class CTL(object):
gt = create_trait(name = ts[0], dataset_name = ts[1])
gt = retrieve_sample_data(gt, dataset, individuals)
for ind in individuals:
- if ind in gt.data.keys():
+ if ind in list(gt.data.keys()):
traits.append(gt.data[ind].value)
else:
traits.append("-999")
diff --git a/wqflask/wqflask/export_traits.py b/wqflask/wqflask/export_traits.py
index 6646cc36..28c6593d 100644
--- a/wqflask/wqflask/export_traits.py
+++ b/wqflask/wqflask/export_traits.py
@@ -61,7 +61,7 @@ def export_search_results_csv(targs):
traits_by_group = sort_traits_by_group(trait_list)
file_list = []
- for group in traits_by_group.keys():
+ for group in list(traits_by_group.keys()):
group_traits = traits_by_group[group]
buff = StringIO.StringIO()
writer = csv.writer(buff)
@@ -135,7 +135,7 @@ def export_search_results_csv(targs):
def sort_traits_by_group(trait_list=[]):
traits_by_group = {}
for trait in trait_list:
- if trait.dataset.group.name not in traits_by_group.keys():
+ if trait.dataset.group.name not in list(traits_by_group.keys()):
traits_by_group[trait.dataset.group.name] = []
traits_by_group[trait.dataset.group.name].append(trait)
diff --git a/wqflask/wqflask/heatmap/heatmap.py b/wqflask/wqflask/heatmap/heatmap.py
index 5098a184..577426b0 100644
--- a/wqflask/wqflask/heatmap/heatmap.py
+++ b/wqflask/wqflask/heatmap/heatmap.py
@@ -60,7 +60,7 @@ class Heatmap(object):
chrnames = []
self.species = species.TheSpecies(dataset=self.trait_list[0][1])
- for key in self.species.chromosomes.chromosomes.keys():
+ for key in list(self.species.chromosomes.chromosomes.keys()):
chrnames.append([self.species.chromosomes.chromosomes[key].name, self.species.chromosomes.chromosomes[key].mb_length])
for trait_db in self.trait_list:
@@ -93,7 +93,7 @@ class Heatmap(object):
pos = []
markernames = []
- for trait in self.trait_results.keys():
+ for trait in list(self.trait_results.keys()):
lodnames.append(trait)
self.dataset.group.get_markers()
diff --git a/wqflask/wqflask/interval_analyst/GeneUtil.py b/wqflask/wqflask/interval_analyst/GeneUtil.py
index 273168a8..a39e5d0f 100644
--- a/wqflask/wqflask/interval_analyst/GeneUtil.py
+++ b/wqflask/wqflask/interval_analyst/GeneUtil.py
@@ -24,7 +24,7 @@ def loadGenes(chrName, diffCol, startMb, endMb, species='mouse'):
##List current Species and other Species
speciesId = speciesDict[species]
- otherSpecies = [[X, speciesDict[X]] for X in speciesDict.keys()]
+ otherSpecies = [[X, speciesDict[X]] for X in list(speciesDict.keys())]
otherSpecies.remove([species, speciesId])
results = g.db.execute("""
diff --git a/wqflask/wqflask/marker_regression/display_mapping_results.py b/wqflask/wqflask/marker_regression/display_mapping_results.py
index 7b6e70d2..0328ce85 100644
--- a/wqflask/wqflask/marker_regression/display_mapping_results.py
+++ b/wqflask/wqflask/marker_regression/display_mapping_results.py
@@ -229,7 +229,7 @@ class DisplayMappingResults(object):
self.manhattan_plot = start_vars['manhattan_plot']
- if 'permCheck' in start_vars.keys():
+ if 'permCheck' in list(start_vars.keys()):
self.permChecked = start_vars['permCheck']
else:
self.permChecked = False
@@ -242,46 +242,46 @@ class DisplayMappingResults(object):
else:
self.nperm = 0
- if 'bootCheck' in start_vars.keys():
+ if 'bootCheck' in list(start_vars.keys()):
self.bootChecked = start_vars['bootCheck']
else:
self.bootChecked = False
- if 'num_bootstrap' in start_vars.keys():
+ if 'num_bootstrap' in list(start_vars.keys()):
self.nboot = int(start_vars['num_bootstrap'])
else:
self.nboot = 0
- if 'bootstrap_results' in start_vars.keys():
+ if 'bootstrap_results' in list(start_vars.keys()):
self.bootResult = start_vars['bootstrap_results']
else:
self.bootResult = []
- if 'do_control' in start_vars.keys():
+ if 'do_control' in list(start_vars.keys()):
self.doControl = start_vars['do_control']
else:
self.doControl = "false"
- if 'control_marker' in start_vars.keys():
+ if 'control_marker' in list(start_vars.keys()):
self.controlLocus = start_vars['control_marker']
else:
self.controlLocus = ""
- if 'covariates' in start_vars.keys():
+ if 'covariates' in list(start_vars.keys()):
self.covariates = start_vars['covariates']
- if 'maf' in start_vars.keys():
+ if 'maf' in list(start_vars.keys()):
self.maf = start_vars['maf']
else:
self.maf = ""
- if 'output_files' in start_vars.keys():
+ if 'output_files' in list(start_vars.keys()):
self.output_files = start_vars['output_files']
- if 'use_loco' in start_vars.keys() and self.mapping_method == "gemma":
+ if 'use_loco' in list(start_vars.keys()) and self.mapping_method == "gemma":
self.use_loco = start_vars['use_loco']
- if 'reaper_version' in start_vars.keys() and self.mapping_method == "reaper":
+ if 'reaper_version' in list(start_vars.keys()) and self.mapping_method == "reaper":
self.reaper_version = start_vars['reaper_version']
if 'output_files' in start_vars:
self.output_files = ",".join(start_vars['output_files'])
self.categorical_vars = ""
self.perm_strata = ""
- if 'perm_strata' in start_vars.keys() and 'categorical_vars' in start_vars.keys():
+ if 'perm_strata' in list(start_vars.keys()) and 'categorical_vars' in list(start_vars.keys()):
self.categorical_vars = start_vars['categorical_vars']
self.perm_strata = start_vars['perm_strata']
@@ -323,7 +323,7 @@ class DisplayMappingResults(object):
self.graphWidth = self.MULT_GRAPH_DEFAULT_WIDTH
## BEGIN HaplotypeAnalyst
- if 'haplotypeAnalystCheck' in start_vars.keys():
+ if 'haplotypeAnalystCheck' in list(start_vars.keys()):
self.haplotypeAnalystChecked = start_vars['haplotypeAnalystCheck']
else:
self.haplotypeAnalystChecked = False
@@ -331,25 +331,25 @@ class DisplayMappingResults(object):
self.graphHeight = self.GRAPH_DEFAULT_HEIGHT
self.dominanceChecked = False
- if 'LRSCheck' in start_vars.keys():
+ if 'LRSCheck' in list(start_vars.keys()):
self.LRS_LOD = start_vars['LRSCheck']
else:
self.LRS_LOD = start_vars['score_type']
self.intervalAnalystChecked = True
self.draw2X = False
- if 'additiveCheck' in start_vars.keys():
+ if 'additiveCheck' in list(start_vars.keys()):
self.additiveChecked = start_vars['additiveCheck']
else:
self.additiveChecked = False
- if 'viewLegend' in start_vars.keys():
+ if 'viewLegend' in list(start_vars.keys()):
self.legendChecked = start_vars['viewLegend']
else:
self.legendChecked = False
- if 'showSNP' in start_vars.keys():
+ if 'showSNP' in list(start_vars.keys()):
self.SNPChecked = start_vars['showSNP']
else:
self.SNPChecked = False
- if 'showGenes' in start_vars.keys():
+ if 'showGenes' in list(start_vars.keys()):
self.geneChecked = start_vars['showGenes']
else:
self.geneChecked = False
@@ -530,7 +530,7 @@ class DisplayMappingResults(object):
showLocusForm = HT.Form(cgi= os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), enctype='multipart/form-data',
name=showLocusForm, submit=HT.Input(type='hidden'))
hddn = {'FormID':'showDatabase', 'ProbeSetID':'_','database':fd.RISet+"Geno",'CellID':'_', 'RISet':fd.RISet, 'incparentsf1':'ON'}
- for key in hddn.keys():
+ for key in list(hddn.keys()):
showLocusForm.append(HT.Input(name=key, value=hddn[key], type='hidden'))
showLocusForm.append(intImg)
else:
diff --git a/wqflask/wqflask/marker_regression/run_mapping.py b/wqflask/wqflask/marker_regression/run_mapping.py
index c9d10f7c..145dbc77 100644
--- a/wqflask/wqflask/marker_regression/run_mapping.py
+++ b/wqflask/wqflask/marker_regression/run_mapping.py
@@ -347,7 +347,7 @@ class RunMapping(object):
if marker['chr1'] > 0 or marker['chr1'] == "X" or marker['chr1'] == "X/Y":
if marker['chr1'] > highest_chr or marker['chr1'] == "X" or marker['chr1'] == "X/Y":
highest_chr = marker['chr1']
- if 'lod_score' in marker.keys():
+ if 'lod_score' in list(marker.keys()):
self.qtl_results.append(marker)
self.trimmed_markers = results
@@ -411,7 +411,7 @@ class RunMapping(object):
if marker['chr'] > 0 or marker['chr'] == "X" or marker['chr'] == "X/Y":
if marker['chr'] > highest_chr or marker['chr'] == "X" or marker['chr'] == "X/Y":
highest_chr = marker['chr']
- if ('lod_score' in marker.keys()) or ('lrs_value' in marker.keys()):
+ if ('lod_score' in list(marker.keys())) or ('lrs_value' in list(marker.keys())):
self.qtl_results.append(marker)
with Bench("Exporting Results"):
@@ -538,28 +538,28 @@ def export_mapping_results(dataset, trait, markers, results_path, mapping_scale,
output_file.write("Mb," + score_type)
else:
output_file.write("Cm," + score_type)
- if "additive" in markers[0].keys():
+ if "additive" in list(markers[0].keys()):
output_file.write(",Additive")
- if "dominance" in markers[0].keys():
+ if "dominance" in list(markers[0].keys()):
output_file.write(",Dominance")
output_file.write("\n")
for i, marker in enumerate(markers):
output_file.write(marker['name'] + "," + str(marker['chr']) + "," + str(marker['Mb']) + ",")
- if "lod_score" in marker.keys():
+ if "lod_score" in list(marker.keys()):
output_file.write(str(marker['lod_score']))
else:
output_file.write(str(marker['lrs_value']))
- if "additive" in marker.keys():
+ if "additive" in list(marker.keys()):
output_file.write("," + str(marker['additive']))
- if "dominance" in marker.keys():
+ if "dominance" in list(marker.keys()):
output_file.write("," + str(marker['dominance']))
if i < (len(markers) - 1):
output_file.write("\n")
def trim_markers_for_figure(markers):
- if 'p_wald' in markers[0].keys():
+ if 'p_wald' in list(markers[0].keys()):
score_type = 'p_wald'
- elif 'lod_score' in markers[0].keys():
+ elif 'lod_score' in list(markers[0].keys()):
score_type = 'lod_score'
else:
score_type = 'lrs_value'
@@ -617,7 +617,7 @@ def trim_markers_for_figure(markers):
return filtered_markers
def trim_markers_for_table(markers):
- if 'lod_score' in markers[0].keys():
+ if 'lod_score' in list(markers[0].keys()):
sorted_markers = sorted(markers, key=lambda k: k['lod_score'], reverse=True)
else:
sorted_markers = sorted(markers, key=lambda k: k['lrs_value'], reverse=True)
@@ -695,10 +695,10 @@ def get_genofile_samplelist(dataset):
def get_perm_strata(this_trait, sample_list, categorical_vars, used_samples):
perm_strata_strings = []
for sample in used_samples:
- if sample in sample_list.sample_attribute_values.keys():
+ if sample in list(sample_list.sample_attribute_values.keys()):
combined_string = ""
for var in categorical_vars:
- if var in sample_list.sample_attribute_values[sample].keys():
+ if var in list(sample_list.sample_attribute_values[sample].keys()):
combined_string += str(sample_list.sample_attribute_values[sample][var])
else:
combined_string += "NA"
diff --git a/wqflask/wqflask/resource_manager.py b/wqflask/wqflask/resource_manager.py
index 39a07310..6b3e00fb 100644
--- a/wqflask/wqflask/resource_manager.py
+++ b/wqflask/wqflask/resource_manager.py
@@ -125,7 +125,7 @@ def add_group_to_resource():
def get_group_names(group_masks):
group_masks_with_names = {}
- for group_id, group_mask in group_masks.iteritems():
+ for group_id, group_mask in list(group_masks.items()):
this_mask = group_mask
group_name = get_group_info(group_id)['name']
this_mask['name'] = group_name
diff --git a/wqflask/wqflask/show_trait/export_trait_data.py b/wqflask/wqflask/show_trait/export_trait_data.py
index 253c887b..68c3ad7d 100644
--- a/wqflask/wqflask/show_trait/export_trait_data.py
+++ b/wqflask/wqflask/show_trait/export_trait_data.py
@@ -47,7 +47,7 @@ def get_export_metadata(trait_id, dataset_name):
def dict_to_sorted_list(dictionary):
- sorted_list = [item for item in dictionary.iteritems()]
+ sorted_list = [item for item in list(dictionary.items())]
sorted_list = sorted(sorted_list, cmp=cmp_samples)
sorted_values = [item[1] for item in sorted_list]
return sorted_values
diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py
index f188fd9d..c156e61b 100644
--- a/wqflask/wqflask/show_trait/show_trait.py
+++ b/wqflask/wqflask/show_trait/show_trait.py
@@ -261,7 +261,7 @@ class ShowTrait(object):
hddn['export_data'] = ""
hddn['export_format'] = "excel"
if len(self.scales_in_geno) < 2:
- hddn['mapping_scale'] = self.scales_in_geno[self.scales_in_geno.keys()[0]][0][0]
+ hddn['mapping_scale'] = self.scales_in_geno[list(self.scales_in_geno.keys())[0]][0][0]
# We'll need access to this_trait and hddn in the Jinja2 Template, so we put it inside self
self.hddn = hddn
@@ -405,7 +405,7 @@ class ShowTrait(object):
if not self.temp_trait:
other_sample_names = []
- for sample in self.this_trait.data.keys():
+ for sample in list(self.this_trait.data.keys()):
if (self.this_trait.data[sample].name2 in primary_sample_names) and (self.this_trait.data[sample].name not in primary_sample_names):
primary_sample_names.append(self.this_trait.data[sample].name)
primary_sample_names.remove(self.this_trait.data[sample].name2)
@@ -558,7 +558,7 @@ def get_table_widths(sample_groups, has_num_cases=False):
def has_num_cases(this_trait):
has_n = False
if this_trait.dataset.type != "ProbeSet" and this_trait.dataset.type != "Geno":
- for name, sample in this_trait.data.iteritems():
+ for name, sample in list(this_trait.data.items()):
if sample.num_cases:
has_n = True
break
@@ -611,7 +611,7 @@ def get_categorical_variables(this_trait, sample_list):
if len(sample_list.attributes) > 0:
for attribute in sample_list.attributes:
attribute_vals = []
- for sample_name in this_trait.data.keys():
+ for sample_name in list(this_trait.data.keys()):
if sample_list.attributes[attribute].name in this_trait.data[sample_name].extra_attributes:
attribute_vals.append(this_trait.data[sample_name].extra_attributes[sample_list.attributes[attribute].name])
else:
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index d67f1a2e..394a9e28 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -533,7 +533,7 @@ def heatmap_page():
result = template_vars.__dict__
- for item in template_vars.__dict__.keys():
+ for item in list(template_vars.__dict__.keys()):
logger.info(" ---**--- {}: {}".format(type(template_vars.__dict__[item]), item))
pickled_result = pickle.dumps(result, pickle.HIGHEST_PROTOCOL)
@@ -637,7 +637,7 @@ def loading_page():
if 'wanted_inputs' in initial_start_vars:
wanted = initial_start_vars['wanted_inputs'].split(",")
start_vars = {}
- for key, value in initial_start_vars.iteritems():
+ for key, value in list(initial_start_vars.items()):
if key in wanted or key.startswith(('value:')):
start_vars[key] = value
@@ -737,7 +737,7 @@ def mapping_results_page():
'transform'
)
start_vars = {}
- for key, value in initial_start_vars.iteritems():
+ for key, value in list(initial_start_vars.items()):
if key in wanted or key.startswith(('value:')):
start_vars[key] = value
#logger.debug("Mapping called with start_vars:", start_vars)