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/__init__.py0
-rw-r--r--wqflask/tests/base/__init__.py0
-rw-r--r--wqflask/tests/base/data.py110
-rw-r--r--wqflask/tests/base/test_data_set.py140
-rw-r--r--wqflask/tests/base/test_general_object.py41
-rw-r--r--wqflask/tests/base/test_webqtl_case_data.py39
-rw-r--r--wqflask/tests/utility/__init__.py0
-rw-r--r--wqflask/tests/utility/test_chunks.py19
-rw-r--r--wqflask/tests/utility/test_corestats.py55
-rw-r--r--wqflask/tests/utility/test_corr_result_helpers.py32
-rw-r--r--wqflask/tests/utility/test_formatting.py33
-rw-r--r--wqflask/tests/wqflask/__init__.py0
-rw-r--r--wqflask/tests/wqflask/api/__init__.py0
-rw-r--r--wqflask/tests/wqflask/api/test_gen_menu.py407
-rw-r--r--wqflask/tests/wqflask/marker_regression/__init__.py0
-rw-r--r--wqflask/tests/wqflask/marker_regression/test_display_mapping_results.py151
16 files changed, 1027 insertions, 0 deletions
diff --git a/wqflask/tests/__init__.py b/wqflask/tests/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/wqflask/tests/__init__.py
diff --git a/wqflask/tests/base/__init__.py b/wqflask/tests/base/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/wqflask/tests/base/__init__.py
diff --git a/wqflask/tests/base/data.py b/wqflask/tests/base/data.py
new file mode 100644
index 00000000..06a5a989
--- /dev/null
+++ b/wqflask/tests/base/data.py
@@ -0,0 +1,110 @@
+gen_menu_json = """
+{
+  "datasets": {
+    "human": {
+      "HLC": {
+        "Liver mRNA": [
+          [
+            "320",
+            "HLC_0311",
+            "GSE9588 Human Liver Normal (Mar11) Both Sexes"
+          ]
+        ],
+        "Phenotypes": [
+          [
+            "635",
+            "HLCPublish",
+            "HLC Published Phenotypes"
+          ]
+        ]
+      }
+    },
+    "mouse": {
+      "BXD": {
+        "Genotypes": [
+          [
+            "600",
+            "BXDGeno",
+            "BXD Genotypes"
+          ]
+        ],
+        "Hippocampus mRNA": [
+          [
+            "112",
+            "HC_M2_0606_P",
+            "Hippocampus Consortium M430v2 (Jun06) PDNN"
+          ]
+        ],
+        "Phenotypes": [
+          [
+            "602",
+            "BXDPublish",
+            "BXD Published Phenotypes"
+          ]
+        ]
+      }
+    }
+  },
+  "groups": {
+    "human": [
+      [
+        "HLC",
+        "Liver: Normal Gene Expression with Genotypes (Merck)",
+        "Family:None"
+      ]
+    ],
+    "mouse": [
+      [
+        "BXD",
+        "BXD",
+        "Family:None"
+      ]
+    ]
+  },
+  "species": [
+    [
+      "human",
+      "Human"
+    ],
+    [
+      "mouse",
+      "Mouse"
+    ]
+  ],
+  "types": {
+    "human": {
+      "HLC": [
+        [
+          "Phenotypes",
+          "Traits and Cofactors",
+          "Phenotypes"
+        ],
+        [
+          "Liver mRNA",
+          "Liver mRNA",
+          "Molecular Trait Datasets"
+        ]
+      ]
+    },
+    "mouse": {
+      "BXD": [
+        [
+          "Phenotypes",
+          "Traits and Cofactors",
+          "Phenotypes"
+        ],
+        [
+          "Genotypes",
+          "DNA Markers and SNPs",
+          "Genotypes"
+        ],
+        [
+          "Hippocampus mRNA",
+          "Hippocampus mRNA",
+          "Molecular Trait Datasets"
+        ]
+      ]
+    }
+  }
+}
+"""
diff --git a/wqflask/tests/base/test_data_set.py b/wqflask/tests/base/test_data_set.py
new file mode 100644
index 00000000..94780a5d
--- /dev/null
+++ b/wqflask/tests/base/test_data_set.py
@@ -0,0 +1,140 @@
+"""Tests for wqflask/base/data_set.py"""
+
+import unittest
+import mock
+
+from wqflask import app
+from data import gen_menu_json
+from base.data_set import DatasetType
+
+
+class TestDataSetTypes(unittest.TestCase):
+    """Tests for the DataSetType class"""
+
+    def setUp(self):
+        self.test_dataset = """
+            {
+                "AD-cases-controls-MyersGeno": "Geno",
+                "AD-cases-controls-MyersPublish": "Publish",
+                "AKXDGeno": "Geno",
+                "AXBXAGeno": "Geno",
+                "AXBXAPublish": "Publish",
+                "Aging-Brain-UCIPublish": "Publish",
+                "All Phenotypes": "Publish",
+                "B139_K_1206_M": "ProbeSet",
+                "B139_K_1206_R": "ProbeSet"
+            }
+            """
+        self.app_context = app.app_context()
+        self.app_context.push()
+
+    def tearDown(self):
+        self.app_context.pop()
+
+    @mock.patch('base.data_set.g')
+    def test_data_set_type(self, db_mock):
+        """Test that DatasetType returns correctly if the Redis Instance is not empty
+        and the name variable exists in the dictionary
+
+        """
+        with app.app_context():
+            db_mock.get = mock.Mock()
+            redis_mock = mock.Mock()
+            redis_mock.get.return_value = self.test_dataset
+            self.assertEqual(DatasetType(redis_mock)
+                             ("All Phenotypes"), "Publish")
+            redis_mock.get.assert_called_once_with("dataset_structure")
+
+    @mock.patch('base.data_set.requests.get')
+    def test_data_set_type_with_empty_redis(self, request_mock):
+        """Test that DatasetType returns correctly if the Redis Instance is empty and
+        the name variable exists in the dictionary
+
+        """
+        with app.app_context():
+            request_mock.return_value.content = gen_menu_json
+            redis_mock = mock.Mock()
+            redis_mock.get.return_value = None
+            data_set = DatasetType(redis_mock)
+            self.assertEqual(data_set("BXDGeno"), "Geno")
+            self.assertEqual(data_set("BXDPublish"), "Publish")
+            self.assertEqual(data_set("HLC_0311"), "ProbeSet")
+            redis_mock.set.assert_called_once_with(
+                "dataset_structure",
+                '{"BXDGeno": "Geno", "BXDPublish": "Publish", "HLCPublish": "Publish", "HLC_0311": "ProbeSet", "HC_M2_0606_P": "ProbeSet"}')
+
+    @mock.patch('base.data_set.g')
+    def test_set_dataset_key_mrna(self, db_mock):
+        with app.app_context():
+            db_mock.db.execute.return_value = [1, 2, 3]
+            redis_mock = mock.Mock()
+            redis_mock.get.return_value = self.test_dataset
+            data_set = DatasetType(redis_mock)
+            data_set.set_dataset_key("mrna_expr", "Test")
+            self.assertEqual(data_set("Test"), "ProbeSet")
+            redis_mock.set.assert_called_once_with(
+                "dataset_structure",
+                '{"Aging-Brain-UCIPublish": "Publish", "AKXDGeno": "Geno", "B139_K_1206_M": "ProbeSet", "AD-cases-controls-MyersGeno": "Geno", "AD-cases-controls-MyersPublish": "Publish", "All Phenotypes": "Publish", "Test": "ProbeSet", "AXBXAPublish": "Publish", "B139_K_1206_R": "ProbeSet", "AXBXAGeno": "Geno"}')
+            expected_db_call = """"""
+            db_mock.db.execute.assert_called_with(
+                ("SELECT ProbeSetFreeze.Id FROM ProbeSetFreeze " +
+                 "WHERE ProbeSetFreeze.Name = \"Test\" ")
+            )
+
+    @mock.patch('base.data_set.g')
+    def test_set_dataset_key_pheno(self, db_mock):
+        with app.app_context():
+            db_mock.db.execute.return_value = [1, 2, 3]
+            redis_mock = mock.Mock()
+            redis_mock.get.return_value = self.test_dataset
+            data_set = DatasetType(redis_mock)
+            data_set.set_dataset_key("pheno", "Test")
+            self.assertEqual(data_set("Test"), "Publish")
+            redis_mock.set.assert_called_once_with(
+                "dataset_structure",
+                '{"Aging-Brain-UCIPublish": "Publish", "AKXDGeno": "Geno", "B139_K_1206_M": "ProbeSet", "AD-cases-controls-MyersGeno": "Geno", "AD-cases-controls-MyersPublish": "Publish", "All Phenotypes": "Publish", "Test": "Publish", "AXBXAPublish": "Publish", "B139_K_1206_R": "ProbeSet", "AXBXAGeno": "Geno"}')
+            expected_db_call = """"""
+            db_mock.db.execute.assert_called_with(
+                ("SELECT InfoFiles.GN_AccesionId " +
+                 "FROM InfoFiles, PublishFreeze, InbredSet " +
+                 "WHERE InbredSet.Name = 'Test' AND "
+                 "PublishFreeze.InbredSetId = InbredSet.Id AND " +
+                 "InfoFiles.InfoPageName = PublishFreeze.Name")
+            )
+
+    @mock.patch('base.data_set.g')
+    def test_set_dataset_other_pheno(self, db_mock):
+        with app.app_context():
+            db_mock.db.execute.return_value = [1, 2, 3]
+            redis_mock = mock.Mock()
+            redis_mock.get.return_value = self.test_dataset
+            data_set = DatasetType(redis_mock)
+            data_set.set_dataset_key("other_pheno", "Test")
+            self.assertEqual(data_set("Test"), "Publish")
+            redis_mock.set.assert_called_once_with(
+                "dataset_structure",
+                '{"Aging-Brain-UCIPublish": "Publish", "AKXDGeno": "Geno", "B139_K_1206_M": "ProbeSet", "AD-cases-controls-MyersGeno": "Geno", "AD-cases-controls-MyersPublish": "Publish", "All Phenotypes": "Publish", "Test": "Publish", "AXBXAPublish": "Publish", "B139_K_1206_R": "ProbeSet", "AXBXAGeno": "Geno"}')
+            expected_db_call = """"""
+            db_mock.db.execute.assert_called_with(
+                ("SELECT PublishFreeze.Name " +
+                 "FROM PublishFreeze, InbredSet " +
+                 "WHERE InbredSet.Name = 'Test' AND "
+                 "PublishFreeze.InbredSetId = InbredSet.Id")
+            )
+
+    @mock.patch('base.data_set.g')
+    def test_set_dataset_geno(self, db_mock):
+        with app.app_context():
+            db_mock.db.execute.return_value = [1, 2, 3]
+            redis_mock = mock.Mock()
+            redis_mock.get.return_value = self.test_dataset
+            data_set = DatasetType(redis_mock)
+            data_set.set_dataset_key("geno", "Test")
+            self.assertEqual(data_set("Test"), "Geno")
+            redis_mock.set.assert_called_once_with(
+                "dataset_structure",
+                '{"Aging-Brain-UCIPublish": "Publish", "AKXDGeno": "Geno", "B139_K_1206_M": "ProbeSet", "AD-cases-controls-MyersGeno": "Geno", "AD-cases-controls-MyersPublish": "Publish", "All Phenotypes": "Publish", "Test": "Geno", "AXBXAPublish": "Publish", "B139_K_1206_R": "ProbeSet", "AXBXAGeno": "Geno"}')
+            expected_db_call = """"""
+            db_mock.db.execute.assert_called_with(
+                ("SELECT GenoFreeze.Id FROM GenoFreeze WHERE GenoFreeze.Name = \"Test\" ")
+            )
diff --git a/wqflask/tests/base/test_general_object.py b/wqflask/tests/base/test_general_object.py
new file mode 100644
index 00000000..c7701021
--- /dev/null
+++ b/wqflask/tests/base/test_general_object.py
@@ -0,0 +1,41 @@
+import unittest
+
+from base.GeneralObject import GeneralObject
+
+
+class TestGeneralObjectTests(unittest.TestCase):
+    """
+    Test the GeneralObject base class
+    """
+
+    def test_object_contents(self):
+        """Test whether base contents are stored properly"""
+        test_obj = GeneralObject("a", "b", "c")
+        self.assertEqual("abc", ''.join(test_obj.contents))
+        self.assertEqual(len(test_obj), 0)
+
+    def test_object_dict(self):
+        """Test whether the base class is printed properly"""
+        test_obj = GeneralObject("a", name="test", value=1)
+        self.assertEqual(str(test_obj), "value = 1\nname = test\n")
+        self.assertEqual(
+            repr(test_obj), "value = 1\nname = test\ncontents = ['a']\n")
+        self.assertEqual(len(test_obj), 2)
+        self.assertEqual(test_obj["value"], 1)
+        test_obj["test"] = 1
+        self.assertEqual(test_obj["test"], 1)
+
+    def test_get_attribute(self):
+        "Test that getattr works"
+        test_obj = GeneralObject("a", name="test", value=1)
+        self.assertEqual(getattr(test_obj, "value", None), 1)
+        self.assertEqual(getattr(test_obj, "non-existent", None), None)
+
+    def test_object_comparisons(self):
+        "Test that 2 objects of the same length are equal"
+        test_obj1 = GeneralObject("a", name="test", value=1)
+        test_obj2 = GeneralObject("b", name="test2", value=2)
+        test_obj3 = GeneralObject("a", name="test", x=1, y=2)
+        self.assertTrue(test_obj1 == test_obj2 )
+        self.assertFalse(test_obj1 == test_obj3 )
+
diff --git a/wqflask/tests/base/test_webqtl_case_data.py b/wqflask/tests/base/test_webqtl_case_data.py
new file mode 100644
index 00000000..8e8ba482
--- /dev/null
+++ b/wqflask/tests/base/test_webqtl_case_data.py
@@ -0,0 +1,39 @@
+"""Tests for wqflask/base/webqtlCaseData.py"""
+import unittest
+
+from wqflask import app  # Required because of utility.tools in webqtlCaseData.py
+from base.webqtlCaseData import webqtlCaseData
+
+class TestWebqtlCaseData(unittest.TestCase):
+    """Tests for WebqtlCaseData class"""
+
+    def setUp(self):
+        self.w = webqtlCaseData(name="Test",
+                           value=0,
+                           variance=0.0,
+                           num_cases=10,
+                           name2="Test2")
+
+    def test_webqtl_case_data_repr(self):
+        self.assertEqual(
+            repr(self.w),
+            "<webqtlCaseData> value=0.000 variance=0.000 ndata=10 name=Test name2=Test2"
+        )
+
+    def test_class_outlier(self):
+        self.assertEqual(self.w.class_outlier, "")
+
+    def test_display_value(self):
+        self.assertEqual(self.w.display_value, "0.000")
+        self.w.value = None
+        self.assertEqual(self.w.display_value, "x")
+
+    def test_display_variance(self):
+        self.assertEqual(self.w.display_variance, "0.000")
+        self.w.variance = None
+        self.assertEqual(self.w.display_variance, "x")
+
+    def test_display_num_cases(self):
+        self.assertEqual(self.w.display_num_cases, "10")
+        self.w.num_cases = None
+        self.assertEqual(self.w.display_num_cases, "x")
diff --git a/wqflask/tests/utility/__init__.py b/wqflask/tests/utility/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/wqflask/tests/utility/__init__.py
diff --git a/wqflask/tests/utility/test_chunks.py b/wqflask/tests/utility/test_chunks.py
new file mode 100644
index 00000000..8d90a1ec
--- /dev/null
+++ b/wqflask/tests/utility/test_chunks.py
@@ -0,0 +1,19 @@
+"""Test chunking"""
+
+import unittest
+
+from utility.chunks import divide_into_chunks
+
+
+class TestChunks(unittest.TestCase):
+    "Test Utility method for chunking"
+    def test_divide_into_chunks(self):
+        "Check that a list is chunked correctly"
+        self.assertEqual(divide_into_chunks([1, 2, 7, 3, 22, 8, 5, 22, 333], 3),
+                         [[1, 2, 7], [3, 22, 8], [5, 22, 333]])
+        self.assertEqual(divide_into_chunks([1, 2, 7, 3, 22, 8, 5, 22, 333], 4),
+                         [[1, 2, 7], [3, 22, 8], [5, 22, 333]])
+        self.assertEqual(divide_into_chunks([1, 2, 7, 3, 22, 8, 5, 22, 333], 5),
+                         [[1, 2], [7, 3], [22, 8], [5, 22], [333]])
+        self.assertEqual(divide_into_chunks([], 5),
+                         [[]])
diff --git a/wqflask/tests/utility/test_corestats.py b/wqflask/tests/utility/test_corestats.py
new file mode 100644
index 00000000..cf91a248
--- /dev/null
+++ b/wqflask/tests/utility/test_corestats.py
@@ -0,0 +1,55 @@
+"""Test Core Stats"""
+
+import unittest
+
+from utility.corestats import Stats
+
+
+class TestChunks(unittest.TestCase):
+    "Test Utility method for chunking"
+
+    def setUp(self):
+        self.stat_test = Stats((x for x in range(1, 11)))
+
+    def test_stats_sum(self):
+        """ Test sequence sum """
+        self.assertEqual(self.stat_test.sum(), 55)
+        self.stat_test = Stats([])
+        self.assertEqual(self.stat_test.sum(), None)
+
+    def test_stats_count(self):
+        """ Test sequence count """
+        self.assertEqual(self.stat_test.count(), 10)
+        self.stat_test = Stats([])
+        self.assertEqual(self.stat_test.count(), 0)
+
+    def test_stats_min(self):
+        """ Test min value in sequence"""
+        self.assertEqual(self.stat_test.min(), 1)
+        self.stat_test = Stats([])
+        self.assertEqual(self.stat_test.min(), None)
+
+    def test_stats_max(self):
+        """ Test max value in sequence """
+        self.assertEqual(self.stat_test.max(), 10)
+        self.stat_test = Stats([])
+        self.assertEqual(self.stat_test.max(), None)
+
+    def test_stats_avg(self):
+        """ Test avg of sequence """
+        self.assertEqual(self.stat_test.avg(), 5.5)
+        self.stat_test = Stats([])
+        self.assertEqual(self.stat_test.avg(), None)
+
+    def test_stats_stdev(self):
+        """ Test standard deviation of sequence """
+        self.assertEqual(self.stat_test.stdev(), 3.0276503540974917)
+        self.stat_test = Stats([])
+        self.assertEqual(self.stat_test.stdev(), None)
+
+    def test_stats_percentile(self):
+        """ Test percentile of sequence """
+        self.assertEqual(self.stat_test.percentile(20), 3.0)
+        self.assertEqual(self.stat_test.percentile(101), None)
+        self.stat_test = Stats([])
+        self.assertEqual(self.stat_test.percentile(20), None)
diff --git a/wqflask/tests/utility/test_corr_result_helpers.py b/wqflask/tests/utility/test_corr_result_helpers.py
new file mode 100644
index 00000000..e196fbdf
--- /dev/null
+++ b/wqflask/tests/utility/test_corr_result_helpers.py
@@ -0,0 +1,32 @@
+""" Test correlation helper methods """
+
+import unittest
+from utility.corr_result_helpers import normalize_values, common_keys, normalize_values_with_samples
+
+
+class TestCorrelationHelpers(unittest.TestCase):
+    """Test methods for normalising lists"""
+
+    def test_normalize_values(self):
+        """Test that a list is normalised correctly"""
+        self.assertEqual(
+            normalize_values([2.3, None, None, 3.2, 4.1, 5], [
+                             3.4, 7.2, 1.3, None, 6.2, 4.1]),
+            ([2.3, 4.1, 5], [3.4, 6.2, 4.1], 3)
+        )
+
+    def test_common_keys(self):
+        """Test that common keys are returned as a list"""
+        a = dict(BXD1=9.113, BXD2=9.825, BXD14=8.985, BXD15=9.300)
+        b = dict(BXD1=9.723, BXD3=9.825, BXD14=9.124, BXD16=9.300)
+        self.assertEqual(sorted(common_keys(a, b)), ['BXD1', 'BXD14'])
+
+    def test_normalize_values_with_samples(self):
+        """Test that a sample(dict) is normalised correctly"""
+        self.assertEqual(
+            normalize_values_with_samples(
+                dict(BXD1=9.113, BXD2=9.825, BXD14=8.985,
+                     BXD15=9.300, BXD20=9.300),
+                dict(BXD1=9.723, BXD3=9.825, BXD14=9.124, BXD16=9.300)),
+            (({'BXD1': 9.113, 'BXD14': 8.985}, {'BXD1': 9.723, 'BXD14': 9.124}, 2))
+        )
diff --git a/wqflask/tests/utility/test_formatting.py b/wqflask/tests/utility/test_formatting.py
new file mode 100644
index 00000000..9d3033d1
--- /dev/null
+++ b/wqflask/tests/utility/test_formatting.py
@@ -0,0 +1,33 @@
+import unittest
+from utility.formatting import numify, commify
+
+
+class TestFormatting(unittest.TestCase):
+    """Test formatting numbers by numifying or commifying"""
+
+    def test_numify(self):
+        "Test that a number is correctly converted to a English readable string"
+        self.assertEqual(numify(1, 'item', 'items'),
+                         'one item')
+        self.assertEqual(numify(2, 'book'), 'two')
+        self.assertEqual(numify(2, 'book', 'books'), 'two books')
+        self.assertEqual(numify(0, 'book', 'books'), 'zero books')
+        self.assertEqual(numify(0), 'zero')
+        self.assertEqual(numify(5), 'five')
+        self.assertEqual(numify(14, 'book', 'books'), '14 books')
+        self.assertEqual(numify(999, 'book', 'books'), '999 books')
+        self.assertEqual(numify(1000000, 'book', 'books'), '1,000,000 books')
+        self.assertEqual(numify(1956), '1956')
+
+    def test_commify(self):
+        "Test that commas are added correctly"
+        self.assertEqual(commify(1), '1')
+        self.assertEqual(commify(123), '123')
+        self.assertEqual(commify(1234), '1234')
+        self.assertEqual(commify(12345), '12,345')
+        self.assertEqual(commify(1234567890), '1,234,567,890')
+        self.assertEqual(commify(123.0), '123.0')
+        self.assertEqual(commify(1234.5), '1234.5')
+        self.assertEqual(commify(1234.56789), '1234.56789')
+        self.assertEqual(commify(123456.789), '123,456.789')
+        self.assertEqual(commify(None), None)
diff --git a/wqflask/tests/wqflask/__init__.py b/wqflask/tests/wqflask/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/wqflask/tests/wqflask/__init__.py
diff --git a/wqflask/tests/wqflask/api/__init__.py b/wqflask/tests/wqflask/api/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/wqflask/tests/wqflask/api/__init__.py
diff --git a/wqflask/tests/wqflask/api/test_gen_menu.py b/wqflask/tests/wqflask/api/test_gen_menu.py
new file mode 100644
index 00000000..239484aa
--- /dev/null
+++ b/wqflask/tests/wqflask/api/test_gen_menu.py
@@ -0,0 +1,407 @@
+"""Test cases for wqflask.api.gen_menu"""
+import unittest
+import mock
+
+from wqflask.api.gen_menu import gen_dropdown_json
+from wqflask.api.gen_menu import get_species
+from wqflask.api.gen_menu import get_groups
+from wqflask.api.gen_menu import get_types
+from wqflask.api.gen_menu import get_datasets
+from wqflask.api.gen_menu import phenotypes_exist
+from wqflask.api.gen_menu import genotypes_exist
+from wqflask.api.gen_menu import build_datasets
+from wqflask.api.gen_menu import build_types
+
+
+class TestGenMenu(unittest.TestCase):
+    """Tests for the gen_menu module"""
+
+    def setUp(self):
+        self.test_group = {
+            'mouse': [
+                ['H_T1',
+                 'H_T',
+                 'Family:DescriptionA'
+                 ],
+                ['H_T2', "H_T'", 'Family:None']
+            ],
+            'human': [
+                ['BXD', 'BXD', 'Family:None'],
+                ['HLC', 'Liver: Normal Gene Expression with Genotypes (Merck)',
+                 'Family:Test']
+            ]
+        }
+
+        self.test_type = {
+            'mouse': {
+                'H_T2': [('Phenotypes',
+                          'Traits and Cofactors',
+                          'Phenotypes'),
+                         ('Genotypes',
+                          'DNA Markers and SNPs',
+                          'Genotypes'),
+                         ['M', 'M', 'Molecular Trait Datasets']],
+                'H_T1': [('Phenotypes',
+                          'Traits and Cofactors',
+                          'Phenotypes'),
+                         ('Genotypes',
+                          'DNA Markers and SNPs',
+                          'Genotypes'),
+                         ['M', 'M', 'Molecular Trait Datasets']]
+            },
+            'human': {
+                'HLC': [('Phenotypes',
+                         'Traits and Cofactors',
+                         'Phenotypes'),
+                        ('Genotypes',
+                         'DNA Markers and SNPs',
+                         'Genotypes'),
+                        ['M', 'M', 'Molecular Trait Datasets']],
+                'BXD': [('Phenotypes',
+                         'Traits and Cofactors',
+                         'Phenotypes'),
+                        ('Genotypes',
+                         'DNA Markers and SNPs',
+                         'Genotypes'),
+                        ['M', 'M', 'Molecular Trait Datasets']]
+            }
+        }
+
+    @mock.patch('wqflask.api.gen_menu.g')
+    def test_get_species(self, db_mock):
+        """Test that assertion is raised when dataset and dataset_name
+        are defined"""
+        db_mock.db.execute.return_value.fetchall.return_value = (
+            ('human', 'Human'),
+            ('mouse', 'Mouse'))
+        self.assertEqual(get_species(),
+                         [['human', 'Human'], ['mouse', 'Mouse']])
+        db_mock.db.execute.assert_called_once_with(
+            "SELECT Name, MenuName FROM Species ORDER BY OrderId"
+        )
+
+    @mock.patch('wqflask.api.gen_menu.g')
+    def test_get_groups(self, db_mock):
+        """Test that species groups are grouped correctly"""
+        db_mock.db.execute.return_value.fetchall.side_effect = [
+            # Mouse
+            (('BXD', 'BXD', None),
+             ('HLC', 'Liver: Normal Gene Expression with Genotypes (Merck)',
+              'Test')),
+            # Human
+            (('H_T1', "H_T", "DescriptionA"),
+             ('H_T2', "H_T'", None))
+        ]
+
+        self.assertEqual(get_groups([["human", "Human"], ["mouse", "Mouse"]]),
+                         self.test_group)
+
+        for name in ["mouse", "human"]:
+            db_mock.db.execute.assert_any_call(
+                ("SELECT InbredSet.Name, InbredSet.FullName, " +
+                 "IFNULL(InbredSet.Family, 'None') " +
+                 "FROM InbredSet, Species WHERE Species.Name " +
+                 "= '{}' AND InbredSet.SpeciesId = Species.Id GROUP by " +
+                 "InbredSet.Name ORDER BY IFNULL(InbredSet.FamilyOrder, " +
+                 "InbredSet.FullName) ASC, IFNULL(InbredSet.Family, " +
+                 "InbredSet.FullName) ASC, InbredSet.FullName ASC, " +
+                 "InbredSet.MenuOrderId ASC").format(name)
+            )
+
+    @mock.patch('wqflask.api.gen_menu.g')
+    def test_phenotypes_exist_called_with_correct_query(self, db_mock):
+        """Test that phenotypes_exist is called with the correct query"""
+        db_mock.db.execute.return_value.fetchone.return_value = None
+        phenotypes_exist("test")
+        db_mock.db.execute.assert_called_with(
+            "SELECT Name FROM PublishFreeze "
+            "WHERE PublishFreeze.Name = 'testPublish'"
+        )
+
+    @mock.patch('wqflask.api.gen_menu.g')
+    def test_phenotypes_exist_with_falsy_values(self, db_mock):
+        """Test that phenotype check returns correctly when given
+        a None value"""
+        for x in [None, False, (), [], ""]:
+            db_mock.db.execute.return_value.fetchone.return_value = x
+            self.assertFalse(phenotypes_exist("test"))
+
+    @mock.patch('wqflask.api.gen_menu.g')
+    def test_phenotypes_exist_with_truthy_value(self, db_mock):
+        """Test that phenotype check returns correctly when given Truthy """
+        for x in ["x", ("result"), ["result"], [1]]:
+            db_mock.db.execute.return_value.fetchone.return_value = (x)
+            self.assertTrue(phenotypes_exist("test"))
+
+    @mock.patch('wqflask.api.gen_menu.g')
+    def test_genotypes_exist_called_with_correct_query(self, db_mock):
+        """Test that genotypes_exist is called with the correct query"""
+        db_mock.db.execute.return_value.fetchone.return_value = None
+        genotypes_exist("test")
+        db_mock.db.execute.assert_called_with(
+            "SELECT Name FROM GenoFreeze WHERE GenoFreeze.Name = 'testGeno'"
+        )
+
+    @mock.patch('wqflask.api.gen_menu.g')
+    def test_genotypes_exist_with_falsy_values(self, db_mock):
+        """Test that genotype check returns correctly when given
+        a None value"""
+        for x in [None, False, (), [], ""]:
+            db_mock.db.execute.return_value.fetchone.return_value = x
+            self.assertFalse(genotypes_exist("test"))
+
+    @mock.patch('wqflask.api.gen_menu.g')
+    def test_genotypes_exist_with_truthy_value(self, db_mock):
+        """Test that genotype check returns correctly when given Truthy """
+        for x in ["x", ("result"), ["result"], [1]]:
+            db_mock.db.execute.return_value.fetchone.return_value = (x)
+            self.assertTrue(phenotypes_exist("test"))
+
+    @mock.patch('wqflask.api.gen_menu.g')
+    def test_build_datasets_with_type_phenotypes(self, db_mock):
+        """Test that correct dataset is returned for a phenotype type"""
+        db_mock.db.execute.return_value.fetchall.return_value = (
+            (602, "BXDPublish", "BXD Published Phenotypes"),
+        )
+        self.assertEqual(build_datasets("Mouse", "BXD", "Phenotypes"),
+                         [['602', "BXDPublish", "BXD Published Phenotypes"]])
+        db_mock.db.execute.assert_called_with(
+            "SELECT InfoFiles.GN_AccesionId, PublishFreeze.Name, " +
+            "PublishFreeze.FullName FROM InfoFiles, PublishFreeze, " +
+            "InbredSet WHERE InbredSet.Name = 'BXD' AND " +
+            "PublishFreeze.InbredSetId = InbredSet.Id AND " +
+            "InfoFiles.InfoPageName = PublishFreeze.Name " +
+            "ORDER BY PublishFreeze.CreateTime ASC"
+        )
+        self.assertEqual(build_datasets("Mouse", "MDP", "Phenotypes"),
+                         [['602', "BXDPublish", "Mouse Phenome Database"]])
+
+        db_mock.db.execute.return_value.fetchall.return_value = ()
+        db_mock.db.execute.return_value.fetchone.return_value = (
+            "BXDPublish", "Mouse Phenome Database"
+        )
+        self.assertEqual(build_datasets("Mouse", "MDP", "Phenotypes"),
+                         [["None", "BXDPublish", "Mouse Phenome Database"]])
+
+    @mock.patch('wqflask.api.gen_menu.g')
+    def test_build_datasets_with_type_phenotypes_and_no_results(self, db_mock):
+        """Test that correct dataset is returned for a phenotype type with no
+        results
+
+        """
+        db_mock.db.execute.return_value.fetchall.return_value = None
+        db_mock.db.execute.return_value.fetchone.return_value = (121,
+                                                                 "text value")
+        self.assertEqual(build_datasets("Mouse", "BXD", "Phenotypes"),
+                         [["None", "121", "text value"]])
+        db_mock.db.execute.assert_called_with(
+            "SELECT PublishFreeze.Name, PublishFreeze.FullName "
+            "FROM PublishFreeze, InbredSet "
+            "WHERE InbredSet.Name = 'BXD' AND "
+            "PublishFreeze.InbredSetId = InbredSet.Id "
+            "ORDER BY PublishFreeze.CreateTime ASC"
+        )
+
+    @mock.patch('wqflask.api.gen_menu.g')
+    def test_build_datasets_with_type_genotypes(self, db_mock):
+        """Test that correct dataset is returned for a phenotype type"""
+        db_mock.db.execute.return_value.fetchone.return_value = (
+            635, "HLCPublish", "HLC Published Genotypes"
+        )
+
+        self.assertEqual(build_datasets("Mouse", "HLC", "Genotypes"),
+                         [["635", "HLCGeno", "HLC Genotypes"]])
+        db_mock.db.execute.assert_called_with(
+            "SELECT InfoFiles.GN_AccesionId FROM InfoFiles, "
+            "GenoFreeze, InbredSet WHERE InbredSet.Name = 'HLC' AND "
+            "GenoFreeze.InbredSetId = InbredSet.Id AND "
+            "InfoFiles.InfoPageName = GenoFreeze.ShortName " +
+            "ORDER BY GenoFreeze.CreateTime DESC"
+        )
+        db_mock.db.execute.return_value.fetchone.return_value = ()
+        self.assertEqual(build_datasets("Mouse", "HLC", "Genotypes"),
+                         [["None", "HLCGeno", "HLC Genotypes"]])
+
+    @mock.patch('wqflask.api.gen_menu.g')
+    def test_build_datasets_with_type_mrna(self, db_mock):
+        """Test that correct dataset is returned for a mRNA
+        expression/ Probeset"""
+        db_mock.db.execute.return_value.fetchall.return_value = (
+            (112, "HC_M2_0606_P",
+             "Hippocampus Consortium M430v2 (Jun06) PDNN"), )
+        self.assertEqual(build_datasets("Mouse", "HLC", "mRNA"), [[
+            "112", 'HC_M2_0606_P', "Hippocampus Consortium M430v2 (Jun06) PDNN"
+        ]])
+        db_mock.db.execute.assert_called_once_with(
+            "SELECT ProbeSetFreeze.Id, ProbeSetFreeze.Name, " +
+            "ProbeSetFreeze.FullName FROM ProbeSetFreeze, " +
+            "ProbeFreeze, InbredSet, Tissue, Species WHERE " +
+            "Species.Name = 'Mouse' AND Species.Id = " +
+            "InbredSet.SpeciesId AND InbredSet.Name = 'HLC' AND " +
+            "ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id and " +
+            "Tissue.Name = 'mRNA' AND ProbeFreeze.TissueId = " +
+            "Tissue.Id and ProbeFreeze.InbredSetId = InbredSet.Id " +
+            "ORDER BY ProbeSetFreeze.CreateTime DESC")
+
+    @mock.patch('wqflask.api.gen_menu.build_datasets')
+    @mock.patch('wqflask.api.gen_menu.g')
+    def test_build_types(self, db_mock, datasets_mock):
+        """Test that correct tissue metadata is returned"""
+        datasets_mock.return_value = [
+            ["112", 'HC_M2_0606_P',
+                "Hippocampus Consortium M430v2 (Jun06) PDNN"]
+        ]
+        db_mock.db.execute.return_value.fetchall.return_value = (
+            ('Mouse Tissue'), ('Human Tissue'), ('Rat Tissue')
+        )
+        self.assertEqual(build_types('mouse', 'random group'),
+                         [['M', 'M', 'Molecular Traits'],
+                          ['H', 'H', 'Molecular Traits'],
+                          ['R', 'R', 'Molecular Traits']])
+        db_mock.db.execute.assert_called_once_with(
+            "SELECT DISTINCT Tissue.Name " +
+            "FROM ProbeFreeze, ProbeSetFreeze, InbredSet, " +
+            "Tissue, Species WHERE Species.Name = 'mouse' " +
+            "AND Species.Id = InbredSet.SpeciesId AND " +
+            "InbredSet.Name = 'random group' AND " +
+            "ProbeFreeze.TissueId = Tissue.Id AND " +
+            "ProbeFreeze.InbredSetId = InbredSet.Id AND " +
+            "ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id " +
+            "ORDER BY Tissue.Name"
+        )
+
+    @mock.patch('wqflask.api.gen_menu.build_types')
+    @mock.patch('wqflask.api.gen_menu.genotypes_exist')
+    @mock.patch('wqflask.api.gen_menu.phenotypes_exist')
+    def test_get_types_with_existing_genotype_and_phenotypes(
+            self,
+            phenotypes_exist_mock,
+            genotypes_exist_mock,
+            build_types_mock):
+        """Test that build types are constructed correctly if phenotypes and genotypes
+        exist
+
+        """
+        phenotypes_exist_mock.return_value = True
+        genotypes_exist_mock.return_value = True
+
+        expected_result = self.test_type
+
+        build_types_mock.return_value = [
+            ['M', 'M', 'Molecular Trait Datasets']
+        ]
+        self.assertEqual(get_types(self.test_group), expected_result)
+
+    @mock.patch('wqflask.api.gen_menu.build_types')
+    @mock.patch('wqflask.api.gen_menu.genotypes_exist')
+    @mock.patch('wqflask.api.gen_menu.phenotypes_exist')
+    def test_get_types_with_buildtype_and_non_existent_genotype_and_phenotypes(
+            self,
+            phenotypes_exist_mock,
+            genotypes_exist_mock,
+            build_types_mock):
+        """Test that build types are constructed correctly if phenotypes_exist and
+        genotypes_exist are false but build_type is falsy
+
+        """
+        phenotypes_exist_mock.return_value = False
+        genotypes_exist_mock.return_value = False
+
+        build_types_mock.return_value = []
+        self.assertEqual(get_types(self.test_group), {
+            'mouse': {},
+            'human': {}
+        })
+
+    @mock.patch('wqflask.api.gen_menu.build_types')
+    @mock.patch('wqflask.api.gen_menu.genotypes_exist')
+    @mock.patch('wqflask.api.gen_menu.phenotypes_exist')
+    def test_get_types_with_non_existent_genotype_phenotypes_and_buildtype(
+            self,
+            phenotypes_exist_mock,
+            genotypes_exist_mock,
+            build_types_mock):
+        """Test that build types are constructed correctly if phenotypes_exist,
+        genotypes_exist and build_types are truthy
+
+        """
+        phenotypes_exist_mock.return_value = False
+        genotypes_exist_mock.return_value = False
+
+        build_types_mock.return_value = [
+            ['M', 'M', 'Molecular Trait Datasets']
+        ]
+        expected_result = {
+            'mouse': {
+                'H_T2': [['M', 'M', 'Molecular Trait Datasets']],
+                'H_T1': [['M', 'M', 'Molecular Trait Datasets']]},
+            'human': {
+                'HLC': [['M', 'M', 'Molecular Trait Datasets']],
+                'BXD': [['M', 'M', 'Molecular Trait Datasets']]}}
+        self.assertEqual(get_types(self.test_group),
+                         expected_result)
+
+    @mock.patch('wqflask.api.gen_menu.build_datasets')
+    def test_get_datasets_with_existent_datasets(self,
+                                                 build_datasets_mock):
+        """Test correct dataset is returned with existent build_datasets"""
+        build_datasets_mock.return_value = "Test"
+        expected_result = {
+            'mouse': {
+                'H_T2': {'Genotypes': 'Test',
+                         'M': 'Test',
+                         'Phenotypes': 'Test'},
+                'H_T1': {'Genotypes': 'Test',
+                         'M': 'Test',
+                         'Phenotypes': 'Test'}},
+            'human': {'HLC': {'Genotypes': 'Test',
+                              'M': 'Test',
+                              'Phenotypes': 'Test'},
+                      'BXD': {'Genotypes': 'Test',
+                              'M': 'Test',
+                              'Phenotypes': 'Test'}}}
+        self.assertEqual(get_datasets(self.test_type),
+                         expected_result)
+
+    @mock.patch('wqflask.api.gen_menu.build_datasets')
+    def test_get_datasets_with_non_existent_datasets(self,
+                                                     build_datasets_mock):
+        """Test correct dataset is returned with non-existent build_datasets"""
+        build_datasets_mock.return_value = None
+        expected_result = {
+            'mouse': {
+                'H_T2': {},
+                'H_T1': {}},
+            'human': {'HLC': {},
+                      'BXD': {}}}
+        self.assertEqual(get_datasets(self.test_type),
+                         expected_result)
+
+    @mock.patch('wqflask.api.gen_menu.get_datasets')
+    @mock.patch('wqflask.api.gen_menu.get_types')
+    @mock.patch('wqflask.api.gen_menu.get_groups')
+    @mock.patch('wqflask.api.gen_menu.get_species')
+    def test_gen_dropdown_json(self,
+                               species_mock,
+                               groups_mock,
+                               types_mock,
+                               datasets_mock):
+        "Test that the correct dictionary is constructed properly"
+        species_mock.return_value = ("speciesA speciesB speciesC speciesD"
+                                     .split(" "))
+        datasets_mock.return_value = ("datasetA datasetB datasetC datasetD"
+                                      .split(" "))
+        groups_mock.return_value = ("groupA groupB groupC groupD"
+                                    .split(" "))
+        types_mock.return_value = ("typeA typeB typeC typeD"
+                                   .split(" "))
+        datasets_mock.return_value = ("datasetA datasetB datasetC datasetD"
+                                      .split(" "))
+
+        expected_result = {
+            'datasets': ['datasetA', 'datasetB', 'datasetC', 'datasetD'],
+            'types': ['typeA', 'typeB', 'typeC', 'typeD'],
+            'groups': ['groupA', 'groupB', 'groupC', 'groupD'],
+            'species': ['speciesA', 'speciesB', 'speciesC', 'speciesD']}
+
+        self.assertEqual(gen_dropdown_json(), expected_result)
diff --git a/wqflask/tests/wqflask/marker_regression/__init__.py b/wqflask/tests/wqflask/marker_regression/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/wqflask/tests/wqflask/marker_regression/__init__.py
diff --git a/wqflask/tests/wqflask/marker_regression/test_display_mapping_results.py b/wqflask/tests/wqflask/marker_regression/test_display_mapping_results.py
new file mode 100644
index 00000000..6f791df1
--- /dev/null
+++ b/wqflask/tests/wqflask/marker_regression/test_display_mapping_results.py
@@ -0,0 +1,151 @@
+import unittest
+
+from htmlgen import HTMLgen2 as HT
+from wqflask.marker_regression.display_mapping_results import (
+    DisplayMappingResults,
+    HtmlGenWrapper
+)
+
+
+class TestDisplayMappingResults(unittest.TestCase):
+    """Basic Methods to test Mapping Results"""
+    def test_pil_colors(self):
+        """Test that colors use PILLOW color format"""
+        self.assertEqual(DisplayMappingResults.CLICKABLE_WEBQTL_REGION_COLOR,
+                         (245, 211, 211))
+
+
+class TestHtmlGenWrapper(unittest.TestCase):
+    """Test Wrapper around HTMLGen"""
+    def test_create_image(self):
+        """Test HT.Image method"""
+        self.assertEqual(
+            str(HtmlGenWrapper.create_image_tag(src="test.png",
+                                                alt="random",
+                                                border="0",
+                                                width="10",
+                                                height="13",
+                                                usemap="#webqtlmap")),
+            ("""<IMG src="test.png" height="13" width="10" """
+             """alt="random" border="0" """
+             """usemap="#webqtlmap">""")
+        )
+
+    def test_create_form(self):
+        """Test HT.Form method"""
+        test_form = HtmlGenWrapper.create_form_tag(
+            cgi="/testing/",
+            enctype='multipart/form-data',
+            name="formName",
+            submit=HT.Input(type='hidden')
+        )
+        test_image = HtmlGenWrapper.create_image_tag(
+            src="test.png",
+            alt="random",
+            border="0",
+            width="10",
+            height="13",
+            usemap="#webqtlmap"
+        )
+        self.assertEqual(
+            str(test_form).replace("\n", ""),
+            ("""<FORM METHOD="POST" ACTION="/testing/" """
+             """ENCTYPE="multipart/form-data" """
+             """NAME="formName"><INPUT TYPE="hidden" """
+             """NAME="Default_Name"></FORM>"""))
+        hddn = {
+            'FormID': 'showDatabase',
+            'ProbeSetID': '_',
+            'database': "TestGeno",
+            'CellID': '_',
+            'RISet': "Test",
+            'incparentsf1': 'ON'
+        }
+        for key in hddn.keys():
+            test_form.append(HT.Input(name=key, value=hddn[key],
+                                      type='hidden'))
+        test_form.append(test_image)
+        self.assertEqual(str(test_form).replace("\n", ""), (
+            """<FORM METHOD="POST" ACTION="/testing/" """
+            """ENCTYPE="multipart/form-data" NAME="formName">"""
+            """<INPUT TYPE="hidden" NAME="database" VALUE="TestGeno">"""
+            """<INPUT TYPE="hidden" NAME="incparentsf1" VALUE="ON">"""
+            """<INPUT TYPE="hidden" NAME="FormID" VALUE="showDatabase">"""
+            """<INPUT TYPE="hidden" NAME="ProbeSetID" VALUE="_">"""
+            """<INPUT TYPE="hidden" NAME="RISet" VALUE="Test">"""
+            """<INPUT TYPE="hidden" NAME="CellID" VALUE="_">"""
+            """<IMG src="test.png" height="13" width="10" alt="random" """
+            """border="0" usemap="#webqtlmap">"""
+            """<INPUT TYPE="hidden" NAME="Default_Name"></FORM>"""))
+
+    def test_create_paragraph(self):
+        """Test HT.Paragraph method"""
+        test_p_element = HtmlGenWrapper.create_p_tag(id="smallSize")
+        par_text = (
+            "Mapping using genotype data as "
+            "a trait will result in infinity LRS at one locus. "
+            "In order to display the result properly, all LRSs "
+            "higher than 100 are capped at 100."
+        )
+        self.assertEqual(
+            str(test_p_element),
+            """<P id="smallSize"></P>"""
+        )
+        test_p_element.append(HT.BR())
+        test_p_element.append(par_text)
+        self.assertEqual(
+            str(test_p_element),
+            """<P id="smallSize"><BR>{}</P>""".format(par_text)
+        )
+
+    def test_create_br_tag(self):
+        """Test HT.BR() method"""
+        self.assertEqual(str(HtmlGenWrapper.create_br_tag()),
+                         "<BR>")
+
+    def test_create_input_tag(self):
+        """Test HT.Input method"""
+        self.assertEqual(
+            str(HtmlGenWrapper.create_input_tag(
+                type="hidden",
+                name="name",
+                value="key",
+                Class="trait trait_")).replace("\n", ""),
+            ("""<INPUT TYPE="hidden" NAME="name" """
+             """class="trait trait_" VALUE="key">"""))
+
+    def test_create_map_tag(self):
+        """Test HT.Map method"""
+        self.assertEqual(str(HtmlGenWrapper.create_map_tag(
+            name="WebqTLImageMap")).replace("\n", ""),
+            """<MAP NAME="WebqTLImageMap"></MAP>""")
+        gifmap = HtmlGenWrapper.create_map_tag(areas=[])
+        gifmap.areas.append(HT.Area(shape="rect",
+                                    coords='1 2 3', href='#area1'))
+        gifmap.areas.append(HT.Area(shape="rect",
+                                    coords='1 2 3', href='#area2'))
+        self.assertEqual(
+            str(gifmap).replace("\n", ""),
+            ("""<MAP NAME="">"""
+             """<AREA coords="1 2 3" """
+             """href="#area1" shape="rect">"""
+             """<AREA coords="1 2 3" href="#area2" shape="rect">"""
+             """</MAP>"""))
+
+    def test_create_area_tag(self):
+        """Test HT.Area method"""
+        self.assertEqual(
+            str(HtmlGenWrapper.create_area_tag(
+                shape="rect",
+                coords="1 2",
+                href="http://test.com",
+                title="Some Title")).replace("\n", ""),
+            ("""<AREA coords="1 2" href="http://test.com" """
+             """shape="rect" title="Some Title">"""))
+
+    def test_create_link_tag(self):
+        """Test HT.HREF method"""
+        self.assertEqual(
+            str(HtmlGenWrapper.create_link_tag(
+                "www.test.com", "test", target="_blank")).replace("\n", ""),
+            """<A HREF="www.test.com" TARGET="_blank">test</A>""")