Skip to content

Commit

Permalink
feat: create bed2saf module
Browse files Browse the repository at this point in the history
adapted from CCBR-1346 DDIS project
  • Loading branch information
kelly-sovacool committed Jan 23, 2025
1 parent 8caecb7 commit f9c7161
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
35 changes: 35 additions & 0 deletions modules/CCBR/custom/bed2saf/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
process CUSTOM_BED2SAF {
label 'process_single'

input:
tuple val(meta), path(bed)

output:
tuple val(meta), path("*.saf"), emit: saf
path('versions.yml'), emit: versions

script:
def saf = "${bed.baseName}.saf"
"""
#!/usr/bin/env python
import platform
with open("${saf}", 'w') as outfile:
outfile.write('\\t'.join(['GeneID', 'Chr', 'Start', 'End', 'Strand']))
with open("${bed}", 'r') as infile:
for line in infile:
(chr, start, end,) = line.strip().split('\\t')
peak_id = f'{chr}:{start}-{end}'
strand = '.' # no strand info available
outfile.write('\\t'.join([peak_id, chr, start, end, strand]) + '\\n')
with open("versions.yml", "w") as outfile:
outfile.write('"${task.process}":\\n')
outfile.write(f' Python: "{platform.python_version()}"\\n')
"""

stub:
"""
touch ${bed.baseName}.saf versions.yml
"""
}
41 changes: 41 additions & 0 deletions modules/CCBR/custom/bed2saf/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: custom_bed2saf
description: |
The module converts a BED file to SAF (simplified annotation format)
keywords:
- bed
- saf
tools:
- Python:
description: |
The Python Programming Language
homepage: https://www.python.org/
licence: ["Python License 2.0"]
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- bam:
type: file
description: BED file
pattern: "*.bed"
output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- saf:
type: file
description: SAF file
pattern: "*.saf"
- versions:
type: file
description: File containing software versions
pattern: "versions.yml"
authors:
- "@kelly-sovacool"
maintainers:
- "@kelly-sovacool"

0 comments on commit f9c7161

Please sign in to comment.