Mercurial > repos > chrisb > gap_all_glycan_tools
diff get_data/kegg_glycan/test_findKEGG.py @ 1:0a5e0df17054 draft default tip
Uploaded
author | chrisb |
---|---|
date | Fri, 06 May 2016 08:05:48 -0400 |
parents | 89592faa2875 |
children |
line wrap: on
line diff
--- a/get_data/kegg_glycan/test_findKEGG.py Wed Mar 23 14:35:56 2016 -0400 +++ b/get_data/kegg_glycan/test_findKEGG.py Fri May 06 08:05:48 2016 -0400 @@ -41,9 +41,10 @@ m = fk.find_entries_in_KEGG("john", "glucose") def test_unfindable_entry(self): - """should return None""" + """should return an empty string""" m = fk.find_entries_in_KEGG("glycan", "sally") - self.assertIsNone(m) + emptystring="" + self.assertItemsEqual(m,emptystring,"Expected Empty String for non-existent entry") def test_find_example(self): m = fk.find_entries_in_KEGG("glycan", "glucose") @@ -52,9 +53,123 @@ def test_query_has_newlines(self): """ - should be fine and return entries + Assume a new line query is an AND query. + """ + m = fk.find_entries_in_KEGG("glycan", "glucose\nUDP") + self.assertIsNotNone(m) + print m + self.assertIn("UDP-D-glucose", m) + + def test_query_has_newlines_and_a_space(self): + """ + glucose\\n UDP. OR's should pass """ m = fk.find_entries_in_KEGG("glycan", "glucose\n UDP") self.assertIsNotNone(m) self.assertIn("UDP-D-glucose", m) + def test_gene_specific_or(self): + """ + test "shiga toxin" returns. + /find/genes/"shiga toxin" for keywords "shiga toxin" + """ + m = fk.find_entries_in_KEGG("genes","shiga toxin") + self.assertIsNotNone(m) + #. not matching to all entries - that is silly, the db get updated! + self.assertIn("shiga", m) + self.assertIn("toxin", m) + self.assertNotIn("stm:STM0284",m) # should not be found in the OR query + + def test_gene_specific_and(self): + """ + test "shiga+toxin" returns. it should + /find/genes/shiga+toxin for keywords "shiga" and "toxin" + """ + m = fk.find_entries_in_KEGG("genes","shiga+toxin") + self.assertIsNotNone(m) + #. not matching to all entries - that is silly, the db get updated! + self.assertIn("shiga", m) + self.assertIn("toxin", m) + self.assertIn("stm:STM0284",m) # should be found in the AND query + + def test_enzyme_specific_1(self): + """ + test 2.4.99.1 returns + """ + m = fk.find_entries_in_KEGG("enzyme","2.4.99.1") + self.assertIsNotNone(m) + #. not matching to all entries - that is silly, the db get updated! + self.assertIn("2.4.99.1", m) + + def test_enzyme_specific_2(self): + """ + test 2.4.99.6 returns + """ + m = fk.find_entries_in_KEGG("enzyme","2.4.99.6") + self.assertIsNotNone(m) + #. not matching to all entries - that is silly, the db get updated! + self.assertIn("2.4.99.6", m) + + def test_enzyme_specific_3(self): + """ + test ec: 2.4.99.6 with space (tests stripping space functionality) + """ + m = fk.find_entries_in_KEGG("enzyme","ec: 2.4.99.6") + self.assertIsNotNone(m) + #. not matching to all entries - that is silly, the db get updated! + self.assertIn("2.4.99.6", m) + + def test_enzyme_specific_4(self): + """ + test ec: 2.4.99. , should return 2.4.99.* + """ + m = fk.find_entries_in_KEGG("enzyme","ec: 2.4.99.") + self.assertIsNotNone(m) + #. not matching to all entries - that is silly, the db get updated! + self.assertIn("2.4.99.1", m) + self.assertIn("2.4.99.6", m) + self.assertIn("2.4.99.11", m) + + def test_enzyme_specific_5(self): + """ + test ec: 2.4.99.1+2.4.99.6 . AND function, so returns nothing here. Do not expect an enzyme to be doubly classified. + """ + m = fk.find_entries_in_KEGG("enzyme","2.4.99.1+2.4.99.6") + self.assertIsNotNone(m) + emptystring="" + self.assertItemsEqual(m,emptystring,"Expected Empty String for non-existent entry") + + def test_enzyme_specific_6(self): + """ + test ec: 2.4.99.1 2.4.99.6 . OR function, should return something but does not (KEGG FAILURE?). + note that trying this without "" will return the AND function result which is incorrect. + """ + m = fk.find_entries_in_KEGG("enzyme","2.4.99.1 2.4.99.6") + self.assertIsNotNone(m) + #self.assertIn("2.4.99.1", m) + emptystring="" + print m + self.assertItemsEqual(m,emptystring,"Expected Empty String for non-existent entry") + + + def test_enzyme_specific_7(self): + """ + test deoxy+1.1.1. . AND function, that should return something + """ + m = fk.find_entries_in_KEGG("enzyme","deoxy+1.1.1") + self.assertIsNotNone(m) + print m + self.assertIn("deoxy", m) + self.assertIn("1.1.1", m) + + def test_enzyme_specific_8(self): + """ + test deoxy 1.1.1. . OR function. should return deoxy or 1.1.1. but does not (KEGG FAILURE?). i + note that trying this without "" will return the AND function result which is incorrect. + """ + m = fk.find_entries_in_KEGG("enzyme","deoxy 1.1.1") + self.assertIsNotNone(m) + emptystring="" + print m + self.assertItemsEqual(m,emptystring,"Expected Empty String for non-existent entry") +