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

Module:ppflagfixer #43

Merged
merged 16 commits into from
Jul 25, 2024
9 changes: 9 additions & 0 deletions modules/msk/ppflagfixer/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
name: "ppflagfixer"
channels:
- conda-forge
- bioconda
- defaults
dependencies:
- "YOUR-TOOL-HERE"
48 changes: 48 additions & 0 deletions modules/msk/ppflagfixer/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
process PPFLAGFIXER {
tag "$meta.id"
label 'process_medium'

container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'docker://mskcc/facets-suite:2.0.9':
'docker.io/mskcc/facets-suite:2.0.9' }"

input:
tuple val(meta), path(process_bam), path(process_bam_index)

output:
tuple val(meta), path("ppflag.*.bam") , emit: ppflag_bam
path "versions.yml" , emit: versions

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

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"

"""
/usr/bin/ppflag-fixer \
${args} \
${process_bam} \
ppflag.${prefix}.bam

cat <<-END_VERSIONS > versions.yml
"${task.process}":
htslib: \$(bgzip --version | grep -oP '(?<=\\(htslib\\) ).*')
r: \$(R --version | grep -oP '(?<=R version ).*(?=\\()')
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"

"""
echo "stub test" >> ppflag.${prefix}.bam
cat <<-END_VERSIONS > versions.yml
"${task.process}":
htslib: \$(bgzip --version | grep -oP '(?<=\\(htslib\\) ).*')
r: \$(R --version | grep -oP '(?<=R version ).*(?=\\()')
END_VERSIONS
"""
}
53 changes: 53 additions & 0 deletions modules/msk/ppflagfixer/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "ppflagfixer"
## TODO nf-core: Add a description of the module and list keywords
description: pplag-fixer for a single bam file
keywords:
- ppflag
- fixer
- bams
tools:
- "htstools":
description: "Contains tools to process bam files for downstream copy number analysis."
homepage: "https://github.com/mskcc/htstools"
documentation: "https://github.com/mskcc/htstools"

input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample_name' ]`

- process_bam:
type: file
description: Sorted BAM/CRAM/SAM file
pattern: "*.{bam,cram,sam}"

- process_bam_index:
type: file
description: "Index of the process bam file"
pattern: "*.bai"

output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample_name' ]`

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

- ppflag_bam:
type: file
description: Sorted BAM/CRAM/SAM file
pattern: "*.{bam,cram,sam}"

authors:
- "@huyu335"
maintainers:
- "@huyu335"
87 changes: 87 additions & 0 deletions modules/msk/ppflagfixer/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
nextflow_process {

name "Test PPFLAGFIXER"
script "../main.nf"
process "PPFLAGFIXER"
config "./nextflow.config"

tag "modules"
tag "modules_nfcore"
tag "modules_msk"
tag "ppflagfixer"

test("ppflagfixer - normal bam") {

when {
process {
"""
meta = [ id:'test' ] // meta map
input[0] = [
meta,
file(params.test_data_mskcc['bam_files']['test_argos_sample_1_normal_bam'], checkIfExists: true),
file(params.test_data_mskcc['bam_files']['test_argos_sample_1_normal_bam_bai'], checkIfExists: true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

test("ppflagfixer - tumor bam") {

when {
process {
"""
meta = [ id:'test' ] // meta map
input[0] = [
meta,
file(params.test_data_mskcc['bam_files']['test_argos_sample_1_tumor_bam'], checkIfExists: true),
file(params.test_data_mskcc['bam_files']['test_argos_sample_1_tumor_bam_bai'], checkIfExists: true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

test("ppflagfixer - bam - stub") {

options "-stub"

when {
process {
"""
meta = [ id:'test' ] // meta map
input[0] = [
meta,
file("stub_file"),
file("stub_file1")
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

}
101 changes: 101 additions & 0 deletions modules/msk/ppflagfixer/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"ppflagfixer - normal bam": {
"content": [
{
"0": [
[
{
"id": "test"
},
"ppflag.test.bam:md5,d25c13205b1d33c5c4b12999fc839d86"
]
],
"1": [
"versions.yml:md5,ed3820a8eb6f0db2010ddec9aefa7249"
],
"ppflag_bam": [
[
{
"id": "test"
},
"ppflag.test.bam:md5,d25c13205b1d33c5c4b12999fc839d86"
]
],
"versions": [
"versions.yml:md5,ed3820a8eb6f0db2010ddec9aefa7249"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.04.2"
},
"timestamp": "2024-02-26T23:05:23.642445"
},
"ppflagfixer - bam - stub": {
"content": [
{
"0": [
[
{
"id": "test"
},
"ppflag.test.bam:md5,3d77e3e110a219d3495d44e243450313"
]
],
"1": [
"versions.yml:md5,ed3820a8eb6f0db2010ddec9aefa7249"
],
"ppflag_bam": [
[
{
"id": "test"
},
"ppflag.test.bam:md5,3d77e3e110a219d3495d44e243450313"
]
],
"versions": [
"versions.yml:md5,ed3820a8eb6f0db2010ddec9aefa7249"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.04.2"
},
"timestamp": "2024-02-26T23:06:14.360871"
},
"ppflagfixer - tumor bam": {
"content": [
{
"0": [
[
{
"id": "test"
},
"ppflag.test.bam:md5,d05041f7678abb654e5d349ec430b131"
]
],
"1": [
"versions.yml:md5,ed3820a8eb6f0db2010ddec9aefa7249"
],
"ppflag_bam": [
[
{
"id": "test"
},
"ppflag.test.bam:md5,d05041f7678abb654e5d349ec430b131"
]
],
"versions": [
"versions.yml:md5,ed3820a8eb6f0db2010ddec9aefa7249"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.04.2"
},
"timestamp": "2024-02-26T23:06:08.243018"
}
}
10 changes: 10 additions & 0 deletions modules/msk/ppflagfixer/tests/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
params {
enable_conda = false
}

process {
publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" }
withName: 'PPFLAGFIXER' {
ext.args = '-m 500'
}
}
2 changes: 2 additions & 0 deletions modules/msk/ppflagfixer/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ppflagfixer:
- "modules/msk/ppflagfixer/**"
Loading