autolei 1.0.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.
- autolei-1.0.0/LICENSE +11 -0
- autolei-1.0.0/PKG-INFO +130 -0
- autolei-1.0.0/README.md +85 -0
- autolei-1.0.0/autolei/__init__.py +1 -0
- autolei-1.0.0/autolei/_run.bat +2 -0
- autolei-1.0.0/autolei/autolei.py +385 -0
- autolei-1.0.0/autolei/autolei_core.py +2988 -0
- autolei-1.0.0/autolei/instrument_profile/Ceta-1k-200kV +15 -0
- autolei-1.0.0/autolei/instrument_profile/Ceta-2k-200kV +15 -0
- autolei-1.0.0/autolei/instrument_profile/Ceta-512-200kV +15 -0
- autolei-1.0.0/autolei/instrument_profile/Ceta-D-1024-SciLifeLab +15 -0
- autolei-1.0.0/autolei/instrument_profile/Ceta-D-2k-SciLifeLab +15 -0
- autolei-1.0.0/autolei/instrument_profile/Ceta-D-512-SciLifeLab +15 -0
- autolei-1.0.0/autolei/instrument_profile/Chettah-Themis-Z_SU +16 -0
- autolei-1.0.0/autolei/instrument_profile/Oneview-Themis-Z_SU +13 -0
- autolei-1.0.0/autolei/instrument_profile/TimePix-512_2100_SU +16 -0
- autolei-1.0.0/autolei/instrument_profile/TimePix-516_2100_SU +16 -0
- autolei-1.0.0/autolei/instrument_profile/__init__.py +0 -0
- autolei-1.0.0/autolei/realtime.py +1324 -0
- autolei-1.0.0/autolei/setting.ini +40 -0
- autolei-1.0.0/autolei/src/_XDSINP +227 -0
- autolei-1.0.0/autolei/src/__init__.py +0 -0
- autolei-1.0.0/autolei/src/analysis_hkl.py +1990 -0
- autolei-1.0.0/autolei/src/cif_io.py +349 -0
- autolei-1.0.0/autolei/src/extinction.json +4033 -0
- autolei-1.0.0/autolei/src/generate_pets.py +616 -0
- autolei-1.0.0/autolei/src/image_io.py +1445 -0
- autolei-1.0.0/autolei/src/symmetry_operation.py +788 -0
- autolei-1.0.0/autolei/src/util.py +699 -0
- autolei-1.0.0/autolei/src/xds_analysis.py +768 -0
- autolei-1.0.0/autolei/src/xds_cluster.py +1045 -0
- autolei-1.0.0/autolei/src/xds_input.py +1963 -0
- autolei-1.0.0/autolei/src/xds_refine.py +1070 -0
- autolei-1.0.0/autolei/src/xds_report.py +1165 -0
- autolei-1.0.0/autolei/src/xds_runner.py +419 -0
- autolei-1.0.0/autolei/src/xds_shelx.py +423 -0
- autolei-1.0.0/autolei/tool.py +463 -0
- autolei-1.0.0/pyproject.toml +69 -0
autolei-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Copyright 2024 Xiaodong Zou, Lei Wang and Yinlin Chen
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
4
|
+
|
|
5
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
6
|
+
|
|
7
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
8
|
+
|
|
9
|
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
10
|
+
|
|
11
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
autolei-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: autolei
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A GUI for electron diffraction data analysis
|
|
5
|
+
License: BSD 3-Clause
|
|
6
|
+
Keywords: electron-diffraction,XDS,microed,data-analysis,automation
|
|
7
|
+
Author: Lei Wang
|
|
8
|
+
Author-email: lei.wang@mmk.su.se
|
|
9
|
+
Maintainer: Lei Wang
|
|
10
|
+
Maintainer-email: lei.wang@mmk.su.se
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
14
|
+
Classifier: License :: Other/Proprietary License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Requires-Dist: fabio (>=0.14.0)
|
|
23
|
+
Requires-Dist: h5py (>=3.1.0)
|
|
24
|
+
Requires-Dist: hdf5plugin (>=3.3.1)
|
|
25
|
+
Requires-Dist: matplotlib (>=3.3.4)
|
|
26
|
+
Requires-Dist: mplcursors (>=0.5.1)
|
|
27
|
+
Requires-Dist: mpld3 (>=0.5.0)
|
|
28
|
+
Requires-Dist: mrcfile (>=1.5.0)
|
|
29
|
+
Requires-Dist: numba (>=0.53.0)
|
|
30
|
+
Requires-Dist: numpy (>=1.19.5)
|
|
31
|
+
Requires-Dist: openpyxl (>=3.0.0)
|
|
32
|
+
Requires-Dist: pandas (>=1.1.5)
|
|
33
|
+
Requires-Dist: pillow (>=8.0.0)
|
|
34
|
+
Requires-Dist: plotly (>=5.0.0)
|
|
35
|
+
Requires-Dist: scikit-image (>=0.18.0)
|
|
36
|
+
Requires-Dist: scipy (>=1.5.4)
|
|
37
|
+
Requires-Dist: screeninfo (>=0.8.1)
|
|
38
|
+
Requires-Dist: tqdm (>=4.46.1)
|
|
39
|
+
Project-URL: Bug Reports, https://gitlab.com/395736627tristone/autolei/issues
|
|
40
|
+
Project-URL: Documentation, https://gitlab.com/395736627tristone/autolei/docs
|
|
41
|
+
Project-URL: Homepage, https://gitlab.com/395736627tristone/autolei
|
|
42
|
+
Project-URL: Repository, https://gitlab.com/395736627tristone/autolei
|
|
43
|
+
Description-Content-Type: text/markdown
|
|
44
|
+
|
|
45
|
+
# AutoLEI
|
|
46
|
+
|
|
47
|
+
**Automated EffortLess MicroED Graphic User Interface (AutoLEI)** is an XDS-based GUI designed for real-time and batch processing of MicroED/3DED datasets. It provides a user-friendly platform for rapid, automated data processing and merging of multiple MicroED datasets, with well-designed and significantly streamlining structure determination workflows.
|
|
48
|
+
|
|
49
|
+
**Key Features**
|
|
50
|
+
- **User-Friendly Interface**: Simplifies MicroED data processing, requiring minimal manual input.
|
|
51
|
+
- **Batch Processing**: Handles large numbers of datasets with automated workflows.
|
|
52
|
+
- **Real-Time Data Processing**: Provides live feedback during data collection.
|
|
53
|
+
- **Versatility**: Supports diverse samples, including small molecules and proteins workflow.
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Installation
|
|
59
|
+
|
|
60
|
+
### Requirements
|
|
61
|
+
- **Operating Systems**: Linux or Windows via [WSL](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux) (versions 1/2).
|
|
62
|
+
- **Software Dependencies**:
|
|
63
|
+
- Python 3.8+ with libraries specified in `pyproject.toml`.
|
|
64
|
+
- [XDS](https://xds.mr.mpg.de/) and [XDSGUI](https://wiki.uni-konstanz.de/xds/index.php/XDSGUI).
|
|
65
|
+
- Optional tools: `xprep` for advanced features and LibreOffice for `.xlsx` files in Linux.
|
|
66
|
+
|
|
67
|
+
### Steps
|
|
68
|
+
1. Install via pip:
|
|
69
|
+
```bash
|
|
70
|
+
pip install autolei
|
|
71
|
+
```
|
|
72
|
+
For historical versions, use:
|
|
73
|
+
```bash
|
|
74
|
+
pip install autolei-[version_name].zip
|
|
75
|
+
```
|
|
76
|
+
2. Manual installation:
|
|
77
|
+
Follow the steps in the [Tutorial for AutoLEI](doc/AutoLEI_Tutorial.pdf) and [our Wiki](https://gitlab.com/395736627tristone/automicroedgui/-/wikis/home).
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Usage
|
|
82
|
+
|
|
83
|
+
### Command-line Usage
|
|
84
|
+
- **Launch the GUI**:
|
|
85
|
+
```bash
|
|
86
|
+
autolei
|
|
87
|
+
```
|
|
88
|
+
> *Note*: The first launch may take slightly longer as dependencies initialize.
|
|
89
|
+
|
|
90
|
+
- **Configure Settings**:
|
|
91
|
+
```bash
|
|
92
|
+
autolei_setting
|
|
93
|
+
```
|
|
94
|
+
The opened .ini file includes settings on screen scaling, multi-thread and report format.
|
|
95
|
+
|
|
96
|
+
- **Import Instrument**:
|
|
97
|
+
```bash
|
|
98
|
+
autolei_add_instrument [instrument_setting_file]
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
### GUI pages
|
|
103
|
+
AutoLEI is organised into multiple working pages:
|
|
104
|
+
- **Input**: Configure experiment parameters and generate input files.
|
|
105
|
+
- **XDSRunner**: Automate initial processing and data quality inspection.
|
|
106
|
+
- **CellCorr**: Update unit cell information and refine settings.
|
|
107
|
+
- **XDSRefine**: Fine-tune processing parameters, including rotation axis and scaling.
|
|
108
|
+
- **MergeData**: Filter and merge datasets for downstream analysis.
|
|
109
|
+
- **Cluster&Output**: Perform clustering and generate outputs for structure determination.
|
|
110
|
+
- **Expert**: Miscellaneous tools for data reduction and PETS related function.
|
|
111
|
+
- **RealTime**: Live data processing with real-time feedback and automatic merging.
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Documentation
|
|
116
|
+
Detailed guides and examples can be found in:
|
|
117
|
+
- [Tutorial for AutoLEI](doc/AutoLEI_Tutorial.pdf)
|
|
118
|
+
- [Our Wiki](https://gitlab.com/395736627tristone/automicroedgui/-/wikis/home)
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Authors and Acknowledgments
|
|
123
|
+
Developed by Lei Wang and Yinlin Chen. Contributions from Gerhard Hofer, Hongyi Xu, and Xiaodong Zou at Stockholm University. The project integrates valuable resources from [edtools](https://github.com/instamatic-dev/edtools).
|
|
124
|
+
|
|
125
|
+
Supported by the European Union’s Horizon 2020 research and innovation programme under the Marie Sklodowska-Curie grant agreement no. 956099 (NanED − Electron Nanocrystallography−H2020-MSCAITN).
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
## License
|
|
129
|
+
The software is licensed under the BSD 3-Clause License.
|
|
130
|
+
|
autolei-1.0.0/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# AutoLEI
|
|
2
|
+
|
|
3
|
+
**Automated EffortLess MicroED Graphic User Interface (AutoLEI)** is an XDS-based GUI designed for real-time and batch processing of MicroED/3DED datasets. It provides a user-friendly platform for rapid, automated data processing and merging of multiple MicroED datasets, with well-designed and significantly streamlining structure determination workflows.
|
|
4
|
+
|
|
5
|
+
**Key Features**
|
|
6
|
+
- **User-Friendly Interface**: Simplifies MicroED data processing, requiring minimal manual input.
|
|
7
|
+
- **Batch Processing**: Handles large numbers of datasets with automated workflows.
|
|
8
|
+
- **Real-Time Data Processing**: Provides live feedback during data collection.
|
|
9
|
+
- **Versatility**: Supports diverse samples, including small molecules and proteins workflow.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
### Requirements
|
|
17
|
+
- **Operating Systems**: Linux or Windows via [WSL](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux) (versions 1/2).
|
|
18
|
+
- **Software Dependencies**:
|
|
19
|
+
- Python 3.8+ with libraries specified in `pyproject.toml`.
|
|
20
|
+
- [XDS](https://xds.mr.mpg.de/) and [XDSGUI](https://wiki.uni-konstanz.de/xds/index.php/XDSGUI).
|
|
21
|
+
- Optional tools: `xprep` for advanced features and LibreOffice for `.xlsx` files in Linux.
|
|
22
|
+
|
|
23
|
+
### Steps
|
|
24
|
+
1. Install via pip:
|
|
25
|
+
```bash
|
|
26
|
+
pip install autolei
|
|
27
|
+
```
|
|
28
|
+
For historical versions, use:
|
|
29
|
+
```bash
|
|
30
|
+
pip install autolei-[version_name].zip
|
|
31
|
+
```
|
|
32
|
+
2. Manual installation:
|
|
33
|
+
Follow the steps in the [Tutorial for AutoLEI](doc/AutoLEI_Tutorial.pdf) and [our Wiki](https://gitlab.com/395736627tristone/automicroedgui/-/wikis/home).
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
### Command-line Usage
|
|
40
|
+
- **Launch the GUI**:
|
|
41
|
+
```bash
|
|
42
|
+
autolei
|
|
43
|
+
```
|
|
44
|
+
> *Note*: The first launch may take slightly longer as dependencies initialize.
|
|
45
|
+
|
|
46
|
+
- **Configure Settings**:
|
|
47
|
+
```bash
|
|
48
|
+
autolei_setting
|
|
49
|
+
```
|
|
50
|
+
The opened .ini file includes settings on screen scaling, multi-thread and report format.
|
|
51
|
+
|
|
52
|
+
- **Import Instrument**:
|
|
53
|
+
```bash
|
|
54
|
+
autolei_add_instrument [instrument_setting_file]
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
### GUI pages
|
|
59
|
+
AutoLEI is organised into multiple working pages:
|
|
60
|
+
- **Input**: Configure experiment parameters and generate input files.
|
|
61
|
+
- **XDSRunner**: Automate initial processing and data quality inspection.
|
|
62
|
+
- **CellCorr**: Update unit cell information and refine settings.
|
|
63
|
+
- **XDSRefine**: Fine-tune processing parameters, including rotation axis and scaling.
|
|
64
|
+
- **MergeData**: Filter and merge datasets for downstream analysis.
|
|
65
|
+
- **Cluster&Output**: Perform clustering and generate outputs for structure determination.
|
|
66
|
+
- **Expert**: Miscellaneous tools for data reduction and PETS related function.
|
|
67
|
+
- **RealTime**: Live data processing with real-time feedback and automatic merging.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Documentation
|
|
72
|
+
Detailed guides and examples can be found in:
|
|
73
|
+
- [Tutorial for AutoLEI](doc/AutoLEI_Tutorial.pdf)
|
|
74
|
+
- [Our Wiki](https://gitlab.com/395736627tristone/automicroedgui/-/wikis/home)
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Authors and Acknowledgments
|
|
79
|
+
Developed by Lei Wang and Yinlin Chen. Contributions from Gerhard Hofer, Hongyi Xu, and Xiaodong Zou at Stockholm University. The project integrates valuable resources from [edtools](https://github.com/instamatic-dev/edtools).
|
|
80
|
+
|
|
81
|
+
Supported by the European Union’s Horizon 2020 research and innovation programme under the Marie Sklodowska-Curie grant agreement no. 956099 (NanED − Electron Nanocrystallography−H2020-MSCAITN).
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
## License
|
|
85
|
+
The software is licensed under the BSD 3-Clause License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .autolei import main, setting, add_instrument
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
"""
|
|
2
|
+
AutoLEI Graphical User Interface (GUI) Module
|
|
3
|
+
=============================================
|
|
4
|
+
|
|
5
|
+
This module provides a graphical user interface for the AutoLEI application, an integrated
|
|
6
|
+
tool for crystallographic data processing and analysis. The GUI is designed to enhance user
|
|
7
|
+
experience by offering an intuitive interface for interacting with AutoLEI's core functionalities.
|
|
8
|
+
|
|
9
|
+
The module supports dataset management, real-time monitoring of XDS processes, and easy access
|
|
10
|
+
to key settings and tools required for crystallographic data processing.
|
|
11
|
+
|
|
12
|
+
Features:
|
|
13
|
+
- Adjustable scaling for high-resolution displays.
|
|
14
|
+
- Integration with various AutoLEI processing modules.
|
|
15
|
+
- Multi-tabbed interface for seamless navigation.
|
|
16
|
+
- Robust error handling and user prompts.
|
|
17
|
+
|
|
18
|
+
Attributes:
|
|
19
|
+
config (configparser.ConfigParser): Parses and reads the AutoLEI configuration file.
|
|
20
|
+
script_dir (str): The directory where the script is located.
|
|
21
|
+
|
|
22
|
+
Classes:
|
|
23
|
+
AutoLei: Main GUI application class that handles the primary window and user interaction.
|
|
24
|
+
|
|
25
|
+
Functions:
|
|
26
|
+
start_gui(): Launches the AutoLEI GUI.
|
|
27
|
+
main(): Entry point for the application.
|
|
28
|
+
setting(): Opens the `setting.ini` file for editing.
|
|
29
|
+
add_instrument(file_name: str): Adds an instrument profile to the AutoLEI instrument directory.
|
|
30
|
+
|
|
31
|
+
Notes:
|
|
32
|
+
- The `setting.ini` file must be properly configured and located in the script directory.
|
|
33
|
+
- XDS software must be installed and available in the system path.
|
|
34
|
+
- Designed to support high-resolution displays through automatic scaling adjustments.
|
|
35
|
+
|
|
36
|
+
Dependencies:
|
|
37
|
+
- Standard Libraries:
|
|
38
|
+
- configparser
|
|
39
|
+
- multiprocessing
|
|
40
|
+
- os
|
|
41
|
+
- shutil
|
|
42
|
+
- subprocess
|
|
43
|
+
- sys
|
|
44
|
+
- warnings
|
|
45
|
+
- Third-Party Libraries:
|
|
46
|
+
- tkinter
|
|
47
|
+
- screeninfo
|
|
48
|
+
|
|
49
|
+
Contact:
|
|
50
|
+
- Lei Wang: lei.wang@mmk.su.se
|
|
51
|
+
- Yinlin Chen: yinlin.chen@mmk.su.se
|
|
52
|
+
|
|
53
|
+
License:
|
|
54
|
+
BSD 3-Clause License
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
import configparser
|
|
58
|
+
import multiprocessing
|
|
59
|
+
import warnings
|
|
60
|
+
|
|
61
|
+
warnings.simplefilter(action='ignore', category=FutureWarning)
|
|
62
|
+
warnings.simplefilter(action='ignore', category=UserWarning)
|
|
63
|
+
warnings.simplefilter(action='ignore', category=RuntimeWarning)
|
|
64
|
+
|
|
65
|
+
import os.path
|
|
66
|
+
import sys
|
|
67
|
+
from multiprocessing import Process
|
|
68
|
+
from tkinter import font, messagebox
|
|
69
|
+
from screeninfo import get_monitors, ScreenInfoError
|
|
70
|
+
|
|
71
|
+
try:
|
|
72
|
+
from .src.util import *
|
|
73
|
+
from .realtime import RealTime
|
|
74
|
+
from .tool import Tools
|
|
75
|
+
from .autolei_core import Input, XDSRunner, UnitCellCorr, XDSRefine, MergeData, Cluster_Output
|
|
76
|
+
except ImportError:
|
|
77
|
+
from src.util import *
|
|
78
|
+
from realtime import RealTime
|
|
79
|
+
from tool import Tools
|
|
80
|
+
from autolei_core import Input, XDSRunner, UnitCellCorr, XDSRefine, MergeData, Cluster_Output
|
|
81
|
+
|
|
82
|
+
script_dir = os.path.dirname(__file__)
|
|
83
|
+
# Read configuration settings
|
|
84
|
+
config = configparser.ConfigParser()
|
|
85
|
+
config.read(os.path.join(script_dir, 'setting.ini'))
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
# Main window class
|
|
89
|
+
class AutoLei(tk.Tk):
|
|
90
|
+
"""
|
|
91
|
+
A class representing the main GUI application for AutoLEI.
|
|
92
|
+
|
|
93
|
+
AutoLEI is an interactive application designed to facilitate dataset
|
|
94
|
+
processing, unit cell refinement, merging of data, and various other
|
|
95
|
+
scientific computations. This class handles the initialization and
|
|
96
|
+
configuration of the GUI, including the creation of multiple tabs
|
|
97
|
+
for different functionalities. It uses the tkinter library for
|
|
98
|
+
the graphical interface and ttk for styling.
|
|
99
|
+
|
|
100
|
+
Attributes:
|
|
101
|
+
sf (float): Scaling factor for GUI elements based on screen resolution.
|
|
102
|
+
notebook (ttk.Notebook): The main tabbed interface for the application.
|
|
103
|
+
dataset_counts (int): Number of datasets currently loaded.
|
|
104
|
+
input_path (str or None): The current directory path being processed by the application.
|
|
105
|
+
pages (dict): Dictionary of instantiated pages for different functionalities.
|
|
106
|
+
"""
|
|
107
|
+
|
|
108
|
+
def __init__(self, *args, **kwargs):
|
|
109
|
+
"""Initialize the AutoLEI GUI application.
|
|
110
|
+
|
|
111
|
+
Arguments:
|
|
112
|
+
*args: Variable length argument list.
|
|
113
|
+
**kwargs: Arbitrary keyword arguments.
|
|
114
|
+
"""
|
|
115
|
+
super().__init__(*args, **kwargs)
|
|
116
|
+
|
|
117
|
+
self.title("AutoLEI 1.0.0")
|
|
118
|
+
sf = self.adjust_scaling()
|
|
119
|
+
window_width = int(1100 * sf)
|
|
120
|
+
window_height = int(760 * sf)
|
|
121
|
+
self.geometry(f'{window_width}x{window_height}')
|
|
122
|
+
|
|
123
|
+
if config["General"]["window_scaling"] == "True":
|
|
124
|
+
self.sf = sf ** 0.4
|
|
125
|
+
else:
|
|
126
|
+
self.sf = 1
|
|
127
|
+
self.call('tk', 'scaling', sf)
|
|
128
|
+
|
|
129
|
+
# Configure styles
|
|
130
|
+
style = ttk.Style()
|
|
131
|
+
style.theme_use('alt')
|
|
132
|
+
|
|
133
|
+
default_font = font.nametofont("TkDefaultFont")
|
|
134
|
+
default_font.configure(family="Liberation Sans", size=int(15 * self.sf))
|
|
135
|
+
self.option_add("*Font", default_font)
|
|
136
|
+
|
|
137
|
+
style.configure(
|
|
138
|
+
"TNotebook.Tab",
|
|
139
|
+
font=("Liberation Sans", int(16 * self.sf), "bold"),
|
|
140
|
+
padding=[20 * self.sf, 6 * self.sf, 20 * self.sf, 6 * self.sf]
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
# Create the notebook widget
|
|
144
|
+
self.notebook = ttk.Notebook(self)
|
|
145
|
+
self.notebook.pack(expand=True, fill="both")
|
|
146
|
+
|
|
147
|
+
# Initialisation
|
|
148
|
+
self.dataset_counts = 0
|
|
149
|
+
self.input_path = None
|
|
150
|
+
self.check_XDS()
|
|
151
|
+
|
|
152
|
+
# Create pages and add them to the notebook
|
|
153
|
+
self.pages = {}
|
|
154
|
+
page_name_mapping = {
|
|
155
|
+
"Input": "Input",
|
|
156
|
+
"XDSRunner": "XDSRunner",
|
|
157
|
+
"UnitCellCorr": "CellCorr",
|
|
158
|
+
"XDSRefine": "XDSRefine",
|
|
159
|
+
"MergeData": "MergeData",
|
|
160
|
+
"Cluster_Output": "Cluster&Output",
|
|
161
|
+
"Tools": "Expert",
|
|
162
|
+
"RealTime": "RealTime",
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
page_classes = [Input, XDSRunner, UnitCellCorr, XDSRefine, MergeData, Cluster_Output, Tools, RealTime]
|
|
166
|
+
|
|
167
|
+
for F in page_classes:
|
|
168
|
+
page = F(parent=self.notebook)
|
|
169
|
+
self.pages[F.__name__] = page
|
|
170
|
+
# Use the mapping to set the page name
|
|
171
|
+
page_name = page_name_mapping.get(F.__name__, F.__name__) # Fallback to class name if not in mapping
|
|
172
|
+
self.notebook.add(page, text=page_name)
|
|
173
|
+
|
|
174
|
+
self.protocol("WM_DELETE_WINDOW", self.on_close)
|
|
175
|
+
|
|
176
|
+
def set_input_path(self, path: str):
|
|
177
|
+
"""Set the input path and update pages accordingly.
|
|
178
|
+
|
|
179
|
+
Arguments:
|
|
180
|
+
path (str): The directory path to be set as input.
|
|
181
|
+
"""
|
|
182
|
+
self.input_path = path # refresh path
|
|
183
|
+
for page_name, page in self.pages.items():
|
|
184
|
+
if hasattr(page, 'input_path'):
|
|
185
|
+
page.input_path = path
|
|
186
|
+
os.chdir(path)
|
|
187
|
+
self.update_title()
|
|
188
|
+
if os.path.isdir(os.path.join(path, "merge")):
|
|
189
|
+
self.pages["Cluster_Output"].update_path_dict()
|
|
190
|
+
if os.path.isfile(os.path.join(path, "online.json")) or os.path.isfile(os.path.join(path, "realtime.json")):
|
|
191
|
+
self.pages["RealTime"].update_display_initial()
|
|
192
|
+
|
|
193
|
+
def update_title(self):
|
|
194
|
+
"""Update the application title to reflect the current input path and dataset count."""
|
|
195
|
+
if self.input_path:
|
|
196
|
+
self.title(f"AutoLEI 1.0.0 - {self.input_path} - {self.dataset_counts} datasets")
|
|
197
|
+
else:
|
|
198
|
+
self.title("AutoLEI 1.0.0")
|
|
199
|
+
|
|
200
|
+
def on_close(self):
|
|
201
|
+
"""Handle the application close event.
|
|
202
|
+
|
|
203
|
+
Prompts the user to confirm before closing the application.
|
|
204
|
+
"""
|
|
205
|
+
if messagebox.askyesno("Exit", "Are you sure you want to close the window? Realtime monitor will disconnect."):
|
|
206
|
+
if "realtime" in self.pages["RealTime"].thread and self.pages["RealTime"].thread["realtime"].is_alive():
|
|
207
|
+
self.pages["RealTime"].thread["realtime"].terminate()
|
|
208
|
+
self.destroy()
|
|
209
|
+
|
|
210
|
+
def check_XDS(self):
|
|
211
|
+
"""Check if the XDS program is available in the system path.
|
|
212
|
+
|
|
213
|
+
Warns the user if the program is missing.
|
|
214
|
+
|
|
215
|
+
Returns:
|
|
216
|
+
bool: True if the check passes, otherwise exits the application.
|
|
217
|
+
"""
|
|
218
|
+
if not shutil.which("xds") and sys.platform.startswith("linux"):
|
|
219
|
+
response = messagebox.askyesno(
|
|
220
|
+
"Warning",
|
|
221
|
+
"XDS not existing! Do you wish to continue?",
|
|
222
|
+
icon='warning',
|
|
223
|
+
parent=self
|
|
224
|
+
)
|
|
225
|
+
if not response:
|
|
226
|
+
self.destroy()
|
|
227
|
+
return True
|
|
228
|
+
|
|
229
|
+
@classmethod
|
|
230
|
+
def get_monitors_safe(cls, queue: multiprocessing.Queue):
|
|
231
|
+
"""Safely retrieve monitor information.
|
|
232
|
+
|
|
233
|
+
Arguments:
|
|
234
|
+
queue (multiprocessing.Queue): Queue to store monitor information or errors.
|
|
235
|
+
"""
|
|
236
|
+
try:
|
|
237
|
+
monitors = get_monitors()
|
|
238
|
+
queue.put(("success", monitors))
|
|
239
|
+
except Exception as e:
|
|
240
|
+
queue.put(("error", str(e)))
|
|
241
|
+
|
|
242
|
+
def adjust_scaling(self) -> float:
|
|
243
|
+
"""Adjust GUI scaling based on the screen size or user preferences.
|
|
244
|
+
|
|
245
|
+
Returns:
|
|
246
|
+
float: The calculated scaling factor.
|
|
247
|
+
"""
|
|
248
|
+
try:
|
|
249
|
+
window_scaling_enabled = strtobool(config["General"]["window_scaling"])
|
|
250
|
+
except (ValueError, KeyError) as e:
|
|
251
|
+
print(f"[Error] Invalid configuration for 'window_scaling': {e}. Using default scaling (1.0).")
|
|
252
|
+
return 1.0
|
|
253
|
+
|
|
254
|
+
if not window_scaling_enabled:
|
|
255
|
+
return 1.0
|
|
256
|
+
|
|
257
|
+
# Step 2: Check if a specific scaling factor is set
|
|
258
|
+
set_scaling = config["General"].get("set_scaling", "0")
|
|
259
|
+
if set_scaling != "0":
|
|
260
|
+
try:
|
|
261
|
+
scaling = float(set_scaling)
|
|
262
|
+
if scaling <= 0:
|
|
263
|
+
raise ValueError("Scaling factor must be positive.")
|
|
264
|
+
self.call('tk', 'scaling', scaling)
|
|
265
|
+
print(f"[Info] Applied user-specified scaling factor: {scaling}")
|
|
266
|
+
return scaling
|
|
267
|
+
except ValueError:
|
|
268
|
+
print("[Error] Invalid 'set_scaling' value. Using default scaling (1.0).")
|
|
269
|
+
return 1.0
|
|
270
|
+
|
|
271
|
+
queue = multiprocessing.Queue()
|
|
272
|
+
p = multiprocessing.Process(target=self.get_monitors_safe, args=(queue,))
|
|
273
|
+
p.start()
|
|
274
|
+
try:
|
|
275
|
+
p.join(timeout=1)
|
|
276
|
+
if p.is_alive():
|
|
277
|
+
print("[Warning] get_monitors() timed out. Terminating process and falling back to Tkinter methods.")
|
|
278
|
+
p.terminate()
|
|
279
|
+
p.join()
|
|
280
|
+
raise TimeoutError("get_monitors() timed out.")
|
|
281
|
+
|
|
282
|
+
status, result = queue.get_nowait()
|
|
283
|
+
if status == "success":
|
|
284
|
+
monitors = result
|
|
285
|
+
if not monitors:
|
|
286
|
+
raise ScreenInfoError("No monitors detected.")
|
|
287
|
+
primary_monitor = monitors[0]
|
|
288
|
+
screen_width = primary_monitor.width
|
|
289
|
+
screen_height = primary_monitor.height
|
|
290
|
+
print(f"[Info] Retrieved monitor dimensions via screeninfo: {screen_width}x{screen_height}")
|
|
291
|
+
else:
|
|
292
|
+
raise ScreenInfoError(result)
|
|
293
|
+
|
|
294
|
+
except Exception as e:
|
|
295
|
+
p.terminate()
|
|
296
|
+
print(
|
|
297
|
+
f"[Warning] Failed to retrieve monitor information via screeninfo{e}. Falling back to Tkinter methods.")
|
|
298
|
+
screen_width = None
|
|
299
|
+
screen_height = None
|
|
300
|
+
|
|
301
|
+
if screen_width is None or screen_height is None:
|
|
302
|
+
try:
|
|
303
|
+
# Ensure the Tkinter window is updated to get accurate screen dimensions
|
|
304
|
+
self.update_idletasks()
|
|
305
|
+
self.update()
|
|
306
|
+
|
|
307
|
+
screen_width = self.winfo_screenwidth()
|
|
308
|
+
screen_height = self.winfo_screenheight()
|
|
309
|
+
|
|
310
|
+
print(f"[Info] Retrieved screen dimensions via Tkinter: {screen_width}x{screen_height}")
|
|
311
|
+
except Exception as e:
|
|
312
|
+
print(f"[Error] Failed to retrieve screen information via Tkinter: {e}. Using default scaling (1.0).")
|
|
313
|
+
return 1.0
|
|
314
|
+
|
|
315
|
+
# Step 5: Calculate scaling factor based on screen size
|
|
316
|
+
try:
|
|
317
|
+
reference_width = 1920
|
|
318
|
+
reference_height = 1080
|
|
319
|
+
|
|
320
|
+
scaling_factor_width = screen_width / reference_width
|
|
321
|
+
scaling_factor_height = screen_height / reference_height
|
|
322
|
+
|
|
323
|
+
# Choose the smaller scaling factor to ensure UI elements fit
|
|
324
|
+
scaling_factor = min(scaling_factor_width, scaling_factor_height)
|
|
325
|
+
|
|
326
|
+
# Clamp the scaling factor between 1.0 and 2.0
|
|
327
|
+
scaling_factor = max(1.0, min(scaling_factor, 2.0))
|
|
328
|
+
|
|
329
|
+
# Apply the scaling factor
|
|
330
|
+
self.call('tk', 'scaling', scaling_factor)
|
|
331
|
+
print(f"[Info] Applied scaling factor: {scaling_factor:.2f}")
|
|
332
|
+
|
|
333
|
+
return scaling_factor
|
|
334
|
+
|
|
335
|
+
except Exception as e:
|
|
336
|
+
print(f"[Error] Failed to calculate or apply scaling factor: {e}. Using default scaling (1.0).")
|
|
337
|
+
return 1.0
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
def start_gui() -> None:
|
|
341
|
+
"""Start the AutoLEI GUI application."""
|
|
342
|
+
app = AutoLei()
|
|
343
|
+
app.mainloop()
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
def main() -> None:
|
|
347
|
+
"""Main entry point for the AutoLEI application.
|
|
348
|
+
|
|
349
|
+
Displays version information and launches the GUI.
|
|
350
|
+
"""
|
|
351
|
+
print("Report bug: \nlei.wang@mmk.su.se\nyinlin.chen@mmk.su.se\n")
|
|
352
|
+
|
|
353
|
+
print("AutoLEI version 1.0.0, build date 2024-12-25")
|
|
354
|
+
print("Welcome using AutoLEI!\n")
|
|
355
|
+
|
|
356
|
+
# Run the GUI in a separate process
|
|
357
|
+
gui_process = Process(target=start_gui)
|
|
358
|
+
gui_process.start()
|
|
359
|
+
gui_process.join()
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
def setting():
|
|
363
|
+
"""Open the AutoLEI settings file for editing."""
|
|
364
|
+
print("You will change the setting file of AutoLEI.")
|
|
365
|
+
setting_path = os.path.join(os.path.dirname(__file__), 'setting.ini')
|
|
366
|
+
subprocess.run(['nano', setting_path])
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
def add_instrument(file_name: str) -> None:
|
|
370
|
+
"""Add an instrument profile to the AutoLEI instrument directory.
|
|
371
|
+
|
|
372
|
+
Arguments:
|
|
373
|
+
file_name (str): Path to the instrument profile file.
|
|
374
|
+
"""
|
|
375
|
+
src = file_name
|
|
376
|
+
dest_dir = os.path.join(os.path.dirname(__file__), 'instrument_profile')
|
|
377
|
+
if not os.path.exists(dest_dir):
|
|
378
|
+
os.makedirs(dest_dir)
|
|
379
|
+
dest = os.path.join(dest_dir, os.path.basename(file_name))
|
|
380
|
+
shutil.copyfile(src, dest)
|
|
381
|
+
print(f"Copied {src} to AutoLEI Instrument Files.")
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
if __name__ == "__main__":
|
|
385
|
+
main()
|