Back to index

python-biopython  1.60
test_SCOP_Raf.py
Go to the documentation of this file.
00001 
00002 """Unit test for Raf"""
00003 
00004 import unittest
00005 
00006 from Bio.SCOP import Raf
00007 
00008 
00009 
00010 
00011 class RafTests(unittest.TestCase):
00012     rafLine = "101m_ 0.01 38 010301 111011    0  153    0 mm   1 vv   2 ll   3 ss   4 ee   5 gg   6 ee   7 ww   8 qq   9 ll  10 vv  11 ll  12 hh  13 vv  14 ww  15 aa  16 kk  17 vv  18 ee  19 aa  20 dd  21 vv  22 aa  23 gg  24 hh  25 gg  26 qq  27 dd  28 ii  29 ll  30 ii  31 rr  32 ll  33 ff  34 kk  35 ss  36 hh  37 pp  38 ee  39 tt  40 ll  41 ee  42 kk  43 ff  44 dd  45 rr  46 vv  47 kk  48 hh  49 ll  50 kk  51 tt  52 ee  53 aa  54 ee  55 mm  56 kk  57 aa  58 ss  59 ee  60 dd  61 ll  62 kk  63 kk  64 hh  65 gg  66 vv  67 tt  68 vv  69 ll  70 tt  71 aa  72 ll  73 gg  74 aa  75 ii  76 ll  77 kk  78 kk  79 kk  80 gg  81 hh  82 hh  83 ee  84 aa  85 ee  86 ll  87 kk  88 pp  89 ll  90 aa  91 qq  92 ss  93 hh  94 aa  95 tt  96 kk  97 hh  98 kk  99 ii 100 pp 101 ii 102 kk 103 yy 104 ll 105 ee 106 ff 107 ii 108 ss 109 ee 110 aa 111 ii 112 ii 113 hh 114 vv 115 ll 116 hh 117 ss 118 rr 119 hh 120 pp 121 gg 122 nn 123 ff 124 gg 125 aa 126 dd 127 aa 128 qq 129 gg 130 aa 131 mm 132 nn 133 kk 134 aa 135 ll 136 ee 137 ll 138 ff 139 rr 140 kk 141 dd 142 ii 143 aa 144 aa 145 kk 146 yy 147 kk 148 ee 149 ll 150 gg 151 yy 152 qq 153 gg"
00013 
00014     rafLine2 = "101mA 0.01 38 010301 111011    0  153    0 mm   1 vv   2 ll   3 ss   4 ee   5 gg   6Aee   7Aww   8Aqq"
00015 
00016     rafLine3 = "101mB 0.01 38 010301 111011    0  153   90 mm  91 vv  92 ll  939ss  94 ee  95 gg"
00017 
00018 
00019     def testParse(self):
00020         """Can we parse a RAF record?"""
00021         r = Raf.SeqMap(self.rafLine)
00022 
00023         self.assertEqual(r.pdbid, "101m")
00024         self.assertEqual(r.pdb_datestamp, "010301")
00025         self.assertEqual(r.flags, "111011")
00026       
00027         i = r.index("143")
00028         res = r.res[i]
00029         self.assertEqual(res.chainid, "_")
00030         self.assertEqual(res.resid, "143")
00031         self.assertEqual(res.seqres, "A")
00032         self.assertEqual(res.atom, "A")
00033 
00034         r = Raf.SeqMap(self.rafLine2)   
00035         res = r.res[r.index("6A", chainid="A")]
00036         self.assertEqual(res.resid, "6A")
00037         self.assertEqual(res.atom, "E")
00038 
00039     def testSeqMapAdd(self):
00040         r2 = Raf.SeqMap(self.rafLine2)
00041         r3 = Raf.SeqMap(self.rafLine3)
00042 
00043         l = len(r2.res) + len(r3.res)
00044         r2 += r3
00045         self.assertEqual(len(r2.res), l)
00046 
00047 
00048         r2.extend(r2)
00049         self.assertEqual(len(r2.res), l*2)
00050 
00051         r4 = r2 + r2
00052         self.assertEqual(len(r4.res), l*4)
00053 
00054         r4.append(Raf.Res())
00055         self.assertEqual(len(r4.res), (l*4)+1)
00056         
00057 
00058     def testSeqMapSlice(self):
00059         r = Raf.SeqMap(self.rafLine)
00060         r = r[ r.index("124"): r.index("135")+1]
00061         self.assertEqual(len(r.res), 12)
00062 
00063 
00064     def testSeqMapIndex(self):
00065         filename = ("./SCOP/raftest.txt")
00066         
00067         index = Raf.SeqMapIndex(filename)
00068         r = index.getSeqMap("103m")
00069         self.assertEqual(r.pdbid, "103m")
00070         self.assertEqual(len(r.res), 154)
00071         self.assertEqual(r.pdb_datestamp, "010301")
00072         self.assertEqual(r.flags, "111011")
00073 
00074         r = index.getSeqMap("103m 1-10")
00075         self.assertEqual(r.pdbid, "103m",)
00076         self.assertEqual(len(r.res), 10)
00077         self.assertEqual(r.pdb_datestamp, "010301")
00078         self.assertEqual(r.flags, "111011")
00079 
00080         r = index.getSeqMap("104l A:")
00081         self.assertEqual(r.pdbid, "104l")
00082 
00083         r = index.getSeqMap("104l A:112-113")
00084         self.assertEqual(r.pdbid, "104l")
00085         self.assertEqual(len(r.res), 2)
00086 
00087         r = index.getSeqMap("104l A:112-113,B:146-148")
00088         self.assertEqual(r.pdbid, "104l")
00089         self.assertEqual(len(r.res), 5)
00090 
00091         
00092 if __name__=='__main__':
00093     runner = unittest.TextTestRunner(verbosity = 2)
00094     unittest.main(testRunner=runner)