Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
a-frantz committed Dec 15, 2023
1 parent 9b45316 commit 520ae46
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ git-testament = "0.2.1"
indexmap = "1.9.1"
indicatif = "0.16.2"
itertools = "0.10.5"
lazy_static = "1.4.0"
noodles = { version = "0.34.0", features = [
"async",
"bam",
Expand Down
38 changes: 24 additions & 14 deletions src/derive/endedness/compute.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
//! Module holding the logic for computing the endedness of a BAM.
use anyhow::bail;
use lazy_static::lazy_static;
use noodles::sam::header;
use serde::Serialize;
use std::collections::HashMap;
use std::collections::HashSet;
use std::sync::Arc;
use tracing::warn;

/// String used to index into the HashMaps used to store the "overall" ordering flags.
pub static OVERALL: &str = "overall";
// Strings used to index into the HashMaps used to store the Read Group ordering flags.
// Lazy statics are used to save memory.
lazy_static! {
/// String used to index into the HashMaps used to store the "overall" ordering flags.
pub static ref OVERALL: Arc<String> = Arc::new(String::from("overall"));

/// String used to index into th HashMaps used to store the "unknown_read_group" ordering flags.
pub static UNKNOWN_READ_GROUP: &str = "unknown_read_group";
/// String used to index into th HashMaps used to store the "unknown_read_group" ordering flags.
pub static ref UNKNOWN_READ_GROUP: Arc<String> = Arc::new(String::from("unknown_read_group"));
}

/// Struct holding the ordering flags for a single read group.
#[derive(Debug, Clone)]
Expand Down Expand Up @@ -232,7 +239,10 @@ fn calculate_reads_per_template<'rg>(
}
}

reads_per_template.insert(OVERALL, total_reads as f64 / total_templates as f64);
reads_per_template.insert(
OVERALL.as_str(),
total_reads as f64 / total_templates as f64,
);

for (read_group, num_reads) in read_group_reads.iter() {
let num_templates = read_group_templates.get(read_group).unwrap();
Expand Down Expand Up @@ -362,7 +372,7 @@ pub fn predict(
);

for (read_group, rg_ordering_flags) in ordering_flags.iter() {
if (*read_group == UNKNOWN_READ_GROUP)
if (*read_group == UNKNOWN_READ_GROUP.as_str())
&& (rg_ordering_flags.first == 0
&& rg_ordering_flags.last == 0
&& rg_ordering_flags.both == 0
Expand Down Expand Up @@ -401,7 +411,7 @@ mod tests {
fn test_predict_endedness() {
let mut ordering_flags: HashMap<&str, OrderingFlagsCounts> = HashMap::new();
ordering_flags.insert(
OVERALL,
OVERALL.as_str(),
OrderingFlagsCounts {
first: 1,
last: 1,
Expand All @@ -411,7 +421,7 @@ mod tests {
);
let result = predict_endedness(
"overall".to_string(),
&ordering_flags.get(OVERALL).unwrap(),
&ordering_flags.get(OVERALL.as_str()).unwrap(),
0.0,
None,
false,
Expand Down Expand Up @@ -449,7 +459,7 @@ mod tests {
fn test_derive_endedness_from_only_first() {
let mut ordering_flags: HashMap<&str, OrderingFlagsCounts> = HashMap::new();
ordering_flags.insert(
OVERALL,
OVERALL.as_str(),
OrderingFlagsCounts {
first: 1,
last: 0,
Expand All @@ -472,7 +482,7 @@ mod tests {
fn test_derive_endedness_from_only_last() {
let mut ordering_flags: HashMap<&str, OrderingFlagsCounts> = HashMap::new();
ordering_flags.insert(
OVERALL,
OVERALL.as_str(),
OrderingFlagsCounts {
first: 0,
last: 1,
Expand All @@ -495,7 +505,7 @@ mod tests {
fn test_derive_endedness_from_only_both() {
let mut ordering_flags: HashMap<&str, OrderingFlagsCounts> = HashMap::new();
ordering_flags.insert(
OVERALL,
OVERALL.as_str(),
OrderingFlagsCounts {
first: 0,
last: 0,
Expand All @@ -518,7 +528,7 @@ mod tests {
fn test_derive_endedness_from_only_neither() {
let mut ordering_flags: HashMap<&str, OrderingFlagsCounts> = HashMap::new();
ordering_flags.insert(
OVERALL,
OVERALL.as_str(),
OrderingFlagsCounts {
first: 0,
last: 0,
Expand All @@ -541,7 +551,7 @@ mod tests {
fn test_derive_endedness_from_first_and_last() {
let mut ordering_flags: HashMap<&str, OrderingFlagsCounts> = HashMap::new();
ordering_flags.insert(
OVERALL,
OVERALL.as_str(),
OrderingFlagsCounts {
first: 1,
last: 1,
Expand Down Expand Up @@ -583,7 +593,7 @@ mod tests {
let rg_paired = "rg_paired";
let rg_single = "rg_single";
ordering_flags.insert(
OVERALL,
OVERALL.as_str(),
OrderingFlagsCounts {
first: 8,
last: 8,
Expand Down

0 comments on commit 520ae46

Please sign in to comment.