1   
  2   
  3   
  4   
  5   
  6   
  7   
  8   
  9   
 10   
 11   
 12   
 13   
 14   
 15   
 16   
 17   
 18   
 19   
 20   
 21   
 22   
 23   
 24  from numpy import float64, zeros 
 25  from os import sep 
 26  from tempfile import mktemp 
 27   
 28   
 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   
 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           
 47          super(Structure, self).__init__(methodName) 
  48   
 49   
 51          """Set up for all the functional tests.""" 
 52   
 53           
 54          self.interpreter.pipe.create('mf', 'mf') 
  55   
 56   
 58          """Test of the structure.displacement user function.""" 
 59   
 60           
 61          path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 
 62   
 63           
 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           
 68          R = zeros((3, 3), float64) 
 69          euler_to_R_zyz(1.3, 0.4, 4.5, R) 
 70   
 71           
 72          self.interpreter.structure.rotate(R, model=2) 
 73   
 74           
 75          self.interpreter.structure.displacement() 
 76   
 77           
 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           
 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           
105          self.assert_(hasattr(cdp.structure, 'displacements')) 
106          for i in range(len(models)): 
107              for j in range(len(models)): 
108                   
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                   
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           
120          self.tmpfile = mktemp() 
121          self.interpreter.state.save(self.tmpfile, dir=None, force=True) 
122   
123           
124          self.interpreter.reset() 
125   
126           
127          self.interpreter.state.load(self.tmpfile) 
128   
129           
130          self.assert_(hasattr(cdp.structure, 'displacements')) 
131          for i in range(len(models)): 
132              for j in range(len(models)): 
133                   
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                   
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           
149          path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 
150   
151           
152          self.interpreter.results.read(file='str_internal', dir=path) 
153   
154           
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           
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           
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           
199          path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 
200   
201           
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           
209          path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 
210   
211           
212          self.interpreter.results.read(file='str_scientific', dir=path) 
213   
214           
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           
227          res_list = ['GLY', 'PRO', 'LEU', 'GLY', 'SER', 'MET', 'ASP', 'SER', 'PRO', 'PRO', 'GLU', 'GLY'] 
228   
229           
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               
235              self.assertEqual(res_name, res_list[i]) 
236   
237               
238              i = i + 1 
 239   
240   
242          """Test the reading of a file by structure.read_pdb that is not a PDB.""" 
243   
244           
245          path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'saved_states' 
246   
247           
248          self.interpreter.structure.read_pdb(file='basic_single_pipe.bz2', dir=path, parser='internal') 
 249   
250   
277   
278   
279   
294   
295   
313   
314   
329   
330   
345   
346   
362   
363   
379   
380   
382          """Load a few 'lactose_MCMM4_S1_*.pdb' PDB files as models (using the internal structural object PDB reader).""" 
383   
384           
385          path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'lactose' 
386   
387           
388          files = ['lactose_MCMM4_S1_1.pdb', 
389                   'lactose_MCMM4_S1_2.pdb', 
390                   'lactose_MCMM4_S1_3.pdb'] 
391   
392           
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           
398          self.interpreter.structure.load_spins('@*H*') 
399   
400           
401          self.interpreter.structure.load_spins() 
402   
403           
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           
422          path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'phthalic_acid' 
423   
424           
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           
429          self.interpreter.structure.load_spins('@*H*') 
430   
431           
432          self.interpreter.structure.load_spins() 
433   
434           
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           
453          path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 
454   
455           
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           
463          self.interpreter.structure.load_spins('@*H*') 
464   
465           
466          self.interpreter.structure.load_spins() 
467   
468           
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   
512   
513   
528   
529   
547   
548   
563   
564   
579   
580   
596   
597   
613   
614   
616          """Load a few 'lactose_MCMM4_S1_*.pdb' PDB files as models (using the Scientific python structural object PDB reader).""" 
617   
618           
619          path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'lactose' 
620   
621           
622          files = ['lactose_MCMM4_S1_1.pdb', 
623                   'lactose_MCMM4_S1_2.pdb', 
624                   'lactose_MCMM4_S1_3.pdb'] 
625   
626           
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           
632          self.interpreter.structure.load_spins('@*H*') 
633   
634           
635          self.interpreter.structure.load_spins() 
636   
637           
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)   
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           
656          path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'phthalic_acid' 
657   
658           
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           
663          self.interpreter.structure.load_spins('@*H*') 
664   
665           
666          self.interpreter.structure.load_spins() 
667   
668           
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           
687          path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 
688   
689           
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           
697          self.interpreter.structure.load_spins('@*H*') 
698   
699           
700          self.interpreter.structure.load_spins() 
701   
702           
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   
745   
746   
748          """Load the 'SSS-cluster4-new-test.xyz' XYZ file (using the internal structural object XYZ reader).""" 
749   
750           
751          path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 
752   
753           
754          self.interpreter.structure.read_xyz(file='SSS-cluster4-new-test.xyz', dir=path, read_model=[1]) 
755   
756           
757          self.assertEqual(cdp.structure.structural_data[0].mol[0].mol_name, 'SSS-cluster4-new-test_mol1') 
758   
759           
760          self.interpreter.structure.load_spins('#SSS-cluster4-new-test_mol1@2') 
761          self.assertEqual(count_spins(), 1) 
762   
763           
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           
770           
771   
772           
773          self.interpreter.structure.load_spins() 
774   
775           
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           
786          path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'frame_order' 
787   
788           
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           
794          self.interpreter.structure.superimpose(method='fit to first', atom_id='@N,C,CA,O') 
795   
796           
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               
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               
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           
816          path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'frame_order' 
817   
818           
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           
823          self.interpreter.structure.superimpose(method='fit to mean', atom_id='@N,C,CA,O') 
824   
825           
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           
838          path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'frame_order' 
839   
840           
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           
846          self.interpreter.structure.translate([20.0, 0.0, 0.0], model=3) 
847   
848           
849          self.interpreter.structure.superimpose(models=[2, 3], method='fit to mean', atom_id='@N,C,CA,O') 
850   
851           
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               
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               
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