aboutsummaryrefslogtreecommitdiff
path: root/gn3/api/gemma.py
diff options
context:
space:
mode:
authorBonfaceKilz2021-03-04 22:46:26 +0300
committerBonfaceKilz2021-03-08 21:09:58 +0300
commit747c9f5cb96d24f5f498127ec6cc89aa28ad50db (patch)
tree591d409045d951c60741e8825e304559607a74c5 /gn3/api/gemma.py
parentdb1eaaf359749814859b969d1fb4fb3341004705 (diff)
downloadgenenetwork3-747c9f5cb96d24f5f498127ec6cc89aa28ad50db.tar.gz
Replace "generate_gemma_computation_cmd" with "compose_gemma_cmd"
Diffstat (limited to 'gn3/api/gemma.py')
-rw-r--r--gn3/api/gemma.py52
1 files changed, 30 insertions, 22 deletions
diff --git a/gn3/api/gemma.py b/gn3/api/gemma.py
index 7fcf2a2..e5a38e4 100644
--- a/gn3/api/gemma.py
+++ b/gn3/api/gemma.py
@@ -113,21 +113,24 @@ traitfile, and snpsfile are extracted from a metadata.json file.
genofile, phenofile, snpsfile = [os.path.join(working_dir,
_dict.get(x))
for x in ["geno", "pheno", "snps"]]
+ if not do_paths_exist([genofile, phenofile, snpsfile]):
+ raise FileNotFoundError
gemma_kwargs = {"g": genofile, "p": phenofile, "a": snpsfile}
_hash = get_hash_of_files([genofile, phenofile, snpsfile])
k_output_filename = f"{_hash}-k-output.json"
- k_computation_cmd = generate_gemma_computation_cmd(
- gemma_cmd=current_app.config.get("GEMMA_WRAPPER_CMD"),
- gemma_wrapper_kwargs=None,
- gemma_kwargs=gemma_kwargs,
- output_file=(f"{current_app.config.get('TMPDIR')}/"
- f"{token}/{k_output_filename}"))
return jsonify(
unique_id=queue_cmd(
conn=redis.Redis(),
email=(request.get_json() or {}).get('email'),
job_queue=current_app.config.get("REDIS_JOB_QUEUE"),
- cmd=f"{k_computation_cmd}"),
+ cmd=compose_gemma_cmd(
+ gemma_wrapper_cmd=current_app.config.get("GEMMA_"
+ "WRAPPER_CMD"),
+ gemma_wrapper_kwargs=None,
+ gemma_kwargs=gemma_kwargs,
+ gemma_args=["-gk", ">",
+ (f"{current_app.config.get('TMPDIR')}/"
+ f"{token}/{k_output_filename}")])),
status="queued",
output_file=k_output_filename)
# pylint: disable=W0703
@@ -154,18 +157,19 @@ values.
gemma_kwargs = {"g": genofile, "p": phenofile, "a": snpsfile}
_hash = get_hash_of_files([genofile, phenofile, snpsfile])
k_output_filename = f"{_hash}-k-output.json"
- k_computation_cmd = generate_gemma_computation_cmd(
- gemma_cmd=current_app.config.get("GEMMA_WRAPPER_CMD"),
- gemma_wrapper_kwargs={"loco": f"--input {chromosomes}"},
- gemma_kwargs=gemma_kwargs,
- output_file=(f"{current_app.config.get('TMPDIR')}/"
- f"{token}/{k_output_filename}"))
return jsonify(
unique_id=queue_cmd(
conn=redis.Redis(),
email=(request.get_json() or {}).get('email'),
job_queue=current_app.config.get("REDIS_JOB_QUEUE"),
- cmd=f"{k_computation_cmd}"),
+ cmd=compose_gemma_cmd(
+ gemma_wrapper_cmd=current_app.config.get("GEMMA_"
+ "WRAPPER_CMD"),
+ gemma_wrapper_kwargs={"loco": f"--input {chromosomes}"},
+ gemma_kwargs=gemma_kwargs,
+ gemma_args=["-gk", ">",
+ (f"{current_app.config.get('TMPDIR')}/"
+ f"{token}/{k_output_filename}")])),
status="queued",
output_file=k_output_filename)
# pylint: disable=W0703
@@ -198,14 +202,16 @@ def compute_gwa(k_filename, token):
conn=redis.Redis(),
email=(request.get_json() or {}).get('email'),
job_queue=current_app.config.get("REDIS_JOB_QUEUE"),
- cmd=generate_gemma_computation_cmd(
- gemma_cmd=current_app.config.get("GEMMA_WRAPPER_CMD"),
+ cmd=compose_gemma_cmd(
+ gemma_wrapper_cmd=current_app.config.get("GEMMA_"
+ "WRAPPER_CMD"),
gemma_wrapper_kwargs={
"input": os.path.join(working_dir, k_filename)
},
gemma_kwargs=gemma_kwargs,
- output_file=(f"{current_app.config.get('TMPDIR')}/"
- f"{token}/{_output_filename}"))),
+ gemma_args=["gk", ">",
+ (f"{current_app.config.get('TMPDIR')}/"
+ f"{token}/{_output_filename}")])),
status="queued",
output_file=_output_filename)
# pylint: disable=W0703
@@ -239,14 +245,16 @@ def compute_gwa_with_covar(k_filename, token):
conn=redis.Redis(),
email=(request.get_json() or {}).get('email'),
job_queue=current_app.config.get("REDIS_JOB_QUEUE"),
- cmd=generate_gemma_computation_cmd(
- gemma_cmd=current_app.config.get("GEMMA_WRAPPER_CMD"),
+ cmd=compose_gemma_cmd(
+ gemma_wrapper_cmd=current_app.config.get("GEMMA_"
+ "WRAPPER_CMD"),
gemma_wrapper_kwargs={
"input": os.path.join(working_dir, k_filename)
},
gemma_kwargs=gemma_kwargs,
- output_file=(f"{current_app.config.get('TMPDIR')}/"
- f"{token}/{_output_filename}"))),
+ gemma_args=["-gk", ">",
+ (f"{current_app.config.get('TMPDIR')}/"
+ f"{token}/{_output_filename}")])),
status="queued",
output_file=_output_filename)
# pylint: disable=W0703