Skip to content

Commit e2b8519

Browse files
committed
Refine Kallisto summary outputs
1 parent 74d14ee commit e2b8519

2 files changed

Lines changed: 30 additions & 30 deletions

File tree

pipes/WDL/tasks/tasks_metagenomics.wdl

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -682,15 +682,12 @@ task kallisto {
682682
--threads "~{cpu}" \
683683
--loglevel=DEBUG
684684
685-
tar -c -C "~{count_dir}" . | zstd > "~{out_basename}.kallisto_count.tar.zst"
686-
687685
{ if [ -f /sys/fs/cgroup/memory.peak ]; then cat /sys/fs/cgroup/memory.peak; elif [ -f /sys/fs/cgroup/memory/memory.max_usage_in_bytes ]; then cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes; else echo "0"; fi } > MEM_BYTES
688686
>>>
689687

690688
output {
691689
File kallisto_counts_tsv = "~{count_dir}/counts.tsv"
692690
File kallisto_counts_h5ad = "~{count_dir}/adata.h5ad"
693-
File kallisto_count_tar = "~{out_basename}.kallisto_count.tar.zst"
694691
Array[File] kallisto_loom_files = glob("~{count_dir}/*.loom")
695692
Int max_ram_gb = ceil(read_float("MEM_BYTES")/1000000000)
696693
String viralngs_version = read_string("VERSION")
@@ -813,9 +810,9 @@ task build_kallisto_db {
813810
}
814811
}
815812

816-
task kallisto_extract {
813+
task kallisto_read_summary {
817814
meta {
818-
description: "Extracts reads that pseudoalign to selected Kallisto target IDs."
815+
description: "Runs Kallisto extract internally and emits a read-level Kallisto summary TSV."
819816
}
820817

821818
input {
@@ -853,7 +850,7 @@ task kallisto_extract {
853850
category: "required"
854851
}
855852
sample_id: {
856-
description: "Optional sample identifier to stamp into the read-level Kallisto TSV. Defaults to the input reads basename with common BAM/FASTQ extensions removed.",
853+
description: "Optional sample identifier to stamp into summary.tsv. Defaults to the input reads basename with common BAM/FASTQ extensions removed.",
857854
category: "common"
858855
}
859856
target_ids: {
@@ -866,7 +863,7 @@ task kallisto_extract {
866863
category: "common"
867864
}
868865
id_to_taxon_map: {
869-
description: "Optional CSV/TSV mapping Kallisto hit IDs to taxonomy columns. When provided, taxonomy lineage and selected taxonomy name are added to the read-level TSV.",
866+
description: "Optional CSV/TSV mapping Kallisto hit IDs to taxonomy columns. When provided, taxonomy lineage and selected taxonomy name are added to summary.tsv.",
870867
patterns: ["*.csv", "*.tsv", "*.csv.gz", "*.tsv.gz"],
871868
category: "common"
872869
}
@@ -935,21 +932,18 @@ task kallisto_extract {
935932
--out_dir "~{extract_dir}" \
936933
~{true="--protein" false="" protein} \
937934
--sample-id "~{output_sample_id}" \
938-
--read-hits-tsv "~{extract_dir}/read_hits.tsv" \
935+
--summary-tsv "~{extract_dir}/summary.tsv" \
939936
"${TAXONOMY_ARGS[@]}" \
940937
--taxonomy-level "~{taxonomy_level}" \
941938
--threads "~{cpu}" \
942939
"${TARGET_ARGS[@]}" \
943940
--loglevel=DEBUG
944941
945-
tar -c -C "~{extract_dir}" . | zstd > "~{out_basename}.kallisto_extract.tar.zst"
946-
947942
{ if [ -f /sys/fs/cgroup/memory.peak ]; then cat /sys/fs/cgroup/memory.peak; elif [ -f /sys/fs/cgroup/memory/memory.max_usage_in_bytes ]; then cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes; else echo "0"; fi } > MEM_BYTES
948943
>>>
949944

950945
output {
951-
File kallisto_extract_tar = "~{out_basename}.kallisto_extract.tar.zst"
952-
File read_hits_tsv = "~{extract_dir}/read_hits.tsv"
946+
File summary_tsv = "~{extract_dir}/summary.tsv"
953947
Int max_ram_gb = ceil(read_float("MEM_BYTES")/1000000000)
954948
String viralngs_version = read_string("VERSION")
955949
}
@@ -968,11 +962,11 @@ task kallisto_extract {
968962

969963
task report_primary_kallisto_taxa {
970964
meta {
971-
description: "Interprets Kallisto count output and emits the primary contributing hit under a focal taxon."
965+
description: "Interprets Kallisto counts TSV output and emits the primary contributing hit under a focal taxon."
972966
}
973967

974968
input {
975-
File kallisto_count_tar
969+
File kallisto_counts_tsv
976970
File? id_to_taxon_map
977971
String focal_taxon = "Viruses"
978972

@@ -981,14 +975,14 @@ task report_primary_kallisto_taxa {
981975
}
982976

983977
parameter_meta {
984-
kallisto_count_tar: {
985-
description: "Kallisto count tarball emitted by the kallisto task.",
986-
patterns: ["*.tar.zst", "*.tar.gz"],
978+
kallisto_counts_tsv: {
979+
description: "Long-form Kallisto counts TSV emitted by the kallisto task.",
980+
patterns: ["*.tsv", "*.tsv.gz"],
987981
category: "required"
988982
}
989983
id_to_taxon_map: {
990-
description: "Optional CSV mapping Kallisto hit IDs to taxonomy columns.",
991-
patterns: ["*.csv", "*.csv.gz"],
984+
description: "Optional CSV/TSV mapping Kallisto hit IDs to taxonomy columns.",
985+
patterns: ["*.csv", "*.tsv", "*.csv.gz", "*.tsv.gz"],
992986
category: "common"
993987
}
994988
focal_taxon: {
@@ -1005,19 +999,25 @@ task report_primary_kallisto_taxa {
1005999
}
10061000
}
10071001

1008-
String count_tar_basename = sub(sub(basename(kallisto_count_tar), "\\.tar\\.zst$", ""), "\\.tar\\.gz$", "")
1009-
String out_basename = sub(count_tar_basename, "\\.kallisto_count$", "")
1010-
Int disk_size = ceil((4 * size(kallisto_count_tar, "GB") + size(id_to_taxon_map, "GB") + 100) / 375.0) * 375
1002+
String out_basename = sub(sub(basename(kallisto_counts_tsv), "\\.tsv\\.gz$", ""), "\\.tsv$", "")
1003+
Int disk_size = ceil((4 * size(kallisto_counts_tsv, "GB") + size(id_to_taxon_map, "GB") + 100) / 375.0) * 375
10111004

10121005
command <<<
10131006
set -ex -o pipefail
10141007
10151008
metagenomics --version | tee VERSION
10161009
1010+
ID_TO_TAXON_MAP="~{default='' id_to_taxon_map}"
1011+
if [ -n "$ID_TO_TAXON_MAP" ]; then
1012+
TAXONOMY_ARGS=(--id-to-tax-map "$ID_TO_TAXON_MAP")
1013+
else
1014+
TAXONOMY_ARGS=()
1015+
fi
1016+
10171017
metagenomics kallisto_top_taxa \
1018-
"~{kallisto_count_tar}" \
1018+
"~{kallisto_counts_tsv}" \
10191019
"~{out_basename}.ranked_focal_report.tsv" \
1020-
~{"--id-to-tax-map " + id_to_taxon_map} \
1020+
"${TAXONOMY_ARGS[@]}" \
10211021
--target-taxon "~{focal_taxon}" \
10221022
--loglevel=DEBUG
10231023

pipes/WDL/workflows/classify_kallisto.wdl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import "../tasks/tasks_metagenomics.wdl" as metagenomics
44

55
workflow classify_kallisto {
66
meta {
7-
description: "Kallisto/kb pseudoalignment classification of a single BAM or single FASTQ file. Emits long-form counts and a read-level Kallisto TSV for reads extracted from count-derived Kallisto targets."
7+
description: "Kallisto/kb pseudoalignment classification of a single BAM or single FASTQ file. Emits long-form counts and read-level Kallisto summary TSV outputs."
88
author: "Broad Viral Genomics"
99
email: "viral-ngs@broadinstitute.org"
1010
allowNestedInputs: true
@@ -46,11 +46,11 @@ workflow classify_kallisto {
4646
category: "required"
4747
}
4848
sample_id: {
49-
description: "Optional sample identifier to stamp into Kallisto count and read-level TSV outputs. Defaults to the input reads basename with common BAM/FASTQ extensions removed.",
49+
description: "Optional sample identifier to stamp into Kallisto count and summary TSV outputs. Defaults to the input reads basename with common BAM/FASTQ extensions removed.",
5050
category: "common"
5151
}
5252
id_to_taxon_map: {
53-
description: "Optional CSV/TSV mapping Kallisto hit IDs to taxonomy columns. When provided, taxonomy lineage and selected taxonomy name are added to the read-level TSV.",
53+
description: "Optional CSV/TSV mapping Kallisto hit IDs to taxonomy columns. When provided, taxonomy lineage and selected taxonomy name are added to summary.tsv.",
5454
patterns: ["*.csv", "*.tsv", "*.csv.gz", "*.tsv.gz"],
5555
category: "common"
5656
}
@@ -110,7 +110,7 @@ workflow classify_kallisto {
110110
docker = docker
111111
}
112112
113-
call metagenomics.kallisto_extract {
113+
call metagenomics.kallisto_read_summary {
114114
input:
115115
reads_bam = reads_bam,
116116
kallisto_index = kallisto_index,
@@ -127,7 +127,7 @@ workflow classify_kallisto {
127127
}
128128
129129
output {
130-
File kallisto_counts_tsv = kallisto.kallisto_counts_tsv
131-
File kallisto_read_hits_tsv = kallisto_extract.read_hits_tsv
130+
File kallisto_counts_tsv = kallisto.kallisto_counts_tsv
131+
File kallisto_summary_tsv = kallisto_read_summary.summary_tsv
132132
}
133133
}

0 commit comments

Comments
 (0)