mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-11-13 05:13:09 +00:00
Cooler cload (#634)
* rebuild cooler cload. * update test file path of cload. * add pytest for cload * update to version.yml * update the test data path * Update tests/modules/cooler/cload/main.nf Co-authored-by: Sébastien Guizard <sguizard@ed.ac.uk> * Update modules/cooler/cload/main.nf Co-authored-by: Sébastien Guizard <sguizard@ed.ac.uk> * Update tests/config/test_data.config Co-authored-by: Sébastien Guizard <sguizard@ed.ac.uk> * Update main.nf Remove a lonely curly bracket. * Update test.yml Updated with new workflows. * update the test files * merge the conflicts. * update the test.yml * update for change of cooler/dump Co-authored-by: Gregor Sturm <mail@gregor-sturm.de> Co-authored-by: Sébastien Guizard <sguizard@ed.ac.uk> Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
This commit is contained in:
parent
c2bba7a65d
commit
52c541b080
7 changed files with 269 additions and 1 deletions
78
modules/cooler/cload/functions.nf
Normal file
78
modules/cooler/cload/functions.nf
Normal 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/cooler/cload/main.nf
Normal file
47
modules/cooler/cload/main.nf
Normal file
|
@ -0,0 +1,47 @@
|
|||
// Import generic module functions
|
||||
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
|
||||
|
||||
params.options = [:]
|
||||
options = initOptions(params.options)
|
||||
|
||||
process COOLER_CLOAD {
|
||||
tag "$meta.id"
|
||||
label 'process_high'
|
||||
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::cooler=0.8.11" : null)
|
||||
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||
container "https://depot.galaxyproject.org/singularity/cooler:0.8.11--pyh3252c3a_0"
|
||||
} else {
|
||||
container "quay.io/biocontainers/cooler:0.8.11--pyh3252c3a_0"
|
||||
}
|
||||
|
||||
input:
|
||||
tuple val(meta), path(pairs), path(index)
|
||||
val cool_bin
|
||||
path chromsizes
|
||||
|
||||
output:
|
||||
tuple val(meta), val(cool_bin), path("*.cool"), emit: cool
|
||||
path "versions.yml" , emit: versions
|
||||
|
||||
script:
|
||||
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||
def nproc = options.args.contains('pairix') || options.args.contains('tabix')? "--nproc ${task.cpus}" : ''
|
||||
|
||||
"""
|
||||
cooler cload \\
|
||||
$options.args \\
|
||||
$nproc \\
|
||||
${chromsizes}:${cool_bin} \\
|
||||
$pairs \\
|
||||
${prefix}.${cool_bin}.cool
|
||||
|
||||
cat <<-END_VERSIONS > versions.yml
|
||||
${getProcessName(task.process)}:
|
||||
${getSoftwareName(task.process)}: \$(cooler --version 2>&1 | sed 's/cooler, version //')
|
||||
END_VERSIONS
|
||||
"""
|
||||
}
|
52
modules/cooler/cload/meta.yml
Normal file
52
modules/cooler/cload/meta.yml
Normal file
|
@ -0,0 +1,52 @@
|
|||
name: cooler_cload
|
||||
description: Create a cooler from genomic pairs and bins
|
||||
keywords:
|
||||
- cool
|
||||
tools:
|
||||
- cooler:
|
||||
description: Sparse binary format for genomic interaction matrices
|
||||
homepage: https://cooler.readthedocs.io/en/latest/index.html
|
||||
documentation: https://cooler.readthedocs.io/en/latest/index.html
|
||||
tool_dev_url: https://github.com/open2c/cooler
|
||||
doi: "10.1093/bioinformatics/btz540"
|
||||
licence: ['BSD-3-clause']
|
||||
|
||||
input:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- pairs:
|
||||
type: file
|
||||
description: Path to contacts (i.e. read pairs) file.
|
||||
- index:
|
||||
type: file
|
||||
description: Path to index file of the contacts.
|
||||
- cool_bin:
|
||||
type: value
|
||||
description: Bins size in bp
|
||||
- chromsizes:
|
||||
type: file
|
||||
description: Path to a chromsizes file.
|
||||
|
||||
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: "versions.yml"
|
||||
- cool:
|
||||
type: file
|
||||
description: Output COOL file path
|
||||
pattern: "*.cool"
|
||||
- cool_bin:
|
||||
type: value
|
||||
description: Bins size in bp
|
||||
|
||||
authors:
|
||||
- "@jianhong"
|
|
@ -298,6 +298,10 @@ cooler/digest:
|
|||
- modules/cooler/digest/**
|
||||
- tests/modules/cooler/digest/**
|
||||
|
||||
cooler/cload:
|
||||
- modules/cooler/cload/**
|
||||
- tests/modules/cooler/cload/**
|
||||
|
||||
cooler/dump:
|
||||
- modules/cooler/dump/**
|
||||
- tests/modules/cooler/dump/**
|
||||
|
|
|
@ -263,7 +263,13 @@ params {
|
|||
'txt' {
|
||||
hello = "${test_data_dir}/generic/txt/hello.txt"
|
||||
}
|
||||
'cooler' {
|
||||
'cooler'{
|
||||
test_pairix_pair_gz = "${test_data_dir}/genomics/homo_sapiens/cooler/cload/hg19/hg19.GM12878-MboI.pairs.subsample.blksrt.txt.gz"
|
||||
test_pairix_pair_gz_px2 = "${test_data_dir}/genomics/homo_sapiens/cooler/cload/hg19/hg19.GM12878-MboI.pairs.subsample.blksrt.txt.gz.px2"
|
||||
test_pairs_pair = "${test_data_dir}/genomics/homo_sapiens/cooler/cload/hg19/hg19.sample1.pairs"
|
||||
test_tabix_pair_gz = "${test_data_dir}/genomics/homo_sapiens/cooler/cload/hg19/hg19.GM12878-MboI.pairs.subsample.sorted.possrt.txt.gz"
|
||||
test_tabix_pair_gz_tbi = "${test_data_dir}/genomics/homo_sapiens/cooler/cload/hg19/hg19.GM12878-MboI.pairs.subsample.sorted.possrt.txt.gz.tbi"
|
||||
hg19_chrom_sizes = "${test_data_dir}/genomics/homo_sapiens/cooler/cload/hg19/hg19.chrom.sizes"
|
||||
test_merge_cool = "${test_data_dir}/genomics/homo_sapiens/cooler/merge/toy/toy.symm.upper.2.cool"
|
||||
test_merge_cool_cp2 = "${test_data_dir}/genomics/homo_sapiens/cooler/merge/toy/toy.symm.upper.2.cp2.cool"
|
||||
|
||||
|
|
52
tests/modules/cooler/cload/main.nf
Normal file
52
tests/modules/cooler/cload/main.nf
Normal file
|
@ -0,0 +1,52 @@
|
|||
#!/usr/bin/env nextflow
|
||||
|
||||
nextflow.enable.dsl = 2
|
||||
|
||||
include { COOLER_CLOAD } from '../../../../modules/cooler/cload/main.nf' addParams( options: [args:'pairix'] )
|
||||
include { COOLER_CLOAD as COOLER_CLOAD_PAIRS } from '../../../../modules/cooler/cload/main.nf' addParams( options: [args:'pairs --chrom1 1 --pos1 2 --chrom2 4 --pos2 5 -N'] )
|
||||
include { COOLER_CLOAD as COOLER_CLOAD_TABIX } from '../../../../modules/cooler/cload/main.nf' addParams( options: [args:'tabix'] )
|
||||
include { COOLER_DUMP } from '../../../../modules/cooler/dump/main.nf' addParams( options: [:] )
|
||||
include { COOLER_DUMP as COOLER_DUMP_PAIRS} from '../../../../modules/cooler/dump/main.nf' addParams( options: [:] )
|
||||
include { COOLER_DUMP as COOLER_DUMP_TABIX} from '../../../../modules/cooler/dump/main.nf' addParams( options: [:] )
|
||||
|
||||
workflow test_cooler_cload_pairix {
|
||||
|
||||
input = [ [ id:'test_pairix', single_end:false ], // meta map
|
||||
file(params.test_data['generic']['cooler']['test_pairix_pair_gz'], checkIfExists: true),
|
||||
file(params.test_data['generic']['cooler']['test_pairix_pair_gz_px2'], checkIfExists: true)]
|
||||
|
||||
sizes = file(params.test_data['generic']['cooler']['hg19_chrom_sizes'], checkIfExists: true)
|
||||
bin_size = 2000000
|
||||
|
||||
COOLER_CLOAD ( input, bin_size, sizes )
|
||||
COOLER_DUMP(COOLER_CLOAD.out.cool.map{[it[0], it[2]]}, [])
|
||||
|
||||
}
|
||||
|
||||
workflow test_cooler_cload_pairs {
|
||||
|
||||
input = [ [ id:'test_pairs', single_end:false ], // meta map
|
||||
file(params.test_data['generic']['cooler']['test_pairs_pair'], checkIfExists: true),
|
||||
[]]
|
||||
|
||||
sizes = file(params.test_data['generic']['cooler']['hg19_chrom_sizes'], checkIfExists: true)
|
||||
bin_size = 2000000
|
||||
|
||||
COOLER_CLOAD_PAIRS ( input, bin_size, sizes )
|
||||
COOLER_DUMP_PAIRS(COOLER_CLOAD_PAIRS.out.cool.map{[it[0], it[2]]}, [])
|
||||
|
||||
}
|
||||
|
||||
workflow test_cooler_cload_tabix {
|
||||
|
||||
input = [ [ id:'test_tabix', single_end:false ], // meta map
|
||||
file(params.test_data['generic']['cooler']['test_tabix_pair_gz'], checkIfExists: true),
|
||||
file(params.test_data['generic']['cooler']['test_tabix_pair_gz_tbi'], checkIfExists: true)]
|
||||
|
||||
sizes = file(params.test_data['generic']['cooler']['hg19_chrom_sizes'], checkIfExists: true)
|
||||
bin_size = 2000000
|
||||
|
||||
COOLER_CLOAD_TABIX ( input, bin_size, sizes )
|
||||
COOLER_DUMP_TABIX(COOLER_CLOAD_TABIX.out.cool.map{[it[0], it[2]]}, [])
|
||||
|
||||
}
|
29
tests/modules/cooler/cload/test.yml
Normal file
29
tests/modules/cooler/cload/test.yml
Normal file
|
@ -0,0 +1,29 @@
|
|||
- name: cooler cload test_cooler_cload_pairix
|
||||
command: nextflow run tests/modules/cooler/cload -entry test_cooler_cload_pairix -c tests/config/nextflow.config
|
||||
tags:
|
||||
- cooler/cload
|
||||
- cooler
|
||||
files:
|
||||
- path: output/cooler/test_pairix.2000000.cool
|
||||
- path: output/cooler/test_pairix.bedpe
|
||||
md5sum: 0cd85311089669688ec17468eae02111
|
||||
|
||||
- name: cooler cload test_cooler_cload_pairs
|
||||
command: nextflow run tests/modules/cooler/cload -entry test_cooler_cload_pairs -c tests/config/nextflow.config
|
||||
tags:
|
||||
- cooler/cload
|
||||
- cooler
|
||||
files:
|
||||
- path: output/cooler/test_pairs.2000000.cool
|
||||
- path: output/cooler/test_pairs.bedpe
|
||||
md5sum: 7f832733fc7853ebb1937b33e4c1e0de
|
||||
|
||||
- name: cooler cload test_cooler_cload_tabix
|
||||
command: nextflow run tests/modules/cooler/cload -entry test_cooler_cload_tabix -c tests/config/nextflow.config
|
||||
tags:
|
||||
- cooler/cload
|
||||
- cooler
|
||||
files:
|
||||
- path: output/cooler/test_tabix.2000000.cool
|
||||
- path: output/cooler/test_tabix.bedpe
|
||||
md5sum: 0cd85311089669688ec17468eae02111
|
Loading…
Reference in a new issue