Added all modules with basic functionality and updated meta.yml files.

This commit is contained in:
Sruthi Suresh 2020-11-12 20:42:47 -06:00 committed by sruthipsuresh
parent 89e5473b44
commit a984c1be7c
33 changed files with 1081 additions and 9 deletions

View file

@ -45,9 +45,13 @@ output:
- bed: - bed:
type: file type: file
description: Edited bed file description: Edited bed file
pattern: "*.{slopbed}" pattern: "*.{complement.bed}"
- version: - version:
type: file type: file
description: File containing software version description: File containing software version
pattern: "*.{version.txt}" pattern: "*.{version.txt}"
authors:
-"@Emiller88"
-"@sruthipsuresh"

View file

@ -0,0 +1,60 @@
/*
* -----------------------------------------------------
* Utility functions used in nf-core DSL2 module files
* -----------------------------------------------------
*/
/*
* Extract name of software tool from process name using $task.process
*/
def getSoftwareName(task_process) {
return task_process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()
}
/*
* Function to initialise default values and to generate a Groovy Map of available options for nf-core modules
*/
def initOptions(Map args) {
def Map options = [:]
options.args = args.args ?: ''
options.args2 = args.args2 ?: ''
options.publish_by_id = args.publish_by_id ?: false
options.publish_dir = args.publish_dir ?: ''
options.publish_files = args.publish_files
options.suffix = args.suffix ?: ''
options.sizeA - args.sizeA ?: '-sizeA'
return options
}
/*
* Tidy up and join elements of a list to return a path string
*/
def getPathFromList(path_list) {
def paths = path_list.findAll { item -> !item?.trim().isEmpty() } // Remove empty entries
paths = paths.collect { it.trim().replaceAll("^[/]+|[/]+\$", "") } // Trim whitespace and trailing slashes
return paths.join('/')
}
/*
* Function to save/publish module results
*/
def saveFiles(Map args) {
if (!args.filename.endsWith('.version.txt')) {
def ioptions = initOptions(args.options)
def path_list = [ ioptions.publish_dir ?: args.publish_dir ]
if (ioptions.publish_by_id) {
path_list.add(args.publish_id)
}
if (ioptions.publish_files instanceof Map) {
for (ext in ioptions.publish_files) {
if (args.filename.endsWith(ext.key)) {
def ext_list = path_list.collect()
ext_list.add(ext.value)
return "${getPathFromList(ext_list)}/$args.filename"
}
}
} else if (ioptions.publish_files == null) {
return "${getPathFromList(path_list)}/$args.filename"
}
}
}

View file

@ -0,0 +1,31 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
def options = initOptions(params.options)
process BEDTOOLS_GENOMECOV {
tag "$meta.id"
label 'process_medium'
publishDir "${params.outdir}",
mode: params.publish_dir_mode,
saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) }
conda (params.enable_conda ? "bioconda::bedtools =2.29.2" : null)
container "quay.io/biocontainers/bedtools:2.29.2--hc088bd4_0"
input:
tuple val(meta), path(bams)
path sizes
output:
tuple val(meta), path("*.bed"), emit: coverage
path "*.version.txt", emit: version
script:
def software = getSoftwareName(task.process)
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
"""
bedtools genomecov -ibam $bams -g $sizes ${options.args} > ${prefix}.bed
bedtools --version | sed -e "s/Bedtools v//g" > ${software}.version.txt
"""
}

View file

@ -0,0 +1,58 @@
name: bedtools_genomecov
description: Computes histograms (default), per-base reports (-d) and BEDGRAPH (-bg) summaries of feature coverage (e.g., aligned sequences) for a given genome.
keywords:
- bed
- bam
- genomecov
tools:
- bedtools:
description: |
A set of tools for genomic analysis tasks, specifically enabling genome arithmetic (merge, count, complement) on various file types.
documentation: https://bedtools.readthedocs.io/en/latest/
params:
- outdir:
type: string
description: |
The pipeline's output directory. By default, the module will
output files into `$params.outdir/<SOFTWARE>`
- publish_dir_mode:
type: string
description: |
Value for the Nextflow `publishDir` mode parameter.
Available: symlink, rellink, link, copy, copyNoFollow, move.
- enable_conda:
type: boolean
description: |
Run the module with Conda using the software specified
via the `conda` directive
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- bam:
type: file
description: List of bam files
pattern: "*.{bed}"
output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- bed:
type: file
description: Computed bed file
pattern: "*.{bed}"
- version:
type: file
description: File containing software version
pattern: "*.{version.txt}"
authors:
-"@Emiller88"
-"@sruthipsuresh"

View file

@ -0,0 +1 @@
chr1 1780869

View file

@ -0,0 +1,23 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { BEDTOOLS_GENOMECOV } from '../main.nf' addParams( options: [publish_dir:'test_bed_file'] )
// Define input channels
// Run the workflow
workflow test_bed_file {
def input = []
input = [ [ id:'test'],
[ file("${baseDir}/input/JK2067_downsampled_s0.1.bam", checkIfExists: true),] ]
BEDTOOLS_GENOMECOV (
input,
file("${baseDir}/input/genome.sizes", checkIfExists: true) )
}
workflow {
test_bed_file()
}

View file

@ -0,0 +1,20 @@
params {
outdir = "output/"
publish_dir_mode = "copy"
enable_conda = false
}
profiles {
conda {
params.enable_conda = true
}
docker {
docker.enabled = true
docker.runOptions = '-u \$(id -u):\$(id -g)'
}
singularity {
singularity.enabled = true
singularity.autoMounts = true
}
}

View file

@ -0,0 +1,294 @@
1 0 249204716 249250621 0.999816
1 1 43780 249250621 0.000175647
1 2 1412 249250621 5.66498e-06
1 3 539 249250621 2.16248e-06
1 4 96 249250621 3.85154e-07
1 5 58 249250621 2.32698e-07
1 6 20 249250621 8.02405e-08
2 0 243163429 243199373 0.999852
2 1 34966 243199373 0.000143775
2 2 788 243199373 3.24014e-06
2 3 108 243199373 4.4408e-07
2 4 6 243199373 2.46711e-08
2 5 7 243199373 2.8783e-08
2 6 18 243199373 7.40134e-08
2 7 9 243199373 3.70067e-08
2 8 22 243199373 9.04608e-08
2 9 20 243199373 8.22371e-08
3 0 197987095 198022430 0.999822
3 1 34330 198022430 0.000173364
3 2 846 198022430 4.27224e-06
3 3 133 198022430 6.71641e-07
3 4 6 198022430 3.02996e-08
3 5 9 198022430 4.54494e-08
3 6 11 198022430 5.55493e-08
4 0 191126526 191154276 0.999855
4 1 26574 191154276 0.000139019
4 2 1004 191154276 5.2523e-06
4 3 82 191154276 4.28973e-07
4 4 83 191154276 4.34204e-07
4 5 7 191154276 3.66196e-08
5 0 180886808 180915260 0.999843
5 1 27410 180915260 0.000151507
5 2 923 180915260 5.10184e-06
5 3 118 180915260 6.52239e-07
5 4 1 180915260 5.52745e-09
6 0 171084991 171115067 0.999824
6 1 28629 171115067 0.000167308
6 2 1305 171115067 7.62645e-06
6 3 92 171115067 5.3765e-07
6 4 25 171115067 1.46101e-07
6 5 12 171115067 7.01282e-08
6 6 7 171115067 4.09081e-08
6 7 6 171115067 3.50641e-08
7 0 159111304 159138663 0.999828
7 1 26666 159138663 0.000167565
7 2 440 159138663 2.76488e-06
7 3 183 159138663 1.14994e-06
7 4 70 159138663 4.39868e-07
8 0 146341699 146364022 0.999848
8 1 21455 146364022 0.000146587
8 2 759 146364022 5.1857e-06
8 3 37 146364022 2.52794e-07
8 4 72 146364022 4.91924e-07
9 0 141187603 141213431 0.999817
9 1 24761 141213431 0.000175345
9 2 998 141213431 7.06732e-06
9 3 13 141213431 9.20592e-08
9 4 30 141213431 2.12444e-07
9 5 26 141213431 1.84118e-07
10 0 135509469 135534747 0.999813
10 1 24236 135534747 0.000178818
10 2 776 135534747 5.72547e-06
10 3 167 135534747 1.23216e-06
10 4 11 135534747 8.116e-08
10 5 7 135534747 5.16473e-08
10 6 4 135534747 2.95127e-08
10 7 1 135534747 7.37818e-09
10 8 2 135534747 1.47564e-08
10 9 4 135534747 2.95127e-08
10 10 3 135534747 2.21345e-08
10 11 8 135534747 5.90255e-08
10 12 2 135534747 1.47564e-08
10 13 7 135534747 5.16473e-08
10 14 9 135534747 6.64036e-08
10 15 3 135534747 2.21345e-08
10 16 7 135534747 5.16473e-08
10 17 5 135534747 3.68909e-08
10 18 26 135534747 1.91833e-07
11 0 134983075 135006516 0.999826
11 1 22281 135006516 0.000165036
11 2 904 135006516 6.69597e-06
11 3 191 135006516 1.41475e-06
11 4 4 135006516 2.96282e-08
11 5 61 135006516 4.5183e-07
12 0 133825601 133851895 0.999804
12 1 25225 133851895 0.000188455
12 2 801 133851895 5.98423e-06
12 3 145 133851895 1.08329e-06
12 4 55 133851895 4.10902e-07
12 5 4 133851895 2.98838e-08
12 6 64 133851895 4.7814e-07
13 0 115155062 115169878 0.999871
13 1 14274 115169878 0.000123939
13 2 347 115169878 3.01294e-06
13 3 142 115169878 1.23296e-06
13 4 24 115169878 2.08388e-07
13 5 11 115169878 9.55111e-08
13 6 18 115169878 1.56291e-07
14 0 107333562 107349540 0.999851
14 1 15532 107349540 0.000144686
14 2 191 107349540 1.77923e-06
14 3 121 107349540 1.12716e-06
14 4 88 107349540 8.19752e-07
14 5 46 107349540 4.28507e-07
15 0 102515396 102531392 0.999844
15 1 15486 102531392 0.000151037
15 2 366 102531392 3.56964e-06
15 3 144 102531392 1.40445e-06
16 0 90333722 90354753 0.999767
16 1 20001 90354753 0.000221361
16 2 820 90354753 9.07534e-06
16 3 71 90354753 7.85792e-07
16 4 44 90354753 4.86969e-07
16 5 11 90354753 1.21742e-07
16 6 5 90354753 5.53374e-08
16 7 3 90354753 3.32025e-08
16 8 2 90354753 2.2135e-08
16 9 5 90354753 5.53374e-08
16 10 6 90354753 6.64049e-08
16 11 3 90354753 3.32025e-08
16 12 3 90354753 3.32025e-08
16 13 12 90354753 1.3281e-07
16 14 2 90354753 2.2135e-08
16 15 20 90354753 2.2135e-07
16 16 23 90354753 2.54552e-07
17 0 81170932 81195210 0.999701
17 1 23491 81195210 0.000289315
17 2 692 81195210 8.52267e-06
17 3 11 81195210 1.35476e-07
17 4 17 81195210 2.09372e-07
17 5 10 81195210 1.2316e-07
17 6 34 81195210 4.18744e-07
17 7 23 81195210 2.83268e-07
18 0 78063262 78077248 0.999821
18 1 13667 78077248 0.000175045
18 2 262 78077248 3.35565e-06
18 3 19 78077248 2.43349e-07
18 4 33 78077248 4.22658e-07
18 5 5 78077248 6.40391e-08
19 0 59108190 59128983 0.999648
19 1 19902 59128983 0.000336586
19 2 610 59128983 1.03164e-05
19 3 27 59128983 4.56629e-07
19 4 116 59128983 1.96181e-06
19 5 33 59128983 5.58102e-07
19 6 44 59128983 7.44136e-07
19 7 3 59128983 5.07365e-08
19 8 3 59128983 5.07365e-08
19 9 19 59128983 3.21331e-07
19 10 9 59128983 1.5221e-07
19 11 27 59128983 4.56629e-07
20 0 63012076 63025520 0.999787
20 1 12945 63025520 0.000205393
20 2 397 63025520 6.29904e-06
20 3 102 63025520 1.61839e-06
21 0 48122958 48129895 0.999856
21 1 6643 48129895 0.000138022
21 2 149 48129895 3.09579e-06
21 3 91 48129895 1.89072e-06
21 4 15 48129895 3.11657e-07
21 5 39 48129895 8.10307e-07
22 0 51293939 51304566 0.999793
22 1 10237 51304566 0.000199534
22 2 285 51304566 5.55506e-06
22 3 105 51304566 2.0466e-06
X 0 155247415 155270560 0.999851
X 1 22268 155270560 0.000143414
X 2 756 155270560 4.86892e-06
X 3 50 155270560 3.22019e-07
X 4 18 155270560 1.15927e-07
X 5 18 155270560 1.15927e-07
X 6 4 155270560 2.57615e-08
X 7 3 155270560 1.93211e-08
X 8 9 155270560 5.79633e-08
X 9 7 155270560 4.50826e-08
X 10 12 155270560 7.72845e-08
Y 0 59371245 59373566 0.999961
Y 1 2321 59373566 3.90915e-05
MT 0 3945 16569 0.238095
MT 1 4850 16569 0.292715
MT 2 3384 16569 0.204237
MT 3 2390 16569 0.144245
MT 4 1097 16569 0.066208
MT 5 575 16569 0.0347034
MT 6 224 16569 0.0135192
MT 7 93 16569 0.00561289
MT 8 11 16569 0.00066389
GL000226.1 0 14927 15008 0.994603
GL000226.1 1 81 15008 0.00539712
GL000240.1 0 41815 41933 0.997186
GL000240.1 1 109 41933 0.00259938
GL000240.1 2 9 41933 0.000214628
GL000243.1 0 43287 43341 0.998754
GL000243.1 1 54 43341 0.00124593
GL000237.1 0 45784 45867 0.99819
GL000237.1 1 83 45867 0.00180958
GL000191.1 0 106392 106433 0.999615
GL000191.1 1 41 106433 0.000385219
GL000227.1 0 128301 128374 0.999431
GL000227.1 1 73 128374 0.000568651
GL000228.1 0 128928 129120 0.998513
GL000228.1 1 192 129120 0.00148699
GL000214.1 0 137590 137718 0.999071
GL000214.1 1 128 137718 0.000929436
GL000221.1 0 155362 155397 0.999775
GL000221.1 1 35 155397 0.00022523
GL000220.1 0 159710 161802 0.987071
GL000220.1 1 1762 161802 0.0108899
GL000220.1 2 298 161802 0.00184176
GL000220.1 3 17 161802 0.000105067
GL000220.1 4 15 161802 9.27059e-05
GL000213.1 0 164203 164239 0.999781
GL000213.1 1 36 164239 0.000219193
GL000211.1 0 166452 166566 0.999316
GL000211.1 1 114 166566 0.000684413
GL000217.1 0 172108 172149 0.999762
GL000217.1 1 41 172149 0.000238166
GL000224.1 0 179651 179693 0.999766
GL000224.1 1 42 179693 0.000233732
GL000212.1 0 186823 186858 0.999813
GL000212.1 1 35 186858 0.000187308
GL000222.1 0 186783 186861 0.999583
GL000222.1 1 78 186861 0.000417423
GL000200.1 0 186924 187035 0.999407
GL000200.1 1 111 187035 0.000593472
GL000194.1 0 191355 191469 0.999405
GL000194.1 1 114 191469 0.000595397
GL000225.1 0 211019 211173 0.999271
GL000225.1 1 154 211173 0.00072926
GL000192.1 0 547447 547496 0.99991
GL000192.1 1 49 547496 8.94984e-05
hs37d5 0 35470929 35477943 0.999802
hs37d5 1 6883 35477943 0.000194008
hs37d5 2 111 35477943 3.1287e-06
hs37d5 3 20 35477943 5.63731e-07
GL000207.1 0 4262 4262 1
GL000229.1 0 19913 19913 1
GL000231.1 0 27386 27386 1
GL000210.1 0 27682 27682 1
GL000239.1 0 33824 33824 1
GL000235.1 0 34474 34474 1
GL000201.1 0 36148 36148 1
GL000247.1 0 36422 36422 1
GL000245.1 0 36651 36651 1
GL000197.1 0 37175 37175 1
GL000203.1 0 37498 37498 1
GL000246.1 0 38154 38154 1
GL000249.1 0 38502 38502 1
GL000196.1 0 38914 38914 1
GL000248.1 0 39786 39786 1
GL000244.1 0 39929 39929 1
GL000238.1 0 39939 39939 1
GL000202.1 0 40103 40103 1
GL000234.1 0 40531 40531 1
GL000232.1 0 40652 40652 1
GL000206.1 0 41001 41001 1
GL000236.1 0 41934 41934 1
GL000241.1 0 42152 42152 1
GL000242.1 0 43523 43523 1
GL000230.1 0 43691 43691 1
GL000233.1 0 45941 45941 1
GL000204.1 0 81310 81310 1
GL000198.1 0 90085 90085 1
GL000208.1 0 92689 92689 1
GL000209.1 0 159169 159169 1
GL000218.1 0 161147 161147 1
GL000199.1 0 169874 169874 1
GL000216.1 0 172294 172294 1
GL000215.1 0 172545 172545 1
GL000205.1 0 174588 174588 1
GL000219.1 0 179198 179198 1
GL000223.1 0 180455 180455 1
GL000195.1 0 182896 182896 1
GL000193.1 0 189789 189789 1
NC_007605 0 171823 171823 1
genome 0 3136893859 3137454505 0.999821
genome 1 532145 3137454505 0.00016961
genome 2 19633 3137454505 6.25762e-06
genome 3 5118 3137454505 1.63126e-06
genome 4 1926 3137454505 6.13873e-07
genome 5 939 3137454505 2.99287e-07
genome 6 453 3137454505 1.44385e-07
genome 7 141 3137454505 4.49409e-08
genome 8 49 3137454505 1.56178e-08
genome 9 55 3137454505 1.75301e-08
genome 10 30 3137454505 9.56189e-09
genome 11 38 3137454505 1.21117e-08
genome 12 5 3137454505 1.59365e-09
genome 13 19 3137454505 6.05586e-09
genome 14 11 3137454505 3.50603e-09
genome 15 23 3137454505 7.33078e-09
genome 16 30 3137454505 9.56189e-09
genome 17 5 3137454505 1.59365e-09
genome 18 26 3137454505 8.28697e-09

View file

@ -0,0 +1,59 @@
/*
* -----------------------------------------------------
* Utility functions used in nf-core DSL2 module files
* -----------------------------------------------------
*/
/*
* Extract name of software tool from process name using $task.process
*/
def getSoftwareName(task_process) {
return task_process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()
}
/*
* Function to initialise default values and to generate a Groovy Map of available options for nf-core modules
*/
def initOptions(Map args) {
def Map options = [:]
options.args = args.args ?: ''
options.args2 = args.args2 ?: ''
options.publish_by_id = args.publish_by_id ?: false
options.publish_dir = args.publish_dir ?: ''
options.publish_files = args.publish_files
options.suffix = args.suffix ?: ''
return options
}
/*
* Tidy up and join elements of a list to return a path string
*/
def getPathFromList(path_list) {
def paths = path_list.findAll { item -> !item?.trim().isEmpty() } // Remove empty entries
paths = paths.collect { it.trim().replaceAll("^[/]+|[/]+\$", "") } // Trim whitespace and trailing slashes
return paths.join('/')
}
/*
* Function to save/publish module results
*/
def saveFiles(Map args) {
if (!args.filename.endsWith('.version.txt')) {
def ioptions = initOptions(args.options)
def path_list = [ ioptions.publish_dir ?: args.publish_dir ]
if (ioptions.publish_by_id) {
path_list.add(args.publish_id)
}
if (ioptions.publish_files instanceof Map) {
for (ext in ioptions.publish_files) {
if (args.filename.endsWith(ext.key)) {
def ext_list = path_list.collect()
ext_list.add(ext.value)
return "${getPathFromList(ext_list)}/$args.filename"
}
}
} else if (ioptions.publish_files == null) {
return "${getPathFromList(path_list)}/$args.filename"
}
}
}

View file

@ -0,0 +1,30 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
def options = initOptions(params.options)
process BEDTOOLS_INTERSECT {
tag "$meta.id"
label 'process_medium'
publishDir "${params.outdir}",
mode: params.publish_dir_mode,
saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) }
conda (params.enable_conda ? "bioconda::bedtools =2.29.2" : null)
container "quay.io/biocontainers/bedtools:2.29.2--hc088bd4_0"
input:
tuple val(meta), path(beds)
output:
tuple val(meta), path("*.intersect.bed"), emit: intersect
path "*.version.txt", emit: version
script: // TODO change script to account for multiple possible intersections
def software = getSoftwareName(task.process)
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
"""
bedtools intersect -a ${beds[0]} -b ${beds[1]} ${options.args} > ${prefix}.intersect.bed
bedtools --version | sed -e "s/Bedtools v//g" > ${software}.version.txt
"""
}

View file

@ -0,0 +1,58 @@
name: bedtools_intersect
description: allows one to screen for overlaps between two sets of genomic features.
keywords:
- bed
- intersect
tools:
- bedtools:
description: |
A set of tools for genomic analysis tasks, specifically enabling genome arithmetic (merge, count, complement) on various file types.
documentation: https://bedtools.readthedocs.io/en/latest/
params:
- outdir:
type: string
description: |
The pipeline's output directory. By default, the module will
output files into `$params.outdir/<SOFTWARE>`
- publish_dir_mode:
type: string
description: |
Value for the Nextflow `publishDir` mode parameter.
Available: symlink, rellink, link, copy, copyNoFollow, move.
- enable_conda:
type: boolean
description: |
Run the module with Conda using the software specified
via the `conda` directive
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- bed:
type: file
description: List of bed files
pattern: "*.{bed}"
output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- bed:
type: file
description: Overlapped bed file
pattern: "*.{intersect.bed}"
- version:
type: file
description: File containing software version
pattern: "*.{version.txt}"
authors:
-"@Emiller88"
-"@sruthipsuresh"

View file

@ -0,0 +1,5 @@
chr1 951 1061
chr1 1300 1420
chr1 1400 1500

View file

@ -0,0 +1 @@
chr1 999 1010

View file

@ -0,0 +1,19 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { BEDTOOLS_INTERSECT } from '../main.nf' addParams( options: [publish_dir:'test_bed_file'] )
// Run the workflow
workflow test_bed_file {
def input = []
input = [ [ id:'test'],
[ file("${baseDir}/input/A.bed", checkIfExists: true),
file("${baseDir}/input/B.bed", checkIfExists: true) ] ]
BEDTOOLS_INTERSECT( input )
}
workflow {
test_bed_file()
}

View file

@ -0,0 +1,20 @@
params {
outdir = "output/"
publish_dir_mode = "copy"
enable_conda = false
}
profiles {
conda {
params.enable_conda = true
}
docker {
docker.enabled = true
docker.runOptions = '-u \$(id -u):\$(id -g)'
}
singularity {
singularity.enabled = true
singularity.autoMounts = true
}
}

View file

@ -0,0 +1 @@
chr1 999 1010

View file

@ -0,0 +1,59 @@
/*
* -----------------------------------------------------
* Utility functions used in nf-core DSL2 module files
* -----------------------------------------------------
*/
/*
* Extract name of software tool from process name using $task.process
*/
def getSoftwareName(task_process) {
return task_process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()
}
/*
* Function to initialise default values and to generate a Groovy Map of available options for nf-core modules
*/
def initOptions(Map args) {
def Map options = [:]
options.args = args.args ?: ''
options.args2 = args.args2 ?: ''
options.publish_by_id = args.publish_by_id ?: false
options.publish_dir = args.publish_dir ?: ''
options.publish_files = args.publish_files
options.suffix = args.suffix ?: ''
return options
}
/*
* Tidy up and join elements of a list to return a path string
*/
def getPathFromList(path_list) {
def paths = path_list.findAll { item -> !item?.trim().isEmpty() } // Remove empty entries
paths = paths.collect { it.trim().replaceAll("^[/]+|[/]+\$", "") } // Trim whitespace and trailing slashes
return paths.join('/')
}
/*
* Function to save/publish module results
*/
def saveFiles(Map args) {
if (!args.filename.endsWith('.version.txt')) {
def ioptions = initOptions(args.options)
def path_list = [ ioptions.publish_dir ?: args.publish_dir ]
if (ioptions.publish_by_id) {
path_list.add(args.publish_id)
}
if (ioptions.publish_files instanceof Map) {
for (ext in ioptions.publish_files) {
if (args.filename.endsWith(ext.key)) {
def ext_list = path_list.collect()
ext_list.add(ext.value)
return "${getPathFromList(ext_list)}/$args.filename"
}
}
} else if (ioptions.publish_files == null) {
return "${getPathFromList(path_list)}/$args.filename"
}
}
}

View file

@ -0,0 +1,30 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
def options = initOptions(params.options)
process BEDTOOLS_MERGE {
tag "$meta.id"
label 'process_medium'
publishDir "${params.outdir}",
mode: params.publish_dir_mode,
saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) }
conda (params.enable_conda ? "bioconda::bedtools =2.29.2" : null)
container "quay.io/biocontainers/bedtools:2.29.2--hc088bd4_0"
input:
tuple val(meta), path(beds)
output:
tuple val(meta), path("*.merged.bed"), emit: merge
path "*.version.txt", emit: version
script:
def software = getSoftwareName(task.process)
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
"""
bedtools merge -i $beds ${options.args} > ${prefix}.merged.bed
bedtools --version | sed -e "s/Bedtools v//g" > ${software}.version.txt
"""
}

View file

@ -0,0 +1,58 @@
name: bedtools_merge
description: combines overlapping or “book-ended” features in an interval file into a single feature which spans all of the combined features.
keywords:
- bed
- merge
tools:
- bedtools:
description: |
A set of tools for genomic analysis tasks, specifically enabling genome arithmetic (merge, count, complement) on various file types.
documentation: https://bedtools.readthedocs.io/en/latest/
params:
- outdir:
type: string
description: |
The pipeline's output directory. By default, the module will
output files into `$params.outdir/<SOFTWARE>`
- publish_dir_mode:
type: string
description: |
Value for the Nextflow `publishDir` mode parameter.
Available: symlink, rellink, link, copy, copyNoFollow, move.
- enable_conda:
type: boolean
description: |
Run the module with Conda using the software specified
via the `conda` directive
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- bed:
type: file
description: List of bed files
pattern: "*.{bed}"
output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- bed:
type: file
description: Overlapped bed file
pattern: "*.{merged.bed}"
- version:
type: file
description: File containing software version
pattern: "*.{version.txt}"
authors:
-"@Emiller88"
-"@sruthipsuresh"

View file

@ -0,0 +1,5 @@
chr1 951 1061
chr1 1300 1420
chr1 1400 1500

View file

@ -0,0 +1,20 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { BEDTOOLS_MERGE } from '../main.nf' addParams( options: [publish_dir:'test_bed_file'] )
// Define input channels
// TODO ensure input file is presorted (could use output of sort module)
// Run the workflow
workflow test_bed_file {
def input = []
input = [ [ id:'test'],
[ file("${baseDir}/input/A.bed", checkIfExists: true),] ]
BEDTOOLS_MERGE( input )
}
workflow {
test_bed_file()
}

View file

@ -0,0 +1,20 @@
params {
outdir = "output/"
publish_dir_mode = "copy"
enable_conda = false
}
profiles {
conda {
params.enable_conda = true
}
docker {
docker.enabled = true
docker.runOptions = '-u \$(id -u):\$(id -g)'
}
singularity {
singularity.enabled = true
singularity.autoMounts = true
}
}

View file

@ -0,0 +1,2 @@
chr1 951 1061
chr1 1300 1500

View file

@ -22,12 +22,6 @@ def initOptions(Map args) {
options.publish_dir = args.publish_dir ?: '' options.publish_dir = args.publish_dir ?: ''
options.publish_files = args.publish_files options.publish_files = args.publish_files
options.suffix = args.suffix ?: '' options.suffix = args.suffix ?: ''
options.l = args.l ?: ''
options.r = args.r ?: ''
options.b = args.b ?: ''
options.s = args.s ?: ''
options.pct = args.pct ?: true
options.header = args.header ?: true
return options return options
} }

View file

@ -73,3 +73,7 @@ output:
type: file type: file
description: File containing software version description: File containing software version
pattern: "*.{version.txt}" pattern: "*.{version.txt}"
authors:
-"@Emiller88"
-"@sruthipsuresh"

View file

@ -0,0 +1,59 @@
/*
* -----------------------------------------------------
* Utility functions used in nf-core DSL2 module files
* -----------------------------------------------------
*/
/*
* Extract name of software tool from process name using $task.process
*/
def getSoftwareName(task_process) {
return task_process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()
}
/*
* Function to initialise default values and to generate a Groovy Map of available options for nf-core modules
*/
def initOptions(Map args) {
def Map options = [:]
options.args = args.args ?: ''
options.args2 = args.args2 ?: ''
options.publish_by_id = args.publish_by_id ?: false
options.publish_dir = args.publish_dir ?: ''
options.publish_files = args.publish_files
options.suffix = args.suffix ?: ''
return options
}
/*
* Tidy up and join elements of a list to return a path string
*/
def getPathFromList(path_list) {
def paths = path_list.findAll { item -> !item?.trim().isEmpty() } // Remove empty entries
paths = paths.collect { it.trim().replaceAll("^[/]+|[/]+\$", "") } // Trim whitespace and trailing slashes
return paths.join('/')
}
/*
* Function to save/publish module results
*/
def saveFiles(Map args) {
if (!args.filename.endsWith('.version.txt')) {
def ioptions = initOptions(args.options)
def path_list = [ ioptions.publish_dir ?: args.publish_dir ]
if (ioptions.publish_by_id) {
path_list.add(args.publish_id)
}
if (ioptions.publish_files instanceof Map) {
for (ext in ioptions.publish_files) {
if (args.filename.endsWith(ext.key)) {
def ext_list = path_list.collect()
ext_list.add(ext.value)
return "${getPathFromList(ext_list)}/$args.filename"
}
}
} else if (ioptions.publish_files == null) {
return "${getPathFromList(path_list)}/$args.filename"
}
}
}

View file

@ -0,0 +1,30 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
def options = initOptions(params.options)
process BEDTOOLS_SORT {
tag "$meta.id"
label 'process_medium'
publishDir "${params.outdir}",
mode: params.publish_dir_mode,
saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) }
conda (params.enable_conda ? "bioconda::bedtools =2.29.2" : null)
container "quay.io/biocontainers/bedtools:2.29.2--hc088bd4_0"
input:
tuple val(meta), path(beds)
output:
tuple val(meta), path("*.sort.bed"), emit: sort
path "*.version.txt", emit: version
script:
def software = getSoftwareName(task.process)
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
"""
bedtools sort -i $beds ${options.args} > ${prefix}.sort.bed
bedtools --version | sed -e "s/Bedtools v//g" > ${software}.version.txt
"""
}

View file

@ -0,0 +1,58 @@
name: bedtools_sort
description: Sorts a feature file by chromosome and other criteria.
keywords:
- bed
- sort
tools:
- bedtools:
description: |
A set of tools for genomic analysis tasks, specifically enabling genome arithmetic (merge, count, complement) on various file types.
documentation: https://bedtools.readthedocs.io/en/latest/
params:
- outdir:
type: string
description: |
The pipeline's output directory. By default, the module will
output files into `$params.outdir/<SOFTWARE>`
- publish_dir_mode:
type: string
description: |
Value for the Nextflow `publishDir` mode parameter.
Available: symlink, rellink, link, copy, copyNoFollow, move.
- enable_conda:
type: boolean
description: |
Run the module with Conda using the software specified
via the `conda` directive
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- bed:
type: file
description: List of bed files
pattern: "*.{bed}"
output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- bed:
type: file
description: Sorted bed file
pattern: "*.{sort.bed}"
- version:
type: file
description: File containing software version
pattern: "*.{version.txt}"
authors:
-"@Emiller88"
-"@sruthipsuresh"

View file

@ -0,0 +1,5 @@
chr1 951 1061
chr1 1300 1420
chr1 1400 1500

View file

@ -0,0 +1,21 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { BEDTOOLS_SORT } from '../main.nf' addParams( options: [publish_dir:'test_bed_file'] )
// Define input channels
// Run the workflow
workflow test_bed_file {
def input = []
input = [ [ id:'test'],
[ file("${baseDir}/input/A.bed", checkIfExists: true),] ]
BEDTOOLS_SORT( input )
}
workflow {
test_bed_file()
}

View file

@ -0,0 +1,20 @@
params {
outdir = "output/"
publish_dir_mode = "copy"
enable_conda = false
}
profiles {
conda {
params.enable_conda = true
}
docker {
docker.enabled = true
docker.runOptions = '-u \$(id -u):\$(id -g)'
}
singularity {
singularity.enabled = true
singularity.autoMounts = true
}
}

View file

@ -0,0 +1,3 @@
chr1 951 1061
chr1 1300 1420
chr1 1400 1500