Skip to content

bio-cr/bam-filter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bam-filter

.github/workflows/ci.yml Slack Get invite to BioCrystal

Crystal implementation of bam-filter by Brent Pedersen.

Filter BAM / CRAM / SAM files with a simple expression language.

Installation

git clone https://github.com/bio-cr/bam-filter
make
sudo make install
  • Ubuntu 20.04 and 22.04: deb packages are available from the Github release page.
    • Please note that installing the bam-filter deb package may uninstall packages that depend on libcurl4-openssl-dev, since libhts-dev depends on libcurl4-gnutls-dev.
  • Currently only Linux is supported. Pull requests are welcome.

Usage

Usage: bam-filter [options] <bam_file>
    -e, --expression EXPR            eval code
    -o, --output PATH                Write output to FILE [standard output]
    -f, --fasta FASTA                Reference sequence FASTA FILE [null]
    -S, --sam                        Output SAM
    -b, --bam                        Output BAM
    -C, --cram                       Output CRAM (requires -f)
    -t, --threads NUM                Number of threads to use [0]
    --no-PG                          Do not add @PG line to the header
    -h, --help                       Show this help
    -v, --version                    Show version number

Example

bam-filter -S -e "chr=='chr1' && pos > 200 && tag_AS > 35" test/moo.bam

The given expression is evaluated by klib/kexpr.

Available values in expression

Fields: name flag chr pos start stop mapq mchr mpos isize

Flags: paired proper_pair unmapped mate_unmapped reverse mate_reverse read1 read2 secondary qcfail duplicate supplementary

Tags: tag_XX (XX is aux tag)

Development

The easiest way to start development is to use Gitpod. All you need is a browser.

Contributing

Bug fixes and macOS support are welcome.

Note

bam-filter was originally created to develop and test HTS.cr.