aboutsummaryrefslogtreecommitdiff
path: root/gn3
diff options
context:
space:
mode:
authorBonfaceKilz2021-02-24 10:27:02 +0300
committerBonfaceKilz2021-02-24 14:20:29 +0300
commit06f480b625fe5a240ddcdf3e6887f0796cfefb52 (patch)
treeb58a8b03be9a7ce4e22f1f55106b2e9f668760a6 /gn3
parent06250b830c8cc26b66354363935c3b9b06a6e7cc (diff)
downloadgenenetwork3-06f480b625fe5a240ddcdf3e6887f0796cfefb52.tar.gz
Add new procedure that computes the hash of an array of strings
Diffstat (limited to 'gn3')
-rw-r--r--gn3/computations/gemma.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/gn3/computations/gemma.py b/gn3/computations/gemma.py
index 790aecb..ea0f86a 100644
--- a/gn3/computations/gemma.py
+++ b/gn3/computations/gemma.py
@@ -2,6 +2,8 @@
import random
import string
+from base64 import b64encode
+from hashlib import md5
def generate_random_n_string(n_length: int) -> str:
"""Generate a random string that is N chars long"""
@@ -9,6 +11,11 @@ def generate_random_n_string(n_length: int) -> str:
for _ in range(n_length))
+def generate_hash_of_string(unhashed_str: str) -> str:
+ """Given an UNHASHED_STRING, generate it's md5 hash while removing the '==' at
+the end"""
+ hashed_str = md5(unhashed_str.encode("utf-8")).digest()
+ return b64encode(hashed_str).decode("utf-8").replace("==", "")
def generate_pheno_txt_file(trait_filename: str,
values: str,
tmpdir: str = "/tmp") -> str: