@@ -2,6 +2,7 @@ version 1.0
22
33import "ProcessOnInstrumentDemuxedChunk.wdl" as TreatPerReadGroup
44
5+ import "../../../tasks/Utility/Utils.wdl" as U
56import "../../../tasks/Utility/BAMutils.wdl" as BU
67import "../../../tasks/Utility/GeneralUtils.wdl" as GU
78import "../../../tasks/Utility/Finalize.wdl" as FF
@@ -54,16 +55,16 @@ workflow ProcessOnDownsampledMultiReadgroupUBAM {
5455 output {
5556 String last_processing_date = today .yyyy_mm_dd
5657
57- Array [File ] readgroup_aligned_bams = eachRG .aligned_bam
58- Array [File ] readgroup_aligned_bais = eachRG .aligned_bai
59- Array [File ] readgroup_aligned_pbis = eachRG .aligned_pbi
60- Array [String ] readgroup_meta_movies = eachRG .movie
61- Array [Float ] readgroup_metrics_contam = select_all (eachRG .contamination_est )
58+ Array [File ] readgroup_aligned_bams = select_all ( eachRG .aligned_bam )
59+ Array [File ] readgroup_aligned_bais = select_all ( eachRG .aligned_bai )
60+ Array [File ] readgroup_aligned_pbis = select_all ( eachRG .aligned_pbi )
61+ Array [String ] readgroup_meta_movies = select_all ( eachRG .movie )
62+ Array [Float ] readgroup_metrics_contam = select_all (select_all ( eachRG .contamination_est ) )
6263
63- Array [Map [String , String ]?] readgroup_metrics_optional_fingerprint_check = eachRG .fingerprint_check
64- Array [Map [String , String ]?] readgroup_metrics_optional_inferred_sex_info = eachRG .inferred_sex_info
65- Array [Map [String , String ]?] readgroup_metrics_optional_methyl_tag_simple_stats = eachRG .methyl_tag_simple_stats
66- Array [Map [String , String ]] readgroup_metrics_optional_aBAM_metrics_files = eachRG .aBAM_metrics_files
64+ Array [Map [String , String ]?] readgroup_metrics_optional_fingerprint_check = select_all ( eachRG .fingerprint_check )
65+ Array [Map [String , String ]?] readgroup_metrics_optional_inferred_sex_info = select_all ( eachRG .inferred_sex_info )
66+ Array [Map [String , String ]?] readgroup_metrics_optional_methyl_tag_simple_stats = select_all ( eachRG .methyl_tag_simple_stats )
67+ Array [Map [String , String ]] readgroup_metrics_optional_aBAM_metrics_files = select_all ( eachRG .aBAM_metrics_files )
6768 }
6869
6970 # split by read group
@@ -77,23 +78,31 @@ workflow ProcessOnDownsampledMultiReadgroupUBAM {
7778 # align by each read group
7879 Array [Pair [String , File ]] readgroup_2_bam = zip (SplitByRG .rg_ids , SplitByRG .split_bam )
7980 scatter (pair in readgroup_2_bam ) {
80- call TreatPerReadGroup .ProcessOnInstrumentDemuxedChunk as eachRG { input :
81- gcs_out_root_dir = gcs_out_root_dir ,
81+ call U .CountBamRecords as PreventEmptyBam { input :
82+ bam = pair .right
83+ }
84+ if (defined (PreventEmptyBam .samools_error )) {
85+ call U .StopWorkflow { input : reason = "samtools count error occurred" }
86+ }
87+ if (PreventEmptyBam .num_records != 0 ) {
88+ call TreatPerReadGroup .ProcessOnInstrumentDemuxedChunk as eachRG { input :
89+ gcs_out_root_dir = gcs_out_root_dir ,
8290
83- uBAM = pair .right ,
91+ uBAM = pair .right ,
8492
85- readgroup_id = pair .left ,
86- bam_SM_field = bam_SM_field ,
93+ readgroup_id = pair .left ,
94+ bam_SM_field = bam_SM_field ,
8795
88- platform = 'Revio' , # non-critical lie, this parameter was used for setting bam size lower bound threshold for failing QC
96+ platform = 'Revio' , # non-critical lie, this parameter was used for setting bam size lower bound threshold for failing QC
8997
90- # args for optional QC subworkflows
91- qc_metrics_config_json = qc_metrics_config_json ,
92- fingerprint_sample_id = fingerprint_sample_id ,
93- expected_sex_type = expected_sex_type ,
98+ # args for optional QC subworkflows
99+ qc_metrics_config_json = qc_metrics_config_json ,
100+ fingerprint_sample_id = fingerprint_sample_id ,
101+ expected_sex_type = expected_sex_type ,
94102
95- ref_map_file = ref_map_file ,
96- disk_type = disk_type
103+ ref_map_file = ref_map_file ,
104+ disk_type = disk_type
105+ }
97106 }
98107 }
99108
0 commit comments