Beispiel #1
0
 def test_skipping_with_breaks(self):
     """
     Here we skip row "one" from the analysis, simulating a previous run where promoter "one" was already used.
     We use the same set up as test_with_breaks, which means that testing stops after a set amount.
     """
     pdutil.multi_set_data_frame(self.data,
                                 (("one", "col1"), ("one", "col2"),
                                  ("one", "col3")), 1)
     self.data.at["five", "col2"] = 0
     result = [['two', ['three', ['four']]]]
     result_2 = []
     three = classes.Promoters.node_based_vencode_getter(
         self.data,
         combinations_number=3,
         skip=["one"],
         breaks=self.breaks,
         stop=1)
     three_2 = classes.Promoters.node_based_vencode_getter(
         self.data,
         combinations_number=3,
         skip=["two"],
         breaks=self.breaks,
         stop=2)
     to_assert = ((result, three), (result_2, three_2))
     for i in to_assert:
         with self.subTest(i=i):
             self.assertEqual(i[0], i[1], msg="Result not expected")
Beispiel #2
0
 def test_three_contiguous(self):
     pdutil.multi_set_data_frame(self.data,
                                 (("one", "col2"), ("one", "col3")), 1)
     self.three = classes.Promoters.node_based_vencode_getter(
         self.data, combinations_number=4)
     result = [['one', ['two', ['three']]]]
     self.assertEqual(result, self.three, msg="Result not expected")
Beispiel #3
0
 def test_one_not_first(self):
     self.data.at["one", "col1"] = 1
     pdutil.multi_set_data_frame(self.data,
                                 (("three", "col1"), ("three", "col3")), 0)
     self.one = classes.Promoters.node_based_vencode_getter(
         self.data, combinations_number=4)
     result = [["three"]]
     self.assertEqual(result, self.one, msg="Result not expected")
Beispiel #4
0
 def test_two_contiguous(self):
     pdutil.multi_set_data_frame(self.data,
                                 (("one", "col1"), ("four", "col1")), 1)
     self.data.at["two", "col1"] = 0
     self.two = classes.Promoters.node_based_vencode_getter(
         self.data, combinations_number=4)
     result = [["one", ["two"]]]
     self.assertEqual(result, self.two, msg="Result not expected")
Beispiel #5
0
 def test_four_non_contiguous(self):
     pdutil.multi_set_data_frame(self.data,
                                 (("one", "col1"), ("one", "col4"),
                                  ("four", "col4"), ("two", "col3"),
                                  ("one", "col3")), 1)
     self.four = classes.Promoters.node_based_vencode_getter(
         self.data, combinations_number=4)
     result = [['one', ['three', ['four', ['five']]]]]
     self.assertEqual(result, self.four, msg="Result not expected")
Beispiel #6
0
 def test_one_many(self):
     pdutil.multi_set_data_frame(self.data,
                                 (("three", "col1"), ("three", "col3")), 0)
     df = pd.DataFrame.from_dict({"six": [0, 0, 0, 0]}, orient="index")
     df.columns = self.data.columns
     self.data = pd.concat([self.data, df])
     self.one = classes.Promoters.node_based_vencode_getter(
         self.data, combinations_number=4)
     result = [["one", "three", "six"]]
     self.assertEqual(result, self.one, msg="Result not expected")
Beispiel #7
0
 def test_skipping(self):
     """
     Here we skip row "two" from the analysis, simulating a previous run where promoter "two" was already used.
     We use the same set up as test_three_non_contiguous.
     """
     pdutil.multi_set_data_frame(self.data,
                                 (("one", "col1"), ("one", "col4"),
                                  ("four", "col4")), 1)
     self.three = classes.Promoters.node_based_vencode_getter(
         self.data, combinations_number=4, skip=["two"])
     result = [['one', ['three', ['four']]]]
     self.assertEqual(result, self.three, msg="Result not expected")
Beispiel #8
0
 def test_with_breaks(self):
     """
     Here we test the ability of stopping the iteration short. If left unchecked, it would have found the solution:
     [['one', ['four', ['five']]]] first, but by putting a cap of value 2 in the search, node "one" will only
     search until "one + three + Any", not sufficient for a VEnCode of k=3 with this data. So, the algorithm must
     continue to node "two", then finding the below described solution.
     """
     pdutil.multi_set_data_frame(self.data,
                                 (("one", "col1"), ("one", "col2"),
                                  ("one", "col3")), 1)
     self.data.at["five", "col2"] = 0
     result = [['two', ['three', ['four']]]]
     self.with_breaks = classes.Promoters.node_based_vencode_getter(
         self.data, combinations_number=3, breaks=self.breaks, stop=2)
     self.assertEqual(result, self.with_breaks, msg="Result not expected")
Beispiel #9
0
 def test_three_non_contiguous(self):
     pdutil.multi_set_data_frame(self.data,
                                 (("one", "col1"), ("one", "col4"),
                                  ("four", "col4")), 1)
     self.three = classes.Promoters.node_based_vencode_getter(
         self.data, combinations_number=4)
     result = [['one', ['two', ['three', ['four']]]]]
     self.assertEqual(result, self.three, msg="Result not expected")
     """
     Note for this result:
     Even with a solution of a combination of 3 instead of four [['one', ['three', ['four']]]], our algorithm will 
     first find the solution of four due to searching "two" first. This, of course only happens when searching for
     combinations of up to 4. If we set the search for "k" up to 3, we then get the solution:
     [['one', ['three', ['four']]]]
     """
     self.three_new = classes.Promoters.node_based_vencode_getter(
         self.data, combinations_number=3)
     result = [['one', ['three', ['four']]]]
     self.assertEqual(result, self.three_new, msg="Result not expected")
Beispiel #10
0
 def test_threshold_zero_one_success(self):
     pdutil.multi_set_data_frame(self.test_pandas_df,
                                 (("one", "col1"), ("four", "col1")), 0.1)
     test = util.assess_vencode_one_zero_boolean(self.test_pandas_df,
                                                 threshold=0.1)
     self.assertTrue(test, msg="Result not expected")