Back to index

python-biopython  1.60
Public Member Functions
test_PDB.ParseReal Class Reference

List of all members.

Public Member Functions

def test_empty
def test_c_n
def test_strict
def test_model_numbering

Detailed Description

Testing with real PDB files.

Definition at line 494 of file test_PDB.py.


Member Function Documentation

Extract polypeptides from 1A80.

Definition at line 509 of file test_PDB.py.

00509 
00510     def test_c_n(self):
00511         """Extract polypeptides from 1A80."""
00512         parser = PDBParser(PERMISSIVE=False)
00513         structure = parser.get_structure("example", "PDB/1A8O.pdb")
00514         self.assertEqual(len(structure), 1)
00515         for ppbuild in [PPBuilder(), CaPPBuilder()]:
00516             #==========================================================
00517             #First try allowing non-standard amino acids,
00518             polypeptides = ppbuild.build_peptides(structure[0], False)
00519             self.assertEqual(len(polypeptides), 1)
00520             pp = polypeptides[0]
00521             # Check the start and end positions
00522             self.assertEqual(pp[0].get_id()[1], 151)
00523             self.assertEqual(pp[-1].get_id()[1], 220)
00524             # Check the sequence
00525             s = pp.get_sequence()
00526             self.assertTrue(isinstance(s, Seq))
00527             self.assertEqual(s.alphabet, generic_protein)
00528             #Here non-standard MSE are shown as M
00529             self.assertEqual("MDIRQGPKEPFRDYVDRFYKTLRAEQASQEVKNWMTETLLVQ"
00530                              "NANPDCKTILKALGPGATLEEMMTACQG", str(s))
00531             #==========================================================
00532             #Now try strict version with only standard amino acids
00533             #Should ignore MSE 151 at start, and then break the chain
00534             #at MSE 185, and MSE 214,215
00535             polypeptides = ppbuild.build_peptides(structure[0], True)
00536             self.assertEqual(len(polypeptides), 3)
00537             #First fragment
00538             pp = polypeptides[0]
00539             self.assertEqual(pp[0].get_id()[1], 152)
00540             self.assertEqual(pp[-1].get_id()[1], 184)
00541             s = pp.get_sequence()
00542             self.assertTrue(isinstance(s, Seq))
00543             self.assertEqual(s.alphabet, generic_protein)
00544             self.assertEqual("DIRQGPKEPFRDYVDRFYKTLRAEQASQEVKNW", str(s))
00545             #Second fragment
00546             pp = polypeptides[1]
00547             self.assertEqual(pp[0].get_id()[1], 186)
00548             self.assertEqual(pp[-1].get_id()[1], 213)
00549             s = pp.get_sequence()
00550             self.assertTrue(isinstance(s, Seq))
00551             self.assertEqual(s.alphabet, generic_protein)
00552             self.assertEqual("TETLLVQNANPDCKTILKALGPGATLEE", str(s))
00553             #Third fragment
00554             pp = polypeptides[2]
00555             self.assertEqual(pp[0].get_id()[1], 216)
00556             self.assertEqual(pp[-1].get_id()[1], 220)
00557             s = pp.get_sequence()
00558             self.assertTrue(isinstance(s, Seq))
00559             self.assertEqual(s.alphabet, generic_protein)
00560             self.assertEqual("TACQG", str(s))

Parse an empty file.

Definition at line 497 of file test_PDB.py.

00497 
00498     def test_empty(self):
00499         """Parse an empty file."""
00500         parser = PDBParser()
00501         filenumber, filename = tempfile.mkstemp()
00502         os.close(filenumber)
00503         try:
00504             struct = parser.get_structure('MT', filename)
00505             # Structure has no children (models)
00506             self.assertFalse(len(struct))
00507         finally:
00508             os.remove(filename)

Preserve model serial numbers during I/O.

Definition at line 655 of file test_PDB.py.

00655 
00656     def test_model_numbering(self):
00657         """Preserve model serial numbers during I/O."""
00658         def confirm_numbering(struct):
00659             self.assertEqual(len(struct), 20)
00660             for idx, model in enumerate(struct):
00661                 self.assertTrue(model.serial_num, idx + 1)
00662                 self.assertTrue(model.serial_num, model.id + 1)
00663         parser = PDBParser()
00664         struct1 = parser.get_structure("1mot", "PDB/1MOT.pdb")
00665         confirm_numbering(struct1)
00666         # Round trip: serialize and parse again
00667         io = PDBIO()
00668         io.set_structure(struct1)
00669         filenumber, filename = tempfile.mkstemp()
00670         os.close(filenumber)
00671         try:
00672             io.save(filename)
00673             struct2 = parser.get_structure("1mot", filename)
00674             confirm_numbering(struct2)
00675         finally:
00676             os.remove(filename)
00677 

Parse 1A8O.pdb file in strict mode.

Definition at line 561 of file test_PDB.py.

00561 
00562     def test_strict(self):
00563         """Parse 1A8O.pdb file in strict mode."""
00564         parser = PDBParser(PERMISSIVE=False)
00565         structure = parser.get_structure("example", "PDB/1A8O.pdb")
00566         self.assertEqual(len(structure), 1)
00567         model = structure[0]
00568         self.assertEqual(model.id, 0)
00569         self.assertEqual(model.level, "M")
00570         self.assertEqual(len(model), 1)
00571         chain = model["A"]
00572         self.assertEqual(chain.id, "A")
00573         self.assertEqual(chain.level, "C")
00574         self.assertEqual(len(chain), 158)
00575         self.assertEqual(" ".join(residue.resname for residue in chain),
00576                          "MSE ASP ILE ARG GLN GLY PRO LYS GLU PRO PHE ARG "
00577                          "ASP TYR VAL ASP ARG PHE TYR LYS THR LEU ARG ALA "
00578                          "GLU GLN ALA SER GLN GLU VAL LYS ASN TRP MSE THR "
00579                          "GLU THR LEU LEU VAL GLN ASN ALA ASN PRO ASP CYS "
00580                          "LYS THR ILE LEU LYS ALA LEU GLY PRO GLY ALA THR "
00581                          "LEU GLU GLU MSE MSE THR ALA CYS GLN GLY HOH HOH "
00582                          "HOH HOH HOH HOH HOH HOH HOH HOH HOH HOH HOH HOH "
00583                          "HOH HOH HOH HOH HOH HOH HOH HOH HOH HOH HOH HOH "
00584                          "HOH HOH HOH HOH HOH HOH HOH HOH HOH HOH HOH HOH "
00585                          "HOH HOH HOH HOH HOH HOH HOH HOH HOH HOH HOH HOH "
00586                          "HOH HOH HOH HOH HOH HOH HOH HOH HOH HOH HOH HOH "
00587                          "HOH HOH HOH HOH HOH HOH HOH HOH HOH HOH HOH HOH "
00588                          "HOH HOH HOH HOH HOH HOH HOH HOH HOH HOH HOH HOH "
00589                          "HOH HOH")
00590         self.assertEqual(" ".join(atom.name for atom in chain.get_atoms()),
00591                          "N CA C O CB CG SE CE N CA C O CB CG OD1 OD2 N CA "
00592                          "C O CB CG1 CG2 CD1 N CA C O CB CG CD NE CZ NH1 "
00593                          "NH2 N CA C O CB CG CD OE1 NE2 N CA C O N CA C O "
00594                          "CB CG CD N CA C O CB CG CD CE NZ N CA C O CB CG "
00595                          "CD OE1 OE2 N CA C O CB CG CD N CA C O CB CG CD1 "
00596                          "CD2 CE1 CE2 CZ N CA C O CB CG CD NE CZ NH1 NH2 N "
00597                          "CA C O CB CG OD1 OD2 N CA C O CB CG CD1 CD2 CE1 "
00598                          "CE2 CZ OH N CA C O CB CG1 CG2 N CA C O CB CG OD1 "
00599                          "OD2 N CA C O CB CG CD NE CZ NH1 NH2 N CA C O CB "
00600                          "CG CD1 CD2 CE1 CE2 CZ N CA C O CB CG CD1 CD2 CE1 "
00601                          "CE2 CZ OH N CA C O CB CG CD CE NZ N CA C O CB "
00602                          "OG1 CG2 N CA C O CB CG CD1 CD2 N CA C O CB CG CD "
00603                          "NE CZ NH1 NH2 N CA C O CB N CA C O CB CG CD OE1 "
00604                          "OE2 N CA C O CB CG CD OE1 NE2 N CA C O CB N CA C "
00605                          "O CB OG N CA C O CB CG CD OE1 NE2 N CA C O CB CG "
00606                          "CD OE1 OE2 N CA C O CB CG1 CG2 N CA C O CB CG CD "
00607                          "CE NZ N CA C O CB CG OD1 ND2 N CA C O CB CG CD1 "
00608                          "CD2 NE1 CE2 CE3 CZ2 CZ3 CH2 N CA C O CB CG SE CE "
00609                          "N CA C O CB OG1 CG2 N CA C O CB CG CD OE1 OE2 N "
00610                          "CA C O CB OG1 CG2 N CA C O CB CG CD1 CD2 N CA C "
00611                          "O CB CG CD1 CD2 N CA C O CB CG1 CG2 N CA C O CB "
00612                          "CG CD OE1 NE2 N CA C O CB CG OD1 ND2 N CA C O CB "
00613                          "N CA C O CB CG OD1 ND2 N CA C O CB CG CD N CA C "
00614                          "O CB CG OD1 OD2 N CA C O CB SG N CA C O CB CG CD "
00615                          "CE NZ N CA C O CB OG1 CG2 N CA C O CB CG1 CG2 "
00616                          "CD1 N CA C O CB CG CD1 CD2 N CA C O CB CG CD CE "
00617                          "NZ N CA C O CB N CA C O CB CG CD1 CD2 N CA C O N "
00618                          "CA C O CB CG CD N CA C O N CA C O CB N CA C O CB "
00619                          "OG1 CG2 N CA C O CB CG CD1 CD2 N CA C O CB CG CD "
00620                          "OE1 OE2 N CA C O CB CG CD OE1 OE2 N CA C O CB CG "
00621                          "SE CE N CA C O CB CG SE CE N CA C O CB OG1 CG2 N "
00622                          "CA C O CB N CA C O CB SG N CA C O CB CG CD OE1 "
00623                          "NE2 N CA C O OXT O O O O O O O O O O O O O O O O "
00624                          "O O O O O O O O O O O O O O O O O O O O O O O O "
00625                          "O O O O O O O O O O O O O O O O O O O O O O O O "
00626                          "O O O O O O O O O O O O O O O O O O O O O O O O")
00627         self.assertEqual(" ".join(atom.element for atom in chain.get_atoms()),
00628                          "N C C O C C SE C N C C O C C O O N C C O C C C C "
00629                          "N C C O C C C N C N N N C C O C C C O N N C C O "
00630                          "N C C O C C C N C C O C C C C N N C C O C C C O "
00631                          "O N C C O C C C N C C O C C C C C C C N C C O C "
00632                          "C C N C N N N C C O C C O O N C C O C C C C C C "
00633                          "C O N C C O C C C N C C O C C O O N C C O C C C "
00634                          "N C N N N C C O C C C C C C C N C C O C C C C C "
00635                          "C C O N C C O C C C C N N C C O C O C N C C O C "
00636                          "C C C N C C O C C C N C N N N C C O C N C C O C "
00637                          "C C O O N C C O C C C O N N C C O C N C C O C O "
00638                          "N C C O C C C O N N C C O C C C O O N C C O C C "
00639                          "C N C C O C C C C N N C C O C C O N N C C O C C "
00640                          "C C N C C C C C N C C O C C SE C N C C O C O C N "
00641                          "C C O C C C O O N C C O C O C N C C O C C C C N "
00642                          "C C O C C C C N C C O C C C N C C O C C C O N N "
00643                          "C C O C C O N N C C O C N C C O C C O N N C C O "
00644                          "C C C N C C O C C O O N C C O C S N C C O C C C "
00645                          "C N N C C O C O C N C C O C C C C N C C O C C C "
00646                          "C N C C O C C C C N N C C O C N C C O C C C C N "
00647                          "C C O N C C O C C C N C C O N C C O C N C C O C "
00648                          "O C N C C O C C C C N C C O C C C O O N C C O C "
00649                          "C C O O N C C O C C SE C N C C O C C SE C N C C "
00650                          "O C O C N C C O C N C C O C S N C C O C C C O N "
00651                          "N C C O O O O O O O O O O O O O O O O O O O O O "
00652                          "O O O O O O O O O O O O O O O O O O O O O O O O "
00653                          "O O O O O O O O O O O O O O O O O O O O O O O O "
00654                          "O O O O O O O O O O O O O O O O O O O O O")


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