pdb-tools 2.5.0__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.5.0.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.5.0.dist-info → pdb_tools-2.5.1.dist-info}/WHEEL +1 -1
  4. {pdb_tools-2.5.0.dist-info → pdb_tools-2.5.1.dist-info}/entry_points.txt +0 -1
  5. {pdb_tools-2.5.0.dist-info → pdb_tools-2.5.1.dist-info}/top_level.txt +0 -1
  6. pdbtools/pdb_tidy.py +17 -9
  7. pdb_tools-2.5.0.dist-info/RECORD +0 -105
  8. tests/__init__.py +0 -38
  9. tests/config.py +0 -25
  10. tests/test_pdb_b.py +0 -161
  11. tests/test_pdb_chain.py +0 -160
  12. tests/test_pdb_chainbows.py +0 -140
  13. tests/test_pdb_chainxseg.py +0 -156
  14. tests/test_pdb_chkensemble.py +0 -191
  15. tests/test_pdb_delchain.py +0 -165
  16. tests/test_pdb_delelem.py +0 -165
  17. tests/test_pdb_delhetatm.py +0 -115
  18. tests/test_pdb_delinsertion.py +0 -226
  19. tests/test_pdb_delres.py +0 -241
  20. tests/test_pdb_delresname.py +0 -171
  21. tests/test_pdb_element.py +0 -151
  22. tests/test_pdb_fixinsert.py +0 -223
  23. tests/test_pdb_fromcif.py +0 -124
  24. tests/test_pdb_gap.py +0 -125
  25. tests/test_pdb_head.py +0 -142
  26. tests/test_pdb_intersect.py +0 -139
  27. tests/test_pdb_keepcoord.py +0 -115
  28. tests/test_pdb_merge.py +0 -106
  29. tests/test_pdb_mkensemble.py +0 -132
  30. tests/test_pdb_occ.py +0 -161
  31. tests/test_pdb_reatom.py +0 -243
  32. tests/test_pdb_reres.py +0 -281
  33. tests/test_pdb_rplchain.py +0 -172
  34. tests/test_pdb_rplresname.py +0 -172
  35. tests/test_pdb_seg.py +0 -160
  36. tests/test_pdb_segxchain.py +0 -146
  37. tests/test_pdb_selaltloc.py +0 -943
  38. tests/test_pdb_selatom.py +0 -165
  39. tests/test_pdb_selchain.py +0 -210
  40. tests/test_pdb_selelem.py +0 -165
  41. tests/test_pdb_selhetatm.py +0 -116
  42. tests/test_pdb_selmodel.py +0 -165
  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.5.0.dist-info → pdb_tools-2.5.1.dist-info/licenses}/LICENSE +0 -0
tests/test_pdb_selseg.py DELETED
@@ -1,165 +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_selseg`.
20
- """
21
-
22
- import os
23
- import sys
24
- import unittest
25
-
26
- from config import data_dir
27
- from utils import OutputCapture
28
-
29
-
30
- class TestTool(unittest.TestCase):
31
- """
32
- Generic class for testing tools.
33
- """
34
-
35
- def setUp(self):
36
- # Dynamically import the module
37
- name = 'pdbtools.pdb_selseg'
38
- self.module = __import__(name, fromlist=[''])
39
-
40
- def exec_module(self):
41
- """
42
- Execs module.
43
- """
44
-
45
- with OutputCapture() as output:
46
- try:
47
- self.module.main()
48
- except SystemExit as e:
49
- self.retcode = e.code
50
-
51
- self.stdout = output.stdout
52
- self.stderr = output.stderr
53
-
54
- return
55
-
56
- def test_one_option(self):
57
- """$ pdb_selseg -Z data/dummy.pdb"""
58
-
59
- # Simulate input
60
- # pdb_selseg dummy.pdb
61
- sys.argv = ['', '-Z', os.path.join(data_dir, 'dummy.pdb')]
62
-
63
- # Execute the script
64
- self.exec_module()
65
-
66
- # Validate results
67
- self.assertEqual(self.retcode, 0) # ensure the program exited OK.
68
- self.assertEqual(len(self.stdout), 39) # selected Z
69
- self.assertEqual(len(self.stderr), 0) # no errors
70
-
71
- def test_multiple(self):
72
- """
73
- $ pdb_selseg -A,B data/dummy.pdb
74
- """
75
-
76
- sys.argv = ['', '-A,B', os.path.join(data_dir, 'dummy.pdb')]
77
-
78
- self.exec_module()
79
-
80
- self.assertEqual(self.retcode, 0)
81
- self.assertEqual(len(self.stdout), 19) # segments A & B (i.e. nothing)
82
- self.assertEqual(len(self.stderr), 0)
83
-
84
- def test_file_not_found(self):
85
- """$ pdb_selseg not_existing.pdb"""
86
-
87
- afile = os.path.join(data_dir, 'not_existing.pdb')
88
- sys.argv = ['', afile]
89
-
90
- self.exec_module()
91
-
92
- self.assertEqual(self.retcode, 1) # exit code is 1 (error)
93
- self.assertEqual(len(self.stdout), 0) # nothing written to stdout
94
- self.assertEqual(self.stderr[0][:22],
95
- "ERROR!! File not found") # proper error message
96
-
97
- @unittest.skipIf(os.getenv('SKIP_TTY_TESTS'), 'skip on GHA - no TTY')
98
- def test_file_missing(self):
99
- """$ pdb_selseg -A"""
100
-
101
- sys.argv = ['', '-A']
102
-
103
- self.exec_module()
104
-
105
- self.assertEqual(self.retcode, 1)
106
- self.assertEqual(len(self.stdout), 0) # no output
107
- self.assertEqual(self.stderr[0],
108
- "ERROR!! No data to process!")
109
-
110
- @unittest.skipIf(os.getenv('SKIP_TTY_TESTS'), 'skip on GHA - no TTY')
111
- def test_helptext(self):
112
- """$ pdb_selseg"""
113
-
114
- sys.argv = ['']
115
-
116
- self.exec_module()
117
-
118
- self.assertEqual(self.retcode, 1) # ensure the program exited gracefully.
119
- self.assertEqual(len(self.stdout), 0) # no output
120
- self.assertEqual(self.stderr, self.module.__doc__.split("\n")[:-1])
121
-
122
- def test_invalid_option(self):
123
- """$ pdb_selseg data/dummy.pdb"""
124
-
125
- sys.argv = ['', os.path.join(data_dir, 'dummy.pdb')]
126
-
127
- self.exec_module()
128
-
129
- self.assertEqual(self.retcode, 1)
130
- self.assertEqual(len(self.stdout), 0)
131
- self.assertEqual(self.stderr[0][:47],
132
- "ERROR!! You must provide at least one segment i")
133
-
134
- def test_invalid_option_2(self):
135
- """$ pdb_selseg -ABCDE data/dummy.pdb"""
136
-
137
- sys.argv = ['', '-ABCDE', os.path.join(data_dir, 'dummy.pdb')]
138
-
139
- self.exec_module()
140
-
141
- self.assertEqual(self.retcode, 1)
142
- self.assertEqual(len(self.stdout), 0)
143
- self.assertEqual(self.stderr[0][:40],
144
- "ERROR!! Segment identifier name is inval")
145
-
146
- def test_not_an_option(self):
147
- """$ pdb_selseg 20 data/dummy.pdb"""
148
-
149
- sys.argv = ['', '20', os.path.join(data_dir, 'dummy.pdb')]
150
-
151
- self.exec_module()
152
-
153
- self.assertEqual(self.retcode, 1)
154
- self.assertEqual(len(self.stdout), 0)
155
- self.assertEqual(self.stderr[0],
156
- "ERROR! First argument is not an option: '20'")
157
-
158
-
159
- if __name__ == '__main__':
160
- from config import test_dir
161
-
162
- mpath = os.path.abspath(os.path.join(test_dir, '..'))
163
- sys.path.insert(0, mpath) # so we load dev files before any installation
164
-
165
- unittest.main()
@@ -1,241 +0,0 @@
1
- #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
- #
4
- # Copyright 1118 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_shiftres`.
20
- """
21
-
22
- import os
23
- import sys
24
- import unittest
25
-
26
- from config import data_dir
27
- from utils import OutputCapture
28
-
29
-
30
- class TestTool(unittest.TestCase):
31
- """
32
- Generic class for testing tools.
33
- """
34
-
35
- def setUp(self):
36
- # Dynamically import the module
37
- name = 'pdbtools.pdb_shiftres'
38
- self.module = __import__(name, fromlist=[''])
39
-
40
- def exec_module(self):
41
- """
42
- Execs module.
43
- """
44
-
45
- with OutputCapture() as output:
46
- try:
47
- self.module.main()
48
- except SystemExit as e:
49
- self.retcode = e.code
50
-
51
- self.stdout = output.stdout
52
- self.stderr = output.stderr
53
-
54
- return
55
-
56
- def test_default(self):
57
- """$ pdb_shiftres data/dummy.pdb"""
58
-
59
- # Simulate input
60
- # pdb_shiftres dummy.pdb
61
- sys.argv = ['', os.path.join(data_dir, 'dummy.pdb')]
62
-
63
- # Execute the script
64
- self.exec_module()
65
-
66
- # Validate results
67
- self.assertEqual(self.retcode, 0) # ensure the program exited OK.
68
- self.assertEqual(len(self.stdout), 204) # no lines deleted
69
- self.assertEqual(len(self.stderr), 0) # no errors
70
-
71
- records = (('ATOM', 'HETATM'))
72
- resid_list = [int(l[22:26]) for l in self.stdout
73
- if l.startswith(records)]
74
-
75
- expected = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
76
- 4, 4, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
77
- 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 1, 1, 1, 1, 1, 1, 1, 1, 1,
78
- 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
79
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
80
- 3, 3, 3, 3, 3, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
81
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 2, 2, 2, 2, 2, 2, 2,
82
- 2, 2, 2, 2, 2, 2, 2, 2, -1, -1, -1, -1, -1, -1, -1, -1, 2,
83
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
84
- 301, 302, 303, 301, 301, 302, 303, 304, 305]
85
-
86
- self.assertEqual(resid_list, expected)
87
-
88
- def test_single_option_1(self):
89
- """$ pdb_shiftres -10 data/dummy.pdb"""
90
-
91
- # Simulate input
92
- # pdb_shiftres dummy.pdb
93
- sys.argv = ['', '-10', os.path.join(data_dir, 'dummy.pdb')]
94
-
95
- # Execute the script
96
- self.exec_module()
97
-
98
- # Validate results
99
- self.assertEqual(self.retcode, 0) # ensure the program exited OK.
100
- self.assertEqual(len(self.stdout), 204) # no lines deleted
101
- self.assertEqual(len(self.stderr), 0) # no errors
102
-
103
- records = (('ATOM', 'HETATM'))
104
- resid_list = [int(l[22:26]) for l in self.stdout
105
- if l.startswith(records)]
106
-
107
- expected = [14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
108
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 16, 16, 16, 16,
109
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17,
110
- 17, 17, 17, 17, 17, 17, 11, 11, 11, 11, 11, 11, 11, 11, 11,
111
- 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12,
112
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
113
- 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
114
- 13, 13, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
115
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 12, 12,
116
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 9, 9, 9,
117
- 9, 9, 9, 9, 9, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
118
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 311, 312, 313, 311, 311,
119
- 312, 313, 314, 315]
120
-
121
- self.assertEqual(resid_list, expected)
122
-
123
- def test_single_option_2(self):
124
- """$ pdb_shiftres --10 data/dummy.pdb"""
125
-
126
- # Simulate input
127
- # pdb_shiftres dummy.pdb
128
- sys.argv = ['', '--10', os.path.join(data_dir, 'dummy.pdb')]
129
-
130
- # Execute the script
131
- self.exec_module()
132
-
133
- # Validate results
134
- self.assertEqual(self.retcode, 0) # ensure the program exited OK.
135
- self.assertEqual(len(self.stdout), 204) # no lines deleted
136
- self.assertEqual(len(self.stderr), 0) # no errors
137
-
138
- records = (('ATOM', 'HETATM'))
139
- resid_list = [int(l[22:26]) for l in self.stdout
140
- if l.startswith(records)]
141
-
142
- expected = [-6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6,
143
- -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -4, -4, -4, -4,
144
- -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -3, -3, -3, -3,
145
- -3, -3, -3, -3, -3, -3, -9, -9, -9, -9, -9, -9, -9, -9, -9,
146
- -9, -9, -9, -9, -9, -9, -9, -9, -8, -8, -8, -8, -8, -8, -8,
147
- -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8,
148
- -8, -8, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7,
149
- -7, -7, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5,
150
- -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -8, -8,
151
- -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -11,
152
- -11, -11, -11, -11, -11, -11, -11, -8, -8, -8, -8, -8, -8,
153
- -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, 291,
154
- 292, 293, 291, 291, 292, 293, 294, 295]
155
-
156
- self.assertEqual(resid_list, expected)
157
-
158
- def test_too_many_residues(self):
159
- """$ pdb_shiftres -9998 data/dummy.pdb"""
160
-
161
- sys.argv = ['', '-9998', os.path.join(data_dir, 'dummy.pdb')]
162
-
163
- self.exec_module()
164
-
165
- self.assertEqual(self.retcode, 1)
166
- self.assertEqual(len(self.stdout), 0)
167
- self.assertEqual(len(self.stderr), 1)
168
-
169
- self.assertEqual(self.stderr[0][:22],
170
- "Cannot set residue num") # proper error message
171
-
172
- def test_file_not_found(self):
173
- """$ pdb_shiftres -10 not_existing.pdb"""
174
-
175
- afile = os.path.join(data_dir, 'not_existing.pdb')
176
- sys.argv = ['', '-10', afile]
177
-
178
- self.exec_module()
179
-
180
- self.assertEqual(self.retcode, 1) # exit code is 1 (error)
181
- self.assertEqual(len(self.stdout), 0) # nothing written to stdout
182
- self.assertEqual(self.stderr[0][:22],
183
- "ERROR!! File not found") # proper error message
184
-
185
- @unittest.skipIf(os.getenv('SKIP_TTY_TESTS'), 'skip on GHA - no TTY')
186
- def test_file_missing(self):
187
- """$ pdb_shiftres -10"""
188
-
189
- sys.argv = ['', '-10']
190
-
191
- self.exec_module()
192
-
193
- self.assertEqual(self.retcode, 1)
194
- self.assertEqual(len(self.stdout), 0) # no output
195
- self.assertEqual(self.stderr[0],
196
- "ERROR!! No data to process!")
197
-
198
- @unittest.skipIf(os.getenv('SKIP_TTY_TESTS'), 'skip on GHA - no TTY')
199
- def test_helptext(self):
200
- """$ pdb_shiftres"""
201
-
202
- sys.argv = ['']
203
-
204
- self.exec_module()
205
-
206
- self.assertEqual(self.retcode, 1) # ensure the program exited gracefully.
207
- self.assertEqual(len(self.stdout), 0) # no output
208
- self.assertEqual(self.stderr, self.module.__doc__.split("\n")[:-1])
209
-
210
- def test_invalid_option(self):
211
- """$ pdb_shiftres -A data/dummy.pdb"""
212
-
213
- sys.argv = ['', '-A', os.path.join(data_dir, 'dummy.pdb')]
214
-
215
- self.exec_module()
216
-
217
- self.assertEqual(self.retcode, 1)
218
- self.assertEqual(len(self.stdout), 0)
219
- self.assertEqual(self.stderr[0][:36],
220
- "ERROR!! You provided an invalid numb")
221
-
222
- def test_not_an_option(self):
223
- """$ pdb_shiftres 11 data/dummy.pdb"""
224
-
225
- sys.argv = ['', '11', os.path.join(data_dir, 'dummy.pdb')]
226
-
227
- self.exec_module()
228
-
229
- self.assertEqual(self.retcode, 1)
230
- self.assertEqual(len(self.stdout), 0)
231
- self.assertEqual(self.stderr[0],
232
- "ERROR! First argument is not an option: '11'")
233
-
234
-
235
- if __name__ == '__main__':
236
- from config import test_dir
237
-
238
- mpath = os.path.abspath(os.path.join(test_dir, '..'))
239
- sys.path.insert(0, mpath) # so we load dev files before any installation
240
-
241
- unittest.main()
tests/test_pdb_sort.py DELETED
@@ -1,254 +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_sort`.
20
- """
21
-
22
- import os
23
- import sys
24
- import unittest
25
-
26
- from config import data_dir
27
- from utils import OutputCapture
28
-
29
-
30
- class TestTool(unittest.TestCase):
31
- """
32
- Generic class for testing tools.
33
- """
34
-
35
- def setUp(self):
36
- # Dynamically import the module
37
- name = 'pdbtools.pdb_sort'
38
- self.module = __import__(name, fromlist=[''])
39
-
40
- def exec_module(self):
41
- """
42
- Execs module.
43
- """
44
-
45
- with OutputCapture() as output:
46
- try:
47
- self.module.main()
48
- except SystemExit as e:
49
- self.retcode = e.code
50
-
51
- self.stdout = output.stdout
52
- self.stderr = output.stderr
53
-
54
- return
55
-
56
- def test_default(self):
57
- """$ pdb_sort data/dummy.pdb"""
58
-
59
- fpath = os.path.join(data_dir, 'dummy.pdb')
60
- sys.argv = ['', fpath]
61
-
62
- # Execute the script
63
- self.exec_module()
64
-
65
- # Validate results
66
- self.assertEqual(self.retcode, 0) # ensure the program exited OK.
67
- self.assertEqual(len(self.stdout), 200)
68
- self.assertEqual(len(self.stderr), 0) # no errors
69
-
70
- # Check order of chains
71
- records = ('ATOM', 'HETATM')
72
- chain_ids = [l[21] for l in self.stdout if l.startswith(records)]
73
-
74
- expected = ['A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
75
- 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
76
- 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
77
- 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
78
- 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'B', 'B', 'B', 'B',
79
- 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B',
80
- 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B',
81
- 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B',
82
- 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'C',
83
- 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C',
84
- 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C',
85
- 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C',
86
- 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C',
87
- 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D',
88
- 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'A', 'A', 'A', 'B',
89
- 'C', 'C', 'C', 'C', 'C']
90
-
91
- self.assertEqual(chain_ids, expected)
92
-
93
- # Check order of residue numbers
94
- resids = [int(l[22:26]) for l in self.stdout if l.startswith(records)]
95
-
96
- expected = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2,
97
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
98
- 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4,
99
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
100
- 4, 4, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7,
101
- 7, 7, 7, 7, 7, 7, 7, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2,
102
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 5, 5, 5, 5, 5, 5, 5,
103
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 2,
104
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
105
- 301, 302, 303, 301, 301, 302, 303, 304, 305]
106
-
107
- self.assertEqual(resids, expected)
108
-
109
- # Check order of altlocs
110
- altlocs = [l[16] for l in self.stdout if l.startswith(records)]
111
-
112
- expected = [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
113
- ' ', ' ', ' ', 'A', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
114
- ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
115
- ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
116
- ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
117
- ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
118
- ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
119
- ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
120
- ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
121
- ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
122
- ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
123
- ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
124
- ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
125
- ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
126
- ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
127
- ' ', ' ', ' ', ' ', ' ']
128
-
129
- self.assertEqual(altlocs, expected)
130
-
131
- def test_sort_chains(self):
132
- """$ pdb_sort -C data/dummy.pdb"""
133
-
134
- fpath = os.path.join(data_dir, 'dummy.pdb')
135
- sys.argv = ['', '-C', fpath]
136
-
137
- # Execute the script
138
- self.exec_module()
139
-
140
- # Validate results
141
- self.assertEqual(self.retcode, 0) # ensure the program exited OK.
142
- self.assertEqual(len(self.stdout), 200)
143
- self.assertEqual(len(self.stderr), 0) # no errors
144
-
145
- # Check order of chains
146
- records = ('ATOM', 'HETATM')
147
- chain_ids = [l[21] for l in self.stdout if l.startswith(records)]
148
-
149
- expected = ['A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
150
- 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
151
- 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
152
- 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
153
- 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'B', 'B', 'B', 'B',
154
- 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B',
155
- 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B',
156
- 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B',
157
- 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'C',
158
- 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C',
159
- 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C',
160
- 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C',
161
- 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C',
162
- 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D',
163
- 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'A', 'A', 'A', 'B',
164
- 'C', 'C', 'C', 'C', 'C']
165
-
166
- self.assertEqual(chain_ids, expected)
167
-
168
- # Check order of residue numbers did NOT change
169
- resids = [int(l[22:26]) for l in self.stdout if l.startswith(records)]
170
-
171
- expected = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
172
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3,
173
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 4, 4, 4, 4,
174
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
175
- 4, 4, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7,
176
- 7, 7, 7, 7, 7, 7, 7, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
177
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 2, 2, 2, 2, 2, 2, 2,
178
- 2, 2, 2, 2, 2, 2, 2, 2, -1, -1, -1, -1, -1, -1, -1, -1, 2,
179
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
180
- 301, 302, 303, 301, 301, 302, 303, 304, 305]
181
-
182
- self.assertEqual(resids, expected)
183
-
184
- # Check order of altlocs
185
- altlocs = [l[16] for l in self.stdout if l.startswith(records)]
186
-
187
- expected = [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
188
- ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
189
- ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
190
- ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
191
- ' ', ' ', ' ', ' ', ' ', ' ', 'A', 'B', ' ', ' ', ' ', ' ',
192
- ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
193
- ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
194
- ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
195
- ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
196
- ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
197
- ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
198
- ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
199
- ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
200
- ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
201
- ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
202
- ' ', ' ', ' ', ' ', ' ']
203
-
204
- self.assertEqual(altlocs, expected)
205
-
206
- def test_file_not_found(self):
207
- """$ pdb_sort not_existing.pdb"""
208
-
209
- # Error (file not found)
210
- afile = os.path.join(data_dir, 'not_existing.pdb')
211
- sys.argv = ['', afile]
212
-
213
- # Execute the script
214
- self.exec_module()
215
-
216
- self.assertEqual(self.retcode, 1)
217
- self.assertEqual(len(self.stdout), 0)
218
- self.assertEqual(self.stderr[0][:22],
219
- "ERROR!! File not found")
220
-
221
- @unittest.skipIf(os.getenv('SKIP_TTY_TESTS'), 'skip on GHA - no TTY')
222
- def test_helptext(self):
223
- """$ pdb_sort"""
224
-
225
- sys.argv = ['']
226
-
227
- # Execute the script
228
- self.exec_module()
229
-
230
- self.assertEqual(self.retcode, 1)
231
- self.assertEqual(len(self.stdout), 0)
232
- self.assertEqual(self.stderr, self.module.__doc__.split("\n")[:-1])
233
-
234
- def test_invalid_option(self):
235
- """$ pdb_sort -A data/dummy.pdb"""
236
-
237
- sys.argv = ['', '-A', os.path.join(data_dir, 'dummy.pdb')]
238
-
239
- # Execute the script
240
- self.exec_module()
241
-
242
- self.assertEqual(self.retcode, 1)
243
- self.assertEqual(len(self.stdout), 0)
244
- self.assertEqual(self.stderr[0][:36],
245
- "ERROR!! Sorting key is not valid: 'A")
246
-
247
-
248
- if __name__ == '__main__':
249
- from config import test_dir
250
-
251
- mpath = os.path.abspath(os.path.join(test_dir, '..'))
252
- sys.path.insert(0, mpath) # so we load dev files before any installation
253
-
254
- unittest.main()