Skip to content

Commit

Permalink
Adding wdl-common
Browse files Browse the repository at this point in the history
  • Loading branch information
fleharty committed Apr 22, 2024
1 parent acf556d commit 29293e8
Show file tree
Hide file tree
Showing 25 changed files with 1,951 additions and 0 deletions.
34 changes: 34 additions & 0 deletions HiFi-human-WGS-WDL/workflows/wdl-common/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Copyright (c) 2023, Pacific Biosciences of California, Inc.

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted (subject to the limitations in the
disclaimer below) provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.

* Neither the name of Pacific Biosciences nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY PACIFIC
BIOSCIENCES AND ITS CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL PACIFIC BIOSCIENCES OR ITS
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
15 changes: 15 additions & 0 deletions HiFi-human-WGS-WDL/workflows/wdl-common/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<h1 align="center"><img width="300px" src="images/logo_wdl_workflows.svg"/></h1>

<h1 align="center">PacBio Pipelines<br/>Common Tasks and Workflows</h1>

Workflows and tasks reused across PacBio workflows.

---

**The WDL files here are under active development and are currently provided in an unsupported format.**

---

## DISCLAIMER

TO THE GREATEST EXTENT PERMITTED BY APPLICABLE LAW, THIS WEBSITE AND ITS CONTENT, INCLUDING ALL SOFTWARE, SOFTWARE CODE, SITE-RELATED SERVICES, AND DATA, ARE PROVIDED "AS IS," WITH ALL FAULTS, WITH NO REPRESENTATIONS OR WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTIES OF MERCHANTABILITY, SATISFACTORY QUALITY, NON-INFRINGEMENT OR FITNESS FOR A PARTICULAR PURPOSE. ALL WARRANTIES ARE REJECTED AND DISCLAIMED. YOU ASSUME TOTAL RESPONSIBILITY AND RISK FOR YOUR USE OF THE FOREGOING. PACBIO IS NOT OBLIGATED TO PROVIDE ANY SUPPORT FOR ANY OF THE FOREGOING, AND ANY SUPPORT PACBIO DOES PROVIDE IS SIMILARLY PROVIDED WITHOUT REPRESENTATION OR WARRANTY OF ANY KIND. NO ORAL OR WRITTEN INFORMATION OR ADVICE SHALL CREATE A REPRESENTATION OR WARRANTY OF ANY KIND. ANY REFERENCES TO SPECIFIC PRODUCTS OR SERVICES ON THE WEBSITES DO NOT CONSTITUTE OR IMPLY A RECOMMENDATION OR ENDORSEMENT BY PACBIO.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions HiFi-human-WGS-WDL/workflows/wdl-common/wdl/structs.wdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version 1.0

struct IndexData {
File data
File data_index
}

struct RuntimeAttributes {
# The number of times to retry a task that fails due to preemption
Int preemptible_tries
# The number of times to retry a task that fails due a to nonzero return code
Int max_retries

String zones
String queue_arn
String container_registry
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
version 1.0

# Calculate VCF stats
import "../structs.wdl"

task bcftools_stats {
input {
File vcf
String? params

File? reference

RuntimeAttributes runtime_attributes
}
String vcf_basename = basename(vcf, ".gz")
Int threads = 2
Int reference_size = if (defined(reference)) then ceil(size(reference, "GB")) else 0
Int disk_size = ceil((size(vcf, "GB") + reference_size) * 2 + 20)
command <<<
set -euo pipefail
bcftools --version
bcftools stats \
--threads ~{threads - 1} \
~{params} \
~{"--fasta-ref " + reference} \
~{vcf} \
> ~{vcf_basename}.stats.txt
>>>
output {
File stats = "~{vcf_basename}.stats.txt"
}

runtime {
docker: "~{runtime_attributes.container_registry}/bcftools@sha256:46720a7ab5feba5be06d5269454a6282deec13060e296f0bc441749f6f26fdec"
cpu: threads
memory: "4 GB"
disk: disk_size + " GB"
disks: "local-disk " + disk_size + " HDD"
preemptible: runtime_attributes.preemptible_tries
maxRetries: runtime_attributes.max_retries
awsBatchRetryAttempts: runtime_attributes.max_retries
queueArn: runtime_attributes.queue_arn
zones: runtime_attributes.zones
}
}
59 changes: 59 additions & 0 deletions HiFi-human-WGS-WDL/workflows/wdl-common/wdl/tasks/concat_vcf.wdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
version 1.0

# Concatenate and sort VCFs
import "../structs.wdl"

task concat_vcf {
input {
Array[File] vcfs
Array[File] vcf_indices

String output_vcf_name

RuntimeAttributes runtime_attributes
}
Int threads = 4
Int disk_size = ceil(size(vcfs, "GB") * 2 + 20)
command <<<
set -euo pipefail
mkdir vcfs
while read -r input || [[ -n "${input}" ]]; do
ln -s "${input}" vcfs
done < ~{write_lines(flatten([vcfs,vcf_indices]))}
find vcfs -name "*.vcf.gz" > vcf.list
bcftools --version
bcftools concat \
--allow-overlaps \
--threads ~{threads - 1} \
--output-type z \
--output ~{output_vcf_name} \
--file-list vcf.list
bcftools index --tbi ~{output_vcf_name}
>>>
output {
File concatenated_vcf = "~{output_vcf_name}"
File concatenated_vcf_index = "~{output_vcf_name}.tbi"
}

runtime {
docker: "~{runtime_attributes.container_registry}/bcftools@sha256:36d91d5710397b6d836ff87dd2a924cd02fdf2ea73607f303a8544fbac2e691f"
cpu: threads
memory: "8 GB"
disk: disk_size + " GB"
disks: "local-disk " + disk_size + " HDD"
preemptible: runtime_attributes.preemptible_tries
maxRetries: runtime_attributes.max_retries
awsBatchRetryAttempts: runtime_attributes.max_retries
queueArn: runtime_attributes.queue_arn
zones: runtime_attributes.zones
}
}
70 changes: 70 additions & 0 deletions HiFi-human-WGS-WDL/workflows/wdl-common/wdl/tasks/glnexus.wdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
version 1.0

# Run joint calling using GLnexus
import "../structs.wdl"

task glnexus {
input {
String cohort_id
Array[File] gvcfs
Array[File] gvcf_indices

String reference_name

File? regions_bed

Int mem_gb = 30

RuntimeAttributes runtime_attributes
}
Int threads = 24
Int disk_size = ceil(size(gvcfs, "GB") * 2 + 100)
command <<<
set -euo pipefail
# glneux_cli has no version option
glnexus_cli --help 2>&1 | grep -Eo 'glnexus_cli release v[0-9a-f.-]+'
glnexus_cli \
--threads ~{threads} \
--mem-gbytes ~{mem_gb} \
--dir ~{cohort_id}.~{reference_name}.GLnexus.DB \
--config DeepVariant_unfiltered \
~{"--bed " + regions_bed} \
~{sep=' ' gvcfs} \
> ~{cohort_id}.~{reference_name}.deepvariant.glnexus.bcf
bcftools --version
bcftools view \
--threads ~{threads} \
--output-type z \
--output-file ~{cohort_id}.~{reference_name}.deepvariant.glnexus.vcf.gz \
~{cohort_id}.~{reference_name}.deepvariant.glnexus.bcf
tabix --version
tabix ~{cohort_id}.~{reference_name}.deepvariant.glnexus.vcf.gz
>>>
output {
File vcf = "~{cohort_id}.~{reference_name}.deepvariant.glnexus.vcf.gz"
File vcf_index = "~{cohort_id}.~{reference_name}.deepvariant.glnexus.vcf.gz.tbi"
}

runtime {
docker: "~{runtime_attributes.container_registry}/glnexus@sha256:ce6fecf59dddc6089a8100b31c29c1e6ed50a0cf123da9f2bc589ee4b0c69c8e"
cpu: threads
memory: mem_gb + " GB"
disk: disk_size + " GB"
disks: "local-disk " + disk_size + " HDD"
preemptible: runtime_attributes.preemptible_tries
maxRetries: runtime_attributes.max_retries
awsBatchRetryAttempts: runtime_attributes.max_retries
queueArn: runtime_attributes.queue_arn
zones: runtime_attributes.zones
}
}
50 changes: 50 additions & 0 deletions HiFi-human-WGS-WDL/workflows/wdl-common/wdl/tasks/mosdepth.wdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
version 1.0

# Calculate summary stats using mosdepth
import "../structs.wdl"

task mosdepth {
input {
File aligned_bam
File aligned_bam_index

RuntimeAttributes runtime_attributes
}
String prefix = basename(aligned_bam, ".bam")
Int threads = 4
Int disk_size = ceil(size(aligned_bam, "GB") * 2 + 20)
command <<<
set -euo pipefail
mosdepth --version
mosdepth \
--threads ~{threads - 1} \
--by 500 \
--no-per-base \
--use-median \
~{prefix} \
~{aligned_bam}
>>>
output {
File summary = "~{prefix}.mosdepth.summary.txt"
File region_bed = "~{prefix}.regions.bed.gz"
}

runtime {
docker: "~{runtime_attributes.container_registry}/mosdepth@sha256:35d5e02facf4f38742e5cae9e5fdd3807c2b431dd8d881fd246b55e6d5f7f600"
cpu: threads
memory: "4 GB"
disk: disk_size + " GB"
disks: "local-disk " + disk_size + " LOCAL"
preemptible: runtime_attributes.preemptible_tries
maxRetries: runtime_attributes.max_retries
awsBatchRetryAttempts: runtime_attributes.max_retries
queueArn: runtime_attributes.queue_arn
zones: runtime_attributes.zones
}
}
Loading

0 comments on commit 29293e8

Please sign in to comment.