<tool id="pairtools_split" name="Pairtools split" version="@TOOL_VERSION@+galaxy@SUFFIX_VERSION@" profile="@PROFILE_VERSION@" license="MIT">
    <description>Split a pairsam file into pairs and SAM/BAM</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="requirements"/>
    <command detect_errors="exit_code"><![CDATA[
        #if $pairsam_path.is_of_type('4dn_pairsam.gz'):
            #set $input_link = "input.gz"
            #set $output_pairs_link = "output_pairs.gz"
        #else
            #set $input_link = "input"
            #set $output_pairs_link = "output_pairs"
        #end if
        ln -s '$pairsam_path' '$input_link' &&
        ln -s '$output_pairs' '$output_pairs_link' &&
        pairtools split
            '$input_link'
            --output-pairs '$output_pairs_link'
            --output-sam ./output.bam
            --nproc-in \${GALAXY_SLOTS:-4}
            --nproc-out \${GALAXY_SLOTS:-4}
    ]]></command>
    <inputs>
        <param name="pairsam_path" type="data" format="4dn_pairsam,4dn_pairsam.gz" label="Input 4dn pairsam file"/>
    </inputs>
    <outputs>
        <data name="output_pairs" label="${tool.name} on ${on_string}: Output Pairs"  auto_format="true" />
        <data name="output_file" format="qname_sorted.bam" from_work_dir="output.bam" label="${tool.name} on ${on_string}: Output BAM" />
    </outputs>
    <tests>
        <!--Test default parameters-->
        <test expect_num_outputs="2">
            <param name="pairsam_path" value="output_dedup_pairs_markdups.pairsam"/>
            <output name="output_pairs" file="output_pairs_split.pairs" ftype="4dn_pairs" lines_diff="10"/>
            <output name="output_file" ftype="qname_sorted.bam" file="output_pairs_split.bam" lines_diff="20"/>
        </test>
        <!--Test default parameters and compressed input and output-->
        <test expect_num_outputs="2">
            <param name="pairsam_path" value="output_dedup_pairs_markdups.pairsam.gz"/>
            <output name="output_pairs" file="output_pairs_split.pairs" ftype="4dn_pairs.gz" decompress="true" lines_diff="10"/>
            <output name="output_file" ftype="qname_sorted.bam" file="output_pairs_split.bam" lines_diff="20"/>
        </test>
    </tests>
    <help><![CDATA[
        **Pairtools split**

        Restore a SAM/BAM file from SAM1 and SAM2 fields of a `pairsam` file. Create a `pairs` file without SAM1/SAM2 fields.
              
    ]]></help>
    <expand macro="citations"/>
    <expand macro="creator"/>
</tool>
