Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding tbp_parser and clockwork to TheiaProk #192

Merged
merged 25 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions tasks/species_typing/task_clockwork.wdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
version 1.0

task clockwork_decon_reads {
input {
File read1
File? read2 # only optional to not fail in merlin_magic
String samplename
Int disk_size = 200
Int cpu = 16
Int mem = 64
String docker = "us-docker.pkg.dev/general-theiagen/cdcgov/varpipe_wgs_with_refs:2bc7234074bd53d9e92a1048b0485763cd9bbf6f4d12d5a1cc82bfec8ca7d75e"
}
command <<<
# Print and save version
clockwork version > VERSION

# Map reads to the clockwork reference
clockwork map_reads \
--unsorted_sam ~{samplename} /varpipe_wgs/tools/clockwork-0.11.3/OUT/ref.fa \
"~{samplename}.sam" \
~{read1} \
~{read2}

# Remove contaminants (reads that map with high identity to non-MTB sequences)
clockwork remove_contam \
/varpipe_wgs/tools/clockwork-0.11.3/OUT/remove_contam_metadata.tsv \
"~{samplename}.sam" \
"~{samplename}_outfile_read_counts" \
"clockwork_cleaned_~{samplename}_R1.fastq.gz" \
"clockwork_cleaned_~{samplename}_R2.fastq.gz"

# Clean up files
rm "~{samplename}.sam"
>>>
output {
File clockwork_cleaned_read1 = "clockwork_cleaned_~{samplename}_R1.fastq.gz"
File clockwork_cleaned_read2 = "clockwork_cleaned_~{samplename}_R2.fastq.gz"
}
runtime {
docker: docker
memory: mem + " GB"
cpu: cpu
disks: "local-disk " + disk_size + " SSD"
disk: disk_size + " GB"
maxRetries: 3
preemptible: 1
}
}
210 changes: 0 additions & 210 deletions tasks/species_typing/task_tb_gene_coverage.wdl

This file was deleted.

56 changes: 56 additions & 0 deletions tasks/species_typing/task_tbp_parser.wdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
version 1.0

task tbp_parser {
input {
File tbprofiler_json
File tbprofiler_bam
File tbprofiler_bai
String samplename

String? sequencing_method
String? operator
Int min_depth = 10
Int coverage_threshold = 100
Boolean tbp_parser_debug = false

String docker = "us-docker.pkg.dev/general-theiagen/theiagen/tbp-parser:0.0.10"
Int disk_size = 100
Int memory = 4
Int cpu = 1
}
command <<<
# get version
python3 /tbp-parser/tbp_parser/tbp_parser.py --version | tee VERSION

# run tbp-parser
python3 /tbp-parser/tbp_parser/tbp_parser.py ~{tbprofiler_json} ~{tbprofiler_bam} \
~{"--sequencing_method " + sequencing_method} \
~{"--operator " + operator} \
~{"--min_depth " + min_depth} \
~{"--coverage_threshold " + coverage_threshold} \
--output_prefix ~{samplename} \
~{true="--debug" false="--verbose" tbp_parser_debug}

# get genome percent coverage for the entire reference genome length over min_depth
genome=$(samtools depth -J ~{tbprofiler_bam} | awk -F "\t" '{if ($3 >= ~{min_depth}) print;}' | wc -l )
python3 -c "print ( ($genome / 4411532 ) * 100 )" | tee GENOME_PC
>>>
output {
File tbp_parser_looker_report_csv = "~{samplename}.looker_report.csv"
File tbp_parser_laboratorian_report_csv = "~{samplename}.laboratorian_report.csv"
File tbp_parser_lims_report_csv = "~{samplename}.lims_report.csv"
File tbp_parser_coverage_report = "~{samplename}.percent_gene_coverage.csv"
Float tbp_parser_genome_percent_coverage = read_float("GENOME_PC")
String tbp_parser_version = read_string("VERSION")
String tbp_parser_docker = docker
}
runtime {
docker: docker
memory: memory + " GB"
cpu: cpu
disks: "local-disk " + disk_size + " SSD"
disk: disk_size + " GB"
maxRetries: 3
preemptible: 1
}
}
18 changes: 14 additions & 4 deletions tasks/species_typing/task_tbprofiler.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ task tbprofiler {
String tbprofiler_docker_image = "us-docker.pkg.dev/general-theiagen/staphb/tbprofiler:4.4.2"
Int disk_size = 100
String mapper = "bwa"
String caller = "bcftools"
String caller = "freebayes"
Int min_depth = 10
Float min_af = 0.1
Float min_af_pred = 0.1
Expand All @@ -22,9 +22,10 @@ task tbprofiler {
date | tee DATE

# Print and save version
tb-profiler --version > VERSION && sed -i -e 's/^/TBProfiler version /' VERSION
tb-profiler version > VERSION && sed -i -e 's/TBProfiler version //' VERSION && sed -n -i '$p' VERSION

if [ -z "~{read2}" ] ; then
# check if file is non existant or non empty
if [ -z "~{read2}" ] || [ ! -s "~{read2}" ] ; then
INPUT_READS="-1 ~{read1}"
else
INPUT_READS="-1 ~{read1} -2 ~{read2}"
Expand Down Expand Up @@ -89,6 +90,12 @@ task tbprofiler {
res_genes.append(tsv_dict[i])
res_genes_string=';'.join(res_genes)
Resistance_Genes.write(res_genes_string)
with open ("MEDIAN_COVERAGE", 'wt') as Median_Coverage:
median_coverage=tsv_dict['median_coverage']
Median_Coverage.write(median_coverage)
with open ("PCT_READS_MAPPED", 'wt') as Pct_Reads_Mapped:
pct_reads_mapped=tsv_dict['pct_reads_mapped']
Pct_Reads_Mapped.write(pct_reads_mapped)
CODE
>>>
output {
Expand All @@ -104,13 +111,16 @@ task tbprofiler {
String tbprofiler_num_dr_variants = read_string("NUM_DR_VARIANTS")
String tbprofiler_num_other_variants = read_string("NUM_OTHER_VARIANTS")
String tbprofiler_resistance_genes = read_string("RESISTANCE_GENES")
Int tbprofiler_median_coverage = read_int("MEDIAN_COVERAGE")
Float tbprofiler_pct_reads_mapped = read_float("PCT_READS_MAPPED")
}
runtime {
docker: "~{tbprofiler_docker_image}"
memory: "16 GB"
cpu: cpu
disks: "local-disk " + disk_size + " SSD"
disk: disk_size + " GB"
maxRetries: 3
maxRetries: 3
preemptible: 1
}
}
Loading