aboutsummaryrefslogtreecommitdiff
path: root/wqflask/utility
diff options
context:
space:
mode:
authorzsloan2016-06-20 16:01:12 +0000
committerzsloan2016-06-20 16:01:12 +0000
commit30a37c6f1f9a9f759a92fd61876af9e9e3d078b9 (patch)
treee4f5b49aa21c32aa2b770b1a65c8fef7782b625f /wqflask/utility
parent4fec0e6fc0772785a30451d417082bc189f2f6dd (diff)
parent10df36b60273d81678f6630c07a2d8e5a6409282 (diff)
downloadgenenetwork2-30a37c6f1f9a9f759a92fd61876af9e9e3d078b9.tar.gz
Merge branch 'staging' of github.com:genenetwork/genenetwork2 into development
Diffstat (limited to 'wqflask/utility')
-rw-r--r--wqflask/utility/Plot.py8
-rwxr-xr-xwqflask/utility/benchmark.py8
-rw-r--r--wqflask/utility/chunks.py10
-rwxr-xr-xwqflask/utility/corr_result_helpers.py18
-rw-r--r--wqflask/utility/genofile_parser.py4
-rwxr-xr-xwqflask/utility/temp_data.py6
-rw-r--r--wqflask/utility/tools.py4
-rwxr-xr-xwqflask/utility/webqtlUtil.py8
8 files changed, 33 insertions, 33 deletions
diff --git a/wqflask/utility/Plot.py b/wqflask/utility/Plot.py
index 444c71c9..063de387 100644
--- a/wqflask/utility/Plot.py
+++ b/wqflask/utility/Plot.py
@@ -282,11 +282,11 @@ def gpercentile(lst2, np):
def find_outliers(vals):
"""Calculates the upper and lower bounds of a set of sample/case values
-
-
+
+
>>> find_outliers([3.504, 5.234, 6.123, 7.234, 3.542, 5.341, 7.852, 4.555, 12.537])
(11.252500000000001, 0.5364999999999993)
-
+
>>> >>> find_outliers([9,12,15,17,31,50,7,5,6,8])
(32.0, -8.0)
@@ -294,7 +294,7 @@ def find_outliers(vals):
which code that calls it will have to deal with.
>>> find_outliers([])
(None, None)
-
+
"""
print("xerxes vals is:", pf(vals))
diff --git a/wqflask/utility/benchmark.py b/wqflask/utility/benchmark.py
index 182187ae..d5b32703 100755
--- a/wqflask/utility/benchmark.py
+++ b/wqflask/utility/benchmark.py
@@ -7,7 +7,7 @@ import time
class Bench(object):
entries = collections.OrderedDict()
-
+
def __init__(self, name=None):
self.name = name
@@ -26,10 +26,10 @@ class Bench(object):
time_taken = time.time() - self.start_time
print(" %s took: %f seconds" % (name, (time_taken)))
-
+
if self.name:
Bench.entries[self.name] = Bench.entries.get(self.name, 0) + time_taken
-
+
@classmethod
def report(cls):
@@ -39,7 +39,7 @@ class Bench(object):
percent = int(round((time_taken/total_time) * 100))
print("[{}%] {}: {}".format(percent, name, time_taken))
print()
-
+
def reset(cls):
"""Reset the entries"""
cls.entries = collections.OrderedDict() \ No newline at end of file
diff --git a/wqflask/utility/chunks.py b/wqflask/utility/chunks.py
index 9565fb96..b0e33c08 100644
--- a/wqflask/utility/chunks.py
+++ b/wqflask/utility/chunks.py
@@ -6,21 +6,21 @@ import time
def divide_into_chunks(the_list, number_chunks):
"""Divides a list into approximately number_chunks smaller lists
-
+
>>> divide_into_chunks([1, 2, 7, 3, 22, 8, 5, 22, 333], 3)
[[1, 2, 7], [3, 22, 8], [5, 22, 333]]
- >>> divide_into_chunks([1, 2, 7, 3, 22, 8, 5, 22, 333], 4)
+ >>> divide_into_chunks([1, 2, 7, 3, 22, 8, 5, 22, 333], 4)
[[1, 2, 7], [3, 22, 8], [5, 22, 333]]
- >>> divide_into_chunks([1, 2, 7, 3, 22, 8, 5, 22, 333], 5)
+ >>> divide_into_chunks([1, 2, 7, 3, 22, 8, 5, 22, 333], 5)
[[1, 2], [7, 3], [22, 8], [5, 22], [333]]
>>>
-
+
"""
length = len(the_list)
if length == 0:
return [[]]
-
+
if length <= number_chunks:
number_chunks = length
diff --git a/wqflask/utility/corr_result_helpers.py b/wqflask/utility/corr_result_helpers.py
index a253026c..ef644d85 100755
--- a/wqflask/utility/corr_result_helpers.py
+++ b/wqflask/utility/corr_result_helpers.py
@@ -1,16 +1,16 @@
def normalize_values(a_values, b_values):
"""
Trim two lists of values to contain only the values they both share
-
+
Given two lists of sample values, trim each list so that it contains
only the samples that contain a value in both lists. Also returns
the number of such samples.
-
+
>>> normalize_values([2.3, None, None, 3.2, 4.1, 5], [3.4, 7.2, 1.3, None, 6.2, 4.1])
([2.3, 4.1, 5], [3.4, 6.2, 4.1], 3)
-
+
"""
-
+
min_length = min(len(a_values), len(b_values))
a_new = []
b_new = []
@@ -18,10 +18,10 @@ def normalize_values(a_values, b_values):
if a_values[counter] and b_values[counter]:
a_new.append(a_values[counter])
b_new.append(b_values[counter])
-
+
num_overlap = len(a_new)
assert num_overlap == len(b_new), "Lengths should be the same"
-
+
return a_new, b_new, num_overlap
@@ -37,16 +37,16 @@ def common_keys(a_samples, b_samples):
def normalize_values_with_samples(a_samples, b_samples):
common_samples = common_keys(a_samples, b_samples)
-
+
a_new = {}
b_new = {}
for sample in common_samples:
a_new[sample] = a_samples[sample]
b_new[sample] = b_samples[sample]
-
+
num_overlap = len(a_new)
assert num_overlap == len(b_new), "Lengths should be the same"
-
+
return a_new, b_new, num_overlap
diff --git a/wqflask/utility/genofile_parser.py b/wqflask/utility/genofile_parser.py
index 67b84dc9..7149e560 100644
--- a/wqflask/utility/genofile_parser.py
+++ b/wqflask/utility/genofile_parser.py
@@ -28,10 +28,10 @@ class ConvertGenoFile(object):
self.mb_exists = False
self.cm_exists = False
self.markers = []
-
+
self.latest_row_pos = None
self.latest_col_pos = None
-
+
self.latest_row_value = None
self.latest_col_value = None
self.input_fh = open(input_file)
diff --git a/wqflask/utility/temp_data.py b/wqflask/utility/temp_data.py
index 004d45c6..5bf700c9 100755
--- a/wqflask/utility/temp_data.py
+++ b/wqflask/utility/temp_data.py
@@ -4,16 +4,16 @@ from redis import Redis
import simplejson as json
class TempData(object):
-
+
def __init__(self, temp_uuid):
self.temp_uuid = temp_uuid
self.redis = Redis()
self.key = "tempdata:{}".format(self.temp_uuid)
-
+
def store(self, field, value):
self.redis.hset(self.key, field, value)
self.redis.expire(self.key, 60*15) # Expire in 15 minutes
-
+
def get_all(self):
return self.redis.hgetall(self.key)
diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py
index dd8c4a1e..11441d7a 100644
--- a/wqflask/utility/tools.py
+++ b/wqflask/utility/tools.py
@@ -35,7 +35,7 @@ def get_setting(command_id,guess=None):
return command
else:
return None
-
+
# ---- Check whether environment exists
sys.stderr.write("Looking for "+command_id+"\n")
command = value(os.environ.get(command_id))
@@ -128,7 +128,7 @@ def locate_ignore_error(name, subdir=None):
def tempdir():
return valid_path(get_setting("TEMPDIR","/tmp"))
-
+
# Cached values
PYLMM_COMMAND = pylmm_command()
GEMMA_COMMAND = gemma_command()
diff --git a/wqflask/utility/webqtlUtil.py b/wqflask/utility/webqtlUtil.py
index 1108614b..4fc978f5 100755
--- a/wqflask/utility/webqtlUtil.py
+++ b/wqflask/utility/webqtlUtil.py
@@ -129,7 +129,7 @@ def inverseCumul(p):
return None
if p>0 and p < 1:
- e = 0.5 * erfcc(-x/sqrt(2)) - p
+ e = 0.5 * erfcc(-x/sqrt(2)) - p
u = e * sqrt(2*pi) * exp(x*x/2)
x = x - u/(1 + x*u/2)
return x
@@ -318,10 +318,10 @@ def FloatList2String(lst):
def ListNotNull(lst):
'''Obsolete - Use built in function any (or all or whatever)
-
-
+
+
Determine if the elements in a list are all null
-
+
'''
for item in lst:
if item is not None: