|
1 | 1 | #!/usr/bin/env python |
2 | 2 | # -*- coding: utf-8 -*- |
3 | | - |
4 | 3 | # |
5 | | -# pyars pyARS. |
| 4 | +# py-ard pyARD. |
6 | 5 | # Copyright (c) 2018 Be The Match operated by National Marrow Donor Program. All Rights Reserved. |
7 | 6 | # |
8 | 7 | # This library is free software; you can redistribute it and/or modify it |
|
24 | 23 | # |
25 | 24 |
|
26 | 25 | """ |
27 | | -test_pyars |
| 26 | +test_pyard |
28 | 27 | ---------------------------------- |
29 | 28 |
|
30 | | -Tests for `pyars` module. |
| 29 | +Tests for `py-ard` module. |
31 | 30 | """ |
32 | | -import os |
33 | | -import sys |
34 | 31 | import json |
| 32 | +import os |
35 | 33 | import unittest |
36 | 34 |
|
37 | 35 | from pyard import ARD |
38 | 36 |
|
39 | 37 |
|
40 | | -class TestPyard(unittest.TestCase): |
| 38 | +class TestPyArd(unittest.TestCase): |
| 39 | + |
| 40 | + @classmethod |
| 41 | + def setUpClass(cls) -> None: |
| 42 | + cls.db_version = '3290' |
| 43 | + cls.ard = ARD(cls.db_version, data_dir='/tmp/3290') |
41 | 44 |
|
42 | 45 | def setUp(self): |
43 | | - self.ard = ARD(verbose=True) |
44 | | - self.data_dir = os.path.dirname(__file__) |
45 | 46 | self.assertIsInstance(self.ard, ARD) |
46 | | - expected_json = self.data_dir + "/expected.json" |
47 | | - with open(expected_json) as json_data: |
48 | | - self.expected = json.load(json_data) |
49 | | - pass |
50 | | - |
51 | | - def test_000_nomac(self): |
52 | | - self.ardnomac = ARD(download_mac=False) |
53 | | - self.assertIsInstance(self.ardnomac, ARD) |
54 | | - self.assertFalse(self.ardnomac.download_mac) |
55 | | - self.assertTrue(len(self.ardnomac.mac.keys()) == 0) |
56 | | - self.assertTrue(self.ardnomac.redux("A*01:01:01", 'G') == "A*01:01:01G") |
57 | | - self.assertTrue(self.ardnomac.redux("A*01:01:01", 'lg') == "A*01:01g") |
58 | | - self.assertTrue(self.ardnomac.redux("A*01:01:01", 'lgx') == "A*01:01") |
59 | | - self.assertTrue(self.ardnomac.redux("HLA-A*01:01:01", 'G') == "HLA-A*01:01:01G") |
60 | | - self.assertTrue(self.ardnomac.redux("HLA-A*01:01:01", 'lg') == "HLA-A*01:01g") |
61 | | - self.assertTrue(self.ardnomac.redux("HLA-A*01:01:01", 'lgx') == "HLA-A*01:01") |
62 | | - pass |
63 | | - |
64 | | - def test_001_dbversions(self): |
65 | | - for db in ['3310', '3300', '3290', '3280']: |
66 | | - self.arddb = ARD(dbversion=db, download_mac=False) |
67 | | - self.assertIsInstance(self.arddb, ARD) |
68 | | - self.assertFalse(self.arddb.download_mac) |
69 | | - self.assertTrue(self.arddb.dbversion == db) |
70 | | - self.assertTrue(self.arddb.redux("A*01:01:01", 'G') == "A*01:01:01G") |
71 | | - self.assertTrue(self.arddb.redux("A*01:01:01", 'lg') == "A*01:01g") |
72 | | - self.assertTrue(self.arddb.redux("A*01:01:01", 'lgx') == "A*01:01") |
73 | | - pass |
74 | 47 |
|
75 | | - def test_002_remove_invalid(self): |
76 | | - self.assertTrue(self.ard.redux("A*01:01:01", 'G') == "A*01:01:01G") |
77 | | - pass |
78 | | - |
79 | | - def test_003_mac(self): |
80 | | - self.assertTrue(self.ard.redux_gl("A*01:AB", 'G') == "A*01:01:01G/A*01:02") |
81 | | - self.assertTrue(self.ard.redux_gl("HLA-A*01:AB", 'G') == "HLA-A*01:01:01G/HLA-A*01:02") |
82 | | - pass |
83 | | - |
84 | | - def test_004_redux_gl(self): |
85 | | - for ex in self.expected['redux_gl']: |
| 48 | + def test_no_mac(self): |
| 49 | + self.ard_no_mac = ARD(self.db_version, data_dir='/tmp/3290', download_mac=False) |
| 50 | + self.assertIsInstance(self.ard_no_mac, ARD) |
| 51 | + self.assertEqual(len(self.ard_no_mac.mac.keys()), 0) |
| 52 | + self.assertEqual(self.ard_no_mac.redux("A*01:01:01", 'G'), "A*01:01:01G") |
| 53 | + self.assertEqual(self.ard_no_mac.redux("A*01:01:01", 'lg'), "A*01:01g") |
| 54 | + self.assertEqual(self.ard_no_mac.redux("A*01:01:01", 'lgx'), "A*01:01") |
| 55 | + self.assertEqual(self.ard_no_mac.redux("HLA-A*01:01:01", 'G'), "HLA-A*01:01:01G") |
| 56 | + self.assertEqual(self.ard_no_mac.redux("HLA-A*01:01:01", 'lg'), "HLA-A*01:01g") |
| 57 | + self.assertEqual(self.ard_no_mac.redux("HLA-A*01:01:01", 'lgx'), "HLA-A*01:01") |
| 58 | + |
| 59 | + def test_remove_invalid(self): |
| 60 | + self.assertEqual(self.ard.redux("A*01:01:01", 'G'), "A*01:01:01G") |
| 61 | + |
| 62 | + def test_mac(self): |
| 63 | + self.assertEqual(self.ard.redux_gl("A*01:AB", 'G'), "A*01:01:01G/A*01:02") |
| 64 | + self.assertEqual(self.ard.redux_gl("HLA-A*01:AB", 'G'), "HLA-A*01:01:01G/HLA-A*01:02") |
| 65 | + |
| 66 | + def test_redux_gl(self): |
| 67 | + data_dir = os.path.dirname(__file__) |
| 68 | + expected_json = data_dir + "/expected.json" |
| 69 | + with open(expected_json) as json_data: |
| 70 | + expected = json.load(json_data) |
| 71 | + for ex in expected['redux_gl']: |
86 | 72 | glstring = ex['glstring'] |
87 | 73 | ard_type = ex['ard_type'] |
88 | 74 | expected_gl = ex['expected_gl'] |
89 | | - self.assertTrue(self.ard.redux_gl(glstring, ard_type) == expected_gl) |
90 | | - pass |
91 | | - |
92 | | - def test_005_mac_G(self): |
93 | | - self.assertTrue(self.ard.redux("A*01:01:01", 'G') == "A*01:01:01G") |
94 | | - pass |
95 | | - |
96 | | - |
97 | | - |
| 75 | + self.assertEqual(self.ard.redux_gl(glstring, ard_type), expected_gl) |
98 | 76 |
|
| 77 | + def test_mac_G(self): |
| 78 | + self.assertEqual(self.ard.redux("A*01:01:01", 'G'), "A*01:01:01G") |
0 commit comments