psdi-data-conversion 0.0.23__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.
- psdi_data_conversion/__init__.py +11 -0
- psdi_data_conversion/app.py +242 -0
- psdi_data_conversion/bin/linux/atomsk +0 -0
- psdi_data_conversion/bin/linux/c2x +0 -0
- psdi_data_conversion/bin/mac/atomsk +0 -0
- psdi_data_conversion/bin/mac/c2x +0 -0
- psdi_data_conversion/constants.py +185 -0
- psdi_data_conversion/converter.py +459 -0
- psdi_data_conversion/converters/__init__.py +6 -0
- psdi_data_conversion/converters/atomsk.py +32 -0
- psdi_data_conversion/converters/base.py +702 -0
- psdi_data_conversion/converters/c2x.py +32 -0
- psdi_data_conversion/converters/openbabel.py +239 -0
- psdi_data_conversion/database.py +1064 -0
- psdi_data_conversion/dist.py +87 -0
- psdi_data_conversion/file_io.py +216 -0
- psdi_data_conversion/log_utility.py +241 -0
- psdi_data_conversion/main.py +776 -0
- psdi_data_conversion/scripts/atomsk.sh +32 -0
- psdi_data_conversion/scripts/c2x.sh +26 -0
- psdi_data_conversion/security.py +38 -0
- psdi_data_conversion/static/content/accessibility.htm +254 -0
- psdi_data_conversion/static/content/convert.htm +121 -0
- psdi_data_conversion/static/content/convertato.htm +65 -0
- psdi_data_conversion/static/content/convertc2x.htm +65 -0
- psdi_data_conversion/static/content/documentation.htm +94 -0
- psdi_data_conversion/static/content/feedback.htm +53 -0
- psdi_data_conversion/static/content/header-links.html +8 -0
- psdi_data_conversion/static/content/index-versions/header-links.html +8 -0
- psdi_data_conversion/static/content/index-versions/psdi-common-footer.html +99 -0
- psdi_data_conversion/static/content/index-versions/psdi-common-header.html +28 -0
- psdi_data_conversion/static/content/psdi-common-footer.html +99 -0
- psdi_data_conversion/static/content/psdi-common-header.html +28 -0
- psdi_data_conversion/static/content/report.htm +103 -0
- psdi_data_conversion/static/data/data.json +143940 -0
- psdi_data_conversion/static/img/colormode-toggle-dm.svg +3 -0
- psdi_data_conversion/static/img/colormode-toggle-lm.svg +3 -0
- psdi_data_conversion/static/img/psdi-icon-dark.svg +136 -0
- psdi_data_conversion/static/img/psdi-icon-light.svg +208 -0
- psdi_data_conversion/static/img/psdi-logo-darktext.png +0 -0
- psdi_data_conversion/static/img/psdi-logo-lighttext.png +0 -0
- psdi_data_conversion/static/img/social-logo-bluesky-black.svg +4 -0
- psdi_data_conversion/static/img/social-logo-bluesky-white.svg +4 -0
- psdi_data_conversion/static/img/social-logo-instagram-black.svg +1 -0
- psdi_data_conversion/static/img/social-logo-instagram-white.svg +1 -0
- psdi_data_conversion/static/img/social-logo-linkedin-black.png +0 -0
- psdi_data_conversion/static/img/social-logo-linkedin-white.png +0 -0
- psdi_data_conversion/static/img/social-logo-mastodon-black.svg +4 -0
- psdi_data_conversion/static/img/social-logo-mastodon-white.svg +4 -0
- psdi_data_conversion/static/img/social-logo-x-black.svg +3 -0
- psdi_data_conversion/static/img/social-logo-x-white.svg +3 -0
- psdi_data_conversion/static/img/social-logo-youtube-black.png +0 -0
- psdi_data_conversion/static/img/social-logo-youtube-white.png +0 -0
- psdi_data_conversion/static/img/ukri-epsr-logo-darktext.png +0 -0
- psdi_data_conversion/static/img/ukri-epsr-logo-lighttext.png +0 -0
- psdi_data_conversion/static/img/ukri-logo-darktext.png +0 -0
- psdi_data_conversion/static/img/ukri-logo-lighttext.png +0 -0
- psdi_data_conversion/static/javascript/accessibility.js +196 -0
- psdi_data_conversion/static/javascript/common.js +42 -0
- psdi_data_conversion/static/javascript/convert.js +296 -0
- psdi_data_conversion/static/javascript/convert_common.js +252 -0
- psdi_data_conversion/static/javascript/convertato.js +107 -0
- psdi_data_conversion/static/javascript/convertc2x.js +107 -0
- psdi_data_conversion/static/javascript/data.js +176 -0
- psdi_data_conversion/static/javascript/format.js +611 -0
- psdi_data_conversion/static/javascript/load_accessibility.js +89 -0
- psdi_data_conversion/static/javascript/psdi-common.js +177 -0
- psdi_data_conversion/static/javascript/report.js +381 -0
- psdi_data_conversion/static/styles/format.css +147 -0
- psdi_data_conversion/static/styles/psdi-common.css +705 -0
- psdi_data_conversion/templates/index.htm +114 -0
- psdi_data_conversion/testing/__init__.py +5 -0
- psdi_data_conversion/testing/constants.py +12 -0
- psdi_data_conversion/testing/conversion_callbacks.py +394 -0
- psdi_data_conversion/testing/conversion_test_specs.py +208 -0
- psdi_data_conversion/testing/utils.py +522 -0
- psdi_data_conversion-0.0.23.dist-info/METADATA +663 -0
- psdi_data_conversion-0.0.23.dist-info/RECORD +81 -0
- psdi_data_conversion-0.0.23.dist-info/WHEEL +4 -0
- psdi_data_conversion-0.0.23.dist-info/entry_points.txt +2 -0
- psdi_data_conversion-0.0.23.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,208 @@
|
|
1
|
+
"""
|
2
|
+
# conversion_test_specs.py
|
3
|
+
|
4
|
+
This module contains conversion test specifications, which define conversions to be run and how the results should be
|
5
|
+
checked. These test specs can be used to test the same conversion in each of the Python library, command-line
|
6
|
+
application, and GUI.
|
7
|
+
"""
|
8
|
+
|
9
|
+
from psdi_data_conversion import constants as const
|
10
|
+
from psdi_data_conversion.converters.atomsk import CONVERTER_ATO
|
11
|
+
from psdi_data_conversion.converters.base import (FileConverterAbortException, FileConverterHelpException,
|
12
|
+
FileConverterInputException, FileConverterSizeException)
|
13
|
+
from psdi_data_conversion.converters.c2x import CONVERTER_C2X
|
14
|
+
from psdi_data_conversion.converters.openbabel import CONVERTER_OB, COORD_GEN_KEY, COORD_GEN_QUAL_KEY
|
15
|
+
from psdi_data_conversion.testing.conversion_callbacks import (CheckArchiveContents, CheckException, CheckLogContents,
|
16
|
+
CheckLogContentsSuccess, CheckFileStatus,
|
17
|
+
CheckStderrContents, CheckStdoutContents,
|
18
|
+
MatchOutputFile, MultiCallback)
|
19
|
+
from psdi_data_conversion.testing.utils import ConversionTestSpec
|
20
|
+
|
21
|
+
basic_tests = ConversionTestSpec(filename=["1NE6.mmcif", "standard_test.cdxml",
|
22
|
+
"hemoglobin.pdb", "nacl.cif",
|
23
|
+
"hemoglobin.pdb", "nacl.cif",
|
24
|
+
"hemoglobin.pdb", "nacl.cif"],
|
25
|
+
to_format=["pdb", "inchi", "cif", "xyz",
|
26
|
+
"cif", "xyz",
|
27
|
+
"cif", "xyz"],
|
28
|
+
name=[CONVERTER_OB, CONVERTER_OB,
|
29
|
+
CONVERTER_OB, CONVERTER_OB,
|
30
|
+
CONVERTER_ATO, CONVERTER_ATO,
|
31
|
+
CONVERTER_C2X, CONVERTER_C2X],
|
32
|
+
callback=MultiCallback(CheckFileStatus(),
|
33
|
+
CheckLogContentsSuccess()))
|
34
|
+
"""A basic set of test conversions which we expect to succeed without issue, running two conversions with each of the
|
35
|
+
Open Babel, Atomsk, and c2x converters"""
|
36
|
+
|
37
|
+
archive_callback = MultiCallback(CheckFileStatus(),
|
38
|
+
CheckArchiveContents(l_filename_bases=["caffeine-no-flags",
|
39
|
+
"caffeine-ia",
|
40
|
+
"caffeine-ia-ox",
|
41
|
+
"caffeine-ia-okx",
|
42
|
+
"caffeine-ia-okx-oof4",
|
43
|
+
"caffeine-ia-okx-oof4l5",],
|
44
|
+
to_format="inchi"))
|
45
|
+
archive_tests = ConversionTestSpec(filename=["caffeine-smi.zip",
|
46
|
+
"caffeine-smi.tar",
|
47
|
+
"caffeine-smi.tar.gz"],
|
48
|
+
to_format="inchi",
|
49
|
+
callback=archive_callback)
|
50
|
+
"""A test of converting a archives of files"""
|
51
|
+
|
52
|
+
archive_wrong_format_test = ConversionTestSpec(filename="caffeine-smi.zip",
|
53
|
+
to_format="inchi",
|
54
|
+
conversion_kwargs=[{"from_format": "pdb"},
|
55
|
+
{"from_format": "pdb", "strict": True}],
|
56
|
+
expect_success=[True, False],
|
57
|
+
callback=[CheckStderrContents(const.ERR_WRONG_EXTENSIONS),
|
58
|
+
CheckException(ex_type=FileConverterInputException,
|
59
|
+
ex_message=const.ERR_WRONG_EXTENSIONS)]
|
60
|
+
)
|
61
|
+
"""A test that if the user provides the wrong input format for files in an archive, and error will be output to stderr
|
62
|
+
"""
|
63
|
+
|
64
|
+
log_mode_tests = ConversionTestSpec(conversion_kwargs=[{"log_mode": const.LOG_NONE},
|
65
|
+
{"log_mode": const.LOG_STDOUT},
|
66
|
+
{"log_mode": const.LOG_SIMPLE},
|
67
|
+
{"log_mode": const.LOG_FULL},
|
68
|
+
{"log_mode": const.LOG_FULL_FORCE},],
|
69
|
+
callback=[CheckFileStatus(expect_log_exists=False,
|
70
|
+
expect_global_log_exists=False),
|
71
|
+
CheckFileStatus(expect_log_exists=False,
|
72
|
+
expect_global_log_exists=False),
|
73
|
+
CheckFileStatus(expect_log_exists=True,
|
74
|
+
expect_global_log_exists=False),
|
75
|
+
CheckFileStatus(expect_log_exists=True,
|
76
|
+
expect_global_log_exists=True),
|
77
|
+
CheckFileStatus(expect_log_exists=True,
|
78
|
+
expect_global_log_exists=True)],
|
79
|
+
)
|
80
|
+
"""Tests that the different log modes have the desired effects on logs
|
81
|
+
|
82
|
+
NOTE: Not compatible with GUI tests, since the GUI requires the log mode to always be "Full"
|
83
|
+
"""
|
84
|
+
|
85
|
+
stdout_test = ConversionTestSpec(conversion_kwargs={"log_mode": const.LOG_STDOUT},
|
86
|
+
callback=CheckStdoutContents(l_strings_to_exclude=["ERROR", "exception", "Exception"],
|
87
|
+
l_regex_to_find=[r"File name:\s*nacl",
|
88
|
+
const.DATETIME_RE_RAW]
|
89
|
+
))
|
90
|
+
"""Test that the log is output to stdout when requested
|
91
|
+
|
92
|
+
NOTE: Not compatible with GUI tests, since the GUI requires the log mode to always be "Full"
|
93
|
+
"""
|
94
|
+
|
95
|
+
quiet_test = ConversionTestSpec(conversion_kwargs={"log_mode": const.LOG_NONE},
|
96
|
+
callback=CheckStdoutContents(l_regex_to_exclude=r"."))
|
97
|
+
"""Test that nothing is output to stdout when quiet mode is enabled
|
98
|
+
|
99
|
+
NOTE: Not compatible with GUI tests, since the GUI doesn't support quiet mode
|
100
|
+
"""
|
101
|
+
|
102
|
+
open_babel_warning_test = ConversionTestSpec(filename="1NE6.mmcif",
|
103
|
+
to_format="pdb",
|
104
|
+
callback=CheckLogContentsSuccess(["Open Babel Warning",
|
105
|
+
"Failed to kekulize aromatic bonds",])
|
106
|
+
)
|
107
|
+
"""A test that confirms expected warnings form Open Babel are output and captured in the log"""
|
108
|
+
|
109
|
+
invalid_converter_callback = MultiCallback(CheckFileStatus(expect_output_exists=False,
|
110
|
+
expect_log_exists=False),
|
111
|
+
CheckException(ex_type=FileConverterInputException,
|
112
|
+
ex_message="Converter {} not recognized"))
|
113
|
+
invalid_converter_test = ConversionTestSpec(name="INVALID",
|
114
|
+
expect_success=False,
|
115
|
+
callback=invalid_converter_callback)
|
116
|
+
"""A test that a proper error is returned if an invalid converter is requested"""
|
117
|
+
|
118
|
+
quality_note_callback = CheckLogContentsSuccess(["WARNING",
|
119
|
+
const.QUAL_NOTE_OUT_MISSING.format(const.QUAL_2D_LABEL),
|
120
|
+
const.QUAL_NOTE_OUT_MISSING.format(const.QUAL_3D_LABEL),
|
121
|
+
const.QUAL_NOTE_IN_MISSING.format(const.QUAL_CONN_LABEL)])
|
122
|
+
quality_note_test = ConversionTestSpec(filename="quartz.xyz",
|
123
|
+
to_format="inchi",
|
124
|
+
callback=quality_note_callback)
|
125
|
+
"""A test conversion which we expect to produce a warning for conversion quality issues, where the connections property
|
126
|
+
isn't present in the input and has to be extrapolated, and the 2D and 3D coordinates properties aren't present in the
|
127
|
+
output and will be lost"""
|
128
|
+
|
129
|
+
cleanup_input_test = ConversionTestSpec(conversion_kwargs={"delete_input": True},
|
130
|
+
callback=CheckFileStatus(expect_input_exists=False))
|
131
|
+
"""A test that the input file to a conversion is deleted when cleanup is requested"""
|
132
|
+
|
133
|
+
cant_read_xyz_callback = MultiCallback(CheckFileStatus(expect_output_exists=False,
|
134
|
+
expect_log_exists=None),
|
135
|
+
CheckException(ex_type=FileConverterAbortException,
|
136
|
+
ex_message="Problems reading an XYZ file"))
|
137
|
+
invalid_conversion_callback = MultiCallback(CheckFileStatus(expect_output_exists=False,
|
138
|
+
expect_log_exists=None),
|
139
|
+
CheckException(ex_type=FileConverterHelpException,
|
140
|
+
ex_message="is not supported"))
|
141
|
+
wrong_type_callback = MultiCallback(CheckFileStatus(expect_output_exists=False,
|
142
|
+
expect_log_exists=None),
|
143
|
+
CheckException(ex_type=FileConverterAbortException,
|
144
|
+
ex_message="not a valid {} file"))
|
145
|
+
failed_conversion_test = ConversionTestSpec(filename=["quartz_err.xyz", "hemoglobin.pdb", "1NE6.mmcif"],
|
146
|
+
to_format=["inchi", "pdb", "cif"],
|
147
|
+
conversion_kwargs=[{}, {}, {"from_format": "pdb"}],
|
148
|
+
expect_success=False,
|
149
|
+
callback=[cant_read_xyz_callback, invalid_conversion_callback,
|
150
|
+
wrong_type_callback])
|
151
|
+
"""A test that a conversion which fails due to an invalid input file will properly fail"""
|
152
|
+
|
153
|
+
max_size_callback = MultiCallback(CheckFileStatus(expect_output_exists=False),
|
154
|
+
CheckLogContents("Output file exceeds maximum size"),
|
155
|
+
CheckException(ex_type=FileConverterSizeException,
|
156
|
+
ex_message="exceeds maximum size",
|
157
|
+
ex_status_code=const.STATUS_CODE_SIZE))
|
158
|
+
max_size_test = ConversionTestSpec(filename=["1NE6.mmcif", "caffeine-smi.tar.gz"],
|
159
|
+
to_format="pdb",
|
160
|
+
conversion_kwargs=[{"max_file_size": 0.0001}, {"max_file_size": 0.0005}],
|
161
|
+
expect_success=False,
|
162
|
+
callback=max_size_callback)
|
163
|
+
"""A set of test conversion that the maximum size constraint is properly applied. In the first test, the input file
|
164
|
+
will be greater than the maximum size, and the test should fail as soon as it checks it. In the second test, the input
|
165
|
+
archive is smaller than the maximum size, but the unpacked files in it are greater, so it should fail midway through.
|
166
|
+
|
167
|
+
NOTE: Not compatible with CLA tests, since the CLA doesn't allow the imposition of a maximum size.
|
168
|
+
"""
|
169
|
+
|
170
|
+
|
171
|
+
format_args_test = ConversionTestSpec(filename="caffeine.inchi",
|
172
|
+
to_format="smi",
|
173
|
+
conversion_kwargs=[{},
|
174
|
+
{"data": {"from_flags": "a"}},
|
175
|
+
{"data": {"from_flags": "a", "to_flags": "x"}},
|
176
|
+
{"data": {"from_flags": "a", "to_flags": "kx"}},
|
177
|
+
{"data": {"from_flags": "a", "to_flags": "kx",
|
178
|
+
"to_options": "f4"}},
|
179
|
+
{"data": {"from_flags": "a", "to_flags": "kx",
|
180
|
+
"to_options": "f4 l5"}}
|
181
|
+
],
|
182
|
+
callback=[MatchOutputFile("caffeine-no-flags.smi"),
|
183
|
+
MatchOutputFile("caffeine-ia.smi"),
|
184
|
+
MatchOutputFile("caffeine-ia-ox.smi"),
|
185
|
+
MatchOutputFile("caffeine-ia-okx.smi"),
|
186
|
+
MatchOutputFile("caffeine-ia-okx-oof4.smi"),
|
187
|
+
MatchOutputFile("caffeine-ia-okx-oof4l5.smi")
|
188
|
+
]
|
189
|
+
)
|
190
|
+
"""A set of tests which checks that format args (for how to read from and write to specific file formats) are processed
|
191
|
+
correctly, by matching tests using them to expected output files"""
|
192
|
+
|
193
|
+
|
194
|
+
coord_gen_test = ConversionTestSpec(filename="caffeine.inchi",
|
195
|
+
to_format="xyz",
|
196
|
+
conversion_kwargs=[{},
|
197
|
+
{"data": {COORD_GEN_KEY: "Gen2D",
|
198
|
+
COORD_GEN_QUAL_KEY: "fastest"}},
|
199
|
+
{"data": {COORD_GEN_KEY: "Gen3D",
|
200
|
+
COORD_GEN_QUAL_KEY: "best"}}
|
201
|
+
],
|
202
|
+
callback=[MatchOutputFile("caffeine.xyz"),
|
203
|
+
MatchOutputFile("caffeine-2D-fastest.xyz"),
|
204
|
+
MatchOutputFile("caffeine-3D-best.xyz"),
|
205
|
+
]
|
206
|
+
)
|
207
|
+
"""A set of tests which checks that coordinate generation options are processed correctly, by matching tests using them
|
208
|
+
to expected output files"""
|