#def quote(s):
#set $s = [ _ for _ in $s.split(" ") if _ != "" ]
#set $q = False
#for $i, $p in enumerate($s):
#if $p == "":
#continue
#end if
#if $p.startswith('"'):
#set $q = True
#end if
## #if p.startswith('-'):
## #set p = "\\" + p
## #elif p.startswith('"-'):
## #set p = "\\" + p[1:]
## #end if
#if not $q:
#set $s[i] = '"%s"' % p
#end if
#if $p.endswith('"'):
#set $q = False
#end if
#end for
#return " ".join($s)
#end def
#def oms2gxyext(o)
#set m={'txt': 'txt', 'tsv': 'tabular', 'bioml': 'xml', 'consensusXML': 'consensusxml', 'csv': 'csv', 'dta': 'dta', 'dta2d': 'dta2d', 'edta': 'edta', 'fa': 'fasta', 'fas': 'fasta', 'fasta': 'fasta', 'FASTA': 'fasta', 'featureXML': 'featurexml', 'featurexml': 'featurexml', 'html': 'html', 'HTML': 'html', 'idXML': 'idxml', 'json': 'json', 'kroenik': 'kroenik', 'mascotXML': 'mascotxml', 'mgf': 'mgf', 'mrm': 'mrm', 'ms': 'sirius.ms', 'ms2': 'ms2', 'msp': 'msp', 'mzData': 'mzdata', 'mzid': 'mzid', 'mzML': 'mzml', 'mzml': 'mzml', 'mzq': 'mzq', 'mzQC': 'mzqc', 'mzTab': 'mztab', 'mzXML': 'mzxml', 'novor': 'txt', 'obo': 'obo', 'oms': 'sqlite', 'omssaXML': 'idxml', 'osw': 'osw', 'OSW': 'osw', 'params': 'txt', 'paramXML': 'paramxml', 'peplist': 'peplist', 'pep.xml': 'pepxml', 'pepXML': 'pepxml', 'png': 'png', 'PNG': 'png', 'protXML': 'protxml', 'psms': 'psms', 'pqp': 'pqp', 'qcML': 'qcml', 'spec.xml': 'spec.xml', 'splib': 'splib', 'sqMass': 'sqmass', 'tandem.xml': 'tandem', 'trafoXML': 'trafoxml', 'traML': 'traml', 'TraML': 'traml', 'tab': 'tabular', 'raw': 'thermo.raw', 'xls': 'tsv', 'XML': 'xml', 'xml': 'xml', 'xquest.xml': 'xquest.xml', 'xsd': 'xsd', 'zip': 'zip'}
#return m[o]
#end def
#def gxy2omsext(g)
#set m={'txt': 'txt', 'tabular': 'tsv', 'xml': 'bioml', 'consensusxml': 'consensusXML', 'csv': 'csv', 'dta': 'dta', 'dta2d': 'dta2d', 'edta': 'edta', 'fasta': 'fa', 'featurexml': 'featureXML', 'html': 'html', 'idxml': 'idXML', 'json': 'json', 'kroenik': 'kroenik', 'mascotxml': 'mascotXML', 'mgf': 'mgf', 'mrm': 'mrm', 'sirius.ms': 'ms', 'ms2': 'ms2', 'msp': 'msp', 'mzdata': 'mzData', 'mzid': 'mzid', 'mzml': 'mzML', 'mzq': 'mzq', 'mzqc': 'mzQC', 'mztab': 'mzTab', 'mzxml': 'mzXML', 'obo': 'obo', 'sqlite': 'oms', 'osw': 'osw', 'paramxml': 'paramXML', 'peff': 'fasta', 'peplist': 'peplist', 'pepxml': 'pep.xml', 'png': 'png', 'protxml': 'protXML', 'psms': 'psms', 'pqp': 'pqp', 'qcml': 'qcML', 'spec.xml': 'spec.xml', 'splib': 'splib', 'sqmass': 'sqMass', 'tandem': 'tandem.xml', 'trafoxml': 'trafoXML', 'traml': 'traML', 'thermo.raw': 'raw', 'tsv': 'xls', 'xquest.xml': 'xquest.xml', 'xsd': 'xsd', 'zip': 'zip'}
#return m[g]
#end def
#import re
## Preprocessing
mkdir in &&
cp '$in' 'in/${re.sub("[^\w\-_]", "_", $in.element_identifier)}.$gxy2omsext($in.ext)' &&
mkdir pair_in &&
cp '$pair_in' 'pair_in/${re.sub("[^\w\-_]", "_", $pair_in.element_identifier)}.$gxy2omsext($pair_in.ext)' &&
mkdir out &&
#if "feature_out_FLAG" in str($OPTIONAL_OUTPUTS).split(',')
mkdir feature_out &&
#end if
## Main program call
set -o pipefail &&
ERPairFinder -write_ctd ./ &&
python3 '$__tool_directory__/fill_ctd.py' 'ERPairFinder.ctd' '$args_json' '$hardcoded_json' &&
ERPairFinder -ini ERPairFinder.ctd
-in
'in/${re.sub("[^\w\-_]", "_", $in.element_identifier)}.$gxy2omsext($in.ext)'
-pair_in
'pair_in/${re.sub("[^\w\-_]", "_", $pair_in.element_identifier)}.$gxy2omsext($pair_in.ext)'
-out
'out/output.${gxy2omsext("consensusxml")}'
#if "feature_out_FLAG" in str($OPTIONAL_OUTPUTS).split(',')
-feature_out
'feature_out/output.${gxy2omsext("featurexml")}'
#end if
#if len(str($OPTIONAL_OUTPUTS).split(',')) == 0
| tee '$stdout'
#end if
## Postprocessing
&& mv 'out/output.${gxy2omsext("consensusxml")}' '$out'
#if "feature_out_FLAG" in str($OPTIONAL_OUTPUTS).split(',')
&& mv 'feature_out/output.${gxy2omsext("featurexml")}' '$feature_out'
#end if
#if "ctd_out_FLAG" in $OPTIONAL_OUTPUTS
&& mv 'ERPairFinder.ctd' '$ctd_out'
#end if