bam-filter
Version, currently 0.1.120 versions
- 0.3.0latestJun 21, 2026
- 0.2.1not indexedJun 23, 2026
- 0.2.0not indexedJun 23, 2026
- 0.1.7not indexedJun 23, 2026
- 0.1.6not indexedJun 23, 2026
- 0.1.5not indexedJun 23, 2026
- 0.1.4not indexedJun 23, 2026
- 0.1.3not indexedJun 23, 2026
- 0.1.2not indexedJun 23, 2026
- 0.1.1not indexedJun 23, 2026
- 0.1.0not indexedJun 23, 2026
- 0.0.9not indexedJun 23, 2026
- 0.0.8not indexedJun 23, 2026
- 0.0.7not indexedJun 23, 2026
- 0.0.6not indexedJun 23, 2026
- 0.0.5not indexedJun 23, 2026
- 0.0.4not indexedJun 23, 2026
- 0.0.3not indexedJun 23, 2026
- 0.0.2not indexedJun 23, 2026
- 0.0.1not indexedJun 23, 2026
github.com/bio-cr/bam-filter
Use simple expressions to filter a BAM/CRAM file
6 stars
0 dependents
License: MIT
Nothing has been indexed for 0.1.1 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
bam-filter:
github: bio-cr/bam-filter
version: ~> 0.1.1Then run:
shards installshard.yml
No shard.yml has been indexed for 0.1.1. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
# bam-filter
[](https://github.com/bio-cr/bam-filter/actions/workflows/ci.yml)
[](https://github.com/bio-cr/bam-filter/actions/workflows/build.yml)
[](https://tokei.kojix2.net/github/bio-cr/bam-filter)
[](https://doi.org/10.5281/zenodo.6462575)
Filter BAM, CRAM, and SAM records with Ruby expressions.
`bam-filter` is a Crystal command-line tool inspired by Brent Pedersen's Nim-based
[bam-filter](https://github.com/brentp/hts-nim-tools). Expressions are evaluated
with embedded [mruby](https://github.com/mruby/mruby) via
[Anyolite](https://github.com/Anyolite/anyolite).
## Installation
Download the binary from the [GitHub Release](https://github.com/bio-cr/bam-filter/releases).
From source:
```sh
git clone https://github.com/bio-cr/bam-filter
cd bam-filter
make
sudo make install
```
## Usage
```text
Usage: bam-filter [options] <bam_file>
-e, --expression EXPR eval code
-r, --require PATH Load Ruby script file before evaluating expression
-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
```
## Examples
Write SAM records on chromosome 1 after position 200 with an `AS` tag greater than
35:
```sh
bam-filter -S -e 'chr == "chr1" && pos > 200 && tag_AS && tag_AS > 35' input.bam
```
Write BAM output:
```sh
bam-filter -e 'mapq >= 30 && !duplicate' -o filtered.bam input.bam
```
Write CRAM output:
```sh
bam-filter -C -f reference.fa -e 'proper_pair && !unmapped' -o filtered.cram input.bam
```
Load Ruby helper scripts before expression evaluation:
```sh
bam-filter -r helpers.rb -r filters.rb -e 'keep_record(mapq, tag_AS)' -o filtered.bam input.bam
```
## Expressions
Expressions use Ruby syntax. A record is kept unless the final expression value is
`false`, `nil`, numeric `0`, or numeric `0.0`.
Available fields:
```text
name flag chr pos start stop mapq mchr mpos isize
```
Available flag booleans:
```text
paired proper_pair unmapped mate_unmapped reverse mate_reverse
read1 read2 secondary qcfail duplicate supplementary
```
Auxiliary tags are available as `tag_XX`, where `XX` is a two-character SAM tag.
Integer, float, string, character, and numeric `B` array tags can be used from
Ruby expressions. Missing tags evaluate to `nil`, so guard comparisons
explicitly:
```sh
bam-filter -e 'tag_AS && tag_AS > 35' input.bam
```
Array tags are exposed as Ruby arrays:
```sh
bam-filter -e 'tag_XB && tag_XB[0] == 1 && tag_XB.include?(3)' input.bam
```
## Development
```sh
make
make test
```
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.1- Tagged
- Jun 23, 2026
- Commit
cb9b0861a406- Indexed
- not yet
Dependents
No indexed shard depends on this one yet.
Repository
github.com/bio-cr/bam-filter
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 13, 2026
- Synced
- Aug 13, 2026
- Versions
- 20