Skip to content

Commit 0086c3c

Browse files
committed
feat: log seed used when --seed not passed
1 parent 1fd13d4 commit 0086c3c

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

README.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -404,12 +404,11 @@ of the reads.
404404

405405
##### `-s`, `--seed`
406406

407-
This option allows you to specify the [random seed][seed] used by the random subsampler.
408-
By explicitly setting this parameter, you make the subsample for the input reproducible.
409-
The seed is an integer, and by default it is not set, meaning the operating system will
410-
seed the random subsampler. You should only pass this parameter if you are likely to
411-
want to subsample the same input file again in the future and want the same subset of
412-
reads.
407+
This option allows you to specify the [random seed][seed] used by the random subsampler. By explicitly setting this
408+
parameter, you make the subsample for the input reproducible. You only need to pass this parameter if you are likely
409+
to want to subsample the same input file again in the future and want the same subset of reads. However, if you forget
410+
to use this option, the seed generated by the system will be printed to the log output, allowing you to use it in the
411+
future.
413412

414413
#### Verbosity
415414

src/alignment.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ impl Runner for Alignment {
5555

5656
let mut rng = match self.seed {
5757
Some(s) => rand_pcg::Pcg64::seed_from_u64(s),
58-
None => rand_pcg::Pcg64::seed_from_u64(random()),
58+
None => {
59+
let seed = random();
60+
info!("Using seed: {}", seed);
61+
rand_pcg::Pcg64::seed_from_u64(seed)
62+
}
5963
};
6064

6165
let mut reader =

src/subsampler.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use log::info;
12
use rand::prelude::*;
23

34
/// A `Struct` for dealing with the randomised part of sub-sampling.
@@ -39,9 +40,14 @@ impl SubSampler {
3940
/// ```
4041
fn shuffled_indices<T>(&self, v: &[T]) -> Vec<u32> {
4142
let mut indices: Vec<u32> = (0..v.len() as u32).collect();
43+
4244
let mut rng = match self.seed {
4345
Some(s) => rand_pcg::Pcg64::seed_from_u64(s),
44-
None => rand_pcg::Pcg64::seed_from_u64(random()),
46+
None => {
47+
let seed = random();
48+
info!("Using seed: {}", seed);
49+
rand_pcg::Pcg64::seed_from_u64(seed)
50+
}
4551
};
4652

4753
indices.shuffle(&mut rng);

0 commit comments

Comments
 (0)