aboutsummaryrefslogtreecommitdiff
path: root/gn3
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2021-09-22 08:36:11 +0300
committerFrederick Muriuki Muriithi2021-09-22 08:36:11 +0300
commit71cc35e5178904b512b9007e33be17a36f6656f2 (patch)
tree2d059b89aa30ce55d2cafe781915abc3ea31d948 /gn3
parentcd7f301688fd9780df1f842f8bd2b7602775ba1f (diff)
downloadgenenetwork3-71cc35e5178904b512b9007e33be17a36f6656f2.tar.gz
Fix typing issues
* Ignore some errors * Update typing definitions for some portions of code * Add missing imports
Diffstat (limited to 'gn3')
-rw-r--r--gn3/app.py2
-rw-r--r--gn3/computations/qtlreaper.py6
-rw-r--r--gn3/db/genotypes.py10
-rw-r--r--gn3/db/traits.py8
-rw-r--r--gn3/heatmaps.py8
5 files changed, 18 insertions, 16 deletions
diff --git a/gn3/app.py b/gn3/app.py
index 8badb65..5e852e1 100644
--- a/gn3/app.py
+++ b/gn3/app.py
@@ -5,7 +5,7 @@ from typing import Dict
from typing import Union
from flask import Flask
-from flask_cors import CORS
+from flask_cors import CORS # type: ignore
from gn3.api.gemma import gemma
from gn3.api.rqtl import rqtl
diff --git a/gn3/computations/qtlreaper.py b/gn3/computations/qtlreaper.py
index 5d17fed..5ddea76 100644
--- a/gn3/computations/qtlreaper.py
+++ b/gn3/computations/qtlreaper.py
@@ -4,6 +4,8 @@ computation of QTLs.
"""
import os
import subprocess
+from typing import Union
+
from gn3.random import random_string
from gn3.settings import TMPDIR, REAPER_COMMAND
@@ -70,9 +72,9 @@ def run_reaper(
output_dir, random_string(10))
output_list = ["--main_output", output_filename]
if separate_nperm_output:
- permu_output_filename = "{}/qtlreaper/permu_output_{}.txt".format(
+ permu_output_filename: Union[None, str] = "{}/qtlreaper/permu_output_{}.txt".format(
output_dir, random_string(10))
- output_list = output_list + ["--permu_output", permu_output_filename]
+ output_list = output_list + ["--permu_output", permu_output_filename] # type: ignore[list-item]
else:
permu_output_filename = None
diff --git a/gn3/db/genotypes.py b/gn3/db/genotypes.py
index 919c539..9ea9f20 100644
--- a/gn3/db/genotypes.py
+++ b/gn3/db/genotypes.py
@@ -2,6 +2,8 @@
import os
import gzip
+from typing import Union, TextIO
+
from gn3.settings import GENOTYPE_FILES
def build_genotype_file(
@@ -44,17 +46,17 @@ def __load_genotype_samples_from_geno(genotype_filename: str):
"""
gzipped_filename = "{}.gz".format(genotype_filename)
if os.path.isfile(gzipped_filename):
- genofile = gzip.open(gzipped_filename)
+ genofile: Union[TextIO, gzip.GzipFile] = gzip.open(gzipped_filename)
else:
genofile = open(genotype_filename)
for row in genofile:
line = row.strip()
- if (not line) or (line.startswith(("#", "@"))):
+ if (not line) or (line.startswith(("#", "@"))): # type: ignore[arg-type]
continue
break
- headers = line.split("\t")
+ headers = line.split("\t" ) # type: ignore[arg-type]
if headers[3] == "Mb":
return headers[4:]
return headers[3:]
@@ -107,7 +109,7 @@ def parse_genotype_header(line: str, parlist: tuple = tuple()):
("prgy", prgy),
("nprgy", len(prgy)))
-def parse_genotype_marker(line: str, geno_obj: dict, parlist: list):
+def parse_genotype_marker(line: str, geno_obj: dict, parlist: tuple):
"""
Parse a data line in a genotype file
diff --git a/gn3/db/traits.py b/gn3/db/traits.py
index 747ed27..4fc47c3 100644
--- a/gn3/db/traits.py
+++ b/gn3/db/traits.py
@@ -63,22 +63,22 @@ def update_sample_data(conn: Any,
with conn.cursor() as cursor:
# Update the Strains table
cursor.execute(STRAIN_ID_SQL, (strain_name, strain_id))
- updated_strains: int = cursor.rowcount
+ updated_strains = cursor.rowcount
# Update the PublishData table
cursor.execute(PUBLISH_DATA_SQL,
(None if value == "x" else value,
strain_id, publish_data_id))
- updated_published_data: int = cursor.rowcount
+ updated_published_data = cursor.rowcount
# Update the PublishSE table
cursor.execute(PUBLISH_SE_SQL,
(None if error == "x" else error,
strain_id, publish_data_id))
- updated_se_data: int = cursor.rowcount
+ updated_se_data = cursor.rowcount
# Update the NStrain table
cursor.execute(N_STRAIN_SQL,
(None if count == "x" else count,
strain_id, publish_data_id))
- updated_n_strains: int = cursor.rowcount
+ updated_n_strains = cursor.rowcount
return (updated_strains, updated_published_data,
updated_se_data, updated_n_strains)
diff --git a/gn3/heatmaps.py b/gn3/heatmaps.py
index 9d82fb2..45d0c22 100644
--- a/gn3/heatmaps.py
+++ b/gn3/heatmaps.py
@@ -7,9 +7,9 @@ from functools import reduce
from typing import Any, Dict, Sequence
import numpy as np
-import plotly.graph_objects as go
-import plotly.figure_factory as ff
-from plotly.subplots import make_subplots
+import plotly.graph_objects as go # type: ignore
+import plotly.figure_factory as ff # type: ignore
+from plotly.subplots import make_subplots # type: ignore
from gn3.settings import TMPDIR
from gn3.random import random_string
@@ -171,8 +171,6 @@ def build_heatmap(traits_names, conn: Any):
clustered = cluster_traits(exported_traits_data_list)
slinked = slink(clustered)
traits_order = compute_traits_order(slinked)
- ordered_traits_names = [
- traits[idx]["trait_fullname"] for idx in traits_order]
strains_and_values = retrieve_strains_and_values(
traits_order, strains, exported_traits_data_list)
traits_filename = "{}/traits_test_file_{}.txt".format(