pyausaxs 1.3.0__tar.gz
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.
- pyausaxs-1.3.0/LICENSE +165 -0
- pyausaxs-1.3.0/PKG-INFO +61 -0
- pyausaxs-1.3.0/README.md +37 -0
- pyausaxs-1.3.0/pyausaxs/__init__.py +19 -0
- pyausaxs-1.3.0/pyausaxs/__main__.py +218 -0
- pyausaxs-1.3.0/pyausaxs/__pyinstaller/__init__.py +0 -0
- pyausaxs-1.3.0/pyausaxs/__pyinstaller/hook-pyausaxs.py +14 -0
- pyausaxs-1.3.0/pyausaxs/__pyinstaller/pyinstaller.py +4 -0
- pyausaxs-1.3.0/pyausaxs/architecture.py +114 -0
- pyausaxs-1.3.0/pyausaxs/config.py +1 -0
- pyausaxs-1.3.0/pyausaxs/gui/__init__.py +6 -0
- pyausaxs-1.3.0/pyausaxs/gui/data_pane.py +490 -0
- pyausaxs-1.3.0/pyausaxs/gui/em_pane.py +133 -0
- pyausaxs-1.3.0/pyausaxs/gui/gui.py +86 -0
- pyausaxs-1.3.0/pyausaxs/gui/load_recovery.py +197 -0
- pyausaxs-1.3.0/pyausaxs/gui/panes.py +562 -0
- pyausaxs-1.3.0/pyausaxs/gui/plotting.py +521 -0
- pyausaxs-1.3.0/pyausaxs/gui/rigidbody_pane.py +1150 -0
- pyausaxs-1.3.0/pyausaxs/gui/runner.py +221 -0
- pyausaxs-1.3.0/pyausaxs/gui/saxs_pane.py +153 -0
- pyausaxs-1.3.0/pyausaxs/gui/session.py +109 -0
- pyausaxs-1.3.0/pyausaxs/gui/structure_pane.py +1566 -0
- pyausaxs-1.3.0/pyausaxs/gui/theme.py +197 -0
- pyausaxs-1.3.0/pyausaxs/gui/widgets.py +934 -0
- pyausaxs-1.3.0/pyausaxs/integration.py +91 -0
- pyausaxs-1.3.0/pyausaxs/loader.py +119 -0
- pyausaxs-1.3.0/pyausaxs/plot/__init__.py +0 -0
- pyausaxs-1.3.0/pyausaxs/plot/plot.py +140 -0
- pyausaxs-1.3.0/pyausaxs/plot/plot_animator.py +151 -0
- pyausaxs-1.3.0/pyausaxs/plot/plot_helper.py +665 -0
- pyausaxs-1.3.0/pyausaxs/signatures.py +52 -0
- pyausaxs-1.3.0/pyausaxs/wrapper/AUSAXS.py +123 -0
- pyausaxs-1.3.0/pyausaxs/wrapper/BackendObject.py +52 -0
- pyausaxs-1.3.0/pyausaxs/wrapper/Datafile.py +124 -0
- pyausaxs-1.3.0/pyausaxs/wrapper/ExactDebye.py +71 -0
- pyausaxs-1.3.0/pyausaxs/wrapper/Filetypes.py +54 -0
- pyausaxs-1.3.0/pyausaxs/wrapper/FitResult.py +189 -0
- pyausaxs-1.3.0/pyausaxs/wrapper/FormFactor.py +90 -0
- pyausaxs-1.3.0/pyausaxs/wrapper/Histogram.py +52 -0
- pyausaxs-1.3.0/pyausaxs/wrapper/IterativeFit.py +132 -0
- pyausaxs-1.3.0/pyausaxs/wrapper/Models.py +62 -0
- pyausaxs-1.3.0/pyausaxs/wrapper/Molecule.py +465 -0
- pyausaxs-1.3.0/pyausaxs/wrapper/Output.py +30 -0
- pyausaxs-1.3.0/pyausaxs/wrapper/PDBfile.py +231 -0
- pyausaxs-1.3.0/pyausaxs/wrapper/Rigidbody.py +373 -0
- pyausaxs-1.3.0/pyausaxs/wrapper/__init__.py +0 -0
- pyausaxs-1.3.0/pyausaxs/wrapper/sasview.py +51 -0
- pyausaxs-1.3.0/pyausaxs/wrapper/settings.py +254 -0
- pyausaxs-1.3.0/pyausaxs.egg-info/PKG-INFO +61 -0
- pyausaxs-1.3.0/pyausaxs.egg-info/SOURCES.txt +67 -0
- pyausaxs-1.3.0/pyausaxs.egg-info/dependency_links.txt +1 -0
- pyausaxs-1.3.0/pyausaxs.egg-info/entry_points.txt +5 -0
- pyausaxs-1.3.0/pyausaxs.egg-info/requires.txt +13 -0
- pyausaxs-1.3.0/pyausaxs.egg-info/top_level.txt +1 -0
- pyausaxs-1.3.0/pyproject.toml +55 -0
- pyausaxs-1.3.0/setup.cfg +4 -0
- pyausaxs-1.3.0/tests/test_cmd_tools.py +22 -0
- pyausaxs-1.3.0/tests/test_fit.py +113 -0
- pyausaxs-1.3.0/tests/test_form_factors.py +22 -0
- pyausaxs-1.3.0/tests/test_histogram_debye.py +61 -0
- pyausaxs-1.3.0/tests/test_imports.py +23 -0
- pyausaxs-1.3.0/tests/test_io.py +75 -0
- pyausaxs-1.3.0/tests/test_misc.py +35 -0
- pyausaxs-1.3.0/tests/test_molecule.py +54 -0
- pyausaxs-1.3.0/tests/test_rigidbody.py +18 -0
- pyausaxs-1.3.0/tests/test_script_quoting.py +65 -0
- pyausaxs-1.3.0/tests/test_settings.py +69 -0
- pyausaxs-1.3.0/tests/test_singleton.py +26 -0
- pyausaxs-1.3.0/tests/test_structure_preview_script.py +94 -0
pyausaxs-1.3.0/LICENSE
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
pyausaxs-1.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyausaxs
|
|
3
|
+
Version: 1.3.0
|
|
4
|
+
Summary: An efficient small-angle Debye scattering calculator.
|
|
5
|
+
Author-email: Kristian Lytje <kristian.lytje@uni-saarland.de>
|
|
6
|
+
License-Expression: LGPL-3.0-or-later
|
|
7
|
+
Project-URL: Homepage, https://github.com/AUSAXS/pyAUSAXS
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: py-cpuinfo>=8.0.0
|
|
14
|
+
Requires-Dist: numpy>=1.20.0
|
|
15
|
+
Provides-Extra: plots
|
|
16
|
+
Requires-Dist: matplotlib>=3.7; extra == "plots"
|
|
17
|
+
Requires-Dist: scipy>=1.10; extra == "plots"
|
|
18
|
+
Provides-Extra: gui
|
|
19
|
+
Requires-Dist: pyausaxs[plots]; extra == "gui"
|
|
20
|
+
Requires-Dist: tkinterdnd2>=0.3.0; extra == "gui"
|
|
21
|
+
Provides-Extra: all
|
|
22
|
+
Requires-Dist: pyausaxs[gui,plots]; extra == "all"
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+

|
|
26
|
+

|
|
27
|
+
|
|
28
|
+
[](#installation)
|
|
29
|
+
[](https://python.org/downloads)
|
|
30
|
+
[](https://pypi.org/project/pyausaxs)
|
|
31
|
+
[](https://pypistats.org/packages/pyausaxs)
|
|
32
|
+
|
|
33
|
+
Welcome to `pyAUSAXS`, the perhaps fastest Python tool for evaluating the scattering intensity of biological samples and crystals.
|
|
34
|
+
`pyAUSAXS` is a Python wrapper around [`AUSAXS`](https://github.com/AUSAXS/AUSAXS), the high-performance C++ backend, offering easy
|
|
35
|
+
access to most of its features.
|
|
36
|
+
|
|
37
|
+
## Who is this for?
|
|
38
|
+
`pyAUSAXS` offers highly efficient calculation of the expected scattering intensity of your structures. These calculations include
|
|
39
|
+
form factors, and hydration shell & excluded volume modeling. Calculations without these solvent effects are also possible, if only
|
|
40
|
+
the pure Debye calculation is of interest. For a full overview of how it works, see the `AUSAXS` article:
|
|
41
|
+
[10.1107/S160057672500562X](https://doi.org/10.1107/S160057672500562X).
|
|
42
|
+
|
|
43
|
+
## Installation
|
|
44
|
+
To install, simply run:
|
|
45
|
+
```bash
|
|
46
|
+
pip install pyausaxs
|
|
47
|
+
```
|
|
48
|
+
and you are good to go!
|
|
49
|
+
|
|
50
|
+
## Usage
|
|
51
|
+
Proper documentation is currently being written. For now, please refer to the runnable examples [here](https://github.com/AUSAXS/pyAUSAXS/tree/master/examples).
|
|
52
|
+
|
|
53
|
+
## Contributing
|
|
54
|
+
Are you encountering problems, have feedback or suggestions, or are you considering contributing to the project? Please check out the [contributor guidelines](CONTRIBUTING.md).
|
|
55
|
+
|
|
56
|
+
## Citation
|
|
57
|
+
If you use `pyAUSAXS` in published work, please cite the following paper:
|
|
58
|
+
Small-angle X-ray scattering profile calculation for high-resolution models of biomacromolecules
|
|
59
|
+
(doi: [10.1107/S160057672500562X](https://doi.org/10.1107/S160057672500562X))
|
|
60
|
+
|
|
61
|
+
*This project is licenced under the GNU Lesser General Public Licence v3.0.*
|
pyausaxs-1.3.0/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+

|
|
2
|
+

|
|
3
|
+
|
|
4
|
+
[](#installation)
|
|
5
|
+
[](https://python.org/downloads)
|
|
6
|
+
[](https://pypi.org/project/pyausaxs)
|
|
7
|
+
[](https://pypistats.org/packages/pyausaxs)
|
|
8
|
+
|
|
9
|
+
Welcome to `pyAUSAXS`, the perhaps fastest Python tool for evaluating the scattering intensity of biological samples and crystals.
|
|
10
|
+
`pyAUSAXS` is a Python wrapper around [`AUSAXS`](https://github.com/AUSAXS/AUSAXS), the high-performance C++ backend, offering easy
|
|
11
|
+
access to most of its features.
|
|
12
|
+
|
|
13
|
+
## Who is this for?
|
|
14
|
+
`pyAUSAXS` offers highly efficient calculation of the expected scattering intensity of your structures. These calculations include
|
|
15
|
+
form factors, and hydration shell & excluded volume modeling. Calculations without these solvent effects are also possible, if only
|
|
16
|
+
the pure Debye calculation is of interest. For a full overview of how it works, see the `AUSAXS` article:
|
|
17
|
+
[10.1107/S160057672500562X](https://doi.org/10.1107/S160057672500562X).
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
To install, simply run:
|
|
21
|
+
```bash
|
|
22
|
+
pip install pyausaxs
|
|
23
|
+
```
|
|
24
|
+
and you are good to go!
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
Proper documentation is currently being written. For now, please refer to the runnable examples [here](https://github.com/AUSAXS/pyAUSAXS/tree/master/examples).
|
|
28
|
+
|
|
29
|
+
## Contributing
|
|
30
|
+
Are you encountering problems, have feedback or suggestions, or are you considering contributing to the project? Please check out the [contributor guidelines](CONTRIBUTING.md).
|
|
31
|
+
|
|
32
|
+
## Citation
|
|
33
|
+
If you use `pyAUSAXS` in published work, please cite the following paper:
|
|
34
|
+
Small-angle X-ray scattering profile calculation for high-resolution models of biomacromolecules
|
|
35
|
+
(doi: [10.1107/S160057672500562X](https://doi.org/10.1107/S160057672500562X))
|
|
36
|
+
|
|
37
|
+
*This project is licenced under the GNU Lesser General Public Licence v3.0.*
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from .wrapper.PDBfile import read_pdb
|
|
2
|
+
from .wrapper.Datafile import read_data, create_datafile
|
|
3
|
+
from .wrapper.Molecule import create_molecule
|
|
4
|
+
from .wrapper.IterativeFit import manual_fit
|
|
5
|
+
from .wrapper.Rigidbody import Rigidbody, prepare_rigidbody_refinement
|
|
6
|
+
from .wrapper.BackendObject import advanced
|
|
7
|
+
from .wrapper.ExactDebye import unoptimized
|
|
8
|
+
from .wrapper.Models import ExvModel, ExvTable
|
|
9
|
+
from .wrapper.FormFactor import form_factor
|
|
10
|
+
from .wrapper.settings import settings
|
|
11
|
+
from .wrapper.sasview import sasview
|
|
12
|
+
from .wrapper.Output import set_output_callback, reset_output_callback
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
"read_pdb", "read_data", "create_datafile", "create_molecule", "sasview", "settings", "manual_fit",
|
|
16
|
+
"prepare_rigidbody_refinement", "ExvModel", "ExvTable", "unoptimized", "advanced", "form_factor", "Rigidbody",
|
|
17
|
+
"set_output_callback", "reset_output_callback"
|
|
18
|
+
]
|
|
19
|
+
__version__ = "1.3.0"
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import importlib.util
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
from .__init__ import __version__
|
|
6
|
+
|
|
7
|
+
# tool name -> (backend C function name, program name passed as argv[0])
|
|
8
|
+
_CLI_TOOLS = {
|
|
9
|
+
"fit": ("cli_saxs_fitter", "ausaxs_fit"),
|
|
10
|
+
"em": ("cli_em_fitter", "ausaxs_em"),
|
|
11
|
+
"rigidbody": ("cli_rigidbody", "ausaxs_rigidbody"),
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
# Optional CLI tools backed by pip extras: tool -> (extra name, modules that must be importable).
|
|
15
|
+
# We check _tkinter (the C extension), not tkinter (whose pure-Python package ships even on no-Tk builds).
|
|
16
|
+
_OPTIONAL_TOOLS = {
|
|
17
|
+
"plot": ("plots", ("matplotlib", "scipy")),
|
|
18
|
+
"gui": ("gui", ("matplotlib", "scipy", "_tkinter")),
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _extra_available(tool: str) -> bool:
|
|
23
|
+
"""Check if the optional dependencies for a tool are available by trying to find their modules."""
|
|
24
|
+
_, modules = _OPTIONAL_TOOLS[tool]
|
|
25
|
+
for module in modules:
|
|
26
|
+
try:
|
|
27
|
+
if importlib.util.find_spec(module) is None:
|
|
28
|
+
return False
|
|
29
|
+
except ModuleNotFoundError:
|
|
30
|
+
return False
|
|
31
|
+
return True
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _extra_missing_error(tool: str) -> int:
|
|
35
|
+
extra = _OPTIONAL_TOOLS[tool][0]
|
|
36
|
+
print(
|
|
37
|
+
f"Error: the '{extra}' extension is not installed."
|
|
38
|
+
f"\nPlease install it by running the command \"pip install pyausaxs[{extra}]\".",
|
|
39
|
+
file=sys.stderr,
|
|
40
|
+
)
|
|
41
|
+
return 1
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class _Formatter(argparse.HelpFormatter):
|
|
45
|
+
def _format_action(self, action):
|
|
46
|
+
result = super()._format_action(action)
|
|
47
|
+
if action.nargs == argparse.PARSER:
|
|
48
|
+
lines = result.splitlines(keepends=True)
|
|
49
|
+
return ''.join(
|
|
50
|
+
line for line in lines[1:] if argparse.SUPPRESS not in line
|
|
51
|
+
)
|
|
52
|
+
return result
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _build_parser() -> argparse.ArgumentParser:
|
|
56
|
+
parser = argparse.ArgumentParser(
|
|
57
|
+
prog="ausaxs",
|
|
58
|
+
description="An efficient small-angle Debye scattering calculator.",
|
|
59
|
+
formatter_class=_Formatter,
|
|
60
|
+
)
|
|
61
|
+
parser.add_argument("-v", "--version", action="version", version=f"pyAUSAXS {__version__}")
|
|
62
|
+
parser.add_argument("--license", action="store_true", help="show license information and exit")
|
|
63
|
+
sub = parser.add_subparsers(dest="tool", title="tools")
|
|
64
|
+
|
|
65
|
+
# C CLI tools — argparse does not consume their flags; everything after the subcommand name is passed through to the backend as-is.
|
|
66
|
+
for name, desc in [
|
|
67
|
+
("fit", "validate structures against SAXS data"),
|
|
68
|
+
("em", "validate EM maps against SAXS data"),
|
|
69
|
+
("rigidbody", "perform rigid-body refinements"),
|
|
70
|
+
("plot", "plot results from other tools"),
|
|
71
|
+
("gui", "start the graphical interface"),
|
|
72
|
+
]:
|
|
73
|
+
if name in _OPTIONAL_TOOLS and not _extra_available(name):
|
|
74
|
+
desc += " (disabled)"
|
|
75
|
+
sub.add_parser(name, help=desc, add_help=False)
|
|
76
|
+
|
|
77
|
+
# 'setup' is unlisted and has its own structured flags.
|
|
78
|
+
setup = sub.add_parser(
|
|
79
|
+
"setup", help=argparse.SUPPRESS,
|
|
80
|
+
description="Configure the AUSAXS backend.",
|
|
81
|
+
)
|
|
82
|
+
grp = setup.add_mutually_exclusive_group()
|
|
83
|
+
grp.add_argument(
|
|
84
|
+
"--relink", metavar="PATH",
|
|
85
|
+
help="use the backend library at PATH instead of the bundled one",
|
|
86
|
+
)
|
|
87
|
+
grp.add_argument(
|
|
88
|
+
"--reset", action="store_true",
|
|
89
|
+
help="forget any relinked path and use the bundled library",
|
|
90
|
+
)
|
|
91
|
+
grp.add_argument(
|
|
92
|
+
"--show", action="store_true",
|
|
93
|
+
help="show which backend library is currently in use (default)",
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
# # Put the tools section above the options section in help output.
|
|
97
|
+
by_title = {g.title: g for g in parser._action_groups}
|
|
98
|
+
parser._action_groups[:] = [by_title["tools"], by_title["options"]]
|
|
99
|
+
|
|
100
|
+
return parser
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def main(argv=None):
|
|
104
|
+
if argv is None:
|
|
105
|
+
argv = sys.argv[1:]
|
|
106
|
+
|
|
107
|
+
parser = _build_parser()
|
|
108
|
+
ns, remaining = parser.parse_known_args(argv)
|
|
109
|
+
|
|
110
|
+
if ns.license:
|
|
111
|
+
_print_licence()
|
|
112
|
+
return 0
|
|
113
|
+
|
|
114
|
+
if ns.tool is None:
|
|
115
|
+
parser.print_help()
|
|
116
|
+
return 0
|
|
117
|
+
|
|
118
|
+
match ns.tool:
|
|
119
|
+
case "setup":
|
|
120
|
+
return _run_setup(ns)
|
|
121
|
+
case "gui":
|
|
122
|
+
if not _extra_available("gui"):
|
|
123
|
+
return _extra_missing_error("gui")
|
|
124
|
+
print("Warning: The Python GUI is highly experimental. Use at your own risk.", file=sys.stderr)
|
|
125
|
+
from .gui import main as gui_main
|
|
126
|
+
return gui_main(remaining)
|
|
127
|
+
case "plot":
|
|
128
|
+
if not _extra_available("plot"):
|
|
129
|
+
return _extra_missing_error("plot")
|
|
130
|
+
from .plot.plot import main as plot_main
|
|
131
|
+
return plot_main(remaining)
|
|
132
|
+
case t if t in _CLI_TOOLS:
|
|
133
|
+
return _run_cli_tool(t, remaining)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def _run_cli_tool(tool, args):
|
|
137
|
+
from .wrapper.AUSAXS import AUSAXS
|
|
138
|
+
func_name, prog = _CLI_TOOLS[tool]
|
|
139
|
+
lib = AUSAXS().lib()
|
|
140
|
+
if not lib.ready():
|
|
141
|
+
print("Error: AUSAXS library not ready", file=sys.stderr)
|
|
142
|
+
return 1
|
|
143
|
+
return _call_cli(getattr(lib.functions, func_name), [prog, *args])
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def _call_cli(cli_func, args):
|
|
147
|
+
import ctypes as ct
|
|
148
|
+
c_args = [arg.encode("utf-8") for arg in args]
|
|
149
|
+
c_argv = (ct.c_char_p * len(c_args))(*c_args)
|
|
150
|
+
return cli_func(len(c_args), c_argv)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def _run_setup(ns):
|
|
154
|
+
from pathlib import Path
|
|
155
|
+
from . import loader
|
|
156
|
+
from .wrapper.AUSAXS import AUSAXS
|
|
157
|
+
|
|
158
|
+
if ns.relink:
|
|
159
|
+
previous = loader.get_relink_path()
|
|
160
|
+
try:
|
|
161
|
+
cache = loader.set_relink_path(ns.relink)
|
|
162
|
+
except (FileNotFoundError, ValueError) as e:
|
|
163
|
+
print(f"Error: {e}", file=sys.stderr)
|
|
164
|
+
return 1
|
|
165
|
+
|
|
166
|
+
# validate the newly relinked library actually loads before committing to it
|
|
167
|
+
if not AUSAXS.ready():
|
|
168
|
+
error = AUSAXS.init_error()
|
|
169
|
+
if previous is not None:
|
|
170
|
+
loader.set_relink_path(previous)
|
|
171
|
+
else:
|
|
172
|
+
loader.clear_relink_path()
|
|
173
|
+
AUSAXS.reset_singleton()
|
|
174
|
+
print(f"Error: '{ns.relink}' failed to load as an AUSAXS backend: {error}", file=sys.stderr)
|
|
175
|
+
return 1
|
|
176
|
+
|
|
177
|
+
linked = loader.get_relink_path()
|
|
178
|
+
if "ausaxs" not in Path(linked).stem.lower():
|
|
179
|
+
print(
|
|
180
|
+
f"Warning: '{Path(linked).name}' does not look like an AUSAXS "
|
|
181
|
+
"library (its name should contain 'ausaxs').",
|
|
182
|
+
file=sys.stderr,
|
|
183
|
+
)
|
|
184
|
+
print(f"Relinked AUSAXS backend to: {linked}")
|
|
185
|
+
print(f"(stored in {cache})")
|
|
186
|
+
return 0
|
|
187
|
+
|
|
188
|
+
if ns.reset:
|
|
189
|
+
if loader.clear_relink_path():
|
|
190
|
+
print("Reset: now using the bundled AUSAXS backend.")
|
|
191
|
+
else:
|
|
192
|
+
print("No relink configured; already using the bundled backend.")
|
|
193
|
+
return 0
|
|
194
|
+
|
|
195
|
+
# default: --show
|
|
196
|
+
path, origin = loader.resolve_lib()
|
|
197
|
+
print(f"AUSAXS backend in use: {path}")
|
|
198
|
+
print({
|
|
199
|
+
"relink": " (relinked; reset with: ausaxs setup --reset)",
|
|
200
|
+
"environment": " (set via the AUSAXS_LIB environment variable)",
|
|
201
|
+
"bundled": " (bundled)",
|
|
202
|
+
"prefix": " (installed in the environment prefix)",
|
|
203
|
+
}[origin])
|
|
204
|
+
return 0
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
def _print_licence():
|
|
208
|
+
import importlib.resources as pkg_resources
|
|
209
|
+
try:
|
|
210
|
+
ref = pkg_resources.files("pyausaxs").joinpath("../../LICENSE")
|
|
211
|
+
with pkg_resources.as_file(ref) as p:
|
|
212
|
+
print(p.read_text(encoding="utf-8"))
|
|
213
|
+
except Exception:
|
|
214
|
+
print("LGPL-3.0-or-later — see https://github.com/AUSAXS/pyAUSAXS/blob/master/LICENSE")
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
if __name__ == "__main__":
|
|
218
|
+
raise SystemExit(main())
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from PyInstaller.utils.hooks import collect_data_files
|
|
2
|
+
from pyausaxs.loader import find_lib_path
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
datas = collect_data_files('pyausaxs')
|
|
6
|
+
hiddenimports = []
|
|
7
|
+
binaries = []
|
|
8
|
+
|
|
9
|
+
lib_path = find_lib_path()
|
|
10
|
+
if os.path.exists(lib_path):
|
|
11
|
+
datas.append((lib_path, 'pyausaxs/resources'))
|
|
12
|
+
binaries.append((lib_path, '.'))
|
|
13
|
+
else:
|
|
14
|
+
raise FileNotFoundError(f"Library not found at expected path: {lib_path}")
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
import os
|
|
4
|
+
import platform
|
|
5
|
+
import cpuinfo
|
|
6
|
+
|
|
7
|
+
class OS(Enum):
|
|
8
|
+
WIN = 0
|
|
9
|
+
LINUX = 1
|
|
10
|
+
MAC = 2
|
|
11
|
+
UNKNOWN = 3
|
|
12
|
+
|
|
13
|
+
class CPUFeatures:
|
|
14
|
+
"""CPU feature detection for AUSAXS library compatibility."""
|
|
15
|
+
|
|
16
|
+
@staticmethod
|
|
17
|
+
def get_cpu_info():
|
|
18
|
+
try:
|
|
19
|
+
return cpuinfo.get_cpu_info()
|
|
20
|
+
except:
|
|
21
|
+
return {}
|
|
22
|
+
|
|
23
|
+
@staticmethod
|
|
24
|
+
def has_sse_support():
|
|
25
|
+
cpu_info = CPUFeatures.get_cpu_info()
|
|
26
|
+
flags = cpu_info.get('flags', [])
|
|
27
|
+
return any('sse' in flag.lower() for flag in flags)
|
|
28
|
+
|
|
29
|
+
@staticmethod
|
|
30
|
+
def has_avx_support():
|
|
31
|
+
cpu_info = CPUFeatures.get_cpu_info()
|
|
32
|
+
flags = cpu_info.get('flags', [])
|
|
33
|
+
return 'avx' in [flag.lower() for flag in flags]
|
|
34
|
+
|
|
35
|
+
@staticmethod
|
|
36
|
+
def has_avx2_support():
|
|
37
|
+
cpu_info = CPUFeatures.get_cpu_info()
|
|
38
|
+
flags = cpu_info.get('flags', [])
|
|
39
|
+
return 'avx2' in [flag.lower() for flag in flags]
|
|
40
|
+
|
|
41
|
+
@staticmethod
|
|
42
|
+
def get_architecture():
|
|
43
|
+
return platform.machine().lower()
|
|
44
|
+
|
|
45
|
+
@staticmethod
|
|
46
|
+
def is_compatible_architecture():
|
|
47
|
+
def is_compatible_macos():
|
|
48
|
+
arch = CPUFeatures.get_architecture()
|
|
49
|
+
return arch in ['x86_64', 'amd64', 'arm64']
|
|
50
|
+
|
|
51
|
+
def is_compatible_linux():
|
|
52
|
+
arch = CPUFeatures.get_architecture()
|
|
53
|
+
if arch in ['aarch64', 'arm64']: return True
|
|
54
|
+
return arch in ['x86_64', 'amd64'] and CPUFeatures.has_avx2_support()
|
|
55
|
+
|
|
56
|
+
def is_compatible_windows():
|
|
57
|
+
arch = CPUFeatures.get_architecture()
|
|
58
|
+
return arch in ['x86_64', 'amd64'] and CPUFeatures.has_avx2_support()
|
|
59
|
+
|
|
60
|
+
match get_os():
|
|
61
|
+
case OS.MAC: return is_compatible_macos()
|
|
62
|
+
case OS.LINUX: return is_compatible_linux()
|
|
63
|
+
case OS.WIN: return is_compatible_windows()
|
|
64
|
+
case _: return False
|
|
65
|
+
|
|
66
|
+
def get_os():
|
|
67
|
+
if platform.system() == "Windows": return OS.WIN
|
|
68
|
+
elif platform.system() == "Linux": return OS.LINUX
|
|
69
|
+
elif platform.system() == "Darwin": return OS.MAC
|
|
70
|
+
return OS.UNKNOWN
|
|
71
|
+
|
|
72
|
+
def get_cache_dir() -> Path:
|
|
73
|
+
"""Return the AUSAXS cache directory, mirroring the C++ backend's path resolution."""
|
|
74
|
+
_os = get_os()
|
|
75
|
+
if _os == OS.WIN:
|
|
76
|
+
base = os.environ.get("LOCALAPPDATA")
|
|
77
|
+
elif _os == OS.MAC:
|
|
78
|
+
base = os.path.join(os.environ.get("HOME", "~"), "Library", "Caches")
|
|
79
|
+
else:
|
|
80
|
+
base = os.environ.get("XDG_CACHE_HOME") or os.path.join(os.environ.get("HOME", "~"), ".cache")
|
|
81
|
+
return Path(base or ".") / "ausaxs"
|
|
82
|
+
|
|
83
|
+
def get_shared_lib_extension():
|
|
84
|
+
"""
|
|
85
|
+
Get the shared library extension for the current operating system, including the dot.
|
|
86
|
+
If the operating system is unknown, return an empty string.
|
|
87
|
+
"""
|
|
88
|
+
_os = get_os()
|
|
89
|
+
if _os == OS.WIN:
|
|
90
|
+
return ".dll"
|
|
91
|
+
elif _os == OS.LINUX:
|
|
92
|
+
return ".so"
|
|
93
|
+
elif _os == OS.MAC:
|
|
94
|
+
return ".dylib"
|
|
95
|
+
return ""
|
|
96
|
+
|
|
97
|
+
def _compat_cache_file() -> Path:
|
|
98
|
+
return get_cache_dir() / "cpu_compatible"
|
|
99
|
+
|
|
100
|
+
def is_architecture_compatible() -> bool:
|
|
101
|
+
"""Return whether the current CPU is compatible with the AUSAXS backend."""
|
|
102
|
+
cache = _compat_cache_file()
|
|
103
|
+
if cache.is_file():
|
|
104
|
+
return True
|
|
105
|
+
|
|
106
|
+
if not CPUFeatures.is_compatible_architecture():
|
|
107
|
+
return False
|
|
108
|
+
|
|
109
|
+
try:
|
|
110
|
+
cache.parent.mkdir(parents=True, exist_ok=True)
|
|
111
|
+
cache.write_text("ok", encoding="utf-8")
|
|
112
|
+
except OSError:
|
|
113
|
+
pass # caching is best-effort; we'll just re-check next time
|
|
114
|
+
return True
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
architecture_runtime_validation = True
|