aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzsloan2021-06-18 21:13:03 +0000
committerzsloan2021-06-18 22:08:04 +0000
commitd42b85ae5fcea1b71a7165fd6e64745a228c48f9 (patch)
tree4249050b7e04559605b11fd1286417557d0c22b2
parentf172f7cbe0e5fd44b452bf3f3be094ba8b6b2c0e (diff)
downloadgenenetwork3-d42b85ae5fcea1b71a7165fd6e64745a228c48f9.tar.gz
Fixed pylint issues
-rw-r--r--gn3/api/rqtl.py7
-rw-r--r--gn3/computations/rqtl.py45
2 files changed, 28 insertions, 24 deletions
diff --git a/gn3/api/rqtl.py b/gn3/api/rqtl.py
index 38f4c1e..ebb746c 100644
--- a/gn3/api/rqtl.py
+++ b/gn3/api/rqtl.py
@@ -6,7 +6,6 @@ from flask import current_app
from flask import jsonify
from flask import request
-from gn3.commands import run_cmd
from gn3.computations.rqtl import generate_rqtl_cmd, process_rqtl_output, process_perm_output
from gn3.computations.gemma import do_paths_exist
@@ -45,13 +44,15 @@ run the rqtl_wrapper script and return the results as JSON
)
rqtl_output = {}
- if not os.path.isfile(os.path.join(current_app.config.get("TMPDIR"), "output", rqtl_cmd.get('output_file'))):
+ if not os.path.isfile(os.path.join(current_app.config.get("TMPDIR"),
+ "output", rqtl_cmd.get('output_file'))):
os.system(rqtl_cmd.get('rqtl_cmd'))
rqtl_output['results'] = process_rqtl_output(rqtl_cmd.get('output_file'))
rqtl_output['results'] = process_rqtl_output(rqtl_cmd.get('output_file'))
if int(rqtl_kwargs['nperm']) > 0:
- rqtl_output['perm_results'], rqtl_output['suggestive'], rqtl_output['significant'] = process_perm_output(rqtl_cmd.get('output_file'))
+ rqtl_output['perm_results'], rqtl_output['suggestive'], rqtl_output['significant'] = \
+ process_perm_output(rqtl_cmd.get('output_file'))
return jsonify(rqtl_output)
diff --git a/gn3/computations/rqtl.py b/gn3/computations/rqtl.py
index 7b1a35c..0433b3f 100644
--- a/gn3/computations/rqtl.py
+++ b/gn3/computations/rqtl.py
@@ -1,8 +1,9 @@
"""Procedures related rqtl computations"""
import os
-import numpy as np
from typing import Dict, List, Union
+import numpy as np
+
from flask import current_app
from gn3.commands import compose_rqtl_cmd
@@ -54,27 +55,28 @@ def process_rqtl_output(file_name: str) -> List:
marker_obs = []
# Later I should probably redo this using csv.read to avoid the
# awkwardness with removing quotes with [1:-1]
- with open(os.path.join(current_app.config.get("TMPDIR", "/tmp"), "output", file_name), "r") as the_file:
+ with open(os.path.join(current_app.config.get("TMPDIR", "/tmp"),
+ "output", file_name), "r") as the_file:
for line in the_file:
line_items = line.split(",")
if line_items[1][1:-1] == "chr" or not line_items:
# Skip header line
continue
- else:
- # Convert chr to int if possible
- the_chr: Union[int, str]
- try:
- the_chr = int(line_items[1][1:-1])
- except:
- the_chr = line_items[1][1:-1]
- this_marker = {
- "name": line_items[0][1:-1],
- "chr": the_chr,
- "cM": float(line_items[2]),
- "Mb": float(line_items[2]),
- "lod_score": float(line_items[3])
- }
- marker_obs.append(this_marker)
+
+ # Convert chr to int if possible
+ the_chr: Union[int, str]
+ try:
+ the_chr = int(line_items[1][1:-1])
+ except ValueError:
+ the_chr = line_items[1][1:-1]
+ this_marker = {
+ "name": line_items[0][1:-1],
+ "chr": the_chr,
+ "cM": float(line_items[2]),
+ "Mb": float(line_items[2]),
+ "lod_score": float(line_items[3])
+ }
+ marker_obs.append(this_marker)
return marker_obs
@@ -85,14 +87,15 @@ def process_perm_output(file_name: str):
"""
perm_results = []
- with open(os.path.join(current_app.config.get("TMPDIR", "/tmp"), "output", "PERM_" + file_name), "r") as the_file:
+ with open(os.path.join(current_app.config.get("TMPDIR", "/tmp"),
+ "output", "PERM_" + file_name), "r") as the_file:
for i, line in enumerate(the_file):
if i == 0:
# Skip header line
continue
- else:
- line_items = line.split(",")
- perm_results.append(float(line_items[1]))
+
+ line_items = line.split(",")
+ perm_results.append(float(line_items[1]))
suggestive = np.percentile(np.array(perm_results), 67)
significant = np.percentile(np.array(perm_results), 95)