Scroll to navigation

BAMMERGE(1) General Commands Manual BAMMERGE(1)


bammerge - merge BAM files


bammerge [options]


bammerge reads a set of input BAM files, merges the contained headers and alignment data and writes the output on standard output in BAM format. The input files can be specified via the I key. Any none key=value arguments given after the key=value pairs will also be considered as input files. The input files need to be sorted by coordinate or query name. The set of reference sequences in the files does not need to be identical. For merging coordinate sorted files however the order of the reference sequences in the headers needs to be consistent among the files, i.e. if reference sequence A appears before reference sequence B in any input file, then this needs to hold for all other files as well. If the order is not consistent then bammerge cannot be used for merging. In this case the merging can be done by concatenating the files using bamcat and running bamsort afterwards.

The following key=value pairs can be given:

I=<stdin>: name of the input file. This key can be used multiple times

SO=<coordinate>: Sort order. By default the sort order is coordinate.

input files are sorted by coordinate. The created output file will be sorted by coordinate as well.
input files are sorted by query name. The created output file will be sorted by query name as well.

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

zlib/gzip default compression level
zlib/gzip level 1 (fast) compression
zlib/gzip level 9 (best) compression

If libmaus has been compiled with support for igzip (see then an additional valid value is

igzip compression

verbose=<1>: Valid values are

print progress report on standard error
do not print progress report

tmpfile=<filename>: prefix for temporary files. By default the temporary files are created in the current directory

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

do not compute checksum. This is the default.
compute checksum. If the md5filename key is set, then the checksum is written to the given file. If md5filename is unset, then no checksum will be computed.

md5filename file name for md5 checksum if md5=1.

index=<0|1>: compute BAM index for output file. Valid values are

do not compute BAM index. This is the default.
compute BAM index. If the indexfilename key is set, then the BAM index is written to the given file. If indexfilename is unset, then no BAM index will be computed.

indexfilename file name for BAM index if index=1.

IL name of file containing input file names. The given text file contains a list of input file names, one file per line.


Written by German Tischler.


Report bugs to <>


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

October 2013 BIOBAMBAM