Skip to content

Commit

Permalink
defend against empty input
Browse files Browse the repository at this point in the history
  • Loading branch information
dpark01 committed Feb 6, 2025
1 parent 0208be8 commit de73651
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
17 changes: 12 additions & 5 deletions pipes/WDL/tasks/tasks_reports.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,22 @@ task coverage_report {
Int disk_size = 375
command <<<
set -e
reports.py --version | tee VERSION
reports.py coverage_only \
~{sep=' ' mapped_bams} \
"~{out_report_name}" \
--loglevel DEBUG
python3 << CODE
import tools.samtools
import reports
in_bams = list([bam for bam in ["~{sep='", "' mapped_bams}"] if bam and not tools.samtools.isEmpty(bam)])
if in_bams:
reports.coverage_only(in_bams, "~{out_report_name}")
else:
with open("~{out_report_name}", "w") as outf:
outf.write('\t'.join(('sample', 'aln2self_cov_median', 'aln2self_cov_mean', 'aln2self_cov_mean_non0', 'aln2self_cov_1X', 'aln2self_cov_5X', 'aln2self_cov_20X', 'aln2self_cov_100X'))+'\n')
CODE
>>>
output {
File coverage_report = "~{out_report_name}"
File coverage_report = out_report_name
String viralngs_version = read_string("VERSION")
}
Expand Down
3 changes: 2 additions & 1 deletion pipes/WDL/workflows/scaffold_and_refine_multitaxa.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ workflow scaffold_and_refine_multitaxa {
call reports.coverage_report as coverage_self {
input:
mapped_bams = [refine.align_to_self_merged_aligned_only_bam],
mapped_bam_idx = []
mapped_bam_idx = [],
out_report_name = "~{sample_id}.coverage_report.txt"
}
call utils.tsv_drop_cols as coverage_two_col {
input:
Expand Down

0 comments on commit de73651

Please sign in to comment.