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.
Files changed (58) hide show
  1. {pdb_tools-2.5.0.dist-info → pdb_tools-2.5.1.dist-info}/METADATA +19 -11
  2. pdb_tools-2.5.1.dist-info/RECORD +55 -0
  3. {pdb_tools-2.5.0.dist-info → pdb_tools-2.5.1.dist-info}/WHEEL +1 -1
  4. {pdb_tools-2.5.0.dist-info → pdb_tools-2.5.1.dist-info}/entry_points.txt +0 -1
  5. {pdb_tools-2.5.0.dist-info → pdb_tools-2.5.1.dist-info}/top_level.txt +0 -1
  6. pdbtools/pdb_tidy.py +17 -9
  7. pdb_tools-2.5.0.dist-info/RECORD +0 -105
  8. tests/__init__.py +0 -38
  9. tests/config.py +0 -25
  10. tests/test_pdb_b.py +0 -161
  11. tests/test_pdb_chain.py +0 -160
  12. tests/test_pdb_chainbows.py +0 -140
  13. tests/test_pdb_chainxseg.py +0 -156
  14. tests/test_pdb_chkensemble.py +0 -191
  15. tests/test_pdb_delchain.py +0 -165
  16. tests/test_pdb_delelem.py +0 -165
  17. tests/test_pdb_delhetatm.py +0 -115
  18. tests/test_pdb_delinsertion.py +0 -226
  19. tests/test_pdb_delres.py +0 -241
  20. tests/test_pdb_delresname.py +0 -171
  21. tests/test_pdb_element.py +0 -151
  22. tests/test_pdb_fixinsert.py +0 -223
  23. tests/test_pdb_fromcif.py +0 -124
  24. tests/test_pdb_gap.py +0 -125
  25. tests/test_pdb_head.py +0 -142
  26. tests/test_pdb_intersect.py +0 -139
  27. tests/test_pdb_keepcoord.py +0 -115
  28. tests/test_pdb_merge.py +0 -106
  29. tests/test_pdb_mkensemble.py +0 -132
  30. tests/test_pdb_occ.py +0 -161
  31. tests/test_pdb_reatom.py +0 -243
  32. tests/test_pdb_reres.py +0 -281
  33. tests/test_pdb_rplchain.py +0 -172
  34. tests/test_pdb_rplresname.py +0 -172
  35. tests/test_pdb_seg.py +0 -160
  36. tests/test_pdb_segxchain.py +0 -146
  37. tests/test_pdb_selaltloc.py +0 -943
  38. tests/test_pdb_selatom.py +0 -165
  39. tests/test_pdb_selchain.py +0 -210
  40. tests/test_pdb_selelem.py +0 -165
  41. tests/test_pdb_selhetatm.py +0 -116
  42. tests/test_pdb_selmodel.py +0 -165
  43. tests/test_pdb_selres.py +0 -257
  44. tests/test_pdb_selresname.py +0 -171
  45. tests/test_pdb_selseg.py +0 -165
  46. tests/test_pdb_shiftres.py +0 -241
  47. tests/test_pdb_sort.py +0 -254
  48. tests/test_pdb_splitchain.py +0 -242
  49. tests/test_pdb_splitmodel.py +0 -235
  50. tests/test_pdb_splitseg.py +0 -251
  51. tests/test_pdb_tidy.py +0 -312
  52. tests/test_pdb_tocif.py +0 -238
  53. tests/test_pdb_tofasta.py +0 -158
  54. tests/test_pdb_uniqname.py +0 -156
  55. tests/test_pdb_validate.py +0 -142
  56. tests/test_pdb_wc.py +0 -161
  57. tests/utils.py +0 -56
  58. {pdb_tools-2.5.0.dist-info → pdb_tools-2.5.1.dist-info/licenses}/LICENSE +0 -0
tests/test_pdb_chain.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_chain`.
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_chain'
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_chain 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
- unique_chain_ids = list(set(chain_ids))
73
- self.assertEqual(unique_chain_ids, [' '])
74
-
75
- def test_two_options(self):
76
- """$ pdb_chain -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
- chain_ids = [l[21] for l in self.stdout if l.startswith(records)]
88
- unique_chain_ids = list(set(chain_ids))
89
- self.assertEqual(unique_chain_ids, ['X'])
90
-
91
- def test_file_not_found(self):
92
- """$ pdb_chain -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_chain -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_chain"""
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_chain -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][:47],
139
- "ERROR!! Chain identifiers must be a single char")
140
-
141
- def test_not_an_option(self):
142
- """$ pdb_chain 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()
@@ -1,140 +0,0 @@
1
- #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
- #
4
- # Copyright 2020 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_chainbows`.
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_chainbows'
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_chainbows data/dummy.pdb"""
58
-
59
- fpath = os.path.join(data_dir, 'dummy.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
- # CONECTs are ignored by issue #72, expected only 204 lines
68
- self.assertEqual(len(self.stdout), 204)
69
- self.assertEqual(len(self.stderr), 0) # no warnings/errors
70
-
71
- # Check chains were reassigned properly
72
- expected = ['A'] * 51 + ['B'] * 56 + ['C'] * 49 + ['D'] * 20
73
- chains = [
74
- l[21] for l in self.stdout if l.startswith('ATOM')
75
- ]
76
- self.assertEqual(chains, expected)
77
-
78
- # Check TERs
79
- expected = ['A', 'B', 'C']
80
- chains = [
81
- l[21] for l in self.stdout if l.startswith('TER')
82
- ]
83
- self.assertEqual(chains, expected)
84
-
85
- # Check HETATM were reassigned properly
86
- expected = ['B', 'B', 'B', 'A', 'C', 'C', 'C', 'C', 'C']
87
- chains = [
88
- l[21] for l in self.stdout if l.startswith('HETATM')
89
- ]
90
- self.assertEqual(chains, expected)
91
-
92
- def test_file_not_found(self):
93
- """$ pdb_chainbows not_existing.pdb"""
94
-
95
- # Error (file not found)
96
- afile = os.path.join(data_dir, 'not_existing.pdb')
97
- sys.argv = ['', afile]
98
-
99
- # Execute the script
100
- self.exec_module()
101
-
102
- self.assertEqual(self.retcode, 1)
103
- self.assertEqual(len(self.stdout), 0)
104
- self.assertEqual(self.stderr[0][:22],
105
- "ERROR!! File not found")
106
-
107
- @unittest.skipIf(os.getenv('SKIP_TTY_TESTS'), 'skip on GHA - no TTY')
108
- def test_helptext(self):
109
- """$ pdb_chainbows"""
110
-
111
- sys.argv = ['']
112
-
113
- # Execute the script
114
- self.exec_module()
115
-
116
- self.assertEqual(self.retcode, 1)
117
- self.assertEqual(len(self.stdout), 0)
118
- self.assertEqual(self.stderr, self.module.__doc__.split("\n")[:-1])
119
-
120
- def test_invalid_option(self):
121
- """$ pdb_chainbows -A data/dummy.pdb"""
122
-
123
- sys.argv = ['', '-A', os.path.join(data_dir, 'dummy.pdb')]
124
-
125
- # Execute the script
126
- self.exec_module()
127
-
128
- self.assertEqual(self.retcode, 1)
129
- self.assertEqual(len(self.stdout), 0)
130
- self.assertEqual(self.stderr[0][:36],
131
- "ERROR!! Script takes 1 argument, not")
132
-
133
-
134
- if __name__ == '__main__':
135
- from config import test_dir
136
-
137
- mpath = os.path.abspath(os.path.join(test_dir, '..'))
138
- sys.path.insert(0, mpath) # so we load dev files before any installation
139
-
140
- unittest.main()
@@ -1,156 +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_chainxseg`.
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_chainxseg'
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_chainxseg 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[72:76] for l in self.stdout if l.startswith(records)]
72
-
73
- # Test content
74
- unique_chain_ids = sorted(set(map(str.strip, chain_ids)))
75
- self.assertEqual(unique_chain_ids, ['A', 'B', 'C', 'D'])
76
-
77
- # Test order
78
- segid_list = ['B ', 'B ', 'B ', 'B ', 'B ', 'B ', 'B ',
79
- 'B ', 'B ', 'B ', 'B ', 'B ', 'B ', 'B ',
80
- 'B ', 'B ', 'B ', 'B ', 'B ', 'B ', 'B ',
81
- 'B ', 'B ', 'B ', 'B ', 'B ', 'B ', 'B ',
82
- 'B ', 'B ', 'B ', 'B ', 'B ', 'B ', 'B ',
83
- 'B ', 'B ', 'B ', 'B ', 'B ', 'B ', 'B ',
84
- 'B ', 'B ', 'B ', 'B ', 'B ', 'B ', 'B ',
85
- 'B ', 'B ', 'A ', 'A ', 'A ', 'A ', 'A ',
86
- 'A ', 'A ', 'A ', 'A ', 'A ', 'A ', 'A ',
87
- 'A ', 'A ', 'A ', 'A ', 'A ', 'A ', 'A ',
88
- 'A ', 'A ', 'A ', 'A ', 'A ', 'A ', 'A ',
89
- 'A ', 'A ', 'A ', 'A ', 'A ', 'A ', 'A ',
90
- 'A ', 'A ', 'A ', 'A ', 'A ', 'A ', 'A ',
91
- 'A ', 'A ', 'A ', 'A ', 'A ', 'A ', 'A ',
92
- 'A ', 'A ', 'A ', 'A ', 'A ', 'A ', 'A ',
93
- 'A ', 'A ', 'C ', 'C ', 'C ', 'C ', 'C ',
94
- 'C ', 'C ', 'C ', 'C ', 'C ', 'C ', 'C ',
95
- 'C ', 'C ', 'C ', 'C ', 'C ', 'C ', 'C ',
96
- 'C ', 'C ', 'C ', 'C ', 'C ', 'C ', 'C ',
97
- 'C ', 'C ', 'C ', 'C ', 'C ', 'C ', 'C ',
98
- 'C ', 'C ', 'C ', 'C ', 'C ', 'C ', 'C ',
99
- 'C ', 'C ', 'C ', 'C ', 'C ', 'C ', 'C ',
100
- 'C ', 'C ', 'D ', 'D ', 'D ', 'D ', 'D ',
101
- 'D ', 'D ', 'D ', 'D ', 'D ', 'D ', 'D ',
102
- 'D ', 'D ', 'D ', 'D ', 'D ', 'D ', 'D ',
103
- 'D ', 'A ', 'A ', 'A ', 'B ', 'C ', 'C ',
104
- 'C ', 'C ', 'C ']
105
-
106
- self.assertEqual(chain_ids, segid_list)
107
-
108
- def test_file_not_found(self):
109
- """$ pdb_chainxseg not_existing.pdb"""
110
-
111
- # Error (file not found)
112
- afile = os.path.join(data_dir, 'not_existing.pdb')
113
- sys.argv = ['', afile]
114
-
115
- # Execute the script
116
- self.exec_module()
117
-
118
- self.assertEqual(self.retcode, 1) # exit code is 1 (error)
119
- self.assertEqual(len(self.stdout), 0) # nothing written to stdout
120
- self.assertEqual(self.stderr[0][:22],
121
- "ERROR!! File not found") # proper error message
122
-
123
- @unittest.skipIf(os.getenv('SKIP_TTY_TESTS'), 'skip on GHA - no TTY')
124
- def test_helptext(self):
125
- """$ pdb_chainxseg"""
126
-
127
- sys.argv = ['']
128
-
129
- # Execute the script
130
- self.exec_module()
131
-
132
- self.assertEqual(self.retcode, 1) # ensure the program exited gracefully.
133
- self.assertEqual(len(self.stdout), 0) # no output
134
- self.assertEqual(self.stderr, self.module.__doc__.split("\n")[:-1])
135
-
136
- def test_invalid_option(self):
137
- """$ pdb_chainxseg -A data/dummy.pdb"""
138
-
139
- sys.argv = ['', '-A', os.path.join(data_dir, 'dummy.pdb')]
140
-
141
- # Execute the script
142
- self.exec_module()
143
-
144
- self.assertEqual(self.retcode, 1)
145
- self.assertEqual(len(self.stdout), 0)
146
- self.assertEqual(self.stderr[0][:36],
147
- "ERROR!! Script takes 1 argument, not")
148
-
149
-
150
- if __name__ == '__main__':
151
- from config import test_dir
152
-
153
- mpath = os.path.abspath(os.path.join(test_dir, '..'))
154
- sys.path.insert(0, mpath) # so we load dev files before any installation
155
-
156
- unittest.main()
@@ -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()