<!--
  ~ Copyright (C) 2009-2012 Institute for Computational Biomedicine,
  ~                    Weill Medical College of Cornell University
  ~
  ~  This program is free software; you can redistribute it and/or modify
  ~  it under the terms of the GNU General Public License as published by
  ~  the Free Software Foundation; either version 3 of the License, or
  ~  (at your option) any later version.
  ~
  ~  This program is distributed in the hope that it will be useful,
  ~  but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  ~  GNU General Public License for more details.
  ~
  ~  You should have received a copy of the GNU General Public License
  ~  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  -->

<jsap>
    <parameters>
        <flaggedOption>
            <id>output</id>
            <shortFlag>o</shortFlag>
            <longFlag>output</longFlag>
            <required>true</required>
            <help>The basename where to write the sorted alignment.</help>
        </flaggedOption>
        <unflaggedOption>
            <id>input</id>
            <required>true</required>
            <help>The compact alignment file to read as input.</help>
        </unflaggedOption>
        <switch>
           <id>dry-run</id>
            <longFlag>dry-run</longFlag>
            <help>Do not execute the sort, but print the split/merge plan for inspection.</help>
        </switch>
        <flaggedOption>
            <id>num-threads</id>
            <shortFlag>t</shortFlag>
            <longFlag>num-threads</longFlag>
            <required>false</required>
            <stringParser>
                <classname>IntegerStringParser</classname>
            </stringParser>
            <defaults>
                <string>0</string>
            </defaults>
            <help>The number of threads to run with. When -1, use as many threads as available on the machine.
                Specify a value of 0 or 1 to run single-threaded (zero disables thread-pool, 1 runs with a thread
                pool with one thread).
            </help>
        </flaggedOption>
        <flaggedOption>
            <id>files-per-merge</id>
            <shortFlag>n</shortFlag>
            <longFlag>files-per-merge</longFlag>
            <required>false</required>
            <stringParser>
                <classname>IntegerStringParser</classname>
            </stringParser>
            <defaults>
                <string>30</string>
            </defaults>
            <help>The number of splits / files per merge. The maximum value you can use for this is related to the
                number of file descriptors available from your OS. sort-large mode will open approximately ((4 *
                num-threads * files-per-merge) + 4) during the merge process.
            </help>
        </flaggedOption>
        <flaggedOption>
            <id>split-size</id>
            <shortFlag>s</shortFlag>
            <longFlag>split-size</longFlag>
            <required>false</required>
            <stringParser>
                <classname>LongStringParser</classname>
            </stringParser>
            <defaults>
                <string>-1</string>
            </defaults>
            <help>The size of the split in bytes. The default, -1, attempts to guess the split size based on available
                memory including overhead. Keep in mind that threads you run with, the less available memory to each
                parallel sort.
            </help>
        </flaggedOption>
        <flaggedOption>
            <id>temp-dir</id>
            <shortFlag>d</shortFlag>
            <longFlag>temp-dir</longFlag>
            <required>false</required>
            <stringParser>
                <classname>StringStringParser</classname>
            </stringParser>
            <defaults>
                <string>/tmp</string>
            </defaults>
            <help>The temporary directory where temporary files will be written during the sort/merge process.</help>
        </flaggedOption>
        <flaggedOption>
            <id>memory-percentage-for-work</id>
            <shortFlag>w</shortFlag>
            <longFlag>memory-percentage-for-work</longFlag>
            <required>false</required>
            <stringParser>
                <classname>DoubleStringParser</classname>
            </stringParser>
            <defaults>
                <string>0.75</string>
            </defaults>
            <help>The percentage of available memory available to worker threads
                (to increase overall memory available to Java using -Xmx and -Xms, such as "-Xmx8g -Xms8g" to run
                the program with a total of 8g of memory). Also see split-size-scaling-factor
                documentation. This parameter cannot be value larger than "0.99" or
                less than "0.5".
            </help>
        </flaggedOption>
        <flaggedOption>
            <id>thread-memory-scaling-factor</id>
            <shortFlag>f</shortFlag>
            <longFlag>thread-memory-scaling-factor</longFlag>
            <required>false</required>
            <stringParser>
                <classname>IntegerStringParser</classname>
            </stringParser>
            <defaults>
                <string>50</string>
            </defaults>
            <help>The larger the value of split-size-scaling-factor the more splits will be made because this
                value controls the COMPRESSED size of a single split, based on the equation
                ((TOTAL_AVAILABLE_MEMORY * memory-percentage-for-work) / (num-threads * split-size-scaling-factor))
                This means the larger the split-size-scaling-factor, the smaller the the split-size will be
                per thread. If, during sort-large-mode, you are running out of memory, INCREASE the value for
                split-size-scaling-factor. Also, if you are running out of memory, it is advisable to increase the
                overall memory available to Java using -Xmx and -Xms, such as "-Xmx8g -Xms8g" to run
                the program with a total of 8g of memory. The relatively large value for this (the default is 50)
                is required because the alignments will be decompressed after being read. In setting this value,
                consider which codec the data are compressed with. Codecs that compress less require lower values,
                while codec that compress more (hybrid-1) require larger values because the same amount of disk bytes
                yield more data in memory.
            </help>
        </flaggedOption>
    </parameters>
</jsap>
