name: samtools_sort
namespace: samtools
description: Sort SAM/BAM/CRAM file.
keywords: [sort, bam, sam, cram]
links:
  homepage: https://www.htslib.org/
  documentation: https://www.htslib.org/doc/samtools-sort.html
  repository: https://github.com/samtools/samtools
references: 
  doi: [10.1093/bioinformatics/btp352, 10.1093/gigascience/giab008]
license: MIT/Expat
authors:
  - __merge__: /src/_authors/emma_rousseau.yaml
    roles: [ author, maintainer ]
argument_groups:
  - name: Inputs
    arguments:
      - name: --input
        type: file
        description: SAM/BAM/CRAM input file.
        required: true
        must_exist: true
  - name: Outputs
    arguments:
      - name: --output
        type: file
        description: |
          Write final output to file.
        required: true
        direction: output
        example: out.bam
      - name: --output_fmt
        alternatives: -O
        type: string
        description: |
          Specify output format (SAM, BAM, CRAM).
        example: BAM
      - name: --output_fmt_option
        type: string
        description: |
          Specify a single output file format option in the form
          of OPTION or OPTION=VALUE.
      - name: --reference
        type: file
        description: |
          Reference sequence FASTA FILE.
        example: ref.fa
      - name: --write_index
        type: boolean_true
        description: |
          Automatically index the output files.
      - name: --prefix
        alternatives: -T
        type: string
        description: |
          Write temporary files to PREFIX.nnnn.bam.
      - name: --no_PG
        type: boolean_true
        description: |
          Do not add a PG line.
      - name: --template_coordinate
        type: boolean_true
        description: |
          Sort by template-coordinate.
      - name: --input_fmt_option
        type: string
        description: |
          Specify a single input file format option in the form
          of OPTION or OPTION=VALUE.
  - name: Options
    arguments:
      - name: --compression
        alternatives: -l
        type: integer
        description: |
          Set compression level, from 0 (uncompressed) to 9 (best).
        default: 0
      - name: --uncompressed
        alternatives: -u
        type: boolean_true
        description: |
          Output uncompressed data (equivalent to --compression 0).
      - name: --minimiser
        alternatives: -M
        type: boolean_true
        description: |
          Use minimiser for clustering unaligned/unplaced reads.
      - name: --not_reverse
        alternatives: -R
        type: boolean_true
        description: |
          Do not use reverse strand (only compatible with --minimiser)
      - name: --kmer_size
        alternatives: -K
        type: integer
        description: |
          Kmer size to use for minimiser.
        example: 20
      - name: --order
        alternatives: -I
        type: file
        description: |
          Order minimisers by their position in FILE FASTA.
        example: ref.fa
      - name: --window
        alternatives: -w
        type: integer
        description: |
          Window size for minimiser INDEXING VIA --order REF.FA.
        example: 100
      - name: --homopolymers
        alternatives: -H
        type: boolean_true
        description: |
          Squash homopolymers when computing minimiser.
      - name: --natural_sort
        alternatives: -n
        type: boolean_true
        description: |
          Sort by read name (natural): cannot be used with samtools index.
      - name: --ascii_sort
        alternatives: -N
        type: boolean_true
        description: |
          Sort by read name (ASCII): cannot be used with samtools index.
      - name: --tag
        alternatives: -t
        type: string
        description: |
          Sort by value of TAG. Uses position as secondary index 
          (or read name if --natural_sort is set).

resources:
  - type: bash_script
    path: script.sh
test_resources:
  - type: bash_script
    path: test.sh
  - type: file
    path: test_data
engines:
  - type: docker
    image: quay.io/biocontainers/samtools:1.19.2--h50ea8bc_1
    setup:
      - type: docker
        run: |
          samtools --version 2>&1 | grep -E '^(samtools|Using htslib)' | \
          sed 's#Using ##;s# \([0-9\.]*\)$#: \1#' > /var/software_versions.txt
runners:
- type: executable
- type: nextflow