Skip to content

Commit

Permalink
feat: add bedops/bedmap module
Browse files Browse the repository at this point in the history
  • Loading branch information
kelly-sovacool committed Nov 28, 2023
1 parent cbf2d59 commit 075450e
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Our documentation website is now live: <https://ccbr.github.io/nf-modules/> (#16

### New modules

- bedops/bedmap (#37)
- bedtools/map (#37)
- bedtools/merge (#37)
- bedtools/sort (#37)
Expand Down
37 changes: 37 additions & 0 deletions modules/CCBR/bedops/bedmap/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
process BEDOPS_BEDMAP {
tag { meta.id }
label 'process_single'
container 'nciccbr/ccbr_ubuntu_base_20.04:v6.1'

input:
tuple val(meta1), path(refbed)
tuple val(meta2), path(mapbed)

output:
tuple val(meta2), path("*.mapped.bed"), emit: bed
path "versions.yml" , emit: versions

when:
task.ext.when == null || task.ext.when

script:
"""
bedmap \\
--delim '\t' \\
--echo-ref-name \\
--count \\
${refbed} \\
${mapbed} \\
> ${meta2.id}.mapped.bed
cat <<-END_VERSIONS > versions.yml
"${task.process}":
bedops: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//' ))
END_VERSIONS
"""

stub:
"""
touch ${meta2.id}.mapped.bed versions.yml
"""
}
55 changes: 55 additions & 0 deletions modules/CCBR/bedops/bedmap/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
name: "bedops_bedmap"
description: The bedmap program is used to retrieve and process signal or other features over regions of interest in BED files
keywords:
- bedops
- bedmap
- bed
- intervals
tools:
- bedops:
description: |
fast, highly scalable and easily-parallelizable genome analysis toolkit
documentation: https://bedops.readthedocs.io/
tool_dev_url: https://github.com/bedops/bedops
licence: ["GPLv2"]
doi: 10.1093/bioinformatics/bts277

input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'test', single_end:false ]`
- refbed:
type: file
description: BED file
pattern: "*.bed"
- mapbed:
type: file
description: BED file
pattern: "*.bed"

output:
#Only when we have meta
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'test', single_end:false ]`
- mapped_bed:
type: file
description: BED file
pattern: "*.bed"

- versions:
type: file
description: File containing software versions
pattern: "versions.yml"

authors:
- "@kelly-sovacool"
maintainers:
- "@kelly-sovacool"
4 changes: 4 additions & 0 deletions tests/config/pytest_modules.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
bedops/bedmap:
- modules/CCBR/bedops/bedmap/**
- tests/modules/CCBR/bedops/bedmap/**

bedtools/map:
- modules/CCBR/bedtools/map/**
- tests/modules/CCBR/bedtools/map/**
Expand Down
26 changes: 26 additions & 0 deletions tests/modules/CCBR/bedops/bedmap/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env nextflow

nextflow.enable.dsl = 2

include { CAT_CAT } from '../../../../../modules/CCBR/cat/cat/main.nf'
include { BEDOPS_BEDMAP } from '../../../../../modules/CCBR/bedops/bedmap/main.nf'
include { BEDTOOLS_SORT as SORT_CAT
BEDTOOLS_SORT as SORT_PEAK } from '../../../../../modules/CCBR/bedtools/sort/main.nf'
include { BEDTOOLS_MERGE } from '../../../../../modules/CCBR/bedtools/merge/main.nf'

workflow test_bedops_bedmap {

ch_peaks = [
[ id: 'test', group: 'macs_broad' ], // meta map
[ file(params.test_data['macs_peaks_1'], checkIfExists: true),
file(params.test_data['macs_peaks_2'], checkIfExists: true),
]
]

ch_peaks.collect() | CAT_CAT
CAT_CAT.out.file_out | SORT_CAT
SORT_CAT.out.sorted | BEDTOOLS_MERGE

ch_peaks | SORT_PEAK
BEDOPS_BEDMAP( BEDTOOLS_MERGE.out.bed, SORT_PEAK.out.sorted )
}
7 changes: 7 additions & 0 deletions tests/modules/CCBR/bedops/bedmap/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
process {

publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" }

}

includeConfig '../../../../config/test_data_CCBR.config'
12 changes: 12 additions & 0 deletions tests/modules/CCBR/bedops/bedmap/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## TODO nf-core: Please run the following command to build this file:
# nf-core modules create-test-yml /bedmap
- name: "bedops bedmap"
command: nextflow run ./tests/modules/CCBR/bedops/bedmap -entry test_bedops_bedmap -c ./tests/config/nextflow.config
tags:
- "bedops"
- "bedops/bedmap"
files:
- path: "output/bedops/test.bam"
md5sum: e667c7caad0bc4b7ac383fd023c654fc
- path: "output/bedops/versions.yml"
md5sum: a01fe51bc4c6a3a6226fbf77b2c7cf3b

0 comments on commit 075450e

Please sign in to comment.