• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ProteinsWebTeam / interpro7-api / 9887981828

11 Jul 2024 08:20AM UTC coverage: 93.827% (-0.2%) from 94.023%
9887981828

Pull #151

github

web-flow
Update webfront/serializers/content_serializers.py

Co-authored-by: Matthias Blum <mat.blum@gmail.com>
Pull Request #151: Replacing `_subset` with `_url` in filter by DB requests

429 of 436 new or added lines in 29 files covered. (98.39%)

6 existing lines in 5 files now uncovered.

9089 of 9687 relevant lines covered (93.83%)

0.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.09
/webfront/tests/tests_proteome.py
1
from rest_framework import status
1✔
2

3
from webfront.models import Proteome
1✔
4
from webfront.tests.InterproRESTTestCase import InterproRESTTestCase
1✔
5

6

7
class ProteomeFixturesTest(InterproRESTTestCase):
1✔
8
    def test_the_fixtures_are_loaded(self):
1✔
9
        proteomes = Proteome.objects.all()
1✔
10
        self.assertEqual(proteomes.count(), 4)
1✔
11
        names = [t.name for t in proteomes]
1✔
12
        self.assertIn("Lactobacillus brevis KB290", names)
1✔
13
        self.assertNotIn("unicorn", names)
1✔
14

15
    def test_can_get_the_proteome_count(self):
1✔
16
        response = self.client.get("/api/proteome")
1✔
17
        self.assertEqual(response.status_code, status.HTTP_200_OK)
1✔
18
        self.assertIn("proteomes", response.data)
1✔
19
        self.assertIn("uniprot", response.data["proteomes"])
1✔
20

21
    def test_can_read_proteome_list(self):
1✔
22
        response = self.client.get("/api/proteome/uniprot")
1✔
23
        self.assertEqual(response.status_code, status.HTTP_200_OK)
1✔
24
        self._check_is_list_of_objects_with_key(response.data["results"], "metadata")
1✔
25
        self.assertEqual(len(response.data["results"]), 4)
1✔
26

27
    def test_can_read_proteome_id(self):
1✔
28
        response = self.client.get("/api/proteome/uniprot/UP000012042")
1✔
29
        self.assertEqual(response.status_code, status.HTTP_200_OK)
1✔
30
        self._check_proteome_details(response.data["metadata"])
1✔
31

32
    def test_can_filter_by_is_reference_false(self):
1✔
33
        response = self.client.get("/api/proteome/uniprot/?is_reference=false")
×
34
        self.assertEqual(response.status_code, status.HTTP_200_OK)
×
35
        self.assertIn("count", response.data)
×
36
        self.assertEqual(response.data["count"], 1)
×
37
        self.assertIn("results", response.data)
×
38
        self.assertEqual(len(response.data["results"]), 1)
×
39
        for result in response.data["results"]:
×
40
            self.assertIn("metadata", result)
×
41
            self.assertIn("is_reference", result["metadata"])
×
42
            self.assertEqual(result["metadata"]["is_reference"], False)
×
43

44
    def test_can_filter_by_entry_and_is_reference_true(self):
1✔
45
        response = self.client.get(
1✔
46
            "/api/proteome/uniprot/entry/InterPro/?is_reference=true"
47
        )
48
        self.assertEqual(response.status_code, status.HTTP_200_OK)
1✔
49
        self.assertIn("count", response.data)
1✔
50
        self.assertEqual(response.data["count"], 2)
1✔
51
        self.assertIn("results", response.data)
1✔
52
        self.assertEqual(len(response.data["results"]), 2)
1✔
53
        for result in response.data["results"]:
1✔
54
            self.assertIn("metadata", result)
1✔
55
            self.assertIn("is_reference", result["metadata"])
1✔
56
            self.assertEqual(result["metadata"]["is_reference"], True)
1✔
57

58
    def test_can_filter_by_is_reference_false(self):
1✔
59
        response = self.client.get(
1✔
60
            "/api/proteome/uniprot/entry/InterPro/?is_reference=false"
61
        )
62
        # Should consider adding a fixture to return some results for this query
63
        self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
1✔
64

65

66
class EntryProteomeTest(InterproRESTTestCase):
1✔
67
    def test_can_get_the_proteome_count(self):
1✔
68
        response = self.client.get("/api/entry/proteome")
1✔
69
        self.assertEqual(response.status_code, status.HTTP_200_OK)
1✔
70
        self._check_entry_count_overview(response.data)
1✔
71
        self._check_proteome_count_overview(response.data)
1✔
72

73
    def test_can_get_the_proteome_count_on_a_list(self):
1✔
74
        acc = "IPR003165"
1✔
75
        urls = [
1✔
76
            "/api/entry/interpro/proteome/",
77
            "/api/entry/pfam/proteome/",
78
            "/api/entry/unintegrated/proteome/",
79
            "/api/entry/interpro/pfam/proteome/",
80
            "/api/entry/unintegrated/pfam/proteome/",
81
            f"/api/entry/interpro/{acc}/pfam/proteome",
82
        ]
83
        for url in urls:
1✔
84
            response = self.client.get(url)
1✔
85
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
86
            self._check_is_list_of_objects_with_key(
1✔
87
                response.data["results"], "metadata"
88
            )
89
            self._check_is_list_of_objects_with_key(
1✔
90
                response.data["results"], "proteomes"
91
            )
92
            for result in response.data["results"]:
1✔
93
                self._check_proteome_count_overview(result)
1✔
94

95
    def test_urls_that_return_entry_with_proteome_count(self):
1✔
96
        acc = "IPR003165"
1✔
97
        pfam = "PF02171"
1✔
98
        pfam_un = "PF17176"
1✔
99
        urls = [
1✔
100
            f"/api/entry/interpro/{acc}/proteome",
101
            f"/api/entry/pfam/{pfam}/proteome",
102
            f"/api/entry/pfam/{pfam_un}/proteome",
103
            f"/api/entry/interpro/{acc}/pfam/{pfam}/proteome",
104
            f"/api/entry/interpro/pfam/{pfam}/proteome",
105
            f"/api/entry/unintegrated/pfam/{pfam_un}/proteome",
106
        ]
107
        for url in urls:
1✔
108
            response = self.client.get(url)
1✔
109
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
110
            self._check_entry_details(response.data["metadata"])
1✔
111
            self.assertIn(
1✔
112
                "proteomes",
113
                response.data,
114
                "'proteomes' should be one of the keys in the response",
115
            )
116
            self._check_proteome_count_overview(response.data)
1✔
117

118
    def test_can_filter_entry_counter_with_proteome_db(self):
1✔
119
        url = "/api/entry/proteome/uniprot"
1✔
120
        response = self.client.get(url)
1✔
121
        self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
122
        self.assertIn(
1✔
123
            "proteomes",
124
            response.data["entries"]["integrated"],
125
            "'proteomes' should be one of the keys in the response",
126
        )
127
        if response.data["entries"]["unintegrated"] != 0:
1✔
128
            self.assertIn(
1✔
129
                "proteomes",
130
                response.data["entries"]["unintegrated"],
131
                "'proteomes' should be one of the keys in the response",
132
            )
133

134
    def test_can_get_the_proteome_list_on_a_list(self):
1✔
135
        acc = "IPR003165"
1✔
136
        urls = [
1✔
137
            "/api/entry/pfam/proteome/uniprot",
138
            "/api/entry/interpro/pfam/proteome/uniprot",
139
            "/api/entry/unintegrated/pfam/proteome/uniprot",
140
            f"/api/entry/interpro/{acc}/pfam/proteome/uniprot",
141
        ]
142
        for url in urls:
1✔
143
            self._check_list_url_with_and_without_subset(
1✔
144
                url,
145
                "proteome",
146
                check_inner_subset_fn=self._check_proteome_from_searcher,
147
            )
148

149
    def test_can_get_the_proteome_list_on_an_object(self):
1✔
150
        urls = [
1✔
151
            "/api/entry/interpro/IPR003165/proteome/uniprot",
152
            "/api/entry/pfam/PF02171/proteome/uniprot",
153
            "/api/entry/unintegrated/pfam/PF17176/proteome/uniprot",
154
            "/api/entry/interpro/IPR003165/pfam/PF02171/proteome/uniprot",
155
        ]
156
        for url in urls:
1✔
157
            self._check_details_url_with_and_without_subset(
1✔
158
                url,
159
                "proteome",
160
                check_inner_subset_fn=self._check_proteome_from_searcher,
161
                check_metadata_fn=self._check_entry_details,
162
            )
163

164
    def test_can_filter_entry_counter_with_proteome_acc(self):
1✔
165
        urls = [
1✔
166
            "/api/entry/proteome/uniprot/UP000006701",
167
            "/api/entry/proteome/uniprot/up000012042",
168
        ]
169
        for url in urls:
1✔
170
            response = self.client.get(url)
1✔
171
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
172
            self._check_entry_count_overview(response.data)
1✔
173

174
    def test_can_get_the_proteome_object_on_a_list(self):
1✔
175
        acc = "IPR003165"
1✔
176
        urls = [
1✔
177
            "/api/entry/pfam/proteome/uniprot/UP000006701",
178
            "/api/entry/interpro/pfam/proteome/uniprot/UP000006701",
179
            f"/api/entry/interpro/{acc}/pfam/proteome/uniprot/UP000006701",
180
        ]
181
        for url in urls:
1✔
182
            response = self.client.get(url)
1✔
183
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
184
            self._check_is_list_of_objects_with_key(
1✔
185
                response.data["results"], "metadata"
186
            )
187
            self._check_is_list_of_objects_with_key(
1✔
188
                response.data["results"], "proteomes"
189
            )
190
            for result in response.data["results"]:
1✔
191
                for org in result["proteomes"]:
1✔
192
                    self._check_proteome_from_searcher(org)
1✔
193

194
    def test_can_get_the_proteome_object_on_an_object(self):
1✔
195
        urls = [
1✔
196
            "/api/entry/pfam/PF02171/proteome/uniprot/up000006701",
197
            "/api/entry/interpro/IPR003165/proteome/uniprot/up000006701",
198
            "/api/entry/interpro/pfam/PF02171/proteome/uniprot/up000006701",
199
            "/api/entry/interpro/IPR003165/pfam/PF02171/proteome/uniprot/up000006701",
200
        ]
201
        for url in urls:
1✔
202
            response = self.client.get(url)
1✔
203
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
204
            self._check_entry_details(response.data["metadata"])
1✔
205
            self.assertIn("proteomes", response.data)
1✔
206
            for org in response.data["proteomes"]:
1✔
207
                self._check_proteome_from_searcher(org)
1✔
208

209

210
class ProteinProteomeTest(InterproRESTTestCase):
1✔
211
    def test_can_get_the_proteome_count(self):
1✔
212
        response = self.client.get("/api/protein/proteome")
1✔
213
        self.assertEqual(response.status_code, status.HTTP_200_OK)
1✔
214
        self._check_proteome_count_overview(response.data)
1✔
215
        self._check_protein_count_overview(response.data)
1✔
216

217
    def test_can_get_the_proteome_count_on_a_list(self):
1✔
218
        urls = [
1✔
219
            "/api/protein/reviewed/proteome/",
220
            "/api/protein/unreviewed/proteome/",
221
            "/api/protein/uniprot/proteome/",
222
        ]
223
        for url in urls:
1✔
224
            response = self.client.get(url)
1✔
225
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
226
            self._check_is_list_of_objects_with_key(
1✔
227
                response.data["results"], "metadata"
228
            )
229
            self._check_is_list_of_objects_with_key(
1✔
230
                response.data["results"], "proteomes"
231
            )
232
            for result in response.data["results"]:
1✔
233
                self._check_proteome_count_overview(result)
1✔
234

235
    def test_urls_that_return_protein_with_proteome_count(self):
1✔
236
        reviewed = "A1CUJ5"
1✔
237
        unreviewed = "P16582"
1✔
238
        urls = [
1✔
239
            f"/api/protein/uniprot/{reviewed}/proteome/",
240
            f"/api/protein/uniprot/{unreviewed}/proteome/",
241
            f"/api/protein/reviewed/{reviewed}/proteome/",
242
            f"/api/protein/unreviewed/{unreviewed}/proteome/",
243
        ]
244
        for url in urls:
1✔
245
            response = self.client.get(url)
1✔
246
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
247
            self._check_protein_details(response.data["metadata"])
1✔
248
            self.assertIn(
1✔
249
                "proteomes",
250
                response.data,
251
                "'proteomes' should be one of the keys in the response",
252
            )
253
            self._check_proteome_count_overview(response.data)
1✔
254

255
    def test_can_filter_protein_counter_with_proteome_db(self):
1✔
256
        url = "/api/protein/proteome/uniprot"
1✔
257
        response = self.client.get(url)
1✔
258
        self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
259
        self.assertIn(
1✔
260
            "proteins",
261
            response.data["proteins"]["uniprot"],
262
            "'proteins' should be one of the keys in the response",
263
        )
264
        self.assertIn(
1✔
265
            "proteomes",
266
            response.data["proteins"]["uniprot"],
267
            "'proteomes' should be one of the keys in the response",
268
        )
269
        if "reviewed" in response.data["proteins"]:
1✔
270
            self.assertIn(
1✔
271
                "proteins",
272
                response.data["proteins"]["reviewed"],
273
                "'proteins' should be one of the keys in the response",
274
            )
275
            self.assertIn(
1✔
276
                "proteomes",
277
                response.data["proteins"]["reviewed"],
278
                "'proteomes' should be one of the keys in the response",
279
            )
280
        if "unreviewed" in response.data["proteins"]:
1✔
281
            self.assertIn(
1✔
282
                "proteins",
283
                response.data["proteins"]["unreviewed"],
284
                "'proteins' should be one of the keys in the response",
285
            )
286
            self.assertIn(
1✔
287
                "proteomes",
288
                response.data["proteins"]["unreviewed"],
289
                "'proteomes' should be one of the keys in the response",
290
            )
291

292
    def test_can_get_the_proteome_list_on_a_list(self):
1✔
293
        urls = [
1✔
294
            "/api/protein/unreviewed/proteome/uniprot",
295
            "/api/protein/uniprot/proteome/uniprot",
296
            "/api/protein/reviewed/proteome/uniprot",
297
        ]
298
        for url in urls:
1✔
299
            self._check_list_url_with_and_without_subset(
1✔
300
                url,
301
                "proteome",
302
                check_inner_subset_fn=self._check_proteome_from_searcher,
303
            )
304

305
    def test_can_get_the_proteome_list_on_an_object(self):
1✔
306
        urls = [
1✔
307
            "/api/protein/uniprot/A0A0A2L2G2/proteome/uniprot",
308
            "/api/protein/unreviewed/P16582/proteome/uniprot/",
309
            "/api/protein/reviewed/A1CUJ5/proteome/uniprot",
310
        ]
311
        for url in urls:
1✔
312
            self._check_details_url_with_and_without_subset(
1✔
313
                url,
314
                "proteome",
315
                check_inner_subset_fn=self._check_proteome_from_searcher,
316
                check_metadata_fn=self._check_protein_details,
317
                check_subset_fn=lambda s: self.assertEqual(len(s), 1),
318
            )
319

320
    def test_can_filter_counter_with_proteome_acc(self):
1✔
321
        urls = [
1✔
322
            "/api/protein/proteome/uniprot/UP000006701",
323
            "/api/protein/proteome/uniprot/up000030104",
324
        ]
325
        for url in urls:
1✔
326
            response = self.client.get(url)
1✔
327
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
328
            self._check_protein_count_overview(response.data)
1✔
329

330
    def test_can_get_the_proteome_object_on_a_list(self):
1✔
331
        urls = [
1✔
332
            "/api/protein/unreviewed/proteome/uniprot/up000030104",
333
            "/api/protein/uniprot/proteome/uniprot/UP000006701",
334
        ]
335
        for url in urls:
1✔
336
            response = self.client.get(url)
1✔
337
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
338
            self._check_is_list_of_objects_with_key(
1✔
339
                response.data["results"], "metadata"
340
            )
341
            self._check_is_list_of_objects_with_key(
1✔
342
                response.data["results"], "proteomes"
343
            )
344
            for result in response.data["results"]:
1✔
345
                for org in result["proteomes"]:
1✔
346
                    self._check_proteome_from_searcher(org)
1✔
347

348
    def test_can_get_the_proteome_object_on_an_object(self):
1✔
349
        urls = [
1✔
350
            "/api/protein/uniprot/A0A0A2L2G2/proteome/uniprot/up000030104",
351
            "/api/protein/reviewed/A1CUJ5/proteome/uniprot/up000006701",
352
        ]
353
        for url in urls:
1✔
354
            response = self.client.get(url)
1✔
355
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
356
            self._check_protein_details(response.data["metadata"])
1✔
357
            self.assertIn("proteomes", response.data)
1✔
358
            for org in response.data["proteomes"]:
1✔
359
                self._check_proteome_from_searcher(org)
1✔
360

361

362
class StructureProteomeTest(InterproRESTTestCase):
1✔
363
    def test_can_get_the_proteome_count(self):
1✔
364
        response = self.client.get("/api/structure/proteome")
1✔
365
        self.assertEqual(response.status_code, status.HTTP_200_OK)
1✔
366
        self._check_proteome_count_overview(response.data)
1✔
367
        self._check_structure_count_overview(response.data)
1✔
368

369
    def test_can_get_the_proteome_count_on_a_list(self):
1✔
370
        url = "/api/structure/pdb/proteome/"
1✔
371
        response = self.client.get(url)
1✔
372
        self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
373
        self._check_is_list_of_objects_with_key(response.data["results"], "metadata")
1✔
374
        self._check_is_list_of_objects_with_key(response.data["results"], "proteomes")
1✔
375
        for result in response.data["results"]:
1✔
376
            self._check_proteome_count_overview(result)
1✔
377

378
    def test_urls_that_return_structure_with_proteome_count(self):
1✔
379
        urls = [
1✔
380
            f"/api/structure/pdb/{pdb}/proteome/" for pdb in ["1JM7", "2BKM", "1T2V"]
381
        ]
382
        for url in urls:
1✔
383
            response = self.client.get(url)
1✔
384
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
385
            self._check_structure_details(response.data["metadata"])
1✔
386
            self.assertIn(
1✔
387
                "proteomes",
388
                response.data,
389
                "'proteomes' should be one of the keys in the response",
390
            )
391
            self._check_proteome_count_overview(response.data)
1✔
392

393
    def test_can_filter_structure_counter_with_proteome_db(self):
1✔
394
        url = "/api/structure/proteome/uniprot"
1✔
395
        response = self.client.get(url)
1✔
396
        self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
397
        self.assertIn(
1✔
398
            "structures",
399
            response.data["structures"]["pdb"],
400
            "'structures' should be one of the keys in the response",
401
        )
402
        self.assertIn(
1✔
403
            "proteomes",
404
            response.data["structures"]["pdb"],
405
            "'proteomes' should be one of the keys in the response",
406
        )
407

408
    def test_can_get_the_proteome_list_on_a_list(self):
1✔
409
        url = "/api/structure/pdb/proteome/uniprot"
1✔
410
        self._check_list_url_with_and_without_subset(
1✔
411
            url,
412
            "proteome",
413
            check_inner_subset_fn=self._check_proteome_from_searcher,
414
        )
415

416
    def test_can_get_the_proteome_list_on_an_object(self):
1✔
417
        urls = [
1✔
418
            "/api/structure/pdb/1T2V/proteome/uniprot",
419
            "/api/structure/pdb/1JZ8/proteome/uniprot",
420
            "/api/structure/pdb/1JM7/proteome/uniprot",
421
        ]
422
        for url in urls:
1✔
423
            self._check_details_url_with_and_without_subset(
1✔
424
                url,
425
                "proteome",
426
                check_inner_subset_fn=self._check_proteome_from_searcher,
427
                check_metadata_fn=self._check_structure_details,
428
            )
429

430
    def test_can_filter_counter_with_proteome_acc(self):
1✔
431
        urls = [
1✔
432
            "/api/structure/proteome/uniprot/UP000006701",
433
            "/api/structure/proteome/uniprot/up000030104",
434
        ]
435
        for url in urls:
1✔
436
            response = self.client.get(url)
1✔
437
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
438
            self._check_structure_count_overview(response.data)
1✔
439

440
    def test_can_get_the_proteome_object_on_a_list(self):
1✔
441
        urls = [
1✔
442
            "/api/structure/pdb/proteome/uniprot/up000030104",
443
            "/api/structure/pdb/proteome/uniprot/UP000006701",
444
        ]
445
        for url in urls:
1✔
446
            response = self.client.get(url)
1✔
447
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
448
            self._check_is_list_of_objects_with_key(
1✔
449
                response.data["results"], "metadata"
450
            )
451
            self._check_is_list_of_objects_with_key(
1✔
452
                response.data["results"], "proteomes"
453
            )
454
            for result in response.data["results"]:
1✔
455
                for org in result["proteomes"]:
1✔
456
                    self._check_proteome_from_searcher(org)
1✔
457

458
    def test_can_get_the_proteome_object_on_an_object(self):
1✔
459
        urls = [
1✔
460
            "/api/structure/pdb/1T2V/proteome/uniprot/up000030104",
461
            "/api/structure/pdb/1JM7/proteome/uniprot/up000006701",
462
        ]
463
        for url in urls:
1✔
464
            response = self.client.get(url)
1✔
465
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
466
            self._check_structure_details(response.data["metadata"])
1✔
467
            self.assertIn("proteomes", response.data)
1✔
468
            for org in response.data["proteomes"]:
1✔
469
                self._check_proteome_from_searcher(org)
1✔
470

471

472
class SetProteomeTest(InterproRESTTestCase):
1✔
473
    def test_can_get_the_proteome_count(self):
1✔
474
        response = self.client.get("/api/set/proteome")
1✔
475
        self.assertEqual(response.status_code, status.HTTP_200_OK)
1✔
476
        self._check_set_count_overview(response.data)
1✔
477
        self._check_proteome_count_overview(response.data)
1✔
478

479
    def test_can_get_the_proteome_count_on_a_list(self):
1✔
480
        urls = [
1✔
481
            "/api/set/pfam/proteome",
482
            #            "/api/set/kegg/proteome",
483
            #            "/api/set/kegg/KEGG01/node/proteome",
484
        ]
485
        for url in urls:
1✔
486
            response = self.client.get(url)
1✔
487
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
488
            self._check_is_list_of_objects_with_key(
1✔
489
                response.data["results"], "metadata"
490
            )
491
            self._check_is_list_of_objects_with_key(
1✔
492
                response.data["results"], "proteomes"
493
            )
494
            for result in response.data["results"]:
1✔
495
                self._check_proteome_count_overview(result)
1✔
496

497
    def test_can_get_the_proteome_count_on_a_set(self):
1✔
498
        urls = [
1✔
499
            "/api/set/pfam/CL0001/proteome",
500
            #            "/api/set/kegg/KEGG01/proteome",
501
            #            "/api/set/kegg/KEGG01/node/KEGG01-1/proteome",
502
        ]
503
        for url in urls:
1✔
504
            response = self.client.get(url)
1✔
505
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
506
            self._check_set_details(response.data["metadata"])
1✔
507
            self.assertIn(
1✔
508
                "proteomes",
509
                response.data,
510
                "'proteomes' should be one of the keys in the response",
511
            )
512
            self._check_proteome_count_overview(response.data)
1✔
513

514
    def test_can_filter_set_counter_with_structure_db(self):
1✔
515
        url = "/api/set/proteome/uniprot"
1✔
516
        response = self.client.get(url)
1✔
517
        self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
518
        self.assertIsInstance(response.data, dict)
1✔
519
        # if "kegg" in response.data["sets"]:
520
        #     self.assertIn("proteomes", response.data["sets"]["kegg"],
521
        #                   "'proteomes' should be one of the keys in the response")
522
        #     self.assertIn("sets", response.data["sets"]["kegg"],
523
        #                   "'sets' should be one of the keys in the response")
524
        if "pfam" in response.data["sets"]:
1✔
525
            self.assertIn(
1✔
526
                "proteomes",
527
                response.data["sets"]["pfam"],
528
                "'proteomes' should be one of the keys in the response",
529
            )
530
            self.assertIn(
1✔
531
                "sets",
532
                response.data["sets"]["pfam"],
533
                "'sets' should be one of the keys in the response",
534
            )
535

536
    def test_can_get_the_set_list_on_a_list(self):
1✔
537
        urls = [
1✔
538
            "/api/set/pfam/proteome/uniprot",
539
        ]
540
        for url in urls:
1✔
541
            self._check_list_url_with_and_without_subset(
1✔
542
                url,
543
                "proteome",
544
                check_inner_subset_fn=self._check_proteome_from_searcher,
545
            )
546

547
    def test_can_get_a_list_from_the_set_object(self):
1✔
548
        urls = [
1✔
549
            "/api/set/pfam/Cl0001/proteome/uniprot",
550
        ]
551
        for url in urls:
1✔
552
            self._check_details_url_with_and_without_subset(
1✔
553
                url,
554
                "proteome",
555
                check_inner_subset_fn=self._check_proteome_from_searcher,
556
                check_metadata_fn=self._check_set_details,
557
            )
558

559
    def test_can_filter_set_counter_with_acc(self):
1✔
560
        urls = [
1✔
561
            "/api/set/proteome/uniprot/UP000012042",
562
            "/api/set/proteome/uniprot/UP000006701",
563
        ]
564
        for url in urls:
1✔
565
            response = self.client.get(url)
1✔
566
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
567
            self._check_set_count_overview(response.data)
1✔
568

569
    def test_can_get_object_on_a_set_list(self):
1✔
570
        urls = [
1✔
571
            #            "/api/set/kegg/proteome/uniprot/up000030104",
572
            #            "/api/set/kegg/proteome/uniprot/up000006701",
573
            "/api/set/pfam/proteome/uniprot/UP000012042",
574
            #            "/api/set/kegg/kegg01/node/proteome/uniprot/up000030104",
575
        ]
576
        for url in urls:
1✔
577
            response = self.client.get(url)
1✔
578
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
579
            self._check_is_list_of_objects_with_key(
1✔
580
                response.data["results"], "metadata"
581
            )
582
            self._check_is_list_of_objects_with_key(
1✔
583
                response.data["results"], "proteomes"
584
            )
585
            for result in response.data["results"]:
1✔
586
                self._check_set_details(result["metadata"], False)
1✔
587
                for st in result["proteomes"]:
1✔
588
                    self._check_proteome_from_searcher(st)
1✔
589

590
    def test_can_get_an_object_from_the_set_object(self):
1✔
591
        urls = [
1✔
592
            #            "/api/set/kegg/kegg01/proteome/uniprot/UP000006701",
593
            #            "/api/set/kegg/kegg01/node/kegg01-1/proteome/uniprot/UP000006701",
594
            "/api/set/pfam/Cl0001/proteome/uniprot/UP000006701"
595
        ]
596
        for url in urls:
1✔
597
            response = self.client.get(url)
1✔
598
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
599
            self._check_set_details(response.data["metadata"])
1✔
600
            self.assertIn("proteomes", response.data)
1✔
601
            for s in response.data["proteomes"]:
1✔
602
                self._check_proteome_from_searcher(s)
1✔
603

604

605
class ProteomeEntryTest(InterproRESTTestCase):
1✔
606
    def test_can_get_the_proteome_count(self):
1✔
607
        response = self.client.get("/api/proteome/entry")
1✔
608
        self.assertEqual(response.status_code, status.HTTP_200_OK)
1✔
609
        self._check_proteome_count_overview(response.data)
1✔
610
        self._check_entry_count_overview(response.data)
1✔
611

612
    def test_can_get_the_entry_count_on_a_list(self):
1✔
613
        url = "/api/proteome/uniprot/entry"
1✔
614
        response = self.client.get(url)
1✔
615
        self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
616
        self._check_is_list_of_objects_with_key(response.data["results"], "metadata")
1✔
617
        self._check_is_list_of_objects_with_key(response.data["results"], "entries")
1✔
618
        for result in response.data["results"]:
1✔
619
            self._check_entry_count_overview(result)
1✔
620

621
    def test_urls_that_return_proteome_with_entry_count(self):
1✔
622
        urls = [
1✔
623
            "/api/proteome/uniprot/UP000012042/entry",
624
            "/api/proteome/uniprot/UP000006701/entry",
625
        ]
626
        for url in urls:
1✔
627
            response = self.client.get(url)
1✔
628
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
629
            self._check_proteome_details(response.data["metadata"])
1✔
630
            self.assertIn(
1✔
631
                "entries",
632
                response.data,
633
                "'entries' should be one of the keys in the response",
634
            )
635
            self._check_entry_count_overview(response.data)
1✔
636

637
    def test_can_filter_proteomecounter_with_entry_db(self):
1✔
638
        acc = "IPR003165"
1✔
639
        urls = [
1✔
640
            "/api/proteome/entry/interpro",
641
            "/api/proteome/entry/pfam",
642
            "/api/proteome/entry/unintegrated",
643
            "/api/proteome/entry/unintegrated/pfam",
644
            "/api/proteome/entry/interpro/pfam",
645
            f"/api/proteome/entry/interpro/{acc}/pfam",
646
        ]
647
        for url in urls:
1✔
648
            response = self.client.get(url)
1✔
649
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
650
            self.assertIsInstance(response.data, dict)
1✔
651
            self.assertIn(
1✔
652
                "uniprot",
653
                response.data["proteomes"],
654
                "'uniprot' should be one of the keys in the response",
655
            )
656
            self.assertIn(
1✔
657
                "proteomes",
658
                response.data["proteomes"]["uniprot"],
659
                "'proteome' should be one of the keys in the response",
660
            )
661
            self.assertIn(
1✔
662
                "entries",
663
                response.data["proteomes"]["uniprot"],
664
                "'entries' should be one of the keys in the response",
665
            )
666

667
    def test_can_get_a_list_from_the_proteome_list(self):
1✔
668
        urls = [
1✔
669
            "/api/proteome/uniprot/entry/interpro",
670
            "/api/proteome/uniprot/entry/pfam",
671
            "/api/proteome/uniprot/entry/unintegrated",
672
            "/api/proteome/uniprot/entry/interpro/pfam",
673
            "/api/proteome/uniprot/entry/interpro/IPR003165/pfam",
674
        ]
675
        for url in urls:
1✔
676
            self._check_list_url_with_and_without_subset(
1✔
677
                url,
678
                "entry",
679
                check_inner_subset_fn=self._check_entry_from_searcher,
680
                check_metadata_fn=lambda metadata: self._check_proteome_details(
681
                    metadata, False
682
                ),
683
            )
684

685
    def test_can_get_a_list_from_the_proteome_object(self):
1✔
686
        urls = [
1✔
687
            "/api/proteome/uniprot/UP000006701/entry/pfam",
688
            "/api/proteome/uniprot/UP000006701/entry/unintegrated",
689
            "/api/proteome/uniprot/UP000006701/entry/interpro/pfam",
690
            "/api/proteome/uniprot/UP000006701/entry/unintegrated/pfam",
691
            "/api/proteome/uniprot/UP000006701/entry/interpro/IPR003165/smart",
692
        ]
693
        for url in urls:
1✔
694
            self._check_details_url_with_and_without_subset(
1✔
695
                url,
696
                "entry",
697
                check_inner_subset_fn=self._check_entry_from_searcher,
698
                check_metadata_fn=self._check_proteome_details,
699
            )
700

701
    def test_can_filter_proteome_counter_with_acc(self):
1✔
702
        acc = "IPR003165"
1✔
703
        pfam = "PF02171"
1✔
704
        pfam_un = "PF17176"
1✔
705
        urls = [
1✔
706
            f"/api/proteome/entry/interpro/{acc}",
707
            f"/api/proteome/entry/pfam/{pfam}",
708
            f"/api/proteome/entry/pfam/{pfam_un}",
709
            f"/api/proteome/entry/interpro/{acc}/pfam/{pfam}",
710
            f"/api/proteome/entry/interpro/pfam/{pfam}",
711
            f"/api/proteome/entry/unintegrated/pfam/{pfam_un}",
712
        ]
713
        for url in urls:
1✔
714
            response = self.client.get(url)
1✔
715
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
716
            self._check_proteome_count_overview(response.data)
1✔
717

718
    def test_can_get_object_on_a_proteome_list(self):
1✔
719
        acc = "IPR003165"
1✔
720
        pfam = "PF02171"
1✔
721
        pfam_un = "PF17176"
1✔
722
        urls = [
1✔
723
            f"/api/proteome/uniprot/entry/interpro/{acc}",
724
            f"/api/proteome/uniprot/entry/pfam/{pfam}",
725
            f"/api/proteome/uniprot/entry/unintegrated/pfam/{pfam_un}",
726
            f"/api/proteome/uniprot/entry/unintegrated/pfam/{pfam_un}",
727
            f"/api/proteome/uniprot/entry/interpro/pfam/{pfam}",
728
            f"/api/proteome/uniprot/entry/unintegrated/pfam/{pfam_un}",
729
            f"/api/proteome/uniprot/entry/interpro/IPR003165/pfam/{pfam}",
730
        ]
731
        for url in urls:
1✔
732
            response = self.client.get(url)
1✔
733
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
734
            self._check_is_list_of_objects_with_key(
1✔
735
                response.data["results"], "metadata"
736
            )
737
            self._check_is_list_of_objects_with_key(response.data["results"], "entries")
1✔
738
            for result in response.data["results"]:
1✔
739
                self._check_proteome_details(result["metadata"], False)
1✔
740
                for st in result["entries"]:
1✔
741
                    self._check_entry_from_searcher(st)
1✔
742

743
    def test_can_get_an_object_from_the_proteome_object(self):
1✔
744
        urls = [
1✔
745
            "/api/proteome/uniprot/UP000006701/entry/pfam/pf02171",
746
            "/api/proteome/uniprot/UP000006701/entry/unintegrated/pfam/pf17176",
747
            "/api/proteome/uniprot/UP000006701/entry/interpro/pfam/pf02171",
748
            "/api/proteome/uniprot/UP000006701/entry/unintegrated/pfam/pf17176",
749
            "/api/proteome/uniprot/UP000006701/entry/interpro/IPR003165/smart/sm00950",
750
        ]
751
        for url in urls:
1✔
752
            response = self.client.get(url)
1✔
753
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
754
            self._check_proteome_details(response.data["metadata"], False)
1✔
755
            self.assertIn("entries", response.data)
1✔
756
            for st in response.data["entries"]:
1✔
757
                self._check_entry_from_searcher(st)
1✔
758

759

760
class ProteomeProteinTest(InterproRESTTestCase):
1✔
761
    def test_can_get_the_proteome_count(self):
1✔
762
        response = self.client.get("/api/proteome/protein")
1✔
763
        self.assertEqual(response.status_code, status.HTTP_200_OK)
1✔
764
        self._check_proteome_count_overview(response.data)
1✔
765
        self._check_protein_count_overview(response.data)
1✔
766

767
    def test_can_get_the_protein_count_on_a_list(self):
1✔
768
        url = "/api/proteome/uniprot/protein"
1✔
769
        response = self.client.get(url)
1✔
770
        self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
771
        self._check_is_list_of_objects_with_key(response.data["results"], "metadata")
1✔
772
        self._check_is_list_of_objects_with_key(response.data["results"], "proteins")
1✔
773
        for result in response.data["results"]:
1✔
774
            self._check_protein_count_overview(result)
1✔
775

776
    def test_urls_that_return_proteome_with_entry_count(self):
1✔
777
        urls = [
1✔
778
            "/api/proteome/uniprot/UP000012042/protein",
779
            "/api/proteome/uniprot/UP000006701/protein",
780
            "/api/proteome/uniprot/UP000030104/protein",
781
        ]
782
        for url in urls:
1✔
783
            response = self.client.get(url)
1✔
784
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
785
            self._check_proteome_details(response.data["metadata"])
1✔
786
            self.assertIn(
1✔
787
                "proteins",
788
                response.data,
789
                "'proteins' should be one of the keys in the response",
790
            )
791
            self._check_protein_count_overview(response.data)
1✔
792

793
    def test_can_filter_protein_counter_with_proteome_db(self):
1✔
794
        urls = [
1✔
795
            "/api/proteome/protein/uniprot",
796
            "/api/proteome/protein/reviewed",
797
            "/api/proteome/protein/unreviewed",
798
        ]
799
        for url in urls:
1✔
800
            response = self.client.get(url)
1✔
801
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
802
            self.assertIsInstance(response.data, dict)
1✔
803
            self.assertIn(
1✔
804
                "uniprot",
805
                response.data["proteomes"],
806
                "'proteuniprotome' should be one of the keys in the response",
807
            )
808
            self.assertIn(
1✔
809
                "proteomes",
810
                response.data["proteomes"]["uniprot"],
811
                "'proteomes' should be one of the keys in the response",
812
            )
813
            self.assertIn(
1✔
814
                "proteins",
815
                response.data["proteomes"]["uniprot"],
816
                "'entries' should be one of the keys in the response",
817
            )
818

819
    def test_can_get_a_list_from_the_proteome_list(self):
1✔
820
        urls = [
1✔
821
            "/api/proteome/uniprot/protein/uniprot",
822
            "/api/proteome/uniprot/protein/unreviewed",
823
            "/api/proteome/uniprot/protein/reviewed",
824
        ]
825
        for url in urls:
1✔
826
            self._check_list_url_with_and_without_subset(
1✔
827
                url,
828
                "protein",
829
                check_inner_subset_fn=lambda p: self._check_match(
830
                    p, include_coordinates=False
831
                ),
832
                check_metadata_fn=lambda m: self._check_proteome_details(m, False),
833
            )
834

835
    def test_can_get_a_list_from_the_proteome_object(self):
1✔
836
        urls = [
1✔
837
            "/api/proteome/uniprot/UP000006701/protein/uniprot",
838
            "/api/proteome/uniprot/UP000030104/protein/unreviewed",
839
            "/api/proteome/uniprot/UP000006701/protein/reviewed",
840
        ]
841
        for url in urls:
1✔
842
            self._check_details_url_with_and_without_subset(
1✔
843
                url,
844
                "protein",
845
                check_inner_subset_fn=lambda p: self._check_match(
846
                    p, include_coordinates=False
847
                ),
848
                check_metadata_fn=lambda m: self._check_proteome_details(m, False),
849
            )
850

851
    def test_can_filter_proteome_counter_with_acc(self):
1✔
852
        urls = [
1✔
853
            "/api/proteome/protein/uniprot/M5ADK6",
854
            "/api/proteome/protein/unreviewed/A0A0A2L2G2",
855
            "/api/proteome/protein/reviewed/M5ADK6",
856
        ]
857
        for url in urls:
1✔
858
            response = self.client.get(url)
1✔
859
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
860
            self._check_proteome_count_overview(response.data)
1✔
861

862
    def test_can_get_object_on_a_proteome_list(self):
1✔
863
        urls = [
1✔
864
            "/api/proteome/uniprot/protein/uniprot/P16582",
865
            "/api/proteome/uniprot/protein/unreviewed/A0A0A2L2G2",
866
            "/api/proteome/uniprot/protein/reviewed/M5ADK6",
867
            "/api/proteome/uniprot/protein/reviewed/a1cuj5",
868
        ]
869
        for url in urls:
1✔
870
            response = self.client.get(url)
1✔
871
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
872
            self._check_is_list_of_objects_with_key(
1✔
873
                response.data["results"], "metadata"
874
            )
875
            self._check_is_list_of_objects_with_key(
1✔
876
                response.data["results"], "proteins"
877
            )
878
            for result in response.data["results"]:
1✔
879
                self._check_proteome_details(result["metadata"], False)
1✔
880
                for st in result["proteins"]:
1✔
881
                    self._check_match(st, include_coordinates=False)
1✔
882

883
    def test_can_get_an_object_from_the_proteome_object(self):
1✔
884
        urls = [
1✔
885
            "/api/proteome/uniprot/UP000006701/protein/uniprot/a1cuj5",
886
            "/api/proteome/uniprot/UP000030104/protein/unreviewed/A0A0A2L2G2",
887
            "/api/proteome/uniprot/UP000030104/protein/unreviewed/A0A0A2L2G2",
888
        ]
889
        for url in urls:
1✔
890
            response = self.client.get(url)
1✔
891
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
892
            self._check_proteome_details(response.data["metadata"], False)
1✔
893
            self.assertIn("proteins", response.data)
1✔
894
            for st in response.data["proteins"]:
1✔
895
                self._check_match(st, include_coordinates=False)
1✔
896

897

898
class ProteomeStructureTest(InterproRESTTestCase):
1✔
899
    def test_can_get_the_proteome_count(self):
1✔
900
        response = self.client.get("/api/proteome/structure")
1✔
901
        self.assertEqual(response.status_code, status.HTTP_200_OK)
1✔
902
        self._check_proteome_count_overview(response.data)
1✔
903
        self._check_structure_count_overview(response.data)
1✔
904

905
    def test_can_get_the_protein_count_on_a_list(self):
1✔
906
        url = "/api/proteome/uniprot/structure"
1✔
907
        response = self.client.get(url)
1✔
908
        self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
909
        self._check_is_list_of_objects_with_key(response.data["results"], "metadata")
1✔
910
        self._check_is_list_of_objects_with_key(response.data["results"], "structures")
1✔
911
        for result in response.data["results"]:
1✔
912
            self._check_structure_count_overview(result)
1✔
913

914
    def test_urls_that_return_proteome_with_entry_count(self):
1✔
915
        urls = [
×
916
            "/api/proteome/uniprot/40296/structure",
917
            "/api/proteome/uniprot/2/structure",
918
        ]
919
        for url in urls:
×
920
            response = self.client.get(url)
×
NEW
921
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
×
UNCOV
922
            self._check_proteome_details(response.data["metadata"])
×
923
            self.assertIn(
×
924
                "structures",
925
                response.data,
926
                "'structures' should be one of the keys in the response",
927
            )
928
            self._check_structure_count_overview(response.data)
×
929

930
    def test_urls_that_return_proteome_with_entry_count(self):
1✔
931
        urls = [
1✔
932
            "/api/proteome/uniprot/UP000012042/structure",
933
            "/api/proteome/uniprot/UP000006701/structure",
934
            "/api/proteome/uniprot/UP000030104/structure",
935
        ]
936
        for url in urls:
1✔
937
            response = self.client.get(url)
1✔
938
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
939
            self._check_proteome_details(response.data["metadata"])
1✔
940
            self.assertIn(
1✔
941
                "structures",
942
                response.data,
943
                "'structures' should be one of the keys in the response",
944
            )
945
            self._check_structure_count_overview(response.data)
1✔
946

947
    def test_can_filter_structure_counter_with_proteome_db(self):
1✔
948
        url = "/api/proteome/structure/pdb"
1✔
949
        response = self.client.get(url)
1✔
950
        self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
951
        self.assertIsInstance(response.data, dict)
1✔
952
        self.assertIn(
1✔
953
            "uniprot",
954
            response.data["proteomes"],
955
            "'uniprot' should be one of the keys in the response",
956
        )
957
        self.assertIn(
1✔
958
            "proteomes",
959
            response.data["proteomes"]["uniprot"],
960
            "'proteomes' should be one of the keys in the response",
961
        )
962
        self.assertIn(
1✔
963
            "structures",
964
            response.data["proteomes"]["uniprot"],
965
            "'structures' should be one of the keys in the response",
966
        )
967

968
    def test_can_get_a_list_from_the_proteome_list(self):
1✔
969
        url = "/api/proteome/uniprot/structure/pdb"
1✔
970
        self._check_list_url_with_and_without_subset(
1✔
971
            url,
972
            "structure",
973
            check_metadata_fn=lambda m: self._check_proteome_details(m, False),
974
            check_inner_subset_fn=self._check_structure_chain_details,
975
        )
976

977
    def test_can_get_a_list_from_the_proteome_object(self):
1✔
978
        urls = [
1✔
979
            "/api/proteome/uniprot/UP000006701/structure/pdb",
980
            "/api/proteome/uniprot/UP000030104/structure/pdb",
981
        ]
982
        for url in urls:
1✔
983
            self._check_details_url_with_and_without_subset(
1✔
984
                url,
985
                "structure",
986
                check_metadata_fn=lambda m: self._check_proteome_details(m, False),
987
                check_inner_subset_fn=self._check_structure_chain_details,
988
            )
989

990
    def test_can_filter_proteome_counter_with_acc(self):
1✔
991
        urls = ["/api/proteome/structure/pdb/1JM7", "/api/proteome/structure/pdb/1JZ8"]
1✔
992
        for url in urls:
1✔
993
            response = self.client.get(url)
1✔
994
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
995
            self._check_proteome_count_overview(response.data)
1✔
996

997
    def test_can_get_object_on_a_proteome_list(self):
1✔
998
        urls = [
1✔
999
            "/api/proteome/uniprot/structure/pdb/1JM7",
1000
            "/api/proteome/uniprot/structure/pdb/1JZ8",
1001
        ]
1002
        for url in urls:
1✔
1003
            response = self.client.get(url)
1✔
1004
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
1005
            self._check_is_list_of_objects_with_key(
1✔
1006
                response.data["results"], "metadata"
1007
            )
1008
            self._check_is_list_of_objects_with_key(
1✔
1009
                response.data["results"], "structures"
1010
            )
1011
            for result in response.data["results"]:
1✔
1012
                self._check_proteome_details(result["metadata"], False)
1✔
1013
                for st in result["structures"]:
1✔
1014
                    self._check_structure_chain_details(st)
1✔
1015

1016
    def test_can_get_an_object_from_the_proteome_object(self):
1✔
1017
        urls = [
1✔
1018
            "/api/proteome/uniprot/UP000006701/structure/pdb/1jm7",
1019
            "/api/proteome/uniprot/UP000030104/structure/pdb/1t2v",
1020
        ]
1021
        for url in urls:
1✔
1022
            response = self.client.get(url)
1✔
1023
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
1024
            self._check_proteome_details(response.data["metadata"], False)
1✔
1025
            self.assertIn("structures", response.data)
1✔
1026
            for st in response.data["structures"]:
1✔
1027
                self._check_structure_chain_details(st)
1✔
1028

1029

1030
class ProteomeSetTest(InterproRESTTestCase):
1✔
1031
    def test_can_get_the_taxonomy_count(self):
1✔
1032
        response = self.client.get("/api/proteome/set")
1✔
1033
        self.assertEqual(response.status_code, status.HTTP_200_OK)
1✔
1034
        self._check_set_count_overview(response.data)
1✔
1035
        self._check_proteome_count_overview(response.data)
1✔
1036

1037
    def test_can_get_the_set_count_on_a_list(self):
1✔
1038
        url = "/api/proteome/uniprot/set"
1✔
1039
        response = self.client.get(url)
1✔
1040
        self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
1041
        self._check_is_list_of_objects_with_key(response.data["results"], "metadata")
1✔
1042
        self._check_is_list_of_objects_with_key(response.data["results"], "sets")
1✔
1043
        for result in response.data["results"]:
1✔
1044
            self._check_set_count_overview(result)
1✔
1045

1046
    def test_urls_that_return_proteome_with_set_count(self):
1✔
1047
        urls = [
1✔
1048
            "/api/proteome/uniprot/UP000012042/set",
1049
            "/api/proteome/uniprot/UP000006701/set",
1050
        ]
1051
        for url in urls:
1✔
1052
            response = self.client.get(url)
1✔
1053
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
1054
            self._check_proteome_details(response.data["metadata"])
1✔
1055
            self.assertIn(
1✔
1056
                "sets",
1057
                response.data,
1058
                "'sets' should be one of the keys in the response",
1059
            )
1060
            self._check_set_count_overview(response.data)
1✔
1061

1062
    def test_can_filter_proteome_counter_with_proteome_db(self):
1✔
1063
        urls = [
1✔
1064
            "/api/proteome/set/pfam",
1065
            #            "/api/proteome/set/kegg",
1066
            #            "/api/proteome/set/kegg/kegg01/node",
1067
        ]
1068
        for url in urls:
1✔
1069
            response = self.client.get(url)
1✔
1070
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
1071
            self.assertIn(
1✔
1072
                "uniprot",
1073
                response.data["proteomes"],
1074
                "'uniprot' should be one of the keys in the response",
1075
            )
1076
            self.assertIn(
1✔
1077
                "sets",
1078
                response.data["proteomes"]["uniprot"],
1079
                "'sets' should be one of the keys in the response",
1080
            )
1081
            self.assertIn(
1✔
1082
                "proteomes",
1083
                response.data["proteomes"]["uniprot"],
1084
                "'proteomes' should be one of the keys in the response",
1085
            )
1086

1087
    def test_can_get_the_set_list_on_a_list(self):
1✔
1088
        urls = [
1✔
1089
            "/api/proteome/uniprot/set/pfam",
1090
        ]
1091
        for url in urls:
1✔
1092
            self._check_list_url_with_and_without_subset(
1✔
1093
                url,
1094
                "set",
1095
                check_inner_subset_fn=self._check_set_from_searcher,
1096
            )
1097

1098
    def test_can_get_the_set_list_on_a_proteome_object(self):
1✔
1099
        urls = [
1✔
1100
            "/api/proteome/uniprot/UP000006701/set/pfam",
1101
            #            "/api/proteome/uniprot/UP000006701/set/kegg",
1102
            #            "/api/proteome/uniprot/UP000006701/set/kegg/kegg01/node",
1103
        ]
1104
        for url in urls:
1✔
1105
            self._check_details_url_with_and_without_subset(
1✔
1106
                url,
1107
                "set",
1108
                check_inner_subset_fn=self._check_set_from_searcher,
1109
                check_metadata_fn=self._check_proteome_details,
1110
            )
1111

1112
    def test_can_filter_counter_with_set_acc(self):
1✔
1113
        urls = [
1✔
1114
            "/api/proteome/set/pfam/Cl0001",
1115
            #            "/api/proteome/set/kegg/kegg01",
1116
            #            "/api/proteome/set/kegg/kegg01/node/KEGG01-1",
1117
            #            "/api/proteome/set/kegg/kegg01/node/KEGG01-2",
1118
        ]
1119
        for url in urls:
1✔
1120
            response = self.client.get(url)
1✔
1121
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
1122
            self._check_proteome_count_overview(response.data)
1✔
1123

1124
    def test_can_get_the_set_object_on_a_list(self):
1✔
1125
        urls = [
1✔
1126
            #            "/api/proteome/uniprot/set/kegg/kegg01",
1127
            #            "/api/proteome/uniprot/set/kegg/kegg01/node/kegg01-1",
1128
            "/api/proteome/uniprot/set/pfam/Cl0001"
1129
        ]
1130
        for url in urls:
1✔
1131
            response = self.client.get(url)
1✔
1132
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
1133
            self._check_is_list_of_objects_with_key(
1✔
1134
                response.data["results"], "metadata"
1135
            )
1136
            self._check_is_list_of_objects_with_key(response.data["results"], "sets")
1✔
1137
            for result in response.data["results"]:
1✔
1138
                for org in result["sets"]:
1✔
1139
                    self._check_set_from_searcher(org)
1✔
1140

1141
    def test_can_get_the_object_on_an_object(self):
1✔
1142
        urls = [
1✔
1143
            #            "/api/proteome/uniprot/UP000006701/set/kegg/kegg01",
1144
            #            "/api/proteome/uniprot/UP000006701/set/kegg/kegg01/node/kegg01-1",
1145
            "/api/proteome/uniprot/UP000006701/set/pfam/Cl0001"
1146
        ]
1147
        for url in urls:
1✔
1148
            response = self.client.get(url)
1✔
1149
            self.assertEqual(response.status_code, status.HTTP_200_OK, f"URL : [{url}]")
1✔
1150
            self._check_proteome_details(response.data["metadata"])
1✔
1151
            self.assertIn("sets", response.data)
1✔
1152
            for s in response.data["sets"]:
1✔
1153
                self._check_set_from_searcher(s)
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc