def test_make_pathway_filter_fn_by_level(self):
        """make_pathway_filter_function functions specifying KEGG pathway cat level"""
        test_md = self.metadata_example
        #Example 1 has a top-level 'Unclassifed' annotation
        #Example 3 has a bottom-level 'Unclassified' annotation
        #Test 1.  When not specifying level, all levels should be
        #tested and examples 1 & 3 should both return True

        filter_fn = make_pathway_filter_fn(["Unclassified"],\
         metadata_key = 'KEGG_Pathways')
        exp_result = [True,False,True]
        obs_result = [filter_fn(*md) for md in test_md]
        self.assertEqual(obs_result,exp_result)

        #Test 2. When specifying level 1, only Example 1 is true
        filter_fn = make_pathway_filter_fn(["Unclassified"],\
         metadata_key = 'KEGG_Pathways',search_only_pathway_level = 1)
        exp_result = [True,False,False]
        obs_result = [filter_fn(*md) for md in test_md]
        self.assertEqual(obs_result,exp_result)

        #Test 3. When specifying level 3, only Example 3 is true
        filter_fn = make_pathway_filter_fn(["Unclassified"],\
         metadata_key = 'KEGG_Pathways',search_only_pathway_level = 3)
        exp_result = [False,False,True]
        obs_result = [filter_fn(*md) for md in test_md]
        self.assertEqual(obs_result,exp_result)
Example #2
0
    def test_make_pathway_filter_fn_by_level(self):
        """make_pathway_filter_function functions specifying KEGG pathway cat level"""
        test_md = self.metadata_example
        #Example 1 has a top-level 'Unclassifed' annotation
        #Example 3 has a bottom-level 'Unclassified' annotation
        #Test 1.  When not specifying level, all levels should be
        #tested and examples 1 & 3 should both return True

        filter_fn = make_pathway_filter_fn(["Unclassified"],\
         metadata_key = 'KEGG_Pathways')
        exp_result = [True,False,True]
        obs_result = [filter_fn(*md) for md in test_md]
        self.assertEqual(obs_result,exp_result)

        #Test 2. When specifying level 1, only Example 1 is true
        filter_fn = make_pathway_filter_fn(["Unclassified"],\
         metadata_key = 'KEGG_Pathways',search_only_pathway_level = 1)
        exp_result = [True,False,False]
        obs_result = [filter_fn(*md) for md in test_md]
        self.assertEqual(obs_result,exp_result)

        #Test 3. When specifying level 3, only Example 3 is true
        filter_fn = make_pathway_filter_fn(["Unclassified"],\
         metadata_key = 'KEGG_Pathways',search_only_pathway_level = 3)
        exp_result = [False,False,True]
        obs_result = [filter_fn(*md) for md in test_md]
        self.assertEqual(obs_result,exp_result)
Example #3
0
 def test_make_pathway_filter_fn_raises_on_bad_input(self):
     """make_pathway_filter_fn raises on invalid metadata level"""
     #No error on specifying level 1
     filter_fn = make_pathway_filter_fn(["Unclassified"],\
         metadata_key = 'KEGG_Pathways',search_only_pathway_level = 1)
     with self.assertRaises(ValueError):
         #Specifying level 0 should raise an informative error
         filter_fn = make_pathway_filter_fn(["Unclassified"],\
           metadata_key = 'KEGG_Pathways',search_only_pathway_level = 0)
 def test_make_pathway_filter_fn_raises_on_bad_input(self):
     """make_pathway_filter_fn raises on invalid metadata level"""
     #No error on specifying level 1
     filter_fn = make_pathway_filter_fn(["Unclassified"],\
         metadata_key = 'KEGG_Pathways',search_only_pathway_level = 1)
     with self.assertRaises(ValueError):
         #Specifying level 0 should raise an informative error
         filter_fn = make_pathway_filter_fn(["Unclassified"],\
           metadata_key = 'KEGG_Pathways',search_only_pathway_level = 0)
Example #5
0
    def test_make_pathway_filter_fn_KEGG(self):
        """make_pathway_filter_function functions with valid KEGG data"""
        filter_fn = make_pathway_filter_fn(["Phagosome"],\
         metadata_key = 'KEGG_Pathways')

        test_md = self.metadata_example
        exp_result = [True,True,False]
        obs_result = [filter_fn(*md) for md in test_md]
        self.assertEqual(obs_result,exp_result)
    def test_make_pathway_filter_fn_KEGG(self):
        """make_pathway_filter_function functions with valid KEGG data"""
        filter_fn = make_pathway_filter_fn(["Phagosome"],\
         metadata_key = 'KEGG_Pathways')

        test_md = self.metadata_example
        exp_result = [True,True,False]
        obs_result = [filter_fn(*md) for md in test_md]
        self.assertEqual(obs_result,exp_result)
Example #7
0
    def test_pathway_filter_fn_raises_on_bad_md_key(self):
        """make_pathway_filter_fn child fn raises informatively on invalid metadata"""

        test_md = self.metadata_example

        #Assume user misspells 'KEGG_Pathways'
        filter_fn = make_pathway_filter_fn(["Unclassified"],\
          metadata_key = 'KEGG_Pathwayssssssss')

        with self.assertRaises(ValueError):
            obs_result = [filter_fn(*md) for md in test_md]
    def test_pathway_filter_fn_raises_on_bad_md_key(self):
        """make_pathway_filter_fn child fn raises informatively on invalid metadata"""

        test_md = self.metadata_example

        #Assume user misspells 'KEGG_Pathways'
        filter_fn = make_pathway_filter_fn(["Unclassified"],\
          metadata_key = 'KEGG_Pathwayssssssss')

        with self.assertRaises(ValueError):
            obs_result = [filter_fn(*md) for md in test_md]