Skip to content

Commit

Permalink
feat: add logging message with coverage of input before downsampling
Browse files Browse the repository at this point in the history
  • Loading branch information
mbhall88 committed Jan 3, 2024
1 parent 62c5faa commit 79445fc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,13 @@ impl From<GenomeSize> for u64 {
}
}

// add method to convert to f64
impl From<GenomeSize> for f64 {
fn from(g: GenomeSize) -> Self {
g.0 as f64
}
}

impl FromStr for GenomeSize {
type Err = CliError;

Expand Down
7 changes: 7 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ fn main() -> Result<()> {
}
info!("{} reads detected", read_lengths.len());

// calculate the depth of coverage if using coverage-based subsampling
if args.genome_size.is_some() {
let number_of_bases: u64 = read_lengths.iter().map(|&x| x as u64).sum();
let depth_of_covg = (number_of_bases as f64) / f64::from(args.genome_size.unwrap());
info!("Input coverage is {:.2}x", depth_of_covg);
}

let num_reads = match (args.num, args.frac) {
(Some(n), None) => Some(u64::from(n)),
(None, Some(f)) => {
Expand Down

0 comments on commit 79445fc

Please sign in to comment.