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.
Files changed (81) hide show
  1. psdi_data_conversion/__init__.py +11 -0
  2. psdi_data_conversion/app.py +242 -0
  3. psdi_data_conversion/bin/linux/atomsk +0 -0
  4. psdi_data_conversion/bin/linux/c2x +0 -0
  5. psdi_data_conversion/bin/mac/atomsk +0 -0
  6. psdi_data_conversion/bin/mac/c2x +0 -0
  7. psdi_data_conversion/constants.py +185 -0
  8. psdi_data_conversion/converter.py +459 -0
  9. psdi_data_conversion/converters/__init__.py +6 -0
  10. psdi_data_conversion/converters/atomsk.py +32 -0
  11. psdi_data_conversion/converters/base.py +702 -0
  12. psdi_data_conversion/converters/c2x.py +32 -0
  13. psdi_data_conversion/converters/openbabel.py +239 -0
  14. psdi_data_conversion/database.py +1064 -0
  15. psdi_data_conversion/dist.py +87 -0
  16. psdi_data_conversion/file_io.py +216 -0
  17. psdi_data_conversion/log_utility.py +241 -0
  18. psdi_data_conversion/main.py +776 -0
  19. psdi_data_conversion/scripts/atomsk.sh +32 -0
  20. psdi_data_conversion/scripts/c2x.sh +26 -0
  21. psdi_data_conversion/security.py +38 -0
  22. psdi_data_conversion/static/content/accessibility.htm +254 -0
  23. psdi_data_conversion/static/content/convert.htm +121 -0
  24. psdi_data_conversion/static/content/convertato.htm +65 -0
  25. psdi_data_conversion/static/content/convertc2x.htm +65 -0
  26. psdi_data_conversion/static/content/documentation.htm +94 -0
  27. psdi_data_conversion/static/content/feedback.htm +53 -0
  28. psdi_data_conversion/static/content/header-links.html +8 -0
  29. psdi_data_conversion/static/content/index-versions/header-links.html +8 -0
  30. psdi_data_conversion/static/content/index-versions/psdi-common-footer.html +99 -0
  31. psdi_data_conversion/static/content/index-versions/psdi-common-header.html +28 -0
  32. psdi_data_conversion/static/content/psdi-common-footer.html +99 -0
  33. psdi_data_conversion/static/content/psdi-common-header.html +28 -0
  34. psdi_data_conversion/static/content/report.htm +103 -0
  35. psdi_data_conversion/static/data/data.json +143940 -0
  36. psdi_data_conversion/static/img/colormode-toggle-dm.svg +3 -0
  37. psdi_data_conversion/static/img/colormode-toggle-lm.svg +3 -0
  38. psdi_data_conversion/static/img/psdi-icon-dark.svg +136 -0
  39. psdi_data_conversion/static/img/psdi-icon-light.svg +208 -0
  40. psdi_data_conversion/static/img/psdi-logo-darktext.png +0 -0
  41. psdi_data_conversion/static/img/psdi-logo-lighttext.png +0 -0
  42. psdi_data_conversion/static/img/social-logo-bluesky-black.svg +4 -0
  43. psdi_data_conversion/static/img/social-logo-bluesky-white.svg +4 -0
  44. psdi_data_conversion/static/img/social-logo-instagram-black.svg +1 -0
  45. psdi_data_conversion/static/img/social-logo-instagram-white.svg +1 -0
  46. psdi_data_conversion/static/img/social-logo-linkedin-black.png +0 -0
  47. psdi_data_conversion/static/img/social-logo-linkedin-white.png +0 -0
  48. psdi_data_conversion/static/img/social-logo-mastodon-black.svg +4 -0
  49. psdi_data_conversion/static/img/social-logo-mastodon-white.svg +4 -0
  50. psdi_data_conversion/static/img/social-logo-x-black.svg +3 -0
  51. psdi_data_conversion/static/img/social-logo-x-white.svg +3 -0
  52. psdi_data_conversion/static/img/social-logo-youtube-black.png +0 -0
  53. psdi_data_conversion/static/img/social-logo-youtube-white.png +0 -0
  54. psdi_data_conversion/static/img/ukri-epsr-logo-darktext.png +0 -0
  55. psdi_data_conversion/static/img/ukri-epsr-logo-lighttext.png +0 -0
  56. psdi_data_conversion/static/img/ukri-logo-darktext.png +0 -0
  57. psdi_data_conversion/static/img/ukri-logo-lighttext.png +0 -0
  58. psdi_data_conversion/static/javascript/accessibility.js +196 -0
  59. psdi_data_conversion/static/javascript/common.js +42 -0
  60. psdi_data_conversion/static/javascript/convert.js +296 -0
  61. psdi_data_conversion/static/javascript/convert_common.js +252 -0
  62. psdi_data_conversion/static/javascript/convertato.js +107 -0
  63. psdi_data_conversion/static/javascript/convertc2x.js +107 -0
  64. psdi_data_conversion/static/javascript/data.js +176 -0
  65. psdi_data_conversion/static/javascript/format.js +611 -0
  66. psdi_data_conversion/static/javascript/load_accessibility.js +89 -0
  67. psdi_data_conversion/static/javascript/psdi-common.js +177 -0
  68. psdi_data_conversion/static/javascript/report.js +381 -0
  69. psdi_data_conversion/static/styles/format.css +147 -0
  70. psdi_data_conversion/static/styles/psdi-common.css +705 -0
  71. psdi_data_conversion/templates/index.htm +114 -0
  72. psdi_data_conversion/testing/__init__.py +5 -0
  73. psdi_data_conversion/testing/constants.py +12 -0
  74. psdi_data_conversion/testing/conversion_callbacks.py +394 -0
  75. psdi_data_conversion/testing/conversion_test_specs.py +208 -0
  76. psdi_data_conversion/testing/utils.py +522 -0
  77. psdi_data_conversion-0.0.23.dist-info/METADATA +663 -0
  78. psdi_data_conversion-0.0.23.dist-info/RECORD +81 -0
  79. psdi_data_conversion-0.0.23.dist-info/WHEEL +4 -0
  80. psdi_data_conversion-0.0.23.dist-info/entry_points.txt +2 -0
  81. psdi_data_conversion-0.0.23.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,663 @@
1
+ Metadata-Version: 2.1
2
+ Name: psdi_data_conversion
3
+ Version: 0.0.23
4
+ Summary: Chemistry file format conversion service, provided by PSDI
5
+ Project-URL: Homepage, https://psdidev2.azurewebsites.net/
6
+ Project-URL: Documentation, https://psdi-uk.github.io/psdi-data-conversion/
7
+ Project-URL: Repository, https://github.com/PSDI-UK/psdi-data-conversion
8
+ Project-URL: Issues, https://github.com/PSDI-UK/psdi-data-conversion/issues
9
+ Project-URL: Changelog, https://github.com/PSDI-UK/psdi-data-conversion/blob/main/CHANGELOG.md
10
+ Project-URL: Download, https://github.com/PSDI-UK/psdi-data-conversion/releases/latest
11
+ Author: Ray Whorley, Don Cruickshank, Tom Underwood
12
+ Author-email: Samantha Pearman-Kanza <s.pearman-kanza@soton.ac.uk>, Bryan Gillis <7204836+brgillis@users.noreply.github.com>
13
+ License: Apache License
14
+ Version 2.0, January 2004
15
+ http://www.apache.org/licenses/
16
+
17
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
18
+
19
+ 1. Definitions.
20
+
21
+ "License" shall mean the terms and conditions for use, reproduction,
22
+ and distribution as defined by Sections 1 through 9 of this document.
23
+
24
+ "Licensor" shall mean the copyright owner or entity authorized by
25
+ the copyright owner that is granting the License.
26
+
27
+ "Legal Entity" shall mean the union of the acting entity and all
28
+ other entities that control, are controlled by, or are under common
29
+ control with that entity. For the purposes of this definition,
30
+ "control" means (i) the power, direct or indirect, to cause the
31
+ direction or management of such entity, whether by contract or
32
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
33
+ outstanding shares, or (iii) beneficial ownership of such entity.
34
+
35
+ "You" (or "Your") shall mean an individual or Legal Entity
36
+ exercising permissions granted by this License.
37
+
38
+ "Source" form shall mean the preferred form for making modifications,
39
+ including but not limited to software source code, documentation
40
+ source, and configuration files.
41
+
42
+ "Object" form shall mean any form resulting from mechanical
43
+ transformation or translation of a Source form, including but
44
+ not limited to compiled object code, generated documentation,
45
+ and conversions to other media types.
46
+
47
+ "Work" shall mean the work of authorship, whether in Source or
48
+ Object form, made available under the License, as indicated by a
49
+ copyright notice that is included in or attached to the work
50
+ (an example is provided in the Appendix below).
51
+
52
+ "Derivative Works" shall mean any work, whether in Source or Object
53
+ form, that is based on (or derived from) the Work and for which the
54
+ editorial revisions, annotations, elaborations, or other modifications
55
+ represent, as a whole, an original work of authorship. For the purposes
56
+ of this License, Derivative Works shall not include works that remain
57
+ separable from, or merely link (or bind by name) to the interfaces of,
58
+ the Work and Derivative Works thereof.
59
+
60
+ "Contribution" shall mean any work of authorship, including
61
+ the original version of the Work and any modifications or additions
62
+ to that Work or Derivative Works thereof, that is intentionally
63
+ submitted to Licensor for inclusion in the Work by the copyright owner
64
+ or by an individual or Legal Entity authorized to submit on behalf of
65
+ the copyright owner. For the purposes of this definition, "submitted"
66
+ means any form of electronic, verbal, or written communication sent
67
+ to the Licensor or its representatives, including but not limited to
68
+ communication on electronic mailing lists, source code control systems,
69
+ and issue tracking systems that are managed by, or on behalf of, the
70
+ Licensor for the purpose of discussing and improving the Work, but
71
+ excluding communication that is conspicuously marked or otherwise
72
+ designated in writing by the copyright owner as "Not a Contribution."
73
+
74
+ "Contributor" shall mean Licensor and any individual or Legal Entity
75
+ on behalf of whom a Contribution has been received by Licensor and
76
+ subsequently incorporated within the Work.
77
+
78
+ 2. Grant of Copyright License. Subject to the terms and conditions of
79
+ this License, each Contributor hereby grants to You a perpetual,
80
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
81
+ copyright license to reproduce, prepare Derivative Works of,
82
+ publicly display, publicly perform, sublicense, and distribute the
83
+ Work and such Derivative Works in Source or Object form.
84
+
85
+ 3. Grant of Patent License. Subject to the terms and conditions of
86
+ this License, each Contributor hereby grants to You a perpetual,
87
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
88
+ (except as stated in this section) patent license to make, have made,
89
+ use, offer to sell, sell, import, and otherwise transfer the Work,
90
+ where such license applies only to those patent claims licensable
91
+ by such Contributor that are necessarily infringed by their
92
+ Contribution(s) alone or by combination of their Contribution(s)
93
+ with the Work to which such Contribution(s) was submitted. If You
94
+ institute patent litigation against any entity (including a
95
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
96
+ or a Contribution incorporated within the Work constitutes direct
97
+ or contributory patent infringement, then any patent licenses
98
+ granted to You under this License for that Work shall terminate
99
+ as of the date such litigation is filed.
100
+
101
+ 4. Redistribution. You may reproduce and distribute copies of the
102
+ Work or Derivative Works thereof in any medium, with or without
103
+ modifications, and in Source or Object form, provided that You
104
+ meet the following conditions:
105
+
106
+ (a) You must give any other recipients of the Work or
107
+ Derivative Works a copy of this License; and
108
+
109
+ (b) You must cause any modified files to carry prominent notices
110
+ stating that You changed the files; and
111
+
112
+ (c) You must retain, in the Source form of any Derivative Works
113
+ that You distribute, all copyright, patent, trademark, and
114
+ attribution notices from the Source form of the Work,
115
+ excluding those notices that do not pertain to any part of
116
+ the Derivative Works; and
117
+
118
+ (d) If the Work includes a "NOTICE" text file as part of its
119
+ distribution, then any Derivative Works that You distribute must
120
+ include a readable copy of the attribution notices contained
121
+ within such NOTICE file, excluding those notices that do not
122
+ pertain to any part of the Derivative Works, in at least one
123
+ of the following places: within a NOTICE text file distributed
124
+ as part of the Derivative Works; within the Source form or
125
+ documentation, if provided along with the Derivative Works; or,
126
+ within a display generated by the Derivative Works, if and
127
+ wherever such third-party notices normally appear. The contents
128
+ of the NOTICE file are for informational purposes only and
129
+ do not modify the License. You may add Your own attribution
130
+ notices within Derivative Works that You distribute, alongside
131
+ or as an addendum to the NOTICE text from the Work, provided
132
+ that such additional attribution notices cannot be construed
133
+ as modifying the License.
134
+
135
+ You may add Your own copyright statement to Your modifications and
136
+ may provide additional or different license terms and conditions
137
+ for use, reproduction, or distribution of Your modifications, or
138
+ for any such Derivative Works as a whole, provided Your use,
139
+ reproduction, and distribution of the Work otherwise complies with
140
+ the conditions stated in this License.
141
+
142
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
143
+ any Contribution intentionally submitted for inclusion in the Work
144
+ by You to the Licensor shall be under the terms and conditions of
145
+ this License, without any additional terms or conditions.
146
+ Notwithstanding the above, nothing herein shall supersede or modify
147
+ the terms of any separate license agreement you may have executed
148
+ with Licensor regarding such Contributions.
149
+
150
+ 6. Trademarks. This License does not grant permission to use the trade
151
+ names, trademarks, service marks, or product names of the Licensor,
152
+ except as required for reasonable and customary use in describing the
153
+ origin of the Work and reproducing the content of the NOTICE file.
154
+
155
+ 7. Disclaimer of Warranty. Unless required by applicable law or
156
+ agreed to in writing, Licensor provides the Work (and each
157
+ Contributor provides its Contributions) on an "AS IS" BASIS,
158
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
159
+ implied, including, without limitation, any warranties or conditions
160
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
161
+ PARTICULAR PURPOSE. You are solely responsible for determining the
162
+ appropriateness of using or redistributing the Work and assume any
163
+ risks associated with Your exercise of permissions under this License.
164
+
165
+ 8. Limitation of Liability. In no event and under no legal theory,
166
+ whether in tort (including negligence), contract, or otherwise,
167
+ unless required by applicable law (such as deliberate and grossly
168
+ negligent acts) or agreed to in writing, shall any Contributor be
169
+ liable to You for damages, including any direct, indirect, special,
170
+ incidental, or consequential damages of any character arising as a
171
+ result of this License or out of the use or inability to use the
172
+ Work (including but not limited to damages for loss of goodwill,
173
+ work stoppage, computer failure or malfunction, or any and all
174
+ other commercial damages or losses), even if such Contributor
175
+ has been advised of the possibility of such damages.
176
+
177
+ 9. Accepting Warranty or Additional Liability. While redistributing
178
+ the Work or Derivative Works thereof, You may choose to offer,
179
+ and charge a fee for, acceptance of support, warranty, indemnity,
180
+ or other liability obligations and/or rights consistent with this
181
+ License. However, in accepting such obligations, You may act only
182
+ on Your own behalf and on Your sole responsibility, not on behalf
183
+ of any other Contributor, and only if You agree to indemnify,
184
+ defend, and hold each Contributor harmless for any liability
185
+ incurred by, or claims asserted against, such Contributor by reason
186
+ of your accepting any such warranty or additional liability.
187
+
188
+ END OF TERMS AND CONDITIONS
189
+
190
+ APPENDIX: How to apply the Apache License to your work.
191
+
192
+ To apply the Apache License to your work, attach the following
193
+ boilerplate notice, with the fields enclosed by brackets "[]"
194
+ replaced with your own identifying information. (Don't include
195
+ the brackets!) The text should be enclosed in the appropriate
196
+ comment syntax for the file format. We also recommend that a
197
+ file or class name and description of purpose be included on the
198
+ same "printed page" as the copyright notice for easier
199
+ identification within third-party archives.
200
+
201
+ Copyright [yyyy] [name of copyright owner]
202
+
203
+ Licensed under the Apache License, Version 2.0 (the "License");
204
+ you may not use this file except in compliance with the License.
205
+ You may obtain a copy of the License at
206
+
207
+ http://www.apache.org/licenses/LICENSE-2.0
208
+
209
+ Unless required by applicable law or agreed to in writing, software
210
+ distributed under the License is distributed on an "AS IS" BASIS,
211
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
212
+ See the License for the specific language governing permissions and
213
+ limitations under the License.
214
+ License-File: LICENSE
215
+ Keywords: atomsk,chemistry,conversion,flask,openbabel
216
+ Classifier: Development Status :: 3 - Alpha
217
+ Classifier: Framework :: Flask
218
+ Classifier: Intended Audience :: Science/Research
219
+ Classifier: License :: OSI Approved :: Apache Software License
220
+ Classifier: Natural Language :: English
221
+ Classifier: Operating System :: POSIX :: Linux
222
+ Classifier: Programming Language :: JavaScript
223
+ Classifier: Programming Language :: Python :: 3
224
+ Classifier: Topic :: File Formats
225
+ Classifier: Topic :: Scientific/Engineering :: Chemistry
226
+ Requires-Python: >=3.12
227
+ Requires-Dist: openbabel-wheel
228
+ Requires-Dist: py
229
+ Provides-Extra: doc
230
+ Requires-Dist: pdoc3; extra == 'doc'
231
+ Provides-Extra: gui
232
+ Requires-Dist: flask; extra == 'gui'
233
+ Requires-Dist: requests; extra == 'gui'
234
+ Provides-Extra: gui-test
235
+ Requires-Dist: coverage; extra == 'gui-test'
236
+ Requires-Dist: flask; extra == 'gui-test'
237
+ Requires-Dist: pytest; extra == 'gui-test'
238
+ Requires-Dist: requests; extra == 'gui-test'
239
+ Requires-Dist: selenium; extra == 'gui-test'
240
+ Requires-Dist: webdriver-manager; extra == 'gui-test'
241
+ Provides-Extra: test
242
+ Requires-Dist: coverage; extra == 'test'
243
+ Requires-Dist: pytest; extra == 'test'
244
+ Description-Content-Type: text/markdown
245
+
246
+ # PSDI Data Conversion
247
+
248
+ Version: Pre-release 2024-02-27
249
+
250
+ This is the repository for the PSDI PF2 Chemistry File Format Conversion project. The goal of this project is to provide utilities to assist in converting files between the many different file formats used in chemistry, providing information on what converters are available for a given conversion and the expected quality of it, and providing multiple interfaces to perform these conversions. These interfaces are:
251
+
252
+ - Online web service, available at https://psdidev2.azurewebsites.net
253
+ - Version of the web app you can download and run locally (e.g. if you need to convert files which exceed the online app's file size limit)
254
+ - Command-line application, to run conversions from a terminal
255
+ - Python library
256
+
257
+ ## Table of Contents
258
+
259
+ - [Project Structure](#project-structure)
260
+ - [Requirements](#requirements)
261
+ - [Python](#python)
262
+ - [Other Dependencies](#other-dependencies)
263
+ - [Command-Line Application](#command-line-application)
264
+ - [Installation](#installation)
265
+ - [Execution](#execution)
266
+ - [Data Conversion](#data-conversion)
267
+ - [Requesting Information on Possible Conversions](#requesting-information-on-possible-conversions)
268
+ - [Python Library](#python-library)
269
+ - [Installation](#installation-1)
270
+ - [Use](#use)
271
+ - [`run_converter`](#run_converter)
272
+ - [`get_converter`](#get_converter)
273
+ - [`constants`](#constants)
274
+ - [`database`](#database)
275
+ - [Further Information](#further-information)
276
+ - [Using the Online Conversion Service](#using-the-online-conversion-service)
277
+ - [Running the Python/Flask app locally](#running-the-pythonflask-app-locally)
278
+ - [Installation and Setup](#installation-and-setup)
279
+ - [Running the App](#running-the-app)
280
+ - [Testing](#testing)
281
+
282
+ ## Project Structure
283
+
284
+ - `.github`
285
+ - `workflows`
286
+ - (Automated workflows for various tasks related to project maintenance)
287
+ - `deploy`
288
+ - (Files used as part of the deployment to STFC infrastructure)
289
+ - `psdi_data_conversion` (Primary source directory)
290
+ - `bin`
291
+ - (Precompiled binaries for running file format converters)
292
+ - `static` (Static code and assets for the web app)
293
+ - `content`
294
+ - (HTML assets for the web app)
295
+ - `downloads` (created by app.py if not extant)
296
+ - `img`
297
+ - (image assets for the web app)
298
+ - `javascript`
299
+ - (JavaScript code for the web app)
300
+ - `styles`
301
+ - (CSS stylesheets for the web app)
302
+ - `uploads` (created by app.py if not extant)
303
+ - `templates`
304
+ - (HTML assets rendered by Flask for the web app)
305
+ - `__init.py__`
306
+ - (Python packages, modules, and scripts)
307
+ - `scripts`
308
+ - (Scripts used for project maintenance)
309
+ - `test_data`
310
+ - (Files used for testing the project)
311
+ - `tests`
312
+ - (Unit tests for the project)
313
+ - `CHANGELOG.md` (Updates since initial public release)
314
+ - `CONTRIBUTING.md` (Guidelines and information for contributors to the project)
315
+ - `DOCKERFILE` (Dockerfile for image containerising PSDI's data conversion service)
316
+ - `LICENSE` (Apache Licence version 2.0)
317
+ - `pyproject.toml` (Python project metadata and settings)
318
+ - `README.md` (This file)
319
+ - `requirements.txt` (Requirements for the Azure web app deployment of this project)
320
+ - `run_local.sh` (Helper script to run the web app locally)
321
+ - `startup.sh` (Startup script for the Azure web app)
322
+
323
+ ## Requirements
324
+
325
+ ### Python
326
+
327
+ Any local installation of this project requires Python 3.12 or greater. The best way to do this is dependant on your system, and you are likely to find the best tailored instructions by searching the web for e.g. "install Python 3.12 <your-os-or-distribution>". Some standard options are:
328
+
329
+ For Windows and MacOS: Download and run the installer for the latest version from the official site: https://www.python.org/downloads/
330
+
331
+ For Linux systems, Python is most readily installed with your distribution's package manager. For Ubuntu/Debian-based systems, this is `apt`, and the following series of commands can be used to install the latest version of Python compatible with your system:
332
+
333
+ ```bash
334
+ sudo apt update # Make sure the package manager has access to the latest versions of all packages
335
+ sudo apt upgrade # Update all installed packages
336
+ sudo apt install python3 # Install the latest possible version of Python
337
+ ```
338
+
339
+ Check the version of Python installed with one of the following:
340
+
341
+ ```bash
342
+ python --version
343
+ python3 --version
344
+ ```
345
+
346
+ Usually `python` will be set up as an alias to python3, but if you already have an older version installed on your system, this might not be the case. You may be able to set this behaviour up by installing the `python-is-python3` package:
347
+
348
+ ```bash
349
+ sudo apt install python-is-python3
350
+ ```
351
+
352
+ Also check that this process installed Python's package manager, `pip`, on your system:
353
+
354
+ ```bash
355
+ pip --version
356
+ ```
357
+
358
+ If it didn't, you can manually install it with:
359
+
360
+ ```bash
361
+ sudo apt install python3-pip
362
+ ```
363
+
364
+ If this doesn't work, or the version installed is too low, an alternative is to install Python via the Anaconda package manager. For this, see the guide here: https://www.askpython.com/python/examples/install-python-with-conda. If you already have an earlier version of Python installed with Anaconda, you can install and activate a newer version with a command such as:
365
+
366
+ ```bash
367
+ conda create --name converter python=3.12 anaconda # Where 'converter' is a possible conda environment name
368
+ conda activate converter
369
+ ```
370
+
371
+ You can also install a newer version of Python if you wish by substituting "3.12" in the above with e.g. "3.13".
372
+
373
+ ### Other Dependencies
374
+
375
+ This project depends on other projects available via pip, which will be installed automatically as required:
376
+
377
+ Required for all installations (`pip install .`):
378
+
379
+ - `py`
380
+ - `openbabel-wheel`
381
+
382
+ Required to run the web app locally for a GUI experience (`pip install .[gui]`):
383
+
384
+ - `Flask`
385
+ - `requests`
386
+
387
+ Required to run unit tests (`pip install .[test]`):
388
+
389
+ - `pytest`
390
+ - `coverage`
391
+
392
+ Required to run unit tests on the web app (`pip install .[gui-test]`):
393
+
394
+ - (all web app and test requirements listed above)
395
+ - `selenium`
396
+ - `webdriver_manager`
397
+
398
+ In addition to the dependencies listed above, this project uses the assets made public by PSDI's common style project at https://github.com/PSDI-UK/psdi-common-style. The latest versions of these assets are copied to this project periodically (using the scripts in the `scripts` directory). In case a future release of these assets causes a breaking change in this project, the file `fetch-common-style.conf` can be modified to set a previous fixed version to download and use until this project is updated to work with the latest version of the assets.
399
+
400
+ ## Command-Line Application
401
+
402
+ ### Installation
403
+
404
+ The CLA and Python library are installed together. This package is not yet available on PyPI, and so must be installed locally. This can be done most easily with:
405
+
406
+ ```bash
407
+ pip install .
408
+ ```
409
+
410
+ executed from this project's directory. You can also replace the '.' in this command with the path to this project's directory to install it from elsewhere.
411
+
412
+ Depending on your system, it may not be possible to install packages in this manner without creating a virtual environment to do so in. You can do this by first installing the `venv` module for Python3 with e.g.:
413
+
414
+ ```bash
415
+ sudo apt install python3-venv # Or equivalent for your distribution
416
+ ```
417
+
418
+ You can then create and activate a virtual environment with:
419
+
420
+ ```bash
421
+ python -m venv .venv # ".venv" here can be replaced with any name you desire for the virtual environment
422
+ source .venv/bin/activate
423
+ ```
424
+
425
+ You should then be able to install this project. When you wish to deactivate the virtual environment, you can do so with the `deactivate` command.
426
+
427
+ ### Execution
428
+
429
+ Once installed, the command-line script `psdi-data-convert` will be made available, which can be called to either perform a data conversion or to get information about possible conversions and converters. You can see the full options for it by calling:
430
+
431
+ ```bash
432
+ psdi-data-convert -h
433
+ ```
434
+
435
+ This script has two modes of execution: Data conversion, and requesting information on possible conversions and converters.
436
+
437
+ #### Data Conversion
438
+
439
+ Data conversion is the default mode of the script. At its most basic, the syntax for it will look like:
440
+
441
+ ```bash
442
+ psdi-data-convert filename.ext1 -t ext2
443
+ ```
444
+
445
+ This will convert the file 'filename.ext1' to format 'ext2' using the default converter (Open Babel). A list of files can also be provided, and they will each be converted in turn.
446
+
447
+ The full possible syntax for the script is:
448
+
449
+ ```
450
+ psdi-data-convert <input file 1> [<input file 2> <input file 3> ...] -t/--to <output format> [-f/--from <input file
451
+ format>] [-i/--in <input file location>] [-o/--out <location for output files>] [-w/--with <converter>] [--delete-input]
452
+ [--from-flags '<flags to be provided to the converter for reading input>'] [--to-flags '<flags to be provided to the
453
+ converter for writing output>'] [--from-options '<options to be provided to the converter for reading input>']
454
+ [--to-options '<options to be provided to the converter for writing output>'] [--coord-gen <coordinate generation
455
+ options] [-s/--strict] [--nc/--no-check] [-q/--quiet] [-g/--log-file <log file name] [--log-level <level>] [--log-mode
456
+ <mode>]
457
+ ```
458
+
459
+ Call `psdi-data-convert -h` for details on each of these options.
460
+
461
+ #### Requesting Information on Possible Conversions
462
+
463
+ The script can also be used to get information on possible conversions by providing the `-l/--list` argument:
464
+
465
+ ```bash
466
+ psdi-data-convert -l
467
+ ```
468
+
469
+ Without any further arguments, the script will list converters available for use and file formats supported by at least one converter. More detailed information about a specific converter or conversion can be obtained through providing more information.
470
+
471
+ To get more information about a converter, call:
472
+
473
+ ```
474
+ psdi-data-convert -l <converter name>
475
+ ```
476
+
477
+ This will print general information on this converter, including what flags and options it accepts for all conversions, plus a table of what file formats it can handle for input and output.
478
+
479
+ To get information about which converters can handle a given conversion, call:
480
+
481
+ ```
482
+ psdi-data-convert -l -f <input format> -t <output format>
483
+ ```
484
+
485
+ This will provide a list of converters which can handle this conversion, and notes on the degree of success for each.
486
+
487
+ To get information on input/output flags and options a converter supports for given input/output file formats, call:
488
+
489
+ ```
490
+ psdi-data-convert -l <converter name> [-f <input format>] [-t <output format>]
491
+ ```
492
+
493
+ If an input format is provided, information on input flags and options accepted by the converter for this format will be provided, and similar for if an output format is provided.
494
+
495
+ ## Python Library
496
+
497
+ ### Installation
498
+
499
+ The CLA and Python library are installed together. See the [above instructions for installing the CLA](#installation), which will also install the Python library.
500
+
501
+ ### Use
502
+
503
+ Once installed, this project's library can be imported through the following within Python:
504
+
505
+ ```python
506
+ import psdi_data_conversion
507
+ ```
508
+
509
+ The most useful modules and functions within this package to know about are:
510
+
511
+ - `psdi_data_conversion`
512
+ - `converter`
513
+ - `run_converter`
514
+ - `constants`
515
+ - `database`
516
+
517
+ #### `run_converter`
518
+
519
+ This is the standard method to run a file conversion. This method may be imported via:
520
+
521
+ ```python
522
+ from psdi_data_conversion.converter import run_converter
523
+ ```
524
+
525
+ For a simple conversion, this can be used via:
526
+
527
+ ```python
528
+ run_converter(filename, to_format, name=name, data=data)
529
+ ```
530
+
531
+ Where `filename` is the name of the file to convert (either fully-qualified or relative to the current directory), `to_format` is the desired format to convert to (e.g. `"pdb"`), `name` is the name of the converter to use (default "Open Babel"), and `data` is a dict of any extra information required by the specific converter being used, such as flags for how to read/write input/output files (default empty dict).
532
+
533
+ See the method's documentation via `help(run_converter)` after importing it for further details on usage.
534
+
535
+ #### `constants`
536
+
537
+ This package defines most constants used in the package. It may be imported via:
538
+
539
+ ```python
540
+ from psdi_data_conversion import constants
541
+ ```
542
+
543
+ Of the constants not defined in this package, the most notable are the names of available converters. Each converter has its own name defined in its module within the `psdi_data_conversion.converters` package (e.g. `psdi_data_conversion.converters.atomsk.CONVERTER_ATO`), and these are compiled within the `psdi_data_conversion.converter` module into:
544
+
545
+ - `D_SUPPORTED_CONVERTERS` - A dict which relates the names of all converters supported by this package to their classes
546
+ - `D_REGISTERED_CONVERTERS` - As above, but limited to those converters which can be run on the current machine (e.g. a converter may require a precompiled binary which is only available for certain platforms, and hence it will be in the "supported" dict but not the "registered" dict)
547
+ - `L_SUPPORTED_CONVERTERS`/`L_REGISTERED_CONVERTERS` - Lists of the names of supported/registered converters
548
+
549
+ #### `database`
550
+
551
+ The `database` module provides classes and methods to interface with the database of converters, file formats, and known possible conversions. This database is distributed with the project at `psdi_data_conversion/static/data/data.json`, but isn't user-friendly to read. The methods provided in this module provide a more user-friendly way to make common queries from the database:
552
+
553
+ - `get_converter_info` - This method takes the name of a converter and returns an object containing the general information about it stored in the database (note that this doesn't include file formats it can handle - use the `get_possible_formats` method for that)
554
+ - `get_format_info` - This method takes the name of a file format (its extension) and returns an object containing the general information about it stored in the database
555
+ - `get_degree_of_success` - This method takes the name of a converter, the name of an input file format (its extension), and the name of an output file format, and provides the degree of success for this conversion (`None` if not possible, otherwise a string describing it)
556
+ - `get_possible_converters` - This method takes the names of an input and output file format, and returns a list of converters which can perform the desired conversion and their degree of success
557
+ - `get_possible_formats` - This method takes the name of a converter and returns a list of input formats it can accept and a list of output formats it can produce. While it's usually a safe bet that a converter can handle any combination between these lists, it's best to make sure that it can with the `get_degree_of_success` method
558
+ - `get_in_format_args` and `get_out_format_args` - These methods take the name of a converter and the name of an input/output file format, and return a list of info on flags accepted by the converter when using this format for input/output
559
+ - `get_conversion_quality` - Provides information on the quality of a conversion from one format to another with a given converter. If conversion isn't possible, returns `None`. Otherwise returns a short string describing the quality of the conversion, a string providing information on possible issues with the conversion, and a dict providing details on property support between the input and output formats
560
+
561
+ ### Further Information
562
+
563
+ The code documentation for the Python library is published online at https://psdi-uk.github.io/psdi-data-conversion/. Information on modules, classes, and methods in the package can also be obtained through standard Python methods such as `help()` and `dir()`.
564
+
565
+ ## Using the Online Conversion Service
566
+
567
+ Enter https://psdidev2.azurewebsites.net in a browser. Guidance on usage is given on each page of the website.
568
+
569
+ ## Running the Python/Flask app locally
570
+
571
+ ### Installation and Setup
572
+
573
+ Install the package and its requirements, including the optional requirements used to run the GUI locally, by executing the following command from this project's directory:
574
+
575
+ ```bash
576
+ pip install .'[gui]'
577
+ ```
578
+
579
+ If your system does not allow installs in this manner, it may be necessary to set up a virtual environment. See the instructions in the [command-line application installation](#installation) section above for how to do that, and then try to install again once you've set one up and activated it.
580
+
581
+ If you've cloned this repository, you can use the `run_local.sh` bash script to run the application. Otherwise (e.g. if you've installed from a wheel or PyPI), copy and paste the following into a script:
582
+
583
+ ```bash
584
+ #!/bin/bash
585
+
586
+ # The envvar MAX_FILESIZE can be used to set the maximum allowed filesize in MB - 0 indicates no maximum
587
+ if [ -z $MAX_FILESIZE ]; then
588
+ export MAX_FILESIZE=0
589
+ fi
590
+
591
+ # Logging control - "full" sets server-style logging, which is necessary to produce the output logs with the expected
592
+ # names. This should not be changed, or else errors will occur
593
+ export LOG_MODE=full
594
+
595
+ # The level to log at. Leave blank for defaults, which logs at INFO level for user output and ERROR level for the server
596
+ # log and stdout. If set to a different value here (e.g. DEBUG), all these channels will be set to that level
597
+ export LOG_LEVEL=
598
+
599
+ # The envvar SERVICE_MODE can be set to "true" to make this behave as if it's running as the public web service -
600
+ # uncomment the following line to enable that
601
+ # export SERVICE_MODE=true
602
+
603
+ # Uncomment the following line to enable debug mode
604
+ # export FLASK_ENV=development
605
+
606
+ # Execute a local run of the application from the proper path
607
+
608
+ PACKAGE_PATH=`python -c "import psdi_data_conversion; print(psdi_data_conversion.__path__[0])"`
609
+ cd $PACKAGE_PATH/..
610
+ python -m flask --app psdi_data_conversion/app.py run
611
+ ```
612
+
613
+ If desired, you can modify the environmental variables set in this script to modify the operation - see the comments on each for details.
614
+
615
+ ### Running the App
616
+
617
+ Run the `run_local.sh` script to start the server. You can then access the website by going to <http://127.0.0.1:5000> in a browser (this will also be printed in the terminal, and you can CTRL+click it there to open it in your default browser). Guidance for using the app is given on each page of it.
618
+
619
+ In case of problems when using Chrome, try opening Chrome from the command line:
620
+ open -a "Google Chrome.app" --args --allow-file-access-from-files
621
+
622
+ ## Extending Functionality
623
+
624
+ The Python library and CLA are written to make it easy to extend the functionality of this package to use other file format converters. This can be done by downloading or cloning the project's source from it's GitHub Repository (https://github.com/PSDI-UK/psdi-data-conversion), editing the code to add your converter following the guidance in the "[Adding File Format Converters](https://github.com/PSDI-UK/psdi-data-conversion/blob/main/CONTRIBUTING.md#adding-file-format-converters)" section of CONTRIBUTING.md to integrate it with the Python code, and installing the modified package on your system via:
625
+
626
+ ```bash
627
+ pip install --editable .'[test]'
628
+ ```
629
+
630
+ (This command uses the `--editable` option and optional `test` dependencies to ease the process of testing and debugging your changes.)
631
+
632
+ Note that when adding a converter in this manner, information on its possible conversions will not be added to the database, and so these will not show up when you run the CLA with the `-l/--list` option. You will also need to add the `--nc/--no-check` option when running conversions to skip the database check that the conversion is allowed.
633
+
634
+ ## Testing
635
+
636
+ To test the CLA and Python library, install the optional testing requirements locally (ideally within a virtual environment) and test with pytest by executing the following commands from this project's directory:
637
+
638
+ ```bash
639
+ pip install .'[test]'
640
+ pytest
641
+ ```
642
+
643
+ To test the local version of the web app, install the GUI testing requirements locally (which also include the standard GUI requirements and standard testing requirements), start the server, and test by executing the GUI test script:
644
+
645
+ ```bash
646
+ pip install .'[gui-test]'
647
+ ./run_local.sh & # Start the server for the web app in the background
648
+ cd tests/selenium
649
+ ./run.sh
650
+ kill %1 # Stop the web server - it may have a different job ID. If you don't know the job ID, you can alternatively call "fg" to bring the job to the foreground, then type CTRL+c to stop it
651
+ ```
652
+
653
+ ## Contributors
654
+
655
+ - Ray Whorley
656
+ - Don Cruickshank
657
+ - Samantha Pearman-Kanza (s.pearman-kanza@soton.ac.uk)
658
+ - Bryan Gillis (7204836+brgillis@users.noreply.github.com)
659
+ - Tom Underwood
660
+
661
+ ## Funding
662
+
663
+ PSDI acknowledges the funding support by the EPSRC grants EP/X032701/1, EP/X032663/1 and EP/W032252/1