pdb-tools 2.5.0__py3-none-any.whl → 2.6.0__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.
Potentially problematic release.
This version of pdb-tools might be problematic. Click here for more details.
- {pdb_tools-2.5.0.dist-info → pdb_tools-2.6.0.dist-info}/METADATA +19 -11
- pdb_tools-2.6.0.dist-info/RECORD +55 -0
- {pdb_tools-2.5.0.dist-info → pdb_tools-2.6.0.dist-info}/WHEEL +1 -1
- {pdb_tools-2.5.0.dist-info → pdb_tools-2.6.0.dist-info}/entry_points.txt +0 -1
- {pdb_tools-2.5.0.dist-info → pdb_tools-2.6.0.dist-info}/top_level.txt +0 -1
- pdbtools/pdb_splitmodel.py +2 -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.6.0.dist-info/licenses}/LICENSE +0 -0
tests/test_pdb_rplresname.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_rplresname`.
|
|
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_rplresname'
|
|
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_rplresname -MET:DRG data/dummy.pdb"""
|
|
58
|
-
|
|
59
|
-
sys.argv = ['', '-MET:DRG', 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', 'TER'))
|
|
68
|
-
res_list = set([l[17:20] for l in self.stdout if l.startswith(records)])
|
|
69
|
-
self.assertTrue('DRG' in res_list)
|
|
70
|
-
self.assertTrue('MET' not in res_list)
|
|
71
|
-
|
|
72
|
-
def test_option_2(self):
|
|
73
|
-
"""$ pdb_rplresname -DT:DA data/dummy.pdb"""
|
|
74
|
-
|
|
75
|
-
# Simulate input
|
|
76
|
-
sys.argv = ['', '-DT:DA', 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', 'TER'))
|
|
87
|
-
res_list = set([l[17:20] for l in self.stdout if l.startswith(records)])
|
|
88
|
-
self.assertTrue(' DA' in res_list)
|
|
89
|
-
self.assertTrue(' DT' not in res_list)
|
|
90
|
-
|
|
91
|
-
def test_file_not_found(self):
|
|
92
|
-
"""$ pdb_rplresname -DA:DT not_existing.pdb"""
|
|
93
|
-
|
|
94
|
-
afile = os.path.join(data_dir, 'not_existing.pdb')
|
|
95
|
-
sys.argv = ['', '-DA:DT', 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_rplresname -DA"""
|
|
107
|
-
|
|
108
|
-
sys.argv = ['', '-DA']
|
|
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_rplresname"""
|
|
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_rplresname -HIS data/dummy.pdb"""
|
|
131
|
-
|
|
132
|
-
sys.argv = ['', '-HIS', 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: 'HIS")
|
|
140
|
-
|
|
141
|
-
def test_invalid_option_2(self):
|
|
142
|
-
"""$ pdb_rplresname -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!! Residue names must have one to three ch")
|
|
152
|
-
|
|
153
|
-
def test_not_an_option(self):
|
|
154
|
-
"""$ pdb_rplresname 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()
|
tests/test_pdb_seg.py
DELETED
|
@@ -1,160 +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_seg`.
|
|
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_seg'
|
|
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_seg 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
|
-
records = (('ATOM', 'HETATM'))
|
|
71
|
-
seg_ids = [l[72:76] for l in self.stdout if l.startswith(records)]
|
|
72
|
-
unique_seg_ids = list(set(seg_ids))
|
|
73
|
-
self.assertEqual(unique_seg_ids, [' '])
|
|
74
|
-
|
|
75
|
-
def test_two_options(self):
|
|
76
|
-
"""$ pdb_seg -X data/dummy.pdb"""
|
|
77
|
-
|
|
78
|
-
sys.argv = ['', '-X', os.path.join(data_dir, 'dummy.pdb')]
|
|
79
|
-
|
|
80
|
-
self.exec_module()
|
|
81
|
-
|
|
82
|
-
self.assertEqual(self.retcode, 0)
|
|
83
|
-
self.assertEqual(len(self.stdout), 204)
|
|
84
|
-
self.assertEqual(len(self.stderr), 0)
|
|
85
|
-
|
|
86
|
-
records = (('ATOM', 'HETATM'))
|
|
87
|
-
seg_ids = [l[72:76] for l in self.stdout if l.startswith(records)]
|
|
88
|
-
unique_seg_ids = list(set(seg_ids))
|
|
89
|
-
self.assertEqual(unique_seg_ids, ['X '])
|
|
90
|
-
|
|
91
|
-
def test_file_not_found(self):
|
|
92
|
-
"""$ pdb_seg -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_seg -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_seg"""
|
|
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(self):
|
|
130
|
-
"""$ pdb_seg -AHASX data/dummy.pdb"""
|
|
131
|
-
|
|
132
|
-
sys.argv = ['', '-AHASX', 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][:47],
|
|
139
|
-
"ERROR!! Segment id must be max. four characters")
|
|
140
|
-
|
|
141
|
-
def test_not_an_option(self):
|
|
142
|
-
"""$ pdb_seg A data/dummy.pdb"""
|
|
143
|
-
|
|
144
|
-
sys.argv = ['', 'A', 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],
|
|
151
|
-
"ERROR! First argument is not an option: 'A'")
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if __name__ == '__main__':
|
|
155
|
-
from config import test_dir
|
|
156
|
-
|
|
157
|
-
mpath = os.path.abspath(os.path.join(test_dir, '..'))
|
|
158
|
-
sys.path.insert(0, mpath) # so we load dev files before any installation
|
|
159
|
-
|
|
160
|
-
unittest.main()
|
tests/test_pdb_segxchain.py
DELETED
|
@@ -1,146 +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_segxchain`.
|
|
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_segxchain'
|
|
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_segxchain 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
|
-
records = (('ATOM', 'HETATM'))
|
|
71
|
-
chain_ids = [l[21] for l in self.stdout if l.startswith(records)]
|
|
72
|
-
|
|
73
|
-
# Test content
|
|
74
|
-
unique_chain_ids = sorted(set(chain_ids))
|
|
75
|
-
self.assertEqual(unique_chain_ids, [' ', 'A', 'Z'])
|
|
76
|
-
|
|
77
|
-
# Test order
|
|
78
|
-
chain_list = [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
|
|
79
|
-
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
|
|
80
|
-
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
|
|
81
|
-
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
|
|
82
|
-
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
|
|
83
|
-
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
|
|
84
|
-
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
|
|
85
|
-
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
|
|
86
|
-
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
|
|
87
|
-
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
|
|
88
|
-
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
|
|
89
|
-
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
|
|
90
|
-
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
|
|
91
|
-
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
|
|
92
|
-
' ', 'A', 'Z', 'Z', 'Z', 'Z', 'Z', 'Z', 'Z', 'Z', 'Z',
|
|
93
|
-
'Z', 'Z', 'Z', 'Z', 'Z', 'Z', 'Z', 'Z', 'Z', 'Z', 'Z',
|
|
94
|
-
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ']
|
|
95
|
-
|
|
96
|
-
self.assertEqual(chain_ids, chain_list)
|
|
97
|
-
|
|
98
|
-
def test_file_not_found(self):
|
|
99
|
-
"""$ pdb_segxchain not_existing.pdb"""
|
|
100
|
-
|
|
101
|
-
# Error (file not found)
|
|
102
|
-
afile = os.path.join(data_dir, 'not_existing.pdb')
|
|
103
|
-
sys.argv = ['', afile]
|
|
104
|
-
|
|
105
|
-
# Execute the script
|
|
106
|
-
self.exec_module()
|
|
107
|
-
|
|
108
|
-
self.assertEqual(self.retcode, 1) # exit code is 1 (error)
|
|
109
|
-
self.assertEqual(len(self.stdout), 0) # nothing written to stdout
|
|
110
|
-
self.assertEqual(self.stderr[0][:22],
|
|
111
|
-
"ERROR!! File not found") # proper error message
|
|
112
|
-
|
|
113
|
-
@unittest.skipIf(os.getenv('SKIP_TTY_TESTS'), 'skip on GHA - no TTY')
|
|
114
|
-
def test_helptext(self):
|
|
115
|
-
"""$ pdb_segxchain"""
|
|
116
|
-
|
|
117
|
-
sys.argv = ['']
|
|
118
|
-
|
|
119
|
-
# Execute the script
|
|
120
|
-
self.exec_module()
|
|
121
|
-
|
|
122
|
-
self.assertEqual(self.retcode, 1) # ensure the program exited gracefully.
|
|
123
|
-
self.assertEqual(len(self.stdout), 0) # no output
|
|
124
|
-
self.assertEqual(self.stderr, self.module.__doc__.split("\n")[:-1])
|
|
125
|
-
|
|
126
|
-
def test_invalid_option(self):
|
|
127
|
-
"""$ pdb_segxchain -A data/dummy.pdb"""
|
|
128
|
-
|
|
129
|
-
sys.argv = ['', '-A', os.path.join(data_dir, 'dummy.pdb')]
|
|
130
|
-
|
|
131
|
-
# Execute the script
|
|
132
|
-
self.exec_module()
|
|
133
|
-
|
|
134
|
-
self.assertEqual(self.retcode, 1)
|
|
135
|
-
self.assertEqual(len(self.stdout), 0)
|
|
136
|
-
self.assertEqual(self.stderr[0][:36],
|
|
137
|
-
"ERROR!! Script takes 1 argument, not")
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
if __name__ == '__main__':
|
|
141
|
-
from config import test_dir
|
|
142
|
-
|
|
143
|
-
mpath = os.path.abspath(os.path.join(test_dir, '..'))
|
|
144
|
-
sys.path.insert(0, mpath) # so we load dev files before any installation
|
|
145
|
-
|
|
146
|
-
unittest.main()
|