diff options
Diffstat (limited to 'gn3')
-rw-r--r-- | gn3/api/gemma.py | 1 | ||||
-rw-r--r-- | gn3/computations/gemma.py | 30 |
2 files changed, 31 insertions, 0 deletions
diff --git a/gn3/api/gemma.py b/gn3/api/gemma.py index d82f5a5..d08c11b 100644 --- a/gn3/api/gemma.py +++ b/gn3/api/gemma.py @@ -12,6 +12,7 @@ from gn3.commands import queue_cmd from gn3.commands import run_cmd from gn3.file_utils import get_hash_of_files from gn3.file_utils import jsonfile_to_dict +from gn3.computations.gemma import compute_k_values from gn3.computations.gemma import do_paths_exist from gn3.computations.gemma import generate_hash_of_string from gn3.computations.gemma import generate_pheno_txt_file diff --git a/gn3/computations/gemma.py b/gn3/computations/gemma.py index 7b5f91d..3c6bd29 100644 --- a/gn3/computations/gemma.py +++ b/gn3/computations/gemma.py @@ -8,6 +8,7 @@ from typing import List from typing import Optional from typing import ValuesView from gn3.commands import compose_gemma_cmd +from gn3.file_utils import get_hash_of_files def generate_hash_of_string(unhashed_str: str) -> str: @@ -68,3 +69,32 @@ def generate_gemma_computation_cmd( gemma_wrapper_kwargs=gemma_wrapper_kwargs, gemma_kwargs=_kwargs, gemma_args=["-gk", ">", output_file]) + + +# pylint: disable=R0913 +def generate_gemma_cmd(gemma_cmd: str, + output_dir: str, + token: str, + gemma_kwargs: Dict, + gemma_wrapper_kwargs: Dict = None, + chromosomes: str = None) -> Dict: + """Compute k values""" + _hash = get_hash_of_files( + [v for k, v in gemma_kwargs.items() if k in ["g", "p", "a", "c"]]) + if chromosomes: # Only reached when calculating k-values + gemma_wrapper_kwargs = {"loco": f"--input {chromosomes}"} + _hash += f"-{generate_hash_of_string(chromosomes)[:6]}" + _output_filename = f"{_hash}-output.json" + return { + "output_file": + _output_filename, + "gemma_cmd": + compose_gemma_cmd(gemma_wrapper_cmd=gemma_cmd, + gemma_wrapper_kwargs=gemma_wrapper_kwargs, + gemma_kwargs=gemma_kwargs, + gemma_args=[ + "-gk", ">", + (f"{output_dir}/" + f"{token}/{_output_filename}") + ]) + } |