1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 from numpy import float64, zeros
24 from os import sep
25 from tempfile import mktemp
26
27
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
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
46 super(Structure, self).__init__(methodName)
47
48
50 """Set up for all the functional tests."""
51
52
53 self.interpreter.pipe.create('mf', 'mf')
54
55
57 """Test of the structure.displacement user function."""
58
59
60 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'
61
62
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
67 R = zeros((3, 3), float64)
68 euler_to_R_zyz(1.3, 0.4, 4.5, R)
69
70
71 self.interpreter.structure.rotate(R, model=2)
72
73
74 self.interpreter.structure.displacement()
75
76
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
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
104 self.assert_(hasattr(cdp.structure, 'displacements'))
105 for i in range(len(models)):
106 for j in range(len(models)):
107
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
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
119 self.tmpfile = mktemp()
120 self.interpreter.state.save(self.tmpfile, dir=None, force=True)
121
122
123 self.interpreter.reset()
124
125
126 self.interpreter.state.load(self.tmpfile)
127
128
129 self.assert_(hasattr(cdp.structure, 'displacements'))
130 for i in range(len(models)):
131 for j in range(len(models)):
132
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
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
148 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'
149
150
151 self.interpreter.results.read(file='str_internal', dir=path)
152
153
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
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
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
198 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'
199
200
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
208 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'
209
210
211 self.interpreter.results.read(file='str_scientific', dir=path)
212
213
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
226 res_list = ['GLY', 'PRO', 'LEU', 'GLY', 'SER', 'MET', 'ASP', 'SER', 'PRO', 'PRO', 'GLU', 'GLY']
227
228
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
234 self.assertEqual(res_name, res_list[i])
235
236
237 i = i + 1
238
239
241 """Test the reading of a file by structure.read_pdb that is not a PDB."""
242
243
244 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'saved_states'
245
246
247 self.interpreter.structure.read_pdb(file='basic_single_pipe.bz2', dir=path, parser='internal')
248
249
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
514
515
530
531
549
550
565
566
581
582
598
599
615
616
618 """Load a few 'lactose_MCMM4_S1_*.pdb' PDB files as models (using the Scientific python structural object PDB reader)."""
619
620
621 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'lactose'
622
623
624 files = ['lactose_MCMM4_S1_1.pdb',
625 'lactose_MCMM4_S1_2.pdb',
626 'lactose_MCMM4_S1_3.pdb']
627
628
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
634 self.interpreter.structure.load_spins('@*H*')
635
636
637 self.interpreter.structure.load_spins()
638
639
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)
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
658 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'phthalic_acid'
659
660
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
665 self.interpreter.structure.load_spins('@*H*')
666
667
668 self.interpreter.structure.load_spins()
669
670
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
689 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'
690
691
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
699 self.interpreter.structure.load_spins('@*H*')
700
701
702 self.interpreter.structure.load_spins()
703
704
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
747
748
750 """Load the 'SSS-cluster4-new-test.xyz' XYZ file (using the internal structural object XYZ reader)."""
751
752
753 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'
754
755
756 self.interpreter.structure.read_xyz(file='SSS-cluster4-new-test.xyz', dir=path, read_model=[1])
757
758
759 self.assertEqual(cdp.structure.structural_data[0].mol[0].mol_name, 'SSS-cluster4-new-test_mol1')
760
761
762 self.interpreter.structure.load_spins('#SSS-cluster4-new-test_mol1@2')
763 self.assertEqual(count_spins(), 1)
764
765
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
772
773
774
775 self.interpreter.structure.load_spins()
776
777
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
789 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'frame_order'
790
791
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
797 self.interpreter.structure.superimpose(method='fit to first', atom_id='@N,C,CA,O')
798
799
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
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
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
819 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'frame_order'
820
821
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
826 self.interpreter.structure.superimpose(method='fit to mean', atom_id='@N,C,CA,O')
827
828
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
841 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'frame_order'
842
843
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
849 self.interpreter.structure.translate([20.0, 0.0, 0.0], model=3)
850
851
852 self.interpreter.structure.superimpose(models=[2, 3], method='fit to mean', atom_id='@N,C,CA,O')
853
854
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
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
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