Skip to content

Commit

Permalink
Condition on going through the file once
Browse files Browse the repository at this point in the history
  • Loading branch information
apollis44 committed Apr 17, 2024
1 parent 2d32a16 commit 728b286
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/ska_dict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,19 @@ where
let mut reader =
parse_fastx_file(filename).unwrap_or_else(|_| panic!("Invalid path/file: {filename}"));

let mut nb_reads_total = 0;
while let Some(_record) = reader.next() {
nb_reads_total += 1;
}
let mut step: f64 = 1.0;

let mut nb_reads = nb_reads_total;
if proportion_reads.is_some() {
let mut nb_reads_total = 0;
while let Some(_record) = reader.next() {
nb_reads_total += 1;
}

let mut nb_reads = nb_reads_total;
nb_reads = (nb_reads as f64 * proportion_reads.unwrap()) as usize;
}

let step = nb_reads_total as f64 / nb_reads as f64;
step = nb_reads_total as f64 / nb_reads as f64;
}

let mut reader =
parse_fastx_file(filename).unwrap_or_else(|_| panic!("Invalid path/file: {filename}"));
Expand All @@ -128,6 +130,8 @@ where
if (iter_reads as f64 % step) as usize != 0 {
iter_reads += 1;
continue;
} else {
iter_reads += 1;
}

let seqrec = record.expect("Invalid FASTA/Q record");
Expand Down Expand Up @@ -166,7 +170,6 @@ where
}
}
}
iter_reads += 1;
}
}

Expand Down

0 comments on commit 728b286

Please sign in to comment.