pdb-tools 2.4.12__py3-none-any.whl → 2.5.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. {pdb_tools-2.4.12.dist-info → pdb_tools-2.5.1.dist-info}/METADATA +19 -11
  2. pdb_tools-2.5.1.dist-info/RECORD +55 -0
  3. {pdb_tools-2.4.12.dist-info → pdb_tools-2.5.1.dist-info}/WHEEL +1 -1
  4. {pdb_tools-2.4.12.dist-info → pdb_tools-2.5.1.dist-info}/entry_points.txt +1 -1
  5. {pdb_tools-2.4.12.dist-info → pdb_tools-2.5.1.dist-info}/top_level.txt +0 -1
  6. pdbtools/pdb_selmodel.py +194 -0
  7. pdbtools/pdb_tidy.py +17 -9
  8. pdb_tools-2.4.12.dist-info/RECORD +0 -103
  9. tests/__init__.py +0 -38
  10. tests/config.py +0 -25
  11. tests/test_pdb_b.py +0 -161
  12. tests/test_pdb_chain.py +0 -160
  13. tests/test_pdb_chainbows.py +0 -140
  14. tests/test_pdb_chainxseg.py +0 -156
  15. tests/test_pdb_chkensemble.py +0 -191
  16. tests/test_pdb_delchain.py +0 -165
  17. tests/test_pdb_delelem.py +0 -165
  18. tests/test_pdb_delhetatm.py +0 -115
  19. tests/test_pdb_delinsertion.py +0 -226
  20. tests/test_pdb_delres.py +0 -241
  21. tests/test_pdb_delresname.py +0 -171
  22. tests/test_pdb_element.py +0 -151
  23. tests/test_pdb_fixinsert.py +0 -223
  24. tests/test_pdb_fromcif.py +0 -124
  25. tests/test_pdb_gap.py +0 -125
  26. tests/test_pdb_head.py +0 -142
  27. tests/test_pdb_intersect.py +0 -139
  28. tests/test_pdb_keepcoord.py +0 -115
  29. tests/test_pdb_merge.py +0 -106
  30. tests/test_pdb_mkensemble.py +0 -132
  31. tests/test_pdb_occ.py +0 -161
  32. tests/test_pdb_reatom.py +0 -243
  33. tests/test_pdb_reres.py +0 -281
  34. tests/test_pdb_rplchain.py +0 -172
  35. tests/test_pdb_rplresname.py +0 -172
  36. tests/test_pdb_seg.py +0 -160
  37. tests/test_pdb_segxchain.py +0 -146
  38. tests/test_pdb_selaltloc.py +0 -943
  39. tests/test_pdb_selatom.py +0 -165
  40. tests/test_pdb_selchain.py +0 -210
  41. tests/test_pdb_selelem.py +0 -165
  42. tests/test_pdb_selhetatm.py +0 -116
  43. tests/test_pdb_selres.py +0 -257
  44. tests/test_pdb_selresname.py +0 -171
  45. tests/test_pdb_selseg.py +0 -165
  46. tests/test_pdb_shiftres.py +0 -241
  47. tests/test_pdb_sort.py +0 -254
  48. tests/test_pdb_splitchain.py +0 -242
  49. tests/test_pdb_splitmodel.py +0 -235
  50. tests/test_pdb_splitseg.py +0 -251
  51. tests/test_pdb_tidy.py +0 -312
  52. tests/test_pdb_tocif.py +0 -238
  53. tests/test_pdb_tofasta.py +0 -158
  54. tests/test_pdb_uniqname.py +0 -156
  55. tests/test_pdb_validate.py +0 -142
  56. tests/test_pdb_wc.py +0 -161
  57. tests/utils.py +0 -56
  58. {pdb_tools-2.4.12.dist-info → pdb_tools-2.5.1.dist-info/licenses}/LICENSE +0 -0
@@ -1,943 +0,0 @@
1
- #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
- #
4
- # Copyright 2018 João Pedro Rodrigues
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
-
18
- """
19
- Unit Tests for `pdb_selaltloc`.
20
- """
21
- import os
22
- import sys
23
- import unittest
24
-
25
- from config import data_dir
26
- from utils import OutputCapture
27
-
28
-
29
- class TestTool(unittest.TestCase):
30
- """
31
- Generic class for testing tools.
32
- """
33
-
34
- def setUp(self):
35
- # Dynamically import the module
36
- name = 'pdbtools.pdb_selaltloc'
37
- self.module = __import__(name, fromlist=[''])
38
-
39
- def exec_module(self):
40
- """
41
- Execs module.
42
- """
43
-
44
- with OutputCapture() as output:
45
- try:
46
- self.module.main()
47
- except SystemExit as e:
48
- self.retcode = e.code
49
-
50
- self.stdout = output.stdout
51
- self.stderr = output.stderr
52
-
53
- return
54
-
55
- def test_is_same_group_1(self):
56
- """
57
- Test function to identify we entered another altloc group.
58
-
59
- This indicates we are in the SAME altloc group.
60
-
61
- previous line: "" # first line of the PDB file
62
- current line: " ALA 1"
63
-
64
- The result of `is_another_altloc_group` should be False.
65
- """
66
- result = self.module.is_another_altloc_group(
67
- ' ', '', '1', '', 'ALA', '', {}, {})
68
-
69
- self.assertFalse(result)
70
-
71
- def test_is_same_group_2(self):
72
- """
73
- Test function to identify we entered another altloc group.
74
-
75
- This indicates we are in the SAME altloc group.
76
-
77
- All `None` case.
78
-
79
- The result of `is_another_altloc_group` should be False.
80
- """
81
- result = self.module.is_another_altloc_group(
82
- ' ', None, None, None, None, None, {}, {})
83
-
84
- self.assertFalse(result)
85
-
86
- def test_is_same_group_3(self):
87
- """
88
- Test function to identify we entered another altloc group.
89
-
90
- This indicates we are in the SAME altloc group.
91
-
92
- Example: all parameters are the same as the previous line.
93
-
94
- previous line: "BALA 12"
95
- current line: "BALA 12"
96
-
97
- The result of `is_another_altloc_group` should be False.
98
- """
99
- result = self.module.is_another_altloc_group(
100
- 'B', 'B', '12', '12', 'ALA', 'ALA', {'B': None},
101
- {'B': {('ALA', '12')}}
102
- )
103
- self.assertFalse(result)
104
-
105
-
106
- def test_is_same_group_4(self):
107
- """
108
- Test function to identify we entered another altloc group.
109
-
110
- This indicates we are in the SAME altloc group.
111
-
112
- Example: Multiple residue altloc. This considers altloc spanning
113
- several residues. See example dummy_altloc2.pdb.
114
-
115
- previous line: "AGLU 25"
116
- current line: "ALEU 26"
117
-
118
- It is important to note also the dictionary input.
119
-
120
- The result of `is_another_altloc_group` should be False.
121
- """
122
- result = self.module.is_another_altloc_group(
123
- 'A', 'A', '26', '25', 'LEU', 'GLU', {'A': ['lines']},
124
- {'A': {('GLU', '25')}}
125
- )
126
- self.assertFalse(result)
127
-
128
- def test_is_same_group_5(self):
129
- """
130
- Test function to identify we entered another altloc group.
131
-
132
- This indicates we are in the SAME altloc group.
133
-
134
- Example: Multiple residue altloc. This considers altloc spanning
135
- several residues. See example dummy_altloc2.pdb.
136
-
137
- previous line: " GLU 25"
138
- current line: "AALA 25"
139
-
140
- It is important to note also the dictionary input.
141
-
142
- The result of `is_another_altloc_group` should be False.
143
- """
144
- result = self.module.is_another_altloc_group(
145
- 'A', ' ', '25', '25', 'ALA', 'GLU', {' ': ['lines']},
146
- {' ': {('GLU', '25')}}
147
- )
148
- self.assertFalse(result)
149
-
150
- def test_is_another_group_1(self):
151
- """
152
- Test function to identify we entered another altloc group.
153
-
154
- This indicates we entered another altloc group.
155
-
156
- previous line: "BPRO 1"
157
- current line: " ALA 2"
158
-
159
- The result of `is_another_altloc_group` should be True.
160
- """
161
- result = self.module.is_another_altloc_group(
162
- ' ', 'B', '2', '1', 'ALA', 'PRO', {'B': ['lines']},
163
- {'B': {('PRO', '1')}}
164
- )
165
- self.assertTrue(result)
166
-
167
- def test_is_another_group_2(self):
168
- """
169
- Test function to identify we entered another altloc group.
170
-
171
- This indicates we entered another altloc group.
172
-
173
- previous line: " ALA 1"
174
- current line: " ALA 2"
175
-
176
- The result of `is_another_altloc_group` should be True.
177
- """
178
- result = self.module.is_another_altloc_group(
179
- ' ', ' ', '2', '1', 'ALA', 'ALA', {' ': ['lines']},
180
- {' ': {('ALA', '1')}}
181
- )
182
- self.assertTrue(result)
183
-
184
- def test_is_another_group_3(self):
185
- """
186
- Test function to identify we entered another altloc group.
187
-
188
- This indicates we entered another altloc group.
189
-
190
- previous line: " GLU 1"
191
- current line: " ALA 1"
192
-
193
- The result of `is_another_altloc_group` should be True.
194
- """
195
- result = self.module.is_another_altloc_group(
196
- ' ', ' ', '1', '1', 'ALA', 'GLU', {' ': ['lines']},
197
- {' ': {('GLU', '1')}}
198
- )
199
- self.assertTrue(result)
200
-
201
- def test_is_another_group_4(self):
202
- """
203
- Test function to identify we entered another altloc group.
204
-
205
- This indicates we entered another altloc group.
206
-
207
- previous line: "AGLU 25"
208
- current line: "ALEU 26"
209
-
210
- The result of `is_another_altloc_group` should be True.
211
- """
212
- result = self.module.is_another_altloc_group(
213
- 'A', 'A', '26', '25', 'LEU', 'GLU', {' ': ['lines'], 'A': ['lines']},
214
- {' ': {('LEU', '25')}, 'A': {('GLU', '26')}}
215
- )
216
- self.assertTrue(result)
217
-
218
- def test_all_same_residue(self):
219
- """Test all same residue."""
220
- inp = {
221
- ' ': [
222
- "ATOM 3 N ASN A 1 22.066 40.557 0.420 1.00 0.00 N ",
223
- "ATOM 3 H ASN A 1 21.629 41.305 -0.098 1.00 0.00 H ",
224
- "ATOM 3 H2 ASN A 1 23.236 40.798 0.369 1.00 0.00 H ",
225
- "ATOM 3 H3 ASN A 1 21.866 40.736 1.590 1.00 0.00 H ",
226
- ],
227
- 'B': ["ATOM 3 CA BASN A 1 20.000 30.000 0.005 0.60 0.00 C "],
228
- 'A': ["ATOM 3 CA AASN A 1 21.411 39.311 0.054 0.40 0.00 C "],
229
- }
230
-
231
- result = self.module.all_same_residue(inp)
232
- self.assertTrue(result)
233
-
234
- def test_all_same_residue_false(self):
235
- """Test all same residue."""
236
- inp = {
237
- 'B': ["ATOM 3 CA BSER A 2 20.000 30.000 0.005 0.60 0.00 C "], 'A': ["ATOM 3 CA AASN A 1 21.411 39.311 0.054 0.40 0.00 C "], }
238
- result = self.module.all_same_residue(inp)
239
- self.assertFalse(result)
240
-
241
- def test_partial_altloc(self):
242
- inp = {
243
- 'A': [
244
- "ATOM 333 CA AGLU A 26 -10.000 -3.000 -12.000 0.50 4.89 C ",
245
- "ANISOU 333 CA AGLU A 26 576 620 663 31 42 45 C ",
246
- ],
247
- 'B':[
248
- "ATOM 333 CA CGLU A 26 -10.679 -3.437 -12.387 1.00 4.89 C ",
249
- "ANISOU 333 CA CGLU A 26 576 620 663 31 42 45 C ",
250
- ],
251
- }
252
-
253
- result = self.module.partial_altloc(inp)
254
- self.assertFalse(result)
255
-
256
-
257
- def test_default(self):
258
- """$ pdb_selaltloc data/dummy_altloc.pdb"""
259
-
260
- # Simulate input
261
- # pdb_selaltloc dummy.pdb
262
- sys.argv = ['', os.path.join(data_dir, 'dummy_altloc.pdb')]
263
-
264
- # Execute the script
265
- self.exec_module()
266
-
267
- # Validate results
268
- self.assertEqual(self.retcode, 0) # ensure the program exited OK.
269
- self.assertEqual(len(self.stdout), 36)
270
- self.assertEqual(len(self.stderr), 0) # no errors
271
-
272
- # Make sure sequence is correct
273
- expected = [
274
- aa for aa in ['SER', 'GLU', 'ALA', 'LEU'] for _ in range(8)
275
- ] + ["GLU"] * 2
276
- observed = [
277
- ln[17:20] for ln in self.stdout if ln.startswith(("ATOM", "ANISOU"))
278
- ]
279
-
280
- self.assertEqual(observed, expected)
281
-
282
- # Make sure we picked the right GLU atom
283
- atom_CA_GLU_26 = [
284
- l[30:54] for l in self.stdout
285
- if l[12:16] == " CA " and l[17:20] == "GLU" and l[22:26] == " 26"
286
- ]
287
- self.assertEqual(len(atom_CA_GLU_26), 2)
288
- self.assertEqual(atom_CA_GLU_26[0], " -10.679 -3.437 -12.387")
289
-
290
- def test_default2(self):
291
- """$ pdb_selaltloc data/dummy_altloc2.pdb"""
292
-
293
- # Simulate input
294
- # pdb_selaltloc dummy.pdb
295
- sys.argv = ['', os.path.join(data_dir, 'dummy_altloc2.pdb')]
296
-
297
- # Execute the script
298
- self.exec_module()
299
-
300
- # Validate results
301
- self.assertEqual(self.retcode, 0) # ensure the program exited OK.
302
- self.assertEqual(len(self.stdout), 37)
303
- self.assertEqual(len(self.stderr), 0) # no errors
304
-
305
- # Make sure sequence is correct
306
- expected = [
307
- aa for aa in ['SER', 'GLU', 'ALA', 'LEU'] for _ in range(8)
308
- ] + ["GLU"] * 2
309
- observed = [
310
- ln[17:20] for ln in self.stdout if ln.startswith(("ATOM", "ANISOU"))
311
- ]
312
-
313
- self.assertEqual(observed, expected)
314
-
315
- # Make sure we picked the right GLU atom
316
- atom_CA_GLU_26 = [
317
- l[30:54] for l in self.stdout
318
- if l[12:16] == " CA " and l[17:20] == "GLU" and l[22:26] == " 26"
319
- ]
320
- self.assertEqual(len(atom_CA_GLU_26), 2)
321
- self.assertEqual(atom_CA_GLU_26[0], " -10.679 -3.437 -12.387")
322
-
323
- def test_select_loc_A(self):
324
- """$ pdb_selaltloc -A data/dummy_altloc.pdb"""
325
-
326
- # Simulate input
327
- sys.argv = ['', '-A', os.path.join(data_dir, 'dummy_altloc.pdb')]
328
-
329
- # Execute the script
330
- self.exec_module()
331
-
332
- # Validate results
333
- self.assertEqual(self.retcode, 0) # ensure the program exited OK.
334
- self.assertEqual(len(self.stdout), 36)
335
- self.assertEqual(len(self.stderr), 0) # no errors
336
-
337
- # Make sure sequence is correct
338
- expected = [
339
- aa for aa in ['SER', 'GLU', 'ALA', 'LEU'] for _ in range(8)
340
- ] + ["GLU"] * 2
341
- observed = [
342
- ln[17:20] for ln in self.stdout if ln.startswith(("ATOM", "ANISOU"))
343
- ]
344
-
345
- self.assertEqual(observed, expected)
346
-
347
- # Make sure we picked the right GLU atom
348
- atom_CA_GLU_26 = [
349
- l[30:54] for l in self.stdout
350
- if l[12:16] == " CA " and l[17:20] == "GLU" and l[22:26] == " 26"
351
- ]
352
- self.assertEqual(len(atom_CA_GLU_26), 2)
353
- self.assertEqual(atom_CA_GLU_26[0], " -10.000 -3.000 -12.000")
354
-
355
- def test_select_loc_A_2(self):
356
- """$ pdb_selaltloc -A data/dummy_altloc2.pdb"""
357
-
358
- # Simulate input
359
- sys.argv = ['', '-A', os.path.join(data_dir, 'dummy_altloc2.pdb')]
360
-
361
- # Execute the script
362
- self.exec_module()
363
-
364
- # Validate results
365
- self.assertEqual(self.retcode, 0) # ensure the program exited OK.
366
- self.assertEqual(len(self.stdout), 37)
367
- self.assertEqual(len(self.stderr), 0) # no errors
368
-
369
- # Make sure sequence is correct
370
- expected = [
371
- aa for aa in ['SER', 'GLU', 'ALA', 'LEU'] for _ in range(8)
372
- ] + ["GLU"] * 2
373
- observed = [
374
- ln[17:20] for ln in self.stdout if ln.startswith(("ATOM", "ANISOU"))
375
- ]
376
-
377
- self.assertEqual(observed, expected)
378
-
379
- # Make sure we picked the right GLU atom
380
- atom_CA_GLU_26 = [
381
- l[30:54] for l in self.stdout
382
- if l[12:16] == " CA " and l[17:20] == "GLU" and l[22:26] == " 26"
383
- ]
384
- self.assertEqual(len(atom_CA_GLU_26), 2)
385
- self.assertEqual(atom_CA_GLU_26[0], " -10.000 -3.000 -12.000")
386
-
387
- def test_select_loc_B(self):
388
- """$ pdb_selaltloc -B data/dummy_altloc.pdb"""
389
-
390
- # Simulate input
391
- sys.argv = ['', '-B', os.path.join(data_dir, 'dummy_altloc.pdb')]
392
-
393
- # Execute the script
394
- self.exec_module()
395
-
396
- # Validate results
397
- self.assertEqual(self.retcode, 0) # ensure the program exited OK.
398
- self.assertEqual(len(self.stdout), 46)
399
- self.assertEqual(len(self.stderr), 0) # no errors
400
-
401
- # Make sure sequence is correct
402
- expected = [
403
- aa for aa in ['PRO', 'GLU', 'ALA', 'ILE', 'LEU'] for _ in range(8)
404
- ] + ["GLU"] * 4
405
- observed = [
406
- ln[17:20] for ln in self.stdout if ln.startswith(("ATOM", "ANISOU"))
407
- ]
408
-
409
- self.assertEqual(observed, expected)
410
-
411
- def test_select_loc_B_2(self):
412
- """$ pdb_selaltloc -B data/dummy_altloc2.pdb"""
413
-
414
- # Simulate input
415
- sys.argv = ['', '-B', os.path.join(data_dir, 'dummy_altloc2.pdb')]
416
-
417
- # Execute the script
418
- self.exec_module()
419
-
420
- # Validate results
421
- self.assertEqual(self.retcode, 0) # ensure the program exited OK.
422
- self.assertEqual(len(self.stdout), 47)
423
- self.assertEqual(len(self.stderr), 0) # no errors
424
-
425
- # Make sure sequence is correct
426
- expected = [
427
- aa for aa in ['PRO', 'GLU', 'ALA', 'ILE', 'LEU'] for _ in range(8)
428
- ] + ["GLU"] * 4
429
- observed = [
430
- ln[17:20] for ln in self.stdout if ln.startswith(("ATOM", "ANISOU"))
431
- ]
432
-
433
- self.assertEqual(observed, expected)
434
-
435
- def test_select_loc_C(self):
436
- """$ pdb_selaltloc -C data/dummy_altloc.pdb"""
437
-
438
- # Simulate input
439
- sys.argv = ['', '-C', os.path.join(data_dir, 'dummy_altloc.pdb')]
440
-
441
- # Execute the script
442
- self.exec_module()
443
-
444
- # Validate results
445
- self.assertEqual(self.retcode, 0) # ensure the program exited OK.
446
- self.assertEqual(len(self.stdout), 52)
447
- self.assertEqual(len(self.stderr), 0) # no errors
448
-
449
- # Make sure sequence is correct
450
- expected = [
451
- aa for aa in ['SER', 'PRO', 'GLU', 'ALA', 'ILE', 'LEU'] for _ in range(8)
452
- ] + ["GLU"] * 2
453
- observed = [
454
- ln[17:20] for ln in self.stdout if ln.startswith(("ATOM", "ANISOU"))
455
- ]
456
-
457
- self.assertEqual(observed, expected)
458
-
459
- def test_select_loc_C_2(self):
460
- """$ pdb_selaltloc -C data/dummy_altloc2.pdb"""
461
-
462
- # Simulate input
463
- sys.argv = ['', '-C', os.path.join(data_dir, 'dummy_altloc2.pdb')]
464
-
465
- # Execute the script
466
- self.exec_module()
467
-
468
- # Validate results
469
- self.assertEqual(self.retcode, 0) # ensure the program exited OK.
470
- self.assertEqual(len(self.stdout), 61)
471
- self.assertEqual(len(self.stderr), 0) # no errors
472
-
473
- # Make sure sequence is correct
474
- expected = [
475
- aa for aa in ['SER', 'GLU', 'PRO', 'GLU', 'ALA', 'ILE', 'LEU']
476
- for _ in range(8)
477
- ] + ["GLU"] * 2
478
- observed = [
479
- ln[17:20] for ln in self.stdout if ln.startswith(("ATOM", "ANISOU"))
480
- ]
481
-
482
- self.assertEqual(observed, expected)
483
-
484
- def test_gives_same_dummy_A(self):
485
- """Test dummy.pdb is not altered because there are not altlocs."""
486
- sys.argv = ['', '-A', os.path.join(data_dir, 'dummy.pdb')]
487
- self.exec_module()
488
- self.assertEqual(self.retcode, 0)
489
- self.assertEqual(len(self.stdout), 203)
490
- self.assertEqual(len(self.stderr), 0)
491
- self.assertEqual(
492
- self.stdout[80],
493
- "ATOM 3 CA ASN A 1 21.411 39.311 0.054 0.40 0.00 C ")
494
-
495
- def test_gives_same_dummy_B(self):
496
- """Test dummy.pdb is not altered because there are not altlocs."""
497
- sys.argv = ['', '-B', os.path.join(data_dir, 'dummy.pdb')]
498
- self.exec_module()
499
- self.assertEqual(self.retcode, 0)
500
- self.assertEqual(len(self.stdout), 203)
501
- self.assertEqual(len(self.stderr), 0)
502
- self.assertEqual(
503
- self.stdout[80],
504
- "ATOM 3 CA ASN A 1 20.000 30.000 0.005 0.60 0.00 C "
505
- )
506
-
507
- def test_gives_same_dummy_maxocc(self):
508
- """Test dummy.pdb is not altered because there are not altlocs."""
509
- sys.argv = ['', os.path.join(data_dir, 'dummy.pdb')]
510
- self.exec_module()
511
- self.assertEqual(self.retcode, 0)
512
- self.assertEqual(len(self.stdout), 203)
513
- self.assertEqual(len(self.stderr), 0)
514
- self.assertEqual(
515
- self.stdout[80],
516
- "ATOM 3 CA ASN A 1 20.000 30.000 0.005 0.60 0.00 C "
517
- )
518
-
519
- def test_vu7_maxocc(self):
520
- """Test vu7.pdb properly selects highest altloc."""
521
- sys.argv = ['', os.path.join(data_dir, 'vu7.pdb')]
522
- self.exec_module()
523
- self.assertEqual(self.retcode, 0)
524
- self.assertEqual(len(self.stdout), 30)
525
- self.assertEqual(len(self.stderr), 0)
526
- self.assertEqual(
527
- self.stdout[15],
528
- "HETATM 2910 C27 VU7 A 403 -20.472 24.444 21.209 0.70 25.90 C ",
529
- )
530
- self.assertEqual(
531
- self.stdout[23:30],
532
- [
533
- "HETATM 2918 C20 VU7 A 403 -25.101 22.166 21.562 1.00 19.10 C ",
534
- "HETATM 2919 C22 VU7 A 403 -25.005 23.859 23.317 1.00 20.89 C ",
535
- "HETATM 2921 C25 VU7 A 403 -21.980 23.567 22.880 0.70 25.16 C ",
536
- "HETATM 2923 C26 VU7 A 403 -20.710 24.002 22.511 0.70 29.65 C ",
537
- "HETATM 2925 C28 VU7 A 403 -21.503 24.451 20.265 0.70 24.53 C ",
538
- "HETATM 2927 C29 VU7 A 403 -22.775 24.020 20.615 0.70 24.22 C ",
539
- "HETATM 2929 F30 VU7 A 403 -23.749 24.031 19.675 0.70 26.05 F ",
540
- ]
541
- )
542
-
543
- def test_vu7_maxocc_B(self):
544
- """Test vu7.pdb properly selects altloc B."""
545
- sys.argv = ['', '-B', os.path.join(data_dir, 'vu7.pdb')]
546
- self.exec_module()
547
- self.assertEqual(self.retcode, 0)
548
- self.assertEqual(len(self.stdout), 30)
549
- self.assertEqual(len(self.stderr), 0)
550
- self.assertEqual(
551
- self.stdout[15],
552
- "HETATM 2910 C27 VU7 A 403 -20.472 24.444 21.209 0.70 25.90 C ",
553
- )
554
- self.assertEqual(
555
- self.stdout[23:30],
556
- [
557
- "HETATM 2918 C20 VU7 A 403 -25.101 22.166 21.562 1.00 19.10 C ",
558
- "HETATM 2919 C22 VU7 A 403 -25.005 23.859 23.317 1.00 20.89 C ",
559
- "HETATM 2921 C25 VU7 A 403 -21.980 23.567 22.880 0.70 25.16 C ",
560
- "HETATM 2923 C26 VU7 A 403 -20.710 24.002 22.511 0.70 29.65 C ",
561
- "HETATM 2925 C28 VU7 A 403 -21.503 24.451 20.265 0.70 24.53 C ",
562
- "HETATM 2927 C29 VU7 A 403 -22.775 24.020 20.615 0.70 24.22 C ",
563
- "HETATM 2929 F30 VU7 A 403 -23.749 24.031 19.675 0.70 26.05 F ",
564
- ]
565
- )
566
-
567
- def test_vu7_maxocc_A(self):
568
- """Test vu7.pdb properly selects altloc A."""
569
- sys.argv = ['', '-A', os.path.join(data_dir, 'vu7.pdb')]
570
- self.exec_module()
571
- self.assertEqual(self.retcode, 0)
572
- self.assertEqual(len(self.stdout), 30)
573
- self.assertEqual(len(self.stderr), 0)
574
- self.assertEqual(
575
- self.stdout[15],
576
- "HETATM 2909 C27 VU7 A 403 -20.473 24.388 21.073 0.30 23.87 C ",
577
- )
578
- self.assertEqual(
579
- self.stdout[23:30],
580
- [
581
- "HETATM 2918 C20 VU7 A 403 -25.101 22.166 21.562 1.00 19.10 C ",
582
- "HETATM 2919 C22 VU7 A 403 -25.005 23.859 23.317 1.00 20.89 C ",
583
- "HETATM 2920 C25 VU7 A 403 -22.814 24.071 20.642 0.30 22.86 C ",
584
- "HETATM 2922 C26 VU7 A 403 -21.562 24.484 20.224 0.30 22.96 C ",
585
- "HETATM 2924 C28 VU7 A 403 -20.656 23.873 22.343 0.30 25.28 C ",
586
- "HETATM 2926 C29 VU7 A 403 -21.907 23.454 22.776 0.30 23.59 C ",
587
- "HETATM 2928 F30 VU7 A 403 -22.039 22.963 24.024 0.30 24.64 F ",
588
- ]
589
- )
590
-
591
- def test_anisou_lines(self):
592
- """
593
- Test anisou.pdb is not altered because there are not altlocs.
594
-
595
- anisou.pdb has ANISOU lines. Ensure bug reported in #130 is
596
- corrected.
597
- """
598
- infile = os.path.join(data_dir, 'anisou.pdb')
599
- sys.argv = ['', infile]
600
- self.exec_module()
601
- self.assertEqual(self.retcode, 0)
602
- self.assertEqual(len(self.stdout), 24)
603
- self.assertEqual(len(self.stderr), 0)
604
- with open(infile, "r") as fin:
605
- expected_lines = [l.strip(os.linesep) for l in fin.readlines()]
606
- self.assertEqual(self.stdout, expected_lines)
607
-
608
- def test_anisou_with_altloc_maxocc(self):
609
- """
610
- Test anisou_altloc.pdb properly selects the highest altloc.
611
-
612
- anisou.pdb has ANISOU lines. Ensure bug reported in #130 is
613
- corrected.
614
- """
615
- infile = os.path.join(data_dir, 'anisou_altloc.pdb')
616
- sys.argv = ['', infile]
617
- self.exec_module()
618
- self.assertEqual(self.retcode, 0)
619
- self.assertEqual(len(self.stdout), 24)
620
- self.assertEqual(len(self.stderr), 0)
621
- self.assertEqual(
622
- self.stdout,
623
- [
624
- "ATOM 1 N ALA A 31 -12.806 6.423 23.735 0.60 70.81 N ",
625
- "ANISOU 1 N ALA A 31 7836 7867 11203 2151 -675 -66 N ",
626
- "ATOM 2 CA ALA A 31 -13.433 7.788 23.746 0.60 65.66 C ",
627
- "ANISOU 2 CA ALA A 31 7296 7485 10167 1829 -642 -81 C ",
628
- "ATOM 3 C ALA A 31 -12.448 8.891 24.124 1.00 63.44 C ",
629
- "ANISOU 3 C ALA A 31 6818 7632 9654 1744 -656 20 C ",
630
- "ATOM 4 O ALA A 31 -11.549 8.680 24.937 1.00 65.52 O ",
631
- "ANISOU 4 O ALA A 31 6891 8010 9994 1853 -759 238 O ",
632
- "ATOM 5 CB ALA A 31 -14.628 7.834 24.691 1.00 66.76 C ",
633
- "ANISOU 5 CB ALA A 31 7636 7487 10242 1630 -748 143 C ",
634
- "ATOM 6 N THR A 32 -12.659 10.075 23.550 1.00 58.59 N ",
635
- "ANISOU 6 N THR A 32 6249 7244 8768 1532 -569 -122 N ",
636
- "ATOM 7 CA THR A 32 -11.806 11.232 23.788 1.00 55.42 C ",
637
- "ANISOU 7 CA THR A 32 5678 7217 8161 1398 -585 -53 C ",
638
- "ATOM 8 C THR A 32 -12.119 11.857 25.148 1.00 52.59 C ",
639
- "ANISOU 8 C THR A 32 5384 6947 7651 1206 -743 183 C ",
640
- "ATOM 9 O THR A 32 -13.166 11.585 25.770 1.00 49.84 O ",
641
- "ANISOU 9 O THR A 32 5232 6412 7293 1142 -803 278 O ",
642
- "ATOM 10 CB THR A 32 -11.965 12.321 22.696 0.55 51.87 C ",
643
- "ANISOU 10 CB THR A 32 5260 6948 7500 1220 -449 -254 C ",
644
- "ATOM 11 OG1 THR A 32 -13.294 12.844 22.720 1.00 48.11 O ",
645
- "ANISOU 11 OG1 THR A 32 5047 6344 6890 1015 -452 -282 O ",
646
- "ATOM 12 CG2 THR A 32 -11.660 11.781 21.303 1.00 54.23 C ",
647
- "ANISOU 12 CG2 THR A 32 5483 7248 7875 1398 -280 -508 C ",
648
- ]
649
- )
650
-
651
- def test_anisou_with_altloc_maxocc_A(self):
652
- """
653
- Test anisou_altloc.pdb selects altloc -A.
654
-
655
- anisou.pdb has ANISOU lines. Ensure bug reported in #130 is
656
- corrected.
657
- """
658
- infile = os.path.join(data_dir, 'anisou_altloc.pdb')
659
- sys.argv = ['', '-A', infile]
660
- self.exec_module()
661
- self.assertEqual(self.retcode, 0)
662
- self.assertEqual(len(self.stdout), 24)
663
- self.assertEqual(len(self.stderr), 0)
664
- self.assertEqual(
665
- self.stdout,
666
- [
667
- "ATOM 1 N ALA A 31 -12.806 6.423 23.735 0.40 70.81 N ",
668
- "ANISOU 1 N ALA A 31 7836 7867 11203 2151 -675 -66 N ",
669
- "ATOM 2 CA ALA A 31 -13.433 7.788 23.746 0.60 65.66 C ",
670
- "ANISOU 2 CA ALA A 31 7296 7485 10167 1829 -642 -81 C ",
671
- "ATOM 3 C ALA A 31 -12.448 8.891 24.124 1.00 63.44 C ",
672
- "ANISOU 3 C ALA A 31 6818 7632 9654 1744 -656 20 C ",
673
- "ATOM 4 O ALA A 31 -11.549 8.680 24.937 1.00 65.52 O ",
674
- "ANISOU 4 O ALA A 31 6891 8010 9994 1853 -759 238 O ",
675
- "ATOM 5 CB ALA A 31 -14.628 7.834 24.691 1.00 66.76 C ",
676
- "ANISOU 5 CB ALA A 31 7636 7487 10242 1630 -748 143 C ",
677
- "ATOM 6 N THR A 32 -12.659 10.075 23.550 1.00 58.59 N ",
678
- "ANISOU 6 N THR A 32 6249 7244 8768 1532 -569 -122 N ",
679
- "ATOM 7 CA THR A 32 -11.806 11.232 23.788 1.00 55.42 C ",
680
- "ANISOU 7 CA THR A 32 5678 7217 8161 1398 -585 -53 C ",
681
- "ATOM 8 C THR A 32 -12.119 11.857 25.148 1.00 52.59 C ",
682
- "ANISOU 8 C THR A 32 5384 6947 7651 1206 -743 183 C ",
683
- "ATOM 9 O THR A 32 -13.166 11.585 25.770 1.00 49.84 O ",
684
- "ANISOU 9 O THR A 32 5232 6412 7293 1142 -803 278 O ",
685
- "ATOM 10 CB THR A 32 -11.965 12.321 22.696 0.45 51.87 C ",
686
- "ANISOU 10 CB THR A 32 5260 6948 7500 1220 -449 -254 C ",
687
- "ATOM 11 OG1 THR A 32 -13.294 12.844 22.720 1.00 48.11 O ",
688
- "ANISOU 11 OG1 THR A 32 5047 6344 6890 1015 -452 -282 O ",
689
- "ATOM 12 CG2 THR A 32 -11.660 11.781 21.303 1.00 54.23 C ",
690
- "ANISOU 12 CG2 THR A 32 5483 7248 7875 1398 -280 -508 C ",
691
- ]
692
- )
693
-
694
- def test_anisou_with_altloc_maxocc_B(self):
695
- """
696
- Test anisou_altloc.pdb selects altloc -B.
697
-
698
- anisou.pdb has ANISOU lines. Ensure bug reported in #130 is
699
- corrected.
700
- """
701
- infile = os.path.join(data_dir, 'anisou_altloc.pdb')
702
- sys.argv = ['', '-B', infile]
703
- self.exec_module()
704
- self.assertEqual(self.retcode, 0)
705
- self.assertEqual(len(self.stdout), 24)
706
- self.assertEqual(len(self.stderr), 0)
707
- self.assertEqual(
708
- self.stdout,
709
- [
710
- "ATOM 1 N ALA A 31 -12.806 6.423 23.735 0.60 70.81 N ",
711
- "ANISOU 1 N ALA A 31 7836 7867 11203 2151 -675 -66 N ",
712
- "ATOM 2 CA ALA A 31 -13.433 7.788 23.746 0.40 65.66 C ",
713
- "ANISOU 2 CA ALA A 31 7296 7485 10167 1829 -642 -81 C ",
714
- "ATOM 3 C ALA A 31 -12.448 8.891 24.124 1.00 63.44 C ",
715
- "ANISOU 3 C ALA A 31 6818 7632 9654 1744 -656 20 C ",
716
- "ATOM 4 O ALA A 31 -11.549 8.680 24.937 1.00 65.52 O ",
717
- "ANISOU 4 O ALA A 31 6891 8010 9994 1853 -759 238 O ",
718
- "ATOM 5 CB ALA A 31 -14.628 7.834 24.691 1.00 66.76 C ",
719
- "ANISOU 5 CB ALA A 31 7636 7487 10242 1630 -748 143 C ",
720
- "ATOM 6 N THR A 32 -12.659 10.075 23.550 1.00 58.59 N ",
721
- "ANISOU 6 N THR A 32 6249 7244 8768 1532 -569 -122 N ",
722
- "ATOM 7 CA THR A 32 -11.806 11.232 23.788 1.00 55.42 C ",
723
- "ANISOU 7 CA THR A 32 5678 7217 8161 1398 -585 -53 C ",
724
- "ATOM 8 C THR A 32 -12.119 11.857 25.148 1.00 52.59 C ",
725
- "ANISOU 8 C THR A 32 5384 6947 7651 1206 -743 183 C ",
726
- "ATOM 9 O THR A 32 -13.166 11.585 25.770 1.00 49.84 O ",
727
- "ANISOU 9 O THR A 32 5232 6412 7293 1142 -803 278 O ",
728
- "ATOM 10 CB THR A 32 -11.965 12.321 22.696 0.55 51.87 C ",
729
- "ANISOU 10 CB THR A 32 5260 6948 7500 1220 -449 -254 C ",
730
- "ATOM 11 OG1 THR A 32 -13.294 12.844 22.720 1.00 48.11 O ",
731
- "ANISOU 11 OG1 THR A 32 5047 6344 6890 1015 -452 -282 O ",
732
- "ATOM 12 CG2 THR A 32 -11.660 11.781 21.303 1.00 54.23 C ",
733
- "ANISOU 12 CG2 THR A 32 5483 7248 7875 1398 -280 -508 C ",
734
- ]
735
- )
736
-
737
- def test_anisou_missing(self):
738
- """Test raises error if there are missing anisou lines."""
739
- infile = os.path.join(data_dir, 'anisou_missing.pdb')
740
- sys.argv = ['', infile]
741
- self.exec_module()
742
- self.assertEqual(self.retcode, 0)
743
-
744
- def test_captures_previous_residue_maxocc_A(self):
745
- """
746
- Test the previous residue is not lost.
747
-
748
- In version 2.4.5 we realised that the residue previous to the
749
- residues having alternative locations was missing. See dummy_altloc3.pdb.
750
- """
751
- sys.argv = ['', '-A', os.path.join(data_dir, 'dummy_altloc3.pdb')]
752
- self.exec_module()
753
- self.assertEqual(self.retcode, 0)
754
- self.assertEqual(len(self.stdout), 25)
755
- self.assertEqual(len(self.stderr), 0)
756
- self.assertEqual(
757
- self.stdout,
758
- [
759
- "ATOM 153 N VAL A 18 -0.264 -17.574 22.788 0.00 0.00 N ",
760
- "ATOM 154 CA VAL A 18 -0.201 -17.901 24.209 0.00 0.00 C ",
761
- "ATOM 155 C VAL A 18 -1.047 -19.150 24.437 0.00 0.00 C ",
762
- "ATOM 156 O VAL A 18 -2.260 -19.144 24.214 0.00 0.00 O ",
763
- "ATOM 157 CB VAL A 18 -0.689 -16.724 25.084 0.00 0.00 C ",
764
- "ATOM 161 N TRP A 19 -0.408 -20.230 24.882 0.00 0.00 N ",
765
- "ATOM 162 CA TRP A 19 -1.091 -21.490 25.161 0.00 0.00 C ",
766
- "ATOM 163 C TRP A 19 -1.303 -21.563 26.667 0.00 0.00 C ",
767
- "ATOM 164 O TRP A 19 -0.357 -21.920 27.375 0.00 0.00 O ",
768
- "ATOM 165 CB TRP A 19 -0.272 -22.670 24.635 0.00 0.00 C ",
769
- "ATOM 176 N TYR A 20 -2.522 -21.226 27.083 0.00 0.00 N ",
770
- "ATOM 177 CA TYR A 20 -2.898 -21.178 28.493 0.00 0.00 C ",
771
- "ATOM 178 C TYR A 20 -3.718 -22.410 28.851 0.00 0.00 C ",
772
- "ATOM 179 O TYR A 20 -4.629 -22.780 28.105 0.00 0.00 O ",
773
- "ATOM 180 CB TYR A 20 -3.681 -19.898 28.795 0.00 0.00 C ",
774
- "ATOM 189 N VAL A 21 -3.396 -23.034 29.982 0.40 0.00 N ",
775
- "ATOM 190 CA VAL A 21 -4.121 -24.205 30.467 0.40 0.00 C ",
776
- "ATOM 191 C VAL A 21 -4.530 -24.072 31.930 0.40 0.00 C ",
777
- "ATOM 192 O VAL A 21 -3.835 -23.461 32.747 0.40 0.00 O ",
778
- "ATOM 193 CB VAL A 21 -3.289 -25.497 30.298 0.40 0.00 C ",
779
- "ATOM 189 N PRO A 22 -3.396 -23.034 29.982 0.40 0.00 N ",
780
- "ATOM 190 CA PRO A 22 -4.121 -24.205 30.467 0.40 0.00 C ",
781
- "ATOM 191 C PRO A 22 -4.530 -24.072 31.930 0.40 0.00 C ",
782
- "ATOM 192 O PRO A 22 -3.835 -23.461 32.747 0.40 0.00 O ",
783
- "ATOM 193 CB PRO A 22 -3.289 -25.497 30.298 0.40 0.00 C ",
784
- ]
785
- )
786
-
787
- def test_captures_previous_residue_maxocc(self):
788
- """
789
- Test the previous residue is not lost.
790
-
791
- In version 2.4.5 we realised that the residue previous to the
792
- residues having alternative locations was missing. See dummy_altloc3.pdb.
793
- """
794
- sys.argv = ['', os.path.join(data_dir, 'dummy_altloc3.pdb')]
795
- self.exec_module()
796
- self.assertEqual(self.retcode, 0)
797
- self.assertEqual(len(self.stdout), 25)
798
- self.assertEqual(len(self.stderr), 0)
799
- self.assertEqual(
800
- self.stdout,
801
- [
802
- "ATOM 153 N VAL A 18 -0.264 -17.574 22.788 0.00 0.00 N ",
803
- "ATOM 154 CA VAL A 18 -0.201 -17.901 24.209 0.00 0.00 C ",
804
- "ATOM 155 C VAL A 18 -1.047 -19.150 24.437 0.00 0.00 C ",
805
- "ATOM 156 O VAL A 18 -2.260 -19.144 24.214 0.00 0.00 O ",
806
- "ATOM 157 CB VAL A 18 -0.689 -16.724 25.084 0.00 0.00 C ",
807
- "ATOM 161 N TRP A 19 -0.408 -20.230 24.882 0.00 0.00 N ",
808
- "ATOM 162 CA TRP A 19 -1.091 -21.490 25.161 0.00 0.00 C ",
809
- "ATOM 163 C TRP A 19 -1.303 -21.563 26.667 0.00 0.00 C ",
810
- "ATOM 164 O TRP A 19 -0.357 -21.920 27.375 0.00 0.00 O ",
811
- "ATOM 165 CB TRP A 19 -0.272 -22.670 24.635 0.00 0.00 C ",
812
- "ATOM 176 N TYR A 20 -2.522 -21.226 27.083 0.00 0.00 N ",
813
- "ATOM 177 CA TYR A 20 -2.898 -21.178 28.493 0.00 0.00 C ",
814
- "ATOM 178 C TYR A 20 -3.718 -22.410 28.851 0.00 0.00 C ",
815
- "ATOM 179 O TYR A 20 -4.629 -22.780 28.105 0.00 0.00 O ",
816
- "ATOM 180 CB TYR A 20 -3.681 -19.898 28.795 0.00 0.00 C ",
817
- "ATOM 197 N ALA A 21 -5.676 -24.647 32.284 0.60 0.00 N ",
818
- "ATOM 198 CA ALA A 21 -6.012 -24.814 33.696 0.60 0.00 C ",
819
- "ATOM 199 C ALA A 21 -4.990 -25.677 34.426 0.60 0.00 C ",
820
- "ATOM 200 O ALA A 21 -4.494 -26.675 33.897 0.60 0.00 O ",
821
- "ATOM 201 CB ALA A 21 -7.405 -25.428 33.847 0.60 0.00 C ",
822
- "ATOM 197 N GLY A 22 -5.676 -24.647 32.284 0.60 0.00 N ",
823
- "ATOM 198 CA GLY A 22 -6.012 -24.814 33.696 0.60 0.00 C ",
824
- "ATOM 199 C GLY A 22 -4.990 -25.677 34.426 0.60 0.00 C ",
825
- "ATOM 200 O GLY A 22 -4.494 -26.675 33.897 0.60 0.00 O ",
826
- "ATOM 201 CB GLY A 22 -7.405 -25.428 33.847 0.60 0.00 C ",
827
- ]
828
- )
829
-
830
- def test_captures_previous_residue_maxocc_B(self):
831
- """
832
- Test the previous residue is not lost.
833
-
834
- In version 2.4.5 we realised that the residue previous to the
835
- residues having alternative locations was missing. See dummy_altloc3.pdb.
836
- """
837
- sys.argv = ['', '-B', os.path.join(data_dir, 'dummy_altloc3.pdb')]
838
- self.exec_module()
839
- self.assertEqual(self.retcode, 0)
840
- self.assertEqual(len(self.stdout), 25)
841
- self.assertEqual(len(self.stderr), 0)
842
- self.assertEqual(
843
- self.stdout,
844
- [
845
- "ATOM 153 N VAL A 18 -0.264 -17.574 22.788 0.00 0.00 N ",
846
- "ATOM 154 CA VAL A 18 -0.201 -17.901 24.209 0.00 0.00 C ",
847
- "ATOM 155 C VAL A 18 -1.047 -19.150 24.437 0.00 0.00 C ",
848
- "ATOM 156 O VAL A 18 -2.260 -19.144 24.214 0.00 0.00 O ",
849
- "ATOM 157 CB VAL A 18 -0.689 -16.724 25.084 0.00 0.00 C ",
850
- "ATOM 161 N TRP A 19 -0.408 -20.230 24.882 0.00 0.00 N ",
851
- "ATOM 162 CA TRP A 19 -1.091 -21.490 25.161 0.00 0.00 C ",
852
- "ATOM 163 C TRP A 19 -1.303 -21.563 26.667 0.00 0.00 C ",
853
- "ATOM 164 O TRP A 19 -0.357 -21.920 27.375 0.00 0.00 O ",
854
- "ATOM 165 CB TRP A 19 -0.272 -22.670 24.635 0.00 0.00 C ",
855
- "ATOM 176 N TYR A 20 -2.522 -21.226 27.083 0.00 0.00 N ",
856
- "ATOM 177 CA TYR A 20 -2.898 -21.178 28.493 0.00 0.00 C ",
857
- "ATOM 178 C TYR A 20 -3.718 -22.410 28.851 0.00 0.00 C ",
858
- "ATOM 179 O TYR A 20 -4.629 -22.780 28.105 0.00 0.00 O ",
859
- "ATOM 180 CB TYR A 20 -3.681 -19.898 28.795 0.00 0.00 C ",
860
- "ATOM 197 N ALA A 21 -5.676 -24.647 32.284 0.60 0.00 N ",
861
- "ATOM 198 CA ALA A 21 -6.012 -24.814 33.696 0.60 0.00 C ",
862
- "ATOM 199 C ALA A 21 -4.990 -25.677 34.426 0.60 0.00 C ",
863
- "ATOM 200 O ALA A 21 -4.494 -26.675 33.897 0.60 0.00 O ",
864
- "ATOM 201 CB ALA A 21 -7.405 -25.428 33.847 0.60 0.00 C ",
865
- "ATOM 197 N GLY A 22 -5.676 -24.647 32.284 0.60 0.00 N ",
866
- "ATOM 198 CA GLY A 22 -6.012 -24.814 33.696 0.60 0.00 C ",
867
- "ATOM 199 C GLY A 22 -4.990 -25.677 34.426 0.60 0.00 C ",
868
- "ATOM 200 O GLY A 22 -4.494 -26.675 33.897 0.60 0.00 O ",
869
- "ATOM 201 CB GLY A 22 -7.405 -25.428 33.847 0.60 0.00 C ",
870
- ]
871
- )
872
-
873
-
874
- def test_file_not_found(self):
875
- """$ pdb_selaltloc not_existing.pdb"""
876
-
877
- afile = os.path.join(data_dir, 'not_existing.pdb')
878
- sys.argv = ['', afile]
879
-
880
- self.exec_module()
881
-
882
- self.assertEqual(self.retcode, 1) # exit code is 1 (error)
883
- self.assertEqual(len(self.stdout), 0) # nothing written to stdout
884
- self.assertEqual(self.stderr[0][:22],
885
- "ERROR!! File not found") # proper error message
886
-
887
- @unittest.skipIf(os.getenv('SKIP_TTY_TESTS'), 'skip on GHA - no TTY')
888
- def test_file_missing(self):
889
- """$ pdb_selaltloc -A"""
890
-
891
- sys.argv = ['', '-A']
892
-
893
- self.exec_module()
894
-
895
- self.assertEqual(self.retcode, 1)
896
- self.assertEqual(len(self.stdout), 0) # no output
897
- self.assertEqual(self.stderr[0],
898
- "ERROR!! No data to process!")
899
-
900
- @unittest.skipIf(os.getenv('SKIP_TTY_TESTS'), 'skip on GHA - no TTY')
901
- def test_helptext(self):
902
- """$ pdb_selaltloc"""
903
-
904
- sys.argv = ['']
905
-
906
- self.exec_module()
907
-
908
- self.assertEqual(self.retcode, 1) # ensure the program exited gracefully.
909
- self.assertEqual(len(self.stdout), 0) # no output
910
- self.assertEqual(self.stderr, self.module.__doc__.split("\n")[:-1])
911
-
912
- def test_invalid_option(self):
913
- """$ pdb_selaltloc -AH data/dummy.pdb"""
914
-
915
- sys.argv = ['', '-AH', os.path.join(data_dir, 'dummy.pdb')]
916
-
917
- self.exec_module()
918
-
919
- self.assertEqual(self.retcode, 1)
920
- self.assertEqual(len(self.stdout), 0)
921
- self.assertEqual(self.stderr[0][:47],
922
- "ERROR!! Alternate location identifiers must be ")
923
-
924
- def test_not_an_option(self):
925
- """$ pdb_selaltloc 20 data/dummy.pdb"""
926
-
927
- sys.argv = ['', '20', os.path.join(data_dir, 'dummy.pdb')]
928
-
929
- self.exec_module()
930
-
931
- self.assertEqual(self.retcode, 1)
932
- self.assertEqual(len(self.stdout), 0)
933
- self.assertEqual(self.stderr[0],
934
- "ERROR! First argument is not an option: '20'")
935
-
936
-
937
- if __name__ == '__main__':
938
- from config import test_dir
939
-
940
- mpath = os.path.abspath(os.path.join(test_dir, '..'))
941
- sys.path.insert(0, mpath) # so we load dev files before any installation
942
-
943
- unittest.main()