about summary refs log tree commit diff
path: root/wqflask/tests
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask/tests')
-rw-r--r--wqflask/tests/unit/wqflask/api/test_correlation.py4
-rw-r--r--wqflask/tests/unit/wqflask/marker_regression/test_gemma_mapping.py14
-rw-r--r--wqflask/tests/unit/wqflask/marker_regression/test_qtlreaper_mapping.py24
-rw-r--r--wqflask/tests/unit/wqflask/marker_regression/test_rqtl_mapping.py28
-rw-r--r--wqflask/tests/wqflask/show_trait/testSampleList.py6
5 files changed, 38 insertions, 38 deletions
diff --git a/wqflask/tests/unit/wqflask/api/test_correlation.py b/wqflask/tests/unit/wqflask/api/test_correlation.py
index d0264b87..bd99838d 100644
--- a/wqflask/tests/unit/wqflask/api/test_correlation.py
+++ b/wqflask/tests/unit/wqflask/api/test_correlation.py
@@ -127,9 +127,9 @@ class TestCorrelations(unittest.TestCase):
         expected_pearsonr = [-0.21618688834430866, 0.680771605997119, 6]
         expected_spearmanr = [-0.11595420713048969, 0.826848213385815, 6]
         for i, val in enumerate(expected_pearsonr):
-            self.assertAlmostEqual(val, results_pearsonr[i],4)
+            self.assertAlmostEqual(val, results_pearsonr[i], 4)
         for i, val in enumerate(expected_spearmanr):
-            self.assertAlmostEqual(val, results_spearmanr[i],4)
+            self.assertAlmostEqual(val, results_spearmanr[i], 4)
         self.assertEqual(results_num_overlap, None)
 
     @mock.patch("wqflask.api.correlation.do_literature_correlation_for_all_traits")
diff --git a/wqflask/tests/unit/wqflask/marker_regression/test_gemma_mapping.py b/wqflask/tests/unit/wqflask/marker_regression/test_gemma_mapping.py
index fe2569b8..f194c6c9 100644
--- a/wqflask/tests/unit/wqflask/marker_regression/test_gemma_mapping.py
+++ b/wqflask/tests/unit/wqflask/marker_regression/test_gemma_mapping.py
@@ -47,11 +47,11 @@ class TestGemmaMapping(unittest.TestCase):
     @mock.patch("wqflask.marker_regression.run_mapping.random.choice")
     @mock.patch("wqflask.marker_regression.gemma_mapping.os")
     @mock.patch("wqflask.marker_regression.gemma_mapping.gen_pheno_txt_file")
-    def test_run_gemma_firstrun_set_true(self, mock_gen_pheno_txt, mock_os, mock_choice, mock_gen_covar, mock_flat_files,mock_parse_loco):
+    def test_run_gemma_firstrun_set_true(self, mock_gen_pheno_txt, mock_os, mock_choice, mock_gen_covar, mock_flat_files, mock_parse_loco):
         """add tests for run_gemma where first run is set to true"""
-        this_chromosomes={}
+        this_chromosomes = {}
         for i in range(1, 5):
-            this_chromosomes[f'CH{i}']=(AttributeSetter({"name": f"CH{i}"}))
+            this_chromosomes[f'CH{i}'] = (AttributeSetter({"name": f"CH{i}"}))
         chromosomes = AttributeSetter({"chromosomes": this_chromosomes})
 
         dataset_group = MockGroup(
@@ -68,9 +68,9 @@ class TestGemmaMapping(unittest.TestCase):
         mock_parse_loco.return_value = []
         results = run_gemma(this_trait=trait, this_dataset=dataset, samples=[
         ], vals=[], covariates="", use_loco=True)
-        self.assertEqual(mock_os.system.call_count,2)
+        self.assertEqual(mock_os.system.call_count, 2)
         mock_gen_pheno_txt.assert_called_once()
-        mock_parse_loco.assert_called_once_with(dataset, "GP1_GWA_RRRRRR",True)
+        mock_parse_loco.assert_called_once_with(dataset, "GP1_GWA_RRRRRR", True)
         mock_os.path.isfile.assert_called_once_with(
             ('/home/user/imgfile_output.assoc.txt'))
         self.assertEqual(mock_flat_files.call_count, 4)
@@ -144,7 +144,7 @@ class TestGemmaMapping(unittest.TestCase):
             "files": [["file_name", "user", "~/file1"],
                       ["file_name", "user", "~/file2"]]
         }
-        return_file="""X/Y\tM1\t28.457155\tQ\tE\tA\tMMB\t23.3\tW\t0.9\t0.85\t
+        return_file = """X/Y\tM1\t28.457155\tQ\tE\tA\tMMB\t23.3\tW\t0.9\t0.85\t
 chr4\tM2\t12\tQ\tE\tMMB\tR\t24\tW\t0.87\t0.5
 Y\tM4\t12\tQ\tE\tMMB\tR\t11.6\tW\t0.21\t0.7
 X\tM5\t12\tQ\tE\tMMB\tR\t21.1\tW\t0.65\t0.6"""
@@ -159,7 +159,7 @@ X\tM5\t12\tQ\tE\tMMB\tR\t21.1\tW\t0.65\t0.6"""
             mock_open.side_effect = handles
             results = parse_loco_output(
                 this_dataset={}, gwa_output_filename=".xw/")
-            expected_results= [
+            expected_results = [
             {'name': 'M1', 'chr': 'X/Y', 'Mb': 2.8457155e-05, 'p_value': 0.85, 'additive': 23.3, 'lod_score': 0.07058107428570727},
             {'name': 'M2', 'chr': 4, 'Mb': 1.2e-05, 'p_value': 0.5, 'additive': 24.0, 'lod_score': 0.3010299956639812},
             {'name': 'M4', 'chr': 'Y', 'Mb': 1.2e-05, 'p_value': 0.7, 'additive': 11.6, 'lod_score': 0.1549019599857432},
diff --git a/wqflask/tests/unit/wqflask/marker_regression/test_qtlreaper_mapping.py b/wqflask/tests/unit/wqflask/marker_regression/test_qtlreaper_mapping.py
index b47f877a..bbb79f98 100644
--- a/wqflask/tests/unit/wqflask/marker_regression/test_qtlreaper_mapping.py
+++ b/wqflask/tests/unit/wqflask/marker_regression/test_qtlreaper_mapping.py
@@ -1,20 +1,20 @@
 import unittest
-from unittest import  mock
-from wqflask.marker_regression.qtlreaper_mapping import  gen_pheno_txt_file
+from unittest import mock
+from wqflask.marker_regression.qtlreaper_mapping import gen_pheno_txt_file
 
-#issues some methods in genofile object are not defined
-#modify samples should equal to vals
+# issues some methods in genofile object are not defined
+# modify samples should equal to vals
 class TestQtlReaperMapping(unittest.TestCase):
 	@mock.patch("wqflask.marker_regression.qtlreaper_mapping.TEMPDIR", "/home/user/data")
-	def  test_gen_pheno_txt_file(self):                   
-		vals=["V1","x","V4","V3","x"]
-		samples=["S1","S2","S3","S4","S5"]
-		trait_filename="trait_file"
+	def test_gen_pheno_txt_file(self):                   
+		vals = ["V1", "x", "V4", "V3","x"]
+		samples = ["S1", "S2", "S3", "S4","S5"]
+		trait_filename = "trait_file"
 		with mock.patch("builtins.open", mock.mock_open())as mock_open:
-			gen_pheno_txt_file(samples=samples,vals=vals,trait_filename=trait_filename)
-			mock_open.assert_called_once_with("/home/user/data/gn2/trait_file.txt","w")
-			filehandler=mock_open()
-			write_calls= [mock.call('Trait\t'),mock.call('S1\tS3\tS4\n'),mock.call('T1\t'),mock.call('V1\tV4\tV3')]
+			gen_pheno_txt_file(samples=samples, vals=vals, trait_filename=trait_filename)
+			mock_open.assert_called_once_with("/home/user/data/gn2/trait_file.txt", "w")
+			filehandler = mock_open()
+			write_calls = [mock.call('Trait\t'), mock.call('S1\tS3\tS4\n'), mock.call('T1\t'), mock.call('V1\tV4\tV3')]
 
 			filehandler.write.assert_has_calls(write_calls)
 
diff --git a/wqflask/tests/unit/wqflask/marker_regression/test_rqtl_mapping.py b/wqflask/tests/unit/wqflask/marker_regression/test_rqtl_mapping.py
index c585f1df..0e617e93 100644
--- a/wqflask/tests/unit/wqflask/marker_regression/test_rqtl_mapping.py
+++ b/wqflask/tests/unit/wqflask/marker_regression/test_rqtl_mapping.py
@@ -8,7 +8,7 @@ from wqflask.marker_regression.rqtl_mapping import sanitize_rqtl_names
 class TestRqtlMapping(unittest.TestCase):
 
 	def setUp(self):
-		self.app_context=app.app_context()
+		self.app_context = app.app_context()
 		self.app_context.push()
 
 	def tearDown(self):
@@ -17,28 +17,28 @@ class TestRqtlMapping(unittest.TestCase):
 
 	@mock.patch("wqflask.marker_regression.rqtl_mapping.g")
 	@mock.patch("wqflask.marker_regression.rqtl_mapping.logger")
-	def test_get_trait_data(self,mock_logger,mock_db):
+	def test_get_trait_data(self, mock_logger, mock_db):
 		"""test for getting trait data_type return True"""
-		query_value="""SELECT value FROM TraitMetadata WHERE type='trait_data_type'"""
-		mock_db.db.execute.return_value.fetchone.return_value=["""{"type":"trait_data_type","name":"T1","traid_id":"fer434f"}"""]
-		results=get_trait_data_type("traid_id")
+		query_value = """SELECT value FROM TraitMetadata WHERE type='trait_data_type'"""
+		mock_db.db.execute.return_value.fetchone.return_value = ["""{"type":"trait_data_type","name":"T1","traid_id":"fer434f"}"""]
+		results = get_trait_data_type("traid_id")
 		mock_db.db.execute.assert_called_with(query_value)
-		self.assertEqual(results,"fer434f")
+		self.assertEqual(results, "fer434f")
 
 	def test_sanitize_rqtl_phenotype(self):
 		"""test for sanitizing rqtl phenotype"""
-		vals=['f',"x","r","x","x"]
-		results=sanitize_rqtl_phenotype(vals)
-		expected_phenotype_string='c(f,NA,r,NA,NA)'
+		vals = ['f', "x", "r", "x","x"]
+		results = sanitize_rqtl_phenotype(vals)
+		expected_phenotype_string = 'c(f,NA,r,NA,NA)'
 
-		self.assertEqual(results,expected_phenotype_string)
+		self.assertEqual(results, expected_phenotype_string)
 
 	def test_sanitize_rqtl_names(self):
 		"""test for sanitzing rqtl names"""
-		vals=['f',"x","r","x","x"]
-		expected_sanitized_name="c('f',NA,'r',NA,NA)"
-		results=sanitize_rqtl_names(vals)
-		self.assertEqual(expected_sanitized_name,results)
+		vals = ['f', "x", "r", "x","x"]
+		expected_sanitized_name = "c('f',NA,'r',NA,NA)"
+		results = sanitize_rqtl_names(vals)
+		self.assertEqual(expected_sanitized_name, results)
 
 
 		
diff --git a/wqflask/tests/wqflask/show_trait/testSampleList.py b/wqflask/tests/wqflask/show_trait/testSampleList.py
index 34c51e3e..441a88a7 100644
--- a/wqflask/tests/wqflask/show_trait/testSampleList.py
+++ b/wqflask/tests/wqflask/show_trait/testSampleList.py
@@ -10,7 +10,7 @@ class TestSampleList(unittest.TestCase):
 
         characters_list = ["z", "f", "q", "s", "t", "a", "g"]
         names_list = ["temp1", "publish", "Sample", "Dataset"]
-        sorted_list_a=natural_sort(characters_list)
-        sorted_list_b=natural_sort(names_list)
+        sorted_list_a = natural_sort(characters_list)
+        sorted_list_b = natural_sort(names_list)
         self.assertEqual(sorted_list_a, ["a", "f", "g", "q", "s", "t", "z"])
-        self.assertEqual(sorted_list_b,["Dataset", "Sample", "publish", "temp1"])
+        self.assertEqual(sorted_list_b, ["Dataset", "Sample", "publish", "temp1"])