Skip to content

Commit

Permalink
fix: Handle empty sequences for bam-anonymize (#241)
Browse files Browse the repository at this point in the history
* Handle empty sequences

* befriend linter
  • Loading branch information
FelixMoelder committed Jun 14, 2022
1 parent 4231371 commit 039ed92
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/bam/anonymize_reads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub fn anonymize_reads<P: AsRef<Path> + std::fmt::Debug>(
{
record.cache_cigar();
//Check if mate record end within region
let artificial_seq = if record.is_unmapped() {
let artificial_seq = if record.is_unmapped() || record.seq_len() == 0 {
let mut seq = Vec::new();
add_random_bases(record.seq_len() as u64, &mut seq, &mut rng, &alphabet)?;
seq
Expand Down Expand Up @@ -172,7 +172,7 @@ fn set_mandatory_fields(
target_rec.set_pos(source_rec.pos() - offset);
target_rec.set_tid(0);
let (mtid, mpos) = if source_rec.mtid() == -1 {
(-1, 0)
(-1, -1)
} else if source_rec.mtid() == source_rec.tid() {
(0, source_rec.mpos() - offset)
} else {
Expand Down

0 comments on commit 039ed92

Please sign in to comment.