Package test_suite :: Package system_tests :: Module structure
[hide private]
[frames] | no frames]

Source Code for Module test_suite.system_tests.structure

   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  # Python module imports. 
  23  from math import sqrt 
  24  from numpy import float64, zeros 
  25  from os import sep 
  26  from tempfile import mktemp 
  27   
  28  # relax module imports. 
  29  from data_store import Relax_data_store; ds = Relax_data_store() 
  30  from pipe_control.mol_res_spin import count_spins, return_spin 
  31  from lib.geometry.rotations import euler_to_R_zyz 
  32  from lib.errors import RelaxError 
  33  from lib.io import DummyFileObject 
  34  from status import Status; status = Status() 
  35  from test_suite.system_tests.base_classes import SystemTestCase 
  36   
  37   
38 -class Structure(SystemTestCase):
39 """Class for testing the structural objects.""" 40
41 - def setUp(self):
42 """Set up for all the functional tests.""" 43 44 # Create the data pipe. 45 self.interpreter.pipe.create('mf', 'mf')
46 47
48 - def test_alt_loc_missing(self):
49 """Test that a RelaxError occurs when the alternate location indicator is present but not specified.""" 50 51 # Path of the structure file. 52 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 53 54 # Load the file, load the spins, and attach the protons. 55 self.assertRaises(RelaxError, self.interpreter.structure.read_pdb, '1OGT_trunc.pdb', dir=path)
56 57
59 """Test the bug reported as the U{support request #2998<https://web.archive.org/web/https://gna.org/support/?2998>}, the broken CONECT records.""" 60 61 # Path of the structure file. 62 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 63 64 # Load the file. 65 self.interpreter.structure.read_pdb('1RTE_trunc.pdb', dir=path)
66 67
69 """Catch U{bug #20470<https://web.archive.org/web/https://gna.org/bugs/?20470>}, the alternate location indicator problem.""" 70 71 # Path of the structure file. 72 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 73 74 # Load the file, load the spins, and attach the protons. 75 self.interpreter.structure.read_pdb('1OGT_trunc.pdb', dir=path, alt_loc='A') 76 self.interpreter.structure.load_spins(spin_id='@N', ave_pos=True) 77 self.interpreter.sequence.attach_protons()
78 79
81 """Catch U{bug #21187<https://web.archive.org/web/https://gna.org/bugs/?21187>}, the corrupted PDB with all proton atoms numbers set to zero.""" 82 83 # Path of the structure file. 84 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 85 86 # Load the file. 87 self.interpreter.structure.read_pdb('bug_21187_molecule.pdb', dir=path) 88 89 # Load the @N, @H, and @NE1 spins (needed to create the :60@0 spin to trigger the bug later). 90 self.interpreter.structure.load_spins(spin_id='@N', ave_pos=True) 91 self.interpreter.structure.load_spins(spin_id='@NE1', ave_pos=True) 92 self.interpreter.structure.load_spins(spin_id='@H', ave_pos=True) 93 94 # Load the :60@HE1 spin - this clashes with the :60@H spin as both have the spin ID of ':60@0'. 95 self.interpreter.structure.load_spins(spin_id='@HE1', ave_pos=True)
96 97
98 - def test_delete_empty(self):
99 """Test the deletion of non-existent structural data.""" 100 101 # Delete all structural data. 102 self.interpreter.structure.delete()
103 104
105 - def test_delete_multi_pipe(self):
106 """Test the deletion of structural data in only one pipe.""" 107 108 # Create a structure with a single atom. 109 self.interpreter.structure.add_atom(atom_name='PIV', res_name='M1', res_num=1, pos=[0., 1., 2.], element='S') 110 111 # Create a new data pipe. 112 self.interpreter.pipe.create('new', 'N-state') 113 114 # Create a structure with a single atom. 115 self.interpreter.structure.add_atom(atom_name='PIV', res_name='M1', res_num=2, pos=[4., 5., 6.], element='S') 116 117 # Delete all structural data. 118 self.interpreter.structure.delete() 119 120 # Checks. 121 self.assert_(hasattr(cdp, 'structure')) 122 self.assertEqual(len(cdp.structure.structural_data), 0) 123 self.interpreter.pipe.switch('mf') 124 self.assert_(hasattr(cdp, 'structure')) 125 self.assertEqual(len(cdp.structure.structural_data), 1)
126 127
128 - def test_displacement(self):
129 """Test of the structure.displacement user function.""" 130 131 # Path of the structure file. 132 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 133 134 # Load the file as two models. 135 self.interpreter.structure.read_pdb('Ap4Aase_res1-12.pdb', dir=path, set_model_num=1) 136 self.interpreter.structure.read_pdb('Ap4Aase_res1-12.pdb', dir=path, set_model_num=2) 137 138 # A rotation. 139 R = zeros((3, 3), float64) 140 euler_to_R_zyz(1.3, 0.4, 4.5, R) 141 142 # Rotate the second model. 143 self.interpreter.structure.rotate(R, model=2) 144 145 # Calculate the displacement. 146 self.interpreter.structure.displacement() 147 148 # Shift a third structure back using the calculated displacement. 149 self.interpreter.structure.read_pdb('Ap4Aase_res1-12.pdb', dir=path, set_model_num=3) 150 self.interpreter.structure.rotate(R, model=3) 151 152 # The data to check. 153 models = [1, 2] 154 trans_vect = [ 155 [[0.0, 0.0, 0.0], 156 [ 2.270857972754659, -1.811667138656451, 1.878400649688508]], 157 [[ -2.270857972754659, 1.811667138656451, -1.878400649688508], 158 [0.0, 0.0, 0.0]] 159 ] 160 dist = [ 161 [0.0000000000000000, 3.4593818457148173], 162 [3.4593818457148173, 0.0000000000000000] 163 ] 164 rot_axis = [ 165 [None, 166 [ 0.646165066909452, 0.018875759848125, -0.762964227206007]], 167 [[ -0.646165066909452, -0.018875759848125, 0.762964227206007], 168 None] 169 ] 170 angle = [ 171 [0.0000000000000000, 0.6247677290742989], 172 [0.6247677290742989, 0.0000000000000000] 173 ] 174 175 # Test the results. 176 self.assert_(hasattr(cdp.structure, 'displacements')) 177 for i in range(len(models)): 178 for j in range(len(models)): 179 # Check the translation. 180 self.assertAlmostEqual(cdp.structure.displacements._translation_distance[models[i]][models[j]], dist[i][j]) 181 for k in range(3): 182 self.assertAlmostEqual(cdp.structure.displacements._translation_vector[models[i]][models[j]][k], trans_vect[i][j][k]) 183 184 # Check the rotation. 185 self.assertAlmostEqual(cdp.structure.displacements._rotation_angle[models[i]][models[j]], angle[i][j]) 186 if rot_axis[i][j] != None: 187 for k in range(3): 188 self.assertAlmostEqual(cdp.structure.displacements._rotation_axis[models[i]][models[j]][k], rot_axis[i][j][k]) 189 190 # Save the results. 191 self.tmpfile = mktemp() 192 self.interpreter.state.save(self.tmpfile, dir=None, force=True) 193 194 # Reset relax. 195 self.interpreter.reset() 196 197 # Load the results. 198 self.interpreter.state.load(self.tmpfile) 199 200 # Test the re-loaded data. 201 self.assert_(hasattr(cdp.structure, 'displacements')) 202 for i in range(len(models)): 203 for j in range(len(models)): 204 # Check the translation. 205 self.assertAlmostEqual(cdp.structure.displacements._translation_distance[models[i]][models[j]], dist[i][j]) 206 for k in range(3): 207 self.assertAlmostEqual(cdp.structure.displacements._translation_vector[models[i]][models[j]][k], trans_vect[i][j][k]) 208 209 # Check the rotation. 210 self.assertAlmostEqual(cdp.structure.displacements._rotation_angle[models[i]][models[j]], angle[i][j]) 211 if rot_axis[i][j] != None: 212 for k in range(3): 213 self.assertAlmostEqual(cdp.structure.displacements._rotation_axis[models[i]][models[j]][k], rot_axis[i][j][k])
214 215
216 - def test_load_spins_mol_cat(self):
217 """Test the loading of spins from different molecules into one molecule container.""" 218 219 # Path of the files. 220 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'lactose' 221 222 # Read the PDBs. 223 self.interpreter.structure.read_pdb(file='lactose_MCMM4_S1_1.pdb', dir=path, set_mol_name='L1') 224 self.interpreter.structure.read_pdb(file='lactose_MCMM4_S1_2.pdb', dir=path, set_mol_name='L2') 225 226 # Load a few protons. 227 self.interpreter.structure.load_spins('#L1:900@C1', mol_name_target='Lactose') 228 self.interpreter.structure.load_spins('#L2:900@C2', mol_name_target='Lactose') 229 230 # Check the spin data. 231 self.assertEqual(len(cdp.mol), 1) 232 self.assertEqual(cdp.mol[0].name, 'Lactose') 233 self.assertEqual(len(cdp.mol[0].res), 1) 234 self.assertEqual(cdp.mol[0].res[0].name, 'UNK') 235 self.assertEqual(cdp.mol[0].res[0].num, 900) 236 self.assertEqual(len(cdp.mol[0].res[0].spin), 2) 237 self.assertEqual(cdp.mol[0].res[0].spin[0].name, 'C1') 238 self.assertEqual(cdp.mol[0].res[0].spin[0].num, 1) 239 self.assertEqual(cdp.mol[0].res[0].spin[1].name, 'C2') 240 self.assertEqual(cdp.mol[0].res[0].spin[1].num, 2)
241 242
243 - def test_load_internal_results(self):
244 """Load the PDB file using the information in a results file (using the internal structural object).""" 245 246 # Path of the files. 247 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 248 249 # Read the results file. 250 self.interpreter.results.read(file='str_internal', dir=path) 251 252 # Test the structure metadata. 253 self.assert_(hasattr(cdp, 'structure')) 254 self.assert_(hasattr(cdp.structure, 'structural_data')) 255 self.assert_(len(cdp.structure.structural_data)) 256 self.assert_(len(cdp.structure.structural_data[0].mol)) 257 258 mol = cdp.structure.structural_data[0].mol[0] 259 self.assertEqual(mol.file_name, 'Ap4Aase_res1-12.pdb') 260 self.assertEqual(mol.file_path, '') 261 self.assertEqual(mol.file_model, 1) 262 self.assertEqual(mol.file_mol_num, 1) 263 264 # The real atomic data. 265 atom_name = ['N', 'CA', '1HA', '2HA', 'C', 'O', '1HT', '2HT', '3HT', 'N', 'CD', 'CA', 'HA', 'CB', '1HB', '2HB', 'CG', '1HG', '2HG', '1HD', '2HD', 'C', 'O', 'N', 'H', 'CA', 'HA', 'CB', '1HB', '2HB', 'CG', 'HG', 'CD1', '1HD1', '2HD1', '3HD1', 'CD2', '1HD2', '2HD2', '3HD2', 'C', 'O', 'N', 'H', 'CA', '1HA', '2HA', 'C', 'O', 'N', 'H', 'CA', 'HA', 'CB', '1HB', '2HB', 'OG', 'HG', 'C', 'O', 'N', 'H', 'CA', 'HA', 'CB', '1HB', '2HB', 'CG', '1HG', '2HG', 'SD', 'CE', '1HE', '2HE', '3HE', 'C', 'O', 'N', 'H', 'CA', 'HA', 'CB', '1HB', '2HB', 'CG', 'OD1', 'OD2', 'C', 'O', 'N', 'H', 'CA', 'HA', 'CB', '1HB', '2HB', 'OG', 'HG', 'C', 'O', 'N', 'CD', 'CA', 'HA', 'CB', '1HB', '2HB', 'CG', '1HG', '2HG', '1HD', '2HD', 'C', 'O', 'N', 'CD', 'CA', 'HA', 'CB', '1HB', '2HB', 'CG', '1HG', '2HG', '1HD', '2HD', 'C', 'O', 'N', 'H', 'CA', 'HA', 'CB', '1HB', '2HB', 'CG', '1HG', '2HG', 'CD', 'OE1', 'OE2', 'C', 'O', 'N', 'H', 'CA', '1HA', '2HA', 'C', 'O'] 266 bonded = [[]]*174 267 chain_id = [None]*174 268 element = ['N', 'C', 'H', 'H', 'C', 'O', 'H', 'H', 'H', 'N', 'C', 'C', 'H', 'C', 'H', 'H', 'C', 'H', 'H', 'H', 'H', 'C', 'O', 'N', 'H', 'C', 'H', 'C', 'H', 'H', 'C', 'H', 'C', 'H', 'H', 'H', 'C', 'H', 'H', 'H', 'C', 'O', 'N', 'H', 'C', 'H', 'H', 'C', 'O', 'N', 'H', 'C', 'H', 'C', 'H', 'H', 'O', 'H', 'C', 'O', 'N', 'H', 'C', 'H', 'C', 'H', 'H', 'C', 'H', 'H', 'S', 'C', 'H', 'H', 'H', 'C', 'O', 'N', 'H', 'C', 'H', 'C', 'H', 'H', 'C', 'O', 'O', 'C', 'O', 'N', 'H', 'C', 'H', 'C', 'H', 'H', 'O', 'H', 'C', 'O', 'N', 'C', 'C', 'H', 'C', 'H', 'H', 'C', 'H', 'H', 'H', 'H', 'C', 'O', 'N', 'C', 'C', 'H', 'C', 'H', 'H', 'C', 'H', 'H', 'H', 'H', 'C', 'O', 'N', 'H', 'C', 'H', 'C', 'H', 'H', 'C', 'H', 'H', 'C', 'O', 'O', 'C', 'O', 'N', 'H', 'C', 'H', 'H', 'C', 'O'] 269 pdb_record = ['ATOM']*174 270 res_name = ['GLY', 'GLY', 'GLY', 'GLY', 'GLY', 'GLY', 'GLY', 'GLY', 'GLY', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'LEU', 'LEU', 'LEU', 'LEU', 'LEU', 'LEU', 'LEU', 'LEU', 'LEU', 'LEU', 'LEU', 'LEU', 'LEU', 'LEU', 'LEU', 'LEU', 'LEU', 'LEU', 'LEU', 'GLY', 'GLY', 'GLY', 'GLY', 'GLY', 'GLY', 'GLY', 'SER', 'SER', 'SER', 'SER', 'SER', 'SER', 'SER', 'SER', 'SER', 'SER', 'SER', 'MET', 'MET', 'MET', 'MET', 'MET', 'MET', 'MET', 'MET', 'MET', 'MET', 'MET', 'MET', 'MET', 'MET', 'MET', 'MET', 'MET', 'ASP', 'ASP', 'ASP', 'ASP', 'ASP', 'ASP', 'ASP', 'ASP', 'ASP', 'ASP', 'ASP', 'ASP', 'SER', 'SER', 'SER', 'SER', 'SER', 'SER', 'SER', 'SER', 'SER', 'SER', 'SER', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'PRO', 'GLU', 'GLU', 'GLU', 'GLU', 'GLU', 'GLU', 'GLU', 'GLU', 'GLU', 'GLU', 'GLU', 'GLU', 'GLU', 'GLU', 'GLU', 'GLY', 'GLY', 'GLY', 'GLY', 'GLY', 'GLY', 'GLY'] 271 res_num = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12] 272 seg_id = [None]*174 273 x = [8.442, 7.469, 8.013, 6.825, 6.610, 6.827, 9.398, 8.180, 8.448, 5.613, 5.281, 4.714, 5.222, 3.646, 3.332, 2.800, 4.319, 4.853, 3.587, 6.162, 4.805, 4.075, 3.593, 4.074, 4.475, 3.498, 3.572, 2.025, 1.965, 1.609, 1.176, 1.823, 0.176, 0.096, 0.509, -0.789, 0.474, 0.809, -0.595, 0.707, 4.264, 4.364, 4.809, 4.697, 5.561, 6.220, 6.156, 4.659, 4.746, 3.786, 3.770, 2.851, 2.368, 1.785, 1.177, 1.165, 2.360, 1.690, 3.546, 3.804, 3.814, 3.563, 4.442, 4.984, 5.411, 6.192, 4.872, 6.068, 6.868, 5.332, 6.747, 6.155, 5.409, 6.977, 5.721, 3.369, 2.255, 3.703, 4.604, 2.753, 1.851, 3.329, 4.182, 3.644, 2.319, 1.992, 1.854, 2.419, 1.251, 3.451, 4.359, 3.267, 2.246, 4.223, 4.054, 4.040, 5.573, 6.142, 3.488, 4.276, 2.795, 1.828, 2.929, 2.810, 1.772, 0.912, 2.067, 1.505, 0.464, 2.138, 0.938, 2.273, 4.268, 4.585, 5.076, 4.776, 6.392, 6.925, 7.120, 7.968, 7.464, 6.130, 6.384, 6.135, 4.210, 4.246, 6.325, 5.263, 7.477, 8.281, 7.587, 7.039, 9.047, 9.133, 9.654, 9.590, 10.670, 9.215, 9.190, 10.055, 8.012, 7.007, 7.361, 6.144, 5.925, 5.555, 6.329, 4.814, 4.894, 4.761] 274 y = [10.188, 9.889, 9.712, 10.745, 8.674, 7.991, 10.291, 11.073, 9.416, 8.385, 9.152, 7.243, 6.302, 7.443, 6.483, 7.963, 8.253, 7.605, 8.842, 9.327, 10.088, 7.251, 8.285, 6.099, 5.309, 5.986, 4.953, 6.396, 7.471, 6.106, 5.775, 5.225, 4.796, 4.954, 3.787, 4.949, 6.853, 7.828, 6.775, 6.720, 6.853, 8.068, 6.222, 5.251, 6.956, 6.273, 7.706, 7.634, 8.841, 6.847, 5.889, 7.360, 6.511, 8.230, 7.620, 8.669, 9.269, 9.652, 8.174, 9.362, 7.546, 6.604, 8.253, 9.095, 7.354, 7.976, 6.886, 6.258, 5.824, 5.499, 6.846, 5.570, 5.985, 5.190, 4.766, 8.771, 8.245, 9.789, 10.161, 10.351, 10.605, 11.610, 11.341, 12.287, 12.322, 11.787, 13.410, 9.322, 9.015, 8.776, 9.052, 7.758, 7.826, 7.990, 8.977, 7.248, 7.894, 8.285, 6.370, 6.214, 5.342, 5.431, 3.973, 3.943, 3.230, 3.234, 2.212, 3.991, 3.892, 3.624, 5.960, 5.908, 3.339, 3.179, 2.980, 3.150, 2.375, 2.876, 2.616, 3.262, 1.675, 3.264, 4.305, 2.758, 4.055, 2.299, 0.876, 0.258, 0.312, 0.871, -1.106, -1.253, -1.489, -2.564, -1.049, -1.041, -1.011, -0.052, -1.970, -2.740, -1.931, -2.037, -1.962, -2.949, -2.983, -3.917, -4.588, -4.488, -3.289, -3.932] 275 z = [6.302, 7.391, 8.306, 7.526, 7.089, 6.087, 6.697, 5.822, 5.604, 7.943, 9.155, 7.752, 7.908, 8.829, 9.212, 8.407, 9.880, 10.560, 10.415, 9.754, 8.900, 6.374, 5.909, 5.719, 6.139, 4.391, 4.081, 4.415, 4.326, 5.367, 3.307, 2.640, 3.889, 4.956, 3.700, 3.430, 2.493, 2.814, 2.633, 1.449, 3.403, 3.572, 2.369, 2.281, 1.371, 0.855, 1.868, 0.359, 0.149, -0.269, -0.055, -1.268, -1.726, -0.608, 0.037, -1.377, 0.162, 0.731, -2.354, -2.175, -3.496, -3.603, -4.606, -4.199, -5.387, -5.803, -6.196, -4.563, -5.146, -4.350, -3.001, -1.895, -1.241, -1.307, -2.472, -5.551, -5.582, -6.328, -6.269, -7.274, -6.735, -7.913, -8.518, -7.133, -8.791, -9.871, -8.395, -8.346, -8.584, -8.977, -8.732, -10.002, -10.355, -11.174, -11.584, -11.936, -10.759, -11.425, -9.403, -8.469, -9.921, -11.030, -9.410, -8.336, -10.080, -9.428, -10.291, -11.333, -11.606, -12.128, -10.723, -11.893, -9.781, -10.959, -8.768, -7.344, -8.971, -9.765, -7.642, -7.816, -7.251, -6.715, -6.584, -5.765, -7.175, -6.955, -9.288, -9.222, -9.654, -9.696, -10.009, -10.928, -10.249, -10.194, -9.475, -11.596, -11.540, -11.813, -12.724, -13.193, -13.137, -8.947, -7.774, -9.383, -10.338, -8.477, -8.138, -9.017, -7.265, -6.226] 276 277 # Test the atomic data. 278 mol = cdp.structure.structural_data[0].mol[0] 279 for i in range(len(mol.atom_name)): 280 self.assertEqual(mol.atom_name[i], atom_name[i]) 281 self.assertEqual(mol.bonded[i], bonded[i]) 282 self.assertEqual(mol.chain_id[i], chain_id[i]) 283 self.assertEqual(mol.element[i], element[i]) 284 self.assertEqual(mol.pdb_record[i], pdb_record[i]) 285 self.assertEqual(mol.res_name[i], res_name[i]) 286 self.assertEqual(mol.res_num[i], res_num[i]) 287 self.assertEqual(mol.seg_id[i], seg_id[i]) 288 self.assertEqual(mol.x[i], x[i]) 289 self.assertEqual(mol.y[i], y[i]) 290 self.assertEqual(mol.z[i], z[i])
291 292
294 """Load the PDB file using the information in a results file (using the internal structural object).""" 295 296 # Path of the files. 297 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 298 299 # Read the results file. 300 self.interpreter.results.read(file=path+sep+'str_internal')
301 302
303 - def test_metadata_xml(self):
304 """Test the storage and loading of metadata into an XML state file.""" 305 306 # Load the file. 307 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 308 self.interpreter.structure.read_pdb('1UBQ.pdb', dir=path) 309 310 # Delete a big chunk of the molecule. 311 self.interpreter.structure.delete(":35-76") 312 313 # Delete all waters. 314 self.interpreter.structure.delete(":HOH") 315 316 # Write out the results file. 317 self.tmpfile = mktemp() + '.bz2' 318 self.interpreter.results.write(self.tmpfile, dir=None) 319 320 # Create a new data pipe and load the results. 321 self.interpreter.pipe.create('xml text', 'mf') 322 self.interpreter.results.read(self.tmpfile) 323 324 # What the data should look like. 325 helices = [ 326 ['H1', 'A', 'ILE', 23, 'A', 'GLU', 34, 1, 12] 327 ] 328 sheets = [ 329 [1, 'BET', 5, 'GLY', 'A', 10, None, 'VAL', 'A', 17, None, 0, None, None, None, None, None, None, None, None, None, None], 330 [2, 'BET', 5, 'MET', 'A', 1, None, 'THR', 'A', 7, None, -1, None, None, None, None, None, None, None, None, None, None] 331 ] 332 333 # Check the helix data. 334 self.assert_(hasattr(cdp.structure, 'helices')) 335 self.assertEqual(len(cdp.structure.helices), 1) 336 self.assertEqual(cdp.structure.helices[0], helices[0]) 337 338 # Check the sheet data. 339 self.assert_(hasattr(cdp.structure, 'sheets')) 340 self.assertEqual(len(cdp.structure.sheets), 2) 341 self.assertEqual(cdp.structure.sheets[0], sheets[0]) 342 self.assertEqual(cdp.structure.sheets[1], sheets[1])
343 344
345 - def test_read_merge(self):
346 """Test the merging of two molecules into one.""" 347 348 # Path of the files. 349 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 350 351 # Read the PDB files. 352 self.interpreter.structure.read_pdb(file='Ap4Aase_res1-6.pdb', dir=path, set_mol_name='Ap4Aase', set_model_num=1) 353 self.interpreter.structure.read_pdb(file='Ap4Aase_res7-12.pdb', dir=path, set_mol_name='Ap4Aase', set_model_num=1, merge=True) 354 self.interpreter.structure.read_pdb(file='Ap4Aase_res1-12.pdb', dir=path, set_mol_name='Ap4Aase', set_model_num=2) 355 356 # Check that everything is ok. 357 cdp.structure.validate_models()
358 359
360 - def test_read_not_pdb(self):
361 """Test the reading of a file by structure.read_pdb that is not a PDB.""" 362 363 # Path of the files. 364 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'saved_states' 365 366 # Read the non-PDB file. 367 self.interpreter.structure.read_pdb(file='basic_single_pipe.bz2', dir=path)
368 369
370 - def test_read_pdb_internal1(self):
371 """Load the '1F35_N_H_molmol.pdb' PDB file (using the internal structural object PDB reader).""" 372 373 # Path of the files. 374 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 375 376 # Read the PDB. 377 self.interpreter.structure.read_pdb(file='1F35_N_H_molmol.pdb', dir=path) 378 379 # Test the molecule name. 380 self.assertEqual(cdp.structure.structural_data[0].mol[0].mol_name, '1F35_N_H_molmol_mol1') 381 382 # Load a single atom and test it. 383 self.interpreter.structure.load_spins('#1F35_N_H_molmol_mol1:3@N') 384 self.assertEqual(count_spins(), 1) 385 386 # Try loading a few protons. 387 self.interpreter.structure.load_spins('@*H*') 388 389 # And now all the rest of the atoms. 390 self.interpreter.structure.load_spins() 391 392 # Extract a N-Ca vector. 393 self.interpreter.interatom.define(spin_id1='@CA', spin_id2='#1F35_N_H_molmol_mol1:3@N') 394 self.interpreter.interatom.unit_vectors() 395 print(cdp.interatomic[0]) 396 self.assert_(hasattr(cdp.interatomic[0], 'vector'))
397 398
399 - def test_read_pdb_internal2(self):
400 """Load the 'Ap4Aase_res1-12.pdb' PDB file (using the internal structural object PDB reader).""" 401 402 # Path of the files. 403 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 404 405 # Read the PDB. 406 self.interpreter.structure.read_pdb(file='Ap4Aase_res1-12.pdb', dir=path) 407 408 # Try loading a few protons. 409 self.interpreter.structure.load_spins('@*H*') 410 411 # And now all the rest of the atoms. 412 self.interpreter.structure.load_spins()
413 414
415 - def test_read_pdb_internal3(self):
416 """Load the 'gromacs.pdb' PDB file (using the internal structural object PDB reader).""" 417 418 # Path of the files. 419 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'phthalic_acid' 420 421 # Read the PDB. 422 self.interpreter.structure.read_pdb(file='gromacs.pdb', dir=path) 423 424 # Try loading a few protons, without positions averaging across models. 425 self.interpreter.structure.load_spins('@*H*', ave_pos=False) 426 427 # A test. 428 self.assertEqual(len(cdp.mol[0].res[0].spin[0].pos), 2) 429 430 # And now all the rest of the atoms. 431 self.interpreter.structure.load_spins()
432 433
434 - def test_read_pdb_internal4(self):
435 """Load the 'tylers_peptide_trunc.pdb' PDB file (using the internal structural object PDB reader).""" 436 437 # Path of the files. 438 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 439 440 # Read the PDB. 441 self.interpreter.structure.read_pdb(file='tylers_peptide_trunc.pdb', dir=path) 442 443 # Try loading a few protons. 444 self.interpreter.structure.load_spins('@*H*') 445 446 # And now all the rest of the atoms. 447 self.interpreter.structure.load_spins()
448 449
450 - def test_read_pdb_internal5(self):
451 """Load the 'lactose_MCMM4_S1_1.pdb' PDB file (using the internal structural object PDB reader).""" 452 453 # Path of the files. 454 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'lactose' 455 456 # Read the PDB. 457 self.interpreter.structure.read_pdb(file='lactose_MCMM4_S1_1.pdb', dir=path) 458 459 # Try loading a few protons. 460 self.interpreter.structure.load_spins('@*H*') 461 462 # And now all the rest of the atoms. 463 self.interpreter.structure.load_spins()
464 465
466 - def test_read_pdb_internal6(self):
467 """Load the 'lactose_MCMM4_S1_1.pdb' and 'lactose_MCMM4_S1_2.pdb' PDB files as 2 separate structures (using the internal structural object PDB reader).""" 468 469 # Path of the files. 470 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'lactose' 471 472 # Read the PDB twice. 473 self.interpreter.structure.read_pdb(file='lactose_MCMM4_S1_1.pdb', dir=path) 474 self.interpreter.structure.read_pdb(file='lactose_MCMM4_S1_2.pdb', dir=path) 475 476 # Try loading a few protons. 477 self.interpreter.structure.load_spins('@*H*') 478 479 # And now all the rest of the atoms. 480 self.interpreter.structure.load_spins()
481 482
483 - def test_read_pdb_internal7(self):
484 """Load the 'lactose_MCMM4_S1_1.pdb' PDB file twice as 2 separate structures (using the internal structural object PDB reader).""" 485 486 # Path of the files. 487 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'lactose' 488 489 # Read the PDB twice. 490 self.interpreter.structure.read_pdb(file='lactose_MCMM4_S1_1.pdb', dir=path) 491 self.interpreter.structure.read_pdb(file='lactose_MCMM4_S1_1.pdb', dir=path) 492 493 # Try loading a few protons. 494 self.interpreter.structure.load_spins('@*H*') 495 496 # And now all the rest of the atoms. 497 self.interpreter.structure.load_spins()
498 499
501 """Load a few 'lactose_MCMM4_S1_*.pdb' PDB files as models (using the internal structural object PDB reader).""" 502 503 # Path of the files. 504 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'lactose' 505 506 # Files. 507 files = ['lactose_MCMM4_S1_1.pdb', 508 'lactose_MCMM4_S1_2.pdb', 509 'lactose_MCMM4_S1_3.pdb'] 510 511 # Read the PDBs. 512 self.interpreter.structure.read_pdb(file=files[0], dir=path, set_model_num=1) 513 self.interpreter.structure.read_pdb(file=files[1], dir=path, set_model_num=1) 514 self.interpreter.structure.read_pdb(file=files[2], dir=path, set_model_num=1) 515 516 # Try loading a few protons. 517 self.interpreter.structure.load_spins('@*H*') 518 519 # And now all the rest of the atoms. 520 self.interpreter.structure.load_spins() 521 522 # Test the structural data. 523 self.assert_(hasattr(cdp, 'structure')) 524 self.assert_(hasattr(cdp.structure, 'structural_data')) 525 self.assertEqual(len(cdp.structure.structural_data), 1) 526 self.assertEqual(len(cdp.structure.structural_data[0].mol), 3) 527 528 i = 0 529 for mol in cdp.structure.structural_data[0].mol: 530 self.assertEqual(mol.file_name, files[i]) 531 self.assertEqual(mol.file_path, path) 532 self.assertEqual(mol.file_model, 1) 533 self.assertEqual(mol.file_mol_num, 1) 534 i = i + 1
535 536
538 """Load the 2 models of the 'gromacs.pdb' PDB file as separate molecules of the same model (using the internal structural object PDB reader).""" 539 540 # Path of the files. 541 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'phthalic_acid' 542 543 # Read the PDB models. 544 self.interpreter.structure.read_pdb(file='gromacs.pdb', dir=path, read_model=1, set_model_num=1) 545 self.interpreter.structure.read_pdb(file='gromacs.pdb', dir=path, read_model=2, set_model_num=1) 546 547 # Try loading a few protons. 548 self.interpreter.structure.load_spins('@*H*') 549 550 # And now all the rest of the atoms. 551 self.interpreter.structure.load_spins() 552 553 # Test the structural data. 554 self.assert_(hasattr(cdp, 'structure')) 555 self.assert_(hasattr(cdp.structure, 'structural_data')) 556 self.assertEqual(len(cdp.structure.structural_data), 1) 557 self.assertEqual(len(cdp.structure.structural_data[0].mol), 2) 558 559 i = 0 560 for mol in cdp.structure.structural_data[0].mol: 561 self.assertEqual(mol.file_name, 'gromacs.pdb') 562 self.assertEqual(mol.file_path, path) 563 self.assertEqual(mol.file_model, i+1) 564 self.assertEqual(mol.file_mol_num, 1) 565 i = i + 1
566 567
569 """Test the packing of models and molecules using 'gromacs.pdb' and 'lactose_MCMM4_S1_*.pdb' (using the internal structural object PDB reader).""" 570 571 # Path of the files. 572 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 573 574 # Read the PDB models. 575 self.interpreter.structure.read_pdb(file='gromacs.pdb', dir=path+sep+'phthalic_acid') 576 self.interpreter.structure.read_pdb(file='lactose'+sep+'lactose_MCMM4_S1_1.pdb', dir=path, set_model_num=1, set_mol_name='lactose_MCMM4_S1') 577 self.interpreter.structure.read_pdb(file='lactose'+sep+'lactose_MCMM4_S1_2.pdb', dir=path, set_model_num=2, set_mol_name='lactose_MCMM4_S1') 578 self.interpreter.structure.read_pdb(file='lactose'+sep+'lactose_MCMM4_S1_3.pdb', dir=path, set_model_num=1, set_mol_name='lactose_MCMM4_S1b') 579 self.interpreter.structure.read_pdb(file='lactose'+sep+'lactose_MCMM4_S1_4.pdb', dir=path, set_model_num=2, set_mol_name='lactose_MCMM4_S1b') 580 581 # Try loading a few protons. 582 self.interpreter.structure.load_spins('@*H*') 583 584 # And now all the rest of the atoms. 585 self.interpreter.structure.load_spins() 586 587 # Test the structural data. 588 self.assert_(hasattr(cdp, 'structure')) 589 self.assert_(hasattr(cdp.structure, 'structural_data')) 590 self.assertEqual(len(cdp.structure.structural_data), 2) 591 self.assertEqual(len(cdp.structure.structural_data[0].mol), 3) 592 self.assertEqual(len(cdp.structure.structural_data[1].mol), 3) 593 594 files = [['gromacs.pdb', 'lactose_MCMM4_S1_1.pdb', 'lactose_MCMM4_S1_3.pdb'], 595 ['gromacs.pdb', 'lactose_MCMM4_S1_2.pdb', 'lactose_MCMM4_S1_4.pdb']] 596 paths = [[path+sep+'phthalic_acid', path+sep+'lactose', path+sep+'lactose'], 597 [path+sep+'phthalic_acid', path+sep+'lactose', path+sep+'lactose']] 598 models = [[1, 1, 1], [2, 1, 1]] 599 600 for i in range(len(cdp.structure.structural_data)): 601 for j in range(len(cdp.structure.structural_data[i].mol)): 602 mol = cdp.structure.structural_data[i].mol[j] 603 self.assertEqual(mol.file_name, files[i][j]) 604 self.assertEqual(mol.file_path, paths[i][j]) 605 self.assertEqual(mol.file_model, models[i][j]) 606 self.assertEqual(mol.file_mol_num, 1)
607 608
609 - def test_read_pdb_1UBQ(self):
610 """Test the reading of the complete 1UBQ PDB file.""" 611 612 # Load the file. 613 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 614 self.interpreter.structure.read_pdb('1UBQ.pdb', dir=path) 615 616 # Check the data. 617 self.assert_(hasattr(cdp, 'structure')) 618 self.assert_(hasattr(cdp.structure, 'structural_data')) 619 self.assertEqual(len(cdp.structure.structural_data), 1) 620 self.assertEqual(len(cdp.structure.structural_data[0].mol), 1) 621 622 # Check the first atom. 623 self.assertEqual(cdp.structure.structural_data[0].mol[0].atom_num[0], 1) 624 self.assertEqual(cdp.structure.structural_data[0].mol[0].atom_name[0], 'N') 625 self.assertEqual(cdp.structure.structural_data[0].mol[0].chain_id[0], 'A') 626 self.assertEqual(cdp.structure.structural_data[0].mol[0].res_name[0], 'MET') 627 self.assertEqual(cdp.structure.structural_data[0].mol[0].res_num[0], 1) 628 self.assertEqual(cdp.structure.structural_data[0].mol[0].x[0], 27.340) 629 self.assertEqual(cdp.structure.structural_data[0].mol[0].y[0], 24.430) 630 self.assertEqual(cdp.structure.structural_data[0].mol[0].z[0], 2.614) 631 self.assertEqual(cdp.structure.structural_data[0].mol[0].element[0], 'N') 632 633 # Check the last atom (from the last water HETATM record). 634 self.assertEqual(cdp.structure.structural_data[0].mol[0].atom_num[-1], 661) 635 self.assertEqual(cdp.structure.structural_data[0].mol[0].atom_name[-1], 'O') 636 self.assertEqual(cdp.structure.structural_data[0].mol[0].chain_id[-1], None) 637 self.assertEqual(cdp.structure.structural_data[0].mol[0].res_name[-1], 'HOH') 638 self.assertEqual(cdp.structure.structural_data[0].mol[0].res_num[-1], 58) 639 self.assertEqual(cdp.structure.structural_data[0].mol[0].x[-1], 37.667) 640 self.assertEqual(cdp.structure.structural_data[0].mol[0].y[-1], 43.421) 641 self.assertEqual(cdp.structure.structural_data[0].mol[0].z[-1], 17.000) 642 self.assertEqual(cdp.structure.structural_data[0].mol[0].element[-1], 'O')
643 644
645 - def test_read_write_pdb_1UBQ(self):
646 """Test the reading and writing of the 1UBQ PDB file.""" 647 648 # Load the file. 649 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 650 self.interpreter.structure.read_pdb('1UBQ.pdb', dir=path) 651 652 # Delete a big chunk of the molecule. 653 self.interpreter.structure.delete(":35-76") 654 655 # Delete all waters. 656 self.interpreter.structure.delete(":HOH") 657 658 # Write out the file. 659 self.tmpfile = mktemp() + '.pdb' 660 self.interpreter.structure.write_pdb(self.tmpfile) 661 662 # Read the contents of the file. 663 file = open(self.tmpfile) 664 lines = file.readlines() 665 file.close() 666 667 # What the contents should be. 668 real_data = [ 669 "REMARK 4 THIS FILE COMPLIES WITH FORMAT V. 3.30, JUL-2011. \n", 670 "REMARK 40 CREATED BY RELAX (HTTP://WWW.NMR-RELAX.COM). \n", 671 "HELIX 1 H1 ILE A 23 GLU A 34 1 12 \n", 672 "SHEET 1 BET 5 GLY A 10 VAL A 17 0 \n", 673 "SHEET 2 BET 5 MET A 1 THR A 7 -1 \n", 674 "ATOM 1 N MET A 1 27.340 24.430 2.614 1.00 0.00 N \n", 675 "ATOM 2 CA MET A 1 26.266 25.413 2.842 1.00 0.00 C \n", 676 "ATOM 3 C MET A 1 26.913 26.639 3.531 1.00 0.00 C \n", 677 "ATOM 4 O MET A 1 27.886 26.463 4.263 1.00 0.00 O \n", 678 "ATOM 5 CB MET A 1 25.112 24.880 3.649 1.00 0.00 C \n", 679 "ATOM 6 CG MET A 1 25.353 24.860 5.134 1.00 0.00 C \n", 680 "ATOM 7 SD MET A 1 23.930 23.959 5.904 1.00 0.00 S \n", 681 "ATOM 8 CE MET A 1 24.447 23.984 7.620 1.00 0.00 C \n", 682 "ATOM 9 N GLN A 2 26.335 27.770 3.258 1.00 0.00 N \n", 683 "ATOM 10 CA GLN A 2 26.850 29.021 3.898 1.00 0.00 C \n", 684 "ATOM 11 C GLN A 2 26.100 29.253 5.202 1.00 0.00 C \n", 685 "ATOM 12 O GLN A 2 24.865 29.024 5.330 1.00 0.00 O \n", 686 "ATOM 13 CB GLN A 2 26.733 30.148 2.905 1.00 0.00 C \n", 687 "ATOM 14 CG GLN A 2 26.882 31.546 3.409 1.00 0.00 C \n", 688 "ATOM 15 CD GLN A 2 26.786 32.562 2.270 1.00 0.00 C \n", 689 "ATOM 16 OE1 GLN A 2 27.783 33.160 1.870 1.00 0.00 O \n", 690 "ATOM 17 NE2 GLN A 2 25.562 32.733 1.806 1.00 0.00 N \n", 691 "ATOM 18 N ILE A 3 26.849 29.656 6.217 1.00 0.00 N \n", 692 "ATOM 19 CA ILE A 3 26.235 30.058 7.497 1.00 0.00 C \n", 693 "ATOM 20 C ILE A 3 26.882 31.428 7.862 1.00 0.00 C \n", 694 "ATOM 21 O ILE A 3 27.906 31.711 7.264 1.00 0.00 O \n", 695 "ATOM 22 CB ILE A 3 26.344 29.050 8.645 1.00 0.00 C \n", 696 "ATOM 23 CG1 ILE A 3 27.810 28.748 8.999 1.00 0.00 C \n", 697 "ATOM 24 CG2 ILE A 3 25.491 27.771 8.287 1.00 0.00 C \n", 698 "ATOM 25 CD1 ILE A 3 27.967 28.087 10.417 1.00 0.00 C \n", 699 "ATOM 26 N PHE A 4 26.214 32.097 8.771 1.00 0.00 N \n", 700 "ATOM 27 CA PHE A 4 26.772 33.436 9.197 1.00 0.00 C \n", 701 "ATOM 28 C PHE A 4 27.151 33.362 10.650 1.00 0.00 C \n", 702 "ATOM 29 O PHE A 4 26.350 32.778 11.395 1.00 0.00 O \n", 703 "ATOM 30 CB PHE A 4 25.695 34.498 8.946 1.00 0.00 C \n", 704 "ATOM 31 CG PHE A 4 25.288 34.609 7.499 1.00 0.00 C \n", 705 "ATOM 32 CD1 PHE A 4 24.147 33.966 7.038 1.00 0.00 C \n", 706 "ATOM 33 CD2 PHE A 4 26.136 35.346 6.640 1.00 0.00 C \n", 707 "ATOM 34 CE1 PHE A 4 23.812 34.031 5.677 1.00 0.00 C \n", 708 "ATOM 35 CE2 PHE A 4 25.810 35.392 5.267 1.00 0.00 C \n", 709 "ATOM 36 CZ PHE A 4 24.620 34.778 4.853 1.00 0.00 C \n", 710 "ATOM 37 N VAL A 5 28.260 33.943 11.096 1.00 0.00 N \n", 711 "ATOM 38 CA VAL A 5 28.605 33.965 12.503 1.00 0.00 C \n", 712 "ATOM 39 C VAL A 5 28.638 35.461 12.900 1.00 0.00 C \n", 713 "ATOM 40 O VAL A 5 29.522 36.103 12.320 1.00 0.00 O \n", 714 "ATOM 41 CB VAL A 5 29.963 33.317 12.814 1.00 0.00 C \n", 715 "ATOM 42 CG1 VAL A 5 30.211 33.394 14.304 1.00 0.00 C \n", 716 "ATOM 43 CG2 VAL A 5 29.957 31.838 12.352 1.00 0.00 C \n", 717 "ATOM 44 N LYS A 6 27.751 35.867 13.740 1.00 0.00 N \n", 718 "ATOM 45 CA LYS A 6 27.691 37.315 14.143 1.00 0.00 C \n", 719 "ATOM 46 C LYS A 6 28.469 37.475 15.420 1.00 0.00 C \n", 720 "ATOM 47 O LYS A 6 28.213 36.753 16.411 1.00 0.00 O \n", 721 "ATOM 48 CB LYS A 6 26.219 37.684 14.307 1.00 0.00 C \n", 722 "ATOM 49 CG LYS A 6 25.884 39.139 14.615 1.00 0.00 C \n", 723 "ATOM 50 CD LYS A 6 24.348 39.296 14.642 1.00 0.00 C \n", 724 "ATOM 51 CE LYS A 6 23.865 40.723 14.749 1.00 0.00 C \n", 725 "ATOM 52 NZ LYS A 6 22.375 40.720 14.907 1.00 0.00 N \n", 726 "ATOM 53 N THR A 7 29.426 38.430 15.446 1.00 0.00 N \n", 727 "ATOM 54 CA THR A 7 30.225 38.643 16.662 1.00 0.00 C \n", 728 "ATOM 55 C THR A 7 29.664 39.839 17.434 1.00 0.00 C \n", 729 "ATOM 56 O THR A 7 28.850 40.565 16.859 1.00 0.00 O \n", 730 "ATOM 57 CB THR A 7 31.744 38.879 16.299 1.00 0.00 C \n", 731 "ATOM 58 OG1 THR A 7 31.737 40.257 15.824 1.00 0.00 O \n", 732 "ATOM 59 CG2 THR A 7 32.260 37.969 15.171 1.00 0.00 C \n", 733 "ATOM 60 N LEU A 8 30.132 40.069 18.642 1.00 0.00 N \n", 734 "ATOM 61 CA LEU A 8 29.607 41.180 19.467 1.00 0.00 C \n", 735 "ATOM 62 C LEU A 8 30.075 42.538 18.984 1.00 0.00 C \n", 736 "ATOM 63 O LEU A 8 29.586 43.570 19.483 1.00 0.00 O \n", 737 "ATOM 64 CB LEU A 8 29.919 40.890 20.938 1.00 0.00 C \n", 738 "ATOM 65 CG LEU A 8 29.183 39.722 21.581 1.00 0.00 C \n", 739 "ATOM 66 CD1 LEU A 8 29.308 39.750 23.095 1.00 0.00 C \n", 740 "ATOM 67 CD2 LEU A 8 27.700 39.721 21.228 1.00 0.00 C \n", 741 "ATOM 68 N THR A 9 30.991 42.571 17.998 1.00 0.00 N \n", 742 "ATOM 69 CA THR A 9 31.422 43.940 17.553 1.00 0.00 C \n", 743 "ATOM 70 C THR A 9 30.755 44.351 16.277 1.00 0.00 C \n", 744 "ATOM 71 O THR A 9 31.207 45.268 15.566 1.00 0.00 O \n", 745 "ATOM 72 CB THR A 9 32.979 43.918 17.445 1.00 0.00 C \n", 746 "ATOM 73 OG1 THR A 9 33.174 43.067 16.265 1.00 0.00 O \n", 747 "ATOM 74 CG2 THR A 9 33.657 43.319 18.672 1.00 0.00 C \n", 748 "ATOM 75 N GLY A 10 29.721 43.673 15.885 1.00 0.00 N \n", 749 "ATOM 76 CA GLY A 10 28.978 43.960 14.678 1.00 0.00 C \n", 750 "ATOM 77 C GLY A 10 29.604 43.507 13.393 1.00 0.00 C \n", 751 "ATOM 78 O GLY A 10 29.219 43.981 12.301 1.00 0.00 O \n", 752 "ATOM 79 N LYS A 11 30.563 42.623 13.495 1.00 0.00 N \n", 753 "ATOM 80 CA LYS A 11 31.191 42.012 12.331 1.00 0.00 C \n", 754 "ATOM 81 C LYS A 11 30.459 40.666 12.130 1.00 0.00 C \n", 755 "ATOM 82 O LYS A 11 30.253 39.991 13.133 1.00 0.00 O \n", 756 "ATOM 83 CB LYS A 11 32.672 41.717 12.505 1.00 0.00 C \n", 757 "ATOM 84 CG LYS A 11 33.280 41.086 11.227 1.00 0.00 C \n", 758 "ATOM 85 CD LYS A 11 34.762 40.799 11.470 1.00 0.00 C \n", 759 "ATOM 86 CE LYS A 11 35.614 40.847 10.240 1.00 0.00 C \n", 760 "ATOM 87 NZ LYS A 11 35.100 40.073 9.101 1.00 0.00 N \n", 761 "ATOM 88 N THR A 12 30.163 40.338 10.886 1.00 0.00 N \n", 762 "ATOM 89 CA THR A 12 29.542 39.020 10.653 1.00 0.00 C \n", 763 "ATOM 90 C THR A 12 30.494 38.261 9.729 1.00 0.00 C \n", 764 "ATOM 91 O THR A 12 30.849 38.850 8.706 1.00 0.00 O \n", 765 "ATOM 92 CB THR A 12 28.113 39.049 10.015 1.00 0.00 C \n", 766 "ATOM 93 OG1 THR A 12 27.280 39.722 10.996 1.00 0.00 O \n", 767 "ATOM 94 CG2 THR A 12 27.588 37.635 9.715 1.00 0.00 C \n", 768 "ATOM 95 N ILE A 13 30.795 37.015 10.095 1.00 0.00 N \n", 769 "ATOM 96 CA ILE A 13 31.720 36.289 9.176 1.00 0.00 C \n", 770 "ATOM 97 C ILE A 13 30.955 35.211 8.459 1.00 0.00 C \n", 771 "ATOM 98 O ILE A 13 30.025 34.618 9.040 1.00 0.00 O \n", 772 "ATOM 99 CB ILE A 13 32.995 35.883 9.934 1.00 0.00 C \n", 773 "ATOM 100 CG1 ILE A 13 33.306 34.381 9.840 1.00 0.00 C \n", 774 "ATOM 101 CG2 ILE A 13 33.109 36.381 11.435 1.00 0.00 C \n", 775 "ATOM 102 CD1 ILE A 13 34.535 34.028 10.720 1.00 0.00 C \n", 776 "ATOM 103 N THR A 14 31.244 34.986 7.197 1.00 0.00 N \n", 777 "ATOM 104 CA THR A 14 30.505 33.884 6.512 1.00 0.00 C \n", 778 "ATOM 105 C THR A 14 31.409 32.680 6.446 1.00 0.00 C \n", 779 "ATOM 106 O THR A 14 32.619 32.812 6.125 1.00 0.00 O \n", 780 "ATOM 107 CB THR A 14 30.091 34.393 5.078 1.00 0.00 C \n", 781 "ATOM 108 OG1 THR A 14 31.440 34.513 4.487 1.00 0.00 O \n", 782 "ATOM 109 CG2 THR A 14 29.420 35.756 5.119 1.00 0.00 C \n", 783 "ATOM 110 N LEU A 15 30.884 31.485 6.666 1.00 0.00 N \n", 784 "ATOM 111 CA LEU A 15 31.677 30.275 6.639 1.00 0.00 C \n", 785 "ATOM 112 C LEU A 15 31.022 29.288 5.665 1.00 0.00 C \n", 786 "ATOM 113 O LEU A 15 29.809 29.395 5.545 1.00 0.00 O \n", 787 "ATOM 114 CB LEU A 15 31.562 29.686 8.045 1.00 0.00 C \n", 788 "ATOM 115 CG LEU A 15 32.631 29.444 9.060 1.00 0.00 C \n", 789 "ATOM 116 CD1 LEU A 15 33.814 30.390 9.030 1.00 0.00 C \n", 790 "ATOM 117 CD2 LEU A 15 31.945 29.449 10.436 1.00 0.00 C \n", 791 "ATOM 118 N GLU A 16 31.834 28.412 5.125 1.00 0.00 N \n", 792 "ATOM 119 CA GLU A 16 31.220 27.341 4.275 1.00 0.00 C \n", 793 "ATOM 120 C GLU A 16 31.440 26.079 5.080 1.00 0.00 C \n", 794 "ATOM 121 O GLU A 16 32.576 25.802 5.461 1.00 0.00 O \n", 795 "ATOM 122 CB GLU A 16 31.827 27.262 2.894 1.00 0.00 C \n", 796 "ATOM 123 CG GLU A 16 31.363 28.410 1.962 1.00 0.00 C \n", 797 "ATOM 124 CD GLU A 16 31.671 28.291 0.498 1.00 0.00 C \n", 798 "ATOM 125 OE1 GLU A 16 30.869 28.621 -0.366 1.00 0.00 O \n", 799 "ATOM 126 OE2 GLU A 16 32.835 27.861 0.278 1.00 0.00 O \n", 800 "ATOM 127 N VAL A 17 30.310 25.458 5.384 1.00 0.00 N \n", 801 "ATOM 128 CA VAL A 17 30.288 24.245 6.193 1.00 0.00 C \n", 802 "ATOM 129 C VAL A 17 29.279 23.227 5.641 1.00 0.00 C \n", 803 "ATOM 130 O VAL A 17 28.478 23.522 4.725 1.00 0.00 O \n", 804 "ATOM 131 CB VAL A 17 29.903 24.590 7.665 1.00 0.00 C \n", 805 "ATOM 132 CG1 VAL A 17 30.862 25.496 8.389 1.00 0.00 C \n", 806 "ATOM 133 CG2 VAL A 17 28.476 25.135 7.705 1.00 0.00 C \n", 807 "ATOM 134 N GLU A 18 29.380 22.057 6.232 1.00 0.00 N \n", 808 "ATOM 135 CA GLU A 18 28.468 20.940 5.980 1.00 0.00 C \n", 809 "ATOM 136 C GLU A 18 27.819 20.609 7.316 1.00 0.00 C \n", 810 "ATOM 137 O GLU A 18 28.449 20.674 8.360 1.00 0.00 O \n", 811 "ATOM 138 CB GLU A 18 29.213 19.697 5.506 1.00 0.00 C \n", 812 "ATOM 139 CG GLU A 18 29.728 19.755 4.060 1.00 0.00 C \n", 813 "ATOM 140 CD GLU A 18 28.754 20.061 2.978 1.00 0.00 C \n", 814 "ATOM 141 OE1 GLU A 18 27.546 19.992 2.985 1.00 0.00 O \n", 815 "ATOM 142 OE2 GLU A 18 29.336 20.423 1.904 1.00 0.00 O \n", 816 "ATOM 143 N PRO A 19 26.559 20.220 7.288 1.00 0.00 N \n", 817 "ATOM 144 CA PRO A 19 25.829 19.825 8.494 1.00 0.00 C \n", 818 "ATOM 145 C PRO A 19 26.541 18.732 9.251 1.00 0.00 C \n", 819 "ATOM 146 O PRO A 19 26.333 18.536 10.457 1.00 0.00 O \n", 820 "ATOM 147 CB PRO A 19 24.469 19.332 7.952 1.00 0.00 C \n", 821 "ATOM 148 CG PRO A 19 24.299 20.134 6.704 1.00 0.00 C \n", 822 "ATOM 149 CD PRO A 19 25.714 20.108 6.073 1.00 0.00 C \n", 823 "ATOM 150 N SER A 20 27.361 17.959 8.559 1.00 0.00 N \n", 824 "ATOM 151 CA SER A 20 28.054 16.835 9.210 1.00 0.00 C \n", 825 "ATOM 152 C SER A 20 29.258 17.318 9.984 1.00 0.00 C \n", 826 "ATOM 153 O SER A 20 29.930 16.477 10.606 1.00 0.00 O \n", 827 "ATOM 154 CB SER A 20 28.523 15.820 8.182 1.00 0.00 C \n", 828 "ATOM 155 OG SER A 20 28.946 16.445 6.967 1.00 0.00 O \n", 829 "ATOM 156 N ASP A 21 29.599 18.599 9.828 1.00 0.00 N \n", 830 "ATOM 157 CA ASP A 21 30.796 19.083 10.566 1.00 0.00 C \n", 831 "ATOM 158 C ASP A 21 30.491 19.162 12.040 1.00 0.00 C \n", 832 "ATOM 159 O ASP A 21 29.367 19.523 12.441 1.00 0.00 O \n", 833 "ATOM 160 CB ASP A 21 31.155 20.515 10.048 1.00 0.00 C \n", 834 "ATOM 161 CG ASP A 21 31.923 20.436 8.755 1.00 0.00 C \n", 835 "ATOM 162 OD1 ASP A 21 32.493 19.374 8.456 1.00 0.00 O \n", 836 "ATOM 163 OD2 ASP A 21 31.838 21.402 7.968 1.00 0.00 O \n", 837 "ATOM 164 N THR A 22 31.510 18.936 12.852 1.00 0.00 N \n", 838 "ATOM 165 CA THR A 22 31.398 19.064 14.286 1.00 0.00 C \n", 839 "ATOM 166 C THR A 22 31.593 20.553 14.655 1.00 0.00 C \n", 840 "ATOM 167 O THR A 22 32.159 21.311 13.861 1.00 0.00 O \n", 841 "ATOM 168 CB THR A 22 32.492 18.193 14.995 1.00 0.00 C \n", 842 "ATOM 169 OG1 THR A 22 33.778 18.739 14.516 1.00 0.00 O \n", 843 "ATOM 170 CG2 THR A 22 32.352 16.700 14.630 1.00 0.00 C \n", 844 "ATOM 171 N ILE A 23 31.113 20.863 15.860 1.00 0.00 N \n", 845 "ATOM 172 CA ILE A 23 31.288 22.201 16.417 1.00 0.00 C \n", 846 "ATOM 173 C ILE A 23 32.776 22.519 16.577 1.00 0.00 C \n", 847 "ATOM 174 O ILE A 23 33.233 23.659 16.384 1.00 0.00 O \n", 848 "ATOM 175 CB ILE A 23 30.520 22.300 17.764 1.00 0.00 C \n", 849 "ATOM 176 CG1 ILE A 23 29.006 22.043 17.442 1.00 0.00 C \n", 850 "ATOM 177 CG2 ILE A 23 30.832 23.699 18.358 1.00 0.00 C \n", 851 "ATOM 178 CD1 ILE A 23 28.407 22.948 16.366 1.00 0.00 C \n", 852 "ATOM 179 N GLU A 24 33.548 21.526 16.950 1.00 0.00 N \n", 853 "ATOM 180 CA GLU A 24 35.031 21.722 17.069 1.00 0.00 C \n", 854 "ATOM 181 C GLU A 24 35.615 22.190 15.759 1.00 0.00 C \n", 855 "ATOM 182 O GLU A 24 36.532 23.046 15.724 1.00 0.00 O \n", 856 "ATOM 183 CB GLU A 24 35.667 20.383 17.447 1.00 0.00 C \n", 857 "ATOM 184 CG GLU A 24 37.128 20.293 17.872 1.00 0.00 C \n", 858 "ATOM 185 CD GLU A 24 37.561 18.851 18.082 1.00 0.00 C \n", 859 "ATOM 186 OE1 GLU A 24 37.758 18.024 17.195 1.00 0.00 O \n", 860 "ATOM 187 OE2 GLU A 24 37.628 18.599 19.313 1.00 0.00 O \n", 861 "ATOM 188 N ASN A 25 35.139 21.624 14.662 1.00 0.00 N \n", 862 "ATOM 189 CA ASN A 25 35.590 21.945 13.302 1.00 0.00 C \n", 863 "ATOM 190 C ASN A 25 35.238 23.382 12.920 1.00 0.00 C \n", 864 "ATOM 191 O ASN A 25 36.066 24.109 12.333 1.00 0.00 O \n", 865 "ATOM 192 CB ASN A 25 35.064 20.957 12.255 1.00 0.00 C \n", 866 "ATOM 193 CG ASN A 25 35.541 21.418 10.871 1.00 0.00 C \n", 867 "ATOM 194 OD1 ASN A 25 36.772 21.623 10.676 1.00 0.00 O \n", 868 "ATOM 195 ND2 ASN A 25 34.628 21.595 9.920 1.00 0.00 N \n", 869 "ATOM 196 N VAL A 26 34.007 23.745 13.250 1.00 0.00 N \n", 870 "ATOM 197 CA VAL A 26 33.533 25.097 12.978 1.00 0.00 C \n", 871 "ATOM 198 C VAL A 26 34.441 26.099 13.684 1.00 0.00 C \n", 872 "ATOM 199 O VAL A 26 34.883 27.090 13.093 1.00 0.00 O \n", 873 "ATOM 200 CB VAL A 26 32.060 25.257 13.364 1.00 0.00 C \n", 874 "ATOM 201 CG1 VAL A 26 31.684 26.749 13.342 1.00 0.00 C \n", 875 "ATOM 202 CG2 VAL A 26 31.152 24.421 12.477 1.00 0.00 C \n", 876 "ATOM 203 N LYS A 27 34.734 25.822 14.949 1.00 0.00 N \n", 877 "ATOM 204 CA LYS A 27 35.596 26.715 15.736 1.00 0.00 C \n", 878 "ATOM 205 C LYS A 27 36.975 26.826 15.107 1.00 0.00 C \n", 879 "ATOM 206 O LYS A 27 37.579 27.926 15.159 1.00 0.00 O \n", 880 "ATOM 207 CB LYS A 27 35.715 26.203 17.172 1.00 0.00 C \n", 881 "ATOM 208 CG LYS A 27 34.343 26.445 17.898 1.00 0.00 C \n", 882 "ATOM 209 CD LYS A 27 34.509 26.077 19.360 1.00 0.00 C \n", 883 "ATOM 210 CE LYS A 27 33.206 26.311 20.122 1.00 0.00 C \n", 884 "ATOM 211 NZ LYS A 27 33.455 25.910 21.546 1.00 0.00 N \n", 885 "ATOM 212 N ALA A 28 37.499 25.743 14.571 1.00 0.00 N \n", 886 "ATOM 213 CA ALA A 28 38.794 25.761 13.880 1.00 0.00 C \n", 887 "ATOM 214 C ALA A 28 38.728 26.591 12.611 1.00 0.00 C \n", 888 "ATOM 215 O ALA A 28 39.704 27.346 12.277 1.00 0.00 O \n", 889 "ATOM 216 CB ALA A 28 39.285 24.336 13.566 1.00 0.00 C \n", 890 "ATOM 217 N LYS A 29 37.633 26.543 11.867 1.00 0.00 N \n", 891 "ATOM 218 CA LYS A 29 37.471 27.391 10.668 1.00 0.00 C \n", 892 "ATOM 219 C LYS A 29 37.441 28.882 11.052 1.00 0.00 C \n", 893 "ATOM 220 O LYS A 29 38.020 29.772 10.382 1.00 0.00 O \n", 894 "ATOM 221 CB LYS A 29 36.193 27.058 9.911 1.00 0.00 C \n", 895 "ATOM 222 CG LYS A 29 36.153 25.620 9.409 1.00 0.00 C \n", 896 "ATOM 223 CD LYS A 29 34.758 25.280 8.900 1.00 0.00 C \n", 897 "ATOM 224 CE LYS A 29 34.793 24.264 7.767 1.00 0.00 C \n", 898 "ATOM 225 NZ LYS A 29 34.914 24.944 6.441 1.00 0.00 N \n", 899 "ATOM 226 N ILE A 30 36.811 29.170 12.192 1.00 0.00 N \n", 900 "ATOM 227 CA ILE A 30 36.731 30.570 12.645 1.00 0.00 C \n", 901 "ATOM 228 C ILE A 30 38.148 30.981 13.069 1.00 0.00 C \n", 902 "ATOM 229 O ILE A 30 38.544 32.150 12.856 1.00 0.00 O \n", 903 "ATOM 230 CB ILE A 30 35.708 30.776 13.806 1.00 0.00 C \n", 904 "ATOM 231 CG1 ILE A 30 34.228 30.630 13.319 1.00 0.00 C \n", 905 "ATOM 232 CG2 ILE A 30 35.874 32.138 14.512 1.00 0.00 C \n", 906 "ATOM 233 CD1 ILE A 30 33.284 30.504 14.552 1.00 0.00 C \n", 907 "ATOM 234 N GLN A 31 38.883 30.110 13.713 1.00 0.00 N \n", 908 "ATOM 235 CA GLN A 31 40.269 30.508 14.115 1.00 0.00 C \n", 909 "ATOM 236 C GLN A 31 41.092 30.808 12.851 1.00 0.00 C \n", 910 "ATOM 237 O GLN A 31 41.828 31.808 12.681 1.00 0.00 O \n", 911 "ATOM 238 CB GLN A 31 40.996 29.399 14.865 1.00 0.00 C \n", 912 "ATOM 239 CG GLN A 31 42.445 29.848 15.182 1.00 0.00 C \n", 913 "ATOM 240 CD GLN A 31 43.090 28.828 16.095 1.00 0.00 C \n", 914 "ATOM 241 OE1 GLN A 31 42.770 27.655 15.906 1.00 0.00 O \n", 915 "ATOM 242 NE2 GLN A 31 43.898 29.252 17.050 1.00 0.00 N \n", 916 "ATOM 243 N ASP A 32 41.001 29.878 11.931 1.00 0.00 N \n", 917 "ATOM 244 CA ASP A 32 41.718 30.022 10.643 1.00 0.00 C \n", 918 "ATOM 245 C ASP A 32 41.399 31.338 9.967 1.00 0.00 C \n", 919 "ATOM 246 O ASP A 32 42.260 32.036 9.381 1.00 0.00 O \n", 920 "ATOM 247 CB ASP A 32 41.398 28.780 9.810 1.00 0.00 C \n", 921 "ATOM 248 CG ASP A 32 42.626 28.557 8.928 1.00 0.00 C \n", 922 "ATOM 249 OD1 ASP A 32 43.666 28.262 9.539 1.00 0.00 O \n", 923 "ATOM 250 OD2 ASP A 32 42.430 28.812 7.728 1.00 0.00 O \n", 924 "ATOM 251 N LYS A 33 40.117 31.750 9.988 1.00 0.00 N \n", 925 "ATOM 252 CA LYS A 33 39.808 32.994 9.233 1.00 0.00 C \n", 926 "ATOM 253 C LYS A 33 39.837 34.271 9.995 1.00 0.00 C \n", 927 "ATOM 254 O LYS A 33 40.164 35.323 9.345 1.00 0.00 O \n", 928 "ATOM 255 CB LYS A 33 38.615 32.801 8.320 1.00 0.00 C \n", 929 "ATOM 256 CG LYS A 33 37.220 32.822 8.827 1.00 0.00 C \n", 930 "ATOM 257 CD LYS A 33 36.351 33.613 7.838 1.00 0.00 C \n", 931 "ATOM 258 CE LYS A 33 36.322 32.944 6.477 1.00 0.00 C \n", 932 "ATOM 259 NZ LYS A 33 35.768 33.945 5.489 1.00 0.00 N \n", 933 "ATOM 260 N GLU A 34 39.655 34.335 11.285 1.00 0.00 N \n", 934 "ATOM 261 CA GLU A 34 39.676 35.547 12.072 1.00 0.00 C \n", 935 "ATOM 262 C GLU A 34 40.675 35.527 13.200 1.00 0.00 C \n", 936 "ATOM 263 O GLU A 34 40.814 36.528 13.911 1.00 0.00 O \n", 937 "ATOM 264 CB GLU A 34 38.290 35.814 12.698 1.00 0.00 C \n", 938 "ATOM 265 CG GLU A 34 37.156 35.985 11.688 1.00 0.00 C \n", 939 "ATOM 266 CD GLU A 34 37.192 37.361 11.033 1.00 0.00 C \n", 940 "ATOM 267 OE1 GLU A 34 37.519 38.360 11.645 1.00 0.00 O \n", 941 "ATOM 268 OE2 GLU A 34 36.861 37.320 9.822 1.00 0.00 O \n", 942 "TER 269 GLU A 34 \n", 943 "MASTER 0 0 0 0 0 0 0 0 268 1 0 0 \n", 944 "END \n" 945 ] 946 947 # Check the data. 948 for i in range(len(real_data)): 949 self.assertEqual(real_data[i], lines[i])
950 951
952 - def test_read_xyz_internal1(self):
953 """Load the 'Indol_test.xyz' XYZ file (using the internal structural object XYZ reader).""" 954 955 # Path of the files. 956 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 957 958 # Read the XYZ file. 959 self.interpreter.structure.read_xyz(file='Indol_test.xyz', dir=path) 960 961 # Test the molecule name. 962 self.assertEqual(cdp.structure.structural_data[0].mol[0].mol_name, 'Indol_test_mol1') 963 964 # Load a single atom and test it. 965 self.interpreter.structure.load_spins('#Indol_test_mol1@3') 966 self.assertEqual(count_spins(), 1) 967 968 # Try loading a few protons. 969 self.interpreter.structure.load_spins('@*H*') 970 971 # And now all the rest of the atoms. 972 self.interpreter.structure.load_spins()
973 974
975 - def test_read_xyz_internal2(self):
976 """Load the 'SSS-cluster4-new-test.xyz' XYZ file (using the internal structural object XYZ reader).""" 977 978 # Path of the files. 979 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 980 981 # Read the XYZ file. 982 self.interpreter.structure.read_xyz(file='SSS-cluster4-new-test.xyz', dir=path, read_model=[1]) 983 984 # Test the molecule name. 985 self.assertEqual(cdp.structure.structural_data[0].mol[0].mol_name, 'SSS-cluster4-new-test_mol1') 986 987 # Load a single atom and test it. 988 self.interpreter.structure.load_spins('#SSS-cluster4-new-test_mol1@2') 989 self.assertEqual(count_spins(), 1) 990 991 # Test the spin coordinates. 992 a=return_spin('#SSS-cluster4-new-test_mol1@2') 993 self.assertAlmostEqual(a.pos[0], -12.398) 994 self.assertAlmostEqual(a.pos[1], -15.992) 995 self.assertAlmostEqual(a.pos[2], 11.448) 996 997 # Try loading a few protons. 998 #self.interpreter.structure.load_spins('@H') 999 1000 # And now all the rest of the atoms. 1001 self.interpreter.structure.load_spins() 1002 1003 # Extract a vector between first two spins. 1004 self.interpreter.interatom.define(spin_id1='@2', spin_id2='@10') 1005 self.interpreter.interatom.unit_vectors() 1006 self.assertAlmostEqual(cdp.interatomic[0].vector[0], -0.4102707) 1007 self.assertAlmostEqual(cdp.interatomic[0].vector[1], 0.62128879) 1008 self.assertAlmostEqual(cdp.interatomic[0].vector[2], -0.6675913)
1009 1010
1011 - def test_read_xyz_strychnine(self):
1012 """Load the 'strychnine.xyz' XYZ file (using the internal structural object XYZ reader).""" 1013 1014 # Path of the files. 1015 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 1016 1017 # Read the XYZ file. 1018 self.interpreter.structure.read_xyz(file='strychnine.xyz', dir=path, set_mol_name='strychnine') 1019 1020 # Test the molecule data. 1021 self.assertEqual(len(cdp.structure.structural_data), 1) 1022 self.assertEqual(len(cdp.structure.structural_data[0].mol), 1) 1023 1024 # Load the carbon atoms and test it. 1025 self.interpreter.structure.load_spins('@C') 1026 self.assertEqual(count_spins(), 21) 1027 1028 # Load the protons. 1029 self.interpreter.structure.load_spins('@H') 1030 self.assertEqual(count_spins(), 43) 1031 1032 # And now all the rest of the atoms. 1033 self.interpreter.structure.load_spins()
1034 1035
1036 - def test_rmsd(self):
1037 """Test the structure.rmsd user function.""" 1038 1039 # Set up 3 models. 1040 self.interpreter.structure.add_model(model_num=1) 1041 self.interpreter.structure.add_model(model_num=2) 1042 self.interpreter.structure.add_model(model_num=4) 1043 1044 # Check that the models were correctly created. 1045 self.assert_(hasattr(cdp, 'structure')) 1046 self.assert_(hasattr(cdp.structure, 'structural_data')) 1047 self.assertEqual(len(cdp.structure.structural_data), 3) 1048 1049 # Create a structure with some atoms. 1050 self.interpreter.structure.add_atom(atom_name='A', res_name='UNK', res_num=1, pos=[[1., 0., -1.], [0., 0., 0.], [-1., 0., 1.]], element='S') 1051 self.interpreter.structure.add_atom(atom_name='A', res_name='UNK', res_num=2, pos=[[1., 2., -1.], [0., 2., 0.], [-1., 2., 1.]], element='S') 1052 self.interpreter.structure.add_atom(atom_name='A', res_name='UNK', res_num=3, pos=[[1., 20., -1.], [0., 20., 0.], [-1., 20., 1.]], element='S') 1053 1054 # Check the internal atomic info. 1055 self.assertEqual(cdp.structure.structural_data[0].mol[0].x, [1., 1., 1.]) 1056 self.assertEqual(cdp.structure.structural_data[0].mol[0].y, [0., 2., 20.]) 1057 self.assertEqual(cdp.structure.structural_data[0].mol[0].z, [-1., -1., -1.]) 1058 self.assertEqual(cdp.structure.structural_data[1].mol[0].x, [0., 0., 0.]) 1059 self.assertEqual(cdp.structure.structural_data[1].mol[0].y, [0., 2., 20.]) 1060 self.assertEqual(cdp.structure.structural_data[1].mol[0].z, [0., 0., 0.]) 1061 self.assertEqual(cdp.structure.structural_data[2].mol[0].x, [-1., -1., -1.]) 1062 self.assertEqual(cdp.structure.structural_data[2].mol[0].y, [0., 2., 20.]) 1063 self.assertEqual(cdp.structure.structural_data[2].mol[0].z, [1., 1., 1.]) 1064 1065 # Calculate the RMSD. 1066 self.interpreter.structure.rmsd() 1067 1068 # Checks. 1069 self.assert_(hasattr(cdp.structure, 'rmsd')) 1070 self.assertAlmostEqual(cdp.structure.rmsd, 2./3*sqrt(2))
1071 1072
1073 - def test_rmsd_ubi(self):
1074 """Test the structure.rmsd user function on the truncated ubiquitin ensemble.""" 1075 1076 # Load the structure. 1077 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 1078 self.interpreter.structure.read_pdb('trunc_ubi_pcs.pdb', dir=path) 1079 1080 # Calculate the RMSD. 1081 self.interpreter.structure.rmsd() 1082 1083 # Checks (the values match the VMD 1.9.1 RMSD numbers). 1084 self.assert_(hasattr(cdp.structure, 'rmsd')) 1085 self.assertAlmostEqual(cdp.structure.rmsd, 0.77282758781333061)
1086 1087
1089 """Test of the structure.superimpose user function, fitting to the first structure.""" 1090 1091 # Path of the structure file. 1092 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'frame_order'+sep+'cam' 1093 1094 # Load the two rotated structures. 1095 self.interpreter.structure.read_pdb('1J7P_1st_NH.pdb', dir=path, set_model_num=1, set_mol_name='CaM') 1096 self.interpreter.structure.read_pdb('1J7P_1st_NH_rot.pdb', dir=path, set_model_num=2, set_mol_name='CaM') 1097 self.interpreter.structure.read_pdb('1J7P_1st_NH.pdb', dir=path, set_model_num=3, set_mol_name='CaM') 1098 1099 # Superimpose the backbone heavy atoms. 1100 self.interpreter.structure.superimpose(method='fit to first', atom_id='@N,C,CA,O') 1101 1102 # Check that the two structures now have the same atomic coordinates. 1103 model1 = cdp.structure.structural_data[0].mol[0] 1104 model2 = cdp.structure.structural_data[1].mol[0] 1105 model3 = cdp.structure.structural_data[2].mol[0] 1106 for i in range(len(model1.atom_name)): 1107 # Check model 2. 1108 self.assertAlmostEqual(model1.x[i], model2.x[i], 2) 1109 self.assertAlmostEqual(model1.y[i], model2.y[i], 2) 1110 self.assertAlmostEqual(model1.z[i], model2.z[i], 2) 1111 1112 # Check model 3. 1113 self.assertAlmostEqual(model1.x[i], model3.x[i], 2) 1114 self.assertAlmostEqual(model1.y[i], model3.y[i], 2) 1115 self.assertAlmostEqual(model1.z[i], model3.z[i], 2)
1116 1117
1119 """Test of the structure.superimpose user function, fitting to the mean structure.""" 1120 1121 # Path of the structure file. 1122 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'frame_order'+sep+'cam' 1123 1124 # Load the two rotated structures. 1125 self.interpreter.structure.read_pdb('1J7P_1st_NH.pdb', dir=path, set_model_num=1, set_mol_name='CaM') 1126 self.interpreter.structure.read_pdb('1J7P_1st_NH_rot.pdb', dir=path, set_model_num=2, set_mol_name='CaM') 1127 1128 # Superimpose the backbone heavy atoms. 1129 self.interpreter.structure.superimpose(method='fit to mean', atom_id='@N,C,CA,O') 1130 1131 # Check that the two structures now have the same atomic coordinates. 1132 model1 = cdp.structure.structural_data[0].mol[0] 1133 model2 = cdp.structure.structural_data[1].mol[0] 1134 for i in range(len(model1.atom_name)): 1135 self.assertAlmostEqual(model1.x[i], model2.x[i], 2) 1136 self.assertAlmostEqual(model1.y[i], model2.y[i], 2) 1137 self.assertAlmostEqual(model1.z[i], model2.z[i], 2)
1138 1139
1141 """Second test of the structure.superimpose user function, fitting to the mean structure.""" 1142 1143 # Path of the structure file. 1144 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'frame_order'+sep+'cam' 1145 1146 # Load the two rotated structures. 1147 self.interpreter.structure.read_pdb('1J7P_1st_NH.pdb', dir=path, set_model_num=1, set_mol_name='CaM') 1148 self.interpreter.structure.read_pdb('1J7P_1st_NH.pdb', dir=path, set_model_num=2, set_mol_name='CaM') 1149 self.interpreter.structure.read_pdb('1J7P_1st_NH.pdb', dir=path, set_model_num=3, set_mol_name='CaM') 1150 1151 # Transpose model 3. 1152 self.interpreter.structure.translate([20.0, 0.0, 0.0], model=3) 1153 1154 # Superimpose the backbone heavy atoms. 1155 self.interpreter.structure.superimpose(models=[2, 3], method='fit to mean', atom_id='@N,C,CA,O') 1156 1157 # Check that the two structures now have the same atomic coordinates as the original, but shifted 10 Angstrom in x. 1158 model1 = cdp.structure.structural_data[0].mol[0] 1159 model2 = cdp.structure.structural_data[1].mol[0] 1160 model3 = cdp.structure.structural_data[2].mol[0] 1161 for i in range(len(model1.atom_name)): 1162 # Check model 2. 1163 self.assertAlmostEqual(model1.x[i] + 10, model2.x[i], 2) 1164 self.assertAlmostEqual(model1.y[i], model2.y[i], 2) 1165 self.assertAlmostEqual(model1.z[i], model2.z[i], 2) 1166 1167 # Check model 3. 1168 self.assertAlmostEqual(model2.x[i], model3.x[i], 2) 1169 self.assertAlmostEqual(model2.y[i], model3.y[i], 2) 1170 self.assertAlmostEqual(model2.z[i], model3.z[i], 2)
1171 1172
1173 - def test_web_of_motion_12(self):
1174 """Check the operation of the structure.web_of_motion user function using structural models 1 and 2 (of 3).""" 1175 1176 # Load the file. 1177 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 1178 self.interpreter.structure.read_pdb('web_of_motion.pdb', dir=path) 1179 1180 # Run the structure.web_of_motion user function and collect the results in a dummy file object. 1181 file = DummyFileObject() 1182 self.interpreter.structure.web_of_motion(file=file, models=[1, 2]) 1183 1184 # The result. 1185 result = [ 1186 "REMARK 4 THIS FILE COMPLIES WITH FORMAT V. 3.30, JUL-2011. ", 1187 "REMARK 40 CREATED BY RELAX (HTTP://WWW.NMR-RELAX.COM). ", 1188 "ATOM 1 N LEU 4 9.464 -9.232 27.573 1.00 0.00 N ", 1189 "ATOM 2 N LEU 4 9.211 -9.425 26.970 1.00 0.00 N ", 1190 "ATOM 3 H LEU 4 8.575 -8.953 27.963 1.00 0.00 H ", 1191 "ATOM 4 H LEU 4 9.085 -9.743 27.919 1.00 0.00 H ", 1192 "ATOM 5 CA LEU 4 10.302 -8.195 26.930 1.00 0.00 C ", 1193 "ATOM 6 CA LEU 4 10.077 -8.221 26.720 1.00 0.00 C ", 1194 "ATOM 7 CB LEU 4 9.494 -7.221 26.051 1.00 0.00 C ", 1195 "ATOM 8 CB LEU 4 9.297 -7.096 26.024 1.00 0.00 C ", 1196 "ATOM 9 CG LEU 4 10.107 -5.862 25.665 1.00 0.00 C ", 1197 "ATOM 10 CG LEU 4 10.061 -5.803 25.679 1.00 0.00 C ", 1198 "ATOM 11 CD1 LEU 4 11.182 -6.007 24.608 1.00 0.00 C ", 1199 "ATOM 12 CD1 LEU 4 11.029 -6.002 24.507 1.00 0.00 C ", 1200 "ATOM 13 CD2 LEU 4 9.036 -4.875 25.171 1.00 0.00 C ", 1201 "ATOM 14 CD2 LEU 4 9.120 -4.618 25.384 1.00 0.00 C ", 1202 "ATOM 15 C LEU 4 10.999 -7.436 28.046 1.00 0.00 C ", 1203 "ATOM 16 C LEU 4 10.625 -7.721 28.047 1.00 0.00 C ", 1204 "TER 17 LEU 4 ", 1205 "CONECT 1 2 ", 1206 "CONECT 2 1 ", 1207 "CONECT 3 4 ", 1208 "CONECT 4 3 ", 1209 "CONECT 5 6 ", 1210 "CONECT 6 5 ", 1211 "CONECT 7 8 ", 1212 "CONECT 8 7 ", 1213 "CONECT 9 10 ", 1214 "CONECT 10 9 ", 1215 "CONECT 11 12 ", 1216 "CONECT 12 11 ", 1217 "CONECT 13 14 ", 1218 "CONECT 14 13 ", 1219 "CONECT 15 16 ", 1220 "CONECT 16 15 ", 1221 "MASTER 0 0 0 0 0 0 0 0 16 1 16 0 ", 1222 "END " 1223 ] 1224 1225 # Check the created PDB file. 1226 lines = file.readlines() 1227 for i in range(len(lines)): 1228 self.assertEqual(result[i]+'\n', lines[i])
1229 1230
1231 - def test_web_of_motion_13(self):
1232 """Check the operation of the structure.web_of_motion user function using structural models 1 and 3 (of 3).""" 1233 1234 # Load the file. 1235 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 1236 self.interpreter.structure.read_pdb('web_of_motion.pdb', dir=path) 1237 1238 # Run the structure.web_of_motion user function and collect the results in a dummy file object. 1239 file = DummyFileObject() 1240 self.interpreter.structure.web_of_motion(file=file, models=[1, 3]) 1241 1242 # The result. 1243 result = [ 1244 "REMARK 4 THIS FILE COMPLIES WITH FORMAT V. 3.30, JUL-2011. ", 1245 "REMARK 40 CREATED BY RELAX (HTTP://WWW.NMR-RELAX.COM). ", 1246 "ATOM 1 N LEU 4 9.464 -9.232 27.573 1.00 0.00 N ", 1247 "ATOM 2 N LEU 4 7.761 -6.392 27.161 1.00 0.00 N ", 1248 "ATOM 3 H LEU 4 8.575 -8.953 27.963 1.00 0.00 H ", 1249 "ATOM 4 H LEU 4 7.278 -6.195 28.026 1.00 0.00 H ", 1250 "ATOM 5 CA LEU 4 10.302 -8.195 26.930 1.00 0.00 C ", 1251 "ATOM 6 CA LEU 4 9.256 -6.332 27.183 1.00 0.00 C ", 1252 "ATOM 7 CB LEU 4 9.494 -7.221 26.051 1.00 0.00 C ", 1253 "ATOM 8 CB LEU 4 9.799 -5.331 26.144 1.00 0.00 C ", 1254 "ATOM 9 CG LEU 4 10.107 -5.862 25.665 1.00 0.00 C ", 1255 "ATOM 10 CG LEU 4 10.293 -5.882 24.803 1.00 0.00 C ", 1256 "ATOM 11 CD1 LEU 4 11.182 -6.007 24.608 1.00 0.00 C ", 1257 "ATOM 12 CD1 LEU 4 9.404 -6.984 24.274 1.00 0.00 C ", 1258 "ATOM 13 CD2 LEU 4 9.036 -4.875 25.171 1.00 0.00 C ", 1259 "ATOM 14 CD2 LEU 4 10.355 -4.772 23.792 1.00 0.00 C ", 1260 "ATOM 15 C LEU 4 10.999 -7.436 28.046 1.00 0.00 C ", 1261 "ATOM 16 C LEU 4 9.816 -6.033 28.572 1.00 0.00 C ", 1262 "TER 17 LEU 4 ", 1263 "CONECT 1 2 ", 1264 "CONECT 2 1 ", 1265 "CONECT 3 4 ", 1266 "CONECT 4 3 ", 1267 "CONECT 5 6 ", 1268 "CONECT 6 5 ", 1269 "CONECT 7 8 ", 1270 "CONECT 8 7 ", 1271 "CONECT 9 10 ", 1272 "CONECT 10 9 ", 1273 "CONECT 11 12 ", 1274 "CONECT 12 11 ", 1275 "CONECT 13 14 ", 1276 "CONECT 14 13 ", 1277 "CONECT 15 16 ", 1278 "CONECT 16 15 ", 1279 "MASTER 0 0 0 0 0 0 0 0 16 1 16 0 ", 1280 "END " 1281 ] 1282 1283 # Check the created PDB file. 1284 lines = file.readlines() 1285 for i in range(len(lines)): 1286 self.assertEqual(result[i]+'\n', lines[i])
1287 1288
1289 - def test_web_of_motion_all(self):
1290 """Check the operation of the structure.web_of_motion user function using all structural models.""" 1291 1292 # Load the file. 1293 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 1294 self.interpreter.structure.read_pdb('web_of_motion.pdb', dir=path) 1295 1296 # Run the structure.web_of_motion user function and collect the results in a dummy file object. 1297 file = DummyFileObject() 1298 self.interpreter.structure.web_of_motion(file=file) 1299 1300 # The result. 1301 result = [ 1302 "REMARK 4 THIS FILE COMPLIES WITH FORMAT V. 3.30, JUL-2011. ", 1303 "REMARK 40 CREATED BY RELAX (HTTP://WWW.NMR-RELAX.COM). ", 1304 "ATOM 1 N LEU 4 9.464 -9.232 27.573 1.00 0.00 N ", 1305 "ATOM 2 N LEU 4 9.211 -9.425 26.970 1.00 0.00 N ", 1306 "ATOM 3 N LEU 4 7.761 -6.392 27.161 1.00 0.00 N ", 1307 "ATOM 4 H LEU 4 8.575 -8.953 27.963 1.00 0.00 H ", 1308 "ATOM 5 H LEU 4 9.085 -9.743 27.919 1.00 0.00 H ", 1309 "ATOM 6 H LEU 4 7.278 -6.195 28.026 1.00 0.00 H ", 1310 "ATOM 7 CA LEU 4 10.302 -8.195 26.930 1.00 0.00 C ", 1311 "ATOM 8 CA LEU 4 10.077 -8.221 26.720 1.00 0.00 C ", 1312 "ATOM 9 CA LEU 4 9.256 -6.332 27.183 1.00 0.00 C ", 1313 "ATOM 10 CB LEU 4 9.494 -7.221 26.051 1.00 0.00 C ", 1314 "ATOM 11 CB LEU 4 9.297 -7.096 26.024 1.00 0.00 C ", 1315 "ATOM 12 CB LEU 4 9.799 -5.331 26.144 1.00 0.00 C ", 1316 "ATOM 13 CG LEU 4 10.107 -5.862 25.665 1.00 0.00 C ", 1317 "ATOM 14 CG LEU 4 10.061 -5.803 25.679 1.00 0.00 C ", 1318 "ATOM 15 CG LEU 4 10.293 -5.882 24.803 1.00 0.00 C ", 1319 "ATOM 16 CD1 LEU 4 11.182 -6.007 24.608 1.00 0.00 C ", 1320 "ATOM 17 CD1 LEU 4 11.029 -6.002 24.507 1.00 0.00 C ", 1321 "ATOM 18 CD1 LEU 4 9.404 -6.984 24.274 1.00 0.00 C ", 1322 "ATOM 19 CD2 LEU 4 9.036 -4.875 25.171 1.00 0.00 C ", 1323 "ATOM 20 CD2 LEU 4 9.120 -4.618 25.384 1.00 0.00 C ", 1324 "ATOM 21 CD2 LEU 4 10.355 -4.772 23.792 1.00 0.00 C ", 1325 "ATOM 22 C LEU 4 10.999 -7.436 28.046 1.00 0.00 C ", 1326 "ATOM 23 C LEU 4 10.625 -7.721 28.047 1.00 0.00 C ", 1327 "ATOM 24 C LEU 4 9.816 -6.033 28.572 1.00 0.00 C ", 1328 "TER 25 LEU 4 ", 1329 "CONECT 1 2 3 ", 1330 "CONECT 2 1 3 ", 1331 "CONECT 3 1 2 ", 1332 "CONECT 4 5 6 ", 1333 "CONECT 5 4 6 ", 1334 "CONECT 6 4 5 ", 1335 "CONECT 7 8 9 ", 1336 "CONECT 8 7 9 ", 1337 "CONECT 9 7 8 ", 1338 "CONECT 10 11 12 ", 1339 "CONECT 11 10 12 ", 1340 "CONECT 12 10 11 ", 1341 "CONECT 13 14 15 ", 1342 "CONECT 14 13 15 ", 1343 "CONECT 15 13 14 ", 1344 "CONECT 16 17 18 ", 1345 "CONECT 17 16 18 ", 1346 "CONECT 18 16 17 ", 1347 "CONECT 19 20 21 ", 1348 "CONECT 20 19 21 ", 1349 "CONECT 21 19 20 ", 1350 "CONECT 22 23 24 ", 1351 "CONECT 23 22 24 ", 1352 "CONECT 24 22 23 ", 1353 "MASTER 0 0 0 0 0 0 0 0 24 1 24 0 ", 1354 "END " 1355 ] 1356 1357 # Check the created PDB file. 1358 lines = file.readlines() 1359 for i in range(len(lines)): 1360 self.assertEqual(result[i]+'\n', lines[i])
1361