Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
217 changes: 198 additions & 19 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ path = "src/lib/mod.rs"
name = "perbase"
path = "src/main.rs"

[features]
seqair-pileup = ["dep:seqair", "dep:seqair-types"]

[dependencies]
anyhow = "1.0.41"
bio = "3.0.0"
Expand All @@ -39,6 +42,8 @@ lru_time_cache = "0.11.1"
num_cpus = "1.13.0"
rayon = "1.4.0"
rust-htslib = {version = "0.51", default-features = false, features = ["libdeflate"]}
seqair = { version = "0.1.0", optional = true }
seqair-types = { version = "0.1.0", optional = true }
rust-lapper = "1.0"
serde = { version = "1.0.116", features = ["derive"] }
smartstring = { version = "1.0.1", features = ["serde"] }
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@ If the `--mate-fix` flag is passed, each position will first check if there are

If the `--reference-fasta` is supplied, the `REF_BASE` field will be filled in. The reference must be indexed and match the BAM/CRAM header of the input.

#### Experimental seqair pileup backend

`base-depth` can optionally be built with an experimental seqair-backed pileup engine:

```bash
cargo build --release --features seqair-pileup
perbase base-depth --seqair-pileup ./test/test.bam
```

The htslib-backed path remains the default. The seqair path currently requires `--ref-fasta` for CRAM input.

The output can be compressed and indexed as follows:

```bash
Expand Down Expand Up @@ -173,6 +184,9 @@ FLAGS:

**NOTE** If this is set it could result in duplicate output entries for regions that overlap. **NOTE** This
may cause issues with downstream tooling.
--seqair-pileup
Use the experimental seqair-backed pileup engine

-V, --version
Prints version information

Expand Down
12 changes: 6 additions & 6 deletions examples/par_granges_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use anyhow::Result;
use perbase_lib::{
par_granges::{self, RegionProcessor},
position::pileup_position::PileupPosition,
read_filter::ReadFilter,
read_filter::{ReadFilter, ReadView},
};
use rust_htslib::bam::{self, Read, pileup::Alignment, record::Record};
use rust_htslib::bam::{self, Read};
use std::path::PathBuf;

// To use ParGranges you will need to implement a [`RegionProcessor`](par_granges::RegionProcessor),
Expand All @@ -32,11 +32,11 @@ struct BasicReadFilter {
impl ReadFilter for BasicReadFilter {
// Filter reads based SAM flags and mapping quality, true means pass
#[inline]
fn filter_read(&self, read: &Record, _alignment: Option<&Alignment>) -> bool {
fn filter_read<R: ReadView + ?Sized>(&self, read: &R) -> bool {
let flags = read.flags();
(!flags) & &self.include_flags == 0
&& flags & &self.exclude_flags == 0
&& &read.mapq() >= &self.min_mapq
(!flags) & self.include_flags == 0
&& flags & self.exclude_flags == 0
&& read.mapq() >= self.min_mapq
}
}

Expand Down
Loading
Loading