nf-core_modules/modules/chromap/index/functions.nf

69 lines
2.5 KiB
Text
Raw Normal View History

Chromap Module (#659) * Initialise chromap module * Revert "Initialise chromap module" This reverts commit 47c67ae231a6f221ef5b9b7b444b583b5406852b. * Remake chromap base files with new layout * Copy chromap * Copy index * Add compression * Update padding * Update container * Update chromap input test data * Add chromap chromap tests * Add padding * Update comment * update yaml file * Remove TODOs * Add fasta input to yaml * Update YAML * Remove comment, update container * Remove comments * Import Chromap index * Update test.yml * Fix read input * Update test.yml * Add bcftools/concat module. (#641) * draft for bcftools modules [ci skip] * initial test for bcftools concat * Update the params for testing * fix tests * Accomodate code review [ci skip] Co-authored-by: James A. Fellows Yates <jfy133@gmail.com> * Update the meta file and open PR for review * Update the keyword * Update the tags for module [ci skip[ * add threads Co-authored-by: James A. Fellows Yates <jfy133@gmail.com> * add module for dragonflye (#633) * add module for dragonflye * fix tests for dragonflye * Update test.yml * Update meta.yml * Update main.nf * Update main.nf * Update modules/dragonflye/meta.yml Co-authored-by: Gregor Sturm <mail@gregor-sturm.de> * update typos. change quote from ' to ". (#652) * Add bcftools/norm module (#655) * Initial draft [ci skip] * trigger first test * update output file path * Tests passing * finishing touches for meta.yml and update checksum * tweak checksum * add threads to the module * skip version info for matching test md5sum [ci skip] * Add ref fasta and finalize the module Co-authored-by: Gregor Sturm <mail@gregor-sturm.de> * Expansionhunter (#666) Please enter the commit message for your changes. Lines starting * adds expansionhunter module Co-authored-by: Maxime U. Garcia <maxime.garcia@scilifelab.se> * Update test.yml (#668) * Specify in guidelines one should split CPUs when module has n > 1 tool (#660) * Specify more guidelines on input channels * Linting * Updates based on code review * Update README.md * Fix broken sentence * Describe CPU splitting * Update README.md Co-authored-by: Gregor Sturm <mail@gregor-sturm.de> * More CPU examples Co-authored-by: Gregor Sturm <mail@gregor-sturm.de> * Add dsh-bio export-segments module (#631) Co-authored-by: Gregor Sturm <mail@gregor-sturm.de> * update: `BWA/ALN` (#653) * Specify more guidelines on input channels * Linting * Updates based on code review * Update README.md * Fix broken sentence * Remove reads from output channel following module guidelines. Should do a .join() based on $meta, to reassociate. Co-authored-by: Gregor Sturm <mail@gregor-sturm.de> * Update seqwish reported version to match bioconda version. (#678) * Bbmap index (#683) BBMap index module * Initialise chromap module * Revert "Initialise chromap module" This reverts commit 47c67ae231a6f221ef5b9b7b444b583b5406852b. * Remove unnecessary files * Remove unnecessary files * Update modules/chromap/index/main.nf Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Update modules/chromap/index/main.nf Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Update modules/chromap/chromap/main.nf Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Update tests/modules/chromap/chromap/main.nf Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Update tests/modules/chromap/chromap/main.nf Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Update tests/modules/chromap/chromap/main.nf Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Update modules/chromap/index/main.nf Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Remove pytest_software.yml * Apply suggestions from code review Co-authored-by: Abhinav Sharma <abhi18av@users.noreply.github.com> Co-authored-by: James A. Fellows Yates <jfy133@gmail.com> Co-authored-by: Robert A. Petit III <robbie.petit@gmail.com> Co-authored-by: Gregor Sturm <mail@gregor-sturm.de> Co-authored-by: JIANHONG OU <jianhong@users.noreply.github.com> Co-authored-by: Anders Jemt <jemten@users.noreply.github.com> Co-authored-by: Maxime U. Garcia <maxime.garcia@scilifelab.se> Co-authored-by: Michael L Heuer <heuermh@acm.org> Co-authored-by: Daniel Lundin <daniel.lundin@lnu.se> Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
2021-09-15 16:20:55 +00:00
//
// 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"
}
}
}