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
@@ -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()
@@ -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()
@@ -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()
tests/test_pdb_occ.py DELETED
@@ -1,161 +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_occ`.
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_occ'
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_occ data/dummy.pdb"""
58
-
59
- # Simulate input
60
- # pdb_occ dummy.pdb
61
- sys.argv = ['', os.path.join(data_dir, 'dummy.pdb')]
62
-
63
- # Execute the script
64
- self.exec_module()
65
-
66
- # Validate results
67
- self.assertEqual(self.retcode, 0) # ensure the program exited OK.
68
- self.assertEqual(len(self.stdout), 204) # no lines deleted
69
- self.assertEqual(len(self.stderr), 0) # no errors
70
-
71
- records = (('ATOM', 'HETATM'))
72
- occ_list = [l[54:60] for l in self.stdout if l.startswith(records)]
73
- unique_occ = list(set(map(float, occ_list)))
74
- self.assertEqual(unique_occ, [1.0]) # all occ values changed
75
-
76
- def test_two_options(self):
77
- """$ pdb_occ -0.5 data/dummy.pdb"""
78
-
79
- sys.argv = ['', '-0.5', os.path.join(data_dir, 'dummy.pdb')]
80
-
81
- self.exec_module()
82
-
83
- self.assertEqual(self.retcode, 0)
84
- self.assertEqual(len(self.stdout), 204)
85
- self.assertEqual(len(self.stderr), 0)
86
-
87
- records = (('ATOM', 'HETATM'))
88
- occ_list = [l[54:60] for l in self.stdout if l.startswith(records)]
89
- unique_occ = list(set(map(float, occ_list)))
90
- self.assertEqual(unique_occ, [0.5])
91
-
92
- def test_file_not_found(self):
93
- """$ pdb_occ not_existing.pdb"""
94
-
95
- afile = os.path.join(data_dir, 'not_existing.pdb')
96
- sys.argv = ['', '-1.0', afile]
97
-
98
- self.exec_module()
99
-
100
- self.assertEqual(self.retcode, 1) # exit code is 1 (error)
101
- self.assertEqual(len(self.stdout), 0) # nothing written to stdout
102
- self.assertEqual(self.stderr[0][:22],
103
- "ERROR!! File not found") # proper error message
104
-
105
- @unittest.skipIf(os.getenv('SKIP_TTY_TESTS'), 'skip on GHA - no TTY')
106
- def test_file_missing(self):
107
- """$ pdb_occ -1.0"""
108
-
109
- sys.argv = ['', '-1.0']
110
-
111
- self.exec_module()
112
-
113
- self.assertEqual(self.retcode, 1)
114
- self.assertEqual(len(self.stdout), 0) # no output
115
- self.assertEqual(self.stderr[0],
116
- "ERROR!! No data to process!")
117
-
118
- @unittest.skipIf(os.getenv('SKIP_TTY_TESTS'), 'skip on GHA - no TTY')
119
- def test_helptext(self):
120
- """$ pdb_occ"""
121
-
122
- sys.argv = ['']
123
-
124
- self.exec_module()
125
-
126
- self.assertEqual(self.retcode, 1) # ensure the program exited gracefully.
127
- self.assertEqual(len(self.stdout), 0) # no output
128
- self.assertEqual(self.stderr, self.module.__doc__.split("\n")[:-1])
129
-
130
- def test_invalid_option(self):
131
- """$ pdb_occ -A data/dummy.pdb"""
132
-
133
- sys.argv = ['', '-A', os.path.join(data_dir, 'dummy.pdb')]
134
-
135
- self.exec_module()
136
-
137
- self.assertEqual(self.retcode, 1)
138
- self.assertEqual(len(self.stdout), 0)
139
- self.assertEqual(self.stderr[0][:47],
140
- "ERROR!! You provided an invalid occupancy value")
141
-
142
- def test_not_an_option(self):
143
- """$ pdb_occ 20 data/dummy.pdb"""
144
-
145
- sys.argv = ['', '20', os.path.join(data_dir, 'dummy.pdb')]
146
-
147
- self.exec_module()
148
-
149
- self.assertEqual(self.retcode, 1)
150
- self.assertEqual(len(self.stdout), 0)
151
- self.assertEqual(self.stderr[0],
152
- "ERROR! First argument is not an option: '20'")
153
-
154
-
155
- if __name__ == '__main__':
156
- from config import test_dir
157
-
158
- mpath = os.path.abspath(os.path.join(test_dir, '..'))
159
- sys.path.insert(0, mpath) # so we load dev files before any installation
160
-
161
- unittest.main()