-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Criterion-based benchmarks of granged adjust vs bedtools slop
- Added criterion benchmarks against bedtools - New enum pattern for loading BED3 vs BED+ - clippy/fmt issues resolved
- Loading branch information
Showing
14 changed files
with
170 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
//! Benchmarks comparisons against bedtools. | ||
//! | ||
//! For comparison accuracy, any benchmarks conducted here must also have | ||
//! corresponding integration tests in `tests/bedtools_validation.rs`, to | ||
//! ensure the output is the *exact* same. | ||
|
||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use granges::{commands::granges_random_bed, test_utilities::granges_binary_path}; | ||
use std::process::Command; | ||
use tempfile::NamedTempFile; | ||
|
||
/// Create a random BED3 file based on the hg38 sequence lengths, and write to disk. | ||
pub fn random_bedfile() -> NamedTempFile { | ||
let temp_file = NamedTempFile::new().expect("Failed to create temp file"); | ||
let random_bedfile_path = temp_file.path().to_path_buf(); | ||
granges_random_bed( | ||
"tests_data/hg38_seqlens.tsv", | ||
100_000, | ||
Some(&random_bedfile_path), | ||
true, | ||
) | ||
.expect("could not generate random BED file"); | ||
temp_file | ||
} | ||
|
||
fn bench_range_adjustment(c: &mut Criterion) { | ||
// create the benchmark group | ||
let mut group = c.benchmark_group("slop vs adjust"); | ||
|
||
// create the test data | ||
let input_bedfile = random_bedfile(); | ||
|
||
// configure the sample size for the group | ||
// group.sample_size(10); | ||
|
||
// bedtools slop | ||
group.bench_function("bedtools_slop", |b| { | ||
b.iter(|| { | ||
let bedtools_output = Command::new("bedtools") | ||
.arg("slop") | ||
.arg("-g") | ||
.arg("tests_data/hg38_seqlens.tsv") | ||
.arg("-b") | ||
.arg("10") | ||
.arg("-i") | ||
.arg(input_bedfile.path()) | ||
.output() | ||
.expect("bedtools slop failed"); | ||
assert!(bedtools_output.status.success()); | ||
}); | ||
}); | ||
|
||
group.bench_function("granges_adjust", |b| { | ||
b.iter(|| { | ||
let granges_output = Command::new(granges_binary_path()) | ||
.arg("adjust") | ||
.arg("--seqlens") | ||
.arg("tests_data/hg38_seqlens.tsv") | ||
.arg("--both") | ||
.arg("10") | ||
.arg("--sort") | ||
.arg(input_bedfile.path()) | ||
.output() | ||
.expect("granges adjust failed"); | ||
assert!(granges_output.status.success()); | ||
}); | ||
}); | ||
} | ||
criterion_group!(benches, bench_range_adjustment); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#![allow(clippy::all)] | ||
|
||
use std::rc::Rc; | ||
|
||
use crate::Position; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.