Skip to content

Commit

Permalink
Merge pull request #1 from ICGC-TCGA-PanCancer/fastqc@0.1.0
Browse files Browse the repository at this point in the history
[release] fastqc@0.1.0
  • Loading branch information
junjun-zhang authored Feb 1, 2021
2 parents 040b617 + d4d2268 commit c3e92a2
Show file tree
Hide file tree
Showing 16 changed files with 302 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fastqc/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.gitignore
.nextflow*
tests
work
outdir
69 changes: 69 additions & 0 deletions fastqc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
*.py[cod]

# C extensions
*.so

# Packages
*.egg
*.egg-info
dist
build
eggs
.eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg
lib
lib64
venv*/
pyvenv*/

# Installer logs
pip-log.txt

# Unit test / coverage reports
.coverage
.tox
.coverage.*
nosetests.xml
coverage.xml
htmlcov

# Translations
*.mo

# Mr Developer
.mr.developer.cfg
.project
.pydevproject
.idea
*.iml
*.komodoproject

# Complexity
output/*.html
output/*/index.html

# Sphinx
docs/_build

.DS_Store
*~
.*.sw[po]
.build
.ve
.env
.cache
.pytest
.bootstrap
.appveyor.token
*.bak
*.log
.vscode
.python-version
.nextflow*
work
outdir
9 changes: 9 additions & 0 deletions fastqc/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM pegi3s/fastqc:0.11.9

LABEL org.opencontainers.image.source https://github.com/icgc-tcga-pancancer/demo-tool-pkgs

ENV PATH="/tools:${PATH}"

COPY *.py /tools/

CMD ["/bin/bash"]
54 changes: 54 additions & 0 deletions fastqc/fastqc.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env nextflow

/********************************************************************/
/* 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' // tool version

container = [
'ghcr.io': 'ghcr.io/icgc-tcga-pancancer/demo-tool-pkgs.fastqc'
]
default_container_registry = 'ghcr.io'
/********************************************************************/


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

params.cpus = 1
params.mem = 1 // GB
params.publish_dir = "" // set to empty string will disable publishDir


// tool specific parmas go here, add / change as needed
params.input_file = ""
params.output_pattern = "*.html" // fastqc output html report


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

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

input: // input, make update as needed
path input_file

output: // output, make update as needed
path "output_dir/${params.output_pattern}", emit: output

script:
// add and initialize variables here as needed

"""
mkdir -p output_dir
fastqc.py \
-i ${input_file} \
-o output_dir
"""
}
34 changes: 34 additions & 0 deletions fastqc/fastqc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import sys
import argparse
import subprocess


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

parser = argparse.ArgumentParser(description='Tool: fastqc')
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"fastqc -o {args.output_dir} {args.input_file}", shell=True, check=True)


if __name__ == "__main__":
main()
4 changes: 4 additions & 0 deletions fastqc/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)'
}
40 changes: 40 additions & 0 deletions fastqc/pkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "fastqc",
"version": "0.1.0",
"description": "FastQC tool",
"main": "fastqc",
"scripts": {
"test": "wfpm test"
},
"deprecated": false,
"keywords": [
"bioinformatics",
"seq",
"qc metrics"
],
"repository": {
"type": "git",
"url": "https://github.com/icgc-tcga-pancancer/demo-tool-pkgs.git"
},
"container": {
"registries": [
{
"registry": "ghcr.io",
"type": "docker",
"org": "icgc-tcga-pancancer",
"default": true
}
]
},
"dependencies": [],
"devDependencies": [],
"contributors": [
{
"name": "Junjun Zhang",
"email": "junjun.ca@gmail.com"
}
],
"license": "MIT",
"bugReport": "https://github.com/icgc-tcga-pancancer/demo-tool-pkgs/issues",
"homepage": "https://github.com/icgc-tcga-pancancer/demo-tool-pkgs#readme"
}
75 changes: 75 additions & 0 deletions fastqc/tests/checker.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env nextflow

/********************************************************************/
/* 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' // tool version

container = [
'ghcr.io': 'ghcr.io/icgc-tcga-pancancer/demo-tool-pkgs.fastqc'
]
default_container_registry = 'ghcr.io'
/********************************************************************/

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


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

include { fastqc } from '../fastqc'

Channel
.fromPath(params.input_file, checkIfExists: true)
.set { input_file }


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

input:
path output_file
path expected_gzip

output:
stdout()

script:
"""
# remove date field before comparison eg, <div id="header_filename">Tue 19 Jan 2021<br/>test_rg_3.bam</div>
# sed -e 's#"header_filename">.*<br/>test_rg_3.bam#"header_filename"><br/>test_rg_3.bam</div>#'
diff <( cat ${output_file} | sed -e 's#"header_filename">.*<br/>test_rg_3.bam#"header_filename"><br/>test_rg_3.bam</div>#' ) \
<( gunzip -c ${expected_gzip} | sed -e 's#"header_filename">.*<br/>test_rg_3.bam#"header_filename"><br/>test_rg_3.bam</div>#' ) \
&& ( echo "Test PASSED" && exit 0 ) || ( echo "Test FAILED, output file mismatch." && exit 1 )
"""
}


workflow checker {
take:
input_file
expected_output

main:
fastqc(
input_file
)

file_diff(
fastqc.out.output,
expected_output
)
}


workflow {
checker(
file(params.input_file),
file(params.expected_output)
)
}
1 change: 1 addition & 0 deletions fastqc/tests/expected/expected.input_file_name.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The input file name is README.md
Binary file not shown.
1 change: 1 addition & 0 deletions fastqc/tests/input/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This folder contains tiny data files for testing.
Binary file added fastqc/tests/input/test_rg_3.bam
Binary file not shown.
1 change: 1 addition & 0 deletions fastqc/tests/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
includeConfig '../nextflow.config'
7 changes: 7 additions & 0 deletions fastqc/tests/test-job-1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"input_file": "input/test_rg_3.bam",
"expected_output": "expected/expected.test_rg_3_fastqc.out.gz",
"publish_dir": "outdir",
"cpus": 1,
"mem": 0.5
}
1 change: 1 addition & 0 deletions fastqc/tests/wfpr_modules
1 change: 1 addition & 0 deletions fastqc/wfpr_modules

0 comments on commit c3e92a2

Please sign in to comment.