|
@@ -133,13 +133,11 @@ use crate::{
|
|
|
annotation::{Annotation, Annotations, Caller, CallerCat, Sample},
|
|
annotation::{Annotation, Annotations, Caller, CallerCat, Sample},
|
|
|
collection::vcf::Vcf,
|
|
collection::vcf::Vcf,
|
|
|
commands::{
|
|
commands::{
|
|
|
- bcftools::{BcftoolsConcat, BcftoolsIndex, BcftoolsKeepPass},
|
|
|
|
|
- Command as JobCommand, LocalBatchRunner, LocalRunner, SbatchRunner, SlurmParams,
|
|
|
|
|
- SlurmRunner,
|
|
|
|
|
|
|
+ Command as JobCommand, LocalBatchRunner, LocalRunner, SbatchRunner, SlurmParams, SlurmRunner, bcftools::{BcftoolsConcat, BcftoolsIndex, BcftoolsKeepPass}
|
|
|
},
|
|
},
|
|
|
config::Config,
|
|
config::Config,
|
|
|
helpers::{is_file_older, remove_dir_if_exists, singularity_bind_flags},
|
|
helpers::{is_file_older, remove_dir_if_exists, singularity_bind_flags},
|
|
|
- io::{bed::BedRow, vcf::read_vcf},
|
|
|
|
|
|
|
+ io::{bam::read_sm_tag, bed::BedRow, vcf::read_vcf},
|
|
|
locker::SampleLock,
|
|
locker::SampleLock,
|
|
|
pipes::{Initialize, ShouldRun, Version},
|
|
pipes::{Initialize, ShouldRun, Version},
|
|
|
run, run_many,
|
|
run, run_many,
|
|
@@ -185,6 +183,8 @@ pub struct Mutect2 {
|
|
|
pub id: String,
|
|
pub id: String,
|
|
|
/// BED interval file for this run (full BED or chunk sub-BED).
|
|
/// BED interval file for this run (full BED or chunk sub-BED).
|
|
|
pub bed_path: PathBuf,
|
|
pub bed_path: PathBuf,
|
|
|
|
|
+ /// Normal sample name as found in the `@RG SM` tag of the normal BAM header.
|
|
|
|
|
+ pub normal_sample: String,
|
|
|
/// Directory for log file storage.
|
|
/// Directory for log file storage.
|
|
|
pub log_dir: String,
|
|
pub log_dir: String,
|
|
|
/// Global pipeline configuration.
|
|
/// Global pipeline configuration.
|
|
@@ -226,9 +226,15 @@ impl Initialize for Mutect2 {
|
|
|
bed_path.display()
|
|
bed_path.display()
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
|
|
+ let normal_bam = config.normal_bam(&id);
|
|
|
|
|
+ let normal_sample = read_sm_tag(&normal_bam)
|
|
|
|
|
+ .with_context(|| format!("Failed to read @RG SM from normal BAM: {normal_bam}"))?;
|
|
|
|
|
+ info!("Normal sample name from BAM header: {normal_sample}");
|
|
|
|
|
+
|
|
|
let mutect2 = Self {
|
|
let mutect2 = Self {
|
|
|
id,
|
|
id,
|
|
|
bed_path,
|
|
bed_path,
|
|
|
|
|
+ normal_sample,
|
|
|
log_dir,
|
|
log_dir,
|
|
|
config: config.clone(),
|
|
config: config.clone(),
|
|
|
part_index: None,
|
|
part_index: None,
|
|
@@ -276,7 +282,7 @@ impl JobCommand for Mutect2 {
|
|
|
let bed = self.bed_path.display();
|
|
let bed = self.bed_path.display();
|
|
|
|
|
|
|
|
// Normal sample name must match @RG SM tag in normal BAM header.
|
|
// Normal sample name must match @RG SM tag in normal BAM header.
|
|
|
- let sample_name_normal = format!("{}_{}", self.id, self.config.normal_name);
|
|
|
|
|
|
|
+ let sample_name_normal = &self.normal_sample;
|
|
|
|
|
|
|
|
let bind_flags = singularity_bind_flags([
|
|
let bind_flags = singularity_bind_flags([
|
|
|
&self.config.normal_bam(&self.id),
|
|
&self.config.normal_bam(&self.id),
|