<?xml version="1.0"?>
<macros>
  <xml name="requirements">
    <requirements>
      <requirement type="package" version="1.12.1">jbrowse</requirement>
      <requirement type="package" version="2.7">python</requirement>
      <requirement type="package" version="1.66">biopython</requirement>
      <requirement type="package" version="0.6.2">bcbiogff</requirement>
      <requirement type="package" version="1.2">samtools</requirement>
      <requirement type="package" version="3.11">pyyaml</requirement>
      <yield/>
    </requirements>
  </xml>
  <token name="@DATA_DIR@">\$GALAXY_JBROWSE_SHARED_DIR</token>
  <token name="@WRAPPER_VERSION@">0.5.2</token>
  <xml name="stdio">
    <stdio>
      <exit_code range="1:"/>
      <exit_code range=":-1"/>
      <regex match="Error:"/>
      <regex match="Exception:"/>
    </stdio>
  </xml>
  <token name="@ATTRIBUTION@"><![CDATA[
**Attribution**

This Galaxy tool relies on the JBrowse, maintained by the GMOD Community. The Galaxy wrapper is developed by Eric Rasche
]]>
  </token>
  <xml name="auto_manual_tk"
      token_cond_label="Color"
      token_cond_name="color"
      token_select_label="Color Specification"
      token_select_name="color_select"
      token_automatic_label="Automatically selected"
      token_manual_label="Manual Color Selection">
    <conditional name="@COND_NAME@" label="@COND_LABEL@">
      <param type="select" label="@SELECT_LABEL@" name="@SELECT_NAME@">
        <option value="automatic" selected="true">@AUTOMATIC_LABEL@</option>
        <option value="manual">@MANUAL_LABEL@</option>
      </param>
      <when value="automatic">
      </when>
      <when value="manual">
        <yield />
      </when>
    </conditional>
  </xml>

  <xml name="track_display">
    <param type="select" label="Track Visibility" name="track_visibility">
      <option value="default_off">Off for new users</option>
      <option value="default_on">On for new users</option>
      <option value="force">Force On</option>
      <option value="always">Always On (ignores URL parameters)</option>
    </param>
  </xml>

  <xml name="jb_color"
      token_label="JBrowse style.color"
      token_name="style_color"
      token_value="goldenrod"
      token_help="Basic color of features. Most glyphs interpret this as the fill color of the rectangle they draw. Color syntax is the same as that used for CSS"
      >
    <param label="@LABEL@" type="color" name="@NAME@" value="@VALUE@" help="@HELP@">
      <sanitizer>
        <valid initial="string.letters,string.digits">
          <add value="#" />
        </valid>
      </sanitizer>
    </param>
  </xml>

  <xml name="auto_color"
       token_cond_label="Color"
       token_cond_name="color"
       token_select_label="Color Selection"
       token_select_name="color_select"
       token_automatic_label="Automatically selected"
       token_manual_label="Manual Color Selection">
    <expand macro="auto_manual_tk"
            cond_label="@COND_LABEL@"
            cond_name="@COND_NAME@"
            select_label="@SELECT_LABEL@"
            select_name="@SELECT_NAME@"
            automatic_label="@AUTOMATIC_LABEL@"
            manual_label="@MANUAL_LABEL@">
      <expand macro="jb_color" />
        <yield />
    </expand>
  </xml>



  <xml name="brewer_scheme">
    <param type="select" label="Brewer color Scheme" name="brewer_scheme">
        <option value="BrBg">BrBg: Brown - Blue Green</option>
        <option value="PiYg">PiYg: Pink - Yellow Green</option>
        <option value="PRGn">PRGn: Purple Red - Green</option>
        <option value="PuOr">PuOr: Purple - Orange</option>
        <option value="RdBu" selected="true">RdBu: Red - Blue</option>
        <option value="RdGy">RdGy: Red - Gray</option>
        <option value="RdYlBu">RdYlBu: Red - Yellow - Blue</option>
        <option value="RdYlGn">RdYlBu: Red - Yellow - Green</option>
        <option value="Spectral">Spectral</option>
    </param>
  </xml>
  <xml name="general_options">
    <section name="jbgen" title="General JBrowse Options [Advanced]" expanded="false">
      <param label="Default Location" type="text" name="defaultLocation" value="" help="Initial location to be shown for users who have never visited the browser before. Example: 'ctgA:1234..5678'"/>
      <param label="Track Padding" type="integer" value="20" name="trackPadding" help="Spacing between tracks in the genome view, in pixels." />

      <param label="Enable Share Link" name="shareLink" type="boolean" checked="true" truevalue="true" falsevalue="false" />
      <param label="About the Browser" type="text" name="aboutDescription" value="" help="Description of the browser to be used in the 'About' popup" />

      <param label="Show Track List" name="show_tracklist" type="boolean" checked="true" truevalue="true" falsevalue="false" help="Optionally hide the track list"/>
      <param label="Show Navigation" name="show_nav"       type="boolean" checked="true" truevalue="true" falsevalue="false" help="Optionally hide the navigation menu"/>
      <param label="Show Overview"   name="show_overview"  type="boolean" checked="true" truevalue="true" falsevalue="false" help="Optionally hide the overview bar"/>
      <param label="Show Menu"       name="show_menu"      type="boolean" checked="true" truevalue="true" falsevalue="false" help="Optionally hide the menu bar"/>

      <param label="Hide Genome Options" name="hideGenomeOptions" type="boolean" truevalue="true" falsevalue="false" help="Hide options for opening a sequence file"/>
    </section>
  </xml>
  <xml name="color_selection_minmax">
    <section name="jbcolor" title="JBrowse Color Options [Advanced]" expanded="false">
      <!-- Abuse auto/manual for bicolor pivot. Means we'll have to handle the
           auto case as well, but may be safe to just say "brewer colors? Pff,
           red/blue" -->
      <expand macro="auto_manual_tk"
              token_cond_label="Color"
              token_cond_name="color"
              token_select_label="Color Selection"
              token_select_name="color_select"
              token_automatic_label="Automatically selected"
              token_manual_label="Manual Color Selection">
        <expand macro="jb_color"
                label="JBrowse style.pos_color"
                name="style_pos_color"
                value="blue"
                help="CSS color, default 'blue'. When drawing bicolor plots, the fill color to use for values that are above the pivot point." />
        <expand macro="jb_color"
                label="JBrowse style.neg_color"
                name="style_neg_color"
                value="red"
                help=" CSS color, default 'red'. When drawing bicolor plots, the fill color to use for values that are below the pivot point." />
      </expand>

      <conditional name="bicolor_pivot" label="Bicolor Pivot">
        <param type="select" label="Bicolor Pivot" name="bicolor_pivot_select">
          <option value="zero" selected="true">Zero</option>
          <option value="mean">Mean</option>
          <option value="custom">Custom Value</option>
        </param>
        <when value="zero" />
        <when value="mean" />
        <when value="custom">
          <param label="JBrowse style.bicolor_pivot" type="float" name="pivot_point" value="0.0" help="Where to change from pos_color to neg_color when drawing bicolor plots." />
        </when>
      </conditional>
    </section>
  </xml>

  <xml name="color_selection"
       token_scaling_lin_select="true"
       token_scaling_log_select="false"
      >
    <section name="jbcolor_scale" title="JBrowse Feature Score Scaling &amp; Coloring Options [Advanced]" expanded="false">
      <conditional name="color_score" label="JBrowse style.color &amp; Score relationship">
        <param type="select" label="Color Score Algorithm" name="color_score_select" help="How to color the features. If it is based on score, then features with a score attribute anywhere in their hierachy will have their color affected by the score. If you choose to ignore the score, then you'll be able to select a single solid color for every feature in the track">
          <option value="score">Based on score</option>
          <option value="none" selected="true">Ignore score</option>
        </param>
        <when value="none">
          <!-- When no scaling is done, no scores available, then just let the
               user choose a base color for the track -->
          <expand macro="auto_color" />
        </when>
        <when value="score">
            <!-- Scaling -->
            <param type="select" label="JBrowse style.color function's score scaling" name="score_scaling"
                   help="How should the colors be distributed across the values? For blast results which distributes scores on the scale of approximately [1e-500, 10], it makes sense to request a logarithmic scaling of the color values. Logarithmic is indeed the default for blast. However other analysis methods may produce scores on ranges such as [0, 100] where a linear scale would be more appropriate for color distribution.">
              <option value="linear"      selected="@SCALING_LIN_SELECT@" >Linear scaling</option>
              <option value="logarithmic">Logarithmic scaling</option>
              <option value="blast"       selected="@SCALING_LOG_SELECT@" >Blast scaling</option>
            </param>

            <!-- Scaling Bounds -->
            <conditional name="score_scales" label="Minimum/Maximum values for track scores">
              <param type="select" label="How should minimum and maximum values be determined for the scores of the features" name="scale_select">
                <option value="automatic" selected="true">Automatically determined</option>
                <option value="manual">Manually specify minimum and maximum expected scores for the feature track</option>
              </param>
              <when value="automatic">
              </when>
              <when value="manual">
                <param label="Minimum expected score" name="minimum" type="integer" value="0" />
                <param label="Maximum expected score" name="maximum" type="integer" value="100" />
              </when>
            </conditional>

            <!-- Scale color -->
            <conditional name="color_scheme" label="Color Scheme for scored features">
              <param type="select" label="JBrowse style.color function's color scheme for scored values" name="score_scheme">
                <option value="opacity">Opacity (high scores = 1.0 opacity)</option>
                <!--<option value="brewer">Brewer Color Schemes</option>-->
              </param>
              <when value="opacity">
                <!-- Single color selection mode -->
                <expand macro="auto_color" />
              </when>
              <!--<when value="brewer">-->
                <!--[> Brewer continuum selection <]-->
                <!--<expand macro="brewer_scheme" />-->
              <!--</when>-->
            </conditional>
        </when>
      </conditional>
    </section>
  </xml>
  <xml name="track_styling"
       token_classname="feature"
       token_label="name,id"
       token_description="note,description"
       token_height="100px">
    <section name="jbstyle" title="JBrowse Styling Options [Advanced]" expanded="false">
        <param label="JBrowse style.className" type="text"
               name="style_classname"
               value="@CLASSNAME@"
               help="Set CSS style.className property"/>
        <param label="JBrowse style.label"
               type="text"
               name="style_label"
               value="@LABEL@"
               help="Comma-separated list of case-insensitive feature tags to use for showing the feature's label. The first one found will be used. Default 'name,id'" />
        <param label="JBrowse style.description"
               type="text"
               name="style_description"
               value="@DESCRIPTION@"
               help="Comma-separated list of case-insensitive feature tags to check for the feature's long description. The first one found will be used."/>
        <param label="JBrowse style.height"
               type="text"
               name="style_height"
               value="@HEIGHT@"
               help="Height in pixels of glyphs. Default value varies from glyph to glyph. Note that the 'compact' displayMode uses style->height * 0.35 so changing style height can adjust the compact visualization."/>
    </section>
  </xml>

  <xml name="track_menu">
    <section name="jbmenu" title="JBrowse Contextual Menu options [Advanced]" expanded="false">
      <repeat name="track_menu" title="Track Menu">
          <param label="Menu action"
                 type="select"
                 name="menu_action"
                 help="Action performed when user clicks on the menu">
            <option value="iframeDialog" selected="true">iframeDialog: causes the given url to be opened in a popup dialog box within JBrowse, in an iframe element.</option>
            <option value="newWindow">newWindow: causes the given url to be opened in a new browser window.</option>
            <option value="navigateTo">navigateTo: opens the given url in the same browser window, navigating the user away from JBrowse.</option>
          </param>
          <param label="Menu label"
                 type="text"
                 name="menu_label"
                 help="Will be displayed in the contextual menu on each feature ({name}, {id}, {type}, {start}, {end}, {strand} variables will be interpreted)">
           <expand macro="menu_sanitize" />
          </param>
          <param label="Menu title"
                 type="text"
                 name="menu_title"
                 help="Will be displayed in the popup title bar if displayed ({id}, {type}, {start}, {end}, {strand} variables will be interpreted)">
           <expand macro="menu_sanitize" />
          </param>
          <param label="Menu url"
                 type="text"
                 name="menu_url"
                 help="Destination URL ({name}, {id}, {type}, {start}, {end}, {strand} variables will be interpreted)">
           <expand macro="menu_sanitize" />
          </param>
          <param label="Menu icon"
                 type="select"
                 name="menu_icon"
                 help="Icon to display next to menu label">
            <option value="dijitIconBookmark" selected="true">Bookmark</option>
            <option value="dijitIconSave">Save</option>
            <option value="dijitIconPrint">Print</option>
            <option value="dijitIconCut">Cut</option>
            <option value="dijitIconCopy">Copy</option>
            <option value="dijitIconClear">Clear</option>
            <option value="dijitIconDelete">Delete</option>
            <option value="dijitIconUndo">Undo</option>
            <option value="dijitIconEdit">Edit</option>
            <option value="dijitIconNewTask">New Task</option>
            <option value="dijitIconEditTask">Edit Task</option>
            <option value="dijitIconEditProperty">Edit Property</option>
            <option value="dijitIconTask">Task</option>
            <option value="dijitIconFilter">Filter</option>
            <option value="dijitIconConfigure">Configure</option>
            <option value="dijitIconSearch">Search</option>
            <option value="dijitIconApplication">Application</option>
            <option value="dijitIconChart">Chart</option>
            <option value="dijitIconConnector">Connector</option>
            <option value="dijitIconDatabase">Database</option>
            <option value="dijitIconDocuments">Documents</option>
            <option value="dijitIconMail">Mail</option>
            <option value="dijitLeaf">Leaf</option>
            <option value="dijitIconFile">File</option>
            <option value="dijitIconFunction">Function</option>
            <option value="dijitIconKey">Key</option>
            <option value="dijitIconPackage">Package</option>
            <option value="dijitIconSample">Sample</option>
            <option value="dijitIconTable">Table</option>
            <option value="dijitIconUsers">Users</option>
            <option value="dijitIconFolderClosed">Folder Closed</option>
            <option value="dijitIconFolderOpen">Folder Open</option>
            <option value="dijitIconError">Error</option>
          </param>
      </repeat>
    </section>
  </xml>

  <xml name="menu_sanitize">
    <sanitizer>
        <valid>
            <add value="{"/>
            <add value="}"/>
            <add value="!"/>
            <add value="?"/>
            <add value="&amp;"/>
            <add value="+"/>
            <add value="="/>
            <add value="'"/>
            <add value='"'/>
        </valid>
    </sanitizer>
  </xml>

  <xml name="input_conditional" token_label="Track Data" token_format="data">
      <param label="@LABEL@" format="@FORMAT@" name="annotation" type="data" multiple="True"/>
  </xml>
  <xml name="citations">
    <citations>
      <citation type="doi">10.1101/gr.094607.109</citation>
    </citations>
  </xml>
</macros>
