Skip to content

Commit

Permalink
critical section
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-p committed Aug 5, 2020
1 parent aff914f commit c297394
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions libradicl/src/collate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ pub fn collate(
total_to_collate += record.1;
}

// sort this so that we deal with largest cells (by # of reads) first
// sort in _descending_ order by count.
quickersort::sort_by_key(&mut tsv_map[..], |&a : &(u64, u64)| std::cmp::Reverse(a.1) );
//println!("{:?}", tsv_map);

// get the correction map
let cmfile = std::fs::File::open(parent.join("permit_map.bin")).unwrap();
let correct_map: HashMap<u64, u64> = bincode::deserialize_from(&cmfile).unwrap();
Expand Down
4 changes: 3 additions & 1 deletion libradicl/src/pugutils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@ pub(super) fn get_num_molecules_cell_ranger_like(
// count for this UMI
unresolvable = true;
}
Ordering::Less => {}
Ordering::Less => {
// we do nothing
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions libradicl/src/quant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,23 +481,25 @@ pub fn quantify(
// update the matrix
for (i, v) in counts.into_iter().enumerate() {
if v > 0.0 {
omat.add_triplet(i, cell_num, v);
omat.add_triplet(i, 0, v);
}
}

{
let bc_mer: BitKmer = (bc, bclen as u8);

// writing the files
let omat_csr = &omat.to_csr();
let writer = &mut *bcout.lock().unwrap();
sce::eds::append_writer(&mut writer.1, &omat.to_csr())
sce::eds::append_writer(&mut writer.1, &omat_csr)
.expect("can't write matrix");

// write to barcode file
writeln!(&mut writer.0, "{}\t{}", cell_num, unsafe {
std::str::from_utf8_unchecked(&bitmer_to_bytes(bc_mer)[..])
})
.expect("can't write to barcode file.");

}

cells_remaining.fetch_sub(1, Ordering::SeqCst);
Expand Down

0 comments on commit c297394

Please sign in to comment.