Skip to content

Commit

Permalink
deal with the exception of having to use just one read for the consensus
Browse files Browse the repository at this point in the history
  • Loading branch information
wdecoster committed Aug 5, 2024
1 parent 4ba8c05 commit bab6a3a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ pub fn consensus(
score: -1,
}
} else {
if consensus_reads == 1 {
// if only on read should be used to generate the consensus, the consensus is a randomly selected read
let seq = seqs.choose(&mut rand::thread_rng()).unwrap();
return Consensus {
seq: Some(seq.to_string()),
support: num_reads,
std_dev,
score: 0,
}
}
// if there are more than <consensus_reads> reads, downsample before taking the consensus
// for performance and memory reasons
let seqs_bytes = if num_reads > consensus_reads {
Expand Down

0 comments on commit bab6a3a

Please sign in to comment.