Peddy nf core2 2dev0 (#1048)

* Updated module to fit nf-core2.2dev0 templates

* Updated module to fit nf-core2.2dev0 templates

* Linked test files to nf-core/test-dataset branch:raredisease raw files

* Change order of input: vcf and tbi with meta, ped without

* Change order of input: vcf and tbi with meta, ped without/adapt test

* Change order of input: vcf and tbi with meta, ped without/adapt test, bugfix

* Indent and rename files

* Update modules/peddy/main.nf

Removed newline

Co-authored-by: FriederikeHanssen <Friederike.hanssen@qbic.uni-tuebingen.de>

* Update modules/peddy/main.nf

Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>

* Update modules/peddy/main.nf

Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>

* Update modules/peddy/main.nf

Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>

* Update modules/peddy/meta.yml

Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>

* Update modules/peddy/meta.yml

Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>

* Update modules/peddy/main.nf

Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>

* Update modules/peddy/main.nf

Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>

* Update pytest_modules.yml

* Update main.nf

* Apply suggestions from code review

Co-authored-by: FriederikeHanssen <Friederike.hanssen@qbic.uni-tuebingen.de>
Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
This commit is contained in:
Annick Renevey 2021-11-21 21:14:09 +01:00 committed by GitHub
parent 1455498152
commit 45985ff6f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 231 additions and 0 deletions

View file

@ -0,0 +1,78 @@
//
// 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()
}
//
// Extract name of module from process name using $task.process
//
def getProcessName(task_process) {
return task_process.tokenize(':')[-1]
}
//
// 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) {
def ioptions = initOptions(args.options)
def path_list = [ ioptions.publish_dir ?: args.publish_dir ]
// Do not publish versions.yml unless running from pytest workflow
if (args.filename.equals('versions.yml') && !System.getenv("NF_CORE_MODULES_TEST")) {
return null
}
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"
}
}

47
modules/peddy/main.nf Normal file
View file

@ -0,0 +1,47 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
params.options = [:]
options = initOptions(params.options)
process PEDDY {
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), meta:meta, publish_by_meta:['id']) }
conda (params.enable_conda ? "bioconda::peddy=0.4.8" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/peddy:0.4.8--pyh5e36f6f_0"
} else {
container "quay.io/biocontainers/peddy:0.4.8--pyh5e36f6f_0"
}
input:
tuple val(meta), path(vcf), path(vcf_tbi)
path ped
output:
tuple val(meta), path("*.html") , emit: html
tuple val(meta), path("*.csv") , emit: csv
tuple val(meta), path("*.peddy.ped"), emit: ped
tuple val(meta), path("*.png") , emit: png
path "versions.yml" , emit: versions
script:
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
"""
peddy \\
$options.args \\
--plot \\
-p $task.cpus \\
$vcf \\
$ped
cat <<-END_VERSIONS > versions.yml
${getProcessName(task.process)}:
${getSoftwareName(task.process)}: \$( peddy --version 2>&1 | sed 's/peddy, version //' )
END_VERSIONS
"""
}

64
modules/peddy/meta.yml Normal file
View file

@ -0,0 +1,64 @@
name: peddy
description: Manipulation, validation and exploration of pedigrees
keywords:
- pedigrees
- ped
- family
tools:
- peddy:
description: genotype, ped correspondence check, ancestry check, sex check. directly, quickly on VCF
homepage: https://github.com/brentp/peddy
documentation: https://peddy.readthedocs.io/en/latest/
tool_dev_url: https://github.com/brentp/peddy
doi: "https://doi.org/10.1016/j.ajhg.2017.01.017"
licence: ['MIT']
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- vcf:
type: file
description: VCF file
pattern: "*.{vcf.gz}"
- ped:
type: file
description: PED/FAM file
pattern: "*.{ped,fam}"
- vcf_tbi:
type: file
description: TBI file
pattern: "*.{vcf.gz.tbi}"
output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- ped:
type: file
description: PED/FAM file
pattern: "*.peddy.{ped}"
- html:
type: file
description: HTML file
pattern: "*.{html}"
- csv:
type: file
description: CSV file
pattern: "*.{csv}"
- png:
type: file
description: PNG file
pattern: "*.{png}"
- versions:
type: file
description: File containing software versions
pattern: "versions.yml"
authors:
- "@rannick"

View file

@ -1019,6 +1019,10 @@ picard/collecthsmetrics:
- modules/picard/collecthsmetrics/**
- tests/modules/picard/collecthsmetrics/**
peddy:
- modules/peddy/**
- tests/modules/peddy/**
picard/collectmultiplemetrics:
- modules/picard/collectmultiplemetrics/**
- tests/modules/picard/collectmultiplemetrics/**

View file

@ -128,6 +128,10 @@ params {
index_salmon = "${test_data_dir}/genomics/homo_sapiens/genome/index/salmon"
repeat_expansions = "${test_data_dir}/genomics/homo_sapiens/genome/loci/repeat_expansions.json"
justhusky_ped = "${test_data_dir}/genomics/homo_sapiens/genome/vcf/ped/justhusky.ped"
justhusky_minimal_vcf_gz = "${test_data_dir}/genomics/homo_sapiens/genome/vcf/ped/justhusky_minimal.vcf.gz"
justhusky_minimal_vcf_gz_tbi = "${test_data_dir}/genomics/homo_sapiens/genome/vcf/ped/justhusky_minimal.vcf.gz.tbi"
}
'illumina' {
test_paired_end_sorted_bam = "${test_data_dir}/genomics/homo_sapiens/illumina/bam/test.paired_end.sorted.bam"

View file

@ -0,0 +1,17 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { PEDDY } from '../../../modules/peddy/main.nf' addParams( options: [:] )
workflow test_peddy {
input = [
[ id:'test', single_end:false ],
file(params.test_data['homo_sapiens']['genome']['justhusky_minimal_vcf_gz'], checkIfExists: true),
file(params.test_data['homo_sapiens']['genome']['justhusky_minimal_vcf_gz_tbi'], checkIfExists: true)
]
ped = file(params.test_data['homo_sapiens']['genome']['justhusky_ped'], checkIfExists: true)
PEDDY ( input , ped )
}

View file

@ -0,0 +1,17 @@
- name: peddy test_peddy
command: nextflow run tests/modules/peddy -entry test_peddy -c tests/config/nextflow.config
tags:
- peddy
files:
- path: output/peddy/justhusky_minimal.het_check.csv
md5sum: f4006d47355f2a760e40215b403926c3
- path: output/peddy/justhusky_minimal.html
md5sum: 4f189cdbe8f03fe5c32d343c183506a5
- path: output/peddy/justhusky_minimal.ped_check.csv
md5sum: d79a98558e280afe794d1374d2b985d4
- path: output/peddy/justhusky_minimal.ped_check.rel-difference.csv
md5sum: 9de7e287cb30c742db2ff3622b0e63b1
- path: output/peddy/justhusky_minimal.sex_check.csv
md5sum: 60848489bc697490da6a53b5170baf3b
- path: output/peddy/justhusky_minimal.vs.html
md5sum: 20f5f3a97fa781057c876ac79e044010