Skip to content

Commit

Permalink
Merge pull request #10 from theiagen/jro-snippy_tree-dev
Browse files Browse the repository at this point in the history
Add snippy core and snippy tree workflows
  • Loading branch information
kevinlibuit authored Dec 31, 2022
2 parents 19d40c6 + 6781a8a commit d816661
Show file tree
Hide file tree
Showing 9 changed files with 216 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .dockstore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ workflows:
primaryDescriptorPath: /workflows/wf_snippy_variants.wdl
testParameterFiles:
- empty.json
- name: Snippy_Tree
subclass: WDL
primaryDescriptorPath: /workflows/wf_snippy_tree.wdl
testParameterFiles:
- empty.json
- name: Nullarbor
subclass: WDL
primaryDescriptorPath: /workflows/wf_nullarbor.wdl
Expand Down
10 changes: 6 additions & 4 deletions tasks/gene_typing/task_snippy_variants.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ task snippy_variants {
String? query_gene
String samplename
String docker = "staphb/snippy:4.6.0"
Int cpus = 4
Int memory = 16
Int cpus = 8
Int memory = 32
# Paramters
# --map_qual: Minimum read mapping quality to consider (default '60')
# --base_quality: Minimum base quality to consider (default '13')
Expand All @@ -36,7 +36,7 @@ task snippy_variants {
if [ -z "~{query_gene}" ]; then
no_hit="NA: No query gene was provided"
else
no_hit="No variants identified in quieried genes (~{query_gene})"
no_hit="No variants identified in queried genes (~{query_gene})"
fi
# call snippy
snippy \
Expand Down Expand Up @@ -70,13 +70,15 @@ task snippy_variants {
else
echo "${no_hit}" > SNIPPY_VARIANT_HITS
fi
# Compress output dir
tar -cvzf "./~{samplename}_snippy_variants_outdir.tar" "./~{samplename}"
>>>
output {
String snippy_variants_version = read_string("VERSION")
String snippy_variants_query = "~{query_gene}"
String snippy_variants_hits = read_string("SNIPPY_VARIANT_HITS")
File snippy_variants_outdir_tarball = "./~{samplename}_snippy_variants_outdir.tar"
File snippy_variants_gene_query_results = "./gene_query.csv"
Array[File] snippy_outputs = glob("~{samplename}/~{samplename}*")
File snippy_variants_results = "~{samplename}/~{samplename}.csv"
File snippy_variants_bam = "~{samplename}/~{samplename}.bam"
File snippy_variants_bai ="~{samplename}/~{samplename}.bam.bai"
Expand Down
54 changes: 54 additions & 0 deletions tasks/phylogenetic_inference/task_gubbins.wdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
version 1.0

task gubbins {
input {
File alignment
String cluster_name
String docker = "sangerpathogens/gubbins"
Int? filter_percent = 25 #default is 25%
Int? iterations = 5
String? tree_builder = "raxml"
String? tree_args
String? nuc_subst_model = "GTRGAMMA"
Int? bootstrap = 0
String? outgroup
File? dates_file
}
command <<<
# date and version control
date | tee DATE
run_gubbins.py --version | tee VERSION

run_gubbins.py \
~{alignment} \
--prefix ~{cluster_name} \
--filter-percentage ~{filter_percent} \
--iterations ~{iterations} \
--tree-builder ~{tree_builder} \
~{'--tree-args ' + tree_args} \
~{'--model ' + nuc_subst_model} \
--bootstrap ~{bootstrap} \
~{'--outgroup ' + outgroup} \
~{'--date ' + dates_file} \
--threads 2
>>>
output {
String date = read_string("DATE")
String version = read_string("VERSION")
File gubbins_final_tree = "~{cluster_name}.final_tree.tre"
File gubbins_final_labelled_tree = "~{cluster_name}.node_labelled.final_tree.tre"
File gubbins_polymorphic_fasta = "~{cluster_name}.filtered_polymorphic_sites.fasta"
File gubbins_recombination_gff = "~{cluster_name}.recombination_predictions.gff"
File gubbins_branch_stats = "~{cluster_name}.per_branch_statistics.csv"
File? gubbins_timetree = "~{cluster_name}.final_tree.timetree.tre"
File? gubbins_timetree_stats = "~{cluster_name}.lsd.out"
}
runtime {
docker: "~{docker}"
memory: "32 GB"
cpu: 4
disks: "local-disk 100 SSD"
preemptible: 0
maxRetries: 1
}
}
6 changes: 3 additions & 3 deletions tasks/phylogenetic_inference/task_iqtree.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ task iqtree {
iqtree --version | grep version | sed 's/.*version/version/;s/ for Linux.*//' | tee VERSION

numGenomes=`grep -o '>' ~{alignment} | wc -l`
if [ $numGenomes -gt 3 ]
if [ "$numGenomes" -gt 3 ]
then
cp ~{alignment} ./msa.fasta
iqtree \
Expand All @@ -27,13 +27,13 @@ task iqtree {
-alrt ~{alrt} \
~{iqtree_opts}

cp msa.fasta.contree ~{cluster_name}_msa.tree
cp msa.fasta.contree ~{cluster_name}_iqtree.tree
fi
>>>
output {
String date = read_string("DATE")
String version = read_string("VERSION")
File ml_tree = "~{cluster_name}_msa.tree"
File ml_tree = "~{cluster_name}_iqtree.tree"
}
runtime {
docker: "~{docker}"
Expand Down
56 changes: 56 additions & 0 deletions tasks/phylogenetic_inference/task_snippy_core.wdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
version 1.0

task snippy_core {
input {
Array[File] snippy_variants_outdir_tarball
Array[String] samplenames
String tree_name
String docker = "staphb/snippy:4.6.0"
File reference
File? bed_file
}
command <<<
# version control
snippy --version | head -1 | tee VERSION

tarball_array=(~{sep=" " snippy_variants_outdir_tarball})
samplename_array=(~{sep=" " samplenames})

# iteratively untar
for i in ${tarball_array[@]}; do tar -xf $i; done

# run snippy core
snippy-core \
--prefix ~{tree_name} \
~{'--mask ' + bed_file} \
--ref ~{reference} \
"${samplename_array[@]}"

# run snippy clean
snippy-clean_full_aln \
~{tree_name}.full.aln > ~{tree_name}_snippy_clean_full.aln

mv ~{tree_name}.aln ~{tree_name}_core.aln
mv ~{tree_name}.full.aln ~{tree_name}_full.aln
mv ~{tree_name}.tab ~{tree_name}_all_snps.tsv
mv ~{tree_name}.txt ~{tree_name}_snps_summary.txt
>>>
output {
String snippy_version = read_string("VERSION")
File snippy_core_alignment = "~{tree_name}_core.aln"
File snippy_full_alignment = "~{tree_name}_full.aln"
File snippy_full_alignment_clean = "~{tree_name}_snippy_clean_full.aln"
File snippy_ref = "~{tree_name}.ref.fa"
File snippy_core_tab = "~{tree_name}_all_snps.tsv"
File snippy_txt = "~{tree_name}_snps_summary.txt"
File snippy_vcf = "~{tree_name}.vcf"
String snippy_docker_image = docker
}
runtime {
docker: "~{docker}"
memory: "8 GB"
cpu: 4
disks: "local-disk 100 SSD"
preemptible: 0
}
}
6 changes: 4 additions & 2 deletions tasks/phylogenetic_inference/task_snp_dists.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,15 @@ task snp_dists {
z.close()
print "Matrix has been created in current directory as '~{cluster_name}_snp_distance_matrix.tsv.'"
CODE
CODE
cp snp-dists-molten-ordered.tsv ~{cluster_name}_snp-dists_list.tsv
cp snp-dists-matrix.tsv ~{cluster_name}_snp_distance_matrix.tsv
>>>
output {
String date = read_string("DATE")
String version = read_string("VERSION")
File snp_matrix = "${cluster_name}_snp_distance_matrix.tsv"
File snp_dists_molten_ordered = "snp-dists-molten-ordered.tsv"
File snp_dists_molten_ordered = "${cluster_name}_snp-dists_list.tsv"
}
runtime {
docker: "quay.io/staphb/snp-dists:0.8.2"
Expand Down
Loading

0 comments on commit d816661

Please sign in to comment.