<?xml version='1.0' encoding='UTF-8'?>
<!--This is a configuration file for the integration of a tools into Galaxy (https://galaxyproject.org/). This file was automatically generated using CTDConverter.-->
<!--Proposed Tool Section: [Test]-->
<tool id="ofile-mult" name="ofile-mult" version="@TOOL_VERSION@+galaxy@GALAXY_VERSION@">
  <description>multiple Output File parameter tests</description>
  <macros>
    <token name="@EXECUTABLE@">ofile-mult</token>
    <import>macros.xml</import>
  </macros>
  <expand macro="requirements"/>
  <expand macro="stdio"/>
  <command detect_errors="exit_code"><![CDATA[@QUOTE_FOO@
@EXT_FOO@
#import re

## Preprocessing
mkdir mandatory_mandatoryinput &&
mkdir ${' '.join(["'mandatory_mandatoryinput/%s'" % (i) for i, f in enumerate($inp_mandatory_mandatoryinput) if f])} && 
#if "optional_mandatoryinput_FLAG" in str($OPTIONAL_OUTPUTS).split(',')
  mkdir optional_mandatoryinput &&
  mkdir ${' '.join(["'optional_mandatoryinput/%s'" % (i) for i, f in enumerate($inp_optional_mandatoryinput) if f])} && 
#end if
mkdir inp_mandatory_mandatoryinput &&
mkdir ${' '.join(["'inp_mandatory_mandatoryinput/%s'" % (i) for i, f in enumerate($inp_mandatory_mandatoryinput) if f])} && 
${' '.join(["ln -s '%s' 'inp_mandatory_mandatoryinput/%s/%s.%s' && " % (f, i, re.sub('[^\w\-_]', '_', f.element_identifier), $gxy2omsext(f.ext)) for i, f in enumerate($inp_mandatory_mandatoryinput) if f])}
mkdir inp_optional_mandatoryinput &&
mkdir ${' '.join(["'inp_optional_mandatoryinput/%s'" % (i) for i, f in enumerate($inp_optional_mandatoryinput) if f])} && 
${' '.join(["ln -s '%s' 'inp_optional_mandatoryinput/%s/%s.%s' && " % (f, i, re.sub('[^\w\-_]', '_', f.element_identifier), $gxy2omsext(f.ext)) for i, f in enumerate($inp_optional_mandatoryinput) if f])}

## Main program call

set -o pipefail &&
@EXECUTABLE@ -write_ctd ./ &&
python3 '$__tool_directory__/fill_ctd.py' '@EXECUTABLE@.ctd' '$args_json' '$hardcoded_json' &&
@EXECUTABLE@ -ini @EXECUTABLE@.ctd
-mandatory_mandatoryinput
${' '.join(["'mandatory_mandatoryinput/%s/%s.%s'"%(i, re.sub('[^\w\-_]', '_', f.element_identifier), $gxy2omsext("tsv")) for i, f in enumerate($inp_mandatory_mandatoryinput) if f])}
#if "optional_mandatoryinput_FLAG" in str($OPTIONAL_OUTPUTS).split(',')
  -optional_mandatoryinput
  ${' '.join(["'optional_mandatoryinput/%s/%s.%s'"%(i, re.sub('[^\w\-_]', '_', f.element_identifier), $gxy2omsext("tsv")) for i, f in enumerate($inp_optional_mandatoryinput) if f])}
#end if
-inp_mandatory_mandatoryinput
${' '.join(["'inp_mandatory_mandatoryinput/%s/%s.%s'"%(i, re.sub('[^\w\-_]', '_', f.element_identifier), $gxy2omsext(f.ext)) for i, f in enumerate($inp_mandatory_mandatoryinput) if f])}
-inp_optional_mandatoryinput
${' '.join(["'inp_optional_mandatoryinput/%s/%s.%s'"%(i, re.sub('[^\w\-_]', '_', f.element_identifier), $gxy2omsext(f.ext)) for i, f in enumerate($inp_optional_mandatoryinput) if f])}
#if len(str($OPTIONAL_OUTPUTS).split(',')) == 0
  | tee '$stdout'
#end if

## Postprocessing
${' '.join(["&& mv -n 'mandatory_mandatoryinput/%(bn)s/%(id)s.%(gext)s' 'mandatory_mandatoryinput/%(bn)s/%(id)s'"%{"bn": i, "id": re.sub('[^\w\-_]', '_', f.element_identifier), "gext": $gxy2omsext("tsv")} for i, f in enumerate($inp_mandatory_mandatoryinput) if f])}
#if "optional_mandatoryinput_FLAG" in str($OPTIONAL_OUTPUTS).split(',')
  ${' '.join(["&& mv -n 'optional_mandatoryinput/%(bn)s/%(id)s.%(gext)s' 'optional_mandatoryinput/%(bn)s/%(id)s'"%{"bn": i, "id": re.sub('[^\w\-_]', '_', f.element_identifier), "gext": $gxy2omsext("tsv")} for i, f in enumerate($inp_optional_mandatoryinput) if f])}
#end if
#if "ctd_out_FLAG" in $OPTIONAL_OUTPUTS
  && mv '@EXECUTABLE@.ctd' '$ctd_out'
#end if]]></command>
  <configfiles>
    <inputs name="args_json" data_style="paths"/>
    <configfile name="hardcoded_json"><![CDATA[{}]]></configfile>
  </configfiles>
  <inputs>
    <param name="inp_mandatory_mandatoryinput" argument="-inp_mandatory_mandatoryinput" type="data" format="tsv" multiple="true" optional="false" label="input file" help=" select tsv data sets(s)"/>
    <param name="inp_optional_mandatoryinput" argument="-inp_optional_mandatoryinput" type="data" format="tsv" multiple="true" optional="false" label="input file" help=" select tsv data sets(s)"/>
    <expand macro="adv_opts_macro"/>
    <param name="OPTIONAL_OUTPUTS" type="select" optional="true" multiple="true" label="Optional outputs">
      <option value="optional_mandatoryinput_FLAG">optional_mandatoryinput (output file)</option>
      <option value="ctd_out_FLAG">Output used ctd (ini) configuration file</option>
    </param>
  </inputs>
  <outputs>
    <collection type="list" name="mandatory_mandatoryinput" label="${tool.name} on ${on_string}: mandatory_mandatoryinput">
      <discover_datasets directory="mandatory_mandatoryinput" recurse="true" format="tsv" pattern="__name__"/>
    </collection>
    <collection type="list" name="optional_mandatoryinput" label="${tool.name} on ${on_string}: optional_mandatoryinput">
      <discover_datasets directory="optional_mandatoryinput" recurse="true" format="tsv" pattern="__name__"/>
      <filter>OPTIONAL_OUTPUTS is not None and "optional_mandatoryinput_FLAG" in OPTIONAL_OUTPUTS</filter>
    </collection>
    <data name="ctd_out" format="xml" label="${tool.name} on ${on_string}: ctd">
      <filter>OPTIONAL_OUTPUTS is not None and "ctd_out_FLAG" in OPTIONAL_OUTPUTS</filter>
    </data>
  </outputs>
  <tests>
    <test expect_num_outputs="1">
      <param name="inp_mandatory_mandatoryinput" ftype="tsv" value="0test.ext,0test2.ext"/>
      <param name="inp_optional_mandatoryinput" ftype="tsv" value="1test.ext,1test2.ext"/>
      <conditional name="adv_opts_cond">
        <param name="adv_opts_selector" value="advanced"/>
      </conditional>
      <output_collection name="mandatory_mandatoryinput"/>
    </test>
  </tests>
  <help><![CDATA[Multiple Output File parameter tests.


For more information, visit http://www.openms.de/unavailable.html]]></help>
  <expand macro="references"/>
</tool>
