mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-12-22 11:08:17 +00:00
Add alleleCounter module (#313)
* Add allelecount module * Add bed file input * Added bai file * Changed conda version * Update main.nf * Update pytest_software.yml * Update pytest_software.yml * Update pytest_software.yml * Update pytest_software.yml * Update pytest_software.yml * Update pytest_software.yml * Update pytest_software.yml * Update pytest_software.yml * Update pytest_software.yml * Update pytest_software.yml * Add allelecount module * Add bed file input * Added bai file * Changed conda version * Update main.nf * Update pytest_software.yml * Update pytest_software.yml * Update pytest_software.yml * Update pytest_software.yml * Update pytest_software.yml * Update pytest_software.yml * Remove newline * Fix pytest_software.yml * Update pytest_software.yml Co-authored-by: Gregor Sturm <mail@gregor-sturm.de>
This commit is contained in:
parent
614d61dc13
commit
3d720a24fd
6 changed files with 178 additions and 0 deletions
60
software/allelecounter/functions.nf
Normal file
60
software/allelecounter/functions.nf
Normal 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.args3 = args.args3 ?: ''
|
||||
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"
|
||||
}
|
||||
}
|
||||
}
|
41
software/allelecounter/main.nf
Normal file
41
software/allelecounter/main.nf
Normal file
|
@ -0,0 +1,41 @@
|
|||
// Import generic module functions
|
||||
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
||||
|
||||
params.options = [:]
|
||||
options = initOptions(params.options)
|
||||
|
||||
process ALLELECOUNTER {
|
||||
tag "$meta.id"
|
||||
label 'process_low'
|
||||
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::cancerit-allelecount=4.2.1" : null)
|
||||
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||
container "https://depot.galaxyproject.org/singularity/cancerit-allelecount:4.2.1--h3ecb661_0"
|
||||
} else {
|
||||
container "quay.io/biocontainers/cancerit-allelecount:4.2.1--h3ecb661_0"
|
||||
}
|
||||
|
||||
input:
|
||||
tuple val(meta), path(bam), path(bai)
|
||||
path loci
|
||||
|
||||
output:
|
||||
tuple val(meta), path("*.alleleCount"), emit: allelecount
|
||||
path "*.version.txt" , emit: version
|
||||
|
||||
script:
|
||||
def software = getSoftwareName(task.process)
|
||||
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||
"""
|
||||
alleleCounter \\
|
||||
$options.args \\
|
||||
-l $loci \\
|
||||
-b $bam \\
|
||||
-o ${prefix}.alleleCount
|
||||
|
||||
alleleCounter --version > ${software}.version.txt
|
||||
"""
|
||||
}
|
52
software/allelecounter/meta.yml
Normal file
52
software/allelecounter/meta.yml
Normal file
|
@ -0,0 +1,52 @@
|
|||
name: allelecounter
|
||||
|
||||
description: Generates a count of coverage of alleles
|
||||
keywords:
|
||||
- allele
|
||||
- count
|
||||
tools:
|
||||
- allelecounter:
|
||||
description: Takes a file of locations and a [cr|b]am file and generates a count of coverage of each allele at that location (given any filter settings)
|
||||
homepage: https://github.com/cancerit/alleleCount
|
||||
documentation: https://github.com/cancerit/alleleCount
|
||||
tool_dev_url: https://github.com/cancerit/alleleCount
|
||||
doi: ""
|
||||
licence: A-GPL 3.0
|
||||
|
||||
input:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- bam:
|
||||
type: file
|
||||
description: BAM/CRAM/SAM file
|
||||
pattern: "*.{bam,cram,sam}"
|
||||
- bai:
|
||||
type: file
|
||||
description: BAM/CRAM/SAM index file
|
||||
pattern: "*.{bai,crai,sai}"
|
||||
- loci:
|
||||
type: file
|
||||
description: loci file <CHR><tab><POS1>
|
||||
pattern: "*.{tsv}"
|
||||
|
||||
|
||||
output:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- version:
|
||||
type: file
|
||||
description: File containing software version
|
||||
pattern: "*.{version.txt}"
|
||||
- alleleCount:
|
||||
type: file
|
||||
description: Allele count file
|
||||
pattern: "*.{alleleCount}"
|
||||
|
||||
authors:
|
||||
- "@fullama"
|
|
@ -2,6 +2,10 @@ adapterremoval:
|
|||
- software/adapterremoval/**
|
||||
- tests/software/adapterremoval/**
|
||||
|
||||
allelecounter:
|
||||
- software/allelecounter/**
|
||||
- tests/software/allelecounter/**
|
||||
|
||||
bandage_image:
|
||||
- software/bandage/image/**
|
||||
- tests/software/bandage/image/**
|
||||
|
|
14
tests/software/allelecounter/main.nf
Normal file
14
tests/software/allelecounter/main.nf
Normal file
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env nextflow
|
||||
nextflow.enable.dsl = 2
|
||||
|
||||
include { ALLELECOUNTER } from '../../../software/allelecounter/main.nf' addParams( options: [:] )
|
||||
|
||||
workflow test_allelecounter {
|
||||
|
||||
def input = []
|
||||
input = [ [ id:'test', single_end:false ], // meta map
|
||||
file("${launchDir}/tests/data/genomics/sarscov2/bam/test_paired_end.sorted.bam", checkIfExists: true),
|
||||
file("${launchDir}/tests/data/genomics/sarscov2/bam/test_paired_end.sorted.bam.bai", checkIfExists: true)]
|
||||
positions = [ file("${launchDir}/tests/data/genomics/sarscov2/bed/test.bed", checkIfExists: true) ]
|
||||
ALLELECOUNTER ( input, positions )
|
||||
}
|
7
tests/software/allelecounter/test.yml
Normal file
7
tests/software/allelecounter/test.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
- name: allelecounter test_allelecounter
|
||||
command: nextflow run tests/software/allelecounter -entry test_allelecounter -c tests/config/nextflow.config
|
||||
tags:
|
||||
- allelecounter
|
||||
files:
|
||||
- path: output/allelecounter/test.alleleCount
|
||||
md5sum: 2bbe9d7331b78bdac30fe30dbc5fdaf3
|
Loading…
Reference in a new issue