-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from COMBINE-lab/dev
Dev
- Loading branch information
Showing
9 changed files
with
268 additions
and
36 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "oarfish" | ||
version = "0.2.0" | ||
version = "0.3.0" | ||
edition = "2021" | ||
authors = [ | ||
"Zahra Zare Jousheghani <[email protected]>", | ||
|
@@ -30,7 +30,7 @@ categories = ["command-line-utilities", "science"] | |
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
anyhow = "1.0.79" | ||
anyhow = "1.0.80" | ||
bio-types = "1.0.1" | ||
clap = { version = "4.5.1", features = ["derive"] } | ||
coitrees = "0.4.0" | ||
|
@@ -42,15 +42,17 @@ tabled = "0.15.0" | |
tracing = "0.1.40" | ||
tracing-subscriber = {version="0.3.18", features=["env-filter"]} | ||
typed-builder = "0.18.1" | ||
rayon = "1.8" | ||
rayon = "1.9" | ||
statrs = "0.16" | ||
csv = "1.3" | ||
ndarray = "0.15" | ||
serde = { version = "1", features = ["derive"] } | ||
itertools = "0.12.1" | ||
serde_json = "1.0.113" | ||
serde_json = "1.0.114" | ||
path-tools = "0.1.0" | ||
atomic_float = "0.1.0" | ||
rand = "0.8.5" | ||
arrow2 = { version = "0.18.0", features = ["io_parquet", "io_parquet_gzip", "io_parquet_zstd", "io_parquet_snappy"] } | ||
|
||
[[bin]] | ||
name = "oarfish" | ||
|
@@ -69,7 +71,7 @@ lto = "thin" | |
# Config for 'cargo dist' | ||
[workspace.metadata.dist] | ||
# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax) | ||
cargo-dist-version = "0.10.0" | ||
cargo-dist-version = "0.11.1" | ||
# CI backends to support | ||
ci = ["github"] | ||
# The installers to generate for each app | ||
|
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,55 @@ | ||
use rand::distributions::{Distribution, Uniform}; | ||
use rand::Rng; | ||
|
||
/// Wraps an iterator `I` to produce a new iterator that samples the original | ||
/// with replacement. | ||
pub struct SampleWithReplaceIter<'b, I: ExactSizeIterator> { | ||
pub inds: &'b [usize], | ||
pub iter: I, | ||
pub idx: usize, | ||
pub e_ptr: usize, | ||
pub prev: Option<I::Item>, | ||
} | ||
|
||
impl<'b, I: ExactSizeIterator> Iterator for SampleWithReplaceIter<'b, I> | ||
where | ||
I::Item: Copy, | ||
{ | ||
type Item = I::Item; | ||
|
||
#[inline] | ||
fn next(&mut self) -> Option<Self::Item> { | ||
if let Some(next_ind) = self.inds.get(self.idx) { | ||
// always makes sure we have a previous | ||
// element. This will get the first | ||
// element but wont yet increment | ||
// the pointer (e_ptr) | ||
if self.prev.is_none() { | ||
self.prev = self.iter.next(); | ||
} | ||
// next element is not a duplicate | ||
if self.e_ptr != *next_ind { | ||
// otherwise, call next until we have the | ||
// correct element | ||
loop { | ||
self.prev = self.iter.next(); | ||
self.e_ptr += 1; | ||
if self.e_ptr == *next_ind { | ||
break; | ||
} | ||
} | ||
} | ||
self.idx += 1; | ||
self.prev | ||
} else { | ||
None | ||
} | ||
} | ||
} | ||
|
||
pub fn get_sample_inds<R: Rng + ?Sized>(n: usize, rng: &mut R) -> Vec<usize> { | ||
let dist = Uniform::new(0, n); | ||
let mut inds: Vec<usize> = dist.sample_iter(rng).take(n).collect(); | ||
inds.sort_unstable(); | ||
inds | ||
} |
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.