コード例 #1
0
    def test_threshold(self):
        threshold = 1
        with self.assertRaises(ValueError):
            tree_1, samples_1 = qtrees.get_results(self.test_df,
                                                   threshold,
                                                   index='SampleID')
        correct_depth_pt = [['test_id_sw1', 1, '3.', '3'],
                            ['test_id_nw1', 1, '1.', '1'],
                            ['test_id_ne1', 1, '2.', '2'],
                            ['test_id_se1', 1, '4.', '4'],
                            ['test_id_sw2', 1, '3.', '3'],
                            ['test_id_nw2', 1, '1.', '1'],
                            ['test_id_ne2', 1, '2.', '2'],
                            ['test_id_se2', 1, '4.', '4']]

        correct_depth_df = pd.DataFrame(
            correct_depth_pt,
            columns=['SampleID', 'depth', 'lineage', 'split-depth-1'])
        correct_depth_df = correct_depth_df.set_index('SampleID').sort_index()
        tree_, samples_4 = qtrees.get_results(self.moved_df,
                                              threshold=5,
                                              index='SampleID')
        pdt.assert_frame_equal(samples_4.sort_index(), correct_depth_df)

        tree_8, samples_8 = qtrees.get_results(self.moved_df,
                                               threshold=8,
                                               index='SampleID')
        pdt.assert_frame_equal(samples_8.sort_index(), correct_depth_df)
コード例 #2
0
    def test_boundaries(self):
        boundary_points = [['test_1', 180, 90],
                           ['test_2', 90, 90],
                           ['test_3', 180, 45],
                           ['test_4', 180, 135],
                           ['test_5', 360.0, 90.0]]

        boundary_df = pd.DataFrame(
            boundary_points,
            columns=['SampleID', 'longitude', 'latitude'])
        boundary_df = boundary_df.set_index('SampleID')

        boundary_points_2 = [['test_1', 180, 90],
                             ['test_2', 90, 90],
                             ['test_3', 180, 45],
                             ['test_4', 180, 135],
                             ['test_5', 360.0, 90.0]]

        boundary_df_2 = pd.DataFrame(
            boundary_points_2,
            columns=['SampleID', 'longitude', 'latitude'])
        boundary_df_2 = boundary_df_2.set_index('SampleID')

        tree, samples = qtrees.get_results(boundary_df, 4, index='SampleID')
        tree_2, samples_2 = qtrees.get_results(boundary_df_2, 4,
                                               index='SampleID')
        pdt.assert_frame_equal(samples_2, samples)
コード例 #3
0
 def test_trees_correct(self):
     threshold = 2
     self.clean = qtrees.clean(self.test_df, y_coord='latitude',
                               x_coord='longitude')
     test_tree, test_samples = qtrees.get_results(self.moved_df,
                                                  threshold,
                                                  index='SampleID')
     pdt.assert_frame_equal(test_samples.sort_index(),
                            self.correct_dataframe.sort_index())
     self.assertEqual(test_tree.compare_subsets(self.correct_tree), 0.0)
     self.assertEqual(test_tree.compare_rfd(self.correct_tree), 0.0)