Skip to content

Commit d60d9ca

Browse files
committed
added starting template for payload-add-uniform-ids@0.1.0
1 parent 5c2054e commit d60d9ca

17 files changed

Lines changed: 378 additions & 0 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.gitignore
2+
.nextflow*
3+
tests
4+
work
5+
outdir

payload-add-uniform-ids/.gitignore

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
*.py[cod]
2+
3+
# C extensions
4+
*.so
5+
6+
# Packages
7+
*.egg
8+
*.egg-info
9+
dist
10+
build
11+
eggs
12+
.eggs
13+
parts
14+
bin
15+
var
16+
sdist
17+
develop-eggs
18+
.installed.cfg
19+
lib
20+
lib64
21+
venv*/
22+
pyvenv*/
23+
24+
# Installer logs
25+
pip-log.txt
26+
27+
# Unit test / coverage reports
28+
.coverage
29+
.tox
30+
.coverage.*
31+
nosetests.xml
32+
coverage.xml
33+
htmlcov
34+
35+
# Translations
36+
*.mo
37+
38+
# Mr Developer
39+
.mr.developer.cfg
40+
.project
41+
.pydevproject
42+
.idea
43+
*.iml
44+
*.komodoproject
45+
46+
# Complexity
47+
output/*.html
48+
output/*/index.html
49+
50+
# Sphinx
51+
docs/_build
52+
53+
.DS_Store
54+
*~
55+
.*.sw[po]
56+
.build
57+
.ve
58+
.env
59+
.cache
60+
.pytest
61+
.bootstrap
62+
.appveyor.token
63+
*.bak
64+
*.log
65+
.vscode
66+
.python-version
67+
.nextflow*
68+
work
69+
outdir

payload-add-uniform-ids/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM ubuntu:20.04
2+
3+
LABEL org.opencontainers.image.source https://github.com/icgc-argo/data-processing-utility-tools
4+
5+
ENV PATH="/tools:${PATH}"
6+
7+
COPY *.py /tools/
8+
9+
CMD ["/bin/bash"]

payload-add-uniform-ids/main.nf

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/usr/bin/env nextflow
2+
3+
/*
4+
Copyright (C) 2021, Ontario Institute for Cancer Research
5+
6+
This program is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU Affero General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
(at your option) any later version.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU Affero General Public License for more details.
15+
16+
You should have received a copy of the GNU Affero General Public License
17+
along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
19+
Authors:
20+
Junjun Zhang
21+
*/
22+
23+
/********************************************************************/
24+
/* this block is auto-generated based on info from pkg.json where */
25+
/* changes can be made if needed, do NOT modify this block manually */
26+
nextflow.enable.dsl = 2
27+
version = '0.1.0' // package version
28+
29+
container = [
30+
'ghcr.io': 'ghcr.io/icgc-argo/data-processing-utility-tools.payload-add-uniform-ids'
31+
]
32+
default_container_registry = 'ghcr.io'
33+
/********************************************************************/
34+
35+
36+
// universal params go here
37+
params.container_registry = ""
38+
params.container_version = ""
39+
params.container = ""
40+
41+
params.cpus = 1
42+
params.mem = 1 // GB
43+
params.publish_dir = "" // set to empty string will disable publishDir
44+
45+
46+
// tool specific parmas go here, add / change as needed
47+
params.input_file = ""
48+
params.output_pattern = "*" // output file name pattern
49+
50+
51+
process payloadAddUniformIds {
52+
container "${params.container ?: container[params.container_registry ?: default_container_registry]}:${params.container_version ?: version}"
53+
publishDir "${params.publish_dir}/${task.process.replaceAll(':', '_')}", mode: "copy", enabled: params.publish_dir
54+
55+
cpus params.cpus
56+
memory "${params.mem} GB"
57+
58+
input: // input, make update as needed
59+
path input_file
60+
61+
output: // output, make update as needed
62+
path "output_dir/${params.output_pattern}", emit: output_file
63+
64+
script:
65+
// add and initialize variables here as needed
66+
67+
"""
68+
mkdir -p output_dir
69+
70+
main.py \
71+
-i ${input_file} \
72+
-o output_dir
73+
74+
"""
75+
}
76+
77+
78+
// this provides an entry point for this main script, so it can be run directly without clone the repo
79+
// using this command: nextflow run <git_acc>/<repo>/<pkg_name>/<main_script>.nf -r <pkg_name>.v<pkg_version> --params-file xxx
80+
workflow {
81+
payloadAddUniformIds(
82+
file(params.input_file)
83+
)
84+
}

payload-add-uniform-ids/main.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
4+
"""
5+
Copyright (C) 2021, Ontario Institute for Cancer Research
6+
7+
This program is free software: you can redistribute it and/or modify
8+
it under the terms of the GNU Affero General Public License as published by
9+
the Free Software Foundation, either version 3 of the License, or
10+
(at your option) any later version.
11+
12+
This program is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU Affero General Public License for more details.
16+
17+
You should have received a copy of the GNU Affero General Public License
18+
along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
20+
Authors:
21+
Junjun Zhang
22+
"""
23+
24+
import os
25+
import sys
26+
import argparse
27+
import subprocess
28+
29+
30+
def main():
31+
"""
32+
Python implementation of tool: payload-add-uniform-ids
33+
34+
This is auto-generated Python code, please update as needed!
35+
"""
36+
37+
parser = argparse.ArgumentParser(description='Tool: payload-add-uniform-ids')
38+
parser.add_argument('-i', '--input-file', dest='input_file', type=str,
39+
help='Input file', required=True)
40+
parser.add_argument('-o', '--output-dir', dest='output_dir', type=str,
41+
help='Output directory', required=True)
42+
args = parser.parse_args()
43+
44+
if not os.path.isfile(args.input_file):
45+
sys.exit('Error: specified input file %s does not exist or is not accessible!' % args.input_file)
46+
47+
if not os.path.isdir(args.output_dir):
48+
sys.exit('Error: specified output dir %s does not exist or is not accessible!' % args.output_dir)
49+
50+
subprocess.run(f"cp {args.input_file} {args.output_dir}/", shell=True, check=True)
51+
52+
53+
if __name__ == "__main__":
54+
main()
55+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
docker {
2+
enabled = true
3+
runOptions = '-u \$(id -u):\$(id -g)'
4+
}

payload-add-uniform-ids/pkg.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "payload-add-uniform-ids",
3+
"version": "0.1.0",
4+
"description": "SONG payload utility tool for adding uniform IDs",
5+
"main": "main.nf",
6+
"deprecated": false,
7+
"keywords": [
8+
"bioinformatics",
9+
"metadata"
10+
],
11+
"repository": {
12+
"type": "git",
13+
"url": "https://github.com/icgc-argo/data-processing-utility-tools.git"
14+
},
15+
"container": {
16+
"registries": [
17+
{
18+
"registry": "ghcr.io",
19+
"type": "docker",
20+
"org": "icgc-argo",
21+
"default": true
22+
}
23+
]
24+
},
25+
"dependencies": [],
26+
"devDependencies": [],
27+
"contributors": [
28+
{
29+
"name": "Junjun Zhang",
30+
"email": "junjun.ca@gmail.com"
31+
}
32+
],
33+
"license": "GNU Affero General Public License v3",
34+
"bugReport": "https://github.com/icgc-argo/data-processing-utility-tools/issues",
35+
"homepage": "https://github.com/icgc-argo/data-processing-utility-tools#readme"
36+
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/usr/bin/env nextflow
2+
3+
/*
4+
Copyright (C) 2021, Ontario Institute for Cancer Research
5+
6+
This program is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU Affero General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
(at your option) any later version.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU Affero General Public License for more details.
15+
16+
You should have received a copy of the GNU Affero General Public License
17+
along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
19+
Authors:
20+
Junjun Zhang
21+
*/
22+
23+
/*
24+
This is an auto-generated checker workflow to test the generated main template workflow, it's
25+
meant to illustrate how testing works. Please update to suit your own needs.
26+
*/
27+
28+
/********************************************************************/
29+
/* this block is auto-generated based on info from pkg.json where */
30+
/* changes can be made if needed, do NOT modify this block manually */
31+
nextflow.enable.dsl = 2
32+
version = '0.1.0' // package version
33+
34+
container = [
35+
'ghcr.io': 'ghcr.io/icgc-argo/data-processing-utility-tools.payload-add-uniform-ids'
36+
]
37+
default_container_registry = 'ghcr.io'
38+
/********************************************************************/
39+
40+
// universal params
41+
params.container_registry = ""
42+
params.container_version = ""
43+
params.container = ""
44+
45+
// tool specific parmas go here, add / change as needed
46+
params.input_file = ""
47+
params.expected_output = ""
48+
49+
include { payloadAddUniformIds } from '../main'
50+
51+
52+
process file_smart_diff {
53+
container "${params.container ?: container[params.container_registry ?: default_container_registry]}:${params.container_version ?: version}"
54+
55+
input:
56+
path output_file
57+
path expected_file
58+
59+
output:
60+
stdout()
61+
62+
script:
63+
"""
64+
# Note: this is only for demo purpose, please write your own 'diff' according to your own needs.
65+
# remove date field before comparison eg, <div id="header_filename">Tue 19 Jan 2021<br/>test_rg_3.bam</div>
66+
# sed -e 's#"header_filename">.*<br/>test_rg_3.bam#"header_filename"><br/>test_rg_3.bam</div>#'
67+
68+
diff <( cat ${output_file} | sed -e 's#"header_filename">.*<br/>#"header_filename"><br/>#' ) \
69+
<( ([[ '${expected_file}' == *.gz ]] && gunzip -c ${expected_file} || cat ${expected_file}) | sed -e 's#"header_filename">.*<br/>#"header_filename"><br/>#' ) \
70+
&& ( echo "Test PASSED" && exit 0 ) || ( echo "Test FAILED, output file mismatch." && exit 1 )
71+
"""
72+
}
73+
74+
75+
workflow checker {
76+
take:
77+
input_file
78+
expected_output
79+
80+
main:
81+
payloadAddUniformIds(
82+
input_file
83+
)
84+
85+
file_smart_diff(
86+
payloadAddUniformIds.out.output_file,
87+
expected_output
88+
)
89+
}
90+
91+
92+
workflow {
93+
checker(
94+
file(params.input_file),
95+
file(params.expected_output)
96+
)
97+
}
14.6 KB
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)