|
@@ -124,11 +124,17 @@ use crate::{
|
|
|
commands::{
|
|
commands::{
|
|
|
Command as JobCommand, LocalBatchRunner, LocalRunner, SbatchRunner, SlurmParams,
|
|
Command as JobCommand, LocalBatchRunner, LocalRunner, SbatchRunner, SlurmParams,
|
|
|
SlurmRunner,
|
|
SlurmRunner,
|
|
|
- }, config::Config, helpers::{is_file_older, remove_dir_if_exists}, io::straglr::{StraglrRow, read_straglr_tsv}, locker::SampleLock, pipes::{Initialize, InitializeSolo, ShouldRun, Version}, run, run_many, runners::Run
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ config::Config,
|
|
|
|
|
+ helpers::{is_file_older, remove_dir_if_exists},
|
|
|
|
|
+ io::straglr::{read_straglr_tsv, StraglrRow},
|
|
|
|
|
+ locker::SampleLock,
|
|
|
|
|
+ pipes::{Initialize, InitializeSolo, ShouldRun, Version},
|
|
|
|
|
+ run, run_many,
|
|
|
|
|
+ runners::Run,
|
|
|
};
|
|
};
|
|
|
use anyhow::Context;
|
|
use anyhow::Context;
|
|
|
use log::{debug, info};
|
|
use log::{debug, info};
|
|
|
-use uuid::Uuid;
|
|
|
|
|
use std::{
|
|
use std::{
|
|
|
collections::HashMap,
|
|
collections::HashMap,
|
|
|
fmt,
|
|
fmt,
|
|
@@ -136,6 +142,7 @@ use std::{
|
|
|
io::{BufRead, BufReader, Write},
|
|
io::{BufRead, BufReader, Write},
|
|
|
path::Path,
|
|
path::Path,
|
|
|
};
|
|
};
|
|
|
|
|
+use uuid::Uuid;
|
|
|
|
|
|
|
|
/// Straglr paired (tumor-normal) STR genotyper.
|
|
/// Straglr paired (tumor-normal) STR genotyper.
|
|
|
///
|
|
///
|
|
@@ -285,6 +292,7 @@ impl Run for Straglr {
|
|
|
min_support: self.config.straglr_min_support,
|
|
min_support: self.config.straglr_min_support,
|
|
|
min_cluster_size: self.config.straglr_min_cluster_size,
|
|
min_cluster_size: self.config.straglr_min_cluster_size,
|
|
|
genotype_in_size: self.config.straglr_genotype_in_size,
|
|
genotype_in_size: self.config.straglr_genotype_in_size,
|
|
|
|
|
+ job_name: Some(format!("straglr_{id}_{}", self.config.normal_name))
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
let output = run!(&self.config, &mut job)
|
|
let output = run!(&self.config, &mut job)
|
|
@@ -315,6 +323,7 @@ impl Run for Straglr {
|
|
|
min_support: self.config.straglr_min_support,
|
|
min_support: self.config.straglr_min_support,
|
|
|
min_cluster_size: self.config.straglr_min_cluster_size,
|
|
min_cluster_size: self.config.straglr_min_cluster_size,
|
|
|
genotype_in_size: self.config.straglr_genotype_in_size,
|
|
genotype_in_size: self.config.straglr_genotype_in_size,
|
|
|
|
|
+ job_name: Some(format!("straglr_{id}_{}", self.config.tumoral_name))
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
let output = run!(&self.config, &mut job)
|
|
let output = run!(&self.config, &mut job)
|
|
@@ -423,7 +432,7 @@ impl Straglr {
|
|
|
(true, status)
|
|
(true, status)
|
|
|
}
|
|
}
|
|
|
_ if has_novel => (true, ChangeStatus::Expansion), // Novel allele = expansion
|
|
_ if has_novel => (true, ChangeStatus::Expansion), // Novel allele = expansion
|
|
|
- _ => (false, ChangeStatus::Expansion), // Won't be used
|
|
|
|
|
|
|
+ _ => (false, ChangeStatus::Expansion), // Won't be used
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
if passes_threshold {
|
|
if passes_threshold {
|
|
@@ -595,7 +604,9 @@ impl SomaticStrChange {
|
|
|
|
|
|
|
|
/// Returns true if there are novel tumor alleles.
|
|
/// Returns true if there are novel tumor alleles.
|
|
|
pub fn has_novel_allele(&self) -> bool {
|
|
pub fn has_novel_allele(&self) -> bool {
|
|
|
- self.comparisons.iter().any(|c| c.normal.is_none() && c.tumor.is_some())
|
|
|
|
|
|
|
+ self.comparisons
|
|
|
|
|
+ .iter()
|
|
|
|
|
+ .any(|c| c.normal.is_none() && c.tumor.is_some())
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -633,10 +644,9 @@ fn compare_alleles(
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
let diff = (*tumor_size - *normal_size).abs();
|
|
let diff = (*tumor_size - *normal_size).abs();
|
|
|
- if diff <= match_tolerance
|
|
|
|
|
- && (best.is_none() || diff < best.unwrap().1) {
|
|
|
|
|
- best = Some((i, diff));
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if diff <= match_tolerance && (best.is_none() || diff < best.unwrap().1) {
|
|
|
|
|
+ best = Some((i, diff));
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if let Some((idx, _)) = best {
|
|
if let Some((idx, _)) = best {
|
|
@@ -706,6 +716,7 @@ struct StraglrJob {
|
|
|
min_support: u32,
|
|
min_support: u32,
|
|
|
min_cluster_size: u32,
|
|
min_cluster_size: u32,
|
|
|
genotype_in_size: bool,
|
|
genotype_in_size: bool,
|
|
|
|
|
+ job_name: Option<String>,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
impl JobCommand for StraglrJob {
|
|
impl JobCommand for StraglrJob {
|
|
@@ -736,8 +747,9 @@ impl LocalBatchRunner for StraglrJob {}
|
|
|
|
|
|
|
|
impl SlurmRunner for StraglrJob {
|
|
impl SlurmRunner for StraglrJob {
|
|
|
fn slurm_args(&self) -> Vec<String> {
|
|
fn slurm_args(&self) -> Vec<String> {
|
|
|
|
|
+ let job_name = self.job_name.clone().unwrap_or(String::from("straglr"));
|
|
|
SlurmParams {
|
|
SlurmParams {
|
|
|
- job_name: Some("straglr".into()),
|
|
|
|
|
|
|
+ job_name: Some(job_name),
|
|
|
partition: Some("shortq".into()),
|
|
partition: Some("shortq".into()),
|
|
|
cpus_per_task: Some(20),
|
|
cpus_per_task: Some(20),
|
|
|
mem: Some("10G".into()),
|
|
mem: Some("10G".into()),
|
|
@@ -749,8 +761,9 @@ impl SlurmRunner for StraglrJob {
|
|
|
|
|
|
|
|
impl SbatchRunner for StraglrJob {
|
|
impl SbatchRunner for StraglrJob {
|
|
|
fn slurm_params(&self) -> SlurmParams {
|
|
fn slurm_params(&self) -> SlurmParams {
|
|
|
|
|
+ let job_name = self.job_name.clone().unwrap_or(String::from("straglr"));
|
|
|
SlurmParams {
|
|
SlurmParams {
|
|
|
- job_name: Some("straglr".into()),
|
|
|
|
|
|
|
+ job_name: Some(job_name),
|
|
|
partition: Some("shortq".into()),
|
|
partition: Some("shortq".into()),
|
|
|
cpus_per_task: Some(20),
|
|
cpus_per_task: Some(20),
|
|
|
mem: Some("10G".into()),
|
|
mem: Some("10G".into()),
|
|
@@ -907,6 +920,7 @@ impl Run for StraglrSolo {
|
|
|
min_support: self.config.straglr_min_support,
|
|
min_support: self.config.straglr_min_support,
|
|
|
min_cluster_size: self.config.straglr_min_cluster_size,
|
|
min_cluster_size: self.config.straglr_min_cluster_size,
|
|
|
genotype_in_size: self.config.straglr_genotype_in_size,
|
|
genotype_in_size: self.config.straglr_genotype_in_size,
|
|
|
|
|
+ job_name: Some(format!("straglr_solo_{id}_{time}"))
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
let report =
|
|
let report =
|
|
@@ -1072,7 +1086,11 @@ pub fn run_straglr_chunked(
|
|
|
// Create temporary BED file for this chunk
|
|
// Create temporary BED file for this chunk
|
|
|
let bed_chunk_path = format!(
|
|
let bed_chunk_path = format!(
|
|
|
"{}/straglr_chunk_{}_{}_part{}_{}.bed",
|
|
"{}/straglr_chunk_{}_{}_part{}_{}.bed",
|
|
|
- config.tmp_dir, id, time_point, part_num, Uuid::new_v4()
|
|
|
|
|
|
|
+ config.tmp_dir,
|
|
|
|
|
+ id,
|
|
|
|
|
+ time_point,
|
|
|
|
|
+ part_num,
|
|
|
|
|
+ Uuid::new_v4()
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
let mut bed_chunk_file = File::create(&bed_chunk_path).context(format!(
|
|
let mut bed_chunk_file = File::create(&bed_chunk_path).context(format!(
|
|
@@ -1113,6 +1131,7 @@ pub fn run_straglr_chunked(
|
|
|
min_support: config.straglr_min_support,
|
|
min_support: config.straglr_min_support,
|
|
|
min_cluster_size: config.straglr_min_cluster_size,
|
|
min_cluster_size: config.straglr_min_cluster_size,
|
|
|
genotype_in_size: config.straglr_genotype_in_size,
|
|
genotype_in_size: config.straglr_genotype_in_size,
|
|
|
|
|
+ job_name: Some(format!("straglr_{id}_{time_point}_{part_num}"))
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
jobs.push(job);
|
|
jobs.push(job);
|
|
@@ -1277,7 +1296,10 @@ pub fn compute_stats(changes: &[SomaticStrChange]) -> SomaticStrStats {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Track motif counts
|
|
// Track motif counts
|
|
|
- let motif_stat = stats.by_motif.entry(change.repeat_unit.clone()).or_default();
|
|
|
|
|
|
|
+ let motif_stat = stats
|
|
|
|
|
+ .by_motif
|
|
|
|
|
+ .entry(change.repeat_unit.clone())
|
|
|
|
|
+ .or_default();
|
|
|
motif_stat.count += 1;
|
|
motif_stat.count += 1;
|
|
|
match change.status {
|
|
match change.status {
|
|
|
ChangeStatus::Expansion => motif_stat.expansions += 1,
|
|
ChangeStatus::Expansion => motif_stat.expansions += 1,
|
|
@@ -1289,11 +1311,11 @@ pub fn compute_stats(changes: &[SomaticStrChange]) -> SomaticStrStats {
|
|
|
// Compute global size diff stats
|
|
// Compute global size diff stats
|
|
|
if !size_diffs.is_empty() {
|
|
if !size_diffs.is_empty() {
|
|
|
size_diffs.sort_by(|a, b| a.partial_cmp(b).unwrap());
|
|
size_diffs.sort_by(|a, b| a.partial_cmp(b).unwrap());
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
stats.mean_size_diff = size_diffs.iter().sum::<f64>() / size_diffs.len() as f64;
|
|
stats.mean_size_diff = size_diffs.iter().sum::<f64>() / size_diffs.len() as f64;
|
|
|
stats.min_size_diff = size_diffs[0];
|
|
stats.min_size_diff = size_diffs[0];
|
|
|
stats.max_size_diff = size_diffs[size_diffs.len() - 1];
|
|
stats.max_size_diff = size_diffs[size_diffs.len() - 1];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
let mid = size_diffs.len() / 2;
|
|
let mid = size_diffs.len() / 2;
|
|
|
stats.median_size_diff = if size_diffs.len().is_multiple_of(2) {
|
|
stats.median_size_diff = if size_diffs.len().is_multiple_of(2) {
|
|
|
(size_diffs[mid - 1] + size_diffs[mid]) / 2.0
|
|
(size_diffs[mid - 1] + size_diffs[mid]) / 2.0
|