comparison 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
comparison
equal deleted inserted replaced
0:89592faa2875 1:0a5e0df17054
39 39
40 with self.assertRaises(urllib2.HTTPError): 40 with self.assertRaises(urllib2.HTTPError):
41 m = fk.find_entries_in_KEGG("john", "glucose") 41 m = fk.find_entries_in_KEGG("john", "glucose")
42 42
43 def test_unfindable_entry(self): 43 def test_unfindable_entry(self):
44 """should return None""" 44 """should return an empty string"""
45 m = fk.find_entries_in_KEGG("glycan", "sally") 45 m = fk.find_entries_in_KEGG("glycan", "sally")
46 self.assertIsNone(m) 46 emptystring=""
47 self.assertItemsEqual(m,emptystring,"Expected Empty String for non-existent entry")
47 48
48 def test_find_example(self): 49 def test_find_example(self):
49 m = fk.find_entries_in_KEGG("glycan", "glucose") 50 m = fk.find_entries_in_KEGG("glycan", "glucose")
50 self.assertIsNotNone(m) 51 self.assertIsNotNone(m)
51 self.assertIn("GDP-glucose", m) 52 self.assertIn("GDP-glucose", m)
52 53
53 def test_query_has_newlines(self): 54 def test_query_has_newlines(self):
54 """ 55 """
55 should be fine and return entries 56 Assume a new line query is an AND query.
57 """
58 m = fk.find_entries_in_KEGG("glycan", "glucose\nUDP")
59 self.assertIsNotNone(m)
60 print m
61 self.assertIn("UDP-D-glucose", m)
62
63 def test_query_has_newlines_and_a_space(self):
64 """
65 glucose\\n UDP. OR's should pass
56 """ 66 """
57 m = fk.find_entries_in_KEGG("glycan", "glucose\n UDP") 67 m = fk.find_entries_in_KEGG("glycan", "glucose\n UDP")
58 self.assertIsNotNone(m) 68 self.assertIsNotNone(m)
59 self.assertIn("UDP-D-glucose", m) 69 self.assertIn("UDP-D-glucose", m)
60 70
71 def test_gene_specific_or(self):
72 """
73 test "shiga toxin" returns.
74 /find/genes/"shiga toxin" for keywords "shiga toxin"
75 """
76 m = fk.find_entries_in_KEGG("genes","shiga toxin")
77 self.assertIsNotNone(m)
78 #. not matching to all entries - that is silly, the db get updated!
79 self.assertIn("shiga", m)
80 self.assertIn("toxin", m)
81 self.assertNotIn("stm:STM0284",m) # should not be found in the OR query
82
83 def test_gene_specific_and(self):
84 """
85 test "shiga+toxin" returns. it should
86 /find/genes/shiga+toxin for keywords "shiga" and "toxin"
87 """
88 m = fk.find_entries_in_KEGG("genes","shiga+toxin")
89 self.assertIsNotNone(m)
90 #. not matching to all entries - that is silly, the db get updated!
91 self.assertIn("shiga", m)
92 self.assertIn("toxin", m)
93 self.assertIn("stm:STM0284",m) # should be found in the AND query
94
95 def test_enzyme_specific_1(self):
96 """
97 test 2.4.99.1 returns
98 """
99 m = fk.find_entries_in_KEGG("enzyme","2.4.99.1")
100 self.assertIsNotNone(m)
101 #. not matching to all entries - that is silly, the db get updated!
102 self.assertIn("2.4.99.1", m)
103
104 def test_enzyme_specific_2(self):
105 """
106 test 2.4.99.6 returns
107 """
108 m = fk.find_entries_in_KEGG("enzyme","2.4.99.6")
109 self.assertIsNotNone(m)
110 #. not matching to all entries - that is silly, the db get updated!
111 self.assertIn("2.4.99.6", m)
112
113 def test_enzyme_specific_3(self):
114 """
115 test ec: 2.4.99.6 with space (tests stripping space functionality)
116 """
117 m = fk.find_entries_in_KEGG("enzyme","ec: 2.4.99.6")
118 self.assertIsNotNone(m)
119 #. not matching to all entries - that is silly, the db get updated!
120 self.assertIn("2.4.99.6", m)
121
122 def test_enzyme_specific_4(self):
123 """
124 test ec: 2.4.99. , should return 2.4.99.*
125 """
126 m = fk.find_entries_in_KEGG("enzyme","ec: 2.4.99.")
127 self.assertIsNotNone(m)
128 #. not matching to all entries - that is silly, the db get updated!
129 self.assertIn("2.4.99.1", m)
130 self.assertIn("2.4.99.6", m)
131 self.assertIn("2.4.99.11", m)
132
133 def test_enzyme_specific_5(self):
134 """
135 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.
136 """
137 m = fk.find_entries_in_KEGG("enzyme","2.4.99.1+2.4.99.6")
138 self.assertIsNotNone(m)
139 emptystring=""
140 self.assertItemsEqual(m,emptystring,"Expected Empty String for non-existent entry")
141
142 def test_enzyme_specific_6(self):
143 """
144 test ec: 2.4.99.1 2.4.99.6 . OR function, should return something but does not (KEGG FAILURE?).
145 note that trying this without "" will return the AND function result which is incorrect.
146 """
147 m = fk.find_entries_in_KEGG("enzyme","2.4.99.1 2.4.99.6")
148 self.assertIsNotNone(m)
149 #self.assertIn("2.4.99.1", m)
150 emptystring=""
151 print m
152 self.assertItemsEqual(m,emptystring,"Expected Empty String for non-existent entry")
153
154
155 def test_enzyme_specific_7(self):
156 """
157 test deoxy+1.1.1. . AND function, that should return something
158 """
159 m = fk.find_entries_in_KEGG("enzyme","deoxy+1.1.1")
160 self.assertIsNotNone(m)
161 print m
162 self.assertIn("deoxy", m)
163 self.assertIn("1.1.1", m)
164
165 def test_enzyme_specific_8(self):
166 """
167 test deoxy 1.1.1. . OR function. should return deoxy or 1.1.1. but does not (KEGG FAILURE?). i
168 note that trying this without "" will return the AND function result which is incorrect.
169 """
170 m = fk.find_entries_in_KEGG("enzyme","deoxy 1.1.1")
171 self.assertIsNotNone(m)
172 emptystring=""
173 print m
174 self.assertItemsEqual(m,emptystring,"Expected Empty String for non-existent entry")
175