comparison macros.xml @ 0:72deb053b5a5 draft

"planemo upload for repository https://github.com/ximg-chess/galaxytools/tools/hexrd commit 3e41869cdb6ad4c9a60a4b60dcf9bb4a40955cfa-dirty"
author ximgchess
date Sat, 21 Nov 2020 03:34:48 +0000
parents
children a0be4e3aa66d
comparison
equal deleted inserted replaced
-1:000000000000 0:72deb053b5a5
1 <macros>
2 <token name="@TOOL_VERSION@">0.8.0</token>
3 <xml name="requirements">
4 <requirements>
5 <requirement type="package" version="@TOOL_VERSION@">hexrd</requirement>
6 <yield/>
7 </requirements>
8 </xml>
9 <xml name="citations">
10 <citations>
11 <citation type="doi">10.1016/j.matchar.2020.110366</citation>
12 <yield />
13 </citations>
14 </xml>
15
16 <token name="@CMD_IMPORTS@">
17 #import re
18 #import yaml
19
20 #set global $img_panel_dict = dict()
21 #if $detector.panel_assignment == 'panel_table'
22 #set $fh = open(str($detector.image_panel_table),'r')
23 #for $line in $fh:
24 #set $fields = $line.strip().split('\t')
25 #silent $img_panel_dict[$fields[0]] = $fields[1]
26 #end for
27 #end if
28 #set global $panels = $yaml.safe_load(open(str($instrument),'r'))['detectors'].keys()
29 #def identifier_or_name($input1)
30 #if hasattr($input1, 'element_identifier')
31 #return $input1.element_identifier
32 #elif hasattr($input1, 'name')
33 #return $input1.name
34 #else
35 #return str($input1)
36 #end if
37 #end def
38 #def clean($name1)
39 #set $name_clean = $re.sub('[^\w\-_]', '_', $re.sub('(?i)[.](npz|hexrd|yml|dat|out)$','', $name1.split()[-1]))
40 #return $name_clean
41 #end def
42 #def ln_name($ds,$ext)
43 #set $lname = "%s.%s" % ($clean($identifier_or_name($ds)),$ext)
44 #return $lname
45 #end def
46 #def get_panel($img_input):
47 #set $img_name = $identifier_or_name($img_input)
48 #if $img_panel_dict and $img_name in $img_panel_dict:
49 #return $img_panel_dict[$img_name]
50 #end if
51 #for $p in $panels:
52 #if $p in $img_name:
53 #return $p
54 #end if
55 #end for
56 #return $img_name
57 #end def
58 </token>
59
60 <xml name="common_config" token_multiple_inputs="true" >
61 <param name="inputs" type="data" format="hexrd.npz" multiple="true" label="Image series frame-cache"/>
62 <conditional name="detector">
63 <param name="panel_assignment" type="select" label="Assign detector panel to images">
64 <option value="infer_from_name" selected="true">Infer the panel from the image name</option>
65 <option value="panel_table">Input a table with image panels assignments</option>
66 </param>
67 <when value="infer_from_name"/>
68 <when value="panel_table">
69 <param name="image_panel_table" type="data" format="tabular" label="Image panel assignment table">
70 <help>A 2-column table:image dataset name detector panel name</help>
71 </param>
72 </when>
73 </conditional>
74 <param name="instrument" type="data" format="hexrd.yml" label="instrument"/>
75 <param name="material" type="data" format="material.hexrd" label="material"/>
76 <param name="active_material" type="text" value="" label="active material name">
77 <validator type="empty_field" />
78 </param>
79 </xml>
80
81 <token name="@CMD_LINKS@"><![CDATA[@CMD_IMPORTS@
82 mkdir -p imageseries &&
83 ln -s '$material' $ln_name($material,'hexrd') &&
84 ln -s '$instrument' $ln_name($instrument,'yml') &&
85 #for $input in $inputs
86 ln -s '$input' imageseries/$ln_name($input,'npz') &&
87 #end for
88 ]]>
89 </token>
90 <token name="@FIT_GRAIN_LINKS@"><![CDATA[@CMD_LINKS@
91 ln -s '$ome_map' $ln_name($ome_map,'npz') &&
92 ln -s '$accepted_orientations' $ln_name($accepted_orientations,'dat') &&
93 ##mkdir -p analysis &&
94 ##cp '$grains_estimate' analysis/$ln_name($grains_estimate,'out') &&
95 ]]>
96 </token>
97
98 <token name="@CONVERT2TAB@"><![CDATA[for i in `find analysis -name '[gs]*.out'`; do sed -i.bak "s/[ ][ ][ ]*/\$(printf '\t')/g" \${i}; done]]></token>
99
100 <token name="@COMMON_YML@"><![CDATA[@CMD_IMPORTS@
101 analysis_name: analysis
102
103 multiprocessing: -1
104
105 material:
106 definitions: $ln_name($material,'hexrd')
107 active: $active_material
108
109 instrument: $ln_name($instrument,'yml')
110
111 image_series:
112 format: frame-cache
113 data:
114 #for $input in $inputs
115 - file: imageseries/$ln_name($input,'npz')
116 args: {}
117 panel: $get_panel($input) # must match detector key
118 #end for
119
120 ]]></token>
121
122 <xml name="find_orientations_config">
123 <expand macro="common_config" token_multiple_inputs="true" />
124 <section name="orientation_maps" title="Orientation Maps" expanded="true">
125 <param name="threshold" type="integer" value="25" min="1" label="threshold"/>
126 <param name="bin_frames" type="integer" value="1" label="bin frames"/>
127 <param name="active_hkls" type="text" value="" optional="true" label="active hkls">
128 <validator type="regex" message="">^\d(,\d)*$</validator>
129 </param>
130 </section>
131 <param name="on_map_threshold" type="integer" value="1" min="1" label="on-map threshold used in the scoring"/>
132 <section name="search_options" title="Search Options" expanded="true">
133 <conditional name="search">
134 <param name="search_type" type="select" label="Specify Search">
135 <option value="seed_search" selected="true">use seed search</option>
136 <option value="use_quaternion_grid">use quaternion grid</option>
137 </param>
138 <when value="seed_search">
139 <param name="hkl_seeds" type="text" value="" optional="true" label="hkl seeds">
140 <validator type="regex" message="">^\d(,\d)*$</validator>
141 </param>
142 <param name="fiber_step" type="float" value="0.5" min="0" max="10" label="fiber step"/>
143 <conditional name="params">
144 <param name="method" type="select" label="Method">
145 <option value="label" selected="true">label</option>
146 <option value="blob_dog">blob_dog</option>
147 <option value="blob_log">blob_log</option>
148 </param>
149 <when value="label">
150 <param name="filter_radius" type="integer" value="1" min="1" label="label filter radius"/>
151 <param name="threshold" type="integer" value="1" min="1" label="label threshold"/>
152 </when>
153 <when value="blob_dog">
154 <param name="min_sigma" type="float" value="0.5" min="0" max="10" label="blob_dog min_sigma"/>
155 <param name="max_sigma" type="float" value="5.0" min="0" max="10" label="blob_dog max_sigma"/>
156 <param name="sigma_ratio" type="float" value="1.6" min="0" max="10" label="blob_dog sigma_ratio"/>
157 <param name="threshold" type="float" value="0.01" min="0" max="1.0" label="blob_dog threshold"/>
158 <param name="overlap" type="float" value="0.1" min="0" max="1.0" label="blob_dog overlap"/>
159 </when>
160 <when value="blob_log">
161 <param name="min_sigma" type="float" value="0.5" min="0" max="10" label="blob_log min_sigma"/>
162 <param name="max_sigma" type="float" value="5.0" min="0" max="10" label="blob_log max_sigma"/>
163 <param name="num_sigma" type="integer" value="10" min="0" max="20" label="blob_log num_sigma"/>
164 <param name="threshold" type="float" value="0.01" min="0" max="1.0" label="blob_log threshold"/>
165 <param name="overlap" type="float" value="0.1" min="0" max="1.0" label="blob_log overlap"/>
166 </when>
167 </conditional>
168 </when>
169 <when value="use_quaternion_grid">
170 <param name="quaternion_grid" type="data" format="hexrd.npz" label="quaterion grid file"/>
171 </when>
172 </conditional>
173 </section>
174 <section name="omega" title="Omega" expanded="true">
175 <param name="omega_tolerance" type="float" value="1.0" min="0" max="10.0" label="omega tolerance"/>
176 </section>
177 <section name="eta" title="eta" expanded="true">
178 <param name="eta_tolerance" type="float" value="1.0" min="0" max="10.0" label="eta tolerance"/>
179 <param name="eta_mask" type="float" value="5.0" min="0" max="10.0" label="eta mask"/>
180 </section>
181 <section name="clustering" title="Clustering" expanded="true">
182 <param name="clustering_algorithm" type="select" label="Clustering algorithm">
183 <option value="dbscan" selected="true">dbscan</option>
184 <option value="sph-dbscan">sph-dbscan</option>
185 <option value="ort-dbscan">ort-dbscan</option>
186 <option value="fclusterdata">fclusterdata (won't work for large problems)</option>
187 </param>
188 <param name="clustering_radius" type="float" value="1.0" min="0" max="10" label="clustering radius"/>
189 <param name="clustering_completeness" type="float" value="0.85" min="0" max="1" label="clustering completeness threshold"/>
190 </section>
191 <!--
192 -->
193 </xml>
194
195 <token name="@FIND_ORIENTATIONS_YML@"><![CDATA[@COMMON_YML@
196
197 #set active_hkls = 'all'
198 #if $orientation_maps.active_hkls:
199 #set active_hkls = '[' + str($orientation_maps.active_hkls) + ']'
200 #end if
201 find_orientations:
202 orientation_maps:
203 # A file name must be specified. If it doesn't exist, one will be created
204 file: null
205
206 threshold: $orientation_maps.threshold
207 bin_frames: $orientation_maps.bin_frames # defaults to 1
208
209 # "all", or a list of hkl orders used to find orientations
210 # defaults to all orders listed in the material definition
211 active_hkls: $active_hkls
212
213 # either search full quaternion grid, or seed search based on sparse
214 # orientation maps. For input search space:
215 #
216 # use_quaternion_grid: some/file/name
217 #
218 # otherwise defaults to seeded search
219 #if $search_options.search.search_type == 'use_quaternion_grid'
220 use_quaternion_grid:
221 #elif $search_options.search.search_type == 'seed_search'
222 #set hkl_seeds = '[' + str($search_options.search.hkl_seeds) + ']'
223 seed_search: # this section is ignored if use_quaternion_grid is defined
224 hkl_seeds: $hkl_seeds # hkls ids to use, must be defined for seeded search
225 fiber_step: $search_options.search.fiber_step # degrees, defaults to ome tolerance
226 # Method selection:
227 # Now 3 choices: label (the original), 'blob_dog', and 'blob_log'
228 # Each has its own parameter names, examples below.
229 #
230 method:
231 #if $search_options.search.params.method == 'label'
232 label:
233 filter_radius: $search_options.search.params.filter_radius
234 threshold: $search_options.search.params.threshold
235 #elif $search_options.search.params.method == 'blob_dog'
236 blob_dog:
237 min_sigma: $search_options.search.params.min_sigma
238 max_sigma: $search_options.search.params.max_sigma
239 sigma_ratio: $search_options.search.params.sigma_ratio
240 threshold: $search_options.search.params.threshold
241 overlap: $search_options.search.params.overlap
242 #elif $search_options.search.params.method == 'blob_log'
243 blob_log:
244 min_sigma: $search_options.search.params.min_sigma
245 max_sigma: $search_options.search.params.max_sigma
246 num_sigma: $search_options.search.params.num_sigma
247 threshold: $search_options.search.params.threshold
248 overlap: $search_options.search.params.overlap
249 #end if
250 # this is the on-map threshold using in the scoring
251 # defaults to 1
252 #end if
253 threshold: $on_map_threshold
254
255 omega:
256 tolerance: $omega.omega_tolerance # in degrees, defaults to 2x ome step
257
258 eta:
259 tolerance: $eta.eta_tolerance # in degrees, defaults to 2x ome step
260 mask: $eta.eta_mask # degrees, mask angles close to ome rotation axis, defaults to 5
261
262 clustering:
263 # algorithm choices are
264 # sph-dbscan
265 # ort-dbscn
266 # dbscan <default>
267 # fclusterdata; this is a fallback and won't work for large problems
268 algorithm: $clustering.clustering_algorithm
269 radius: $clustering.clustering_radius
270 completeness: $clustering.clustering_completeness
271
272 ]]></token>
273
274 <xml name="fit_grains_config">
275 <expand macro="common_config" token_multiple_inputs="true"/>
276 <param name="ome_map" type="data" format="hexrd.npz" label="analysis eta-ome_maps.npz from find_orientations"/>
277 <param name="accepted_orientations" type="data" format="tabular" label="accepted_orientations from find_orientations"/>
278 <param name="grains_estimate" type="data" format="tabular" label="grains.out from find_orientations"/>
279 <param name="do_fit" type="boolean" truevalue="true" falsevalue="false" checked="true" label="fit grains" help="if false, extracts grains but doesn't fit"/>
280 <param name="npdiv" type="integer" value="2" min="1" label="number of polar pixel grid subdivisions"/>
281 <param name="threshold" type="integer" value="25" min="1" label="threshold"/>
282 <section name="tolerance" title="Fit Grain Tolerance" expanded="true">
283 <repeat name="tolerance_lists" title="Tolerance values" min="1">
284 <param name="tth" type="float" value="" min="0" label="tth"/>
285 <param name="eta" type="float" value="" min="0" label="eta"/>
286 <param name="omega" type="float" value="" min="0" label="omega"/>
287 </repeat>
288 <param name="refit" type="text" value="1" label="refit">
289 <validator type="regex" message="">^\d(,\d)*$</validator>
290 </param>
291 <param name="tth_max" type="float" value="14.25" label="tth_max"/>
292 </section>
293 </xml>
294
295 <token name="@FIT_GRAINS_YML@"><![CDATA[@COMMON_YML@
296 find_orientations:
297 orientation_maps:
298 # A file name must be specified. If it doesn't exist, one will be created
299 file: $ln_name($ome_map,'npz')
300
301 fit_grains:
302 do_fit: $do_fit # if false, extracts grains but doesn't fit. defaults to true
303
304 # estimate: null
305
306 npdiv: $npdiv # number of polar pixel grid subdivisions, defaults to 2
307
308 threshold: $threshold
309
310 #set $tth = []
311 #set $eta = []
312 #set $omega = []
313 #set refit = '[' + str($tolerance.refit) + ']'
314 #for $tol in $tolerance.tolerance_lists
315 $tth.append(float($tol.tth))
316 $eta.append(float($tol.eta))
317 $omega.append(float($tol.omega))
318 #end for
319 tolerance:
320 tth: $tth # tolerance lists must be identical length
321 eta: $eta
322 omega: $omega
323
324 refit: $refit
325 tth_max: $tolerance.tth_max # true, false, or a non-negative value, defaults to true
326 ]]></token>
327
328 </macros>