Intervallisttools (#491)

* added intervallisttools module

* add intervallisttools module

* arguments are now supplied using options.args

* removed java heapsize settings

* changes in main.nf and it is tested

* comment added

* Update software/gatk4/intervallisttools/meta.yml

Co-authored-by: Maxime U. Garcia <maxime.garcia@scilifelab.se>

* Update tests/software/gatk4/intervallisttools/test.yml

Co-authored-by: Maxime U. Garcia <maxime.garcia@scilifelab.se>

* review comment on tags in bedtointerval

* modified the test to get input from bedtointerval module

* Update software/gatk4/intervallisttools/meta.yml

* Apply suggestions from code review

Co-authored-by: Kevin Menden <kevin.menden@live.com>

* Apply suggestions from code review

* Update tests/config/pytest_software.yml

Co-authored-by: Kevin Menden <kevin.menden@live.com>

* Apply suggestions from code review

* Apply suggestions from code review

Co-authored-by: @praveenraj2018 <praveen.raj.somarajan@ki.se>
Co-authored-by: Maxime U. Garcia <maxime.garcia@scilifelab.se>
Co-authored-by: Kevin Menden <kevin.menden@live.com>
This commit is contained in:
praveenraj2018 2021-05-12 11:44:36 +02:00 committed by GitHub
parent cdff9a056d
commit 598ca152ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 195 additions and 0 deletions

View 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"
}
}
}

View file

@ -0,0 +1,53 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
options = initOptions(params.options)
process GATK4_INTERVALLISTTOOLS {
tag "$meta.id"
label 'process_medium'
publishDir "${params.outdir}",
mode: params.publish_dir_mode,
saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), meta:meta, publish_by_meta:['id']) }
conda (params.enable_conda ? "bioconda::gatk4=4.2.0.0" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/gatk4:4.2.0.0--hdfd78af_1"
} else {
container "quay.io/biocontainers/gatk4:4.2.0.0--hdfd78af_1"
}
input:
tuple val(meta), path(interval_list)
output:
tuple val(meta), path("*_split/*/*.interval_list"), emit: interval_list
path "*.version.txt" , emit: version
script:
def software = getSoftwareName(task.process)
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
"""
mkdir ${prefix}_split
gatk \\
IntervalListTools \\
-I ${interval_list} \\
-O ${prefix}_split \\
$options.args
python3 <<CODE
import glob, os
# The following python code snippet rename the output files into different name to avoid overwriting or name conflict
intervals = sorted(glob.glob("*_split/*/*.interval_list"))
for i, interval in enumerate(intervals):
(directory, filename) = os.path.split(interval)
newName = os.path.join(directory, str(i + 1) + filename)
os.rename(interval, newName)
CODE
gatk --version | grep Picard | sed "s/Picard Version: //g" > ${software}.version.txt
"""
}

View file

@ -0,0 +1,46 @@
name: gatk4_intervallisttools
description: Splits the interval list file into unique, equally-sized interval files and place it under a directory
keywords:
- sort
- bed
- interval list
tools:
- gatk4:
description: |
Developed in the Data Sciences Platform at the Broad Institute, the toolkit offers a wide variety of tools
with a primary focus on variant discovery and genotyping. Its powerful processing engine
and high-performance computing features make it capable of taking on projects of any size.
homepage: https://gatk.broadinstitute.org/hc/en-us
documentation: https://gatk.broadinstitute.org/hc/en-us/categories/360002369672s
doi: 10.1158/1538-7445.AM2017-3590
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- interval_list:
type: file
description: Interval list file
pattern: "*.interval_list"
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}"
- interval_list:
type: file
description: Interval list files
pattern: "*.interval_list"
authors:
- "@praveenraj2018"

View file

@ -290,6 +290,10 @@ gatk4/variantfiltration:
- software/gatk4/variantfiltration/** - software/gatk4/variantfiltration/**
- tests/software/gatk4/variantfiltration/** - tests/software/gatk4/variantfiltration/**
gatk4/intervallisttools:
- software/gatk4/intervallisttools/**
- tests/software/gatk4/intervallisttools/**
gffread: gffread:
- software/gffread/** - software/gffread/**
- tests/software/gffread/** - tests/software/gffread/**

View file

@ -0,0 +1,16 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
test_options = ['args': '--SCATTER_COUNT 6 --SUBDIVISION_MODE BALANCING_WITHOUT_INTERVAL_SUBDIVISION_WITH_OVERFLOW --UNIQUE true --SORT true']
include { GATK4_BEDTOINTERVALLIST } from '../../../../software/gatk4/bedtointervallist/main.nf' addParams( options: [:] )
include { GATK4_INTERVALLISTTOOLS as INTERVALLISTTOOLS } from '../../../../software/gatk4/intervallisttools/main.nf' addParams( options: test_options )
workflow test_gatk4_intervallisttools {
input = [ [ id:'test' ], [ file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true) ]]
dict = file(params.test_data['sarscov2']['genome']['genome_dict'], checkIfExists: true)
GATK4_BEDTOINTERVALLIST ( input, dict )
INTERVALLISTTOOLS ( GATK4_BEDTOINTERVALLIST.out.interval_list )
}

View file

@ -0,0 +1,16 @@
- name: gatk4 intervallisttools test_gatk4_intervallisttools
command: nextflow run tests/software/gatk4/intervallisttools -entry test_gatk4_intervallisttools -c tests/config/nextflow.config
tags:
- gatk4
- gatk4/intervallisttools
files:
- path: output/gatk4/test.interval_list
md5sum: e51101c9357fb2d59fd30e370eefa39c
- path: output/intervallisttools/test_split/temp_0001_of_6/1scattered.interval_list
md5sum: b8ba8a387200df76a0d1c577626dc265
- path: output/intervallisttools/test_split/temp_0002_of_6/2scattered.interval_list
md5sum: 0728d164666d9264ef442a493e008dee
- path: output/intervallisttools/test_split/temp_0003_of_6/3scattered.interval_list
md5sum: 55da0f3c69504148f4e7002a0e072cfe
- path: output/intervallisttools/test_split/temp_0004_of_6/4scattered.interval_list
md5sum: d29ca4447f32547f2936567fa902796a