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_head.py
DELETED
|
@@ -1,142 +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_head`.
|
|
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_head'
|
|
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_option(self):
|
|
57
|
-
"""$ pdb_head -10 data/dummy.pdb"""
|
|
58
|
-
|
|
59
|
-
# Simulate input
|
|
60
|
-
sys.argv = ['', '-10', 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)
|
|
67
|
-
self.assertEqual(len(self.stdout), 10)
|
|
68
|
-
self.assertEqual(len(self.stderr), 0)
|
|
69
|
-
|
|
70
|
-
def test_invalid_option(self):
|
|
71
|
-
"""$ pdb_head --10 data/dummy.pdb"""
|
|
72
|
-
|
|
73
|
-
# Simulate input
|
|
74
|
-
sys.argv = ['', '--10', os.path.join(data_dir, 'dummy.pdb')]
|
|
75
|
-
|
|
76
|
-
# Execute the script
|
|
77
|
-
self.exec_module()
|
|
78
|
-
|
|
79
|
-
# Validate results
|
|
80
|
-
self.assertEqual(self.retcode, 1)
|
|
81
|
-
self.assertEqual(len(self.stdout), 0)
|
|
82
|
-
self.assertEqual(self.stderr[0][:22],
|
|
83
|
-
"ERROR!! Option must be")
|
|
84
|
-
|
|
85
|
-
def test_file_not_found(self):
|
|
86
|
-
"""$ pdb_head not_existing.pdb"""
|
|
87
|
-
|
|
88
|
-
afile = os.path.join(data_dir, 'not_existing.pdb')
|
|
89
|
-
sys.argv = ['', afile]
|
|
90
|
-
|
|
91
|
-
self.exec_module()
|
|
92
|
-
|
|
93
|
-
self.assertEqual(self.retcode, 1) # exit code is 1 (error)
|
|
94
|
-
self.assertEqual(len(self.stdout), 0) # nothing written to stdout
|
|
95
|
-
self.assertEqual(self.stderr[0][:22],
|
|
96
|
-
"ERROR!! File not found") # proper error message
|
|
97
|
-
|
|
98
|
-
@unittest.skipIf(os.getenv('SKIP_TTY_TESTS'), 'skip on GHA - no TTY')
|
|
99
|
-
def test_file_missing(self):
|
|
100
|
-
"""$ pdb_head -10"""
|
|
101
|
-
|
|
102
|
-
sys.argv = ['', '-10']
|
|
103
|
-
|
|
104
|
-
self.exec_module()
|
|
105
|
-
|
|
106
|
-
self.assertEqual(self.retcode, 1)
|
|
107
|
-
self.assertEqual(len(self.stdout), 0) # no output
|
|
108
|
-
self.assertEqual(self.stderr[0],
|
|
109
|
-
"ERROR!! No data to process!")
|
|
110
|
-
|
|
111
|
-
@unittest.skipIf(os.getenv('SKIP_TTY_TESTS'), 'skip on GHA - no TTY')
|
|
112
|
-
def test_helptext(self):
|
|
113
|
-
"""$ pdb_head"""
|
|
114
|
-
|
|
115
|
-
sys.argv = ['']
|
|
116
|
-
|
|
117
|
-
self.exec_module()
|
|
118
|
-
|
|
119
|
-
self.assertEqual(self.retcode, 1) # ensure the program exited gracefully.
|
|
120
|
-
self.assertEqual(len(self.stdout), 0) # no output
|
|
121
|
-
self.assertEqual(self.stderr, self.module.__doc__.split("\n")[:-1])
|
|
122
|
-
|
|
123
|
-
def test_not_an_option(self):
|
|
124
|
-
"""$ pdb_head 20 data/dummy.pdb"""
|
|
125
|
-
|
|
126
|
-
sys.argv = ['', '20', os.path.join(data_dir, 'dummy.pdb')]
|
|
127
|
-
|
|
128
|
-
self.exec_module()
|
|
129
|
-
|
|
130
|
-
self.assertEqual(self.retcode, 1)
|
|
131
|
-
self.assertEqual(len(self.stdout), 0)
|
|
132
|
-
self.assertEqual(self.stderr[0],
|
|
133
|
-
"ERROR! First argument is not an option: '20'")
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if __name__ == '__main__':
|
|
137
|
-
from config import test_dir
|
|
138
|
-
|
|
139
|
-
mpath = os.path.abspath(os.path.join(test_dir, '..'))
|
|
140
|
-
sys.path.insert(0, mpath) # so we load dev files before any installation
|
|
141
|
-
|
|
142
|
-
unittest.main()
|
tests/test_pdb_intersect.py
DELETED
|
@@ -1,139 +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_intersect`.
|
|
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_intersect'
|
|
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_intersect data/dummy.pdb data/dummy.pdb"""
|
|
58
|
-
|
|
59
|
-
# Simulate input
|
|
60
|
-
sys.argv = ['', os.path.join(data_dir, 'dummy.pdb'),
|
|
61
|
-
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), 188) # no lines deleted. Same file.
|
|
69
|
-
self.assertEqual(len(self.stderr), 0) # no errors
|
|
70
|
-
|
|
71
|
-
atom_names = [l[12:16] for l in self.stdout]
|
|
72
|
-
|
|
73
|
-
# Test content
|
|
74
|
-
atoms_list = [' N ', ' H ', ' H2 ', ' H3 ', ' CA ', ' HA ', ' CB ',
|
|
75
|
-
' HB2', ' HB3', ' CG ', ' HG2', ' HG3', ' CD ', ' HD2',
|
|
76
|
-
' HD3', ' NE ', ' HE ', ' CZ ', ' NH1', 'HH11', 'HH12',
|
|
77
|
-
' NH2', 'HH21', 'HH22', ' C ', ' O ', ' N ', ' H ',
|
|
78
|
-
' CA ', ' HA ', ' CB ', ' HB2', ' HB3', ' CG ', ' HG2',
|
|
79
|
-
' HG3', ' CD ', ' OE1', ' OE2', ' C ', ' O ', ' N ',
|
|
80
|
-
' H ', ' CA ', ' HA ', ' CB ', ' HB1', ' HB2', ' HB3',
|
|
81
|
-
' C ', ' O ', ' ', ' N ', ' H ', ' H2 ', ' H3 ',
|
|
82
|
-
' CA ', ' CA ', ' HA ', ' CB ', ' HB2', ' HB3', ' CG ',
|
|
83
|
-
' OD1', ' ND2', 'HD21', 'HD22', ' C ', ' O ', ' N ',
|
|
84
|
-
' H ', ' CA ', ' HA ', ' CB ', ' HB2', ' HB3', ' CG ',
|
|
85
|
-
' HG2', ' HG3', ' CD ', ' HD2', ' HD3', ' NE ', ' HE ',
|
|
86
|
-
' CZ ', ' NH1', 'HH11', 'HH12', ' NH2', 'HH21', 'HH22',
|
|
87
|
-
' C ', ' O ', ' N ', ' H ', ' CA ', ' HA ', ' CB ',
|
|
88
|
-
' HB2', ' HB3', ' CG ', ' HG2', ' HG3', ' CD ', ' OE1',
|
|
89
|
-
' OE2', ' C ', ' O ', ' ', ' N ', ' H ', ' H2 ',
|
|
90
|
-
' H3 ', ' CA ', ' HA ', ' CB ', ' HB2', ' HB3', ' CG ',
|
|
91
|
-
' HG2', ' HG3', ' CD ', ' HD2', ' HD3', ' NE ', ' HE ',
|
|
92
|
-
' CZ ', ' NH1', 'HH11', 'HH12', ' NH2', 'HH21', 'HH22',
|
|
93
|
-
' C ', ' O ', ' N ', ' H ', ' CA ', ' HA ', ' CB ',
|
|
94
|
-
' HB2', ' HB3', ' CG ', ' HG2', ' HG3', ' CD ', ' OE1',
|
|
95
|
-
' OE2', ' C ', ' O ', ' N ', ' CA ', ' C ', ' O ',
|
|
96
|
-
' CB ', ' CG ', ' SD ', ' CE ', ' ', ' P ', ' OP1',
|
|
97
|
-
' OP2', " O5'", " C5'", " C4'", " O4'", " C3'", " O3'",
|
|
98
|
-
" C2'", " C1'", ' N1 ', ' C2 ', ' O2 ', ' N3 ', ' C4 ',
|
|
99
|
-
' O4 ', ' C5 ', ' C7 ', ' C6 ', 'CA ', ' O ', ' O ',
|
|
100
|
-
' O ', ' O ', ' O ', ' O ', ' O ', ' O ']
|
|
101
|
-
|
|
102
|
-
self.assertEqual(atoms_list, atom_names)
|
|
103
|
-
|
|
104
|
-
def test_file_not_found(self):
|
|
105
|
-
"""$ pdb_intersect not_existing.pdb"""
|
|
106
|
-
|
|
107
|
-
# Error (file not found)
|
|
108
|
-
afile = os.path.join(data_dir, 'not_existing.pdb')
|
|
109
|
-
sys.argv = ['', afile]
|
|
110
|
-
|
|
111
|
-
# Execute the script
|
|
112
|
-
self.exec_module()
|
|
113
|
-
|
|
114
|
-
self.assertEqual(self.retcode, 1) # exit code is 1 (error)
|
|
115
|
-
self.assertEqual(len(self.stdout), 0) # nothing written to stdout
|
|
116
|
-
self.assertEqual(self.stderr[0][:22],
|
|
117
|
-
"ERROR!! File not found") # proper error message
|
|
118
|
-
|
|
119
|
-
@unittest.skipIf(os.getenv('SKIP_TTY_TESTS'), 'skip on GHA - no TTY')
|
|
120
|
-
def test_helptext(self):
|
|
121
|
-
"""$ pdb_intersect"""
|
|
122
|
-
|
|
123
|
-
sys.argv = ['']
|
|
124
|
-
|
|
125
|
-
# Execute the script
|
|
126
|
-
self.exec_module()
|
|
127
|
-
|
|
128
|
-
self.assertEqual(self.retcode, 1) # ensure the program exited gracefully.
|
|
129
|
-
self.assertEqual(len(self.stdout), 0) # no output
|
|
130
|
-
self.assertEqual(self.stderr, self.module.__doc__.split("\n")[:-1])
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if __name__ == '__main__':
|
|
134
|
-
from config import test_dir
|
|
135
|
-
|
|
136
|
-
mpath = os.path.abspath(os.path.join(test_dir, '..'))
|
|
137
|
-
sys.path.insert(0, mpath) # so we load dev files before any installation
|
|
138
|
-
|
|
139
|
-
unittest.main()
|
tests/test_pdb_keepcoord.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_keepcoord`.
|
|
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_keepcoord'
|
|
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_keepcoord data/dummy.pdb"""
|
|
58
|
-
|
|
59
|
-
# Simulate input
|
|
60
|
-
# pdb_keepcoord 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), 190) # 13 HEADER records
|
|
69
|
-
self.assertEqual(len(self.stderr), 0) # no errors
|
|
70
|
-
|
|
71
|
-
def test_file_not_found(self):
|
|
72
|
-
"""$ pdb_keepcoord 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_keepcoord"""
|
|
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_keepcoord -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()
|
tests/test_pdb_merge.py
DELETED
|
@@ -1,106 +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_merge`.
|
|
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_merge'
|
|
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_merge data/dummy.pdb"""
|
|
58
|
-
|
|
59
|
-
# Simulate input
|
|
60
|
-
sys.argv = ['', os.path.join(data_dir, 'dummy.pdb'),
|
|
61
|
-
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), 408) # no lines deleted
|
|
69
|
-
self.assertEqual(len(self.stderr), 0) # no errors
|
|
70
|
-
|
|
71
|
-
def test_file_not_found(self):
|
|
72
|
-
"""$ pdb_merge not_existing.pdb"""
|
|
73
|
-
|
|
74
|
-
# Error (file not found)
|
|
75
|
-
afile = os.path.join(data_dir, 'not_existing.pdb')
|
|
76
|
-
sys.argv = ['', afile]
|
|
77
|
-
|
|
78
|
-
# Execute the script
|
|
79
|
-
self.exec_module()
|
|
80
|
-
|
|
81
|
-
self.assertEqual(self.retcode, 1) # exit code is 1 (error)
|
|
82
|
-
self.assertEqual(len(self.stdout), 0) # nothing written to stdout
|
|
83
|
-
self.assertEqual(self.stderr[0][:22],
|
|
84
|
-
"ERROR!! File not found") # proper error message
|
|
85
|
-
|
|
86
|
-
@unittest.skipIf(os.getenv('SKIP_TTY_TESTS'), 'skip on GHA - no TTY')
|
|
87
|
-
def test_helptext(self):
|
|
88
|
-
"""$ pdb_merge"""
|
|
89
|
-
|
|
90
|
-
sys.argv = ['']
|
|
91
|
-
|
|
92
|
-
# Execute the script
|
|
93
|
-
self.exec_module()
|
|
94
|
-
|
|
95
|
-
self.assertEqual(self.retcode, 1)
|
|
96
|
-
self.assertEqual(len(self.stdout), 0) # no output
|
|
97
|
-
self.assertEqual(self.stderr, self.module.__doc__.split("\n")[:-1])
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if __name__ == '__main__':
|
|
101
|
-
from config import test_dir
|
|
102
|
-
|
|
103
|
-
mpath = os.path.abspath(os.path.join(test_dir, '..'))
|
|
104
|
-
sys.path.insert(0, mpath) # so we load dev files before any installation
|
|
105
|
-
|
|
106
|
-
unittest.main()
|
tests/test_pdb_mkensemble.py
DELETED
|
@@ -1,132 +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_mkensemble`.
|
|
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_mkensemble'
|
|
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_mkensemble data/dummy.pdb"""
|
|
58
|
-
|
|
59
|
-
# Simulate input
|
|
60
|
-
sys.argv = ['', os.path.join(data_dir, 'dummy.pdb'),
|
|
61
|
-
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)
|
|
68
|
-
self.assertEqual(len(self.stdout), 385)
|
|
69
|
-
self.assertEqual(len(self.stderr), 0)
|
|
70
|
-
|
|
71
|
-
def test_default_multiple(self):
|
|
72
|
-
"""$ pdb_mkensemble data/dummy.pdb x20"""
|
|
73
|
-
|
|
74
|
-
# Simulate input
|
|
75
|
-
args = [os.path.join(data_dir, 'dummy.pdb') for _ in range(20)]
|
|
76
|
-
sys.argv = [''] + args
|
|
77
|
-
|
|
78
|
-
# Execute the script
|
|
79
|
-
self.exec_module()
|
|
80
|
-
|
|
81
|
-
# Validate results
|
|
82
|
-
self.assertEqual(self.retcode, 0)
|
|
83
|
-
self.assertEqual(len(self.stdout), 3823)
|
|
84
|
-
self.assertEqual(len(self.stderr), 0)
|
|
85
|
-
|
|
86
|
-
# Validate MODEL lines
|
|
87
|
-
model_no = [
|
|
88
|
-
int(line[10:14])
|
|
89
|
-
for line in self.stdout
|
|
90
|
-
if line.startswith('MODEL')
|
|
91
|
-
]
|
|
92
|
-
model_no = sorted(set(model_no))
|
|
93
|
-
n_models = len(model_no)
|
|
94
|
-
self.assertEqual(n_models, 20)
|
|
95
|
-
self.assertEqual(model_no, list(range(1, 21)))
|
|
96
|
-
|
|
97
|
-
def test_file_not_found(self):
|
|
98
|
-
"""$ pdb_mkensemble not_existing.pdb"""
|
|
99
|
-
|
|
100
|
-
# Error (file not found)
|
|
101
|
-
afile = os.path.join(data_dir, 'not_existing.pdb')
|
|
102
|
-
sys.argv = ['', afile]
|
|
103
|
-
|
|
104
|
-
# Execute the script
|
|
105
|
-
self.exec_module()
|
|
106
|
-
|
|
107
|
-
self.assertEqual(self.retcode, 1) # exit code is 1 (error)
|
|
108
|
-
self.assertEqual(len(self.stdout), 0) # nothing written to stdout
|
|
109
|
-
self.assertEqual(self.stderr[0][:22],
|
|
110
|
-
"ERROR!! File not found") # proper error message
|
|
111
|
-
|
|
112
|
-
@unittest.skipIf(os.getenv('SKIP_TTY_TESTS'), 'skip on GHA - no TTY')
|
|
113
|
-
def test_helptext(self):
|
|
114
|
-
"""$ pdb_mkensemble"""
|
|
115
|
-
|
|
116
|
-
sys.argv = ['']
|
|
117
|
-
|
|
118
|
-
# Execute the script
|
|
119
|
-
self.exec_module()
|
|
120
|
-
|
|
121
|
-
self.assertEqual(self.retcode, 1)
|
|
122
|
-
self.assertEqual(len(self.stdout), 0) # no output
|
|
123
|
-
self.assertEqual(self.stderr, self.module.__doc__.split("\n")[:-1])
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
if __name__ == '__main__':
|
|
127
|
-
from config import test_dir
|
|
128
|
-
|
|
129
|
-
mpath = os.path.abspath(os.path.join(test_dir, '..'))
|
|
130
|
-
sys.path.insert(0, mpath) # so we load dev files before any installation
|
|
131
|
-
|
|
132
|
-
unittest.main()
|