-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New csv + serde parsing, with cleaner type inference; new `TsvRecordI…
…terator`. - Rename of `map_over_joins()` to `map_joins()`. - New IO benchmark of our (old) `Bed5Iterator` vs csv + serde. - Reorganized `io::parsers` into different modules. - `deserialize_bed_missing()` and `deserialize_option_generic()` for missing value to `None`. - All new `Bed3Iterator`, `Bed5Iterator`, and `BedlikeIterator` - New `TsvRecordIterator` built on csv + serde.
- Loading branch information
Showing
18 changed files
with
576 additions
and
553 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
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,66 @@ | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use csv::{self, ReaderBuilder}; | ||
use granges::io::parsers::Bed5Addition; | ||
use granges::ranges::GenomicRangeRecord; | ||
use granges::test_utilities::random_bed5file; | ||
use granges::{prelude::*, Position}; | ||
|
||
#[derive(Debug, serde::Deserialize, PartialEq)] | ||
struct Bed5Row { | ||
seqname: String, | ||
start: Position, | ||
end: Position, | ||
name: String, | ||
score: f64, | ||
} | ||
|
||
const BED_LENGTH: usize = 1_000_000; | ||
|
||
fn bench_io_shootout(c: &mut Criterion) { | ||
// create the benchmark group | ||
let mut group = c.benchmark_group("adjust"); | ||
|
||
// create the test data | ||
let input_bedfile = random_bed5file(BED_LENGTH); | ||
|
||
let genome = read_seqlens("tests_data/hg38_seqlens.tsv").unwrap(); | ||
|
||
// configure the sample size for the group | ||
group.sample_size(10); | ||
|
||
// Bed5Iterator | ||
group.bench_function("bed5iterator", |b| { | ||
b.iter(|| { | ||
let iter = Bed5Iterator::new(input_bedfile.path()).unwrap(); | ||
let gr = GRanges::from_iter(iter, &genome).unwrap(); | ||
gr.len() | ||
}); | ||
}); | ||
|
||
// CSV | ||
group.bench_function("csv", |b| { | ||
b.iter(|| { | ||
let mut rdr = ReaderBuilder::new() | ||
.delimiter(b'\t') | ||
.has_headers(false) | ||
.from_path(input_bedfile.path()) | ||
.unwrap(); | ||
|
||
let iter = rdr.deserialize(); | ||
let mut gr: GRanges<VecRangesIndexed, Vec<Bed5Addition>> = GRanges::new_vec(&genome); | ||
|
||
for result in iter { | ||
let row: GenomicRangeRecord<Bed5Addition> = result.unwrap(); | ||
let data = Bed5Addition { | ||
name: row.data.name, | ||
score: row.data.score, | ||
}; | ||
gr.push_range(&row.seqname, row.start, row.end, data) | ||
.unwrap(); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
criterion_group!(benches, bench_io_shootout,); | ||
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
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.