Skip to content

Commit

Permalink
Merge pull request #6 from COMBINE-lab/quants_mat
Browse files Browse the repository at this point in the history
Quants mat
  • Loading branch information
rob-p committed Aug 20, 2020
2 parents 099d233 + 636970c commit 91a903e
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions libradicl/src/quant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,15 @@ pub fn quantify(
let output_path = std::path::Path::new(&output_dir);
fs::create_dir_all(output_path)?;

// create sub-directory for matrix
let output_matrix_path = output_path.join("alevin");
fs::create_dir_all(&output_matrix_path)?;

// well need a protected handle to write out the barcode
let bc_path = output_path.join("barcodes.txt");
let bc_path = output_matrix_path.join("quants_mat_rows.txt");
let bc_file = fs::File::create(bc_path)?;

let mat_path = output_path.join("counts.eds.gz");
let mat_path = output_matrix_path.join("quants_mat.gz");
//let bootstrap_path_1 = output_path.join("bootstraps_1.eds.gz");

let bootstrap_path = output_path.join("bootstraps.eds.gz");
Expand Down Expand Up @@ -759,7 +763,7 @@ pub fn quantify(
}
}

let gn_path = output_path.join("gene_names.txt");
let gn_path = output_matrix_path.join("quants_mat_cols.txt");
let gn_file = File::create(gn_path).expect("couldn't create gene name file.");
let mut gn_writer = BufWriter::new(gn_file);
for g in gene_names {
Expand Down Expand Up @@ -792,5 +796,19 @@ pub fn quantify(
.write_all(aux_info_str.as_bytes())
.expect("cannot write to meta_info.json file");

// k3yavi: Todo delete after api stability
// creating a dummy cmd_info.json for R compatibility
let cmd_info = json!({
"salmon_version": "1.3.0",
"auxDir": "aux_info"
});
let mut cmd_info_file = File::create(output_path.join("cmd_info.json"))
.expect("couldn't create cmd_info.json file.");
let cmd_info_str =
serde_json::to_string_pretty(&cmd_info).expect("could not format cmd_info json.");
cmd_info_file
.write_all(cmd_info_str.as_bytes())
.expect("cannot write to cmd_info.json file");

Ok(())
}

0 comments on commit 91a903e

Please sign in to comment.