nf-core_modules/modules/lima/functions.nf

79 lines
2.6 KiB
Text
Raw Normal View History

New module: `LIMA` (#719) * 📦 NEW: Add module lima * 👌 IMPROVE: Move .pbi output to reports channel * 🐛 FIX: Fix report channel definition * 👌IMPROVE; Remove options from command line update test script with removed options * 👌 IMPROVE: Add some pacbio test files * 🐛 FIX: Add Pacbio index to test_data.config * 👌 IMPROVE: Re add 10000 data test * 🐛 FIX: Add pbi input * 👌 IMPROVE: Add parallelization to lima * 👌 IMPROVE: Add some pbindex * 🐛 FIX: Add pbi extension to files * 👌 IMPROVE: The accept one channel (primers move into the first channel) * 👌 IMPROVE: Assign a value channel for pimers Improve code workflow readability * 👌 IMPROVE: Update .gitignore * 👌 IMPROVE: Update module to last template version * 🐛 FIX: Correct Singularity and Docker URL * 👌 IMPROVE: Update to the last version of modules template * 👌 IMPROVE: Update test_data.config * 👌 IMPROVE: Remove pbi from input files * 👌 IMPROVE: Final version of test datasets config * 👌 IMPROVE: Remove useless index + Fix Typos * 🐛 FIX: Fill contains args * 📦 NEW: Add module lima * 👌 IMPROVE: Move .pbi output to reports channel * 🐛 FIX: Fix report channel definition * 👌IMPROVE; Remove options from command line update test script with removed options * 🐛 FIX: Add pbi input * 👌 IMPROVE: Add parallelization to lima * 👌 IMPROVE: Add some pacbio test files * 🐛 FIX: Add Pacbio index to test_data.config * 👌 IMPROVE: Re add 10000 data test * 👌 IMPROVE: Add some pbindex * 🐛 FIX: Add pbi extension to files * 👌 IMPROVE: The accept one channel (primers move into the first channel) * 👌 IMPROVE: Assign a value channel for pimers Improve code workflow readability * 👌 IMPROVE: Update .gitignore * 👌 IMPROVE: Update module to last template version * 🐛 FIX: Correct Singularity and Docker URL * 👌 IMPROVE: Update to the last version of modules template * 👌 IMPROVE: Update test_data.config * 👌 IMPROVE: Remove pbi from input files * 👌 IMPROVE: Final version of test datasets config * 👌 IMPROVE: Remove useless index + Fix Typos * 🐛 FIX: Fill contains args * 👌 IMPROVE: Add channel for each output * 👌 IMPROVE: Remove comments * 📦 NEW: Add module lima * 👌 IMPROVE: Move .pbi output to reports channel * 🐛 FIX: Fix report channel definition * 👌IMPROVE; Remove options from command line update test script with removed options * 🐛 FIX: Add pbi input * 👌 IMPROVE: Add parallelization to lima * 👌 IMPROVE: Add some pacbio test files * 🐛 FIX: Add Pacbio index to test_data.config * 👌 IMPROVE: Re add 10000 data test * 👌 IMPROVE: Add some pbindex * 🐛 FIX: Add pbi extension to files * 👌 IMPROVE: The accept one channel (primers move into the first channel) * 👌 IMPROVE: Assign a value channel for pimers Improve code workflow readability * 👌 IMPROVE: Update module to last template version * 🐛 FIX: Correct Singularity and Docker URL * 👌 IMPROVE: Update to the last version of modules template * 👌 IMPROVE: Update test_data.config * 👌 IMPROVE: Remove pbi from input files * 🐛 FIX: Fill contains args * 📦 NEW: Add module lima * 👌 IMPROVE: Move .pbi output to reports channel * 🐛 FIX: Fix report channel definition * 👌IMPROVE; Remove options from command line update test script with removed options * 🐛 FIX: Add pbi input * 👌 IMPROVE: Add parallelization to lima * 👌 IMPROVE: Add some pacbio test files * 🐛 FIX: Add Pacbio index to test_data.config * 👌 IMPROVE: Re add 10000 data test * 👌 IMPROVE: Add some pbindex * 🐛 FIX: Add pbi extension to files * 👌 IMPROVE: The accept one channel (primers move into the first channel) * 👌 IMPROVE: Assign a value channel for pimers Improve code workflow readability * 👌 IMPROVE: Update module to last template version * 🐛 FIX: Correct Singularity and Docker URL * 👌 IMPROVE: Update to the last version of modules template * 👌 IMPROVE: Update test_data.config * 👌 IMPROVE: Remove pbi from input files * 👌 IMPROVE: Final version of test datasets config * 👌 IMPROVE: Remove useless index + Fix Typos * 🐛 FIX: Fill contains args * 👌 IMPROVE: Add channel for each output * 👌 IMPROVE: Remove comments * 🐛 FIX: Clean test_data.config * Update modules/lima/main.nf Add meta to each output Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Update modules/lima/main.nf Remove useless parenthesis Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * 🐛 FIX: Keep version number only * 🐛 FIX: Reintegrate prefix variable and use it to define output file name * 👌 IMPROVE: add suffix arg to check output files names * 👌 IMPROVE: Use prefix for output filename * 🐛 FIX: Set optional output Allow usage of different input formats * 👌 IMPROVE: Update meta file * 👌 IMPROVE: Update test One test for each input file type * 👌 IMPROVE: add fasta, fastq.gz, fastq, fastq.gz test files * 👌 IMPROVE: Update with last templates / Follow new version.yaml rule * 🐛 FIX: Fix typos and include getProcessName function * 👌 IMPROVE: Update .gitignore * 👌 IMPROVE: Using suffix to manage output was not a my best idea Add a bash code to detect extension and update output file name * 👌 IMPROVE: clean code Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> Co-authored-by: Gregor Sturm <mail@gregor-sturm.de> Co-authored-by: Mahesh Binzer-Panchal <mahesh.binzer-panchal@nbis.se>
2021-09-27 15:14:35 +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()
}
//
// 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"
}
}