https://github.com/bio-cr/bam-filter
Use simple expressions to filter a BAM/CRAM file
https://github.com/bio-cr/bam-filter
bam bioinformatics crystal genomics htslib
Last synced: about 2 months ago
JSON representation
Use simple expressions to filter a BAM/CRAM file
- Host: GitHub
- URL: https://github.com/bio-cr/bam-filter
- Owner: bio-cr
- License: mit
- Created: 2022-01-19T07:35:21.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-02-10T00:33:11.000Z (over 1 year ago)
- Last Synced: 2025-05-08T19:03:09.155Z (5 months ago)
- Topics: bam, bioinformatics, crystal, genomics, htslib
- Language: C
- Homepage:
- Size: 63.5 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# bam-filter
[](https://github.com/bio-cr/bam-filter/actions/workflows/ci.yml)
[](https://bio-crystal.slack.com/)
[](https://join.slack.com/t/bio-crystal/shared_invite/zt-tas46pww-JSEloonmn3Ma5eD2~VeT_g)[Crystal](https://github.com/crystal-lang/crystal) implementation of [bam-filter](https://github.com/brentp/hts-nim-tools) by Brent Pedersen.
Filter BAM / CRAM / SAM files with a simple expression language.
## Installation
```sh
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](https://github.com/bio-cr/bam-filter/releases).
- 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]
-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](https://attractivechaos.github.io/klib/#Kexpr%3A%20parsing%20mathematical%20expressions).
### 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](https://www.gitpod.io/). 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](https://github.com/bio-cr/hts.cr).