Skip to content

Commit f1021f6

Browse files
tpshea2claude
andcommitted
Fix Genomad task: handle absent virus FASTA when no viral sequences found
geNomad skips writing the virus .fna when it finds no viral sequences, causing the hardcoded cp to fail. Switch to find-based glob so the output path is also robust to geNomad prefix naming variations (.fasta.gz stripping behavior). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 2d2c534 commit f1021f6

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

wdl/tasks/Viral/Genomad.wdl

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,24 @@ task Genomad {
7878
genomad_out \
7979
"${DB_PATH}"
8080
81-
# Rename outputs with sample prefix
82-
cp genomad_out/input_contigs_summary/input_contigs_virus_summary.tsv \
83-
~{sample_name}.genomad_virus_summary.tsv
84-
cp genomad_out/input_contigs_virus/input_contigs_virus.fna \
85-
~{sample_name}.genomad_virus.fna
81+
# Rename outputs with sample prefix.
82+
# The virus FASTA is absent when geNomad finds no viral sequences; touch an
83+
# empty file so WDL output declaration is always satisfied.
84+
SUMMARY_TSV=$(find genomad_out -name '*_virus_summary.tsv' 2>/dev/null | head -1)
85+
if [[ -n "${SUMMARY_TSV}" ]]; then
86+
cp "${SUMMARY_TSV}" ~{sample_name}.genomad_virus_summary.tsv
87+
else
88+
touch ~{sample_name}.genomad_virus_summary.tsv
89+
echo "WARNING: geNomad produced no virus_summary.tsv — no viral sequences found" >&2
90+
fi
91+
92+
VIRUS_FNA=$(find genomad_out -name '*_virus.fna' 2>/dev/null | head -1)
93+
if [[ -n "${VIRUS_FNA}" ]]; then
94+
cp "${VIRUS_FNA}" ~{sample_name}.genomad_virus.fna
95+
else
96+
touch ~{sample_name}.genomad_virus.fna
97+
echo "WARNING: geNomad produced no virus.fna — no viral sequences found" >&2
98+
fi
8699
>>>
87100

88101
output {

0 commit comments

Comments
 (0)