Skip to content

Commit

Permalink
all is good Merge branch 'main' of https://github.com/icgc-argo-qc-wg…
Browse files Browse the repository at this point in the history
  • Loading branch information
abenjak committed Jul 23, 2021
2 parents 2ddb7c8 + 503f579 commit 83a7a6e
Show file tree
Hide file tree
Showing 17 changed files with 758 additions and 2 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Collection of ARGO QC Tools
# Collection of ARGO QC Tools in WFPM Packages

Update this to describe your awesome project.
## QC packages and underlying software tools

| wfpm package name | QC software tool name | tool version |
|-------------------|-----------------------|--------------|
| fastqc | FastQC | 0.11.9 |
| cutadapt | Cutadapt | 2.10 |
| samtools-stats | Samtools:stats | 1.12 |
| picard-collect-rna-seq-metrics | Picard:CollectRnaSeqMetrics | 2.25.6 |
| picard-collect-hs-metrics | Picard:CollectHsMetrics | 2.25.7 |
5 changes: 5 additions & 0 deletions picard-collect-hs-metrics/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.gitignore
.nextflow*
tests
work
outdir
22 changes: 22 additions & 0 deletions picard-collect-hs-metrics/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM continuumio/miniconda3:4.9.2

# filled by wfpm
LABEL org.opencontainers.image.source https://github.com/icgc-argo-qc-wg/argo-qc-tools

# add ps (required by nextflow)
RUN apt-get -y update && \
apt-get install -y procps && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

ENV PATH="//opt/conda/bin:${PATH}"

# install java
RUN conda install --yes -c conda-forge openjdk=11.0.9.1

# Fetch Picard
RUN wget https://github.com/broadinstitute/picard/releases/download/2.25.7/picard.jar

ENTRYPOINT ["/usr/bin/env"]

CMD ["/bin/bash"]
89 changes: 89 additions & 0 deletions picard-collect-hs-metrics/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/usr/bin/env nextflow

/*
Copyright (c) 2021, ICGC ARGO
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Authors:
Andrej Benjak
*/

/********************************************************************/
/* this block is auto-generated based on info from pkg.json where */
/* changes can be made if needed, do NOT modify this block manually */
nextflow.enable.dsl = 2
version = '0.1.0' // package version

container = [
'ghcr.io': 'ghcr.io/icgc-argo-qc-wg/argo-qc-tools.picard-collect-hs-metrics'
]
default_container_registry = 'ghcr.io'
/********************************************************************/


// universal params go here
params.container_registry = ""
params.container_version = ""
params.container = ""

params.cpus = 1
params.mem = 4 // GB
params.publish_dir = "picard-collect-hs-metrics_outdir" // set to empty string will disable publishDir


// tool specific parmas go here, add / change as needed
params.bam = ""
params.target_intervals= ""
params.bait_intervals= ""
params.output_pattern = "*.hs_metrics.txt" // output file name pattern


process picardCollectHsMetrics {
container "${params.container ?: container[params.container_registry ?: default_container_registry]}:${params.container_version ?: version}"
publishDir "${params.publish_dir}/${task.process.replaceAll(':', '_')}", mode: "copy", enabled: params.publish_dir

cpus params.cpus
memory "${params.mem} GB"

input:
path bam
path target_intervals
path bait_intervals

output:
path "${params.output_pattern}", emit: output_file

shell:

'''
java -jar /picard.jar CollectHsMetrics --INPUT !{bam} --TARGET_INTERVALS !{target_intervals} --BAIT_INTERVALS !{bait_intervals} --OUTPUT \$(basename !{bam} .bam).hs_metrics.txt
'''
}


// this provides an entry point for this main script, so it can be run directly without clone the repo
// using this command: nextflow run <git_acc>/<repo>/<pkg_name>/<main_script>.nf -r <pkg_name>.v<pkg_version> --params-file xxx
workflow {
picardCollectHsMetrics(
file(params.bam),
file(params.target_intervals),
file(params.bait_intervals)
)
}
60 changes: 60 additions & 0 deletions picard-collect-hs-metrics/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
Copyright (c) 2021, ICGC ARGO
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Authors:
Andrej Benjak
"""

import os
import sys
import argparse
import subprocess


def main():
"""
Python implementation of tool: picard-collect-hs-metrics
This is auto-generated Python code, please update as needed!
"""

parser = argparse.ArgumentParser(description='Tool: picard-collect-hs-metrics')
parser.add_argument('-i', '--input-file', dest='input_file', type=str,
help='Input file', required=True)
parser.add_argument('-o', '--output-dir', dest='output_dir', type=str,
help='Output directory', required=True)
args = parser.parse_args()

if not os.path.isfile(args.input_file):
sys.exit('Error: specified input file %s does not exist or is not accessible!' % args.input_file)

if not os.path.isdir(args.output_dir):
sys.exit('Error: specified output dir %s does not exist or is not accessible!' % args.output_dir)

subprocess.run(f"cp {args.input_file} {args.output_dir}/", shell=True, check=True)


if __name__ == "__main__":
main()

4 changes: 4 additions & 0 deletions picard-collect-hs-metrics/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
docker {
enabled = true
runOptions = '-u \$(id -u):\$(id -g)'
}
37 changes: 37 additions & 0 deletions picard-collect-hs-metrics/pkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "picard-collect-hs-metrics",
"version": "0.1.0",
"description": "Picard CollectHsMetrics",
"main": "main.nf",
"deprecated": false,
"keywords": [
"qc metrics",
"wes",
"exome"
],
"repository": {
"type": "git",
"url": "https://github.com/icgc-argo-qc-wg/argo-qc-tools.git"
},
"container": {
"registries": [
{
"registry": "ghcr.io",
"type": "docker",
"org": "icgc-argo-qc-wg",
"default": true
}
]
},
"dependencies": [],
"devDependencies": [],
"contributors": [
{
"name": "Andrej Benjak",
"email": "[email protected]"
}
],
"license": "MIT",
"bugReport": "https://github.com/icgc-argo-qc-wg/argo-qc-tools/issues",
"homepage": "https://github.com/icgc-argo-qc-wg/argo-qc-tools#readme"
}
111 changes: 111 additions & 0 deletions picard-collect-hs-metrics/tests/checker.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#!/usr/bin/env nextflow

/*
Copyright (c) 2021, ICGC ARGO
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Authors:
Andrej Benjak
*/

/*
This is an auto-generated checker workflow to test the generated main template workflow, it's
meant to illustrate how testing works. Please update to suit your own needs.
*/

/********************************************************************/
/* this block is auto-generated based on info from pkg.json where */
/* changes can be made if needed, do NOT modify this block manually */
nextflow.enable.dsl = 2
version = '0.1.0' // package version

container = [
'ghcr.io': 'ghcr.io/icgc-argo-qc-wg/argo-qc-tools.picard-collect-hs-metrics'
]
default_container_registry = 'ghcr.io'
/********************************************************************/

// universal params
params.container_registry = ""
params.container_version = ""
params.container = ""

// tool specific parmas go here, add / change as needed
params.bam = ""
params.target_intervals= ""
params.bait_intervals= ""
params.expected_output = ""

include { picardCollectHsMetrics } from '../main'


process file_smart_diff {
container "${params.container ?: container[params.container_registry ?: default_container_registry]}:${params.container_version ?: version}"

input:
path output_file
path expected_file

output:
stdout()

script:
"""
# we need to remove the date field from the files before comparison
grep -v 'Started on' ${output_file} > normalized_output
grep -v 'Started on' ${expected_file} > normalized_expected
diff normalized_output normalized_expected \
&& ( echo "Test PASSED" && exit 0 ) || ( echo "Test FAILED, output file mismatch." && exit 1 )
"""
}


workflow checker {
take:
bam
target_intervals
bait_intervals
expected_output

main:
picardCollectHsMetrics(
bam,
target_intervals,
bait_intervals
)

file_smart_diff(
picardCollectHsMetrics.out.output_file,
expected_output
)
}


workflow {
checker(
file(params.bam),
file(params.target_intervals),
file(params.bait_intervals),
file(params.expected_output)
)
}
Loading

0 comments on commit 83a7a6e

Please sign in to comment.