From 0a8754a582f057bd335441eab15da3f629df9ad7 Mon Sep 17 00:00:00 2001 From: zsloan Date: Mon, 17 May 2021 23:56:10 +0000 Subject: Fixed variety of issues detected by pylint --- gn3/api/rqtl.py | 13 ++++++------- gn3/computations/rqtl.py | 50 ++++++++++++++++++++++++------------------------ 2 files changed, 31 insertions(+), 32 deletions(-) (limited to 'gn3') diff --git a/gn3/api/rqtl.py b/gn3/api/rqtl.py index 82cf34f..7756310 100644 --- a/gn3/api/rqtl.py +++ b/gn3/api/rqtl.py @@ -1,5 +1,4 @@ -import os - +"""Endpoints for running the rqtl cmd""" from flask import Blueprint from flask import current_app from flask import jsonify @@ -12,8 +11,10 @@ rqtl = Blueprint("rqtl", __name__) @rqtl.route("/compute", methods=["POST"]) def compute(): - working_dir = os.path.join(current_app.config.get("TMPDIR")) + """Given at least a geno_file and pheno_file, generate and +run the rqtl_wrapper script and return the results as JSON + """ genofile = request.form['geno_file'] phenofile = request.form['pheno_file'] @@ -28,10 +29,8 @@ def compute(): rqtl_kwargs[kwarg] = request.form[kwarg] results = generate_rqtl_cmd( - rqtl_wrapper_cmd = current_app.config.get("RQTL_WRAPPER_CMD"), - output_dir = current_app.config.get('TMPDIR'), - rqtl_wrapper_kwargs = rqtl_kwargs + rqtl_wrapper_cmd=current_app.config.get("RQTL_WRAPPER_CMD"), + rqtl_wrapper_kwargs=rqtl_kwargs ) return jsonify(results) - diff --git a/gn3/computations/rqtl.py b/gn3/computations/rqtl.py index 087a99f..0e8cd1f 100644 --- a/gn3/computations/rqtl.py +++ b/gn3/computations/rqtl.py @@ -1,25 +1,25 @@ -"""Procedures related rqtl computations""" -import os - -from typing import Dict -from gn3.commands import compose_rqtl_cmd -from gn3.fs_helpers import get_hash_of_files - -def generate_rqtl_cmd(rqtl_wrapper_cmd: str, - output_dir: str, - rqtl_wrapper_kwargs: Dict) -> Dict: - - _hash = get_hash_of_files( - [v for k, v in rqtl_wrapper_kwargs.items() if k in ["g", "p", "addcovar", - "model", "method", - "interval", "nperm", - "scale", "control"]]) - - _output_filename = f"{_hash}-output.json" - return { - "output_file": - _output_filename, - "rqtl_cmd": - compose_rqtl_cmd(rqtl_wrapper_cmd=rqtl_wrapper_cmd, - rqtl_wrapper_kwargs=rqtl_wrapper_kwargs) - } \ No newline at end of file +"""Procedures related rqtl computations""" + +from typing import Dict +from gn3.commands import compose_rqtl_cmd +from gn3.fs_helpers import get_hash_of_files + +def generate_rqtl_cmd(rqtl_wrapper_cmd: str, + rqtl_wrapper_kwargs: Dict) -> Dict: + """Given the base rqtl_wrapper command and +dict of keyword arguments, return the full rqtl_wrapper command and an +output filename generated from a hash of the genotype and phenotype files + + """ + + _hash = get_hash_of_files( + [v for k, v in rqtl_wrapper_kwargs.items() if k in ["g", "p"]]) + + _output_filename = f"{_hash}-output.json" + return { + "output_file": + _output_filename, + "rqtl_cmd": + compose_rqtl_cmd(rqtl_wrapper_cmd=rqtl_wrapper_cmd, + rqtl_wrapper_kwargs=rqtl_wrapper_kwargs) + } -- cgit v1.2.3