Mercurial > repos > muon-spectroscopy-computational-project > larch_athena
comparison larch_athena.xml @ 0:ae2f265ecf8e draft
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_athena commit 5be486890442dedfb327289d597e1c8110240735
author | muon-spectroscopy-computational-project |
---|---|
date | Tue, 14 Nov 2023 15:34:40 +0000 |
parents | |
children | 2b3115342fef |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:ae2f265ecf8e |
---|---|
1 <tool id="larch_athena" name="Larch Athena" version="@TOOL_VERSION@+galaxy@WRAPPER_VERSION@" python_template_version="3.5" profile="22.05" license="MIT"> | |
2 <description>generate Athena projects from XAFS data</description> | |
3 <macros> | |
4 <!-- version of underlying tool (PEP 440) --> | |
5 <token name="@TOOL_VERSION@">0.9.71</token> | |
6 <!-- version of this tool wrapper (integer) --> | |
7 <token name="@WRAPPER_VERSION@">0</token> | |
8 <!-- citation should be updated with every underlying tool version --> | |
9 <!-- typical fields to update are version, month, year, and doi --> | |
10 <token name="@TOOL_CITATION@">10.1088/1742-6596/430/1/012007</token> | |
11 <xml name="format"> | |
12 <param name="format" type="select" display="radio" label="Input format" help="Whether data is in plaintext or already saved as an Athena project"> | |
13 <option value="plaintext" selected="true">Plaintext</option> | |
14 <option value="athena">Athena project</option> | |
15 </param> | |
16 </xml> | |
17 <xml name="extract_group"> | |
18 <param name="extract_group" type="text" optional="true" label="Extract group" help="Which group to extract and process from the Athena project (will use first group in file if unset)"/> | |
19 </xml> | |
20 <xml name="columns"> | |
21 <param name="energy_column" type="text" optional="true" label="Energy column" help="If set, this column we be used as 'energy'. Otherwise, will identify columns ending with 'energy' or labelled 'col1'."/> | |
22 <param name="mu_column" type="text" optional="true" label="μ column" help="If set, this column we be used as 'mu'. Otherwise, will identify the first column labelled as either 'col2', 'xmu', 'lni0it' or 'FFI0'."/> | |
23 </xml> | |
24 <xml name="is_zipped"> | |
25 <param name="is_zipped" type="select" display="radio" label="Inputs Zipped" help="Whether plaintext input files are zipped together into one directory, or not."> | |
26 <option value="" selected="true">No</option> | |
27 <option value="true">Yes</option> | |
28 </param> | |
29 </xml> | |
30 <import>macros.xml</import> | |
31 </macros> | |
32 <creator> | |
33 <person givenName="Patrick" familyName="Austin" url="https://github.com/patrick-austin" identifier="https://orcid.org/0000-0002-6279-7823"/> | |
34 </creator> | |
35 <requirements> | |
36 <requirement type="package" version="@TOOL_VERSION@">xraylarch</requirement> | |
37 <requirement type="package" version="3.5.2">matplotlib</requirement> | |
38 <requirement type="package" version="3.0">zip</requirement> | |
39 <requirement type="package" version="6.0">unzip</requirement> | |
40 </requirements> | |
41 <required_files> | |
42 <include type="literal" path="larch_athena.py"/> | |
43 </required_files> | |
44 <command detect_errors="exit_code"><![CDATA[ | |
45 mkdir prj edge flat derivative | |
46 #if $merge_inputs.format.format=="plaintext": | |
47 #if $merge_inputs.format.is_zipped.is_zipped=="true": | |
48 && echo Unzipping '$merge_inputs.format.is_zipped.dat_file.name' | |
49 && unzip '$merge_inputs.format.is_zipped.dat_file' -d dat_files | |
50 && python '${__tool_directory__}/larch_athena.py' dat_files '$inputs' | |
51 #else | |
52 && python '${__tool_directory__}/larch_athena.py' '$merge_inputs.format.is_zipped.dat_file' '$inputs' | |
53 #end if | |
54 #else | |
55 && python '${__tool_directory__}/larch_athena.py' '$merge_inputs.format.dat_file' '$inputs' | |
56 #end if | |
57 #if $zip_outputs: | |
58 && zip out_zip.zip prj/* edge/* flat/* derivative/* | |
59 #end if | |
60 ]]></command> | |
61 <configfiles> | |
62 <inputs name="inputs"/> | |
63 </configfiles> | |
64 <inputs> | |
65 <conditional name="merge_inputs" > | |
66 <param name="merge_inputs" type="select" display="radio" label="Merge multiple inputs" help="Whether to merge all input data into one Athena project, by default each dataset or file in a zip will result in a separate output."> | |
67 <option value="" selected="true">No</option> | |
68 <option value="true">Yes</option> | |
69 </param> | |
70 <when value=""> | |
71 <conditional name="format" > | |
72 <expand macro="format"/> | |
73 <when value="plaintext"> | |
74 <conditional name="is_zipped" > | |
75 <expand macro="is_zipped"/> | |
76 <when value=""> | |
77 <param name="dat_file" type="data" format="h5,txt" label="XAFS data file" help="X-ray Absorption Fine Structure (XAFS) data, either in h5 or plaintext."/> | |
78 </when> | |
79 <when value="true"> | |
80 <param name="dat_file" type="data" format="zip" label="Zipped XAFS data files" help="Zipped X-ray Absorption Fine Structure (XAFS) data, either in h5 or plaintext."/> | |
81 </when> | |
82 </conditional> | |
83 <expand macro="columns"/> | |
84 </when> | |
85 <when value="athena"> | |
86 <param name="dat_file" type="data" format="prj" label="Athena project" help="X-ray Absorption Spectroscopy (XAS) data, in Athena project format"/> | |
87 <expand macro="extract_group"/> | |
88 </when> | |
89 </conditional> | |
90 </when> | |
91 <when value="true"> | |
92 <conditional name="format" > | |
93 <expand macro="format"/> | |
94 <when value="plaintext"> | |
95 <conditional name="is_zipped" > | |
96 <expand macro="is_zipped"/> | |
97 <when value=""> | |
98 <param name="dat_file" type="data" format="h5,txt" multiple="true" label="XAFS data file" help="X-ray Absorption Fine Structure (XAFS) data, either in h5 or plaintext, which will be merged. Accepts individual files or a zip."/> | |
99 </when> | |
100 <when value="true"> | |
101 <param name="dat_file" type="data" format="zip" label="Zipped XAFS data files" help="Zipped X-ray Absorption Fine Structure (XAFS) data, either in h5 or plaintext. All files in the zip will be merged."/> | |
102 </when> | |
103 </conditional> | |
104 <expand macro="columns"/> | |
105 </when> | |
106 <when value="athena"> | |
107 <param name="dat_file" type="data" format="prj" multiple="true" label="Athena project" help="X-ray Absorption Spectroscopy (XAS) data, which will be merged, in Athena project format"/> | |
108 <expand macro="extract_group"/> | |
109 </when> | |
110 </conditional> | |
111 </when> | |
112 </conditional> | |
113 <param name="annotation" type="text" label="Annotation" optional="true" help="If set, will annotate the output project(s) with this string. This will be used to generate legends when plotting data."/> | |
114 <section name="variables" title="Processing Options"> | |
115 <param name="energy_0" type="float" label="Edge energy (eV)" optional="true" help="If set, data will be calibrated so that the edge occurs at this energy (after merging, if relevant)."/> | |
116 <expand macro="energy_limits"/> | |
117 <param name="pre1" type="float" label="Pre-edge fit lower energy (eV)" optional="true" help="The lower edge of the region used for the pre-edge fitting, if unset will either use existing value or a default based on the data."/> | |
118 <param name="pre2" type="float" label="Pre-edge fit upper energy (eV)" optional="true" help="The upper edge of the region used for the pre-edge fitting, if unset will either use existing value or a default based on the data."/> | |
119 <section name="xftf" title="XFTF"> | |
120 <expand macro="xftf_params"/> | |
121 </section> | |
122 </section> | |
123 <param name="rebin" type="boolean" label="Re-bin data" help="Whether to re-bin along the energy axis to ensure appropriate levels of precision in the pre-edge, near-edge and extended region of the spectrum."/> | |
124 <param name="plot_graph" type="boolean" label="Plot graph" help="Whether to plot the pre/post edge fitting and the normalised xμ data."/> | |
125 <param name="zip_outputs" type="boolean" label="Zip outputs" help="Whether to zip all outputs into one dataset."/> | |
126 </inputs> | |
127 <outputs> | |
128 <!-- Single output if zipping outputs --> | |
129 <data name="out_zip" format="zip" from_work_dir="out_zip.zip" label="Zipped Athena project(s) ${annotation} ${on_string}"> | |
130 <filter>zip_outputs</filter> | |
131 </data> | |
132 <!-- Single outputs of differnt types if merging, or not using a zip --> | |
133 <data name="athena_project_file" format="prj" from_work_dir="prj/out.prj" label="Athena project ${annotation} ${on_string}"> | |
134 <filter>not zip_outputs</filter> | |
135 <filter>merge_inputs["merge_inputs"] or (merge_inputs["format"]["format"] == "plaintext" and merge_inputs["format"]["is_zipped"]["is_zipped"] == "")</filter> | |
136 </data> | |
137 <data name="edge_plot" format="png" from_work_dir="edge/out.png" label="Edge fitting ${annotation} ${on_string}"> | |
138 <filter>plot_graph</filter> | |
139 <filter>not zip_outputs</filter> | |
140 <filter>merge_inputs["merge_inputs"] or (merge_inputs["format"]["format"] == "plaintext" and merge_inputs["format"]["is_zipped"]["is_zipped"] == "")</filter> | |
141 </data> | |
142 <data name="flat_plot" format="png" from_work_dir="flat/out.png" label="Flattened plot ${annotation} ${on_string}"> | |
143 <filter>plot_graph</filter> | |
144 <filter>not zip_outputs</filter> | |
145 <filter>merge_inputs["merge_inputs"] or (merge_inputs["format"]["format"] == "plaintext" and merge_inputs["format"]["is_zipped"]["is_zipped"] == "")</filter> | |
146 </data> | |
147 <data name="derivative_plot" format="png" from_work_dir="derivative/out.png" label="Derivative plot ${annotation} ${on_string}"> | |
148 <filter>plot_graph</filter> | |
149 <filter>not zip_outputs</filter> | |
150 <filter>merge_inputs["merge_inputs"] or merge_inputs["format"]["dat_file"].extension != "zip"</filter> | |
151 <filter>merge_inputs["merge_inputs"] or (merge_inputs["format"]["format"] == "plaintext" and merge_inputs["format"]["is_zipped"]["is_zipped"] == "")</filter> | |
152 </data> | |
153 <!-- Directories of outputs if using single, non-merged zip as input --> | |
154 <collection name="athena_project_file_collection" format="prj" type="list" label="Athena projects ${annotation} ${on_string}"> | |
155 <discover_datasets pattern="__name_and_ext__" directory="prj"/> | |
156 <filter>not zip_outputs</filter> | |
157 <filter>merge_inputs["merge_inputs"] == "" and merge_inputs["format"]["format"] == "plaintext" and merge_inputs["format"]["is_zipped"]["is_zipped"]</filter> | |
158 </collection> | |
159 <collection name="edge_plot_collection" format="png" type="list" label="Edge fittings ${annotation} ${on_string}"> | |
160 <discover_datasets pattern="__name_and_ext__" directory="edge"/> | |
161 <filter>plot_graph</filter> | |
162 <filter>not zip_outputs</filter> | |
163 <filter>merge_inputs["merge_inputs"] == "" and merge_inputs["format"]["format"] == "plaintext" and merge_inputs["format"]["is_zipped"]["is_zipped"]</filter> | |
164 </collection> | |
165 <collection name="flat_plot_collection" format="png" type="list" label="Flattened plots ${annotation} ${on_string}"> | |
166 <discover_datasets pattern="__name_and_ext__" directory="flat"/> | |
167 <filter>plot_graph</filter> | |
168 <filter>not zip_outputs</filter> | |
169 <filter>merge_inputs["merge_inputs"] == "" and merge_inputs["format"]["format"] == "plaintext" and merge_inputs["format"]["is_zipped"]["is_zipped"]</filter> | |
170 </collection> | |
171 <collection name="derivative_plot_collection" format="png" type="list" label="Derivative plots ${annotation} ${on_string}"> | |
172 <discover_datasets pattern="__name_and_ext__" directory="derivative"/> | |
173 <filter>plot_graph</filter> | |
174 <filter>not zip_outputs</filter> | |
175 <filter>merge_inputs["merge_inputs"] == "" and merge_inputs["format"]["format"] == "plaintext" and merge_inputs["format"]["is_zipped"]["is_zipped"]</filter> | |
176 </collection> | |
177 </outputs> | |
178 <tests> | |
179 <test expect_num_outputs="1"> | |
180 <param name="dat_file" value="test.xmu"/> | |
181 <output name="athena_project_file"> | |
182 <assert_contents> | |
183 <has_size value="5405" delta="10"/> | |
184 </assert_contents> | |
185 </output> | |
186 </test> | |
187 <test expect_num_outputs="1"> | |
188 <param name="dat_file" value="ffi0.tabular"/> | |
189 <output name="athena_project_file"> | |
190 <assert_contents> | |
191 <has_size value="34400" delta="100"/> | |
192 </assert_contents> | |
193 </output> | |
194 </test> | |
195 <test expect_num_outputs="4"> | |
196 <param name="dat_file" value="test.xmu"/> | |
197 <param name="plot_graph" value="true"/> | |
198 <output name="athena_project_file"> | |
199 <assert_contents> | |
200 <has_size value="5405" delta="10"/> | |
201 </assert_contents> | |
202 </output> | |
203 <output name="edge_plot"> | |
204 <assert_contents> | |
205 <has_size value="54036" delta="20"/> | |
206 </assert_contents> | |
207 </output> | |
208 <output name="flat_plot"> | |
209 <assert_contents> | |
210 <has_size value="39266" delta="20"/> | |
211 </assert_contents> | |
212 </output> | |
213 <output name="derivative_plot"> | |
214 <assert_contents> | |
215 <has_size value="42435" delta="20"/> | |
216 </assert_contents> | |
217 </output> | |
218 </test> | |
219 <test expect_num_outputs="4"> | |
220 <param name="is_zipped" value="true"/> | |
221 <param name="dat_file" value="test.zip"/> | |
222 <param name="plot_graph" value="true"/> | |
223 <output_collection name="athena_project_file_collection" type="list" count="2"/> | |
224 <output_collection name="edge_plot_collection" type="list" count="2"/> | |
225 <output_collection name="flat_plot_collection" type="list" count="2"/> | |
226 <output_collection name="derivative_plot_collection" type="list" count="2"/> | |
227 </test> | |
228 <test expect_num_outputs="1"> | |
229 <param name="is_zipped" value="true"/> | |
230 <param name="dat_file" value="h5.zip"/> | |
231 <param name="plot_graph" value="true"/> | |
232 <param name="zip_outputs" value="true"/> | |
233 <output name="out_zip"> | |
234 <assert_contents> | |
235 <has_size value="312000" delta="500"/> | |
236 </assert_contents> | |
237 </output> | |
238 </test> | |
239 <test expect_num_outputs="1"> | |
240 <param name="dat_file" value="test.xmu"/> | |
241 <param name="energy_format" value="absolute"/> | |
242 <param name="energy_min" value="7000"/> | |
243 <output name="athena_project_file"> | |
244 <assert_contents> | |
245 <has_size value="5300" delta="100"/> | |
246 </assert_contents> | |
247 </output> | |
248 </test> | |
249 <test expect_num_outputs="4"> | |
250 <param name="dat_file" value="test.xmu"/> | |
251 <param name="energy_format" value="absolute"/> | |
252 <param name="energy_min" value="7000"/> | |
253 <param name="energy_max" value="7200"/> | |
254 <param name="plot_graph" value="true"/> | |
255 <output name="athena_project_file"> | |
256 <assert_contents> | |
257 <has_size value="3300" delta="50"/> | |
258 </assert_contents> | |
259 </output> | |
260 <output name="edge_plot"> | |
261 <assert_contents> | |
262 <has_size value="44430" delta="10"/> | |
263 </assert_contents> | |
264 </output> | |
265 <output name="flat_plot"> | |
266 <assert_contents> | |
267 <has_size value="37310" delta="10"/> | |
268 </assert_contents> | |
269 </output> | |
270 <output name="derivative_plot"> | |
271 <assert_contents> | |
272 <has_size value="46390" delta="10"/> | |
273 </assert_contents> | |
274 </output> | |
275 </test> | |
276 <test expect_num_outputs="1"> | |
277 <param name="dat_file" value="test.xmu"/> | |
278 <param name="energy_format" value="absolute"/> | |
279 <param name="energy_0" value="7050"/> | |
280 <param name="energy_min" value="7000"/> | |
281 <param name="energy_max" value="7200"/> | |
282 <output name="athena_project_file"> | |
283 <assert_contents> | |
284 <has_size value="3300" delta="50"/> | |
285 </assert_contents> | |
286 </output> | |
287 </test> | |
288 <test expect_num_outputs="1"> | |
289 <param name="dat_file" value="test.xmu"/> | |
290 <param name="rebin" value="true"/> | |
291 <output name="athena_project_file"> | |
292 <assert_contents> | |
293 <has_size value="8413" delta="10"/> | |
294 </assert_contents> | |
295 </output> | |
296 </test> | |
297 <test expect_num_outputs="1"> | |
298 <param name="merge_inputs" value="true"/> | |
299 <param name="dat_file" value="262875_PtSn_OCO_Abu_1.nxs,262876_PtSn_OCO_Abu_2.nxs"/> | |
300 <output name="athena_project_file"> | |
301 <assert_contents> | |
302 <has_size value="37550" delta="50"/> | |
303 </assert_contents> | |
304 </output> | |
305 </test> | |
306 <test expect_num_outputs="1"> | |
307 <param name="merge_inputs" value="true"/> | |
308 <param name="is_zipped" value="true"/> | |
309 <param name="dat_file" value="test.zip"/> | |
310 <output name="athena_project_file"> | |
311 <assert_contents> | |
312 <has_size value="18000" delta="50"/> | |
313 </assert_contents> | |
314 </output> | |
315 </test> | |
316 <test expect_num_outputs="1"> | |
317 <param name="format" value="athena"/> | |
318 <param name="dat_file" value="test.prj"/> | |
319 <output name="athena_project_file"> | |
320 <assert_contents> | |
321 <has_size value="5400" delta="200"/> | |
322 </assert_contents> | |
323 </output> | |
324 </test> | |
325 </tests> | |
326 <help><![CDATA[ | |
327 Using Larch, create an Athena project file from the input X-ray Absorption Fine Structure (XAFS) data file. | |
328 | |
329 Accepts both plaintext and HDF5 formatted data or a zip file containing these formats. | |
330 If column names are not present in plaintext data, then the first column is treated as `energy` and the second as `mu`. | |
331 Note that in order to ensure a consistent output, once unzipped all files will sorted first by their parent directories (alphabetically). | |
332 Within a given directory, if all filenames contain digits then the last block of digits will be used to sort the files numerically. | |
333 In the output, all files (regardless of initial filepath) are output in a flat hierarchy, with the number in which it was processed as the file name (zero-padded). | |
334 Care should therefore be taken to ensure input data is consistent with this treatment. | |
335 | |
336 Optionally, plot the xμ data along with pre and post edge fitting lines for visual inspection. | |
337 ]]></help> | |
338 <citations> | |
339 <citation type="doi">@TOOL_CITATION@</citation> | |
340 <citation type="doi">10.1107/S0909049505012719</citation> | |
341 </citations> | |
342 </tool> |