aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorzsloan2016-10-12 16:06:22 +0000
committerzsloan2016-10-12 16:06:22 +0000
commit22339cb85c5db370ee6a2c247de90e603cdf85a5 (patch)
tree33f18dc7daa38e924f10a209b2ec7abc5ed8cfc3 /wqflask
parentf0e48f24647096ae956a23a5a0bfae0375b4dbf2 (diff)
downloadgenenetwork2-22339cb85c5db370ee6a2c247de90e603cdf85a5.tar.gz
Removed unused gemma code from marker_regression.py and changed the order of a couple functions in collect.py to more accurately reflect when they're called
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/collect.py32
-rw-r--r--wqflask/wqflask/marker_regression/marker_regression.py78
-rw-r--r--wqflask/wqflask/user_manager.py1
3 files changed, 15 insertions, 96 deletions
diff --git a/wqflask/wqflask/collect.py b/wqflask/wqflask/collect.py
index 81d03d6c..bf465cdc 100644
--- a/wqflask/wqflask/collect.py
+++ b/wqflask/wqflask/collect.py
@@ -52,7 +52,7 @@ class AnonCollection(object):
self.id = None
self.created_timestamp = datetime.datetime.utcnow().strftime('%b %d %Y %I:%M%p')
self.changed_timestamp = self.created_timestamp #ZS: will be updated when changes are made
-
+
#ZS: Find id and set it if the collection doesn't already exist
if Redis.get(self.key) == "None" or Redis.get(self.key) == None:
Redis.set(self.key, None) #ZS: For some reason I get the error "Operation against a key holding the wrong kind of value" if I don't do this
@@ -66,6 +66,7 @@ class AnonCollection(object):
collection_exists = True
self.id = collection['id']
break
+
if self.id == None:
self.id = str(uuid.uuid4())
@@ -191,7 +192,19 @@ class UserCollection(object):
# Probably have to change that
return redirect(url_for('view_collection', uc_id=uc.id))
-
+def process_traits(unprocessed_traits):
+ #print("unprocessed_traits are:", unprocessed_traits)
+ if isinstance(unprocessed_traits, basestring):
+ unprocessed_traits = unprocessed_traits.split(",")
+ traits = set()
+ for trait in unprocessed_traits:
+ #print("trait is:", trait)
+ data, _separator, hmac = trait.rpartition(':')
+ data = data.strip()
+ assert hmac==user_manager.actual_hmac_creation(data), "Data tampering?"
+ traits.add (str(data))
+ return traits
+
def report_change(len_before, len_now):
new_length = len_now - len_before
if new_length:
@@ -224,7 +237,6 @@ def collections_add():
collections = collection_names,
)
-
@app.route("/collections/new")
def collections_new():
params = request.args
@@ -248,20 +260,6 @@ def collections_new():
else:
CauseAnError
-
-def process_traits(unprocessed_traits):
- #print("unprocessed_traits are:", unprocessed_traits)
- if isinstance(unprocessed_traits, basestring):
- unprocessed_traits = unprocessed_traits.split(",")
- traits = set()
- for trait in unprocessed_traits:
- #print("trait is:", trait)
- data, _separator, hmac = trait.rpartition(':')
- data = data.strip()
- assert hmac==user_manager.actual_hmac_creation(data), "Data tampering?"
- traits.add (str(data))
- return traits
-
def create_new(collection_name):
params = request.args
diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py
index f340e309..7ad5d25a 100644
--- a/wqflask/wqflask/marker_regression/marker_regression.py
+++ b/wqflask/wqflask/marker_regression/marker_regression.py
@@ -309,49 +309,6 @@ class MarkerRegression(object):
perm_results = self.perm_output,
)
-
- def run_gemma(self):
- """Generates p-values for each marker using GEMMA"""
-
- self.gen_pheno_txt_file()
-
- #os.chdir("/home/zas1024/gene/web/gemma")
-
- gemma_command = GEMMA_COMMAND + ' -bfile %s -k output_%s.cXX.txt -lmm 1 -o %s_output' % (
- self.dataset.group.name,
- self.dataset.group.name,
- self.dataset.group.name)
- #logger.debug("gemma_command:" + gemma_command)
-
- os.system(gemma_command)
-
- included_markers, p_values = self.parse_gemma_output()
-
- self.dataset.group.get_specified_markers(markers = included_markers)
- self.dataset.group.markers.add_pvalues(p_values)
- return self.dataset.group.markers.markers
-
- def parse_gemma_output(self):
- included_markers = []
- p_values = []
- # Use a temporary file name here!
- with open(webqtlConfig.GENERATED_TEXT_DIR+"/{}_output.assoc.txt".format(self.dataset.group.name)) as output_file:
- for line in output_file:
- if line.startswith("chr"):
- continue
- else:
- included_markers.append(line.split("\t")[1])
- p_values.append(float(line.split("\t")[10]))
- #p_values[line.split("\t")[1]] = float(line.split("\t")[10])
- #logger.debug("p_values: ", p_values)
- return included_markers, p_values
-
- def gen_pheno_txt_file(self):
- """Generates phenotype file for GEMMA"""
- with open(webqtlConfig.GENERATED_TEXT_DIR+"{}.fam".format(self.dataset.group.name), "w") as outfile:
- for i, sample in enumerate(self.samples):
- outfile.write(str(sample) + " " + str(sample) + " 0 0 0 " + str(self.vals[i]) + "\n")
-
def run_rqtl_plink(self):
# os.chdir("") never do this inside a webserver!!
@@ -425,41 +382,6 @@ class MarkerRegression(object):
output_file.close()
- def gen_pheno_txt_file_rqtl(self, pheno_filename = ''):
- ped_sample_list = self.get_samples_from_ped_file()
- output_file = open("%s%s.txt" % (TMPDIR, pheno_filename), "wb")
- header = 'FID\tIID\t%s\n' % self.this_trait.name
- output_file.write(header)
-
- new_value_list = []
-
- #if valueDict does not include some strain, value will be set to -9999 as missing value
- for i, sample in enumerate(ped_sample_list):
- try:
- value = self.vals[i]
- value = str(value).replace('value=','')
- value = value.strip()
- except:
- value = -9999
-
- new_value_list.append(value)
-
-
- new_line = ''
- for i, sample in enumerate(ped_sample_list):
- j = i+1
- value = new_value_list[i]
- new_line += '%s\t%s\t%s\n'%(sample, sample, value)
-
- if j%1000 == 0:
- output_file.write(newLine)
- new_line = ''
-
- if new_line:
- output_file.write(new_line)
-
- output_file.close()
-
# get strain name from ped file in order
def get_samples_from_ped_file(self):
ped_file= open("{}/{}.ped".format(PLINK_PATH, self.dataset.group.name),"r")
diff --git a/wqflask/wqflask/user_manager.py b/wqflask/wqflask/user_manager.py
index 598af0a6..1e831896 100644
--- a/wqflask/wqflask/user_manager.py
+++ b/wqflask/wqflask/user_manager.py
@@ -158,7 +158,6 @@ def verify_cookie(cookie):
assert the_signature == actual_hmac_creation(the_uuid), "Uh-oh, someone tampering with the cookie?"
return the_uuid
-
def create_signed_cookie():
the_uuid = str(uuid.uuid4())
signature = actual_hmac_creation(the_uuid)