<tool name="MergeSamFiles" id="picard_MergeSamFiles" version="@TOOL_VERSION@.@WRAPPER_VERSION@">
  <description>merges multiple SAM/BAM datasets into one</description>
  <macros>
    <import>picard_macros.xml</import>
    <token name="@WRAPPER_VERSION@">1</token>
  </macros>
  <expand macro="requirements" />
  <command detect_errors="exit_code"><![CDATA[
    @java_options@
    picard
    MergeSamFiles

    #for $element in $inputFile:
      INPUT="${element}"
    #end for

    OUTPUT="${outFile}"
    MERGE_SEQUENCE_DICTIONARIES="${merge_sequence_dictionaries}"

    ASSUME_SORTED="${assume_sorted}"
    #for $element in $comments:
      COMMENT="${element.comment}"
    #end for

    USE_THREADING=true
    SORT_ORDER=coordinate
    VALIDATION_STRINGENCY="${validation_stringency}"
    QUIET=true
    VERBOSITY=ERROR
    @TMPDIR_OPTION@

  ]]></command>
  <inputs>
    <param format="sam,bam" name="inputFile" type="data" multiple="True" label="Select SAM/BAM dataset or dataset collection" help="If empty, upload or import a SAM/BAM dataset"/>
    <param name="merge_sequence_dictionaries" type="boolean" label="Merge the sequence dictionaries of the datasets being merged" help="MERGE_SEQUENCE_DICTIONARIES; default=False"/>
    <param name="assume_sorted" type="boolean" label="Assume the input file is already sorted" help="ASSUME_SORTED; default=False"/>

    <repeat name="comments" title="Comment" min="0" help="You can provide multiple comments">
      <param name="comment" type="text" label="Add this comment to BAM dataset" help="COMMENT"/>
    </repeat>

    <expand macro="VS" />

  </inputs>

  <outputs>
    <data format="bam" name="outFile" label="${tool.name} on ${on_string}: Merged BAM dataset"/>
  </outputs>

  <tests>
    <test>
      <param name="inputFile" value="picard_MergeSamFiles_input1.bam,picard_MergeSamFiles_input2.bam,picard_MergeSamFiles_input3.bam" ftype="bam"/>
      <param name="assume_sorted" value="False"/>
      <param name="merge_sequence_dictionaries" value="False"/>
      <param name="validation_stringency" value="LENIENT"/>
      <output name="outFile" file="picard_MergeSamFiles_test1.bam" ftype="bam" lines_diff="4"/>
    </test>
  </tests>


  <help>

**Purpose**

Merges multiple SAM/BAM datasets into one.

@dataset_collections@

@description@

  ASSUME_SORTED=Boolean
  AS=Boolean                    If true, assume that the input files are in the same sort order as the requested output
                                sort order, even if their headers say otherwise.  Default value: false. This option can
                                be set to 'null' to clear the default value. Possible values: {true, false}

  MERGE_SEQUENCE_DICTIONARIES=Boolean
  MSD=Boolean                   Merge the sequence dictionaries  Default value: false. This option can be set to 'null'
                                to clear the default value. Possible values: {true, false}

  COMMENT=String
  CO=String                     Comment(s) to include in the merged output file's header.  This option may be specified 0
                                or more times.


@more_info@

  </help>
  <expand macro="citations" />
</tool>
