Back to index

python-biopython  1.60
Public Member Functions | Public Attributes
test_Crystal.ChainTestCase Class Reference

List of all members.

Public Member Functions

def setUp
def testEquals
def testLen
def testAppend
def testInsert
def testRemove
def testCount
def testIndex
def testGetItem
def testSetItem
def testDelItem
def testGetSlice
def testSetSlice
def testDelSlice
def testContains
def testAdd

Public Attributes

 a
 b
 c
 d
 e
 f
 g
 h

Detailed Description

Definition at line 14 of file test_Crystal.py.


Member Function Documentation

Definition at line 16 of file test_Crystal.py.

00016 
00017     def setUp(self):
00018         self.a = 'C A A C T A G G T C A C U A G G T C A G'
00019         self.b = 'C T G A C C T A G T G A C C T A G T T G'
00020         self.c = 'THR LYS LEU ASN GLY MET VAL LEU LEU CYS LYS VAL CYS GLY ASP'
00021         self.d = 'THR LYS LEU ASN GLY MET VAL LEU LEU CYS LYS VAL CYS GLY ASP '
00022         self.e = 'TYR LYS LEU ASN GLY MET VAL LEU LEU CYS LYS VAL CYS GLY ASP '
00023         self.f = 'THR LYS LEU ASN GLY MET VAL LEU LEU CYS LYS VAL CYS GLY SER '
00024         self.g = 'C A A C T A G G T C A C U A G G T C A T'
00025         self.h = 'G A A C T A G G T C A C U A G G T C A G'

Definition at line 407 of file test_Crystal.py.

00407 
00408     def testAdd(self):
00409         texta = 'G U G G U C U G A U G A G G C C'
00410         textb = 'G G C C G A A A C U C G U A A G A G U C A C C A C'
00411         targeta = texta + Chain(textb)
00412         targetb = Chain(texta) + textb
00413         targetc = Chain(texta) + Chain(textb)
00414         self.assertEqual(targeta, targetc)
00415         self.assertEqual(targetb, targetc)
00416         self.assertEqual(targeta, targetb)
00417         self.assertEqual(len(targeta), len(Chain(texta)) + len(Chain(textb)))
00418 
00419         targetd = Chain(texta)
00420         targetd += textb
00421 
00422         targete = Chain(texta)
00423         targete += Chain(textb)
00424         self.assertEqual(targetd, targetc)
00425         self.assertEqual(targete, targetb)
00426 
00427 
00428 

Definition at line 73 of file test_Crystal.py.

00073 
00074     def testAppend(self):
00075         chain = Chain(self.a[:])
00076         chain.append('U')
00077         elements = self.a.strip().split()
00078         num_elements = len(elements)
00079         last_element = chain.data[ -1 ]
00080         self.assertEqual('u', last_element.data)
00081         self.assertEqual(len(chain), num_elements + 1)
00082 
00083         chain = Chain(self.a[:])
00084         chain.append(Hetero('A'))
00085         elements = self.a.strip().split()
00086         num_elements = len(elements)
00087         last_element = chain.data[ -1 ]
00088         self.assertEqual('a', last_element.data)
00089         self.assertEqual(len(chain), num_elements + 1)
00090 
00091         chain = Chain(self.b[:])
00092         chain.append('t')
00093         elements = self.b.strip().split()
00094         num_elements = len(elements)
00095         last_element = chain.data[ -1 ]
00096         self.assertEqual('t', last_element.data)
00097         self.assertEqual(len(chain), num_elements + 1)
00098 
00099         chain = Chain(self.b[:])
00100         chain.append(Hetero('C'))
00101         elements = self.b.strip().split()
00102         num_elements = len(elements)
00103         last_element = chain.data[ -1 ]
00104         self.assertEqual('c', last_element.data)
00105         self.assertEqual(len(chain), num_elements + 1)
00106 
00107         chain = Chain(self.c[:])
00108         chain.append('ser')
00109         elements = self.c.strip().split()
00110         num_elements = len(elements)
00111         last_element = chain.data[ -1 ]
00112         self.assertEqual('ser', last_element.data)
00113         self.assertEqual(len(chain), num_elements + 1)
00114 

Definition at line 401 of file test_Crystal.py.

00401 
00402     def testContains(self):
00403         chain = Chain(self.c[ : ])
00404         self.assertFalse('ser' in chain)
00405         self.assertTrue('lys' in chain)
00406         self.assertTrue('asp' in chain)

Definition at line 183 of file test_Crystal.py.

00183 
00184     def testCount(self):
00185         chain = Chain(self.a[:])
00186         num_a = chain.data.count(Hetero('a'))
00187         self.assertEqual(chain.count('a'), num_a)
00188 
00189         chain = Chain(self.b[:])
00190         num_a = chain.data.count(Hetero('t'))
00191         self.assertEqual(chain.count('t'), num_a)
00192 
00193         chain = Chain(self.c[:])
00194         num_a = chain.data.count(Hetero('leu'))
00195         self.assertEqual(chain.count('leu'), num_a)
00196 
00197         chain = Chain(self.c[:])
00198         num_a = chain.data.count(Hetero('cys'))
00199         self.assertEqual(chain.count('cys'), num_a)
00200 

Definition at line 261 of file test_Crystal.py.

00261 
00262     def testDelItem(self):
00263 
00264         chain = Chain(self.a[:])
00265         elements = self.a.strip().split()
00266         num_elements = len(elements)
00267         num_t = chain.data.count(Hetero('t'))
00268         del chain[ 4 ]
00269         num_t_remaining = chain.data.count(Hetero('t'))
00270         self.assertEqual(num_t_remaining, num_t - 1)
00271         self.assertEqual(len(chain), num_elements - 1)
00272 
00273         chain = Chain(self.a[:])
00274         elements = self.a.strip().split()
00275         num_elements = len(elements)
00276         num_u = chain.data.count(Hetero('u'))
00277         del chain[ 12 ]
00278         num_u_remaining = 0
00279         self.assertEqual(num_u_remaining, num_u - 1)
00280         self.assertEqual(len(chain), num_elements - 1)
00281 
00282         chain = Chain(self.b[:])
00283         elements = self.b.strip().split()
00284         num_elements = len(elements)
00285         num_c = chain.data.count(Hetero('c'))
00286         del chain[ 0 ]
00287         num_c_remaining = chain.data.count(Hetero('c'))
00288         self.assertEqual(num_c_remaining, num_c - 1)
00289         self.assertEqual(len(chain), num_elements - 1)
00290 
00291         chain = Chain(self.b[:])
00292         elements = self.b.strip().split()
00293         num_elements = len(elements)
00294         num_g = chain.data.count(Hetero('t'))
00295         del chain[ 6 ]
00296         num_g_remaining = chain.data.count(Hetero('t'))
00297         self.assertEqual(num_g_remaining, num_g - 1)
00298         self.assertEqual(len(chain), num_elements - 1)
00299 
00300         chain = Chain(self.c[:])
00301         elements = self.c.strip().split()
00302         num_elements = len(elements)
00303         num_thr = chain.data.count(Hetero('thr'))
00304         del chain[ 0 ]
00305         num_thr_remaining = chain.data.count(Hetero('thr'))
00306         self.assertEqual(num_thr_remaining, num_thr - 1)
00307         self.assertEqual(len(chain), num_elements - 1)

Definition at line 381 of file test_Crystal.py.

00381 
00382     def testDelSlice(self):
00383         chain = Chain(self.c[ : ])
00384         old_chain = Chain(self.c[ : ])
00385         del chain[ 3 : 8 ]
00386         other = Chain(old_chain.data[ :3 ] + old_chain.data[ 8: ])
00387         self.assertEqual(chain, other)
00388 
00389         chain = Chain(self.c[:] )
00390         old_chain = Chain(self.c[ : ])
00391         del chain[ :4 ]
00392         other = Chain(old_chain.data[ 4: ])
00393         self.assertEqual(chain, other)
00394 
00395         chain = Chain(self.c[:] )
00396         old_chain = Chain(self.c[ : ])
00397         del chain[ 9: ]
00398         other = Chain(old_chain.data[ :9 ])
00399         self.assertEqual(chain, other)
00400 

Definition at line 26 of file test_Crystal.py.

00026 
00027     def testEquals(self):
00028         first = Chain(self.a)
00029         second = Chain(self.a)
00030         self.assertEqual(first, second)
00031 
00032         first = Chain(self.b)
00033         second = Chain(self.b)
00034         self.assertEqual(first, second)
00035 
00036         first = Chain(self.c)
00037         second = Chain(self.c)
00038         self.assertEqual(first, second)
00039 
00040         first = Chain(self.a)
00041         second = Chain(self.g)
00042         self.assertNotEqual(first, second)
00043 
00044         first = Chain(self.a)
00045         second = Chain(self.h)
00046         self.assertNotEqual(first, second)
00047 
00048         first = Chain(self.c)
00049         second = Chain(self.e)
00050         self.assertNotEqual(first, second)
00051 
00052         first = Chain(self.c)
00053         second = Chain(self.f)
00054         self.assertNotEqual(first, second)
00055 

Definition at line 214 of file test_Crystal.py.

00214 
00215     def testGetItem(self):
00216         chain = Chain(self.a[:])
00217         element_3 = chain.data[ 3 ]
00218         self.assertEqual(chain[ 3 ], element_3)
00219 
00220         chain = Chain(self.a[:])
00221         element_0 = chain.data[ 0 ]
00222         self.assertEqual(chain[ 0 ], element_0)
00223 
00224         chain = Chain(self.b[:])
00225         element_7 = chain.data[ 7 ]
00226         self.assertEqual(chain[ 7 ], element_7)
00227 
00228         chain = Chain(self.b[:])
00229         last_element = chain.data[ -1 ]
00230         self.assertEqual(chain[ -1 ], last_element)
00231 
00232         chain = Chain(self.c[:])
00233         element_8 = chain.data[ 8 ]
00234         self.assertEqual(chain[ 8 ], element_8)

Definition at line 308 of file test_Crystal.py.

00308 
00309     def testGetSlice(self):
00310         chain = Chain(self.a[:] )
00311         first = 0
00312         last = len(chain)
00313         slice = chain[ : ]
00314         other = chain.data[:]
00315         self.assertEqual(slice.data, other)
00316 
00317 
00318         chain = Chain(self.a[:] )
00319         first = 0
00320         last = 4
00321         slice = chain[ first : last ]
00322         other = chain.data[ first : last ]
00323         self.assertEqual(slice.data, other)
00324 
00325         chain = Chain(self.b[:])
00326         first = 2
00327         last = len(chain)
00328         slice = chain[ first: last ]
00329         other = chain.data[ first : last ]
00330         self.assertEqual(slice.data, other)
00331 
00332         chain = Chain(self.b[:])
00333         first = -1
00334         slice = chain[ first : ]
00335         other = chain.data[ first:  ]
00336         self.assertEqual(slice.data, other)
00337 
00338         chain = Chain(self.c[:])
00339         first = 3
00340         last = 7
00341         slice = chain[ first : last ]
00342         other = chain.data[ first: last ]
00343         self.assertEqual(slice.data, other)
00344 
00345         chain = Chain(self.c[:])
00346         first = 3
00347         last = -1
00348         slice = chain[ first : last ]
00349         other = chain.data[ first: last ]
00350         self.assertEqual(slice.data, other)
00351 

Definition at line 201 of file test_Crystal.py.

00201 
00202     def testIndex(self):
00203         chain = Chain(self.a[:])
00204         index_g = chain.data.index(Hetero('g'))
00205         self.assertEqual(chain.index('g'), index_g)
00206 
00207         chain = Chain(self.b[:])
00208         index_c = chain.data.index(Hetero('c'))
00209         self.assertEqual(chain.index('c'), index_c)
00210 
00211         chain = Chain(self.c[:])
00212         index_met = chain.data.index(Hetero('met'))
00213         self.assertEqual(chain.index('met'), index_met)

Definition at line 115 of file test_Crystal.py.

00115 
00116     def testInsert(self):
00117         chain = Chain(self.a[:])
00118         i = 4
00119         chain.insert(i, 'g')
00120         elements = self.a.strip().split()
00121         num_elements = len(elements)
00122         target_element = chain.data[ i ]
00123         self.assertEqual('g', target_element.data)
00124         self.assertEqual(len(chain), num_elements + 1)
00125 
00126         chain = Chain(self.a[:])
00127         i = 0
00128         chain.insert(i, 't')
00129         elements = self.a.strip().split()
00130         num_elements = len(elements)
00131         target_element = chain.data[ i ]
00132         self.assertEqual('t', target_element.data)
00133         self.assertEqual(len(chain), num_elements + 1)
00134 
00135         chain = Chain(self.b[:])
00136         i = 9
00137         chain.insert(i, Hetero('a'))
00138         elements = self.a.strip().split()
00139         num_elements = len(elements)
00140         target_element = chain.data[ i ]
00141         self.assertEqual('a', target_element.data)
00142         self.assertEqual(len(chain), num_elements + 1)
00143 
00144         chain = Chain(self.c[:])
00145         i = 5
00146         chain.insert(i, 'gln')
00147         elements = self.c.strip().split()
00148         num_elements = len(elements)
00149         target_element = chain.data[ i ]
00150         self.assertEqual('gln', target_element.data)
00151         self.assertEqual(len(chain), num_elements + 1)
00152 

Definition at line 56 of file test_Crystal.py.

00056 
00057     def testLen(self):
00058         chain = Chain(self.a)
00059         elements = self.a.strip().split()
00060         num_elements = len(elements)
00061         self.assertEqual(len(chain), num_elements)
00062 
00063         chain = Chain(self.b)
00064         elements = self.b.strip().split()
00065         num_elements = len(elements)
00066         self.assertEqual(len(chain), num_elements)
00067 
00068         chain = Chain(self.c)
00069         elements = self.c.strip().split()
00070         num_elements = len(elements)
00071         self.assertEqual(len(chain), num_elements)
00072 

Definition at line 153 of file test_Crystal.py.

00153 
00154     def testRemove(self):
00155 
00156         chain = Chain(self.a[:])
00157         elements = self.a.strip().split()
00158         num_elements = len(elements)
00159         num_a = chain.data.count(Hetero('a'))
00160         chain.remove('a')
00161         num_a_remaining = chain.data.count(Hetero('a'))
00162         self.assertEqual(num_a_remaining, num_a - 1)
00163         self.assertEqual(len(chain), num_elements - 1)
00164 
00165         chain = Chain(self.b[:])
00166         elements = self.b.strip().split()
00167         num_elements = len(elements)
00168         num_b = chain.data.count(Hetero('t'))
00169         chain.remove('t')
00170         num_b_remaining = chain.data.count(Hetero('t'))
00171         self.assertEqual(num_b_remaining, num_b - 1)
00172         self.assertEqual(len(chain), num_elements - 1)
00173 
00174         chain = Chain(self.c[:])
00175         elements = self.c.strip().split()
00176         num_elements = len(elements)
00177         num_leu = chain.data.count(Hetero('leu'))
00178         chain.remove('leu')
00179         num_leu_remaining = chain.data.count(Hetero('leu'))
00180         self.assertEqual(num_leu_remaining, num_leu - 1)
00181         self.assertEqual(len(chain), num_elements - 1)
00182 

Definition at line 235 of file test_Crystal.py.

00235 
00236     def testSetItem(self):
00237         chain = Chain(self.a[:])
00238         chain[ 2 ] = 't'
00239         element_2 = chain.data[ 2 ]
00240         self.assertEqual(chain[ 2 ], element_2)
00241 
00242         chain = Chain(self.a[:])
00243         chain[ 0 ] = Hetero('U')
00244         element_0 = chain.data[ 0 ]
00245         self.assertEqual(chain[ 0 ], element_0)
00246 
00247         chain = Chain(self.b[:])
00248         chain[ -1 ] = Hetero('c')
00249         last_element = chain.data[ -1 ]
00250         self.assertEqual(chain[ -1 ], last_element)
00251 
00252         chain = Chain(self.b[:])
00253         chain[ 1 ] = 'a'
00254         element_1 = chain.data[ 1 ]
00255         self.assertEqual(chain[ 1 ], element_1)
00256 
00257         chain = Chain(self.c[:])
00258         chain[ 5 ] = 'ser'
00259         element_5 = chain.data[ 5 ]
00260         self.assertEqual(chain[ 5 ], element_5)

Definition at line 352 of file test_Crystal.py.

00352 
00353     def testSetSlice(self):
00354         chain = Chain(self.a[:] )
00355         slice = 'G T C A G 5NC G C A T G G'
00356         chain[ : ] = slice[ 4 : 7 ]
00357         other = Chain(slice[ 4: 7 ] )
00358         self.assertEqual(chain, other)
00359 
00360 
00361         chain = Chain(self.c[:] )
00362         old_chain = Chain(self.c[ : ])
00363         slice = 'MET ILE GLU ILE LYS ASP'
00364         chain[ 2 : 5 ] = slice
00365         other = Chain(old_chain.data[ :2 ] + Chain(slice).data + old_chain.data[ 5: ])
00366         self.assertEqual(chain, other)
00367 
00368         chain = Chain(self.c[:] )
00369         old_chain = Chain(self.c[ : ])
00370         slice = 'CYS GLY ALA GLU CYS VAL TYR'
00371         chain[ 7 : ] = slice
00372         other = Chain(old_chain.data[ :7 ] + Chain(slice).data)
00373         self.assertEqual(chain, other)
00374 
00375         chain = Chain(self.c[:] )
00376         old_chain = Chain(self.c[ : ])
00377         slice = 'SER ASN GLU TRP ASP '
00378         chain[ : 9 ] = slice
00379         other = Chain(Chain(slice).data + old_chain.data[ 9: ])
00380         self.assertEqual(chain, other)


Member Data Documentation

Definition at line 17 of file test_Crystal.py.

Definition at line 18 of file test_Crystal.py.

Definition at line 19 of file test_Crystal.py.

Definition at line 20 of file test_Crystal.py.

Definition at line 21 of file test_Crystal.py.

Definition at line 22 of file test_Crystal.py.

Definition at line 23 of file test_Crystal.py.

Definition at line 24 of file test_Crystal.py.


The documentation for this class was generated from the following file: