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-2012 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 numpy import float64, zeros 
 24  from os import sep 
 25  from tempfile import mktemp 
 26   
 27  # relax module imports. 
 28  from data import Relax_data_store; ds = Relax_data_store() 
 29  from generic_fns.mol_res_spin import count_spins, return_spin 
 30  from maths_fns.rotation_matrix import euler_to_R_zyz 
 31  from status import Status; status = Status() 
 32  from test_suite.system_tests.base_classes import SystemTestCase 
 33   
 34   
35 -class Structure(SystemTestCase):
36 """Class for testing the structural objects.""" 37
38 - def __init__(self, methodName='runTest'):
39 """Skip scientific Python tests if not installed. 40 41 @keyword methodName: The name of the test. 42 @type methodName: str 43 """ 44 45 # Execute the base class method. 46 super(Structure, self).__init__(methodName)
47 48
49 - def setUp(self):
50 """Set up for all the functional tests.""" 51 52 # Create the data pipe. 53 self.interpreter.pipe.create('mf', 'mf')
54 55
56 - def test_displacement(self):
57 """Test of the structure.displacement user function.""" 58 59 # Path of the structure file. 60 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 61 62 # Load the file as two models. 63 self.interpreter.structure.read_pdb('Ap4Aase_res1-12.pdb', dir=path, set_model_num=1) 64 self.interpreter.structure.read_pdb('Ap4Aase_res1-12.pdb', dir=path, set_model_num=2) 65 66 # A rotation. 67 R = zeros((3, 3), float64) 68 euler_to_R_zyz(1.3, 0.4, 4.5, R) 69 70 # Rotate the second model. 71 self.interpreter.structure.rotate(R, model=2) 72 73 # Calculate the displacement. 74 self.interpreter.structure.displacement() 75 76 # Shift a third structure back using the calculated displacement. 77 self.interpreter.structure.read_pdb('Ap4Aase_res1-12.pdb', dir=path, set_model_num=3) 78 self.interpreter.structure.rotate(R, model=3) 79 80 # The data to check. 81 models = [1, 2] 82 trans_vect = [ 83 [[0.0, 0.0, 0.0], 84 [ 2.270857972754659, -1.811667138656451, 1.878400649688508]], 85 [[ -2.270857972754659, 1.811667138656451, -1.878400649688508], 86 [0.0, 0.0, 0.0]] 87 ] 88 dist = [ 89 [0.0000000000000000, 3.4593818457148173], 90 [3.4593818457148173, 0.0000000000000000] 91 ] 92 rot_axis = [ 93 [None, 94 [ 0.646165066909452, 0.018875759848125, -0.762964227206007]], 95 [[ -0.646165066909452, -0.018875759848125, 0.762964227206007], 96 None] 97 ] 98 angle = [ 99 [0.0000000000000000, 0.6247677290742989], 100 [0.6247677290742989, 0.0000000000000000] 101 ] 102 103 # Test the results. 104 self.assert_(hasattr(cdp.structure, 'displacements')) 105 for i in range(len(models)): 106 for j in range(len(models)): 107 # Check the translation. 108 self.assertAlmostEqual(cdp.structure.displacements._translation_distance[models[i]][models[j]], dist[i][j]) 109 for k in range(3): 110 self.assertAlmostEqual(cdp.structure.displacements._translation_vector[models[i]][models[j]][k], trans_vect[i][j][k]) 111 112 # Check the rotation. 113 self.assertAlmostEqual(cdp.structure.displacements._rotation_angle[models[i]][models[j]], angle[i][j]) 114 if rot_axis[i][j] != None: 115 for k in range(3): 116 self.assertAlmostEqual(cdp.structure.displacements._rotation_axis[models[i]][models[j]][k], rot_axis[i][j][k]) 117 118 # Save the results. 119 self.tmpfile = mktemp() 120 self.interpreter.state.save(self.tmpfile, dir=None, force=True) 121 122 # Reset relax. 123 self.interpreter.reset() 124 125 # Load the results. 126 self.interpreter.state.load(self.tmpfile) 127 128 # Test the re-loaded data. 129 self.assert_(hasattr(cdp.structure, 'displacements')) 130 for i in range(len(models)): 131 for j in range(len(models)): 132 # Check the translation. 133 self.assertAlmostEqual(cdp.structure.displacements._translation_distance[models[i]][models[j]], dist[i][j]) 134 for k in range(3): 135 self.assertAlmostEqual(cdp.structure.displacements._translation_vector[models[i]][models[j]][k], trans_vect[i][j][k]) 136 137 # Check the rotation. 138 self.assertAlmostEqual(cdp.structure.displacements._rotation_angle[models[i]][models[j]], angle[i][j]) 139 if rot_axis[i][j] != None: 140 for k in range(3): 141 self.assertAlmostEqual(cdp.structure.displacements._rotation_axis[models[i]][models[j]][k], rot_axis[i][j][k])
142 143
145 """Load the PDB file using the information in a results file (using the internal structural object).""" 146 147 # Path of the files. 148 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 149 150 # Read the results file. 151 self.interpreter.results.read(file='str_internal', dir=path) 152 153 # Test the structure metadata. 154 self.assert_(hasattr(cdp, 'structure')) 155 self.assert_(hasattr(cdp.structure, 'structural_data')) 156 self.assert_(len(cdp.structure.structural_data)) 157 self.assert_(len(cdp.structure.structural_data[0].mol)) 158 159 mol = cdp.structure.structural_data[0].mol[0] 160 self.assertEqual(mol.file_name, 'Ap4Aase_res1-12.pdb') 161 self.assertEqual(mol.file_path, '') 162 self.assertEqual(mol.file_model, 1) 163 self.assertEqual(mol.file_mol_num, 1) 164 165 # The real atomic data. 166 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'] 167 bonded = [[]]*174 168 chain_id = [None]*174 169 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'] 170 pdb_record = ['ATOM']*174 171 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'] 172 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] 173 seg_id = [None]*174 174 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] 175 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] 176 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] 177 178 # Test the atomic data. 179 mol = cdp.structure.structural_data[0].mol[0] 180 for i in range(len(mol.atom_name)): 181 self.assertEqual(mol.atom_name[i], atom_name[i]) 182 self.assertEqual(mol.bonded[i], bonded[i]) 183 self.assertEqual(mol.chain_id[i], chain_id[i]) 184 self.assertEqual(mol.element[i], element[i]) 185 self.assertEqual(mol.pdb_record[i], pdb_record[i]) 186 self.assertEqual(mol.res_name[i], res_name[i]) 187 self.assertEqual(mol.res_num[i], res_num[i]) 188 self.assertEqual(mol.seg_id[i], seg_id[i]) 189 self.assertEqual(mol.x[i], x[i]) 190 self.assertEqual(mol.y[i], y[i]) 191 self.assertEqual(mol.z[i], z[i])
192 193
195 """Load the PDB file using the information in a results file (using the internal structural object).""" 196 197 # Path of the files. 198 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 199 200 # Read the results file. 201 self.interpreter.results.read(file=path+sep+'str_internal')
202 203
205 """Load the PDB file using the information in a results file (using the Scientific python structural object).""" 206 207 # Path of the files. 208 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 209 210 # Read the results file. 211 self.interpreter.results.read(file='str_scientific', dir=path) 212 213 # Test the structure metadata. 214 self.assert_(hasattr(cdp, 'structure')) 215 self.assert_(hasattr(cdp.structure, 'structural_data')) 216 self.assert_(len(cdp.structure.structural_data)) 217 self.assert_(len(cdp.structure.structural_data[0].mol)) 218 219 mol = cdp.structure.structural_data[0].mol[0] 220 self.assertEqual(mol.file_name, 'Ap4Aase_res1-12.pdb') 221 self.assertEqual(mol.file_path, 'test_suite/shared_data/structures') 222 self.assertEqual(mol.file_model, 1) 223 self.assertEqual(mol.file_mol_num, 1) 224 225 # The real atomic data. 226 res_list = ['GLY', 'PRO', 'LEU', 'GLY', 'SER', 'MET', 'ASP', 'SER', 'PRO', 'PRO', 'GLU', 'GLY'] 227 228 # Loop over the residues. 229 i = 0 230 for res_name in cdp.structure.atom_loop(atom_id='@N', res_name_flag=True): 231 res_name = res_name[0] 232 233 # Check the residue data. 234 self.assertEqual(res_name, res_list[i]) 235 236 # Increment the residue counter. 237 i = i + 1
238 239
240 - def test_read_not_pdb(self):
241 """Test the reading of a file by structure.read_pdb that is not a PDB.""" 242 243 # Path of the files. 244 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'saved_states' 245 246 # Read the non-PDB file. 247 self.interpreter.structure.read_pdb(file='basic_single_pipe.bz2', dir=path, parser='internal')
248 249
250 - def test_read_pdb_internal1(self):
251 """Load the '1F35_N_H_molmol.pdb' PDB file (using the internal structural object PDB reader).""" 252 253 # Path of the files. 254 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 255 256 # Read the PDB. 257 self.interpreter.structure.read_pdb(file='1F35_N_H_molmol.pdb', dir=path, parser='internal') 258 259 # Test the molecule name. 260 self.assertEqual(cdp.structure.structural_data[0].mol[0].mol_name, '1F35_N_H_molmol_mol1') 261 262 # Load a single atom and test it. 263 self.interpreter.structure.load_spins('#1F35_N_H_molmol_mol1:3@N') 264 self.assertEqual(count_spins(), 1) 265 266 # Try loading a few protons. 267 self.interpreter.structure.load_spins('@*H*') 268 269 # And now all the rest of the atoms. 270 self.interpreter.structure.load_spins() 271 272 # Extract a N-Ca vector. 273 self.interpreter.dipole_pair.define(spin_id1='@CA', spin_id2='#1F35_N_H_molmol_mol1:3@N') 274 self.interpreter.dipole_pair.unit_vectors() 275 print(cdp.interatomic[0]) 276 self.assert_(hasattr(cdp.interatomic[0], 'vector'))
277 278 279
280 - def test_read_pdb_internal2(self):
281 """Load the 'Ap4Aase_res1-12.pdb' PDB file (using the internal structural object PDB reader).""" 282 283 # Path of the files. 284 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 285 286 # Read the PDB. 287 self.interpreter.structure.read_pdb(file='Ap4Aase_res1-12.pdb', dir=path, parser='internal') 288 289 # Try loading a few protons. 290 self.interpreter.structure.load_spins('@*H*') 291 292 # And now all the rest of the atoms. 293 self.interpreter.structure.load_spins()
294 295
296 - def test_read_pdb_internal3(self):
297 """Load the 'gromacs.pdb' PDB file (using the internal structural object PDB reader).""" 298 299 # Path of the files. 300 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'phthalic_acid' 301 302 # Read the PDB. 303 self.interpreter.structure.read_pdb(file='gromacs.pdb', dir=path, parser='internal') 304 305 # Try loading a few protons, without positions averaging across models. 306 self.interpreter.structure.load_spins('@*H*', ave_pos=False) 307 308 # A test. 309 self.assertEqual(len(cdp.mol[0].res[0].spin[0].pos), 2) 310 311 # And now all the rest of the atoms. 312 self.interpreter.structure.load_spins()
313 314
315 - def test_read_pdb_internal4(self):
316 """Load the 'tylers_peptide_trunc.pdb' PDB file (using the internal structural object PDB reader).""" 317 318 # Path of the files. 319 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 320 321 # Read the PDB. 322 self.interpreter.structure.read_pdb(file='tylers_peptide_trunc.pdb', dir=path, parser='internal') 323 324 # Try loading a few protons. 325 self.interpreter.structure.load_spins('@*H*') 326 327 # And now all the rest of the atoms. 328 self.interpreter.structure.load_spins()
329 330
331 - def test_read_pdb_internal5(self):
332 """Load the 'lactose_MCMM4_S1_1.pdb' PDB file (using the internal structural object PDB reader).""" 333 334 # Path of the files. 335 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'lactose' 336 337 # Read the PDB. 338 self.interpreter.structure.read_pdb(file='lactose_MCMM4_S1_1.pdb', dir=path, parser='internal') 339 340 # Try loading a few protons. 341 self.interpreter.structure.load_spins('@*H*') 342 343 # And now all the rest of the atoms. 344 self.interpreter.structure.load_spins()
345 346
347 - def test_read_pdb_internal6(self):
348 """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).""" 349 350 # Path of the files. 351 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'lactose' 352 353 # Read the PDB twice. 354 self.interpreter.structure.read_pdb(file='lactose_MCMM4_S1_1.pdb', dir=path, parser='internal') 355 self.interpreter.structure.read_pdb(file='lactose_MCMM4_S1_2.pdb', dir=path, parser='internal') 356 357 # Try loading a few protons. 358 self.interpreter.structure.load_spins('@*H*') 359 360 # And now all the rest of the atoms. 361 self.interpreter.structure.load_spins()
362 363
364 - def test_read_pdb_internal7(self):
365 """Load the 'lactose_MCMM4_S1_1.pdb' PDB file twice as 2 separate structures (using the internal structural object PDB reader).""" 366 367 # Path of the files. 368 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'lactose' 369 370 # Read the PDB twice. 371 self.interpreter.structure.read_pdb(file='lactose_MCMM4_S1_1.pdb', dir=path, parser='internal') 372 self.interpreter.structure.read_pdb(file='lactose_MCMM4_S1_1.pdb', dir=path, parser='internal') 373 374 # Try loading a few protons. 375 self.interpreter.structure.load_spins('@*H*') 376 377 # And now all the rest of the atoms. 378 self.interpreter.structure.load_spins()
379 380
382 """Load a few 'lactose_MCMM4_S1_*.pdb' PDB files as models (using the internal structural object PDB reader).""" 383 384 # Path of the files. 385 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'lactose' 386 387 # Files. 388 files = ['lactose_MCMM4_S1_1.pdb', 389 'lactose_MCMM4_S1_2.pdb', 390 'lactose_MCMM4_S1_3.pdb'] 391 392 # Read the PDBs. 393 self.interpreter.structure.read_pdb(file=files[0], dir=path, parser='internal', set_model_num=1) 394 self.interpreter.structure.read_pdb(file=files[1], dir=path, parser='internal', set_model_num=1) 395 self.interpreter.structure.read_pdb(file=files[2], dir=path, parser='internal', set_model_num=1) 396 397 # Try loading a few protons. 398 self.interpreter.structure.load_spins('@*H*') 399 400 # And now all the rest of the atoms. 401 self.interpreter.structure.load_spins() 402 403 # Test the structural data. 404 self.assert_(hasattr(cdp, 'structure')) 405 self.assert_(hasattr(cdp.structure, 'structural_data')) 406 self.assertEqual(len(cdp.structure.structural_data), 1) 407 self.assertEqual(len(cdp.structure.structural_data[0].mol), 3) 408 409 i = 0 410 for mol in cdp.structure.structural_data[0].mol: 411 self.assertEqual(mol.file_name, files[i]) 412 self.assertEqual(mol.file_path, path) 413 self.assertEqual(mol.file_model, 1) 414 self.assertEqual(mol.file_mol_num, 1) 415 i = i + 1
416 417
419 """Load the 2 models of the 'gromacs.pdb' PDB file as separate molecules of the same model (using the internal structural object PDB reader).""" 420 421 # Path of the files. 422 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'phthalic_acid' 423 424 # Read the PDB models. 425 self.interpreter.structure.read_pdb(file='gromacs.pdb', dir=path, parser='internal', read_model=1, set_model_num=1) 426 self.interpreter.structure.read_pdb(file='gromacs.pdb', dir=path, parser='internal', read_model=2, set_model_num=1) 427 428 # Try loading a few protons. 429 self.interpreter.structure.load_spins('@*H*') 430 431 # And now all the rest of the atoms. 432 self.interpreter.structure.load_spins() 433 434 # Test the structural data. 435 self.assert_(hasattr(cdp, 'structure')) 436 self.assert_(hasattr(cdp.structure, 'structural_data')) 437 self.assertEqual(len(cdp.structure.structural_data), 1) 438 self.assertEqual(len(cdp.structure.structural_data[0].mol), 2) 439 440 i = 0 441 for mol in cdp.structure.structural_data[0].mol: 442 self.assertEqual(mol.file_name, 'gromacs.pdb') 443 self.assertEqual(mol.file_path, path) 444 self.assertEqual(mol.file_model, i+1) 445 self.assertEqual(mol.file_mol_num, 1) 446 i = i + 1
447 448
450 """Test the packing of models and molecules using 'gromacs.pdb' and 'lactose_MCMM4_S1_*.pdb' (using the internal structural object PDB reader).""" 451 452 # Path of the files. 453 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 454 455 # Read the PDB models. 456 self.interpreter.structure.read_pdb(file='gromacs.pdb', dir=path+sep+'phthalic_acid', parser='internal') 457 self.interpreter.structure.read_pdb(file='lactose'+sep+'lactose_MCMM4_S1_1.pdb', dir=path, parser='internal', set_model_num=1, set_mol_name='lactose_MCMM4_S1') 458 self.interpreter.structure.read_pdb(file='lactose'+sep+'lactose_MCMM4_S1_2.pdb', dir=path, parser='internal', set_model_num=2, set_mol_name='lactose_MCMM4_S1') 459 self.interpreter.structure.read_pdb(file='lactose'+sep+'lactose_MCMM4_S1_3.pdb', dir=path, parser='internal', set_model_num=1, set_mol_name='lactose_MCMM4_S1b') 460 self.interpreter.structure.read_pdb(file='lactose'+sep+'lactose_MCMM4_S1_4.pdb', dir=path, parser='internal', set_model_num=2, set_mol_name='lactose_MCMM4_S1b') 461 462 # Try loading a few protons. 463 self.interpreter.structure.load_spins('@*H*') 464 465 # And now all the rest of the atoms. 466 self.interpreter.structure.load_spins() 467 468 # Test the structural data. 469 self.assert_(hasattr(cdp, 'structure')) 470 self.assert_(hasattr(cdp.structure, 'structural_data')) 471 self.assertEqual(len(cdp.structure.structural_data), 2) 472 self.assertEqual(len(cdp.structure.structural_data[0].mol), 3) 473 self.assertEqual(len(cdp.structure.structural_data[1].mol), 3) 474 475 files = [['gromacs.pdb', 'lactose_MCMM4_S1_1.pdb', 'lactose_MCMM4_S1_3.pdb'], 476 ['gromacs.pdb', 'lactose_MCMM4_S1_2.pdb', 'lactose_MCMM4_S1_4.pdb']] 477 paths = [[path+sep+'phthalic_acid', path+sep+'lactose', path+sep+'lactose'], 478 [path+sep+'phthalic_acid', path+sep+'lactose', path+sep+'lactose']] 479 models = [[1, 1, 1], [2, 1, 1]] 480 481 for i in range(len(cdp.structure.structural_data)): 482 for j in range(len(cdp.structure.structural_data[i].mol)): 483 mol = cdp.structure.structural_data[i].mol[j] 484 self.assertEqual(mol.file_name, files[i][j]) 485 self.assertEqual(mol.file_path, paths[i][j]) 486 self.assertEqual(mol.file_model, models[i][j]) 487 self.assertEqual(mol.file_mol_num, 1)
488 489
491 """Load the '1F35_N_H_molmol.pdb' PDB file (using the Scientific python structural object PDB reader).""" 492 493 # Path of the files. 494 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 495 496 # Read the PDB. 497 self.interpreter.structure.read_pdb(file='1F35_N_H_molmol.pdb', dir=path, parser='scientific') 498 499 # Load a single atom and test it. 500 self.interpreter.structure.load_spins('#1F35_N_H_molmol_mol1:3@N') 501 self.assertEqual(count_spins(), 1) 502 503 # Try loading a few protons. 504 self.interpreter.structure.load_spins('@*H*') 505 506 # And now all the rest of the atoms. 507 self.interpreter.structure.load_spins() 508 509 # Extract a N-Ca vector. 510 self.interpreter.dipole_pair.define(spin_id1='@CA', spin_id2='#1F35_N_H_molmol_mol1:3@N') 511 self.interpreter.dipole_pair.unit_vectors() 512 print(cdp.interatomic[0]) 513 self.assert_(hasattr(cdp.interatomic[0], 'vector'))
514 515
517 """Load the 'Ap4Aase_res1-12.pdb' PDB file (using the Scientific python structural object PDB reader).""" 518 519 # Path of the files. 520 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 521 522 # Read the PDB. 523 self.interpreter.structure.read_pdb(file='Ap4Aase_res1-12.pdb', dir=path, parser='scientific') 524 525 # Try loading a few protons. 526 self.interpreter.structure.load_spins('@*H*') 527 528 # And now all the rest of the atoms. 529 self.interpreter.structure.load_spins()
530 531
533 """Load the 'gromacs.pdb' PDB file (using the Scientific python structural object PDB reader).""" 534 535 # Path of the files. 536 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'phthalic_acid' 537 538 # Read the PDB. 539 self.interpreter.structure.read_pdb(file='gromacs.pdb', dir=path, parser='scientific') 540 541 # Try loading a few protons. 542 self.interpreter.structure.load_spins('@*H*', ave_pos=False) 543 544 # A test. 545 self.assertEqual(len(cdp.mol[0].res[0].spin[0].pos), 2) 546 547 # And now all the rest of the atoms. 548 self.interpreter.structure.load_spins()
549 550
552 """Load the 'tylers_peptide_trunc.pdb' PDB file (using the Scientific python structural object PDB reader).""" 553 554 # Path of the files. 555 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 556 557 # Read the PDB. 558 self.interpreter.structure.read_pdb(file='tylers_peptide_trunc.pdb', dir=path, parser='scientific') 559 560 # Try loading a few protons. 561 self.interpreter.structure.load_spins('@*H*') 562 563 # And now all the rest of the atoms. 564 self.interpreter.structure.load_spins()
565 566
568 """Load the 'lactose_MCMM4_S1_1.pdb' PDB file (using the Scientific python structural object PDB reader).""" 569 570 # Path of the files. 571 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'lactose' 572 573 # Read the PDB. 574 self.interpreter.structure.read_pdb(file='lactose_MCMM4_S1_1.pdb', dir=path, parser='scientific') 575 576 # Try loading a few protons. 577 self.interpreter.structure.load_spins('@*H*') 578 579 # And now all the rest of the atoms. 580 self.interpreter.structure.load_spins()
581 582
584 """Load the 'lactose_MCMM4_S1_1.pdb' and 'lactose_MCMM4_S1_2.pdb' PDB files as 2 separate structures (using the Scientific python structural object PDB reader).""" 585 586 # Path of the files. 587 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'lactose' 588 589 # Read the PDB twice. 590 self.interpreter.structure.read_pdb(file='lactose_MCMM4_S1_1.pdb', dir=path, parser='scientific') 591 self.interpreter.structure.read_pdb(file='lactose_MCMM4_S1_2.pdb', dir=path, parser='scientific') 592 593 # Try loading a few protons. 594 self.interpreter.structure.load_spins('@*H*') 595 596 # And now all the rest of the atoms. 597 self.interpreter.structure.load_spins()
598 599
601 """Load the 'lactose_MCMM4_S1_1.pdb' PDB file twice as 2 separate structures (using the Scientific python structural object PDB reader).""" 602 603 # Path of the files. 604 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'lactose' 605 606 # Read the PDB twice. 607 self.interpreter.structure.read_pdb(file='lactose_MCMM4_S1_1.pdb', dir=path, parser='scientific') 608 self.interpreter.structure.read_pdb(file='lactose_MCMM4_S1_1.pdb', dir=path, parser='scientific') 609 610 # Try loading a few protons. 611 self.interpreter.structure.load_spins('@*H*') 612 613 # And now all the rest of the atoms. 614 self.interpreter.structure.load_spins()
615 616
618 """Load a few 'lactose_MCMM4_S1_*.pdb' PDB files as models (using the Scientific python structural object PDB reader).""" 619 620 # Path of the files. 621 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'lactose' 622 623 # Files. 624 files = ['lactose_MCMM4_S1_1.pdb', 625 'lactose_MCMM4_S1_2.pdb', 626 'lactose_MCMM4_S1_3.pdb'] 627 628 # Read the PDBs. 629 self.interpreter.structure.read_pdb(file=files[0], dir=path, parser='scientific', set_model_num=1) 630 self.interpreter.structure.read_pdb(file=files[1], dir=path, parser='scientific', set_model_num=1) 631 self.interpreter.structure.read_pdb(file=files[2], dir=path, parser='scientific', set_model_num=1) 632 633 # Try loading a few protons. 634 self.interpreter.structure.load_spins('@*H*') 635 636 # And now all the rest of the atoms. 637 self.interpreter.structure.load_spins() 638 639 # Test the structural data. 640 self.assert_(hasattr(cdp, 'structure')) 641 self.assert_(hasattr(cdp.structure, 'structural_data')) 642 self.assertEqual(len(cdp.structure.structural_data), 1) 643 self.assertEqual(len(cdp.structure.structural_data[0].mol), 6) 644 645 i = 0 646 for mol in cdp.structure.structural_data[0].mol: 647 self.assertEqual(mol.file_name, files[int(i/2)]) 648 self.assertEqual(mol.file_path, path) 649 self.assertEqual(mol.file_model, 1) 650 self.assertEqual(mol.file_mol_num, i%2+1) # Odd i, num=1, even i, num=2. 651 i = i + 1
652 653
655 """Load the 2 models of the 'gromacs.pdb' PDB file as separate molecules of the same model (using the Scientific python structural object PDB reader).""" 656 657 # Path of the files. 658 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'phthalic_acid' 659 660 # Read the PDB models. 661 self.interpreter.structure.read_pdb(file='gromacs.pdb', dir=path, parser='scientific', read_model=1, set_model_num=1) 662 self.interpreter.structure.read_pdb(file='gromacs.pdb', dir=path, parser='scientific', read_model=2, set_model_num=1) 663 664 # Try loading a few protons. 665 self.interpreter.structure.load_spins('@*H*') 666 667 # And now all the rest of the atoms. 668 self.interpreter.structure.load_spins() 669 670 # Test the structural data. 671 self.assert_(hasattr(cdp, 'structure')) 672 self.assert_(hasattr(cdp.structure, 'structural_data')) 673 self.assertEqual(len(cdp.structure.structural_data), 1) 674 self.assertEqual(len(cdp.structure.structural_data[0].mol), 2) 675 676 i = 0 677 for mol in cdp.structure.structural_data[0].mol: 678 self.assertEqual(mol.file_name, 'gromacs.pdb') 679 self.assertEqual(mol.file_path, path) 680 self.assertEqual(mol.file_model, i+1) 681 self.assertEqual(mol.file_mol_num, 1) 682 i = i + 1
683 684
686 """Test the packing of models and molecules using 'gromacs.pdb' and 'lactose_MCMM4_S1_*.pdb' (using the Scientific python structural object PDB reader).""" 687 688 # Path of the files. 689 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 690 691 # Read the PDB models. 692 self.interpreter.structure.read_pdb(file='gromacs.pdb', dir=path+sep+'phthalic_acid', parser='scientific') 693 self.interpreter.structure.read_pdb(file='lactose'+sep+'lactose_MCMM4_S1_1.pdb', dir=path, parser='scientific', read_mol=1, set_model_num=1, set_mol_name='lactose_MCMM4_S1') 694 self.interpreter.structure.read_pdb(file='lactose'+sep+'lactose_MCMM4_S1_2.pdb', dir=path, parser='scientific', read_mol=1, set_model_num=2, set_mol_name='lactose_MCMM4_S1') 695 self.interpreter.structure.read_pdb(file='lactose'+sep+'lactose_MCMM4_S1_3.pdb', dir=path, parser='scientific', read_mol=1, set_model_num=1, set_mol_name='lactose_MCMM4_S1b') 696 self.interpreter.structure.read_pdb(file='lactose'+sep+'lactose_MCMM4_S1_4.pdb', dir=path, parser='scientific', read_mol=1, set_model_num=2, set_mol_name='lactose_MCMM4_S1b') 697 698 # Try loading a few protons. 699 self.interpreter.structure.load_spins('@*H*') 700 701 # And now all the rest of the atoms. 702 self.interpreter.structure.load_spins() 703 704 # Test the structural data. 705 self.assert_(hasattr(cdp, 'structure')) 706 self.assert_(hasattr(cdp.structure, 'structural_data')) 707 self.assertEqual(len(cdp.structure.structural_data), 2) 708 self.assertEqual(len(cdp.structure.structural_data[0].mol), 3) 709 self.assertEqual(len(cdp.structure.structural_data[1].mol), 3) 710 711 files = [['gromacs.pdb', 'lactose_MCMM4_S1_1.pdb', 'lactose_MCMM4_S1_3.pdb'], 712 ['gromacs.pdb', 'lactose_MCMM4_S1_2.pdb', 'lactose_MCMM4_S1_4.pdb']] 713 paths = [[path+sep+'phthalic_acid', path+sep+'lactose', path+sep+'lactose'], 714 [path+sep+'phthalic_acid', path+sep+'lactose', path+sep+'lactose']] 715 models = [[1, 1, 1], [2, 1, 1]] 716 717 for i in range(len(cdp.structure.structural_data)): 718 for j in range(len(cdp.structure.structural_data[i].mol)): 719 mol = cdp.structure.structural_data[i].mol[j] 720 self.assertEqual(mol.file_name, files[i][j]) 721 self.assertEqual(mol.file_path, paths[i][j]) 722 self.assertEqual(mol.file_model, models[i][j]) 723 self.assertEqual(mol.file_mol_num, 1)
724 725
726 - def test_read_xyz_internal1(self):
727 """Load the 'Indol_test.xyz' XYZ file (using the internal structural object XYZ reader).""" 728 729 # Path of the files. 730 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 731 732 # Read the XYZ file. 733 self.interpreter.structure.read_xyz(file='Indol_test.xyz', dir=path) 734 735 # Test the molecule name. 736 self.assertEqual(cdp.structure.structural_data[0].mol[0].mol_name, 'Indol_test_mol1') 737 738 # Load a single atom and test it. 739 self.interpreter.structure.load_spins('#Indol_test_mol1@3') 740 self.assertEqual(count_spins(), 1) 741 742 # Try loading a few protons. 743 self.interpreter.structure.load_spins('@*H*') 744 745 # And now all the rest of the atoms. 746 self.interpreter.structure.load_spins()
747 748
749 - def test_read_xyz_internal2(self):
750 """Load the 'SSS-cluster4-new-test.xyz' XYZ file (using the internal structural object XYZ reader).""" 751 752 # Path of the files. 753 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 754 755 # Read the XYZ file. 756 self.interpreter.structure.read_xyz(file='SSS-cluster4-new-test.xyz', dir=path, read_model=[1]) 757 758 # Test the molecule name. 759 self.assertEqual(cdp.structure.structural_data[0].mol[0].mol_name, 'SSS-cluster4-new-test_mol1') 760 761 # Load a single atom and test it. 762 self.interpreter.structure.load_spins('#SSS-cluster4-new-test_mol1@2') 763 self.assertEqual(count_spins(), 1) 764 765 # Test the spin coordinates. 766 a=return_spin('#SSS-cluster4-new-test_mol1@2') 767 self.assertAlmostEqual(a.pos[0], -12.398) 768 self.assertAlmostEqual(a.pos[1], -15.992) 769 self.assertAlmostEqual(a.pos[2], 11.448) 770 771 # Try loading a few protons. 772 #self.interpreter.structure.load_spins('@H') 773 774 # And now all the rest of the atoms. 775 self.interpreter.structure.load_spins() 776 777 # Extract a vector between first two spins. 778 self.interpreter.dipole_pair.define(spin_id1='@2', spin_id2='@10') 779 self.interpreter.dipole_pair.unit_vectors() 780 self.assertAlmostEqual(cdp.interatomic[0].vector[0], -0.4102707) 781 self.assertAlmostEqual(cdp.interatomic[0].vector[1], 0.62128879) 782 self.assertAlmostEqual(cdp.interatomic[0].vector[2], -0.6675913)
783 784
786 """Test of the structure.superimpose user function, fitting to the first structure.""" 787 788 # Path of the structure file. 789 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'frame_order' 790 791 # Load the two rotated structures. 792 self.interpreter.structure.read_pdb('1J7P_1st_NH.pdb', dir=path, set_model_num=1, set_mol_name='CaM') 793 self.interpreter.structure.read_pdb('1J7P_1st_NH_rot.pdb', dir=path, set_model_num=2, set_mol_name='CaM') 794 self.interpreter.structure.read_pdb('1J7P_1st_NH.pdb', dir=path, set_model_num=3, set_mol_name='CaM') 795 796 # Superimpose the backbone heavy atoms. 797 self.interpreter.structure.superimpose(method='fit to first', atom_id='@N,C,CA,O') 798 799 # Check that the two structures now have the same atomic coordinates. 800 model1 = cdp.structure.structural_data[0].mol[0] 801 model2 = cdp.structure.structural_data[1].mol[0] 802 model3 = cdp.structure.structural_data[2].mol[0] 803 for i in range(len(model1.atom_name)): 804 # Check model 2. 805 self.assertAlmostEqual(model1.x[i], model2.x[i], 2) 806 self.assertAlmostEqual(model1.y[i], model2.y[i], 2) 807 self.assertAlmostEqual(model1.z[i], model2.z[i], 2) 808 809 # Check model 3. 810 self.assertAlmostEqual(model1.x[i], model3.x[i], 2) 811 self.assertAlmostEqual(model1.y[i], model3.y[i], 2) 812 self.assertAlmostEqual(model1.z[i], model3.z[i], 2)
813 814
816 """Test of the structure.superimpose user function, fitting to the mean structure.""" 817 818 # Path of the structure file. 819 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'frame_order' 820 821 # Load the two rotated structures. 822 self.interpreter.structure.read_pdb('1J7P_1st_NH.pdb', dir=path, set_model_num=1, set_mol_name='CaM') 823 self.interpreter.structure.read_pdb('1J7P_1st_NH_rot.pdb', dir=path, set_model_num=2, set_mol_name='CaM') 824 825 # Superimpose the backbone heavy atoms. 826 self.interpreter.structure.superimpose(method='fit to mean', atom_id='@N,C,CA,O') 827 828 # Check that the two structures now have the same atomic coordinates. 829 model1 = cdp.structure.structural_data[0].mol[0] 830 model2 = cdp.structure.structural_data[1].mol[0] 831 for i in range(len(model1.atom_name)): 832 self.assertAlmostEqual(model1.x[i], model2.x[i], 2) 833 self.assertAlmostEqual(model1.y[i], model2.y[i], 2) 834 self.assertAlmostEqual(model1.z[i], model2.z[i], 2)
835 836
838 """Second test of the structure.superimpose user function, fitting to the mean structure.""" 839 840 # Path of the structure file. 841 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'frame_order' 842 843 # Load the two rotated structures. 844 self.interpreter.structure.read_pdb('1J7P_1st_NH.pdb', dir=path, set_model_num=1, set_mol_name='CaM') 845 self.interpreter.structure.read_pdb('1J7P_1st_NH.pdb', dir=path, set_model_num=2, set_mol_name='CaM') 846 self.interpreter.structure.read_pdb('1J7P_1st_NH.pdb', dir=path, set_model_num=3, set_mol_name='CaM') 847 848 # Transpose model 3. 849 self.interpreter.structure.translate([20.0, 0.0, 0.0], model=3) 850 851 # Superimpose the backbone heavy atoms. 852 self.interpreter.structure.superimpose(models=[2, 3], method='fit to mean', atom_id='@N,C,CA,O') 853 854 # Check that the two structures now have the same atomic coordinates as the original, but shifted 10 Angstrom in x. 855 model1 = cdp.structure.structural_data[0].mol[0] 856 model2 = cdp.structure.structural_data[1].mol[0] 857 model3 = cdp.structure.structural_data[2].mol[0] 858 for i in range(len(model1.atom_name)): 859 # Check model 2. 860 self.assertAlmostEqual(model1.x[i] + 10, model2.x[i], 2) 861 self.assertAlmostEqual(model1.y[i], model2.y[i], 2) 862 self.assertAlmostEqual(model1.z[i], model2.z[i], 2) 863 864 # Check model 3. 865 self.assertAlmostEqual(model2.x[i], model3.x[i], 2) 866 self.assertAlmostEqual(model2.y[i], model3.y[i], 2) 867 self.assertAlmostEqual(model2.z[i], model3.z[i], 2)
868