mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-12-22 02:58:17 +00:00
Adding plink/vcf module (#656)
* adding plink module using nf-core tool [ci skip] * Restructures the project for plink/vcf (#1) * Add version string for plink * Create a plink/vcf module * small tweaks on main.nf and started to test [ci skip] * small changes on test args, local test with docker passed! * Update plink/vcf module listing * Update tag * fix tags as per linting guidelines * revert to the original state of tags * adding --threads to `main.nf` and `meta.yml` information Co-authored-by: Abhinav Sharma <abhi18av@users.noreply.github.com>
This commit is contained in:
parent
bd68797ffb
commit
59ca7444cf
6 changed files with 194 additions and 0 deletions
68
modules/plink/vcf/functions.nf
Normal file
68
modules/plink/vcf/functions.nf
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
//
|
||||||
|
// 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_meta = args.publish_by_meta ?: []
|
||||||
|
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_meta) {
|
||||||
|
def key_list = ioptions.publish_by_meta instanceof List ? ioptions.publish_by_meta : args.publish_by_meta
|
||||||
|
for (key in key_list) {
|
||||||
|
if (args.meta && key instanceof String) {
|
||||||
|
def path = key
|
||||||
|
if (args.meta.containsKey(key)) {
|
||||||
|
path = args.meta[key] instanceof Boolean ? "${key}_${args.meta[key]}".toString() : args.meta[key]
|
||||||
|
}
|
||||||
|
path = path instanceof String ? path : ''
|
||||||
|
path_list.add(path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
44
modules/plink/vcf/main.nf
Normal file
44
modules/plink/vcf/main.nf
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
// Import generic module functions
|
||||||
|
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
||||||
|
|
||||||
|
params.options = [:]
|
||||||
|
options = initOptions(params.options)
|
||||||
|
|
||||||
|
process PLINK_VCF {
|
||||||
|
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::plink=1.90b6.21" : null)
|
||||||
|
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||||
|
container "https://depot.galaxyproject.org/singularity/plink:1.90b6.21--h779adbc_1"
|
||||||
|
} else {
|
||||||
|
container "quay.io/biocontainers/plink:1.90b6.21--h779adbc_1"
|
||||||
|
}
|
||||||
|
|
||||||
|
input:
|
||||||
|
tuple val(meta), path(vcf)
|
||||||
|
|
||||||
|
output:
|
||||||
|
tuple val(meta), path("*.bed"), emit: bed, optional: true
|
||||||
|
tuple val(meta), path("*.bim"), emit: bim, optional: true
|
||||||
|
tuple val(meta), path("*.fam"), emit: fam, optional: true
|
||||||
|
|
||||||
|
path "*.version.txt", emit: version
|
||||||
|
|
||||||
|
script:
|
||||||
|
def software = getSoftwareName(task.process)
|
||||||
|
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||||
|
|
||||||
|
"""
|
||||||
|
plink \\
|
||||||
|
--vcf ${vcf} \\
|
||||||
|
$options.args \\
|
||||||
|
--threads $task.cpus \\
|
||||||
|
--out ${prefix}
|
||||||
|
|
||||||
|
echo \$(plink --version 2>&1) | sed 's/^PLINK //' | sed 's/..-bit.*//'> ${software}.version.txt
|
||||||
|
"""
|
||||||
|
}
|
53
modules/plink/vcf/meta.yml
Normal file
53
modules/plink/vcf/meta.yml
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
name: plink_vcf
|
||||||
|
description: Analyses variant calling files using plink
|
||||||
|
keywords:
|
||||||
|
- plink
|
||||||
|
- vcf
|
||||||
|
tools:
|
||||||
|
- plink:
|
||||||
|
description: |
|
||||||
|
Whole genome association analysis toolset, designed to perform a range
|
||||||
|
of basic, large-scale analyses in a computationally efficient manner
|
||||||
|
homepage: "https://www.cog-genomics.org/plink"
|
||||||
|
documentation: None
|
||||||
|
tool_dev_url: "https://www.cog-genomics.org/plink/1.9/dev"
|
||||||
|
doi: ""
|
||||||
|
licence: ['GPL']
|
||||||
|
|
||||||
|
input:
|
||||||
|
- meta:
|
||||||
|
type: map
|
||||||
|
description: |
|
||||||
|
Groovy Map containing sample information
|
||||||
|
e.g. [ id:'test', single_end:false ]
|
||||||
|
- vcf:
|
||||||
|
type: file
|
||||||
|
description: Variant calling file (vcf)
|
||||||
|
pattern: "*.{vcf}"
|
||||||
|
|
||||||
|
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}"
|
||||||
|
- bed:
|
||||||
|
type: file
|
||||||
|
description: PLINK binary biallelic genotype table
|
||||||
|
pattern: "*.{bed}"
|
||||||
|
- bim:
|
||||||
|
type: file
|
||||||
|
description: PLINK extended MAP file
|
||||||
|
pattern: "*.{bim}"
|
||||||
|
- fam:
|
||||||
|
type: file
|
||||||
|
description: PLINK sample information file
|
||||||
|
pattern: "*.{fam}"
|
||||||
|
|
||||||
|
authors:
|
||||||
|
- "@Mxrcon"
|
||||||
|
- "@abhi18av"
|
|
@ -659,6 +659,10 @@ plasmidid:
|
||||||
- modules/plasmidid/**
|
- modules/plasmidid/**
|
||||||
- tests/modules/plasmidid/**
|
- tests/modules/plasmidid/**
|
||||||
|
|
||||||
|
plink/vcf:
|
||||||
|
- modules/plink/vcf/**
|
||||||
|
- tests/modules/plink/vcf/**
|
||||||
|
|
||||||
preseq/lcextrap:
|
preseq/lcextrap:
|
||||||
- modules/preseq/lcextrap/**
|
- modules/preseq/lcextrap/**
|
||||||
- tests/modules/preseq/lcextrap/**
|
- tests/modules/preseq/lcextrap/**
|
||||||
|
|
13
tests/modules/plink/vcf/main.nf
Normal file
13
tests/modules/plink/vcf/main.nf
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#!/usr/bin/env nextflow
|
||||||
|
|
||||||
|
nextflow.enable.dsl = 2
|
||||||
|
|
||||||
|
include { PLINK_VCF } from '../../../../modules/plink/vcf/main.nf' addParams( options: ['args':" --make-bed --biallelic-only strict --vcf-half-call missing --double-id --recode ped --id-delim \'=\' --allow-extra-chr"])
|
||||||
|
|
||||||
|
workflow test_plink_vcf {
|
||||||
|
|
||||||
|
input = [ [ id:'test', single_end:false ], // meta map
|
||||||
|
file(params.test_data['sarscov2']['illumina']['test_vcf'], checkIfExists: true) ]
|
||||||
|
|
||||||
|
PLINK_VCF ( input )
|
||||||
|
}
|
12
tests/modules/plink/vcf/test.yml
Normal file
12
tests/modules/plink/vcf/test.yml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
- name: plink vcf test_plink_vcf
|
||||||
|
command: nextflow run tests/modules/plink/vcf -entry test_plink_vcf -c tests/config/nextflow.config
|
||||||
|
tags:
|
||||||
|
- plink
|
||||||
|
- plink/vcf
|
||||||
|
files:
|
||||||
|
- path: output/plink/test.bed
|
||||||
|
md5sum: 55c3ab2636212911b5f952ef6f5d855c
|
||||||
|
- path: output/plink/test.bim
|
||||||
|
md5sum: 54164b6f103e152de05712c6bb317db8
|
||||||
|
- path: output/plink/test.fam
|
||||||
|
md5sum: 22d32d7daa3ae6b819a24895e82b2a70
|
Loading…
Reference in a new issue