Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create bed2saf module #50

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Loading