diff options
author | BonfaceKilz | 2021-02-19 17:08:45 +0300 |
---|---|---|
committer | BonfaceKilz | 2021-02-24 14:20:29 +0300 |
commit | 18d25f2438dda409fce1a95dc26e63f1b68daaa9 (patch) | |
tree | cb998db1f293163bea7596ce32e38a00a9011e83 /gn3 | |
parent | 96bc4c74f2e5b7a8ffa2bf25bdb6680197fd53ed (diff) | |
download | genenetwork3-18d25f2438dda409fce1a95dc26e63f1b68daaa9.tar.gz |
Append random 6 chars to generated phenotype file
Diffstat (limited to 'gn3')
-rw-r--r-- | gn3/computations/gemma.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/gn3/computations/gemma.py b/gn3/computations/gemma.py index 9a972ba..5bdddc1 100644 --- a/gn3/computations/gemma.py +++ b/gn3/computations/gemma.py @@ -1,10 +1,19 @@ """Procedures related gemma computations""" +import random +import string + + +def generate_random_n_string(n_length): + """Generate a random string that is N chars long""" + return ''.join(random.choice(string.ascii_uppercase + string.digits) + for _ in range(n_length)) def generate_pheno_txt_file(trait_filename: str, values: str, tmpdir: str = "/tmp") -> str: """Given VALUES, and TMPDIR, generate a valide traits file""" + trait_filename += f"_{generate_random_n_string(6)}" with open(f"{tmpdir}/gn2/{trait_filename}", "w") as _file: for value in values: if value == "x": |