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.
- {pdb_tools-2.5.0.dist-info → pdb_tools-2.5.1.dist-info}/METADATA +19 -11
- pdb_tools-2.5.1.dist-info/RECORD +55 -0
- {pdb_tools-2.5.0.dist-info → pdb_tools-2.5.1.dist-info}/WHEEL +1 -1
- {pdb_tools-2.5.0.dist-info → pdb_tools-2.5.1.dist-info}/entry_points.txt +0 -1
- {pdb_tools-2.5.0.dist-info → pdb_tools-2.5.1.dist-info}/top_level.txt +0 -1
- pdbtools/pdb_tidy.py +17 -9
- pdb_tools-2.5.0.dist-info/RECORD +0 -105
- tests/__init__.py +0 -38
- tests/config.py +0 -25
- tests/test_pdb_b.py +0 -161
- tests/test_pdb_chain.py +0 -160
- tests/test_pdb_chainbows.py +0 -140
- tests/test_pdb_chainxseg.py +0 -156
- tests/test_pdb_chkensemble.py +0 -191
- tests/test_pdb_delchain.py +0 -165
- tests/test_pdb_delelem.py +0 -165
- tests/test_pdb_delhetatm.py +0 -115
- tests/test_pdb_delinsertion.py +0 -226
- tests/test_pdb_delres.py +0 -241
- tests/test_pdb_delresname.py +0 -171
- tests/test_pdb_element.py +0 -151
- tests/test_pdb_fixinsert.py +0 -223
- tests/test_pdb_fromcif.py +0 -124
- tests/test_pdb_gap.py +0 -125
- tests/test_pdb_head.py +0 -142
- tests/test_pdb_intersect.py +0 -139
- tests/test_pdb_keepcoord.py +0 -115
- tests/test_pdb_merge.py +0 -106
- tests/test_pdb_mkensemble.py +0 -132
- tests/test_pdb_occ.py +0 -161
- tests/test_pdb_reatom.py +0 -243
- tests/test_pdb_reres.py +0 -281
- tests/test_pdb_rplchain.py +0 -172
- tests/test_pdb_rplresname.py +0 -172
- tests/test_pdb_seg.py +0 -160
- tests/test_pdb_segxchain.py +0 -146
- tests/test_pdb_selaltloc.py +0 -943
- tests/test_pdb_selatom.py +0 -165
- tests/test_pdb_selchain.py +0 -210
- tests/test_pdb_selelem.py +0 -165
- tests/test_pdb_selhetatm.py +0 -116
- tests/test_pdb_selmodel.py +0 -165
- tests/test_pdb_selres.py +0 -257
- tests/test_pdb_selresname.py +0 -171
- tests/test_pdb_selseg.py +0 -165
- tests/test_pdb_shiftres.py +0 -241
- tests/test_pdb_sort.py +0 -254
- tests/test_pdb_splitchain.py +0 -242
- tests/test_pdb_splitmodel.py +0 -235
- tests/test_pdb_splitseg.py +0 -251
- tests/test_pdb_tidy.py +0 -312
- tests/test_pdb_tocif.py +0 -238
- tests/test_pdb_tofasta.py +0 -158
- tests/test_pdb_uniqname.py +0 -156
- tests/test_pdb_validate.py +0 -142
- tests/test_pdb_wc.py +0 -161
- tests/utils.py +0 -56
- {pdb_tools-2.5.0.dist-info → pdb_tools-2.5.1.dist-info/licenses}/LICENSE +0 -0
tests/test_pdb_reatom.py
DELETED
|
@@ -1,243 +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_reatom`.
|
|
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_reatom'
|
|
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_reatom data/dummy.pdb"""
|
|
58
|
-
|
|
59
|
-
# Simulate input
|
|
60
|
-
# pdb_reatom 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
|
-
serial_list = [int(l[6:11]) for l in self.stdout
|
|
73
|
-
if l.startswith(records)]
|
|
74
|
-
|
|
75
|
-
expected = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
|
|
76
|
-
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
|
|
77
|
-
33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
|
|
78
|
-
48, 49, 50, 51, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
|
|
79
|
-
64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
|
|
80
|
-
79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
|
|
81
|
-
94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
|
|
82
|
-
107, 108, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
|
|
83
|
-
120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131,
|
|
84
|
-
132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
|
|
85
|
-
144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155,
|
|
86
|
-
156, 157, 158, 160, 161, 162, 163, 164, 165, 166, 167, 168,
|
|
87
|
-
169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180,
|
|
88
|
-
181, 182, 183, 184, 185, 186, 187, 188]
|
|
89
|
-
|
|
90
|
-
self.assertEqual(serial_list, expected)
|
|
91
|
-
|
|
92
|
-
def test_two_options_pos(self):
|
|
93
|
-
"""$ pdb_reatom -10 data/dummy.pdb"""
|
|
94
|
-
|
|
95
|
-
# Simulate input
|
|
96
|
-
# pdb_reatom dummy.pdb
|
|
97
|
-
sys.argv = ['', '-10', os.path.join(data_dir, 'dummy.pdb')]
|
|
98
|
-
|
|
99
|
-
# Execute the script
|
|
100
|
-
self.exec_module()
|
|
101
|
-
|
|
102
|
-
# Validate results
|
|
103
|
-
self.assertEqual(self.retcode, 0) # ensure the program exited OK.
|
|
104
|
-
self.assertEqual(len(self.stdout), 204) # no lines deleted
|
|
105
|
-
self.assertEqual(len(self.stderr), 0) # no errors
|
|
106
|
-
|
|
107
|
-
records = (('ATOM', 'HETATM'))
|
|
108
|
-
serial_list = [int(l[6:11]) for l in self.stdout
|
|
109
|
-
if l.startswith(records)]
|
|
110
|
-
|
|
111
|
-
expected = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
|
|
112
|
-
25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
|
|
113
|
-
40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
|
|
114
|
-
55, 56, 57, 58, 59, 60, 62, 63, 64, 65, 66, 67, 68, 69, 70,
|
|
115
|
-
71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
|
|
116
|
-
86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
|
|
117
|
-
101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
|
|
118
|
-
113, 114, 115, 116, 117, 119, 120, 121, 122, 123, 124, 125,
|
|
119
|
-
126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
|
|
120
|
-
138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
|
|
121
|
-
150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161,
|
|
122
|
-
162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 173, 174,
|
|
123
|
-
175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186,
|
|
124
|
-
187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197]
|
|
125
|
-
|
|
126
|
-
self.assertEqual(serial_list, expected)
|
|
127
|
-
|
|
128
|
-
def test_two_options_neg(self):
|
|
129
|
-
"""$ pdb_reatom --10 data/dummy.pdb"""
|
|
130
|
-
|
|
131
|
-
sys.argv = ['', '--10', os.path.join(data_dir, 'dummy.pdb')]
|
|
132
|
-
|
|
133
|
-
self.exec_module()
|
|
134
|
-
|
|
135
|
-
self.assertEqual(self.retcode, 0)
|
|
136
|
-
self.assertEqual(len(self.stdout), 204)
|
|
137
|
-
self.assertEqual(len(self.stderr), 0)
|
|
138
|
-
|
|
139
|
-
records = (('ATOM', 'HETATM'))
|
|
140
|
-
serial_list = [int(l[6:11]) for l in self.stdout
|
|
141
|
-
if l.startswith(records)]
|
|
142
|
-
|
|
143
|
-
expected = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
|
|
144
|
-
6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
|
|
145
|
-
22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
|
|
146
|
-
37, 38, 39, 40, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
|
|
147
|
-
53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
|
|
148
|
-
68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
|
|
149
|
-
83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97,
|
|
150
|
-
99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
|
|
151
|
-
111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
|
|
152
|
-
123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
|
|
153
|
-
135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146,
|
|
154
|
-
147, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
|
|
155
|
-
160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171,
|
|
156
|
-
172, 173, 174, 175, 176, 177]
|
|
157
|
-
|
|
158
|
-
self.assertEqual(serial_list, expected)
|
|
159
|
-
|
|
160
|
-
def test_too_many_atoms(self):
|
|
161
|
-
"""$ pdb_reatom -99998 data/dummy.pdb"""
|
|
162
|
-
|
|
163
|
-
sys.argv = ['', '-99998', os.path.join(data_dir, 'dummy.pdb')]
|
|
164
|
-
|
|
165
|
-
self.exec_module()
|
|
166
|
-
|
|
167
|
-
self.assertEqual(self.retcode, 1)
|
|
168
|
-
self.assertEqual(len(self.stdout), 0)
|
|
169
|
-
self.assertEqual(len(self.stderr), 1)
|
|
170
|
-
|
|
171
|
-
self.assertEqual(self.stderr[0][:22],
|
|
172
|
-
"Cannot set atom serial") # proper error message
|
|
173
|
-
|
|
174
|
-
def test_file_not_found(self):
|
|
175
|
-
"""$ pdb_reatom -10 not_existing.pdb"""
|
|
176
|
-
|
|
177
|
-
afile = os.path.join(data_dir, 'not_existing.pdb')
|
|
178
|
-
sys.argv = ['', '-10', afile]
|
|
179
|
-
|
|
180
|
-
self.exec_module()
|
|
181
|
-
|
|
182
|
-
self.assertEqual(self.retcode, 1) # exit code is 1 (error)
|
|
183
|
-
self.assertEqual(len(self.stdout), 0) # nothing written to stdout
|
|
184
|
-
self.assertEqual(self.stderr[0][:22],
|
|
185
|
-
"ERROR!! File not found") # proper error message
|
|
186
|
-
|
|
187
|
-
@unittest.skipIf(os.getenv('SKIP_TTY_TESTS'), 'skip on GHA - no TTY')
|
|
188
|
-
def test_file_missing(self):
|
|
189
|
-
"""$ pdb_reatom -10"""
|
|
190
|
-
|
|
191
|
-
sys.argv = ['', '-10']
|
|
192
|
-
|
|
193
|
-
self.exec_module()
|
|
194
|
-
|
|
195
|
-
self.assertEqual(self.retcode, 1)
|
|
196
|
-
self.assertEqual(len(self.stdout), 0) # no output
|
|
197
|
-
self.assertEqual(self.stderr[0],
|
|
198
|
-
"ERROR!! No data to process!")
|
|
199
|
-
|
|
200
|
-
@unittest.skipIf(os.getenv('SKIP_TTY_TESTS'), 'skip on GHA - no TTY')
|
|
201
|
-
def test_helptext(self):
|
|
202
|
-
"""$ pdb_reatom"""
|
|
203
|
-
|
|
204
|
-
sys.argv = ['']
|
|
205
|
-
|
|
206
|
-
self.exec_module()
|
|
207
|
-
|
|
208
|
-
self.assertEqual(self.retcode, 1) # ensure the program exited gracefully.
|
|
209
|
-
self.assertEqual(len(self.stdout), 0) # no output
|
|
210
|
-
self.assertEqual(self.stderr, self.module.__doc__.split("\n")[:-1])
|
|
211
|
-
|
|
212
|
-
def test_invalid_option(self):
|
|
213
|
-
"""$ pdb_reatom -A data/dummy.pdb"""
|
|
214
|
-
|
|
215
|
-
sys.argv = ['', '-A', os.path.join(data_dir, 'dummy.pdb')]
|
|
216
|
-
|
|
217
|
-
self.exec_module()
|
|
218
|
-
|
|
219
|
-
self.assertEqual(self.retcode, 1)
|
|
220
|
-
self.assertEqual(len(self.stdout), 0)
|
|
221
|
-
self.assertEqual(self.stderr[0][:47],
|
|
222
|
-
"ERROR!! You provided an invalid atom serial num")
|
|
223
|
-
|
|
224
|
-
def test_not_an_option(self):
|
|
225
|
-
"""$ pdb_reatom 11 data/dummy.pdb"""
|
|
226
|
-
|
|
227
|
-
sys.argv = ['', '11', os.path.join(data_dir, 'dummy.pdb')]
|
|
228
|
-
|
|
229
|
-
self.exec_module()
|
|
230
|
-
|
|
231
|
-
self.assertEqual(self.retcode, 1)
|
|
232
|
-
self.assertEqual(len(self.stdout), 0)
|
|
233
|
-
self.assertEqual(self.stderr[0],
|
|
234
|
-
"ERROR! First argument is not an option: '11'")
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
if __name__ == '__main__':
|
|
238
|
-
from config import test_dir
|
|
239
|
-
|
|
240
|
-
mpath = os.path.abspath(os.path.join(test_dir, '..'))
|
|
241
|
-
sys.path.insert(0, mpath) # so we load dev files before any installation
|
|
242
|
-
|
|
243
|
-
unittest.main()
|
tests/test_pdb_reres.py
DELETED
|
@@ -1,281 +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_reres`.
|
|
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_reres'
|
|
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_reres data/dummy.pdb"""
|
|
58
|
-
|
|
59
|
-
# Simulate input
|
|
60
|
-
# pdb_reres 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 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
76
|
-
1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
77
|
-
2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
|
78
|
-
4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
|
79
|
-
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6,
|
|
80
|
-
6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
|
81
|
-
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8,
|
|
82
|
-
8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10,
|
|
83
|
-
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
|
84
|
-
10, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
|
|
85
|
-
|
|
86
|
-
self.assertEqual(resid_list, expected)
|
|
87
|
-
|
|
88
|
-
def test_two_options_pos(self):
|
|
89
|
-
"""$ pdb_reres -10 data/dummy.pdb"""
|
|
90
|
-
|
|
91
|
-
# Simulate input
|
|
92
|
-
# pdb_reres 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 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
|
108
|
-
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11,
|
|
109
|
-
11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12,
|
|
110
|
-
12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13,
|
|
111
|
-
13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14,
|
|
112
|
-
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
|
|
113
|
-
14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
|
|
114
|
-
15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
|
|
115
|
-
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17,
|
|
116
|
-
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18,
|
|
117
|
-
18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19,
|
|
118
|
-
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 21, 22, 23,
|
|
119
|
-
24, 25, 26, 27, 28]
|
|
120
|
-
|
|
121
|
-
self.assertEqual(resid_list, expected)
|
|
122
|
-
|
|
123
|
-
def test_two_options_neg(self):
|
|
124
|
-
"""$ pdb_reres --10 data/dummy.pdb"""
|
|
125
|
-
|
|
126
|
-
sys.argv = ['', '--10', os.path.join(data_dir, 'dummy.pdb')]
|
|
127
|
-
|
|
128
|
-
self.exec_module()
|
|
129
|
-
|
|
130
|
-
self.assertEqual(self.retcode, 0)
|
|
131
|
-
self.assertEqual(len(self.stdout), 204)
|
|
132
|
-
self.assertEqual(len(self.stderr), 0)
|
|
133
|
-
|
|
134
|
-
records = (('ATOM', 'HETATM'))
|
|
135
|
-
resid_list = [int(l[22:26]) for l in self.stdout
|
|
136
|
-
if l.startswith(records)]
|
|
137
|
-
|
|
138
|
-
expected = [-10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10,
|
|
139
|
-
-10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10,
|
|
140
|
-
-10, -10, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
|
|
141
|
-
-9, -9, -9, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -7, -7,
|
|
142
|
-
-7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7,
|
|
143
|
-
-6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6,
|
|
144
|
-
-6, -6, -6, -6, -6, -6, -6, -6, -6, -5, -5, -5, -5, -5, -5,
|
|
145
|
-
-5, -5, -5, -5, -5, -5, -5, -5, -5, -4, -4, -4, -4, -4, -4,
|
|
146
|
-
-4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
|
|
147
|
-
-4, -4, -4, -4, -4, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3,
|
|
148
|
-
-3, -3, -3, -3, -3, -2, -2, -2, -2, -2, -2, -2, -2, -1, -1,
|
|
149
|
-
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
150
|
-
-1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8]
|
|
151
|
-
|
|
152
|
-
self.assertEqual(resid_list, expected)
|
|
153
|
-
|
|
154
|
-
def test_three_with_single_res_models(self):
|
|
155
|
-
"""$ pdb_reres -4 data/ensemble.OK.pdb"""
|
|
156
|
-
sys.argv = ['', '-4', os.path.join(data_dir, 'ensemble_OK.pdb')]
|
|
157
|
-
|
|
158
|
-
self.exec_module()
|
|
159
|
-
|
|
160
|
-
self.assertEqual(self.retcode, 0)
|
|
161
|
-
self.assertEqual(len(self.stdout), 11)
|
|
162
|
-
self.assertEqual(len(self.stderr), 0)
|
|
163
|
-
|
|
164
|
-
records = ('ATOM', 'HETATM')
|
|
165
|
-
resid_list = [int(l[22:26]) for l in self.stdout
|
|
166
|
-
if l.startswith(records)]
|
|
167
|
-
|
|
168
|
-
expected = [4, 4, 4, 4]
|
|
169
|
-
self.assertEqual(resid_list, expected)
|
|
170
|
-
|
|
171
|
-
models = ('MODEL',)
|
|
172
|
-
models_int = [int(l[5:]) for l in self.stdout if l.startswith(models)]
|
|
173
|
-
models_expected = [1, 2]
|
|
174
|
-
self.assertEqual(models_int, models_expected)
|
|
175
|
-
|
|
176
|
-
def test_three_with_models(self):
|
|
177
|
-
"""$ pdb_reres -4 data/ensemble.OK.pdb"""
|
|
178
|
-
sys.argv = ['', '-4', os.path.join(data_dir, 'ensemble_more_OK.pdb')]
|
|
179
|
-
|
|
180
|
-
self.exec_module()
|
|
181
|
-
|
|
182
|
-
self.assertEqual(self.retcode, 0)
|
|
183
|
-
self.assertEqual(len(self.stdout), 13)
|
|
184
|
-
self.assertEqual(len(self.stderr), 0)
|
|
185
|
-
|
|
186
|
-
records = ('ATOM', 'HETATM')
|
|
187
|
-
resid_list = [int(l[22:26]) for l in self.stdout
|
|
188
|
-
if l.startswith(records)]
|
|
189
|
-
|
|
190
|
-
expected = [4, 4, 5, 5, 4, 4]
|
|
191
|
-
self.assertEqual(resid_list, expected)
|
|
192
|
-
|
|
193
|
-
models = ('MODEL',)
|
|
194
|
-
models_int = [int(l[5:]) for l in self.stdout if l.startswith(models)]
|
|
195
|
-
models_expected = [1, 2]
|
|
196
|
-
self.assertEqual(models_int, models_expected)
|
|
197
|
-
|
|
198
|
-
def test_too_many_residues(self):
|
|
199
|
-
"""$ pdb_reres -9998 data/dummy.pdb"""
|
|
200
|
-
|
|
201
|
-
sys.argv = ['', '-9998', os.path.join(data_dir, 'dummy.pdb')]
|
|
202
|
-
|
|
203
|
-
self.exec_module()
|
|
204
|
-
|
|
205
|
-
self.assertEqual(self.retcode, 1)
|
|
206
|
-
self.assertEqual(len(self.stdout), 0)
|
|
207
|
-
self.assertEqual(len(self.stderr), 1)
|
|
208
|
-
|
|
209
|
-
self.assertEqual(self.stderr[0][:22],
|
|
210
|
-
"Cannot set residue num") # proper error message
|
|
211
|
-
|
|
212
|
-
def test_file_not_found(self):
|
|
213
|
-
"""$ pdb_reres -10 not_existing.pdb"""
|
|
214
|
-
|
|
215
|
-
afile = os.path.join(data_dir, 'not_existing.pdb')
|
|
216
|
-
sys.argv = ['', '-10', afile]
|
|
217
|
-
|
|
218
|
-
self.exec_module()
|
|
219
|
-
|
|
220
|
-
self.assertEqual(self.retcode, 1) # exit code is 1 (error)
|
|
221
|
-
self.assertEqual(len(self.stdout), 0) # nothing written to stdout
|
|
222
|
-
self.assertEqual(self.stderr[0][:22],
|
|
223
|
-
"ERROR!! File not found") # proper error message
|
|
224
|
-
|
|
225
|
-
@unittest.skipIf(os.getenv('SKIP_TTY_TESTS'), 'skip on GHA - no TTY')
|
|
226
|
-
def test_file_missing(self):
|
|
227
|
-
"""$ pdb_reres -10"""
|
|
228
|
-
|
|
229
|
-
sys.argv = ['', '-10']
|
|
230
|
-
|
|
231
|
-
self.exec_module()
|
|
232
|
-
|
|
233
|
-
self.assertEqual(self.retcode, 1)
|
|
234
|
-
self.assertEqual(len(self.stdout), 0) # no output
|
|
235
|
-
self.assertEqual(self.stderr[0],
|
|
236
|
-
"ERROR!! No data to process!")
|
|
237
|
-
|
|
238
|
-
@unittest.skipIf(os.getenv('SKIP_TTY_TESTS'), 'skip on GHA - no TTY')
|
|
239
|
-
def test_helptext(self):
|
|
240
|
-
"""$ pdb_reres"""
|
|
241
|
-
|
|
242
|
-
sys.argv = ['']
|
|
243
|
-
|
|
244
|
-
self.exec_module()
|
|
245
|
-
|
|
246
|
-
self.assertEqual(self.retcode, 1) # ensure the program exited gracefully.
|
|
247
|
-
self.assertEqual(len(self.stdout), 0) # no output
|
|
248
|
-
self.assertEqual(self.stderr, self.module.__doc__.split("\n")[:-1])
|
|
249
|
-
|
|
250
|
-
def test_invalid_option(self):
|
|
251
|
-
"""$ pdb_reres -A data/dummy.pdb"""
|
|
252
|
-
|
|
253
|
-
sys.argv = ['', '-A', os.path.join(data_dir, 'dummy.pdb')]
|
|
254
|
-
|
|
255
|
-
self.exec_module()
|
|
256
|
-
|
|
257
|
-
self.assertEqual(self.retcode, 1)
|
|
258
|
-
self.assertEqual(len(self.stdout), 0)
|
|
259
|
-
self.assertEqual(self.stderr[0][:47],
|
|
260
|
-
"ERROR!! You provided an invalid residue number:")
|
|
261
|
-
|
|
262
|
-
def test_not_an_option(self):
|
|
263
|
-
"""$ pdb_reres 11 data/dummy.pdb"""
|
|
264
|
-
|
|
265
|
-
sys.argv = ['', '11', os.path.join(data_dir, 'dummy.pdb')]
|
|
266
|
-
|
|
267
|
-
self.exec_module()
|
|
268
|
-
|
|
269
|
-
self.assertEqual(self.retcode, 1)
|
|
270
|
-
self.assertEqual(len(self.stdout), 0)
|
|
271
|
-
self.assertEqual(self.stderr[0],
|
|
272
|
-
"ERROR! First argument is not an option: '11'")
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
if __name__ == '__main__':
|
|
276
|
-
from config import test_dir
|
|
277
|
-
|
|
278
|
-
mpath = os.path.abspath(os.path.join(test_dir, '..'))
|
|
279
|
-
sys.path.insert(0, mpath) # so we load dev files before any installation
|
|
280
|
-
|
|
281
|
-
unittest.main()
|
tests/test_pdb_rplchain.py
DELETED
|
@@ -1,172 +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_rplchain`.
|
|
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_rplchain'
|
|
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_option_1(self):
|
|
57
|
-
"""$ pdb_rplchain -D:Z data/dummy.pdb"""
|
|
58
|
-
|
|
59
|
-
sys.argv = ['', '-D:Z', os.path.join(data_dir, 'dummy.pdb')]
|
|
60
|
-
|
|
61
|
-
self.exec_module()
|
|
62
|
-
|
|
63
|
-
self.assertEqual(self.retcode, 0)
|
|
64
|
-
self.assertEqual(len(self.stdout), 204)
|
|
65
|
-
self.assertEqual(len(self.stderr), 0)
|
|
66
|
-
|
|
67
|
-
records = (('ATOM', 'HETATM'))
|
|
68
|
-
chain_ids = set([l[21] for l in self.stdout if l.startswith(records)])
|
|
69
|
-
self.assertTrue('Z' in chain_ids)
|
|
70
|
-
self.assertTrue('D' not in chain_ids)
|
|
71
|
-
|
|
72
|
-
def test_option_2(self):
|
|
73
|
-
"""$ pdb_rplchain -A: data/dummy.pdb"""
|
|
74
|
-
|
|
75
|
-
# Simulate input
|
|
76
|
-
sys.argv = ['', '-A:', os.path.join(data_dir, 'dummy.pdb')]
|
|
77
|
-
|
|
78
|
-
# Execute the script
|
|
79
|
-
self.exec_module()
|
|
80
|
-
|
|
81
|
-
# Validate results
|
|
82
|
-
self.assertEqual(self.retcode, 0) # ensure the program exited OK.
|
|
83
|
-
self.assertEqual(len(self.stdout), 204) # no lines deleted
|
|
84
|
-
self.assertEqual(len(self.stderr), 0) # no errors
|
|
85
|
-
|
|
86
|
-
records = (('ATOM', 'HETATM'))
|
|
87
|
-
chain_ids = set([l[21] for l in self.stdout if l.startswith(records)])
|
|
88
|
-
self.assertTrue(' ' in chain_ids)
|
|
89
|
-
self.assertTrue('A' not in chain_ids)
|
|
90
|
-
|
|
91
|
-
def test_file_not_found(self):
|
|
92
|
-
"""$ pdb_rplchain -A not_existing.pdb"""
|
|
93
|
-
|
|
94
|
-
afile = os.path.join(data_dir, 'not_existing.pdb')
|
|
95
|
-
sys.argv = ['', '-A', afile]
|
|
96
|
-
|
|
97
|
-
self.exec_module()
|
|
98
|
-
|
|
99
|
-
self.assertEqual(self.retcode, 1) # exit code is 1 (error)
|
|
100
|
-
self.assertEqual(len(self.stdout), 0) # nothing written to stdout
|
|
101
|
-
self.assertEqual(self.stderr[0][:22],
|
|
102
|
-
"ERROR!! File not found") # proper error message
|
|
103
|
-
|
|
104
|
-
@unittest.skipIf(os.getenv('SKIP_TTY_TESTS'), 'skip on GHA - no TTY')
|
|
105
|
-
def test_file_missing(self):
|
|
106
|
-
"""$ pdb_rplchain -A"""
|
|
107
|
-
|
|
108
|
-
sys.argv = ['', '-A']
|
|
109
|
-
|
|
110
|
-
self.exec_module()
|
|
111
|
-
|
|
112
|
-
self.assertEqual(self.retcode, 1)
|
|
113
|
-
self.assertEqual(len(self.stdout), 0) # no output
|
|
114
|
-
self.assertEqual(self.stderr[0],
|
|
115
|
-
"ERROR!! No data to process!")
|
|
116
|
-
|
|
117
|
-
@unittest.skipIf(os.getenv('SKIP_TTY_TESTS'), 'skip on GHA - no TTY')
|
|
118
|
-
def test_helptext(self):
|
|
119
|
-
"""$ pdb_rplchain"""
|
|
120
|
-
|
|
121
|
-
sys.argv = ['']
|
|
122
|
-
|
|
123
|
-
self.exec_module()
|
|
124
|
-
|
|
125
|
-
self.assertEqual(self.retcode, 1) # ensure the program exited gracefully.
|
|
126
|
-
self.assertEqual(len(self.stdout), 0) # no output
|
|
127
|
-
self.assertEqual(self.stderr, self.module.__doc__.split("\n")[:-1])
|
|
128
|
-
|
|
129
|
-
def test_invalid_option_1(self):
|
|
130
|
-
"""$ pdb_rplchain -AH data/dummy.pdb"""
|
|
131
|
-
|
|
132
|
-
sys.argv = ['', '-AH', os.path.join(data_dir, 'dummy.pdb')]
|
|
133
|
-
|
|
134
|
-
self.exec_module()
|
|
135
|
-
|
|
136
|
-
self.assertEqual(self.retcode, 1)
|
|
137
|
-
self.assertEqual(len(self.stdout), 0)
|
|
138
|
-
self.assertEqual(self.stderr[0][:34],
|
|
139
|
-
"ERROR!! Invalid option value: 'AH'")
|
|
140
|
-
|
|
141
|
-
def test_invalid_option_2(self):
|
|
142
|
-
"""$ pdb_rplchain -AH: data/dummy.pdb"""
|
|
143
|
-
|
|
144
|
-
sys.argv = ['', '-AH:', os.path.join(data_dir, 'dummy.pdb')]
|
|
145
|
-
|
|
146
|
-
self.exec_module()
|
|
147
|
-
|
|
148
|
-
self.assertEqual(self.retcode, 1)
|
|
149
|
-
self.assertEqual(len(self.stdout), 0)
|
|
150
|
-
self.assertEqual(self.stderr[0][:47],
|
|
151
|
-
"ERROR!! Chain identifiers must be a single char")
|
|
152
|
-
|
|
153
|
-
def test_not_an_option(self):
|
|
154
|
-
"""$ pdb_rplchain A data/dummy.pdb"""
|
|
155
|
-
|
|
156
|
-
sys.argv = ['', 'A', os.path.join(data_dir, 'dummy.pdb')]
|
|
157
|
-
|
|
158
|
-
self.exec_module()
|
|
159
|
-
|
|
160
|
-
self.assertEqual(self.retcode, 1)
|
|
161
|
-
self.assertEqual(len(self.stdout), 0)
|
|
162
|
-
self.assertEqual(self.stderr[0],
|
|
163
|
-
"ERROR! First argument is not an option: 'A'")
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
if __name__ == '__main__':
|
|
167
|
-
from config import test_dir
|
|
168
|
-
|
|
169
|
-
mpath = os.path.abspath(os.path.join(test_dir, '..'))
|
|
170
|
-
sys.path.insert(0, mpath) # so we load dev files before any installation
|
|
171
|
-
|
|
172
|
-
unittest.main()
|