Package test_suite :: Package unit_tests :: Package _lib :: Package _structure :: Module test_pdb_write
[hide private]
[frames] | no frames]

Source Code for Module test_suite.unit_tests._lib._structure.test_pdb_write

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2008-2013 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  6  #                                                                             # 
  7  # This program is free software: you can redistribute it and/or modify        # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation, either version 3 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # This program is distributed in the hope that it will be useful,             # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 19  #                                                                             # 
 20  ############################################################################### 
 21   
 22  # relax module imports. 
 23  from lib.structure import pdb_write 
 24  from lib.io import DummyFileObject 
 25  from test_suite.unit_tests.base_classes import UnitTestCase 
 26   
 27   
28 -class Test_pdb_write(UnitTestCase):
29 """Unit tests for the functions of the 'lib.structure.pdb_write' module.""" 30
31 - def test_atom(self):
32 """Test the lib.structure.pdb_write.atom() function.""" 33 34 # A dummy file to write to. 35 file = DummyFileObject() 36 37 # Create the PDB record. 38 pdb_write.atom(file, serial=158, name='CG', res_name='GLU', res_seq='11', x=9.59, y=-1.041, z=-11.596, occupancy=1.0, temp_factor=0.0, element='C') 39 40 # Test the record. 41 records = file.readlines() 42 actual = 'ATOM 158 CG GLU 11 9.590 -1.041 -11.596 1.00 0.00 C \n' 43 print(repr(records[0])) 44 print(repr(actual)) 45 self.assertEqual(records[0], actual)
46 47
48 - def test_helix(self):
49 """Test the lib.structure.pdb_write.helix() function.""" 50 51 # A dummy file to write to. 52 file = DummyFileObject() 53 54 # Create the PDB record. 55 pdb_write.helix(file, ser_num=1, helix_id='H1', init_res_name='ILE', init_chain_id='A', init_seq_num=23, init_icode=None, end_res_name='GLU', end_chain_id='A', end_seq_num=34, end_icode=None, helix_class=1, comment=None, length=12) 56 57 # Test the record. 58 records = file.readlines() 59 actual = 'HELIX 1 H1 ILE A 23 GLU A 34 1 12 \n' 60 print(repr(records[0])) 61 print(repr(actual)) 62 self.assertEqual(records[0], actual)
63 64
65 - def test_het(self):
66 """Test the lib.structure.pdb_write.het() function.""" 67 68 # A dummy file to write to. 69 file = DummyFileObject() 70 71 # Create the PDB record. 72 pdb_write.het(file, het_id='CA', chain_id='A', seq_num=1000, icode=None, num_het_atoms=1, text=None) 73 74 # Test the record. 75 records = file.readlines() 76 actual = 'HET CA A1000 1 \n' 77 print(repr(records[0])) 78 print(repr(actual)) 79 self.assertEqual(records[0], actual)
80 81
82 - def test_model(self):
83 """Test the lib.structure.pdb_write.model() function.""" 84 85 # A dummy file to write to. 86 file = DummyFileObject() 87 88 # Create the PDB record. 89 pdb_write.model(file, serial=1) 90 91 # Test the record. 92 records = file.readlines() 93 actual = 'MODEL 1 \n' 94 print(repr(records[0])) 95 print(repr(actual)) 96 self.assertEqual(records[0], actual)
97 98
99 - def test_sheet(self):
100 """Test the lib.structure.pdb_write.sheet() function.""" 101 102 # A dummy file to write to. 103 file = DummyFileObject() 104 105 # Create the PDB record. 106 pdb_write.sheet(file, strand=1, sheet_id='BET', num_strands=5, init_res_name='GLY', init_chain_id='A', init_seq_num=10, init_icode=None, end_res_name='VAL', end_chain_id='A', end_seq_num=17, end_icode=None, sense=0, cur_atom=None, cur_res_name=None, cur_chain_id=None, cur_res_seq=None, cur_icode=None, prev_atom=None, prev_res_name=None, prev_chain_id=None, prev_res_seq=None, prev_icode=None) 107 108 # Test the record. 109 records = file.readlines() 110 actual = 'SHEET 1 BET 5 GLY A 10 VAL A 17 0 \n' 111 print(repr(records[0])) 112 print(repr(actual)) 113 self.assertEqual(records[0], actual)
114