Skip to content

Commit

Permalink
make clippy fully happy
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Patro committed Sep 1, 2020
1 parent 3f0d268 commit 5e58cb6
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 22 deletions.
5 changes: 2 additions & 3 deletions libradicl/src/collate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,13 @@ fn get_orientation(mdata: &serde_json::Value, log: &slog::Logger) -> Strand {
.chars()
.next()
.unwrap();
let expected_ori = match Strand::from_char(&ori_str) {
match Strand::from_char(&ori_str) {
Ok(s) => s,
Err(e) => {
crit!(log, "invalid metadata {}.", e);
std::process::exit(1);
}
};
expected_ori
}
}

pub fn collate_in_memory_multipass(
Expand Down
12 changes: 7 additions & 5 deletions libradicl/src/pugutils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,11 @@ pub(super) fn get_num_molecules_trivial_discard_all_ambig(
) -> (Vec<f32>, f64) {
let mut counts = vec![0.0f32; num_genes];
let s = RandomState::<Hash64>::new();
let mut gene_map = HashMap::with_hasher(s);
let mut gene_map: std::collections::HashMap<
u32,
Vec<u64>,
fasthash::RandomState<fasthash::sea::Hash64>,
> = HashMap::with_hasher(s);

let mut total_umis = 0u64;
let mut multi_gene_umis = 0u64;
Expand Down Expand Up @@ -334,7 +338,7 @@ pub(super) fn get_num_molecules_trivial_discard_all_ambig(
if !multi_gene {
gene_map
.entry(prev_gene_id)
.or_insert_with(|| Vec::new())
.or_default()
.extend(umis.iter().map(|x| x.0));
}
}
Expand Down Expand Up @@ -362,7 +366,7 @@ fn get_num_molecules_large_component(
vertex_ids: &[u32],
tid_to_gid: &[u32],
num_genes: usize,
log: &slog::Logger,
_log: &slog::Logger,
) -> Vec<u32> {
let mut counts = vec![0u32; num_genes];

Expand Down Expand Up @@ -551,7 +555,6 @@ pub(super) fn get_num_molecules(
// the transcripts to their corresponding gene ids.
//let mut global_txps : Vec<u32>;
let mut global_txps = get_set(16);
let mut alternative_resoluton = false;
let mut pug_stats = PUGResolutionStatistics {
used_alternative_strategy: false,
total_mccs: 0u64,
Expand Down Expand Up @@ -590,7 +593,6 @@ pub(super) fn get_num_molecules(
ng
);
pug_stats.used_alternative_strategy = true;
alternative_resoluton = true;
continue;
}

Expand Down
29 changes: 15 additions & 14 deletions libradicl/src/quant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use flate2::Compression;

use self::libradicl::em::{em_optimize, run_bootstrap};
use self::libradicl::pugutils;
use self::libradicl::schema::{EqMap, PUGEdgeType, PUGResolutionStatistics, ResolutionStrategy};
use self::libradicl::schema::{EqMap, PUGEdgeType, ResolutionStrategy};
use self::libradicl::utils::*;

/// Extracts the parsimonious UMI graphs (PUGs) from the
Expand Down Expand Up @@ -278,29 +278,29 @@ impl BootstrapHelper {
fs::File::create(bootstrap_var_path).unwrap(),
Compression::default(),
);
return BootstrapHelper {
BootstrapHelper {
bsfile: None,
mean_var_files: Some((
BufWriter::new(bt_mean_buffered),
BufWriter::new(bt_var_buffered),
)),
};
}
} else {
let bootstrap_path = output_path.join("bootstraps.eds.gz");
let bt_buffered = GzEncoder::new(
fs::File::create(bootstrap_path).unwrap(),
Compression::default(),
);
return BootstrapHelper {
BootstrapHelper {
bsfile: Some(BufWriter::new(bt_buffered)),
mean_var_files: None,
};
}
}
} else {
return BootstrapHelper {
BootstrapHelper {
bsfile: None,
mean_var_files: None,
};
}
}
}
}
Expand All @@ -314,6 +314,9 @@ struct QuantOutputInfo {
bootstrap_helper: BootstrapHelper, //sample_or_mean_and_var: (BufWriter<GzEncoder<fs::File>>)
}

// TODO: see if we'd rather pass an structure
// with these options
#[allow(clippy::too_many_arguments)]
pub fn quantify(
input_dir: String,
tg_map: String,
Expand Down Expand Up @@ -497,7 +500,7 @@ pub fn quantify(
barcode_file: BufWriter::new(bc_file),
eds_file: BufWriter::new(buffered),
feature_file: BufWriter::new(ff_file),
trimat: trimat,
trimat,
row_index: 0usize,
bootstrap_helper: boot_helper,
}));
Expand Down Expand Up @@ -802,12 +805,10 @@ pub fn quantify(
varf.write_all(&eds_var_bytes)
.expect("can't write to bootstrap var file.");
}
} else {
if let Some(bsfile) = &mut writer.bootstrap_helper.bsfile {
bsfile
.write_all(&bt_eds_bytes)
.expect("can't write to bootstrap file");
}
} else if let Some(bsfile) = &mut writer.bootstrap_helper.bsfile {
bsfile
.write_all(&bt_eds_bytes)
.expect("can't write to bootstrap file");
}
} // done bootstrap writing
}
Expand Down
15 changes: 15 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use libradicl::schema::ResolutionStrategy;
use mimalloc::MiMalloc;
use rand::Rng;
use slog::{crit, o, warn, Drain};
use std::unimplemented;

#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;
Expand Down Expand Up @@ -44,6 +45,13 @@ fn main() {
// [] add command for just counting barcode frequency
// [] add other algorithms for determining barcode cutoff

let convert_app = App::new("convert")
.about("Convert a BAM file to a RAD file")
.version(version)
.author(crate_authors)
.arg(Arg::from("-b, --bam=<bam-file> 'input SAM/BAM file'"))
.arg(Arg::from("-o, --output=<rad-file> 'output RAD file'"));

let gen_app = App::new("generate-permit-list")
.about("Generate a permit list of barcodes from a RAD file")
.version(version)
Expand Down Expand Up @@ -109,6 +117,7 @@ fn main() {
.subcommand(gen_app)
.subcommand(collate_app)
.subcommand(quant_app)
.subcommand(convert_app)
.get_matches();

let decorator = slog_term::TermDecorator::new().build();
Expand Down Expand Up @@ -199,6 +208,12 @@ fn main() {
}
}

if let Some(ref t) = opts.subcommand_matches("convert") {
let _input_file: String = t.value_of_t("bam-file").unwrap();
let _rad_file: String = t.value_of_t("rad-file").unwrap();
unimplemented!("convert command is not yet implemented.")
}

if let Some(ref t) = opts.subcommand_matches("collate") {
let input_dir: String = t.value_of_t("input-dir").unwrap();
let rad_file: String = t.value_of_t("rad-file").unwrap();
Expand Down

0 comments on commit 5e58cb6

Please sign in to comment.