aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorzsloan2022-09-26 20:22:55 +0000
committerzsloan2022-09-26 20:23:25 +0000
commitf3fbcc0828967d7bbbb5f60c0fcc79814af70985 (patch)
tree1a796112b2f48284eb76035359713d649d2cefae /wqflask
parent57bd008a577c42cb3ca265e55a23d5bf29d206f1 (diff)
downloadgenenetwork2-f3fbcc0828967d7bbbb5f60c0fcc79814af70985.tar.gz
Get heatmap and mapping working again with changing to species.py
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/heatmap/heatmap.py7
-rw-r--r--wqflask/wqflask/marker_regression/gemma_mapping.py9
-rw-r--r--wqflask/wqflask/marker_regression/run_mapping.py14
3 files changed, 18 insertions, 12 deletions
diff --git a/wqflask/wqflask/heatmap/heatmap.py b/wqflask/wqflask/heatmap/heatmap.py
index 8d9c9e7f..8ef85d3c 100644
--- a/wqflask/wqflask/heatmap/heatmap.py
+++ b/wqflask/wqflask/heatmap/heatmap.py
@@ -33,9 +33,10 @@ class Heatmap:
chrnames = []
self.species = species.TheSpecies(dataset=self.trait_list[0][1])
- for key in list(self.species.chromosomes(db_cursor).chromosomes.keys()):
- chrnames.append([self.species.chromosomes.chromosomes[key].name,
- self.species.chromosomes.chromosomes[key].mb_length])
+ with database_connection() as conn, conn.cursor() as db_cursor:
+ for this_chr in self.species.chromosomes.chromosomes(db_cursor):
+ chrnames.append([self.species.chromosomes.chromosomes(db_cursor)[this_chr].name,
+ self.species.chromosomes.chromosomes(db_cursor)[this_chr].mb_length])
for trait_db in self.trait_list:
diff --git a/wqflask/wqflask/marker_regression/gemma_mapping.py b/wqflask/wqflask/marker_regression/gemma_mapping.py
index cc063d03..08a38527 100644
--- a/wqflask/wqflask/marker_regression/gemma_mapping.py
+++ b/wqflask/wqflask/marker_regression/gemma_mapping.py
@@ -11,6 +11,7 @@ from utility.tools import flat_files, assert_file
from utility.tools import GEMMA_WRAPPER_COMMAND
from utility.tools import TEMPDIR
from utility.tools import WEBSERVER_MODE
+from wqflask.database import database_connection
from gn3.computations.gemma import generate_hash_of_string
@@ -47,9 +48,11 @@ def run_gemma(this_trait, this_dataset, samples, vals, covariates, use_loco,
gwa_output_filename = (f"{this_dataset.group.name}_GWA_"
f"{generate_random_n_string(6)}")
- this_chromosomes = this_dataset.species.chromosomes.chromosomes
- this_chromosomes_name = [this_chromosomes[chromosome].name
- for chromosome in this_chromosomes]
+
+ this_chromosomes_name = []
+ with database_connection() as conn, conn.cursor() as db_cursor:
+ for this_chr in this_dataset.species.chromosomes.chromosomes(db_cursor):
+ this_chromosomes_name.append(this_dataset.species.chromosomes.chromosomes(db_cursor)[this_chr].name)
chr_list_string = ",".join(this_chromosomes_name)
if covariates != "":
diff --git a/wqflask/wqflask/marker_regression/run_mapping.py b/wqflask/wqflask/marker_regression/run_mapping.py
index b2f5af3b..8ca1faf5 100644
--- a/wqflask/wqflask/marker_regression/run_mapping.py
+++ b/wqflask/wqflask/marker_regression/run_mapping.py
@@ -30,6 +30,7 @@ from base import data_set
from base import species
from base import webqtlConfig
from utility import webqtlUtil, helper_functions, hmac, Plot, Bunch, temp_data
+from wqflask.database import database_connection
from wqflask.marker_regression import gemma_mapping, rqtl_mapping, qtlreaper_mapping, plink_mapping
from wqflask.show_trait.SampleList import SampleList
@@ -658,12 +659,13 @@ def geno_db_exists(this_dataset):
def get_chr_lengths(mapping_scale, mapping_method, dataset, qtl_results):
chr_lengths = []
if mapping_scale == "physic":
- for i, the_chr in enumerate(dataset.species.chromosomes.chromosomes):
- this_chr = {
- "chr": dataset.species.chromosomes.chromosomes[the_chr].name,
- "size": str(dataset.species.chromosomes.chromosomes[the_chr].length)
- }
- chr_lengths.append(this_chr)
+ with database_connection() as conn, conn.cursor() as db_cursor:
+ for i, the_chr in enumerate(dataset.species.chromosomes.chromosomes(db_cursor)):
+ this_chr = {
+ "chr": dataset.species.chromosomes.chromosomes(db_cursor)[the_chr].name,
+ "size": str(dataset.species.chromosomes.chromosomes(db_cursor)[the_chr].length)
+ }
+ chr_lengths.append(this_chr)
else:
this_chr = 1
highest_pos = 0