|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | | -XDS_template = """! XDS.INP file for Rotation Electron Diffraction generated by `instamatic` |
4 | | -! {date} |
5 | | -! For definitions of input parameters, see: |
6 | | -! http://xds.mpimf-heidelberg.mpg.de/html_doc/xds_parameters.html |
7 | | -! |
8 | | -! cRED implementation reference paper: |
9 | | -! J. Appl. Cryst. (2018). 51, 1652–1661. http://dx.doi.org/10.1107/S1600576718015145 |
| 3 | +from dataclasses import asdict, dataclass |
| 4 | +from importlib.resources import files |
10 | 5 |
|
11 | | -! ********** Job control ********** |
| 6 | +from instamatic._collections import PartialFormatter |
12 | 7 |
|
13 | | -!JOB= XYCORR INIT COLSPOT IDXREF |
14 | | -!JOB= DEFPIX INTEGRATE CORRECT |
15 | | -!JOB= CORRECT |
| 8 | +XDS_template_path = files('instamatic.processing').joinpath('XDS_template.inp') |
| 9 | +XDS_template_base = XDS_template_path.read_text(encoding='utf-8') |
16 | 10 |
|
17 | | -MAXIMUM_NUMBER_OF_JOBS=4 |
18 | | -MAXIMUM_NUMBER_OF_PROCESSORS=4 |
19 | 11 |
|
20 | | -! ********** Data images ********** |
| 12 | +@dataclass |
| 13 | +class XDSPreset: |
| 14 | + max_cell_axis_error: str = '0.05' |
| 15 | + max_cell_angle_error: str = '3.0' |
| 16 | + strong_pixel_line: str = '!STRONG_PIXEL= 3.0' |
| 17 | + min_fraction_line: str = '!MINIMUM_FRACTION_OF_INDEXED_SPOTS= 0.25' |
21 | 18 |
|
22 | | -NAME_TEMPLATE_OF_DATA_FRAMES= {data_drc}/0????.img SMV |
23 | | -DATA_RANGE= {data_begin:d} {data_end:d} |
24 | | -SPOT_RANGE= {data_begin:d} {data_end:d} |
25 | | -BACKGROUND_RANGE= {data_begin:d} {data_end:d} |
26 | | -{exclude:s} |
27 | 19 |
|
28 | | -! ********** Crystal ********** |
| 20 | +mce = {'max_cell_axis_error': '0.03', 'max_cell_angle_error': '2.0'} |
29 | 21 |
|
30 | | -!SPACE_GROUP_NUMBER= 0 |
31 | | -!UNIT_CELL_CONSTANTS= 10 20 30 90 90 90 |
| 22 | +xds_preset_base = XDSPreset() |
| 23 | +xds_preset_dm = XDSPreset(min_fraction_line='MINIMUM_FRACTION_OF_INDEXED_SPOTS= 0.25 ', **mce) |
| 24 | +xds_preset_tvips = XDSPreset(strong_pixel_line='STRONG_PIXEL= 6.0 ', **mce) |
32 | 25 |
|
33 | | -!REIDX= !Optional reindexing transformation to apply on reflection indices |
34 | | -FRIEDEL'S_LAW=TRUE !TRUE is default |
35 | | -
|
36 | | -!phi(i) = STARTING_ANGLE + OSCILLATION_RANGE * (i - STARTING_FRAME) |
37 | | -STARTING_ANGLE= {starting_angle:0.4f} |
38 | | -STARTING_FRAME= 1 |
39 | | -
|
40 | | -MAX_CELL_AXIS_ERROR= 0.05 !0.03 is default |
41 | | -MAX_CELL_ANGLE_ERROR= 3.0 !2.0 is default |
42 | | -
|
43 | | -TEST_RESOLUTION_RANGE=10. 1.0 !for calculation of Rmeas when analysing the intensity data for space group symmetry in the CORRECT step. |
44 | | -!MIN_RFL_Rmeas=50 !50 is default - used in the CORRECT step for identification of possible space groups. |
45 | | -!MAX_FAC_Rmeas=2.0 !2.0 is default - used in the CORRECT step for identification of possible space groups. |
46 | | -
|
47 | | -! ********** Detector hardware ********** |
48 | | -
|
49 | | -NX={NX} NY={NY} !Number of pixels |
50 | | -QX={QX:.4f} QY={QY:.4f} !Physical size of pixels (mm) |
51 | | -OVERLOAD= 130000 !default value dependent on the detector used |
52 | | -TRUSTED_REGION= 0.0 1.05 !default \"0.0 1.05\". Corners for square detector max \"0.0 1.4142\" |
53 | | -{untrusted_areas} |
54 | | -{stretch_correction} |
55 | | -SENSOR_THICKNESS=0.30 |
56 | | -AIR=0.0 |
57 | | -
|
58 | | -! ********** Trusted detector region ********** |
59 | | -
|
60 | | -VALUE_RANGE_FOR_TRUSTED_DETECTOR_PIXELS= 10 30000 !Values are defined in `ABS.CBF`, check mask in `BKGPIX.CBF`, used in DEFPIX |
61 | | -!MINIMUM_ZETA= !0.05 is default |
62 | | -
|
63 | | -INCLUDE_RESOLUTION_RANGE= 20 0.8 |
64 | | -
|
65 | | -!Ice Ring exclusion, important for data collected using cryo holders |
66 | | -!EXCLUDE_RESOLUTION_RANGE= 3.93 3.87 !ice-ring at 3.897 Angstrom |
67 | | -!EXCLUDE_RESOLUTION_RANGE= 3.70 3.64 !ice-ring at 3.669 Angstrom |
68 | | -!EXCLUDE_RESOLUTION_RANGE= 3.47 3.41 !ice-ring at 3.441 Angstrom (Main) |
69 | | -!EXCLUDE_RESOLUTION_RANGE= 2.70 2.64 !ice-ring at 2.671 Angstrom |
70 | | -!EXCLUDE_RESOLUTION_RANGE= 2.28 2.22 !ice-ring at 2.249 Angstrom (Main) |
71 | | -!EXCLUDE_RESOLUTION_RANGE= 2.102 2.042 !ice-ring at 2.072 Angstrom - strong |
72 | | -!EXCLUDE_RESOLUTION_RANGE= 1.978 1.918 !ice-ring at 1.948 Angstrom - weak |
73 | | -!EXCLUDE_RESOLUTION_RANGE= 1.948 1.888 !ice-ring at 1.918 Angstrom - strong |
74 | | -!EXCLUDE_RESOLUTION_RANGE= 1.913 1.853 !ice-ring at 1.883 Angstrom - weak |
75 | | -!EXCLUDE_RESOLUTION_RANGE= 1.751 1.691 !ice-ring at 1.721 Angstrom - weak |
76 | | -
|
77 | | -! ********** Detector geometry & Rotation axis ********** |
78 | | -
|
79 | | -DIRECTION_OF_DETECTOR_X-AXIS= 1 0 0 |
80 | | -DIRECTION_OF_DETECTOR_Y-AXIS= 0 1 0 |
81 | | -
|
82 | | -ORGX= {origin_x:.2f} ORGY= {origin_y:.2f} !Detector origin (pixels). Often close to the image center, i.e. ORGX=NX/2; ORGY=NY/2 |
83 | | -DETECTOR_DISTANCE= {sign}{detector_distance:.2f} !Can be negative. Positive because the detector normal points away from the crystal. |
84 | | -
|
85 | | -OSCILLATION_RANGE= {osc_angle:.4f} |
86 | | -
|
87 | | -ROTATION_AXIS= {rot_x:.4f} {rot_y:.4f} {rot_z:.4f} |
88 | | -
|
89 | | -! ********** Incident beam ********** |
90 | | -
|
91 | | -X-RAY_WAVELENGTH= {wavelength:.4f} !used by IDXREF |
92 | | -INCIDENT_BEAM_DIRECTION= 0 0 1 !The vector points from the source towards the crystal |
93 | | -
|
94 | | -! ********** Background and peak pixels ********** |
95 | | -
|
96 | | -!NBX=7 NBY=7 ! 3 is default, used to estimate the expected variation in a data image, see GAIN.cbf |
97 | | -!BACKGROUND_PIXEL= 6.0 ! Background pixel belongs to background if variation less than given esds |
98 | | -!STRONG_PIXEL= 3.0 ! Strong pixel must exceed background by more than number of given esds |
99 | | -!MAXIMUM_NUMBER_OF_STRONG_PIXELS= 1500000 ! Approximate upper limit for the total number of 'strong' pixels |
100 | | -!MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT= 6 ! Used to suppress spurious, isolated 'strong' pixels from entering the spot list |
101 | | -!SPOT_MAXIMUM-CENTROID= 3.0 ! Maximum deviation of spot maximum from spot centroid |
102 | | -!SIGNAL_PIXEL= 3.0 ! Signal pixels must exceed background by more than given esds |
103 | | -
|
104 | | -! ********** Refinement ********** |
105 | | -
|
106 | | - REFINE(IDXREF)= BEAM AXIS ORIENTATION CELL !POSITION |
107 | | - REFINE(INTEGRATE)= !POSITION BEAM AXIS !ORIENTATION CELL |
108 | | - REFINE(CORRECT)= BEAM AXIS ORIENTATION CELL !POSITION |
109 | | -
|
110 | | -! ********** Indexing ********** |
111 | | -
|
112 | | -!MINIMUM_FRACTION_OF_INDEXED_SPOTS= 0.25 !0.50 is default. |
113 | | -!MAXIMUM_ERROR_OF_SPOT_POSITION=6.0 ! 3.0 is default |
114 | | -!REFLECTING_RANGE= |
115 | | -!REFLECTING_RANGE_E.S.D.= |
116 | | -!BEAM_DIVERGENCE= |
117 | | -!BEAM_DIVERGENCE_E.S.D.= |
118 | | -""" |
| 26 | +pf = PartialFormatter() |
| 27 | +XDS_template = pf.format(XDS_template_base, **asdict(xds_preset_base)) |
| 28 | +XDS_template_DM = pf.format(XDS_template_base, **asdict(xds_preset_dm)) |
| 29 | +XDS_template_TPX = XDS_template |
| 30 | +XDS_template_TVIPS = pf.format(XDS_template_base, **asdict(xds_preset_tvips)) |
0 commit comments