Back to index

python-biopython  1.60
test_KeyWList.py
Go to the documentation of this file.
00001 # Copyright 1999 by Jeffrey Chang.  All rights reserved.
00002 # This code is part of the Biopython distribution and governed by its
00003 # license.  Please see the LICENSE file that should have been included
00004 # as part of this package.
00005 
00006 import unittest
00007 import os.path
00008 from Bio.SwissProt import KeyWList
00009 
00010 class KeyWListTest(unittest.TestCase):
00011 
00012     def test_parse(self):
00013         "Parsing keywlist.txt"
00014 
00015         filename = os.path.join("SwissProt", "keywlist.txt")
00016         handle = open(filename)
00017         records = KeyWList.parse(handle)
00018 
00019         # Testing the first record
00020         record = records.next()
00021         self.assertEqual(record["ID"], "2Fe-2S.")
00022         self.assertEqual(record["AC"], "KW-0001")
00023         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.")
00024         self.assertEqual(record["SY"], "Fe2S2; [2Fe-2S] cluster; [Fe2S2] cluster; Fe2/S2 (inorganic) cluster; Di-mu-sulfido-diiron; 2 iron, 2 sulfur cluster binding.")
00025         self.assertEqual(len(record["GO"]), 1)
00026         self.assertEqual(record["GO"], ["GO:0051537; 2 iron, 2 sulfur cluster binding"])
00027         self.assertEqual(len(record["HI"]), 2)
00028         self.assertEqual(record["HI"][0], "Ligand: Iron; Iron-sulfur; 2Fe-2S.")
00029         self.assertEqual(record["HI"][1], "Ligand: Metal-binding; 2Fe-2S.")
00030         self.assertEqual(record["CA"], "Ligand.")
00031 
00032         # Testing the second record
00033         record = records.next()
00034         self.assertEqual(record["IC"], "Molecular function.")
00035         self.assertEqual(record["AC"], "KW-9992")
00036         self.assertEqual(record["DE"], "Keywords assigned to proteins due to their particular molecular function.")
00037 
00038         # Testing the third record
00039         record = records.next()
00040         self.assertEqual(record["ID"], "Zymogen.")
00041         self.assertEqual(record["AC"], "KW-0865")
00042         self.assertEqual(record["DE"], "The enzymatically inactive precursor of mostly proteolytic enzymes.")
00043         self.assertEqual(record["SY"], "Proenzyme.")
00044         self.assertEqual(len(record["HI"]), 1)
00045         self.assertEqual(record["HI"][0], "PTM: Zymogen.")
00046         self.assertEqual(record["CA"], "PTM.")
00047 
00048         handle.close()
00049 
00050     def test_parse2(self):
00051         "Parsing keywlist2.txt (without header and footer)"
00052 
00053         filename = os.path.join("SwissProt", "keywlist2.txt")
00054         handle = open(filename)
00055         records = KeyWList.parse(handle)
00056 
00057         # Testing the first record
00058         record = records.next()
00059         self.assertEqual(record["ID"], "2Fe-2S.")
00060         self.assertEqual(record["AC"], "KW-0001")
00061         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.")
00062         self.assertEqual(record["SY"], "Fe2S2; [2Fe-2S] cluster; [Fe2S2] cluster; Fe2/S2 (inorganic) cluster; Di-mu-sulfido-diiron; 2 iron, 2 sulfur cluster binding.")
00063         self.assertEqual(len(record["GO"]), 1)
00064         self.assertEqual(record["GO"], ["GO:0051537; 2 iron, 2 sulfur cluster binding"])
00065         self.assertEqual(len(record["HI"]), 2)
00066         self.assertEqual(record["HI"][0], "Ligand: Iron; Iron-sulfur; 2Fe-2S.")
00067         self.assertEqual(record["HI"][1], "Ligand: Metal-binding; 2Fe-2S.")
00068         self.assertEqual(record["CA"], "Ligand.")
00069 
00070         # Testing the second record
00071         record = records.next()
00072         self.assertEqual(record["ID"], "3D-structure.")
00073         self.assertEqual(record["AC"], "KW-0002")
00074         self.assertEqual(record["DE"], "Protein, or part of a protein, whose three-dimensional structure has been resolved experimentally (for example by X-ray crystallography or NMR spectroscopy) and whose coordinates are available in the PDB database. Can also be used for theoretical models.")
00075         self.assertEqual(len(record["HI"]), 1)
00076         self.assertEqual(record["HI"][0], "Technical term: 3D-structure.")
00077         self.assertEqual(record["CA"], "Technical term.")
00078 
00079         # Testing the third record
00080         record = records.next()
00081         self.assertEqual(record["ID"], "3Fe-4S.")
00082         self.assertEqual(record["AC"], "KW-0003")
00083         self.assertEqual(record["DE"], "Protein which contains at least one 3Fe-4S iron-sulfur cluster: 3 iron atoms complexed to 4 inorganic sulfides and 3 sulfur atoms of cysteines from the protein. In a number of iron-sulfur proteins, the 4Fe-4S cluster can be reversibly converted by oxidation and loss of one iron ion to a 3Fe-4S cluster.")
00084         self.assertEqual(record["SY"], "")
00085         self.assertEqual(len(record["GO"]), 1)
00086         self.assertEqual(record["GO"], ['GO:0051538; 3 iron, 4 sulfur cluster binding'])
00087         self.assertEqual(len(record["HI"]), 2)
00088         self.assertEqual(record["HI"][0], "Ligand: Iron; Iron-sulfur; 3Fe-4S.")
00089         self.assertEqual(record["HI"][1], "Ligand: Metal-binding; 3Fe-4S.")
00090         self.assertEqual(record["CA"], "Ligand.")
00091 
00092         handle.close()
00093 
00094 if __name__ == "__main__":
00095     runner = unittest.TextTestRunner(verbosity = 2)
00096     unittest.main(testRunner=runner)