bamsort

View as Markdown

Sort BAM files.

This tool can sort the reads within a BAM file in a variety of ways, including by position in the genome (coordinate) or read name (queryname). This enables compatibility with the requirements of different downstream tools.

Five sort modes are supported:

  • coordinate (Picard-compatible)
  • coordinate (fgbio-compatible)
  • queryname (Picard-compatible)
  • queryname (fgbio-compatible)
  • template coordinate sort (fgbio-compatible)

Allowed values for —sort-order are as follows:

  • coordinate [default]
  • queryname
  • templatecoordinate

Allowed values for —sort-compatibility are as follows:

  • picard [default]
  • fgbio

coordinate and queryname sorting can be done in either picard or fgbio mode. templatecoordinate can only be done in fgbio mode.

Refer to the bamsort Reference section for a detailed listing of all available options.

Quick Start

1# This command assumes all the inputs are in the current working directory and all the outputs go to the same place.
2docker run --rm --gpus all --volume $(pwd):/workdir --volume $(pwd):/outputdir \
3 --workdir /workdir \
4 nvcr.io/nvidia/clara/clara-parabricks:4.7.1-1 \
5 pbrun bamsort \
6 --ref /workdir/${REFERENCE_FILE} \
7 --in-bam /workdir/${INPUT_BAM} \
8 --out-bam /outputdir/${OUTPUT_BAM} \
9 --sort-order coordinate

Compatible Picard Command

The command below is the Picard counterpart of the Parabricks command above. The output from this command will be identical to the output from the above command.

1$ java -Xmx30g -jar picard.jar SortSam \
2 I=<INPUT_DIR>/${INPUT_BAM} \
3 O=<OUTPUT_DIR>/${OUTPUT_BAM}

Options

TypeNameRequired?Description
I/O--in-bam IN_BAMYesPath of BAM/CRAM for sorting. This option is required.
I/O--out-bam OUT_BAMYesPath of BAM/CRAM file after sorting.
I/O--ref REFYesPath to the reference file.
Tool--sort-order SORT_ORDERNoType of sort to be done. Possible values are {coordinate,queryname,templatecoordinate}. (default: coordinate)
Tool--sort-compatibility SORT_COMPATIBILITYNoSort comparator compatibility to be used for compatibility with other tools. Possible values are {picard,fgbio}. TemplateCoordinate will only use fgbio. (default: picard)
Performance--num-zip-threads NUM_ZIP_THREADSNoNumber of CPUs to use for zipping BAM files in a run (default 16 for coordinate sorts and 10 otherwise).
Performance--num-sort-threads NUM_SORT_THREADSNoNumber of CPUs to use for sorting in a run (default 10 for coordinate sorts and 16 otherwise).
Performance--max-records-in-ram MAX_RECORDS_IN_RAMNoMaximum number of records in RAM when using a queryname or template coordinate sort mode; lowering this number will decrease maximum memory usage. (default: 65000000)
Performance--mem-limit MEM_LIMITNoMemory limit in GBs during sorting and postsorting. By default, the limit is half of the total system memory. (default: 62)
Performance--gpuwriteNoUse one GPU to accelerate writing final BAM/CRAM.
Performance--gpuwrite-deflate-algo GPUWRITE_DEFLATE_ALGONoChoose the nvCOMP DEFLATE algorithm to use with --gpuwrite. Note these options do not correspond to CPU DEFLATE options. Valid options are 1, 2, and 4. Option 1 is fastest, while options 2 and 4 have progressively lower throughput but higher compression ratios. The default value is 1 when the user does not provide an input (i.e., None)
Performance--gpusortNoUse GPUs to accelerate sorting and marking.
Runtime--verboseNoEnable verbose output.
Runtime--x3NoShow full command line arguments.
Runtime--logfile LOGFILENoPath to the log file. If not specified, messages will only be written to the standard error output.
Runtime--tmp-dir TMP_DIRNoFull path to the directory where temporary files will be stored. (default: .)
Runtime--with-petagene-dir WITH_PETAGENE_DIRNoFull path to the PetaGene installation directory. By default, this should have been installed at /opt/petagene. Use of this option also requires that the PetaLink library has been preloaded by setting the LD_PRELOAD environment variable. Optionally set the PETASUITE_REFPATH and PGCLOUD_CREDPATH environment variables that are used for data and credentials. Optionally set the PetaLinkMode environment variable that is used to further configure PetaLink, notably setting it to "+write" to enable outputting compressed BAM and .fastq files.
Runtime--keep-tmpNoDo not delete the directory storing temporary files after completion.
Runtime--no-seccomp-overrideNoDo not override seccomp options for docker.
Runtime--versionNoView compatible software versions.
Runtime--preserve-file-symlinksNoOverride default behavior to keep file symlinks intact and *not* resolve the symlink.