diff macros.xml @ 5:36f0e168e5ef draft

"planemo upload for repository https://github.com/ximg-chess/galaxytools/tools/hexrd commit 0db0d2633f65e2ceca2e34c8899a52b18965d059-dirty"
author ximgchess
date Thu, 01 Apr 2021 18:31:47 +0000
parents
children 164e881c40e2
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/macros.xml	Thu Apr 01 18:31:47 2021 +0000
@@ -0,0 +1,382 @@
+<macros>
+    <token name="@TOOL_VERSION@">0.8.4</token>
+    <token name="@VERSION_SUFFIX@">0</token>
+    <xml name="requirements">
+        <requirements>
+        <requirement type="package" version="@TOOL_VERSION@">hexrd</requirement>
+            <yield/>
+        </requirements>
+    </xml>
+    <xml name="citations">
+        <citations>
+            <citation type="doi">10.1016/j.matchar.2020.110366</citation>
+            <yield />
+        </citations>
+    </xml>
+
+    <token name="@CMD_IMPORTS@">
+#import re
+#import yaml
+
+#set global $img_panel_dict = dict()
+#if $detector.panel_assignment == 'panel_table'
+#set $fh = open(str($detector.image_panel_table),'r')
+#for $line in $fh:
+    #set $fields = $line.strip().split('\t')
+    #silent $img_panel_dict[$fields[0]] = $fields[1]
+#end for
+#end if
+#set global $panels = $yaml.safe_load(open(str($instrument),'r'))['detectors'].keys()
+#def identifier_or_name($input1)
+    #if hasattr($input1, 'element_identifier')
+        #return $input1.element_identifier
+    #elif hasattr($input1, 'name')
+        #return $input1.name
+    #else
+        #return str($input1)
+    #end if
+#end def
+#def clean($name1)
+    #set $name_clean = $re.sub('[^\w\-_]', '_', $re.sub('(?i)[.](npz|hexrd|yml|dat|out)$','', $name1.split()[-1]))
+    #return $name_clean
+#end def
+#def ln_name($ds,$ext)
+    #set $lname = "%s.%s" % ($clean($identifier_or_name($ds)),$ext)
+    #return $lname
+#end def
+#def get_panel($img_input):
+    #set $img_name = $identifier_or_name($img_input)
+    #if $img_panel_dict and $img_name in $img_panel_dict:
+        #return $img_panel_dict[$img_name]
+    #end if
+    #for $p in $panels:
+        #if $p in $img_name:
+            #return $p
+        #end if
+    #end for
+    #return $img_name
+#end def
+    </token>
+
+    <xml name="common_config" token_multiple_inputs="true" >
+        <param name="inputs" type="data" format="hexrd.npz" multiple="true" label="Image series frame-cache"/>
+        <conditional name="detector">
+            <param name="panel_assignment" type="select" label="Assign detector panel to images">
+                <option value="infer_from_name" selected="true">Infer the panel from the image name</option>
+                <option value="panel_table">Input a table with image panels assignments</option>
+            </param>
+            <when value="infer_from_name"/>
+            <when value="panel_table">
+                <param name="image_panel_table" type="data" format="tabular" label="Image panel assignment table">
+                    <help>A 2-column table:image dataset name   detector panel name</help>
+                </param>
+            </when>
+        </conditional>
+        <param name="instrument" type="data" format="hexrd.yml" label="instrument"/>
+        <param name="material" type="data" format="hexrd.materials.h5" label="material"/>
+        <param name="active_material" type="text" value="" label="active material name">
+            <validator type="empty_field" />
+        </param>
+    </xml>
+
+    <token name="@CMD_LINKS@"><![CDATA[@CMD_IMPORTS@
+mkdir -p imageseries &&
+ln -s '$material' $ln_name($material,'h5') &&
+ln -s '$instrument' $ln_name($instrument,'yml') &&
+#for $input in $inputs
+ln -s '$input' imageseries/$ln_name($input,'npz') &&
+#end for
+]]>
+    </token>
+    <token name="@FIT_GRAIN_LINKS@"><![CDATA[@CMD_LINKS@
+ln -s '$ome_map' $ln_name($ome_map,'npz') &&
+ln -s '$accepted_orientations' $ln_name($accepted_orientations,'dat') &&
+##mkdir -p analysis &&
+##cp '$grains_estimate' analysis/$ln_name($grains_estimate,'out') &&
+]]>
+    </token>
+
+    <token name="@CONVERT2TAB@"><![CDATA[for i in `find analysis -name '[gs]*.out'`; do sed -i.bak "s/[ ][ ][ ]*/\$(printf '\t')/g" \${i}; done]]></token>
+
+    <token name="@COMMON_YML@"><![CDATA[@CMD_IMPORTS@
+analysis_name: analysis
+
+multiprocessing: -1
+
+material:
+  definitions: $ln_name($material,'h5')
+  active: $active_material
+
+instrument: $ln_name($instrument,'yml')
+
+image_series:
+  format: frame-cache
+  data:
+#for $input in $inputs
+    - file: imageseries/$ln_name($input,'npz')
+      args: {}
+      panel: $get_panel($input)  # must match detector key
+#end for
+
+]]></token>
+
+    <xml name="find_orientations_config">
+        <expand macro="common_config" token_multiple_inputs="true" />
+        <section name="orientation_maps" title="Orientation Maps" expanded="true">
+            <param name="threshold" type="integer" value="25" min="1" label="threshold"/>
+            <param name="bin_frames" type="integer" value="1" label="bin frames"/>
+            <!-- active_hkls should be able to be optional="true" -->
+            <param name="active_hkls" type="text" value="" label="active hkl planes"> 
+                <help>commas separated list of planes, e.g.: 0,1,2,3,4,5</help>
+                <validator type="regex" message="plane indeces separated by commas">^\d(,\d)*$</validator>
+	    </param> 
+        </section>
+        <param name="on_map_threshold" type="integer" value="1" min="1" label="on-map threshold used in the scoring"/>
+        <section name="search_options" title="Search Options" expanded="true">
+            <conditional name="search">
+                <param name="search_type" type="select" label="Specify Search">
+                    <option value="seed_search" selected="true">use seed search</option>
+                    <option value="use_quaternion_grid">use quaternion grid</option>
+                </param>
+                <when value="seed_search">
+                    <!-- hkl_seeds should be able to be optional="true" -->
+                    <param name="hkl_seeds" type="text" value="" label="hkl seeds">
+                        <help>commas separated list of planes, e.g.: 0,1,2 (subset of active hkl planes)</help>
+                        <validator type="regex" message="">^\d(,\d)*$</validator>
+    	        </param> 
+                    <param name="fiber_step" type="float" value="0.5" min="0" max="10" label="fiber step"/>
+                    <conditional name="params">
+                        <param name="method" type="select" label="Method">
+                            <option value="label" selected="true">label</option>
+                            <option value="blob_dog">blob_dog</option>
+                            <option value="blob_log">blob_log</option>
+                        </param>
+                        <when value="label">
+                            <param name="filter_radius" type="integer" value="1" min="1" label="label filter radius"/>
+                            <param name="threshold" type="integer" value="1" min="1" label="label threshold"/>
+                        </when>
+                        <when value="blob_dog">
+                            <param name="min_sigma" type="float" value="0.5" min="0" max="10" label="blob_dog min_sigma"/>
+                            <param name="max_sigma" type="float" value="5.0" min="0" max="10" label="blob_dog max_sigma"/>
+                            <param name="sigma_ratio" type="float" value="1.6" min="0" max="10" label="blob_dog sigma_ratio"/>
+                            <param name="threshold" type="float" value="0.01" min="0" max="1.0" label="blob_dog threshold"/>
+                            <param name="overlap" type="float" value="0.1" min="0" max="1.0" label="blob_dog overlap"/>
+                        </when>
+                        <when value="blob_log">
+                            <param name="min_sigma" type="float" value="0.5" min="0" max="10" label="blob_log min_sigma"/>
+                            <param name="max_sigma" type="float" value="5.0" min="0" max="10" label="blob_log max_sigma"/>
+                            <param name="num_sigma" type="integer" value="10" min="0" max="20" label="blob_log num_sigma"/>
+                            <param name="threshold" type="float" value="0.01" min="0" max="1.0" label="blob_log threshold"/>
+                            <param name="overlap" type="float" value="0.1" min="0" max="1.0" label="blob_log overlap"/>
+                        </when>
+                    </conditional>
+                </when>
+                <when value="use_quaternion_grid">
+                    <param name="quaternion_grid" type="data" format="hexrd.npz" label="quaterion grid file"/>
+                </when>
+            </conditional>
+        </section>
+        <section name="omega" title="Omega" expanded="true">
+            <param name="omega_tolerance" type="float" value="1.0" min="0" max="10.0" label="omega tolerance"/>
+        </section>
+        <section name="eta" title="eta" expanded="true">
+            <param name="eta_tolerance" type="float" value="1.0" min="0" max="10.0" label="eta tolerance"/>
+            <param name="eta_mask" type="float" value="5.0" min="0" max="10.0" label="eta mask"/>
+        </section>
+        <section name="clustering" title="Clustering" expanded="true">
+            <param name="clustering_algorithm" type="select" label="Clustering algorithm">
+                <option value="dbscan" selected="true">dbscan</option>
+                <option value="sph-dbscan">sph-dbscan</option>
+                <option value="ort-dbscan">ort-dbscan</option>
+                <option value="fclusterdata">fclusterdata (won't work for large problems)</option>
+            </param>
+            <param name="clustering_radius" type="float" value="1.0" min="0" max="10" label="clustering radius"/>
+            <param name="clustering_completeness" type="float" value="0.85" min="0" max="1" label="clustering completeness threshold"/>
+        </section>
+        <!-- 
+        -->
+    </xml>
+
+    <token name="@FIND_ORIENTATIONS_YML@"><![CDATA[@COMMON_YML@
+
+#set active_hkls = 'all'
+#if $orientation_maps.active_hkls:
+#set active_hkls = '[' + str($orientation_maps.active_hkls) + ']'
+#end if
+find_orientations:
+  orientation_maps:
+    # A file name must be specified. If it doesn't exist, one will be created
+    file: null
+
+    threshold: $orientation_maps.threshold
+    bin_frames: $orientation_maps.bin_frames # defaults to 1
+
+    # "all", or a list of hkl orders used to find orientations
+    # defaults to all orders listed in the material definition
+    active_hkls: $active_hkls
+
+  # either search full quaternion grid, or seed search based on sparse
+  # orientation maps.  For input search space:
+  #
+  # use_quaternion_grid: some/file/name
+  #
+  # otherwise defaults to seeded search
+#if $search_options.search.search_type == 'use_quaternion_grid'
+  use_quaternion_grid: 
+#elif $search_options.search.search_type == 'seed_search'
+#set hkl_seeds = '[' + str($search_options.search.hkl_seeds) + ']'
+  seed_search: # this section is ignored if use_quaternion_grid is defined
+    hkl_seeds: $hkl_seeds # hkls ids to use, must be defined for seeded search
+    fiber_step: $search_options.search.fiber_step # degrees, defaults to ome tolerance
+    # Method selection:
+    #   Now 3 choices: label (the original), 'blob_dog', and 'blob_log'
+    #   Each has its own parameter names, examples below.
+    #
+    method:
+    #if $search_options.search.params.method == 'label'
+      label:
+        filter_radius: $search_options.search.params.filter_radius
+        threshold: $search_options.search.params.threshold
+    #elif $search_options.search.params.method == 'blob_dog'
+      blob_dog:
+        min_sigma: $search_options.search.params.min_sigma
+        max_sigma: $search_options.search.params.max_sigma
+        sigma_ratio: $search_options.search.params.sigma_ratio
+        threshold: $search_options.search.params.threshold
+        overlap: $search_options.search.params.overlap
+    #elif $search_options.search.params.method == 'blob_log'
+      blob_log:
+        min_sigma: $search_options.search.params.min_sigma
+        max_sigma: $search_options.search.params.max_sigma
+        num_sigma: $search_options.search.params.num_sigma
+        threshold: $search_options.search.params.threshold
+        overlap: $search_options.search.params.overlap
+    #end if
+  # this is the on-map threshold using in the scoring
+  # defaults to 1
+#end if
+  threshold: $on_map_threshold
+
+  omega:
+    tolerance: $omega.omega_tolerance  # in degrees, defaults to 2x ome step
+
+  eta:
+    tolerance: $eta.eta_tolerance  # in degrees, defaults to 2x ome step
+    mask: $eta.eta_mask  # degrees, mask angles close to ome rotation axis, defaults to 5
+
+  clustering:
+    # algorithm choices are
+    #   sph-dbscan
+    #   ort-dbscn
+    #   dbscan <default>
+    #   fclusterdata; this is a fallback and won't work for large problems
+    algorithm: $clustering.clustering_algorithm
+    radius: $clustering.clustering_radius
+    completeness: $clustering.clustering_completeness
+
+]]></token>
+
+    <xml name="fit_grains_config">
+        <expand macro="common_config" token_multiple_inputs="true"/>
+        <param name="ome_map" type="data" format="hexrd.npz" label="analysis eta-ome_maps.npz from find_orientations"/>
+        <param name="accepted_orientations" type="data" format="tabular" label="accepted_orientations from find_orientations"/>
+        <param name="grains_estimate" type="data" format="tabular" label="grains.out from find_orientations"/>
+        <param name="do_fit" type="boolean" truevalue="true" falsevalue="false" checked="true" label="fit grains" help="if false, extracts grains but doesn't fit"/>
+        <param name="npdiv" type="integer" value="2" min="1" label="number of polar pixel grid subdivisions"/>
+        <param name="threshold" type="integer" value="25" min="1" label="threshold"/>
+        <section name="tolerance" title="Fit Grain Tolerance" expanded="true">
+            <repeat name="tolerance_lists" title="Tolerance values" min="1">
+                <param name="tth" type="float" value="" min="0" label="tth"/>
+                <param name="eta" type="float" value="" min="0" label="eta"/>
+                <param name="omega" type="float" value="" min="0" label="omega"/>
+            </repeat>
+            <param name="refit" type="text" value="1" label="refit">
+                <validator type="regex" message="">^\d(,\d)*$</validator>
+            </param>
+            <conditional name="max_tth">
+                <param name="tth_max_value" type="select" label="Set tth_max">
+                    <option value="true" selected="true">true</option>
+                    <option value="false">false</option>
+                    <option value="entered">enter value</option>
+		</param> 
+                <when value="true"/>
+                <when value="false"/>
+                <when value="entered">
+                    <param name="tth_max" type="float" value="14.25" label="tth_max"/>
+	        </when>
+	  </conditional>
+        </section>
+    </xml>
+
+    <token name="@FIT_GRAINS_YML@"><![CDATA[@COMMON_YML@
+find_orientations:
+  orientation_maps:
+    # A file name must be specified. If it doesn't exist, one will be created
+    file: $ln_name($ome_map,'npz')
+
+fit_grains:
+  do_fit: $do_fit # if false, extracts grains but doesn't fit. defaults to true
+  # estimate: null
+  npdiv: $npdiv # number of polar pixel grid subdivisions, defaults to 2
+  threshold: $threshold
+
+#set $tth = []
+#set $eta = []
+#set $omega = []
+#set refit = '[' + str($tolerance.refit) + ']'
+#for $tol in $tolerance.tolerance_lists
+#silent $tth.append(float($tol.tth))
+#silent $eta.append(float($tol.eta))
+#silent $omega.append(float($tol.omega))
+#end for
+  tolerance:
+    tth: $tth # tolerance lists must be identical length
+    eta: $eta
+    omega: $omega
+
+  refit: $refit
+  #if $tolerance.max_tth.tth_max_value == 'entered':
+  tth_max: $tolerance.max_tth.tth_max # true, false, or a non-negative value, defaults to true
+  #else
+  tth_max: $tolerance.max_tth.tth_max_value # true, false, or a non-negative value, defaults to true
+  #end if
+]]></token>
+    <token name="@HEXRD_HELP@"><![CDATA[
+HEXRD_ provides analysis of x-ray diffraction data, especially high-energy x-ray diffraction. HEXRD is comprised of a library and API for writing scripts, a command line interface, and an interactive graphical user interface.
+
+.. _HEXRD: https://github.com/HEXRD/hexrd
+]]></token>
+
+    <token name="@COMMON_INPUTS_HELP@"><![CDATA[
+
+**INPUTS** 
+
+  - imageseries - Detector image files converted to sparse matrix compressed numpy arrays.  
+  - instrument - A yaml file that decribes the instrument 
+  - materials.hexrd - A "pickled" hexrd Materials object that desscribes the sample material
+]]></token>
+    <token name="@FIT_GRAIN_INPUTS_HELP@"><![CDATA[@COMMON_INPUTS_HELP@
+  - analysis eta-ome_maps.npz from find_orientations
+  - accepted_orientations from find_orientations
+
+]]></token>
+
+    <token name="@COMMON_OUTPUTS_HELP@"><![CDATA[
+
+**OUTPUTS**
+
+  - config yaml - parameter for hexrd
+  - log - the hexrd logging output
+  - grains.out
+]]></token>
+    <token name="@FIND_ORIENTATIONS_OUTPUTS_HELP@"><![CDATA[@COMMON_OUTPUTS_HELP@
+  - analysis eta-ome_maps.npz *(used as input for hexrd fit-grains)*
+  - analysis accepted_orientations_analysis.dat *(used as input for hexrd fit-grains)*
+  - analysis scored_orientations_analysis.npz
+]]></token>
+    <token name="@FIT_GRAINS_OUTPUTS_HELP@"><![CDATA[@COMMON_OUTPUTS_HELP@
+  - Collection of spots.out
+]]></token>
+
+
+</macros>