---
name: "bamflagsplit"
section: "1"
platform: "linux"
package: "biobambam2"
version: "2.0.185+ds-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/bamflagsplit"
---

# bamflagsplit(1)

sort BAM files by coordinate or query name

## NAME

bamflagsplit - sort BAM files by coordinate or query name

## SYNOPSIS

**bamflagsplit** \[options\]

## DESCRIPTION

bamflagsplit reads a name collated BAM, SAM or CRAM file and distributes the contained reads into a set of BAM files. The reads are distributed as follows:

- single

  single end reads are placed in the single file

- unmapped

  (partially) unmapped read pairs (pairs where at least one of the two mates is unmapped) are placed in the unmapped file

- orphan

  orphan reads (pairs where the other mate is missing in the file) are placed in the orphan file

- supplementary

  supplementary mappings (mappings which have the supplementary flag set) are placed in the supplementary file

- split

  split pair reads (pairs such that the two ends map to different reference sequences/chromosomes) are placed in the split file

- samestrand

  read pairs such that both ends map to the same strand are placed in the samestrand file

- improper

  improperly mapped read pairs (read pairs where the mapped as a proper pair flag is not set) are place in the improper file

- proper

  properly mapped pairs are placed in the proper file

The following key=value pairs can be given:

**I=\<\[stdin\]\>:** input filename, standard input if unset.

**level=\<-1\|0\|1\|9\|11\>:** set compression level of the output BAM files. Valid values are

- \-1:

  zlib/gzip default compression level

- 0:

  uncompressed

- 1:

  zlib/gzip level 1 (fast) compression

- 9:

  zlib/gzip level 9 (best) compression

If libmaus has been compiled with support for igzip (see https://software.intel.com/en-us/articles/igzip-a-high-performance-deflate-compressor-with-optimizations-for-genomic-data) then an additional valid value is

- 11:

  igzip compression

**verbose=\<1\>:** Valid values are

- 1:

  print progress report on standard error

- 0:

  do not print progress report

**disablevalidation=\<0\|1\>:** sets whether input validation is performed. Valid values are

- 0:

  validation is enabled (default)

- 1:

  validation is disabled

**single=\<filename\>:** file name for the single file

**singlemd5=\<0\|1\>:** md5 checksum creation for single output file. Valid values are

- 0:

  do not compute checksum. This is the default.

- 1:

  compute checksum. If the splitmd5filename key is set, then the checksum is written to the given file. If splitmd5filename, then no checksum will be computed.

**unmapped=\<filename\>:** file name for the unmapped file

**unmappedmd5=\<0\|1\>:** md5 checksum creation for unmapped output file. Valid values are

- 0:

  do not compute checksum. This is the default.

- 1:

  compute checksum. If the splitmd5filename key is set, then the checksum is written to the given file. If splitmd5filename, then no checksum will be computed.

**orphan=\<filename\>:** file name for the orphan file

**orphanmd5=\<0\|1\>:** md5 checksum creation for orphan output file. Valid values are

- 0:

  do not compute checksum. This is the default.

- 1:

  compute checksum. If the splitmd5filename key is set, then the checksum is written to the given file. If splitmd5filename, then no checksum will be computed.

**supplementary=\<filename\>:** file name for the supplementary file

**supplementarymd5=\<0\|1\>:** md5 checksum creation for supplementary output file. Valid values are

- 0:

  do not compute checksum. This is the default.

- 1:

  compute checksum. If the splitmd5filename key is set, then the checksum is written to the given file. If splitmd5filename, then no checksum will be computed.

**split=\<filename\>:** file name for the split file

**splitmd5=\<0\|1\>:** md5 checksum creation for split output file. Valid values are

- 0:

  do not compute checksum. This is the default.

- 1:

  compute checksum. If the splitmd5filename key is set, then the checksum is written to the given file. If splitmd5filename, then no checksum will be computed.

**samestrand=\<filename\>:** file name for the samestrand file

**samestrandmd5=\<0\|1\>:** md5 checksum creation for samestrand output file. Valid values are

- 0:

  do not compute checksum. This is the default.

- 1:

  compute checksum. If the samestrandmd5filename key is set, then the checksum is written to the given file. If samestrandmd5filename, then no checksum will be computed.

**improper=\<filename\>:** file name for the improper file

**impropermd5=\<0\|1\>:** md5 checksum creation for improper output file. Valid values are

- 0:

  do not compute checksum. This is the default.

- 1:

  compute checksum. If the impropermd5filename key is set, then the checksum is written to the given file. If impropermd5filename, then no checksum will be computed.

**proper=\<filename\>:** file name for the proper file

**propermd5=\<0\|1\>:** md5 checksum creation for proper output file. Valid values are

- 0:

  do not compute checksum. This is the default.

- 1:

  compute checksum. If the propermd5filename key is set, then the checksum is written to the given file. If propermd5filename, then no checksum will be computed.

**inputformat=\<bam\>: input file format.** All versions of bamflagsplit come with support for the BAM input format. If the program in addition is linked to the io\_lib package, then the following options are valid:

- bam:

  BAM (see http://samtools.sourceforge.net/SAM1.pdf)

- sam:

  SAM (see http://samtools.sourceforge.net/SAM1.pdf)

- cram:

  CRAM (see http://www.ebi.ac.uk/ena/about/cram\_toolkit)

## AUTHOR

Written by German Tischler.

## REPORTING BUGS

Report bugs to \<germant@miltenyibiotec.de\>

## COPYRIGHT

Copyright © 2009-2014 German Tischler, © 2011-2014 Genome Research Limited. License GPLv3+: GNU GPL version 3 \<http://gnu.org/licenses/gpl.html\>\
 This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
