Back to index

python-biopython  1.60
Public Member Functions | Public Attributes
test_PDB.ParseTest Class Reference

List of all members.

Public Member Functions

def setUp
def test_c_n
def test_ca_ca
def test_structure
def test_details

Public Attributes

 structure

Detailed Description

Definition at line 142 of file test_PDB.py.


Member Function Documentation

def test_PDB.ParseTest.setUp (   self)

Definition at line 143 of file test_PDB.py.

00143 
00144     def setUp(self):
00145         warnings.simplefilter('ignore', PDBConstructionWarning)
00146         p = PDBParser(PERMISSIVE=1)
00147         self.structure = p.get_structure("example", "PDB/a_structure.pdb")
00148         warnings.filters.pop()

Extract polypeptides using C-N.

Definition at line 149 of file test_PDB.py.

00149 
00150     def test_c_n(self):
00151         """Extract polypeptides using C-N."""
00152         ppbuild = PPBuilder()
00153         polypeptides = ppbuild.build_peptides(self.structure[1])
00154         self.assertEqual(len(polypeptides), 1)
00155         pp = polypeptides[0]
00156         # Check the start and end positions
00157         self.assertEqual(pp[0].get_id()[1], 2)
00158         self.assertEqual(pp[-1].get_id()[1], 86)
00159         # Check the sequence
00160         s = pp.get_sequence()
00161         self.assertTrue(isinstance(s, Seq))
00162         self.assertEqual(s.alphabet, generic_protein)
00163         self.assertEqual("RCGSQGGGSTCPGLRCCSIWGWCGDSEPYCGRTCENKCWSGER"
00164                          "SDHRCGAAVGNPPCGQDRCCSVHGWCGGGNDYCSGGNCQYRC",
00165                          str(s))

Extract polypeptides using CA-CA.

Definition at line 166 of file test_PDB.py.

00166 
00167     def test_ca_ca(self):
00168         """Extract polypeptides using CA-CA."""
00169         ppbuild = CaPPBuilder()
00170         polypeptides = ppbuild.build_peptides(self.structure[1])
00171         self.assertEqual(len(polypeptides), 1)
00172         pp = polypeptides[0]
00173         # Check the start and end positions
00174         self.assertEqual(pp[0].get_id()[1], 2)
00175         self.assertEqual(pp[-1].get_id()[1], 86)
00176         # Check the sequence
00177         s = pp.get_sequence()
00178         self.assertTrue(isinstance(s, Seq))
00179         self.assertEqual(s.alphabet, generic_protein)
00180         self.assertEqual("RCGSQGGGSTCPGLRCCSIWGWCGDSEPYCGRTCENKCWSGER"
00181                          "SDHRCGAAVGNPPCGQDRCCSVHGWCGGGNDYCSGGNCQYRC",
00182                          str(s))

Verify details of the parsed example PDB file.

Definition at line 395 of file test_PDB.py.

00395 
00396     def test_details(self):
00397         """Verify details of the parsed example PDB file."""
00398         structure = self.structure
00399         self.assertEqual(len(structure), 2)
00400 
00401         #First model
00402         model = structure[0]
00403         self.assertEqual(model.id, 0)
00404         self.assertEqual(model.level, "M")
00405         self.assertEqual(len(model), 1)
00406         chain = model["A"]
00407         self.assertEqual(chain.id, "A")
00408         self.assertEqual(chain.level, "C")
00409         self.assertEqual(len(chain), 1)
00410         self.assertEqual(" ".join(residue.resname for residue in chain), "PCA")
00411         self.assertEqual(" ".join(atom.name for atom in chain.get_atoms()),
00412                          "N CA CB CG CD OE C O CA  ")
00413         self.assertEqual(" ".join(atom.element for atom in chain.get_atoms()),
00414                          "N C C C C O C O CA")
00415         #Second model
00416         model = structure[1]
00417         self.assertEqual(model.id, 1)
00418         self.assertEqual(model.level, "M")
00419         self.assertEqual(len(model), 3)
00420         chain = model["A"]
00421         self.assertEqual(chain.id, "A")
00422         self.assertEqual(chain.level, "C")
00423         self.assertEqual(len(chain), 86)
00424         self.assertEqual(" ".join(residue.resname for residue in chain),
00425                          "CYS ARG CYS GLY SER GLN GLY GLY GLY SER THR CYS "
00426                          "PRO GLY LEU ARG CYS CYS SER ILE TRP GLY TRP CYS "
00427                          "GLY ASP SER GLU PRO TYR CYS GLY ARG THR CYS GLU "
00428                          "ASN LYS CYS TRP SER GLY GLU ARG SER ASP HIS ARG "
00429                          "CYS GLY ALA ALA VAL GLY ASN PRO PRO CYS GLY GLN "
00430                          "ASP ARG CYS CYS SER VAL HIS GLY TRP CYS GLY GLY "
00431                          "GLY ASN ASP TYR CYS SER GLY GLY ASN CYS GLN TYR "
00432                          "ARG CYS")
00433         self.assertEqual(" ".join(atom.name for atom in chain.get_atoms()),
00434                          "C N CA C O CB CG CD NE CZ NH1 NH2 N CA C O CB SG "
00435                          "N CA C O N CA C O CB OG N CA C O CB CG CD OE1 NE2 "
00436                          "N CA C O N CA C O N CA C O N CA C O CB OG N CA C "
00437                          "O CB OG1 CG2 N CA C O CB SG N CA C O CB CG CD N "
00438                          "CA C O N CA C O CB CG CD1 CD2 N CA C O CB CG CD NE "
00439                          "CZ NH1 NH2 N CA C O CB SG N CA C O CB SG N CA C O "
00440                          "CB OG N CA C O CB CG1 CG2 CD1 N CA C O CB CG CD1 "
00441                          "CD2 NE1 CE2 CE3 CZ2 CZ3 CH2 N CA C O N CA C O CB "
00442                          "CG CD1 CD2 NE1 CE2 CE3 CZ2 CZ3 CH2 N CA C O CB SG "
00443                          "N CA C O N CA C O CB CG OD1 OD2 N CA C O CB OG N "
00444                          "CA C O CB CG CD OE1 OE2 N CA C O CB CG CD N CA C O "
00445                          "CB CG CD1 CD2 CE1 CE2 CZ OH N CA C O CB SG N CA C "
00446                          "O N CA C O CB CG CD NE CZ NH1 NH2 N CA C O CB OG1 "
00447                          "CG2 N CA C O CB SG N CA C O CB CG CD OE1 OE2 N CA "
00448                          "C O CB CG OD1 ND2 N CA C O CB CG CD CE NZ N CA C O "
00449                          "CB SG N CA C O CB CG CD1 CD2 NE1 CE2 CE3 CZ2 CZ3 "
00450                          "CH2 N CA C O CB OG N CA C O N CA C O CB CG CD OE1 "
00451                          "OE2 N CA C O CB CG CD NE CZ NH1 NH2 N CA C O CB OG "
00452                          "N CA C O CB CG OD1 OD2 N CA C O CB CG ND1 CD2 CE1 "
00453                          "NE2 N CA C O CB CG CD NE CZ NH1 NH2 N CA C O CB SG "
00454                          "N CA C O N CA C O CB N CA C O CB N CA C O CB CG1 "
00455                          "CG2 N CA C O N CA C O CB CG OD1 ND2 N CA C O CB CG "
00456                          "CD N CA C O CB CG CD N CA C O CB SG N CA C O N CA "
00457                          "C O CB CG CD OE1 NE2 N CA C O CB CG OD1 OD2 N CA C "
00458                          "O CB CG CD NE CZ NH1 NH2 N CA C O CB SG N CA C O "
00459                          "CB SG N CA C O CB OG N CA C O CB CG1 CG2 N CA C O "
00460                          "CB CG ND1 CD2 CE1 NE2 N CA C O N CA C O CB CG CD1 "
00461                          "CD2 NE1 CE2 CE3 CZ2 CZ3 CH2 N CA C O CB SG N CA C "
00462                          "O N CA C O N CA C O N CA C O CB CG OD1 ND2 N CA C O "
00463                          "CB CG OD1 OD2 N CA C O CB CG CD1 CD2 CE1 CE2 CZ OH "
00464                          "N CA C O CB SG N CA C O CB OG N CA C O N CA C O N "
00465                          "CA C O CB CG OD1 ND2 N CA C O CB SG N CA C O CB CG "
00466                          "CD OE1 NE2 N CA C O CB CG CD1 CD2 CE1 CE2 CZ OH N "
00467                          "CA C O CB CG CD NE CZ NH1 NH2 N CA C O CB SG")
00468         self.assertEqual(" ".join(atom.element for atom in chain.get_atoms()),
00469                          "C N C C O C C C N C N N N C C O C S N C C O N C C O "
00470                          "C O N C C O C C C O N N C C O N C C O N C C O N C C "
00471                          "O C O N C C O C O C N C C O C S N C C O C C C N C C "
00472                          "O N C C O C C C C N C C O C C C N C N N N C C O C S "
00473                          "N C C O C S N C C O C O N C C O C C C C N C C O C C "
00474                          "C C N C C C C C N C C O N C C O C C C C N C C C C C "
00475                          "N C C O C S N C C O N C C O C C O O N C C O C O N C "
00476                          "C O C C C O O N C C O C C C N C C O C C C C C C C O "
00477                          "N C C O C S N C C O N C C O C C C N C N N N C C O C "
00478                          "O C N C C O C S N C C O C C C O O N C C O C C O N N "
00479                          "C C O C C C C N N C C O C S N C C O C C C C N C C C "
00480                          "C C N C C O C O N C C O N C C O C C C O O N C C O C "
00481                          "C C N C N N N C C O C O N C C O C C O O N C C O C C "
00482                          "N C C N N C C O C C C N C N N N C C O C S N C C O N "
00483                          "C C O C N C C O C N C C O C C C N C C O N C C O C C "
00484                          "O N N C C O C C C N C C O C C C N C C O C S N C C O "
00485                          "N C C O C C C O N N C C O C C O O N C C O C C C N C "
00486                          "N N N C C O C S N C C O C S N C C O C O N C C O C C "
00487                          "C N C C O C C N C C N N C C O N C C O C C C C N C C "
00488                          "C C C N C C O C S N C C O N C C O N C C O N C C O C "
00489                          "C O N N C C O C C O O N C C O C C C C C C C O N C C "
00490                          "O C S N C C O C O N C C O N C C O N C C O C C O N N "
00491                          "C C O C S N C C O C C C O N N C C O C C C C C C C O "
00492                          "N C C O C C C N C N N N C C O C S")
00493 

Verify the structure of the parsed example PDB file.

Definition at line 183 of file test_PDB.py.

00183 
00184     def test_structure(self):
00185         """Verify the structure of the parsed example PDB file."""
00186         # Structure contains 2 models
00187         self.assertEqual(len(self.structure), 2)
00188         # --- Checking model 0 ---
00189         m0 = self.structure[0]
00190         # Model 0 contains 1 chain
00191         self.assertEqual(len(m0), 1)
00192         # Chain 'A' contains 1 residue
00193         self.assertEqual(len(m0['A']), 1)
00194         # Residue ('H_PCA', 1, ' ') contains 8 atoms.
00195         residue = m0['A'].get_list()[0]
00196         self.assertEqual(residue.get_id(), ('H_PCA', 1, ' '))
00197         self.assertEqual(len(residue), 9)
00198         # --- Checking model 1 ---
00199         m1 = self.structure[1]
00200         # Model 1 contains 3 chains
00201         self.assertEqual(len(m1), 3)
00202         # Deconstruct this data structure to check each chain
00203         chain_data = [ # chain_id, chain_len, [(residue_id, residue_len), ...]
00204             ('A', 86, [ ((' ', 0, ' '), 1 ),
00205                         ((' ', 2, ' '), 11),
00206                         ((' ', 3, ' '), 6, 1), # disordered
00207                         ((' ', 4, ' '), 4 ),
00208                         ((' ', 5, ' '), 6 ),
00209                         ((' ', 6, ' '), 9 ),
00210                         ((' ', 7, ' '), 4 ),
00211                         ((' ', 8, ' '), 4 ),
00212                         ((' ', 9, ' '), 4 ),
00213                         ((' ', 10, ' '), 6, ['GLY', 'SER']), # point mut
00214                         ((' ', 11, ' '), 7 ),
00215                         ((' ', 12, ' '), 6 ),
00216                         ((' ', 13, ' '), 7 ),
00217                         ((' ', 14, ' '), 4, ['ALA', 'GLY']), # point mut
00218                         ((' ', 15, ' '), 8, 3), # disordered
00219                         ((' ', 16, ' '), 11, ['ARG', 'TRP']), # point mut
00220                         ((' ', 17, ' '), 6 ),
00221                         ((' ', 18, ' '), 6 ),
00222                         ((' ', 19, ' '), 6 ),
00223                         ((' ', 20, ' '), 8 ),
00224                         ((' ', 21, ' '), 14),
00225                         ((' ', 22, ' '), 4 ),
00226                         ((' ', 23, ' '), 14),
00227                         ((' ', 24, ' '), 6 ),
00228                         ((' ', 25, ' '), 4 ),
00229                         ((' ', 26, ' '), 8 ),
00230                         ((' ', 27, ' '), 6 ),
00231                         ((' ', 28, ' '), 9, 5), # disordered
00232                         ((' ', 29, ' '), 7 ),
00233                         ((' ', 30, ' '), 12),
00234                         ((' ', 31, ' '), 6 ),
00235                         ((' ', 32, ' '), 4 ),
00236                         ((' ', 33, ' '), 11),
00237                         ((' ', 34, ' '), 7 ),
00238                         ((' ', 35, ' '), 6 ),
00239                         ((' ', 36, ' '), 9 ),
00240                         ((' ', 37, ' '), 8 ),
00241                         ((' ', 38, ' '), 9 ),
00242                         ((' ', 39, ' '), 6 ),
00243                         ((' ', 40, ' '), 14),
00244                         ((' ', 41, ' '), 6 ),
00245                         ((' ', 42, ' '), 4 ),
00246                         ((' ', 43, ' '), 9 ),
00247                         ((' ', 44, ' '), 11),
00248                         ((' ', 45, ' '), 6, 1), # disordered
00249                         ((' ', 46, ' '), 8 ),
00250                         ((' ', 47, ' '), 10),
00251                         ((' ', 48, ' '), 11),
00252                         ((' ', 49, ' '), 6 ),
00253                         ((' ', 50, ' '), 4 ),
00254                         ((' ', 51, ' '), 5 ),
00255                         ((' ', 52, ' '), 5 ),
00256                         ((' ', 53, ' '), 7 ),
00257                         ((' ', 54, ' '), 4 ),
00258                         ((' ', 55, ' '), 8 ),
00259                         ((' ', 56, ' '), 7 ),
00260                         ((' ', 57, ' '), 7 ),
00261                         ((' ', 58, ' '), 6 ),
00262                         ((' ', 59, ' '), 4 ),
00263                         ((' ', 60, ' '), 9 ),
00264                         ((' ', 61, ' '), 8 ),
00265                         ((' ', 62, ' '), 11),
00266                         ((' ', 63, ' '), 6 ),
00267                         ((' ', 64, ' '), 6 ),
00268                         ((' ', 65, ' '), 6 ),
00269                         ((' ', 66, ' '), 7 ),
00270                         ((' ', 67, ' '), 10),
00271                         ((' ', 68, ' '), 4 ),
00272                         ((' ', 69, ' '), 14),
00273                         ((' ', 70, ' '), 6 ),
00274                         ((' ', 71, ' '), 4 ),
00275                         ((' ', 72, ' '), 4 ),
00276                         ((' ', 73, ' '), 4 ),
00277                         ((' ', 74, ' '), 8, 3), # disordered
00278                         ((' ', 75, ' '), 8 ),
00279                         ((' ', 76, ' '), 12),
00280                         ((' ', 77, ' '), 6 ),
00281                         ((' ', 78, ' '), 6 ),
00282                         ((' ', 79, ' '), 4, 4), # disordered
00283                         ((' ', 80, ' '), 4, ['GLY', 'SER']), # point mut
00284                         ((' ', 81, ' '), 8, ['ASN', 'LYS']), # point mut
00285                         ((' ', 82, ' '), 6 ),
00286                         ((' ', 83, ' '), 9 ),
00287                         ((' ', 84, ' '), 12),
00288                         ((' ', 85, ' '), 11),
00289                         ((' ', 86, ' '), 6 ),
00290                         ]),
00291             ('B', 4, [ (('H_NAG', 1, ' '), 14),
00292                         (('H_NAG', 2, ' '), 14),
00293                         (('H_NAG', 3, ' '), 14),
00294                         (('H_NAG', 4, ' '), 14),
00295                         ]),
00296             (' ', 76, [ (('W', 1, ' '), 1),
00297                         (('W', 2, ' '), 1),
00298                         (('W', 3, ' '), 1),
00299                         (('W', 4, ' '), 1),
00300                         (('W', 5, ' '), 1),
00301                         (('W', 6, ' '), 1),
00302                         (('W', 7, ' '), 1),
00303                         (('W', 8, ' '), 1),
00304                         (('W', 9, ' '), 1),
00305                         (('W', 10, ' '), 1),
00306                         (('W', 11, ' '), 1),
00307                         (('W', 12, ' '), 1),
00308                         (('W', 13, ' '), 1),
00309                         (('W', 14, ' '), 1),
00310                         (('W', 15, ' '), 1),
00311                         (('W', 16, ' '), 1),
00312                         (('W', 17, ' '), 1),
00313                         (('W', 18, ' '), 1),
00314                         (('W', 19, ' '), 1),
00315                         (('W', 20, ' '), 1),
00316                         (('W', 21, ' '), 1),
00317                         (('W', 22, ' '), 1),
00318                         (('W', 23, ' '), 1),
00319                         (('W', 24, ' '), 1),
00320                         (('W', 25, ' '), 1),
00321                         (('W', 26, ' '), 1),
00322                         (('W', 27, ' '), 1),
00323                         (('W', 28, ' '), 1),
00324                         (('W', 29, ' '), 1),
00325                         (('W', 30, ' '), 1),
00326                         (('W', 31, ' '), 1),
00327                         (('W', 32, ' '), 1),
00328                         (('W', 33, ' '), 1),
00329                         (('W', 34, ' '), 1),
00330                         (('W', 35, ' '), 1),
00331                         (('W', 36, ' '), 1),
00332                         (('W', 37, ' '), 1),
00333                         (('W', 38, ' '), 1),
00334                         (('W', 39, ' '), 1),
00335                         (('W', 40, ' '), 1),
00336                         (('W', 41, ' '), 1),
00337                         (('W', 42, ' '), 1),
00338                         (('W', 43, ' '), 1),
00339                         (('W', 44, ' '), 1),
00340                         (('W', 45, ' '), 1),
00341                         (('W', 46, ' '), 1),
00342                         (('W', 47, ' '), 1),
00343                         (('W', 48, ' '), 1),
00344                         (('W', 49, ' '), 1),
00345                         (('W', 50, ' '), 1),
00346                         (('W', 51, ' '), 1),
00347                         (('W', 52, ' '), 1),
00348                         (('W', 53, ' '), 1),
00349                         (('W', 54, ' '), 1),
00350                         (('W', 55, ' '), 1),
00351                         (('W', 56, ' '), 1),
00352                         (('W', 57, ' '), 1),
00353                         (('W', 58, ' '), 1),
00354                         (('W', 59, ' '), 1),
00355                         (('W', 60, ' '), 1),
00356                         (('W', 61, ' '), 1),
00357                         (('W', 62, ' '), 1),
00358                         (('W', 63, ' '), 1),
00359                         (('W', 64, ' '), 1),
00360                         (('W', 65, ' '), 1),
00361                         (('W', 66, ' '), 1),
00362                         (('W', 67, ' '), 1),
00363                         (('W', 68, ' '), 1),
00364                         (('W', 69, ' '), 1),
00365                         (('W', 70, ' '), 1),
00366                         (('W', 71, ' '), 1),
00367                         (('W', 72, ' '), 1),
00368                         (('W', 73, ' '), 1),
00369                         (('W', 74, ' '), 1),
00370                         (('W', 75, ' '), 1),
00371                         (('W', 77, ' '), 1),
00372                         ])
00373                         ]
00374  
00375         for c_idx, chn in enumerate(chain_data):
00376             # Check chain ID and length
00377             chain = m1.get_list()[c_idx]
00378             self.assertEqual(chain.get_id(), chn[0])
00379             self.assertEqual(len(chain), chn[1])
00380             for r_idx, res in enumerate(chn[2]):
00381                 residue = chain.get_list()[r_idx]
00382                 # Check residue ID and atom count
00383                 self.assertEqual(residue.get_id(), res[0])
00384                 self.assertEqual(len(residue), res[1])
00385                 disorder_lvl = residue.is_disordered()
00386                 if disorder_lvl == 1:
00387                     # Check the number of disordered atoms
00388                     disordered_count = sum(1 for atom in residue
00389                                            if atom.is_disordered())
00390                     if disordered_count:
00391                         self.assertEqual(disordered_count, res[2])
00392                 elif disorder_lvl == 2:
00393                     # Point mutation -- check residue names
00394                     self.assertEqual(residue.disordered_get_id_list(), res[2])


Member Data Documentation

Definition at line 146 of file test_PDB.py.


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