Scroll to navigation

BAM12AUXMERGE(1) General Commands Manual BAM12AUXMERGE(1)


bam12auxmerge - merge two BAM files


bam12auxmerge [options] <input.bam>


bam12auxmerge merges the contents of two BAM files containing the same set of reads together and writes the resulting data as a BAM file. It reads one of the BAM files from standard input, the other one is given via its file name.

It is assumed that the file (A) given by file name was obtained by processing another BAM file by the sequence

bamcollate2 collate=1 | bamcollate2 collate=2

where the first run of bamcollate2 makes sure that the ends of pairs appear adjacently and the second run attaches rank pairs to the read names.

The other file (B) read by bam12auxmerge via standard input is assumed be a (re)aligned version of file (A), which is processed by

bamsort SO=queryname

right before being passed to bam12auxmerge.

This preprocessing ensures that bam12auxmerge observes the reads in the same order, with the possibility of file (B) containing multiple lines for each read (i.e. secondary alignments).

bam12auxmerge merge the SAM headers of (A) and (B) by starting with the header for (B) and prepending the PG type lines from (A), thus restoring the full history of the file to (B). Alignments are merged by inserting the auxiliary tags from lines in (A) into the corresponding lines in (B). Priority is given here to (B), i.e. if a tag appears in both than the version in (B) will be retained.

The following key=value pairs can be given:

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 (default)
do not print progress report

mod=<1048576>: Print progress report after processing each mod'th alignment if verbose is active.

ranksplit=<1>: Split rank pairs into single ranks per read/alignment. This acts like preprocessing the file with bam12split before handing it to bam12auxmerge.

rankstrip=<1>: Strip ranks from reads/alignments. This acts like postprocessing the file with bam12strip after handing it to bam12auxmerge.

clipreinsert=<1>: Reinsert clipped sequence and quality string parts while marking them as soft clipped. This acts like postprocessing the file with bamclipreinsert after handing it to bam12auxmerge.

zztoname=<1>: Insert rank stored in zz auxiliary field to name as a prefix and remove the zz auxiliary field. This acts like postprocessing the file with bamzztoname after handing it to bam12auxmerge.

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 md5filenameis 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.


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.