Skip to content

Commit

Permalink
remove dependency on yanked quickersort
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Patro committed May 9, 2022
1 parent 912ca01 commit 3b7dd1a
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 17 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ num_cpus = "1.13.1"
bio-types = "0.12.1"
itertools = "0.10.3"
thiserror = "1.0.30"
quickersort = "3.0.1"
statrs = "0.15.0"
rust-htslib = { git = "https://github.com/rust-bio/rust-htslib", version = "0.38.2", default-features = false, features = [
"bzip2",
Expand Down
1 change: 0 additions & 1 deletion libradicl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ csv = "1.1.6"
dashmap = "^5.1.0"
crossbeam-channel = "0.5.4"
bio-types = "0.12.1"
quickersort = "3.0.1"
needletail = "0.4.1"
flate2 = "1.0.22"
smallvec = "1.8.0"
Expand Down
4 changes: 2 additions & 2 deletions libradicl/src/rad_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ impl ReadRecord {
}

// make sure these are sorted in this step.
quickersort::sort(&mut rec.refs[..]);
rec.refs.sort_unstable();
rec
}

Expand Down Expand Up @@ -332,7 +332,7 @@ impl ReadRecord {
}

// make sure these are sorted in this step.
quickersort::sort(&mut rec.refs[..]);
rec.refs.sort_unstable();
rec
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/collate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub fn collate(

// 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));
tsv_map.sort_unstable_by_key(|&a: &(u64, u64)| std::cmp::Reverse(a.1));

/*
let est_num_rounds = (total_to_collate as f64 / max_records as f64).ceil() as u64;
Expand Down
4 changes: 2 additions & 2 deletions src/eq_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ impl EqMap {
})
.collect();

quickersort::sort(&mut hash_vec[..]);
hash_vec.sort_unstable();

let mut prev_hash = 0u64;
let mut prev_umi = u64::MAX;
Expand Down Expand Up @@ -408,7 +408,7 @@ impl EqMap {

let v = &mut self.eqc_info[idx];
// sort so dups are adjacent
quickersort::sort(&mut v.umis[..]);
v.umis.sort_unstable();
// we need a copy of the vector b/c we
// can't easily modify it in place
// at least I haven't seen how (@k3yavi, help here if you can).
Expand Down
18 changes: 9 additions & 9 deletions src/pugutils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ fn resolve_num_molecules_crlike_from_vec_prefer_ambig(
// first on umi
// then on gene_id
// then on count
quickersort::sort(umi_gene_count_vec);
umi_gene_count_vec.sort_unstable();

// hold the current umi and gene we are examining
let mut curr_umi = umi_gene_count_vec.first().expect("cell with no UMIs").0;
Expand Down Expand Up @@ -524,7 +524,7 @@ fn resolve_num_molecules_crlike_from_vec(
// first on umi
// then on gene_id
// then on count
quickersort::sort(umi_gene_count_vec);
umi_gene_count_vec.sort_unstable();

// hold the current umi and gene we are examining
let mut curr_umi = umi_gene_count_vec.first().expect("cell with no UMIs").0;
Expand Down Expand Up @@ -640,7 +640,7 @@ pub fn get_num_molecules_cell_ranger_like_small(
.map(|tid| tid_to_gid[*tid as usize])
.collect();
// and make the gene ids unique
quickersort::sort(&mut gset[..]);
gset.sort_unstable();
gset.dedup();
for g in &gset {
umi_gene_count_vec.push((umi, *g, 1));
Expand Down Expand Up @@ -693,7 +693,7 @@ pub fn get_num_molecules_cell_ranger_like(
// necessarily be adjacent here, since
// they are always asigned adjacent ids
// with spliced being even and unspliced odd.
quickersort::sort(&mut gset[..]);
gset.sort_unstable();
gset.dedup();

// add every (umi, count), gene pair as a triplet
Expand Down Expand Up @@ -772,7 +772,7 @@ pub fn get_num_molecules_trivial_discard_all_ambig(
// equivalence classes that still map to the same
// gene.
for (k, v) in gene_map.iter_mut() {
quickersort::sort(&mut v[..]);
v.sort_unstable();
v.dedup();
// the count is the number of distinct UMIs.
counts[*k as usize] += v.len() as f32;
Expand Down Expand Up @@ -827,7 +827,7 @@ fn get_num_molecules_large_component(
.map(|tid| tid_to_gid[*tid as usize])
.collect();
// and make the gene ids unique
quickersort::sort(&mut gset[..]);
gset.sort_unstable();
gset.dedup();

// add every (umi, count), gene pair as a triplet
Expand All @@ -843,7 +843,7 @@ fn get_num_molecules_large_component(
// first on umi
// then on gene_id
// then on count
quickersort::sort(&mut umi_gene_count_vec[..]);
umi_gene_count_vec.sort_unstable();

// hold the current umi and gene we are examining
let mut curr_umi = umi_gene_count_vec.first().expect("cell with no UMIs").0;
Expand Down Expand Up @@ -1110,7 +1110,7 @@ pub fn get_num_molecules(
.map(|i| tid_to_gid[i as usize])
.collect();
// sort since we will be hashing the ordered vector
quickersort::sort(&mut global_genes[..]);
global_genes.sort_unstable();
// dedup as well since we don't care about duplicates
global_genes.dedup();

Expand Down Expand Up @@ -1154,7 +1154,7 @@ pub fn get_num_molecules(
}

let mut global_genes: Vec<u32> = tl.iter().map(|i| tid_to_gid[*i as usize]).collect();
quickersort::sort(&mut global_genes[..]);
global_genes.sort_unstable();
global_genes.dedup();

// extract gene-level eqclass and increment count by 1
Expand Down
1 change: 0 additions & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,6 @@ pub fn extract_usa_eqmap(
// however, because we know the original eqc labels
// and the USA mode labels are 1-1, we don't need this
// so avoid the sort here.
// quickersort::sort(tvec);
idx_eq_list.add_label_vec(tvec.as_slice());
eq_id_count.push((ctr as u32, *count));
}
Expand Down

0 comments on commit 3b7dd1a

Please sign in to comment.