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.
- {pdb_tools-2.4.12.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.4.12.dist-info → pdb_tools-2.5.1.dist-info}/WHEEL +1 -1
- {pdb_tools-2.4.12.dist-info → pdb_tools-2.5.1.dist-info}/entry_points.txt +1 -1
- {pdb_tools-2.4.12.dist-info → pdb_tools-2.5.1.dist-info}/top_level.txt +0 -1
- pdbtools/pdb_selmodel.py +194 -0
- pdbtools/pdb_tidy.py +17 -9
- pdb_tools-2.4.12.dist-info/RECORD +0 -103
- 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_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.4.12.dist-info → pdb_tools-2.5.1.dist-info/licenses}/LICENSE +0 -0
tests/test_pdb_chkensemble.py
DELETED
|
@@ -1,191 +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_chkensemble`.
|
|
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_chkensemble'
|
|
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_valid_ensemble(self):
|
|
57
|
-
"""$ pdb_chkensemble data/ensemble_OK.pdb"""
|
|
58
|
-
|
|
59
|
-
fpath = os.path.join(data_dir, 'ensemble_OK.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), 1)
|
|
68
|
-
self.assertEqual(len(self.stderr), 0) # no errors
|
|
69
|
-
|
|
70
|
-
self.assertEqual(self.stdout[0],
|
|
71
|
-
"Ensemble of 2 models *seems* OK")
|
|
72
|
-
|
|
73
|
-
def test_ensemble_diffatom(self):
|
|
74
|
-
"""$ pdb_chkensemble data/ensemble_error_1.pdb"""
|
|
75
|
-
|
|
76
|
-
fpath = os.path.join(data_dir, 'ensemble_error_1.pdb')
|
|
77
|
-
sys.argv = ['', fpath]
|
|
78
|
-
|
|
79
|
-
# Execute the script
|
|
80
|
-
self.exec_module()
|
|
81
|
-
|
|
82
|
-
# Validate results
|
|
83
|
-
self.assertEqual(self.retcode, 1)
|
|
84
|
-
self.assertEqual(len(self.stdout), 0)
|
|
85
|
-
self.assertEqual(len(self.stderr), 3)
|
|
86
|
-
|
|
87
|
-
self.assertEqual(self.stderr,
|
|
88
|
-
["Models 1 and 2 differ:",
|
|
89
|
-
"Atoms in model 1 only:",
|
|
90
|
-
" 2 H ASN A 1 "])
|
|
91
|
-
|
|
92
|
-
def test_ensemble_nomodel(self):
|
|
93
|
-
"""$ pdb_chkensemble data/ensemble_error_2.pdb"""
|
|
94
|
-
|
|
95
|
-
fpath = os.path.join(data_dir, 'ensemble_error_2.pdb')
|
|
96
|
-
sys.argv = ['', fpath]
|
|
97
|
-
|
|
98
|
-
# Execute the script
|
|
99
|
-
self.exec_module()
|
|
100
|
-
|
|
101
|
-
# Validate results
|
|
102
|
-
self.assertEqual(self.retcode, 1)
|
|
103
|
-
self.assertEqual(len(self.stdout), 0)
|
|
104
|
-
self.assertEqual(len(self.stderr), 1)
|
|
105
|
-
|
|
106
|
-
self.assertEqual(self.stderr[0],
|
|
107
|
-
"ERROR!! MODEL record missing before ATOM at line '3'")
|
|
108
|
-
|
|
109
|
-
def test_ensemble_noendmdl(self):
|
|
110
|
-
"""$ pdb_chkensemble data/ensemble_error_3.pdb"""
|
|
111
|
-
|
|
112
|
-
fpath = os.path.join(data_dir, 'ensemble_error_3.pdb')
|
|
113
|
-
sys.argv = ['', fpath]
|
|
114
|
-
|
|
115
|
-
# Execute the script
|
|
116
|
-
self.exec_module()
|
|
117
|
-
|
|
118
|
-
# Validate results
|
|
119
|
-
self.assertEqual(self.retcode, 1)
|
|
120
|
-
self.assertEqual(len(self.stdout), 0)
|
|
121
|
-
self.assertEqual(len(self.stderr), 1)
|
|
122
|
-
|
|
123
|
-
self.assertEqual(self.stderr[0],
|
|
124
|
-
"ERROR!! ENDMDL record missing at line '10'")
|
|
125
|
-
|
|
126
|
-
def test_ensemble_noendmdl2(self):
|
|
127
|
-
"""$ pdb_chkensemble data/ensemble_error_4.pdb"""
|
|
128
|
-
|
|
129
|
-
fpath = os.path.join(data_dir, 'ensemble_error_4.pdb')
|
|
130
|
-
sys.argv = ['', fpath]
|
|
131
|
-
|
|
132
|
-
# Execute the script
|
|
133
|
-
self.exec_module()
|
|
134
|
-
|
|
135
|
-
# Validate results
|
|
136
|
-
self.assertEqual(self.retcode, 1)
|
|
137
|
-
self.assertEqual(len(self.stdout), 0)
|
|
138
|
-
self.assertEqual(len(self.stderr), 1)
|
|
139
|
-
|
|
140
|
-
self.assertEqual(self.stderr[0],
|
|
141
|
-
"ERROR!! MODEL record found before ENDMDL at line '6'")
|
|
142
|
-
|
|
143
|
-
def test_file_not_found(self):
|
|
144
|
-
"""$ pdb_chkensemble not_existing.pdb"""
|
|
145
|
-
|
|
146
|
-
# Error (file not found)
|
|
147
|
-
afile = os.path.join(data_dir, 'not_existing.pdb')
|
|
148
|
-
sys.argv = ['', afile]
|
|
149
|
-
|
|
150
|
-
# Execute the script
|
|
151
|
-
self.exec_module()
|
|
152
|
-
|
|
153
|
-
self.assertEqual(self.retcode, 1)
|
|
154
|
-
self.assertEqual(len(self.stdout), 0)
|
|
155
|
-
self.assertEqual(self.stderr[0][:22],
|
|
156
|
-
"ERROR!! File not found")
|
|
157
|
-
|
|
158
|
-
@unittest.skipIf(os.getenv('SKIP_TTY_TESTS'), 'skip on GHA - no TTY')
|
|
159
|
-
def test_helptext(self):
|
|
160
|
-
"""$ pdb_chkensemble"""
|
|
161
|
-
|
|
162
|
-
sys.argv = ['']
|
|
163
|
-
|
|
164
|
-
# Execute the script
|
|
165
|
-
self.exec_module()
|
|
166
|
-
|
|
167
|
-
self.assertEqual(self.retcode, 1)
|
|
168
|
-
self.assertEqual(len(self.stdout), 0)
|
|
169
|
-
self.assertEqual(self.stderr, self.module.__doc__.split("\n")[:-1])
|
|
170
|
-
|
|
171
|
-
def test_invalid_option(self):
|
|
172
|
-
"""$ pdb_chkensemble -A data/dummy.pdb"""
|
|
173
|
-
|
|
174
|
-
sys.argv = ['', '-A', os.path.join(data_dir, 'dummy.pdb')]
|
|
175
|
-
|
|
176
|
-
# Execute the script
|
|
177
|
-
self.exec_module()
|
|
178
|
-
|
|
179
|
-
self.assertEqual(self.retcode, 1)
|
|
180
|
-
self.assertEqual(len(self.stdout), 0)
|
|
181
|
-
self.assertEqual(self.stderr[0][:36],
|
|
182
|
-
"ERROR!! Script takes 1 argument, not")
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
if __name__ == '__main__':
|
|
186
|
-
from config import test_dir
|
|
187
|
-
|
|
188
|
-
mpath = os.path.abspath(os.path.join(test_dir, '..'))
|
|
189
|
-
sys.path.insert(0, mpath) # so we load dev files before any installation
|
|
190
|
-
|
|
191
|
-
unittest.main()
|
tests/test_pdb_delchain.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_delchain`.
|
|
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_delchain'
|
|
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_delchain -A data/dummy.pdb"""
|
|
58
|
-
|
|
59
|
-
# Simulate input
|
|
60
|
-
# pdb_delchain dummy.pdb
|
|
61
|
-
sys.argv = ['', '-A', 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), 144) # deleted chain A (60 atoms)
|
|
69
|
-
self.assertEqual(len(self.stderr), 0) # no errors
|
|
70
|
-
|
|
71
|
-
def test_multiple(self):
|
|
72
|
-
"""
|
|
73
|
-
$ pdb_delchain -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) # ensure the program exited OK.
|
|
81
|
-
self.assertEqual(len(self.stdout), 91) # deleted chains A+B (153 atoms)
|
|
82
|
-
self.assertEqual(len(self.stderr), 0) # no errors
|
|
83
|
-
|
|
84
|
-
def test_file_not_found(self):
|
|
85
|
-
"""$ pdb_delchain 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_delchain -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_delchain"""
|
|
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_delchain 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 chain ide")
|
|
133
|
-
|
|
134
|
-
def test_invalid_option_2(self):
|
|
135
|
-
"""$ pdb_delchain -AB data/dummy.pdb"""
|
|
136
|
-
|
|
137
|
-
sys.argv = ['', '-AB', 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!! Chain identifier name is invalid")
|
|
145
|
-
|
|
146
|
-
def test_not_an_option(self):
|
|
147
|
-
"""$ pdb_delchain 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()
|
tests/test_pdb_delelem.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_delelem`.
|
|
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_delelem'
|
|
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_delelem -H data/dummy.pdb"""
|
|
58
|
-
|
|
59
|
-
# Simulate input
|
|
60
|
-
# pdb_delelem dummy.pdb
|
|
61
|
-
sys.argv = ['', '-H', 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), 130) # deleted 74 protons
|
|
69
|
-
self.assertEqual(len(self.stderr), 0) # no errors
|
|
70
|
-
|
|
71
|
-
def test_multiple(self):
|
|
72
|
-
"""
|
|
73
|
-
$ pdb_delelem -C,H data/dummy.pdb
|
|
74
|
-
"""
|
|
75
|
-
|
|
76
|
-
sys.argv = ['', '-C,H', os.path.join(data_dir, 'dummy.pdb')]
|
|
77
|
-
|
|
78
|
-
self.exec_module()
|
|
79
|
-
|
|
80
|
-
self.assertEqual(self.retcode, 0) # ensure the program exited OK.
|
|
81
|
-
self.assertEqual(len(self.stdout), 89) # deleted protons and 41 carbons
|
|
82
|
-
self.assertEqual(len(self.stderr), 0) # no errors
|
|
83
|
-
|
|
84
|
-
def test_file_not_found(self):
|
|
85
|
-
"""$ pdb_delelem 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_delelem -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_delelem"""
|
|
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_delelem 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 element n")
|
|
133
|
-
|
|
134
|
-
def test_invalid_option_2(self):
|
|
135
|
-
"""$ pdb_delelem -ABD data/dummy.pdb"""
|
|
136
|
-
|
|
137
|
-
sys.argv = ['', '-ABC', 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][:32],
|
|
144
|
-
"ERROR!! Element name is invalid:")
|
|
145
|
-
|
|
146
|
-
def test_not_an_option(self):
|
|
147
|
-
"""$ pdb_delelem 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()
|
tests/test_pdb_delhetatm.py
DELETED
|
@@ -1,115 +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_delhetatm`.
|
|
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_delhetatm'
|
|
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_delhetatm data/dummy.pdb"""
|
|
58
|
-
|
|
59
|
-
# Simulate input
|
|
60
|
-
# pdb_delhetatm 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), 194) # 9 HETATM records + 2 CONECT
|
|
69
|
-
self.assertEqual(len(self.stderr), 0) # no errors
|
|
70
|
-
|
|
71
|
-
def test_file_not_found(self):
|
|
72
|
-
"""$ pdb_delhetatm not_existing.pdb"""
|
|
73
|
-
|
|
74
|
-
afile = os.path.join(data_dir, 'not_existing.pdb')
|
|
75
|
-
sys.argv = ['', afile]
|
|
76
|
-
|
|
77
|
-
self.exec_module()
|
|
78
|
-
|
|
79
|
-
self.assertEqual(self.retcode, 1) # exit code is 1 (error)
|
|
80
|
-
self.assertEqual(len(self.stdout), 0) # nothing written to stdout
|
|
81
|
-
self.assertEqual(self.stderr[0][:22],
|
|
82
|
-
"ERROR!! File not found") # proper error message
|
|
83
|
-
|
|
84
|
-
@unittest.skipIf(os.getenv('SKIP_TTY_TESTS'), 'skip on GHA - no TTY')
|
|
85
|
-
def test_helptext(self):
|
|
86
|
-
"""$ pdb_delhetatm"""
|
|
87
|
-
|
|
88
|
-
sys.argv = ['']
|
|
89
|
-
|
|
90
|
-
self.exec_module()
|
|
91
|
-
|
|
92
|
-
self.assertEqual(self.retcode, 1) # ensure the program exited gracefully.
|
|
93
|
-
self.assertEqual(len(self.stdout), 0) # no output
|
|
94
|
-
self.assertEqual(self.stderr, self.module.__doc__.split("\n")[:-1])
|
|
95
|
-
|
|
96
|
-
def test_invalid_option(self):
|
|
97
|
-
"""$ pdb_delhetatm -A data/dummy.pdb"""
|
|
98
|
-
|
|
99
|
-
sys.argv = ['', '-A', os.path.join(data_dir, 'dummy.pdb')]
|
|
100
|
-
|
|
101
|
-
self.exec_module()
|
|
102
|
-
|
|
103
|
-
self.assertEqual(self.retcode, 1)
|
|
104
|
-
self.assertEqual(len(self.stdout), 0)
|
|
105
|
-
self.assertEqual(self.stderr[0][:36],
|
|
106
|
-
"ERROR!! Script takes 1 argument, not")
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if __name__ == '__main__':
|
|
110
|
-
from config import test_dir
|
|
111
|
-
|
|
112
|
-
mpath = os.path.abspath(os.path.join(test_dir, '..'))
|
|
113
|
-
sys.path.insert(0, mpath) # so we load dev files before any installation
|
|
114
|
-
|
|
115
|
-
unittest.main()
|