<tool id="syri" name="SyRI" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="23.2">
  <description>Synteny and Rearrangement Identifier</description>
  <macros>
    <import>macros.xml</import>
  </macros>
  <xrefs>
    <xref type="bio.tools">SyRI</xref>
  </xrefs>
  <expand macro="requirements"/>
  <stdio>
    <exit_code range="1:" level="fatal" description="Error"/>
    <regex match="- ERROR -" source="both" level="fatal" description="Error"/>
  </stdio>
  <version_command>syri --version</version_command>
  <command>
<![CDATA[
    syri
## Input files
      #if $alnfile.is_of_type("bam")
        -F B
      #elif $alnfile.is_of_type("sam")
        -F S
      #elif $alnfile.is_of_type("paf")
        -F P
      #end if
## Additional arguments
      #if $additional_options.aln_filter
        '${additional_options.aln_filter}'
      #end if
      #if $additional_options.seed
        --seed '${additional_options.seed}'
      #end if
      #if $additional_options.sample_name
        --samplename '${additional_options.sample_name}'
      #end if
## SR identification
      #if $sr_options.nosr
        '${sr_options.nosr}'
      #end if
      #if $sr_options.invgaplen
        --invgaplen '${sr_options.invgaplen}'
      #end if
      #if $sr_options.tdgaplen
        --tdgaplen '${sr_options.tdgaplen}'
      #end if
      #if $sr_options.tdmaxolp
        --tdmaxolp '${sr_options.tdmaxolp}'
      #end if
      #if $sr_options.bruteruntime
        -b '${sr_options.bruteruntime}'
      #end if
      #if $sr_options.unic
        --unic '${sr_options.unic}'
      #end if
      #if $sr_options.unip
        --unip '${sr_options.unip}'
      #end if
      #if $sr_options.inc
        --inc '${sr_options.inc}'
      #end if
      #if $sr_options.no_chrmatch
        '${sr_options.no_chrmatch}'
      #end if
## ShV identification
      #if $shv_options.nosv
        '${shv_options.nosv}'
      #end if
      #if $shv_options.nosnp
        '${shv_options.nosnp}'
      #end if
      #if $shv_options.all
        '${shv_options.all}'
      #end if
      #if $shv_options.offset
        --allow-offset '${shv_options.offset}'
      #end if
      #if $shv_options.hdrseq
        '${shv_options.hdrseq}'
      #end if
      #if $shv_options.maxsize
        --maxsize '${shv_options.maxsize}'
      #end if
      -c '${alnfile}' -r '${refgenome}' -q '${qrygenome}' -k --prefix galaxy_ --nc \${GALAXY_SLOTS:-2}
]]> </command>
  <inputs>
    <param type="data" label="Alignment file" name="alnfile" optional="false" format="sam,paf,bam"/>
    <param type="data" label="Reference genome" name="refgenome" optional="false" format="fasta"/>
    <param type="data" label="Query genome" name="qrygenome" optional="false" format="fasta"/>
    <section name="additional_options" title="Additional options">
      <param argument="--seed" type="integer" label="Seed for generating random numbers (default: 1)" min="1" max="10000" optional="true"/>
      <param argument="-f" name="aln_filter" type="boolean" label="Disable filtering of low-quality and small alignments" checked="false" truevalue="-f" falsevalue=""/>
      <param argument="--samplename" name="sample_name" type="text" label="Sample name for the output VCF file. (default: sample)">
        <validator type="regex" message="Invalid characters in sample name">^[a-zA-Z0-9\-_]*$</validator>
      </param>
    </section>
    <section name="sr_options" title="SR identification">
      <param argument="--nosr" type="boolean" label="Set to skip structural rearrangement identification (default: False)" checked="false" truevalue="--nosr" falsevalue=""/>
      <param argument="--invgaplen" type="integer" label="Maximum allowed gap-length between two alignments of a multi-alignment inversion. (default: 1,000,000,000)" optional="true"/>
      <param argument="--tdgaplen" type="integer" label="Maximum allowed gap-length between two alignments of a multi-alignment translocation or duplication. (default: 500,000)" optional="true"/>
      <param argument="--tdmaxolp" type="float" min="0" max="1" label="Maximum allowed overlap between two translocations. Value should be in range (0,1]. (default: 0.8)" optional="true"/>
      <param argument="-b" name="bruteruntime" type="integer" min="1" label="Cutoff to restrict brute force methods from running too long (in seconds). (default: 60)" optional="true"/>
      <param argument="--unic" type="integer" min="1" label="Number of unique base pairs for selecting translocations. (default: 1,000)" optional="true"/>
      <param argument="--unip" type="float" min="0" max="100" label="Percent of unique region required to select translocation. (default: 0.5)" optional="true"/>
      <param argument="--inc" type="integer" min="0" label="Minimum score increase required to add another alignment to a translocation cluster solution. (default: 1,000)" optional="true"/>
      <param argument="--no-chrmatch" type="boolean" label="Prevent automatic matching of chromosome IDs between genomes. (default: False)" checked="false" truevalue="--no-chrmatch" falsevalue=""/>
    </section>
    <section name="shv_options" title="ShV identification">
      <param argument="--nosv" type="boolean" label="Set to skip structural variation identification (default: False)" checked="false" truevalue="--nosv" falsevalue=""/>
      <param argument="--nosnp" type="boolean" label="Set to skip SNP/Indel (within alignment) identification (default: False)" checked="false" truevalue="--nosnp" falsevalue=""/>
      <param argument="--all" type="boolean" label="Use duplications too for variant identification (default: False)" checked="false" truevalue="--all" falsevalue=""/>
      <param argument="--allow-offset" name="offset" type="integer" label="Number of base pairs allowed to overlap. (default: 5)" optional="true"/>
      <param argument="--hdrseq" type="boolean" label="Output highly-diverged regions (HDRs) sequences. (default: False)" checked="false" truevalue="--hdrseq" falsevalue="" optional="true"/>
      <param argument="--maxsize" type="integer" label="Maximum size for printing sequences of large structural variants. Larger variants will be printed as symbolic SVs. (default: -1)" optional="true"/>
    </section>
  </inputs>
  <outputs>
    <data name="syri_out" from_work_dir="galaxy_syri.out" format="tabular" label="${tool.name} on ${on_string} : OUT"/>
    <data name="syri_summary" from_work_dir="galaxy_syri.summary" format="tabular" label="${tool.name} on ${on_string} : Summary"> </data>
    <data name="syri_vcf" from_work_dir="galaxy_syri.vcf" format="vcf" label="${tool.name} on ${on_string} : VCF"/>
    <data name="mapids" from_work_dir="galaxy_mapids.txt" format="tabular" label="${tool.name} on ${on_string} : Map IDs"/>
  </outputs>
  <tests>
    <test expect_num_outputs="4">
      <param name="alnfile" value="aln.bam"/>
      <param name="refgenome" value="ref.fa.gz"/>
      <param name="qrygenome" value="qry.fa.gz"/>
      <section name="additional_options">
        <param name="sample_name" value="syri_user_1"/>
      </section>
      <output name="syri_vcf">
        <assert_contents>
          <has_text text="syri_user_1"/>
        </assert_contents>
      </output>
    </test>
    <test expect_num_outputs="4">
      <param name="alnfile" value="aln.paf"/>
      <param name="refgenome" value="ref.fa.gz"/>
      <param name="qrygenome" value="qry.fa.gz"/>
      <output name="mapids">
        <assert_contents>
          <has_text_matching expression="NC_001133.9\tNC_047487.1"/>
        </assert_contents>
      </output>
    </test>
  </tests>
  <expand macro="help"/>
  <expand macro="citations"/>
</tool>
