forked from biopython/biopython
/
test_KeyWList.py
52 lines (43 loc) · 2.32 KB
/
test_KeyWList.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Copyright 1999 by Jeffrey Chang. All rights reserved.
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should have been included
# as part of this package.
import unittest
import os.path
from Bio.SwissProt import KeyWList
class KeyWListTest(unittest.TestCase):
def test_parse(self):
"Parsing keywlist.txt"
filename = os.path.join("SwissProt", "keywlist.txt")
handle = open(filename)
records = KeyWList.parse(handle)
# Testing the first record
record = records.next()
self.assertEqual(record["ID"], "2Fe-2S.")
self.assertEqual(record["AC"], "KW-0001")
self.assertEqual(record["DE"], "Protein which contains at least one 2Fe-2S iron-sulfur cluster: 2 iron atoms complexed to 2 inorganic sulfides and 4 sulfur atoms of cysteines from the protein.")
self.assertEqual(record["SY"], "Fe2S2; [2Fe-2S] cluster; [Fe2S2] cluster; Fe2/S2 (inorganic) cluster; Di-mu-sulfido-diiron; 2 iron, 2 sulfur cluster binding.")
self.assertEqual(len(record["GO"]), 1)
self.assertEqual(record["GO"], ["GO:0051537; 2 iron, 2 sulfur cluster binding"])
self.assertEqual(len(record["HI"]), 2)
self.assertEqual(record["HI"][0], "Ligand: Iron; Iron-sulfur; 2Fe-2S.")
self.assertEqual(record["HI"][1], "Ligand: Metal-binding; 2Fe-2S.")
self.assertEqual(record["CA"], "Ligand.")
# Testing the second record
record = records.next()
self.assertEqual(record["IC"], "Molecular function.")
self.assertEqual(record["AC"], "KW-9992")
self.assertEqual(record["DE"], "Keywords assigned to proteins due to their particular molecular function.")
# Testing the third record
record = records.next()
self.assertEqual(record["ID"], "Zymogen.")
self.assertEqual(record["AC"], "KW-0865")
self.assertEqual(record["DE"], "The enzymatically inactive precursor of mostly proteolytic enzymes.")
self.assertEqual(record["SY"], "Proenzyme.")
self.assertEqual(len(record["HI"]), 1)
self.assertEqual(record["HI"][0], "PTM: Zymogen.")
self.assertEqual(record["CA"], "PTM.")
handle.close()
if __name__ == "__main__":
runner = unittest.TextTestRunner(verbosity = 2)
unittest.main(testRunner=runner)