Skip to content

Commit

Permalink
Merge pull request #572 from broadinstitute/dp-demux-fix
Browse files Browse the repository at this point in the history
bugfix: demux_deplete with biosample attributes
  • Loading branch information
dpark01 authored Nov 25, 2024
2 parents 6c59d05 + 9017a80 commit b8bb70b
Showing 1 changed file with 33 additions and 31 deletions.
64 changes: 33 additions & 31 deletions pipes/WDL/workflows/demux_deplete.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ workflow demux_deplete {
Boolean insert_demux_outputs_into_terra_tables=false

File? sample_rename_map
Array[File]? biosample_map_tsvs
Array[File] biosample_map_tsvs = []
Int min_reads_per_bam = 100

String? instrument_model_user_specified
Expand Down Expand Up @@ -183,22 +183,43 @@ workflow demux_deplete {
Pair[String,Int] count_cleaned = (basename(raw_reads, '.bam'), read_count_post_depletion)
}

if (length(flatten(select_all([biosample_map_tsvs]))) > 0) {
if(insert_demux_outputs_into_terra_tables) {
call terra.check_terra_env

if(check_terra_env.is_running_on_terra) {
call terra.create_or_update_sample_tables {
input:
flowcell_run_id = illumina_demux.run_info[0]['run_id'],
workspace_name = check_terra_env.workspace_name,
workspace_namespace = check_terra_env.workspace_namespace,

raw_reads_unaligned_bams = flatten(illumina_demux.raw_reads_unaligned_bams),
cleaned_reads_unaligned_bams = select_all(cleaned_bam_passing),
meta_by_filename_json = meta_filename.merged_json,
read_counts_raw_json = write_json(count_raw),
read_counts_cleaned_json = write_json(count_cleaned)
}
}
}
if (length(biosample_map_tsvs) > 0) {
#### merge biosample attribute tsvs (iff provided with more than one)
if (length(flatten(select_all([biosample_map_tsvs]))) > 1) {
if (length(biosample_map_tsvs) > 1) {
call utils.tsv_join as biosample_map_tsv_join {
input:
input_tsvs = flatten([select_first([biosample_map_tsvs,[]])]),
input_tsvs = biosample_map_tsvs,
id_col = 'accession',
out_suffix = ".tsv",
out_basename = "biosample-attributes-merged"
}
}
File biosample_map_tsv = select_first(flatten([[biosample_map_tsv_join.out_tsv], biosample_map_tsvs]))

#### biosample metadata mapping
call ncbi.biosample_to_table {
input:
biosample_attributes_tsv = select_first([biosample_map_tsv_join.out_tsv, biosample_map_tsvs]),
biosample_attributes_tsv = biosample_map_tsv,
cleaned_bam_filepaths = select_all(cleaned_bam_passing),
demux_meta_json = meta_filename.merged_json
}
Expand All @@ -207,7 +228,7 @@ workflow demux_deplete {
call ncbi.sra_meta_prep {
input:
cleaned_bam_filepaths = select_all(cleaned_bam_passing),
biosample_map = select_first([biosample_map_tsv_join.out_tsv, biosample_map_tsvs]),
biosample_map = biosample_map_tsv,
library_metadata = samplesheet_rename_ids.new_sheet,
platform = "ILLUMINA",
paired = (illumina_demux.run_info[0]['indexes'] == '2'),
Expand All @@ -216,32 +237,13 @@ workflow demux_deplete {
instrument_model = select_first(flatten([[instrument_model_user_specified],[illumina_demux.run_info[0]['sequencer_model']]])),
title = select_first([sra_title])
}
}

if(insert_demux_outputs_into_terra_tables) {
call terra.check_terra_env

if(check_terra_env.is_running_on_terra) {
call terra.create_or_update_sample_tables {
input:
flowcell_run_id = illumina_demux.run_info[0]['run_id'],
workspace_name = check_terra_env.workspace_name,
workspace_namespace = check_terra_env.workspace_namespace,

raw_reads_unaligned_bams = flatten(illumina_demux.raw_reads_unaligned_bams),
cleaned_reads_unaligned_bams = select_all(cleaned_bam_passing),
meta_by_filename_json = meta_filename.merged_json,
read_counts_raw_json = write_json(count_raw),
read_counts_cleaned_json = write_json(count_cleaned)
}
if (length(flatten(select_all([biosample_map_tsvs]))) > 0) {
call terra.upload_entities_tsv as terra_load_biosample_data {
input:
workspace_name = check_terra_env.workspace_name,
terra_project = check_terra_env.workspace_namespace,
tsv_file = select_first([biosample_to_table.sample_meta_tsv])
}
if(insert_demux_outputs_into_terra_tables && select_first([check_terra_env.is_running_on_terra])) {
call terra.upload_entities_tsv as terra_load_biosample_data {
input:
workspace_name = select_first([check_terra_env.workspace_name]),
terra_project = select_first([check_terra_env.workspace_namespace]),
tsv_file = biosample_to_table.sample_meta_tsv
}
}
}
Expand Down

0 comments on commit b8bb70b

Please sign in to comment.