bamUtil is a repository that contains several programs that perform operations on SAM/BAM files. All of these programs are built into a single executable,
Where to Find It
The bamUtil repository is available both via release downloads and via github.
On github, https://github.com/statgen/bamUtil, you can both browse and download the bamUtil source code as well as explore the history of changes.
You can obtain the source either with or without git.
The releases may be available both with and without libStatGen included.
If you do not use the release version that already contains libStatGen, you need to download the library: libStatGen.
If you try to compile bamUtil and it cannot find libStatGen, it will fail and provide instructions of what to do next:
- if libStatGen is in a different location then expected
- follow the directions to set the path to libStatGen
- if libStatGen is not downloaded and you have git
make libStatGenwill download via git and build libStatGen
- if libStatGen is not downloaded and you don't have git
- See libStatGen
Using Git To Track the Current Development Version
Clone (get your own copy)
You can create your own git clone (copy) using:
git clone https://github.com/statgen/bamUtil.git
git clone git://github.com/statgen/bamUtil.git
Either of these commands create a directory called
bamUtil in the current directory.
cd bamUtil and compile.
Get the latest Updates (update your copy)
To update your copy to the latest version (a major advantage of using git):
Downloading From GitHub Without Git
If you download the latest code/version, make sure you periodically update it by downloading a newer version.
From github you can download:
- Latest Code (master branch)
- via Website
- Goto: https://github.com/statgen/bamUtil
- Click on the
Download ZIPbutton on the right side panel.
- via Command Line
- via Website
- Specific Release (via a tag)
After downloading the file, uncompress (unzip/untar) it. The directory created will be named
bamUtil-<name of version you downloaded>.
After obtaining the bamUtil repository (either by download or from github), compile the code using:
Object (.o) files are compiled into the
obj directory with a subdirectory
profile for the debugging and profiling objects.
This creates the executable(s) in the
bamUtil/bin/ directory, the debug executable(s) in the
bamUtil/bin/debug/ directory, and the profiling executable(s) in the
make install installs the opt binary if you have permission.
make test compiles for opt, debug, and profile and runs the tests (found in the
To see all make options, type
If compilation fails due to warnings being treated as errors, please contact us so we can fix the warnings. As a work-around to get it to compile, you can disable the treatment of warnings as errors by editing libStatGen/general/Makefile to remove
The software reads the beginning of an input file to determine if it is SAM/BAM. To determine the format (SAM/BAM) of the output file, the software checks the output file's extension. If the extension is ".bam" it writes a BAM file, otherwise it writes a SAM file.
The bam executable has the following functions.
- Rewrite SAM/BAM Files
- convert - Read a SAM/BAM file and write as a SAM/BAM file (optionally converts between '=' & bases in the sequence)
- splitChromosome - Split BAM by Chromosome
- writeRegion - Write the alignments in the indexed BAM file that fall into the specified region and/or have the specified read name
- findCigars - Output just the reads that contain any of the specified CIGAR operations
- readIndexedBam - Read an indexed BAM file reference by reference id -1 to the max reference id and write it out as a SAM/BAM file
- Modify & write SAM/BAM Files
- filter - Filter reads by clipping ends with too high of a mismatch percentage and by marking reads unmapped if the quality of mismatches is too high
- revert - Revert SAM/BAM replacing the specified fields with their previous values (if known) and removes specified tags
- squeeze - reduces files size by dropping OQ fields, duplicates, specified tags, using '=' when a base matches the reference, binning quality scores, and replacing readNames with unique integers
- Informational Tools
- Print Information in Readable Form:
This executable is built using C++ Library: libStatGen.
Just running ./bam will print the Usage information for the bam executable.