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
tests/test_pdb_element.py DELETED
@@ -1,151 +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_element`.
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_element'
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_element data/dummy.pdb"""
58
-
59
- # Simulate input
60
- sys.argv = ['', os.path.join(data_dir, 'dummy.pdb')]
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), 204) # no lines deleted
68
- self.assertEqual(len(self.stderr), 0) # no errors
69
-
70
- element_cols = [l[76:78] for l in self.stdout]
71
-
72
- # Test content
73
- assigned = [l for l in element_cols if l.strip()]
74
- self.assertEqual(len(assigned), 185) # ignore TER/END & headers
75
-
76
- # Test order
77
- element_list = [' ', ' ', ' ', ' ', ' ', ' ', '', '', '', '', '',
78
- '', '', ' N', ' H', ' H', ' H', ' C', ' H', ' C', ' H',
79
- ' H', ' C', ' H', ' H', ' C', ' H', ' H', ' N', ' H',
80
- ' C', ' N', ' H', ' H', ' N', ' H', ' H', ' C', ' O',
81
- ' N', ' H', ' C', ' H', ' C', ' H', ' H', ' C', ' H',
82
- ' H', ' C', ' O', ' O', ' C', ' O', ' N', ' H', ' C',
83
- ' H', ' C', ' H', ' H', ' H', ' C', ' O', '', ' N',
84
- ' H', ' H', ' H', ' C', ' C', ' H', ' C', ' H', ' H',
85
- ' C', ' O', ' N', ' H', ' H', ' C', ' O', ' N', ' H',
86
- ' C', ' H', ' C', ' H', ' H', ' C', ' H', ' H', ' C',
87
- ' H', ' H', ' N', ' H', ' C', ' N', ' H', ' H', ' N',
88
- ' H', ' H', ' C', ' O', ' N', ' H', ' C', ' H', ' C',
89
- ' H', ' H', ' C', ' H', ' H', ' C', ' O', ' O', ' C',
90
- ' O', ' ', ' N', ' H', ' H', ' H', ' C', ' H', ' C',
91
- ' H', ' H', ' C', ' H', ' H', ' C', ' H', ' H', ' N',
92
- ' H', ' C', ' N', ' H', ' H', ' N', ' H', ' H', ' C',
93
- ' O', ' N', ' H', ' C', ' H', ' C', ' H', ' H', ' C',
94
- ' H', ' H', ' C', ' O', ' O', ' C', ' O', ' N', ' C',
95
- ' C', ' O', ' C', ' C', ' S', ' C', ' ', ' P', ' O',
96
- ' O', ' O', ' C', ' C', ' O', ' C', ' O', ' C', ' C',
97
- ' N', ' C', ' O', ' N', ' C', ' O', ' C', ' C', ' C',
98
- 'CA', ' O', ' O', ' O', ' O', ' O', ' O', ' O', ' O',
99
- ' ', '', '']
100
-
101
- self.assertEqual(element_cols, element_list)
102
-
103
- def test_file_not_found(self):
104
- """$ pdb_element not_existing.pdb"""
105
-
106
- # Error (file not found)
107
- afile = os.path.join(data_dir, 'not_existing.pdb')
108
- sys.argv = ['', afile]
109
-
110
- # Execute the script
111
- self.exec_module()
112
-
113
- self.assertEqual(self.retcode, 1) # exit code is 1 (error)
114
- self.assertEqual(len(self.stdout), 0) # nothing written to stdout
115
- self.assertEqual(self.stderr[0][:22],
116
- "ERROR!! File not found") # proper error message
117
-
118
- @unittest.skipIf(os.getenv('SKIP_TTY_TESTS'), 'skip on GHA - no TTY')
119
- def test_helptext(self):
120
- """$ pdb_element"""
121
-
122
- sys.argv = ['']
123
-
124
- # Execute the script
125
- self.exec_module()
126
-
127
- self.assertEqual(self.retcode, 1) # ensure the program exited gracefully.
128
- self.assertEqual(len(self.stdout), 0) # no output
129
- self.assertEqual(self.stderr, self.module.__doc__.split("\n")[:-1])
130
-
131
- def test_invalid_option(self):
132
- """$ pdb_element -A data/dummy.pdb"""
133
-
134
- sys.argv = ['', '-A', os.path.join(data_dir, 'dummy.pdb')]
135
-
136
- # Execute the script
137
- self.exec_module()
138
-
139
- self.assertEqual(self.retcode, 1)
140
- self.assertEqual(len(self.stdout), 0)
141
- self.assertEqual(self.stderr[0][:36],
142
- "ERROR!! Script takes 1 argument, not")
143
-
144
-
145
- if __name__ == '__main__':
146
- from config import test_dir
147
-
148
- mpath = os.path.abspath(os.path.join(test_dir, '..'))
149
- sys.path.insert(0, mpath) # so we load dev files before any installation
150
-
151
- unittest.main()
@@ -1,223 +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_fixinsert`.
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_fixinsert'
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_fixinsert data/dummy_insertions.pdb"""
58
-
59
- # Simulate input
60
- # pdb_fixinsert dummy_insertions.pdb
61
- sys.argv = ['', os.path.join(data_dir, 'dummy_insertions.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), 255) # no lines deleted
69
- self.assertEqual(len(self.stderr), 0) # no errors
70
-
71
- # Check if we do not have any insertions
72
- records = (('ATOM', 'HETATM', 'TER'))
73
- icodes = set(l[26] for l in self.stdout if l.startswith(records))
74
- self.assertEqual(icodes, set(' '))
75
-
76
- # Check numbering was corrected
77
- resid = [int(l[22:26]) for l in self.stdout if l.startswith(records)]
78
- expected = [
79
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
80
- 4, 4, 4, 5, 5, 5, 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8,
81
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7, 7, 7,
82
- 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9,
83
- 9, 9, 9, 9, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
84
- 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
85
- 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5,
86
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
87
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -1, -1, -1, -1, -1, -1,
88
- -1, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
89
- 2, 301, 302, 303, 301, 301, 302, 303, 304, 305
90
- ]
91
- self.assertEqual(resid, expected)
92
-
93
- def test_select_insertion(self):
94
- """$ pdb_fixinsert -A1 data/dummy_insertions.pdb"""
95
-
96
- sys.argv = ['', '-A1', os.path.join(data_dir, 'dummy_insertions.pdb')]
97
-
98
- self.exec_module()
99
-
100
- self.assertEqual(self.retcode, 0)
101
- self.assertEqual(len(self.stdout), 255)
102
- self.assertEqual(len(self.stderr), 0)
103
-
104
- records = (('ATOM', 'HETATM', 'TER'))
105
-
106
- # Check the insertions were deleted specifically
107
- for line in self.stdout:
108
- if line.startswith(records):
109
- icode = line[26]
110
- resid = int(line[22:26])
111
- if line[17:26] == 'ARG B 4':
112
- self.assertIn(icode, ('A', 'B'))
113
- self.assertEqual(resid, 4)
114
- elif line[17:26] == 'GLY B 4':
115
- self.assertEqual(icode, ' ')
116
- self.assertEqual(resid, 4)
117
- elif line[17:26] == 'ASN A 1':
118
- self.assertEqual(icode, ' ')
119
- self.assertEqual(resid, 1)
120
- elif line[17:26] == 'GLY A 1':
121
- self.assertEqual(icode, ' ')
122
- self.assertEqual(resid, 2) # should have renumbered
123
-
124
- # Check numbering was corrected overall
125
- resid = [int(l[22:26]) for l in self.stdout if l.startswith(records)]
126
- expected = [
127
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
128
- 4, 4, 4, 5, 5, 5, 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8,
129
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7, 7, 7,
130
- 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9,
131
- 9, 9, 9, 9, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
132
- 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
133
- 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5,
134
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
135
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -1, -1, -1, -1, -1, -1,
136
- -1, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
137
- 2, 301, 302, 303, 301, 301, 302, 303, 304, 305
138
- ]
139
-
140
- self.assertEqual(resid, expected)
141
-
142
- def test_file_not_found(self):
143
- """$ pdb_fixinsert not_existing.pdb"""
144
-
145
- afile = os.path.join(data_dir, 'not_existing.pdb')
146
- sys.argv = ['', afile]
147
-
148
- self.exec_module()
149
-
150
- self.assertEqual(self.retcode, 1) # exit code is 1 (error)
151
- self.assertEqual(len(self.stdout), 0) # nothing written to stdout
152
- self.assertEqual(self.stderr[0][:22],
153
- "ERROR!! File not found") # proper error message
154
-
155
- @unittest.skipIf(os.getenv('SKIP_TTY_TESTS'), 'skip on GHA - no TTY')
156
- def test_file_missing(self):
157
- """$ pdb_fixinsert -A89"""
158
-
159
- sys.argv = ['', '-A89']
160
-
161
- self.exec_module()
162
-
163
- self.assertEqual(self.retcode, 1)
164
- self.assertEqual(len(self.stdout), 0) # no output
165
- self.assertEqual(self.stderr[0],
166
- "ERROR!! No data to process!")
167
-
168
- @unittest.skipIf(os.getenv('SKIP_TTY_TESTS'), 'skip on GHA - no TTY')
169
- def test_helptext(self):
170
- """$ pdb_fixinsert"""
171
-
172
- sys.argv = ['']
173
-
174
- self.exec_module()
175
-
176
- self.assertEqual(self.retcode, 1) # ensure the program exited gracefully.
177
- self.assertEqual(len(self.stdout), 0) # no output
178
- self.assertEqual(self.stderr, self.module.__doc__.split("\n")[:-1])
179
-
180
- def test_invalid_option(self):
181
- """$ pdb_fixinsert -A data/dummy_insertions.pdb"""
182
-
183
- sys.argv = ['', '-A', os.path.join(data_dir, 'dummy_insertions.pdb')]
184
-
185
- self.exec_module()
186
-
187
- self.assertEqual(self.retcode, 1)
188
- self.assertEqual(len(self.stdout), 0)
189
- self.assertEqual(self.stderr[0][:27],
190
- "ERROR!! Option invalid: 'A'")
191
-
192
- def test_invalid_option_2(self):
193
- """$ pdb_fixinsert -12A data/dummy_insertions.pdb"""
194
-
195
- sys.argv = ['', '-12A', os.path.join(data_dir, 'dummy_insertions.pdb')]
196
-
197
- self.exec_module()
198
-
199
- self.assertEqual(self.retcode, 1)
200
- self.assertEqual(len(self.stdout), 0)
201
- self.assertEqual(self.stderr[0][:39],
202
- "ERROR!! Option invalid: '12A'")
203
-
204
- def test_not_an_option(self):
205
- """$ pdb_fixinsert 20 data/dummy_insertions.pdb"""
206
-
207
- sys.argv = ['', '20', os.path.join(data_dir, 'dummy_insertions.pdb')]
208
-
209
- self.exec_module()
210
-
211
- self.assertEqual(self.retcode, 1)
212
- self.assertEqual(len(self.stdout), 0)
213
- self.assertEqual(self.stderr[0],
214
- "ERROR! First argument is not an option: '20'")
215
-
216
-
217
- if __name__ == '__main__':
218
- from config import test_dir
219
-
220
- mpath = os.path.abspath(os.path.join(test_dir, '..'))
221
- sys.path.insert(0, mpath) # so we load dev files before any installation
222
-
223
- unittest.main()
tests/test_pdb_fromcif.py DELETED
@@ -1,124 +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_fromcif`.
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_fromcif'
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_conversion(self):
57
- """$ pdb_fromcif data/ensemble_OK.pdb"""
58
-
59
- fpath = os.path.join(data_dir, 'ensemble_OK.cif')
60
- sys.argv = ['', fpath]
61
-
62
- # Execute the script
63
- self.exec_module()
64
-
65
- # Validate results
66
- self.assertEqual(self.retcode, 0)
67
- self.assertEqual(len(self.stdout), 9)
68
- self.assertEqual(len(self.stderr), 0)
69
-
70
- # Check order of records
71
- expected = ['MODEL ', 'ATOM ', 'ATOM ', 'ENDMDL',
72
- 'MODEL ', 'ATOM ', 'ATOM ', 'ENDMDL', 'END ']
73
- records = [l[:6] for l in self.stdout]
74
- self.assertEqual(records, expected)
75
-
76
- def test_file_not_found(self):
77
- """$ pdb_fromcif not_existing.pdb"""
78
-
79
- # Error (file not found)
80
- afile = os.path.join(data_dir, 'not_existing.pdb')
81
- sys.argv = ['', afile]
82
-
83
- # Execute the script
84
- self.exec_module()
85
-
86
- self.assertEqual(self.retcode, 1)
87
- self.assertEqual(len(self.stdout), 0)
88
- self.assertEqual(self.stderr[0][:22],
89
- "ERROR!! File not found")
90
-
91
- @unittest.skipIf(os.getenv('SKIP_TTY_TESTS'), 'skip on GHA - no TTY')
92
- def test_helptext(self):
93
- """$ pdb_fromcif"""
94
-
95
- sys.argv = ['']
96
-
97
- # Execute the script
98
- self.exec_module()
99
-
100
- self.assertEqual(self.retcode, 1)
101
- self.assertEqual(len(self.stdout), 0)
102
- self.assertEqual(self.stderr, self.module.__doc__.split("\n")[:-1])
103
-
104
- def test_invalid_option(self):
105
- """$ pdb_fromcif -A data/dummy.pdb"""
106
-
107
- sys.argv = ['', '-A', os.path.join(data_dir, 'dummy.pdb')]
108
-
109
- # Execute the script
110
- self.exec_module()
111
-
112
- self.assertEqual(self.retcode, 1)
113
- self.assertEqual(len(self.stdout), 0)
114
- self.assertEqual(self.stderr[0][:36],
115
- "ERROR!! Script takes 1 argument, not")
116
-
117
-
118
- if __name__ == '__main__':
119
- from config import test_dir
120
-
121
- mpath = os.path.abspath(os.path.join(test_dir, '..'))
122
- sys.path.insert(0, mpath) # so we load dev files before any installation
123
-
124
- unittest.main()
tests/test_pdb_gap.py DELETED
@@ -1,125 +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_gap`.
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_gap'
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_gap data/dummy.pdb"""
58
-
59
- # Simulate input
60
- sys.argv = ['', os.path.join(data_dir, 'dummy.pdb')]
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), 5) # no lines deleted
68
- self.assertEqual(len(self.stderr), 0) # no errors
69
-
70
- self.assertEqual(self.stdout,
71
- ["B:ARG4 < Seq. Gap > B:GLU6",
72
- "A:ASN1 < 9.42A > A:ASN1",
73
- "C:ARG5 < Seq. Gap > C:GLU2",
74
- "C:GLU2 < 95.75A > C:MET-1",
75
- "Found 4 gap(s) in the structure"])
76
-
77
- def test_file_not_found(self):
78
- """$ pdb_gap not_existing.pdb"""
79
-
80
- # Error (file not found)
81
- afile = os.path.join(data_dir, 'not_existing.pdb')
82
- sys.argv = ['', afile]
83
-
84
- # Execute the script
85
- self.exec_module()
86
-
87
- self.assertEqual(self.retcode, 1) # exit code is 1 (error)
88
- self.assertEqual(len(self.stdout), 0) # nothing written to stdout
89
- self.assertEqual(self.stderr[0][:22],
90
- "ERROR!! File not found") # proper error message
91
-
92
- @unittest.skipIf(os.getenv('SKIP_TTY_TESTS'), 'skip on GHA - no TTY')
93
- def test_helptext(self):
94
- """$ pdb_gap"""
95
-
96
- sys.argv = ['']
97
-
98
- # Execute the script
99
- self.exec_module()
100
-
101
- self.assertEqual(self.retcode, 1) # ensure the program exited gracefully.
102
- self.assertEqual(len(self.stdout), 0) # no output
103
- self.assertEqual(self.stderr, self.module.__doc__.split("\n")[:-1])
104
-
105
- def test_invalid_option(self):
106
- """$ pdb_gap -A data/dummy.pdb"""
107
-
108
- sys.argv = ['', '-A', os.path.join(data_dir, 'dummy.pdb')]
109
-
110
- # Execute the script
111
- self.exec_module()
112
-
113
- self.assertEqual(self.retcode, 1)
114
- self.assertEqual(len(self.stdout), 0)
115
- self.assertEqual(self.stderr[0][:36],
116
- "ERROR!! Script takes 1 argument, not")
117
-
118
-
119
- if __name__ == '__main__':
120
- from config import test_dir
121
-
122
- mpath = os.path.abspath(os.path.join(test_dir, '..'))
123
- sys.path.insert(0, mpath) # so we load dev files before any installation
124
-
125
- unittest.main()