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-2011 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax.                                     # 
  6  #                                                                             # 
  7  # relax 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 2 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # relax 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 relax; if not, write to the Free Software                        # 
 19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  # Python module imports. 
 24  from numpy import float64, zeros 
 25  from os import sep 
 26  from tempfile import mktemp 
 27   
 28  # relax module imports. 
 29  from base_classes import SystemTestCase 
 30  from data import Relax_data_store; ds = Relax_data_store() 
 31  from generic_fns.mol_res_spin import count_spins, return_spin 
 32  from maths_fns.rotation_matrix import euler_to_R_zyz 
 33  from status import Status; status = Status() 
 34   
 35   
36 -class Structure(SystemTestCase):
37 """Class for testing the structural objects.""" 38
39 - def __init__(self, methodName='runTest'):
40 """Skip scientific Python tests if not installed. 41 42 @keyword methodName: The name of the test. 43 @type methodName: str 44 """ 45 46 # Execute the base class method. 47 super(Structure, self).__init__(methodName)
48 49
50 - def setUp(self):
51 """Set up for all the functional tests.""" 52 53 # Create the data pipe. 54 self.interpreter.pipe.create('mf', 'mf')
55 56
57 - def test_displacement(self):
58 """Test of the structure.displacement user function.""" 59 60 # Path of the structure file. 61 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 62 63 # Load the file as two models. 64 self.interpreter.structure.read_pdb('Ap4Aase_res1-12.pdb', dir=path, set_model_num=1) 65 self.interpreter.structure.read_pdb('Ap4Aase_res1-12.pdb', dir=path, set_model_num=2) 66 67 # A rotation. 68 R = zeros((3, 3), float64) 69 euler_to_R_zyz(1.3, 0.4, 4.5, R) 70 71 # Rotate the second model. 72 self.interpreter.structure.rotate(R, model=2) 73 74 # Calculate the displacement. 75 self.interpreter.structure.displacement() 76 77 # Shift a third structure back using the calculated displacement. 78 self.interpreter.structure.read_pdb('Ap4Aase_res1-12.pdb', dir=path, set_model_num=3) 79 self.interpreter.structure.rotate(R, model=3) 80 81 # The data to check. 82 models = [1, 2] 83 trans_vect = [ 84 [[0.0, 0.0, 0.0], 85 [ 2.270857972754659, -1.811667138656451, 1.878400649688508]], 86 [[ -2.270857972754659, 1.811667138656451, -1.878400649688508], 87 [0.0, 0.0, 0.0]] 88 ] 89 dist = [ 90 [0.0000000000000000, 3.4593818457148173], 91 [3.4593818457148173, 0.0000000000000000] 92 ] 93 rot_axis = [ 94 [None, 95 [ 0.646165066909452, 0.018875759848125, -0.762964227206007]], 96 [[ -0.646165066909452, -0.018875759848125, 0.762964227206007], 97 None] 98 ] 99 angle = [ 100 [0.0000000000000000, 0.6247677290742989], 101 [0.6247677290742989, 0.0000000000000000] 102 ] 103 104 # Test the results. 105 self.assert_(hasattr(cdp.structure, 'displacements')) 106 for i in range(len(models)): 107 for j in range(len(models)): 108 # Check the translation. 109 self.assertAlmostEqual(cdp.structure.displacements._translation_distance[models[i]][models[j]], dist[i][j]) 110 for k in range(3): 111 self.assertAlmostEqual(cdp.structure.displacements._translation_vector[models[i]][models[j]][k], trans_vect[i][j][k]) 112 113 # Check the rotation. 114 self.assertAlmostEqual(cdp.structure.displacements._rotation_angle[models[i]][models[j]], angle[i][j]) 115 if rot_axis[i][j] != None: 116 for k in range(3): 117 self.assertAlmostEqual(cdp.structure.displacements._rotation_axis[models[i]][models[j]][k], rot_axis[i][j][k]) 118 119 # Save the results. 120 self.tmpfile = mktemp() 121 self.interpreter.state.save(self.tmpfile, dir=None, force=True) 122 123 # Reset relax. 124 self.interpreter.reset() 125 126 # Load the results. 127 self.interpreter.state.load(self.tmpfile) 128 129 # Test the re-loaded data. 130 self.assert_(hasattr(cdp.structure, 'displacements')) 131 for i in range(len(models)): 132 for j in range(len(models)): 133 # Check the translation. 134 self.assertAlmostEqual(cdp.structure.displacements._translation_distance[models[i]][models[j]], dist[i][j]) 135 for k in range(3): 136 self.assertAlmostEqual(cdp.structure.displacements._translation_vector[models[i]][models[j]][k], trans_vect[i][j][k]) 137 138 # Check the rotation. 139 self.assertAlmostEqual(cdp.structure.displacements._rotation_angle[models[i]][models[j]], angle[i][j]) 140 if rot_axis[i][j] != None: 141 for k in range(3): 142 self.assertAlmostEqual(cdp.structure.displacements._rotation_axis[models[i]][models[j]][k], rot_axis[i][j][k])
143 144
146 """Load the PDB file using the information in a results file (using the internal structural object).""" 147 148 # Path of the files. 149 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 150 151 # Read the results file. 152 self.interpreter.results.read(file='str_internal', dir=path) 153 154 # Test the structure metadata. 155 self.assert_(hasattr(cdp, 'structure')) 156 self.assert_(hasattr(cdp.structure, 'structural_data')) 157 self.assert_(len(cdp.structure.structural_data)) 158 self.assert_(len(cdp.structure.structural_data[0].mol)) 159 160 mol = cdp.structure.structural_data[0].mol[0] 161 self.assertEqual(mol.file_name, 'Ap4Aase_res1-12.pdb') 162 self.assertEqual(mol.file_path, '') 163 self.assertEqual(mol.file_model, 1) 164 self.assertEqual(mol.file_mol_num, 1) 165 166 # The real atomic data. 167 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'] 168 bonded = [[]]*174 169 chain_id = [None]*174 170 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'] 171 pdb_record = ['ATOM']*174 172 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'] 173 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] 174 seg_id = [None]*174 175 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] 176 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] 177 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] 178 179 # Test the atomic data. 180 mol = cdp.structure.structural_data[0].mol[0] 181 for i in xrange(len(mol.atom_name)): 182 self.assertEqual(mol.atom_name[i], atom_name[i]) 183 self.assertEqual(mol.bonded[i], bonded[i]) 184 self.assertEqual(mol.chain_id[i], chain_id[i]) 185 self.assertEqual(mol.element[i], element[i]) 186 self.assertEqual(mol.pdb_record[i], pdb_record[i]) 187 self.assertEqual(mol.res_name[i], res_name[i]) 188 self.assertEqual(mol.res_num[i], res_num[i]) 189 self.assertEqual(mol.seg_id[i], seg_id[i]) 190 self.assertEqual(mol.x[i], x[i]) 191 self.assertEqual(mol.y[i], y[i]) 192 self.assertEqual(mol.z[i], z[i])
193 194
196 """Load the PDB file using the information in a results file (using the internal structural object).""" 197 198 # Path of the files. 199 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 200 201 # Read the results file. 202 self.interpreter.results.read(file=path+sep+'str_internal')
203 204
206 """Load the PDB file using the information in a results file (using the Scientific python structural object).""" 207 208 # Path of the files. 209 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 210 211 # Read the results file. 212 self.interpreter.results.read(file='str_scientific', dir=path) 213 214 # Test the structure metadata. 215 self.assert_(hasattr(cdp, 'structure')) 216 self.assert_(hasattr(cdp.structure, 'structural_data')) 217 self.assert_(len(cdp.structure.structural_data)) 218 self.assert_(len(cdp.structure.structural_data[0].mol)) 219 220 mol = cdp.structure.structural_data[0].mol[0] 221 self.assertEqual(mol.file_name, 'Ap4Aase_res1-12.pdb') 222 self.assertEqual(mol.file_path, 'test_suite/shared_data/structures') 223 self.assertEqual(mol.file_model, 1) 224 self.assertEqual(mol.file_mol_num, 1) 225 226 # The real atomic data. 227 res_list = ['GLY', 'PRO', 'LEU', 'GLY', 'SER', 'MET', 'ASP', 'SER', 'PRO', 'PRO', 'GLU', 'GLY'] 228 229 # Loop over the residues. 230 i = 0 231 for res_name in cdp.structure.atom_loop(atom_id='@N', res_name_flag=True): 232 res_name = res_name[0] 233 234 # Check the residue data. 235 self.assertEqual(res_name, res_list[i]) 236 237 # Increment the residue counter. 238 i = i + 1
239 240
241 - def test_read_not_pdb(self):
242 """Test the reading of a file by structure.read_pdb that is not a PDB.""" 243 244 # Path of the files. 245 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'saved_states' 246 247 # Read the non-PDB file. 248 self.interpreter.structure.read_pdb(file='basic_single_pipe.bz2', dir=path, parser='internal')
249 250
251 - def test_read_pdb_internal1(self):
252 """Load the '1F35_N_H_molmol.pdb' PDB file (using the internal structural object PDB reader).""" 253 254 # Path of the files. 255 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 256 257 # Read the PDB. 258 self.interpreter.structure.read_pdb(file='1F35_N_H_molmol.pdb', dir=path, parser='internal') 259 260 # Test the molecule name. 261 self.assertEqual(cdp.structure.structural_data[0].mol[0].mol_name, '1F35_N_H_molmol_mol1') 262 263 # Load a single atom and test it. 264 self.interpreter.structure.load_spins('#1F35_N_H_molmol_mol1:3@N') 265 self.assertEqual(count_spins(), 1) 266 267 # Try loading a few protons. 268 self.interpreter.structure.load_spins('@*H*') 269 270 # And now all the rest of the atoms. 271 self.interpreter.structure.load_spins() 272 273 # Extract a N-Ca vector. 274 self.interpreter.structure.vectors('CA', spin_id='#1F35_N_H_molmol_mol1:3@N') 275 print((cdp.mol[0].res[0].spin[0])) 276 self.assert_(hasattr(cdp.mol[0].res[0].spin[0], 'bond_vect'))
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.structure.vectors('CA', spin_id='#1F35_N_H_molmol_mol1:3@N') 511 self.assert_(hasattr(cdp.mol[0].res[0].spin[0], 'bond_vect'))
512 513
515 """Load the 'Ap4Aase_res1-12.pdb' PDB file (using the Scientific python structural object PDB reader).""" 516 517 # Path of the files. 518 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 519 520 # Read the PDB. 521 self.interpreter.structure.read_pdb(file='Ap4Aase_res1-12.pdb', dir=path, parser='scientific') 522 523 # Try loading a few protons. 524 self.interpreter.structure.load_spins('@*H*') 525 526 # And now all the rest of the atoms. 527 self.interpreter.structure.load_spins()
528 529
531 """Load the 'gromacs.pdb' PDB file (using the Scientific python structural object PDB reader).""" 532 533 # Path of the files. 534 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'phthalic_acid' 535 536 # Read the PDB. 537 self.interpreter.structure.read_pdb(file='gromacs.pdb', dir=path, parser='scientific') 538 539 # Try loading a few protons. 540 self.interpreter.structure.load_spins('@*H*', ave_pos=False) 541 542 # A test. 543 self.assertEqual(len(cdp.mol[0].res[0].spin[0].pos), 2) 544 545 # And now all the rest of the atoms. 546 self.interpreter.structure.load_spins()
547 548
550 """Load the 'tylers_peptide_trunc.pdb' PDB file (using the Scientific python structural object PDB reader).""" 551 552 # Path of the files. 553 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 554 555 # Read the PDB. 556 self.interpreter.structure.read_pdb(file='tylers_peptide_trunc.pdb', dir=path, parser='scientific') 557 558 # Try loading a few protons. 559 self.interpreter.structure.load_spins('@*H*') 560 561 # And now all the rest of the atoms. 562 self.interpreter.structure.load_spins()
563 564
566 """Load the 'lactose_MCMM4_S1_1.pdb' PDB file (using the Scientific python structural object PDB reader).""" 567 568 # Path of the files. 569 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'lactose' 570 571 # Read the PDB. 572 self.interpreter.structure.read_pdb(file='lactose_MCMM4_S1_1.pdb', dir=path, parser='scientific') 573 574 # Try loading a few protons. 575 self.interpreter.structure.load_spins('@*H*') 576 577 # And now all the rest of the atoms. 578 self.interpreter.structure.load_spins()
579 580
582 """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).""" 583 584 # Path of the files. 585 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'lactose' 586 587 # Read the PDB twice. 588 self.interpreter.structure.read_pdb(file='lactose_MCMM4_S1_1.pdb', dir=path, parser='scientific') 589 self.interpreter.structure.read_pdb(file='lactose_MCMM4_S1_2.pdb', dir=path, parser='scientific') 590 591 # Try loading a few protons. 592 self.interpreter.structure.load_spins('@*H*') 593 594 # And now all the rest of the atoms. 595 self.interpreter.structure.load_spins()
596 597
599 """Load the 'lactose_MCMM4_S1_1.pdb' PDB file twice as 2 separate structures (using the Scientific python structural object PDB reader).""" 600 601 # Path of the files. 602 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'lactose' 603 604 # Read the PDB twice. 605 self.interpreter.structure.read_pdb(file='lactose_MCMM4_S1_1.pdb', dir=path, parser='scientific') 606 self.interpreter.structure.read_pdb(file='lactose_MCMM4_S1_1.pdb', dir=path, parser='scientific') 607 608 # Try loading a few protons. 609 self.interpreter.structure.load_spins('@*H*') 610 611 # And now all the rest of the atoms. 612 self.interpreter.structure.load_spins()
613 614
616 """Load a few 'lactose_MCMM4_S1_*.pdb' PDB files as models (using the Scientific python structural object PDB reader).""" 617 618 # Path of the files. 619 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'lactose' 620 621 # Files. 622 files = ['lactose_MCMM4_S1_1.pdb', 623 'lactose_MCMM4_S1_2.pdb', 624 'lactose_MCMM4_S1_3.pdb'] 625 626 # Read the PDBs. 627 self.interpreter.structure.read_pdb(file=files[0], dir=path, parser='scientific', set_model_num=1) 628 self.interpreter.structure.read_pdb(file=files[1], dir=path, parser='scientific', set_model_num=1) 629 self.interpreter.structure.read_pdb(file=files[2], dir=path, parser='scientific', set_model_num=1) 630 631 # Try loading a few protons. 632 self.interpreter.structure.load_spins('@*H*') 633 634 # And now all the rest of the atoms. 635 self.interpreter.structure.load_spins() 636 637 # Test the structural data. 638 self.assert_(hasattr(cdp, 'structure')) 639 self.assert_(hasattr(cdp.structure, 'structural_data')) 640 self.assertEqual(len(cdp.structure.structural_data), 1) 641 self.assertEqual(len(cdp.structure.structural_data[0].mol), 6) 642 643 i = 0 644 for mol in cdp.structure.structural_data[0].mol: 645 self.assertEqual(mol.file_name, files[i/2]) 646 self.assertEqual(mol.file_path, path) 647 self.assertEqual(mol.file_model, 1) 648 self.assertEqual(mol.file_mol_num, i%2+1) # Odd i, num=1, even i, num=2. 649 i = i + 1
650 651
653 """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).""" 654 655 # Path of the files. 656 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'phthalic_acid' 657 658 # Read the PDB models. 659 self.interpreter.structure.read_pdb(file='gromacs.pdb', dir=path, parser='scientific', read_model=1, set_model_num=1) 660 self.interpreter.structure.read_pdb(file='gromacs.pdb', dir=path, parser='scientific', read_model=2, set_model_num=1) 661 662 # Try loading a few protons. 663 self.interpreter.structure.load_spins('@*H*') 664 665 # And now all the rest of the atoms. 666 self.interpreter.structure.load_spins() 667 668 # Test the structural data. 669 self.assert_(hasattr(cdp, 'structure')) 670 self.assert_(hasattr(cdp.structure, 'structural_data')) 671 self.assertEqual(len(cdp.structure.structural_data), 1) 672 self.assertEqual(len(cdp.structure.structural_data[0].mol), 2) 673 674 i = 0 675 for mol in cdp.structure.structural_data[0].mol: 676 self.assertEqual(mol.file_name, 'gromacs.pdb') 677 self.assertEqual(mol.file_path, path) 678 self.assertEqual(mol.file_model, i+1) 679 self.assertEqual(mol.file_mol_num, 1) 680 i = i + 1
681 682
684 """Test the packing of models and molecules using 'gromacs.pdb' and 'lactose_MCMM4_S1_*.pdb' (using the Scientific python structural object PDB reader).""" 685 686 # Path of the files. 687 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 688 689 # Read the PDB models. 690 self.interpreter.structure.read_pdb(file='gromacs.pdb', dir=path+sep+'phthalic_acid', parser='scientific') 691 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') 692 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') 693 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') 694 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') 695 696 # Try loading a few protons. 697 self.interpreter.structure.load_spins('@*H*') 698 699 # And now all the rest of the atoms. 700 self.interpreter.structure.load_spins() 701 702 # Test the structural data. 703 self.assert_(hasattr(cdp, 'structure')) 704 self.assert_(hasattr(cdp.structure, 'structural_data')) 705 self.assertEqual(len(cdp.structure.structural_data), 2) 706 self.assertEqual(len(cdp.structure.structural_data[0].mol), 3) 707 self.assertEqual(len(cdp.structure.structural_data[1].mol), 3) 708 709 files = [['gromacs.pdb', 'lactose_MCMM4_S1_1.pdb', 'lactose_MCMM4_S1_3.pdb'], 710 ['gromacs.pdb', 'lactose_MCMM4_S1_2.pdb', 'lactose_MCMM4_S1_4.pdb']] 711 paths = [[path+sep+'phthalic_acid', path+sep+'lactose', path+sep+'lactose'], 712 [path+sep+'phthalic_acid', path+sep+'lactose', path+sep+'lactose']] 713 models = [[1, 1, 1], [2, 1, 1]] 714 715 for i in range(len(cdp.structure.structural_data)): 716 for j in range(len(cdp.structure.structural_data[i].mol)): 717 mol = cdp.structure.structural_data[i].mol[j] 718 self.assertEqual(mol.file_name, files[i][j]) 719 self.assertEqual(mol.file_path, paths[i][j]) 720 self.assertEqual(mol.file_model, models[i][j]) 721 self.assertEqual(mol.file_mol_num, 1)
722 723
724 - def test_read_xyz_internal1(self):
725 """Load the 'Indol_test.xyz' XYZ file (using the internal structural object XYZ reader).""" 726 727 # Path of the files. 728 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 729 730 # Read the XYZ file. 731 self.interpreter.structure.read_xyz(file='Indol_test.xyz', dir=path) 732 733 # Test the molecule name. 734 self.assertEqual(cdp.structure.structural_data[0].mol[0].mol_name, 'Indol_test_mol1') 735 736 # Load a single atom and test it. 737 self.interpreter.structure.load_spins('#Indol_test_mol1@3') 738 self.assertEqual(count_spins(), 1) 739 740 # Try loading a few protons. 741 self.interpreter.structure.load_spins('@*H*') 742 743 # And now all the rest of the atoms. 744 self.interpreter.structure.load_spins()
745 746
747 - def test_read_xyz_internal2(self):
748 """Load the 'SSS-cluster4-new-test.xyz' XYZ file (using the internal structural object XYZ reader).""" 749 750 # Path of the files. 751 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 752 753 # Read the XYZ file. 754 self.interpreter.structure.read_xyz(file='SSS-cluster4-new-test.xyz', dir=path, read_model=[1]) 755 756 # Test the molecule name. 757 self.assertEqual(cdp.structure.structural_data[0].mol[0].mol_name, 'SSS-cluster4-new-test_mol1') 758 759 # Load a single atom and test it. 760 self.interpreter.structure.load_spins('#SSS-cluster4-new-test_mol1@2') 761 self.assertEqual(count_spins(), 1) 762 763 # Test the spin coordinates. 764 a=return_spin('#SSS-cluster4-new-test_mol1@2') 765 self.assertAlmostEqual(a.pos[0], -12.398) 766 self.assertAlmostEqual(a.pos[1], -15.992) 767 self.assertAlmostEqual(a.pos[2], 11.448) 768 769 # Try loading a few protons. 770 #self.interpreter.structure.load_spins('@H') 771 772 # And now all the rest of the atoms. 773 self.interpreter.structure.load_spins() 774 775 # Extract a vector between first two spins. 776 self.interpreter.structure.vectors(attached='@10', spin_id='@2') 777 self.assertAlmostEqual(a.bond_vect[0], -0.4102707) 778 self.assertAlmostEqual(a.bond_vect[1], 0.62128879) 779 self.assertAlmostEqual(a.bond_vect[2], -0.6675913)
780 781
783 """Test of the structure.superimpose user function, fitting to the first structure.""" 784 785 # Path of the structure file. 786 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'frame_order' 787 788 # Load the two rotated structures. 789 self.interpreter.structure.read_pdb('1J7P_1st_NH.pdb', dir=path, set_model_num=1, set_mol_name='CaM') 790 self.interpreter.structure.read_pdb('1J7P_1st_NH_rot.pdb', dir=path, set_model_num=2, set_mol_name='CaM') 791 self.interpreter.structure.read_pdb('1J7P_1st_NH.pdb', dir=path, set_model_num=3, set_mol_name='CaM') 792 793 # Superimpose the backbone heavy atoms. 794 self.interpreter.structure.superimpose(method='fit to first', atom_id='@N,C,CA,O') 795 796 # Check that the two structures now have the same atomic coordinates. 797 model1 = cdp.structure.structural_data[0].mol[0] 798 model2 = cdp.structure.structural_data[1].mol[0] 799 model3 = cdp.structure.structural_data[2].mol[0] 800 for i in range(len(model1.atom_name)): 801 # Check model 2. 802 self.assertAlmostEqual(model1.x[i], model2.x[i], 2) 803 self.assertAlmostEqual(model1.y[i], model2.y[i], 2) 804 self.assertAlmostEqual(model1.z[i], model2.z[i], 2) 805 806 # Check model 3. 807 self.assertAlmostEqual(model1.x[i], model3.x[i], 2) 808 self.assertAlmostEqual(model1.y[i], model3.y[i], 2) 809 self.assertAlmostEqual(model1.z[i], model3.z[i], 2)
810 811
813 """Test of the structure.superimpose user function, fitting to the mean structure.""" 814 815 # Path of the structure file. 816 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'frame_order' 817 818 # Load the two rotated structures. 819 self.interpreter.structure.read_pdb('1J7P_1st_NH.pdb', dir=path, set_model_num=1, set_mol_name='CaM') 820 self.interpreter.structure.read_pdb('1J7P_1st_NH_rot.pdb', dir=path, set_model_num=2, set_mol_name='CaM') 821 822 # Superimpose the backbone heavy atoms. 823 self.interpreter.structure.superimpose(method='fit to mean', atom_id='@N,C,CA,O') 824 825 # Check that the two structures now have the same atomic coordinates. 826 model1 = cdp.structure.structural_data[0].mol[0] 827 model2 = cdp.structure.structural_data[1].mol[0] 828 for i in range(len(model1.atom_name)): 829 self.assertAlmostEqual(model1.x[i], model2.x[i], 2) 830 self.assertAlmostEqual(model1.y[i], model2.y[i], 2) 831 self.assertAlmostEqual(model1.z[i], model2.z[i], 2)
832 833
835 """Second test of the structure.superimpose user function, fitting to the mean structure.""" 836 837 # Path of the structure file. 838 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'frame_order' 839 840 # Load the two rotated structures. 841 self.interpreter.structure.read_pdb('1J7P_1st_NH.pdb', dir=path, set_model_num=1, set_mol_name='CaM') 842 self.interpreter.structure.read_pdb('1J7P_1st_NH.pdb', dir=path, set_model_num=2, set_mol_name='CaM') 843 self.interpreter.structure.read_pdb('1J7P_1st_NH.pdb', dir=path, set_model_num=3, set_mol_name='CaM') 844 845 # Transpose model 3. 846 self.interpreter.structure.translate([20.0, 0.0, 0.0], model=3) 847 848 # Superimpose the backbone heavy atoms. 849 self.interpreter.structure.superimpose(models=[2, 3], method='fit to mean', atom_id='@N,C,CA,O') 850 851 # Check that the two structures now have the same atomic coordinates as the original, but shifted 10 Angstrom in x. 852 model1 = cdp.structure.structural_data[0].mol[0] 853 model2 = cdp.structure.structural_data[1].mol[0] 854 model3 = cdp.structure.structural_data[2].mol[0] 855 for i in range(len(model1.atom_name)): 856 # Check model 2. 857 self.assertAlmostEqual(model1.x[i] + 10, model2.x[i], 2) 858 self.assertAlmostEqual(model1.y[i], model2.y[i], 2) 859 self.assertAlmostEqual(model1.z[i], model2.z[i], 2) 860 861 # Check model 3. 862 self.assertAlmostEqual(model2.x[i], model3.x[i], 2) 863 self.assertAlmostEqual(model2.y[i], model3.y[i], 2) 864 self.assertAlmostEqual(model2.z[i], model3.z[i], 2)
865