diff --git a/CHANGELOG.md b/CHANGELOG.md index 957a9f5..c5a5880 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,12 @@ -# demultiplex v0.1.2 +# demultiplex v0.2.0 + +## Breaking changes + +* `demultiplex` workflow: renamed `sample_sheet` argument to `run_information` (PR #24) + +## New features + +* Add support for `bases2fastq` demultiplexer (PR #24) ## Minor updates diff --git a/src/dataflow/combine_samples/config.vsh.yaml b/src/dataflow/combine_samples/config.vsh.yaml index d82717e..3e34d99 100644 --- a/src/dataflow/combine_samples/config.vsh.yaml +++ b/src/dataflow/combine_samples/config.vsh.yaml @@ -11,9 +11,11 @@ argument_groups: - name: --forward_input type: file required: true + multiple: true - name: --reverse_input type: file required: false + multiple: true - name: Output arguments arguments: - name: --output_forward diff --git a/src/dataflow/combine_samples/main.nf b/src/dataflow/combine_samples/main.nf index 1a16fa6..a41e6f5 100644 --- a/src/dataflow/combine_samples/main.nf +++ b/src/dataflow/combine_samples/main.nf @@ -11,8 +11,8 @@ workflow run_wf { | groupTuple(by: 0, sort: "hash") | map {run_id, states -> // Gather the following state for all samples - def forward_fastqs = states.collect{it.forward_input} - def reverse_fastqs = states.collect{it.reverse_input}.findAll{it != null} + def forward_fastqs = states.collect{it.forward_input}.flatten() + def reverse_fastqs = states.collect{it.reverse_input}.findAll{it != null}.flatten() def resultState = [ "output_forward": forward_fastqs, diff --git a/src/dataflow/gather_fastqs_and_validate/config.vsh.yaml b/src/dataflow/gather_fastqs_and_validate/config.vsh.yaml index e0b7733..3f8e4b2 100644 --- a/src/dataflow/gather_fastqs_and_validate/config.vsh.yaml +++ b/src/dataflow/gather_fastqs_and_validate/config.vsh.yaml @@ -20,10 +20,12 @@ argument_groups: type: file direction: output required: true + multiple: true - name: "--fastq_reverse" type: file direction: output required: false + multiple: true resources: - type: nextflow_script path: main.nf diff --git a/src/dataflow/gather_fastqs_and_validate/main.nf b/src/dataflow/gather_fastqs_and_validate/main.nf index e6afd77..78fff61 100644 --- a/src/dataflow/gather_fastqs_and_validate/main.nf +++ b/src/dataflow/gather_fastqs_and_validate/main.nf @@ -14,9 +14,11 @@ workflow run_wf { def original_id = id // Parse sample sheet for sample IDs + println "Processing run information file ${sample_sheet}" csv_lines = sample_sheet.splitCsv(header: false, sep: ',') csv_lines.any { csv_items -> if (csv_items.isEmpty()) { + // skip empty line return } def possible_header = csv_items[0] @@ -24,22 +26,40 @@ workflow run_wf { if (header) { if (start_parsing) { // Stop parsing when encountering the next header + println "Encountered next header '[${start_parsing}]', stopping parsing." return true } - if (header == "Data") { + // [Data] for illumina + // [Samples] for Element Biosciences + if (header in ["Data", "Samples"]) { + println "Found header [${header}], start parsing." start_parsing = true + return } } if (start_parsing) { - if ( !sample_id_column_index ) { - sample_id_column_index = csv_items.findIndexValues{it == "Sample_ID"} - assert sample_id_column_index != -1: - "Could not find column 'Sample_ID' in sample sheet!" + if ( sample_id_column_index == null) { + println "Looking for sample name column." + sample_id_column_index = csv_items.findIndexValues{it == "Sample_ID" || it == "SampleName"} + assert (!sample_id_column_index.isEmpty()): + "Could not find column 'Sample_ID' (Illumina) or 'SampleName' " + + "(Element Biosciences) in run information! Found: ${sample_id_column_index}" + assert sample_id_column_index.size() == 1, "Expected run information file to contain " + + "a column 'Sample_ID' or 'SampleName', not both. Found: ${sample_id_column_index}" + sample_id_column_index = sample_id_column_index[0] + println "Found sample names column '${csv_items[sample_id_column_index]}'." return } samples += csv_items[sample_id_column_index] } + // This return is important! (If 'true' is returned, the parsing stops.) + return } + assert start_parsing: + "Sample information file does not contain [Data] or [Samples] header!" + assert samples.size() > 1: + "Sample information file does not seem to contain any information about the samples!" + println "Finished processing run information file, found samples: ${samples}." println "Looking for fastq files in ${state.input}." def allfastqs = state.input.listFiles().findAll{it.isFile() && it.name ==~ /^.+\.fastq.gz$/} println "Found ${allfastqs.size()} fastq files, matching them to the following samples: ${samples}." @@ -48,17 +68,15 @@ workflow run_wf { def reverse_regex = ~/^${sample_id}_S(\d+)_(L(\d+)_)?R2_(\d+)\.fastq\.gz$/ def forward_fastq = state.input.listFiles().findAll{it.isFile() && it.name ==~ forward_regex} def reverse_fastq = state.input.listFiles().findAll{it.isFile() && it.name ==~ reverse_regex} - assert forward_fastq : "No forward fastq files were found for sample ${sample_id}" - assert forward_fastq.size() < 2: - "Found multiple forward fastq files corresponding to sample ${sample_id}: ${forward_fastq}" - assert reverse_fastq.size() < 2: - "Found multiple reverse fastq files corresponding to sample ${sample_id}: ${reverse_fastq}." - assert !forward_fastq.isEmpty(): - "Expected a forward fastq file to have been created correspondig to sample ${sample_id}." - // TODO: if one sample had reverse reads, the others must as well. - reverse_fastq = !reverse_fastq.isEmpty() ? reverse_fastq[0] : null + assert forward_fastq && !forward_fastq.isEmpty(): "No forward fastq files were found for sample ${sample_id}. " + + "All fastq files in directory: ${allfastqs.collect{it.name}}" + assert (reverse_fastq.isEmpty() || (forward_fastq.size() == reverse_fastq.size())): + "Expected equal number of forward and reverse fastq files for sample ${sample_id}. " + + "Found forward: ${forward_fastq} and reverse: ${reverse_fastq}." + println "Found ${forward_fastq.size()} forward and ${reverse_fastq.size()} reverse " + + "fastq files for sample ${sample_id}" def fastqs_state = [ - "fastq_forward": forward_fastq[0], + "fastq_forward": forward_fastq, "fastq_reverse": reverse_fastq, "_meta": [ "join_id": original_id ], ] diff --git a/src/demultiplex/config.vsh.yaml b/src/demultiplex/config.vsh.yaml index 2e13d3a..d275653 100644 --- a/src/demultiplex/config.vsh.yaml +++ b/src/demultiplex/config.vsh.yaml @@ -7,12 +7,24 @@ argument_groups: description: Directory containing raw sequencing data type: file required: true - - name: --sample_sheet + - name: --run_information description: | - Sample sheet as input for BCL Convert. If not specified, - will try to autodetect the sample sheet in the input directory + CSV file containing sample information, which will be used as + input for the demultiplexer. Canonically called 'SampleSheet.csv' (Illumina) + or 'RunManifest.csv' (Element Biosciences). If not specified, + will try to autodetect the sample sheet in the input directory. + Requires --demultiplexer to be set. type: file required: false + - name: "--demultiplexer" + type: string + required: false + choices: ["bases2fastq", "bclconvert"] + description: | + Demultiplexer to use, choice depends on the provider + of the instrument that was used to generate the data. + When not using --sample_sheet, specifying this argument is not + required. - name: Output arguments arguments: - name: --output @@ -40,7 +52,10 @@ resources: test_resources: - type: nextflow_script path: test.nf - entrypoint: test_wf + entrypoint: test_illumina + - type: nextflow_script + path: test.nf + entrypoint: test_bases2fastq dependencies: - name: io/untar @@ -53,6 +68,8 @@ dependencies: repository: local - name: bcl_convert repository: bb + - name: bases2fastq + repository: bb - name: falco repository: bb - name: multiqc @@ -61,7 +78,7 @@ repositories: - name: bb type: vsh repo: biobox - tag: v0.2.0 + tag: v0.3.0 runners: - type: nextflow diff --git a/src/demultiplex/integration_tests.sh b/src/demultiplex/integration_tests.sh index c5f6901..d2e486f 100755 --- a/src/demultiplex/integration_tests.sh +++ b/src/demultiplex/integration_tests.sh @@ -11,7 +11,14 @@ viash ns build --setup cb nextflow run . \ -main-script src/demultiplex/test.nf \ -profile docker,no_publish,local \ - -entry test_wf \ + -entry test_illumina \ -c src/config/labels.config \ --resources_test https://raw.githubusercontent.com/nf-core/test-datasets/demultiplex/testdata/NovaSeq6000/ \ -resume + + nextflow run . \ + -main-script src/demultiplex/test.nf \ + -profile docker,no_publish,local \ + -entry test_bases2fastq \ + -c src/config/labels.config \ + -resume \ No newline at end of file diff --git a/src/demultiplex/main.nf b/src/demultiplex/main.nf index fa3c3ae..c4cb8ab 100644 --- a/src/demultiplex/main.nf +++ b/src/demultiplex/main.nf @@ -23,22 +23,79 @@ workflow run_wf { // Gather input files from folder | map {id, state -> def newState = [:] - if (!state.sample_sheet) { - def sample_sheet = state.input.resolve("SampleSheet.csv") - assert (sample_sheet && sample_sheet.isFile()): "Could not find 'SampleSheet.csv' file in input directory." - newState["sample_sheet"] = sample_sheet + println("Provided run information: ${state.run_information} and demultiplexer: ${state.demultiplexer}") + if (!state.run_information) { + println("Run information was not specified, auto-detecting...") + // The supported_platforms hashmap must be a 1-on-1 mapping + // Also, it's keys must be present in the 'choices' field + // for the 'run_information' argument in the viash config. + def supported_platforms = [ + "bclconvert": "SampleSheet.csv", // Illumina + "bases2fastq": "RunManifest.csv" // Element Biosciences + ] + def found_sample_information = supported_platforms.collectEntries{demultiplexer, filename -> + println("Checking if ${filename} can be found in input folder ${state.input}.") + def resolved_filename = state.input.resolve(filename) + if (!resolved_filename.isFile()) { + resolved_filename = null + } + println("Result after looking for run information for ${demultiplexer}: ${resolved_filename}.") + [demultiplexer, resolved_filename] + } + def demultiplexer = null + def run_information = null + found_sample_information.each{demultiplexer_candidate, file_path -> + if (file_path) { + // At this point, a candicate run information file was found. + assert !run_information: "Autodetection of run information " + + "(SampleSheet, RunManifest) failed: " + + "multiple candidate files found in input folder. " + + "Please specify one using --run_information." + run_information = file_path + demultiplexer = demultiplexer_candidate + } + } + + // When autodetecting, the run information should have been found + assert run_information: "No run information file (SampleSheet, RunManifest) " + + "found in input directory." + + // When autodetecting, the demultiplexer must be set if the run information was found + assert demultiplexer, "State error: the demultiplexer should have been autodetected. " + + "Please report this as a bug." + + // When autodetecting, the found demultiplexer must match + // with the demultiplexer that the user has provided (in case it was provided). + if (state.demultiplexer) { + assert state.demultiplexer == demultiplexer, + "Requested to use demultiplexer ${state.demultiplexer} " + + "but demultiplexer based on the autodetected run information " + "file ${run_information} seems to indicate that the demultiplexer " + "should be ${demultiplexer}. Either avoid specifying the demultiplexer " + "or override the autodetection of the run information by providing " + "the file." + } + println("Using run information ${run_information} and demultiplexer ${demultiplexer}") + // At this point, the autodetected state can override the user provided state. + newState = newState + [ + "run_information": run_information, + "demultiplexer": demultiplexer, + ] } - // Do not add InterOp to state because we generate the summary csv's in the next - // step based on the run dir, not the InterOp dir. - def interop_dir = state.input.resolve("InterOp") - assert interop_dir.isDirectory(): "Expected InterOp directory to be present." + if (newState.demultiplexer in ["bclconvert"]) { + // Do not add InterOp to state because we generate the summary csv's in the next + // step based on the run dir, not the InterOp dir. + def interop_dir = state.input.resolve("InterOp") + assert interop_dir.isDirectory(): "Expected InterOp directory to be present." + } def resultState = state + newState [id, resultState] } | interop_summary_to_csv.run( + runIf: {id, state -> state.demultiplexer in ["bclconvert"]}, directives: [label: ["lowmem", "verylowcpu"]], fromState: [ "input": "input", @@ -50,16 +107,40 @@ workflow run_wf { ) // run bcl_convert | bcl_convert.run( + runIf: {id, state -> state.demultiplexer in ["bclconvert"]}, directives: [label: ["highmem", "midcpu"]], fromState: [ "bcl_input_directory": "input", - "sample_sheet": "sample_sheet", + "sample_sheet": "run_information", "output_directory": "output", ], toState: {id, result, state -> def toAdd = [ - "output_bclconvert" : result.output_directory, - "bclconvert_reports": result.reports, + "output_demultiplexer" : result.output_directory, + "run_id": id, + ] + def newState = state + toAdd + return newState + } + ) + // run bases2fastq + | bases2fastq.run( + runIf: {id, state -> state.demultiplexer in ["bases2fastq"]}, + directives: [label: ["highmem", "midcpu"]], + fromState: [ + "analysis_directory": "input", + "run_manifest": "run_information", + "output_directory": "output", + ], + args: [ + "no_projects": true, // Do not put output files in a subfolder for project + //"split_lanes": true, + "legacy_fastq": true, // Illumina style output names + "group_fastq": true, // No subdir per sample + ], + toState: {id, result, state -> + def toAdd = [ + "output_demultiplexer" : result.output_directory, "run_id": id, ] def newState = state + toAdd @@ -68,8 +149,8 @@ workflow run_wf { ) | gather_fastqs_and_validate.run( fromState: [ - "input": "output_bclconvert", - "sample_sheet": "sample_sheet", + "input": "output_demultiplexer", + "sample_sheet": "run_information", ], toState: [ "fastq_forward": "fastq_forward", @@ -110,15 +191,18 @@ workflow run_wf { | multiqc.run( directives: [label: ["lowcpu", "lowmem"]], fromState: {id, state -> - [ - "input": [ - state.output_falco, + def new_state = [ + "input": [state.output_falco], + "output_report": state.output_multiqc, + "cl_config": 'sp: {fastqc/data: {fn: "*_fastqc_data.txt"}}' + ] + if (state.demultiplexer == "bclconvert") { + new_state["input"] += [ state.interop_run_summary.getParent(), state.interop_index_summary.getParent() - ], - "output_report": state.output_multiqc, - "cl_config": 'sp: {fastqc/data: {fn: "*_fastqc_data.txt"}}', - ] + ] + } + return new_state }, toState: { id, result, state -> state + [ "output_multiqc" : result.output_report ] @@ -126,7 +210,7 @@ workflow run_wf { ) | setState( [ - "output": "output_bclconvert", + "output": "output_demultiplexer", "output_falco": "output_falco", "output_multiqc": "output_multiqc" ] diff --git a/src/demultiplex/test.nf b/src/demultiplex/test.nf index 922fb81..92d708d 100644 --- a/src/demultiplex/test.nf +++ b/src/demultiplex/test.nf @@ -4,7 +4,7 @@ include { demultiplex } from params.rootDir + "/target/nextflow/demultiplex/main params.resources_test = params.rootDir + "/testData/" -workflow test_wf { +workflow test_illumina { output_ch = Channel.fromList([ [ // sample_sheet: resources_test.resolve("bcl_convert_samplesheet.csv"), @@ -27,5 +27,36 @@ workflow test_wf { assert state.output.isDirectory(): "Expected bclconvert output to be a directory" assert state.output_falco.isDirectory(): "Expected falco output to be a directory" assert state.output_multiqc.isFile(): "Expected multiQC output to be a file" + fastq_files = state.output.listFiles().collect{it.name} + assert ["Undetermined_S0_L001_R1_001.fastq.gz", "Sample23_S3_L001_R1_001.fastq.gz", + "sampletest_S4_L001_R1_001.fastq.gz", "Sample1_S1_L001_R1_001.fastq.gz", + "SampleA_S2_L001_R1_001.fastq.gz"].toSet() == fastq_files.toSet(): \ + "Output directory should contain the expected FASTQ files" + fastq_files.each{ + assert it.length() != 0: "Expected FASTQ file to not be empty" + } + } +} + +workflow test_bases2fastq { + output_ch = Channel.fromList([ + [ + input: "http://element-public-data.s3.amazonaws.com/bases2fastq-share/bases2fastq-v2/20230404-bases2fastq-sim-151-151-9-9.tar.gz", + publish_dir: "output_dir/", + ] + ]) + | map { state -> [ "run", state ] } + | demultiplex.run( + toState: { id, output, state -> + output + [ orig_input: state.input ] } + ) + | view { output -> + assert output.size() == 2 : "outputs should contain two elements; [id, file]" + "Output: $output" + } + | map {id, state -> + assert state.output.isDirectory(): "Expected bases2fastq output to be a directory" + assert state.output_falco.isDirectory(): "Expected falco output to be a directory" + assert state.output_multiqc.isFile(): "Expected multiQC output to be a file" } } diff --git a/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/bases2fastq/.config.vsh.yaml b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/bases2fastq/.config.vsh.yaml new file mode 100644 index 0000000..ab735b6 --- /dev/null +++ b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/bases2fastq/.config.vsh.yaml @@ -0,0 +1,421 @@ +name: "bases2fastq" +version: "v0.3.0" +authors: +- name: "Dries Schaumont" + roles: + - "author" + - "maintainer" + info: + links: + email: "dries@data-intuitive.com" + github: "DriesSchaumont" + orcid: "0000-0002-4389-0440" + linkedin: "dries-schaumont" + organizations: + - name: "Data Intuitive" + href: "https://www.data-intuitive.com" + role: "Data Scientist" +argument_groups: +- name: "Input" + arguments: + - type: "file" + name: "--analysis_directory" + description: "Location of analysis directory" + info: null + example: + - "input" + must_exist: true + create_parent: true + required: true + direction: "input" + multiple: false + multiple_sep: ";" + - type: "file" + name: "--run_manifest" + alternatives: + - "-r" + description: "Location of run manifest to use instead of default RunManifest.csv\ + \ found in analysis directory" + info: null + must_exist: true + create_parent: true + required: false + direction: "input" + multiple: false + multiple_sep: ";" +- name: "Output" + arguments: + - type: "file" + name: "--output_directory" + alternatives: + - "-o" + description: "Location to save output fastqs" + info: null + example: + - "fastq_dir" + must_exist: true + create_parent: true + required: true + direction: "output" + multiple: false + multiple_sep: ";" + - type: "file" + name: "--report" + description: "Output location for the HTML report" + info: null + must_exist: true + create_parent: true + required: false + direction: "output" + multiple: false + multiple_sep: ";" + - type: "file" + name: "--logs" + description: "Directory containing log files" + info: null + example: + - "logs_dir" + must_exist: true + create_parent: true + required: false + direction: "output" + multiple: false + multiple_sep: ";" +- name: "Arguments" + arguments: + - type: "string" + name: "--chemistry_version" + description: "Run parameters override, chemistry version." + info: null + required: false + direction: "input" + multiple: false + multiple_sep: ";" + - type: "boolean_true" + name: "--demux_only" + alternatives: + - "-d" + description: "Generate demux files and indexing stats without generating FASTQ\n" + info: null + direction: "input" + - type: "boolean_true" + name: "--detect_adapters" + description: "Detect adapters sequences, overriding any sequences present in run\ + \ manifest.\n" + info: null + direction: "input" + - type: "boolean_true" + name: "--error_on_missing" + description: "Terminate execution for a missing file (by default, missing files\ + \ are\nskipped and execution continues). Also set by --strict.\n" + info: null + direction: "input" + - type: "string" + name: "--exclude_tile" + alternatives: + - "-e" + description: "Regex matching tile names to exclude. This flag can be specified\ + \ multiple times. (e.g. L1.*C0[23]S.)\n" + info: null + required: false + direction: "input" + multiple: true + multiple_sep: ";" + - type: "string" + name: "--filter_mask" + description: "Run parameters override, custom pass filter mask.\n" + info: null + required: false + direction: "input" + multiple: false + multiple_sep: ";" + - type: "string" + name: "--flowcell_id" + description: "Run parameters override, flowcell ID.\n" + info: null + required: false + direction: "input" + multiple: false + multiple_sep: ";" + - type: "boolean_true" + name: "--force_index_orientation" + description: "Do not attempt to find orientation for I1/I2 reads (reverse complement).\n\ + Use orientation given in run manifest.\n" + info: null + direction: "input" + - type: "boolean_true" + name: "--group_fastq" + description: "Group all FASTQ/stats/metrics for a project are in the project folder.\n" + info: null + direction: "input" + - type: "integer" + name: "--i1_cycles" + description: "Run parameters override, I1 cycles.\n" + info: null + required: false + min: 1 + direction: "input" + multiple: false + multiple_sep: ";" + - type: "integer" + name: "--i2_cycles" + description: "Run parameters override, I2 cycles\n" + info: null + required: false + min: 1 + direction: "input" + multiple: false + multiple_sep: ";" + - type: "string" + name: "--include_tile" + alternatives: + - "-i" + description: "Regex matching tile names to include. This flag\ncan be specified\ + \ multiple times. (e.g. L1.*C0[23]S.)\n" + info: null + required: false + direction: "input" + multiple: true + multiple_sep: ";" + - type: "string" + name: "--kit_configuration" + description: "Run parameters override, kit configuration.\n" + info: null + required: false + direction: "input" + multiple: false + multiple_sep: ";" + - type: "boolean_true" + name: "--legacy_fastq" + description: "Legacy naming for FASTQ files (e.g. SampleName_S1_L001_R1_001.fastq.gz)\n" + info: null + direction: "input" + - type: "string" + name: "--log_level" + alternatives: + - "-l" + description: "Severity level for logging.\n" + info: null + example: + - "INFO" + required: false + choices: + - "DEBUG" + - "INFO" + - "WARNING" + - "ERROR" + direction: "input" + multiple: false + multiple_sep: ";" + - type: "boolean_true" + name: "--no_error_on_invalid" + description: "Skip invalid files and continue execution. Overridden by --strict\ + \ options\n" + info: null + direction: "input" + - type: "boolean_true" + name: "--no_projects" + description: "Disable project directories\n" + info: null + direction: "input" + - type: "integer" + name: "--num_unassigned" + description: "Max Number of unassigned sequences to report.\n" + info: null + example: + - 30 + required: false + min: 0 + max: 1000 + direction: "input" + multiple: false + multiple_sep: ";" + - type: "string" + name: "--preparation_workflow" + description: "Run parameters override, preparation workflow. \n" + info: null + required: false + direction: "input" + multiple: false + multiple_sep: ";" + - type: "boolean_true" + name: "--qc_only" + description: "Quickly generate run stats for single tile without generating FASTQ.\n\ + Use --include_tile/--exclude_tile to define custom tile set.\n" + info: null + direction: "input" + - type: "integer" + name: "--r1_cycles" + description: "Run parameters override, R1 cycles.\n" + info: null + required: false + min: 1 + direction: "input" + multiple: false + multiple_sep: ";" + - type: "integer" + name: "--r2_cycles" + description: "Run parameters override, R2 cycles.\n" + info: null + required: false + min: 1 + direction: "input" + multiple: false + multiple_sep: ";" + - type: "boolean_true" + name: "--split_lanes" + description: "Split FASTQ files by lane.\n" + info: null + direction: "input" + - type: "boolean_true" + name: "--strict" + description: "In strict mode any invalid or missing input file will terminate\ + \ execution \n(overrides no_error_on_invalid and sets --error_on_missing)\n" + info: null + direction: "input" +resources: +- type: "bash_script" + path: "script.sh" + is_executable: true +description: "Bases2Fastq demultiplexes sequencing data generated by Element Biosciences\ + \ instruments and converts base calls into FASTQ files.\n" +test_resources: +- type: "bash_script" + path: "test.sh" + is_executable: true +info: null +status: "enabled" +requirements: + commands: + - "ps" +keywords: +- "demultiplex" +- "fastq" +- "demux" +- "Element Biosciences" +license: "Proprietairy" +links: + repository: "https://github.com/viash-hub/biobox" + documentation: "https://docs.elembio.io/docs/bases2fastq/introduction/" +runners: +- type: "executable" + id: "executable" + docker_setup_strategy: "ifneedbepullelsecachedbuild" +- type: "nextflow" + id: "nextflow" + directives: + tag: "$id" + auto: + simplifyInput: true + simplifyOutput: false + transcript: false + publish: false + config: + labels: + mem1gb: "memory = 1000000000.B" + mem2gb: "memory = 2000000000.B" + mem5gb: "memory = 5000000000.B" + mem10gb: "memory = 10000000000.B" + mem20gb: "memory = 20000000000.B" + mem50gb: "memory = 50000000000.B" + mem100gb: "memory = 100000000000.B" + mem200gb: "memory = 200000000000.B" + mem500gb: "memory = 500000000000.B" + mem1tb: "memory = 1000000000000.B" + mem2tb: "memory = 2000000000000.B" + mem5tb: "memory = 5000000000000.B" + mem10tb: "memory = 10000000000000.B" + mem20tb: "memory = 20000000000000.B" + mem50tb: "memory = 50000000000000.B" + mem100tb: "memory = 100000000000000.B" + mem200tb: "memory = 200000000000000.B" + mem500tb: "memory = 500000000000000.B" + mem1gib: "memory = 1073741824.B" + mem2gib: "memory = 2147483648.B" + mem4gib: "memory = 4294967296.B" + mem8gib: "memory = 8589934592.B" + mem16gib: "memory = 17179869184.B" + mem32gib: "memory = 34359738368.B" + mem64gib: "memory = 68719476736.B" + mem128gib: "memory = 137438953472.B" + mem256gib: "memory = 274877906944.B" + mem512gib: "memory = 549755813888.B" + mem1tib: "memory = 1099511627776.B" + mem2tib: "memory = 2199023255552.B" + mem4tib: "memory = 4398046511104.B" + mem8tib: "memory = 8796093022208.B" + mem16tib: "memory = 17592186044416.B" + mem32tib: "memory = 35184372088832.B" + mem64tib: "memory = 70368744177664.B" + mem128tib: "memory = 140737488355328.B" + mem256tib: "memory = 281474976710656.B" + mem512tib: "memory = 562949953421312.B" + cpu1: "cpus = 1" + cpu2: "cpus = 2" + cpu5: "cpus = 5" + cpu10: "cpus = 10" + cpu20: "cpus = 20" + cpu50: "cpus = 50" + cpu100: "cpus = 100" + cpu200: "cpus = 200" + cpu500: "cpus = 500" + cpu1000: "cpus = 1000" + debug: false + container: "docker" +engines: +- type: "docker" + id: "docker" + image: "elembio/bases2fastq:2.1.0" + target_registry: "images.viash-hub.com" + target_tag: "v0.3.0" + namespace_separator: "/" + setup: + - type: "apt" + packages: + - "procps" + - "tree" + interactive: false + - type: "docker" + run: + - "echo \"bases2fastq: $(bases2fastq --version | cut -d' ' -f3)\" > /var/software_versions.txt\n" + test_setup: + - type: "apt" + packages: + - "curl" + interactive: false + entrypoint: [] + cmd: null +- type: "native" + id: "native" +build_info: + config: "src/bases2fastq/config.vsh.yaml" + runner: "nextflow" + engine: "docker|native" + output: "target/nextflow/bases2fastq" + executable: "target/nextflow/bases2fastq/main.nf" + viash_version: "0.9.0" + git_commit: "d86bd5cf62104af02caa852aacd352b1aa97ed60" + git_remote: "https://x-access-token:ghs_EwAUAMYJ0K4VBHlAEMs4ZP2OyQYqJM0PSfEO@github.com/viash-hub/biobox" + git_tag: "v0.2.0-29-gd86bd5c" +package_config: + name: "biobox" + version: "v0.3.0" + description: "A collection of bioinformatics tools for working with sequence data.\n" + info: null + viash_version: "0.9.0" + source: "src" + target: "target" + config_mods: + - ".requirements.commands := ['ps']\n" + - ".engines += { type: \"native\" }" + - ".engines[.type == 'docker'].target_registry := 'images.viash-hub.com'" + - ".engines[.type == 'docker'].target_tag := 'v0.3.0'" + keywords: + - "bioinformatics" + - "modules" + - "sequencing" + license: "MIT" + organization: "vsh" + links: + repository: "https://github.com/viash-hub/biobox" + issue_tracker: "https://github.com/viash-hub/biobox/issues" diff --git a/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/bases2fastq/main.nf b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/bases2fastq/main.nf new file mode 100644 index 0000000..16ca4fb --- /dev/null +++ b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/bases2fastq/main.nf @@ -0,0 +1,3965 @@ +// bases2fastq v0.3.0 +// +// This wrapper script is auto-generated by viash 0.9.0 and is thus a derivative +// work thereof. This software comes with ABSOLUTELY NO WARRANTY from Data +// Intuitive. +// +// The component may contain files which fall under a different license. The +// authors of this component should specify the license in the header of such +// files, or include a separate license file detailing the licenses of all included +// files. +// +// Component authors: +// * Dries Schaumont (author, maintainer) + +//////////////////////////// +// VDSL3 helper functions // +//////////////////////////// + +// helper file: 'src/main/resources/io/viash/runners/nextflow/arguments/_checkArgumentType.nf' +class UnexpectedArgumentTypeException extends Exception { + String errorIdentifier + String stage + String plainName + String expectedClass + String foundClass + + // ${key ? " in module '$key'" : ""}${id ? " id '$id'" : ""} + UnexpectedArgumentTypeException(String errorIdentifier, String stage, String plainName, String expectedClass, String foundClass) { + super("Error${errorIdentifier ? " $errorIdentifier" : ""}:${stage ? " $stage" : "" } argument '${plainName}' has the wrong type. " + + "Expected type: ${expectedClass}. Found type: ${foundClass}") + this.errorIdentifier = errorIdentifier + this.stage = stage + this.plainName = plainName + this.expectedClass = expectedClass + this.foundClass = foundClass + } +} + +/** + * Checks if the given value is of the expected type. If not, an exception is thrown. + * + * @param stage The stage of the argument (input or output) + * @param par The parameter definition + * @param value The value to check + * @param errorIdentifier The identifier to use in the error message + * @return The value, if it is of the expected type + * @throws UnexpectedArgumentTypeException If the value is not of the expected type +*/ +def _checkArgumentType(String stage, Map par, Object value, String errorIdentifier) { + // expectedClass will only be != null if value is not of the expected type + def expectedClass = null + def foundClass = null + + // todo: split if need be + + if (!par.required && value == null) { + expectedClass = null + } else if (par.multiple) { + if (value !instanceof Collection) { + value = [value] + } + + // split strings + value = value.collectMany{ val -> + if (val instanceof String) { + // collect() to ensure that the result is a List and not simply an array + val.split(par.multiple_sep).collect() + } else { + [val] + } + } + + // process globs + if (par.type == "file" && par.direction == "input") { + value = value.collect{ it instanceof String ? file(it, hidden: true) : it }.flatten() + } + + // check types of elements in list + try { + value = value.collect { listVal -> + _checkArgumentType(stage, par + [multiple: false], listVal, errorIdentifier) + } + } catch (UnexpectedArgumentTypeException e) { + expectedClass = "List[${e.expectedClass}]" + foundClass = "List[${e.foundClass}]" + } + } else if (par.type == "string") { + // cast to string if need be + if (value instanceof GString) { + value = value.toString() + } + expectedClass = value instanceof String ? null : "String" + } else if (par.type == "integer") { + // cast to integer if need be + if (value instanceof String) { + try { + value = value.toInteger() + } catch (NumberFormatException e) { + // do nothing + } + } + if (value instanceof java.math.BigInteger) { + value = value.intValue() + } + expectedClass = value instanceof Integer ? null : "Integer" + } else if (par.type == "long") { + // cast to long if need be + if (value instanceof String) { + try { + value = value.toLong() + } catch (NumberFormatException e) { + // do nothing + } + } + if (value instanceof Integer) { + value = value.toLong() + } + expectedClass = value instanceof Long ? null : "Long" + } else if (par.type == "double") { + // cast to double if need be + if (value instanceof String) { + try { + value = value.toDouble() + } catch (NumberFormatException e) { + // do nothing + } + } + if (value instanceof java.math.BigDecimal) { + value = value.doubleValue() + } + if (value instanceof Float) { + value = value.toDouble() + } + expectedClass = value instanceof Double ? null : "Double" + } else if (par.type == "boolean" | par.type == "boolean_true" | par.type == "boolean_false") { + // cast to boolean if need be + if (value instanceof String) { + def valueLower = value.toLowerCase() + if (valueLower == "true") { + value = true + } else if (valueLower == "false") { + value = false + } + } + expectedClass = value instanceof Boolean ? null : "Boolean" + } else if (par.type == "file" && (par.direction == "input" || stage == "output")) { + // cast to path if need be + if (value instanceof String) { + value = file(value, hidden: true) + } + if (value instanceof File) { + value = value.toPath() + } + expectedClass = value instanceof Path ? null : "Path" + } else if (par.type == "file" && stage == "input" && par.direction == "output") { + // cast to string if need be + if (value instanceof GString) { + value = value.toString() + } + expectedClass = value instanceof String ? null : "String" + } else { + // didn't find a match for par.type + expectedClass = par.type + } + + if (expectedClass != null) { + if (foundClass == null) { + foundClass = value.getClass().getName() + } + throw new UnexpectedArgumentTypeException(errorIdentifier, stage, par.plainName, expectedClass, foundClass) + } + + return value +} +// helper file: 'src/main/resources/io/viash/runners/nextflow/arguments/_processInputValues.nf' +Map _processInputValues(Map inputs, Map config, String id, String key) { + if (!workflow.stubRun) { + config.allArguments.each { arg -> + if (arg.required) { + assert inputs.containsKey(arg.plainName) && inputs.get(arg.plainName) != null : + "Error in module '${key}' id '${id}': required input argument '${arg.plainName}' is missing" + } + } + + inputs = inputs.collectEntries { name, value -> + def par = config.allArguments.find { it.plainName == name && (it.direction == "input" || it.type == "file") } + assert par != null : "Error in module '${key}' id '${id}': '${name}' is not a valid input argument" + + value = _checkArgumentType("input", par, value, "in module '$key' id '$id'") + + [ name, value ] + } + } + return inputs +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/arguments/_processOutputValues.nf' +Map _processOutputValues(Map outputs, Map config, String id, String key) { + if (!workflow.stubRun) { + config.allArguments.each { arg -> + if (arg.direction == "output" && arg.required) { + assert outputs.containsKey(arg.plainName) && outputs.get(arg.plainName) != null : + "Error in module '${key}' id '${id}': required output argument '${arg.plainName}' is missing" + } + } + + outputs = outputs.collectEntries { name, value -> + def par = config.allArguments.find { it.plainName == name && it.direction == "output" } + assert par != null : "Error in module '${key}' id '${id}': '${name}' is not a valid output argument" + + value = _checkArgumentType("output", par, value, "in module '$key' id '$id'") + + [ name, value ] + } + } + return outputs +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/channel/IDChecker.nf' +class IDChecker { + final def items = [] as Set + + @groovy.transform.WithWriteLock + boolean observe(String item) { + if (items.contains(item)) { + return false + } else { + items << item + return true + } + } + + @groovy.transform.WithReadLock + boolean contains(String item) { + return items.contains(item) + } + + @groovy.transform.WithReadLock + Set getItems() { + return items.clone() + } +} +// helper file: 'src/main/resources/io/viash/runners/nextflow/channel/_checkUniqueIds.nf' + +/** + * Check if the ids are unique across parameter sets + * + * @param parameterSets a list of parameter sets. + */ +private void _checkUniqueIds(List>> parameterSets) { + def ppIds = parameterSets.collect{it[0]} + assert ppIds.size() == ppIds.unique().size() : "All argument sets should have unique ids. Detected ids: $ppIds" +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/channel/_getChild.nf' + +// helper functions for reading params from file // +def _getChild(parent, child) { + if (child.contains("://") || java.nio.file.Paths.get(child).isAbsolute()) { + child + } else { + def parentAbsolute = java.nio.file.Paths.get(parent).toAbsolutePath().toString() + parentAbsolute.replaceAll('/[^/]*$', "/") + child + } +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/channel/_parseParamList.nf' +/** + * Figure out the param list format based on the file extension + * + * @param param_list A String containing the path to the parameter list file. + * + * @return A String containing the format of the parameter list file. + */ +def _paramListGuessFormat(param_list) { + if (param_list !instanceof String) { + "asis" + } else if (param_list.endsWith(".csv")) { + "csv" + } else if (param_list.endsWith(".json") || param_list.endsWith(".jsn")) { + "json" + } else if (param_list.endsWith(".yaml") || param_list.endsWith(".yml")) { + "yaml" + } else { + "yaml_blob" + } +} + + +/** + * Read the param list + * + * @param param_list One of the following: + * - A String containing the path to the parameter list file (csv, json or yaml), + * - A yaml blob of a list of maps (yaml_blob), + * - Or a groovy list of maps (asis). + * @param config A Map of the Viash configuration. + * + * @return A List of Maps containing the parameters. + */ +def _parseParamList(param_list, Map config) { + // first determine format by extension + def paramListFormat = _paramListGuessFormat(param_list) + + def paramListPath = (paramListFormat != "asis" && paramListFormat != "yaml_blob") ? + file(param_list, hidden: true) : + null + + // get the correct parser function for the detected params_list format + def paramSets = [] + if (paramListFormat == "asis") { + paramSets = param_list + } else if (paramListFormat == "yaml_blob") { + paramSets = readYamlBlob(param_list) + } else if (paramListFormat == "yaml") { + paramSets = readYaml(paramListPath) + } else if (paramListFormat == "json") { + paramSets = readJson(paramListPath) + } else if (paramListFormat == "csv") { + paramSets = readCsv(paramListPath) + } else { + error "Format of provided --param_list not recognised.\n" + + "Found: '$paramListFormat'.\n" + + "Expected: a csv file, a json file, a yaml file,\n" + + "a yaml blob or a groovy list of maps." + } + + // data checks + assert paramSets instanceof List: "--param_list should contain a list of maps" + for (value in paramSets) { + assert value instanceof Map: "--param_list should contain a list of maps" + } + + // id is argument + def idIsArgument = config.allArguments.any{it.plainName == "id"} + + // Reformat from List to List> by adding the ID as first element of a Tuple2 + paramSets = paramSets.collect({ data -> + def id = data.id + if (!idIsArgument) { + data = data.findAll{k, v -> k != "id"} + } + [id, data] + }) + + // Split parameters with 'multiple: true' + paramSets = paramSets.collect({ id, data -> + data = _splitParams(data, config) + [id, data] + }) + + // The paths of input files inside a param_list file may have been specified relatively to the + // location of the param_list file. These paths must be made absolute. + if (paramListPath) { + paramSets = paramSets.collect({ id, data -> + def new_data = data.collectEntries{ parName, parValue -> + def par = config.allArguments.find{it.plainName == parName} + if (par && par.type == "file" && par.direction == "input") { + if (parValue instanceof Collection) { + parValue = parValue.collectMany{path -> + def x = _resolveSiblingIfNotAbsolute(path, paramListPath) + x instanceof Collection ? x : [x] + } + } else { + parValue = _resolveSiblingIfNotAbsolute(parValue, paramListPath) + } + } + [parName, parValue] + } + [id, new_data] + }) + } + + return paramSets +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/channel/_splitParams.nf' +/** + * Split parameters for arguments that accept multiple values using their separator + * + * @param paramList A Map containing parameters to split. + * @param config A Map of the Viash configuration. This Map can be generated from the config file + * using the readConfig() function. + * + * @return A Map of parameters where the parameter values have been split into a list using + * their seperator. + */ +Map _splitParams(Map parValues, Map config){ + def parsedParamValues = parValues.collectEntries { parName, parValue -> + def parameterSettings = config.allArguments.find({it.plainName == parName}) + + if (!parameterSettings) { + // if argument is not found, do not alter + return [parName, parValue] + } + if (parameterSettings.multiple) { // Check if parameter can accept multiple values + if (parValue instanceof Collection) { + parValue = parValue.collect{it instanceof String ? it.split(parameterSettings.multiple_sep) : it } + } else if (parValue instanceof String) { + parValue = parValue.split(parameterSettings.multiple_sep) + } else if (parValue == null) { + parValue = [] + } else { + parValue = [ parValue ] + } + parValue = parValue.flatten() + } + // For all parameters check if multiple values are only passed for + // arguments that allow it. Quietly simplify lists of length 1. + if (!parameterSettings.multiple && parValue instanceof Collection) { + assert parValue.size() == 1 : + "Error: argument ${parName} has too many values.\n" + + " Expected amount: 1. Found: ${parValue.size()}" + parValue = parValue[0] + } + [parName, parValue] + } + return parsedParamValues +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/channel/channelFromParams.nf' +/** + * Parse nextflow parameters based on settings defined in a viash config. + * Return a list of parameter sets, each parameter set corresponding to + * an event in a nextflow channel. The output from this function can be used + * with Channel.fromList to create a nextflow channel with Vdsl3 formatted + * events. + * + * This function performs: + * - A filtering of the params which can be found in the config file. + * - Process the params_list argument which allows a user to to initialise + * a Vsdl3 channel with multiple parameter sets. Possible formats are + * csv, json, yaml, or simply a yaml_blob. A csv should have column names + * which correspond to the different arguments of this pipeline. A json or a yaml + * file should be a list of maps, each of which has keys corresponding to the + * arguments of the pipeline. A yaml blob can also be passed directly as a parameter. + * When passing a csv, json or yaml, relative path names are relativized to the + * location of the parameter file. + * - Combine the parameter sets into a vdsl3 Channel. + * + * @param params Input parameters. Can optionaly contain a 'param_list' key that + * provides a list of arguments that can be split up into multiple events + * in the output channel possible formats of param_lists are: a csv file, + * json file, a yaml file or a yaml blob. Each parameters set (event) must + * have a unique ID. + * @param config A Map of the Viash configuration. This Map can be generated from the config file + * using the readConfig() function. + * + * @return A list of parameters with the first element of the event being + * the event ID and the second element containing a map of the parsed parameters. + */ + +private List>> _paramsToParamSets(Map params, Map config){ + // todo: fetch key from run args + def key_ = config.name + + /* parse regular parameters (not in param_list) */ + /*************************************************/ + def globalParams = config.allArguments + .findAll { params.containsKey(it.plainName) } + .collectEntries { [ it.plainName, params[it.plainName] ] } + def globalID = params.get("id", null) + + /* process params_list arguments */ + /*********************************/ + def paramList = params.containsKey("param_list") && params.param_list != null ? + params.param_list : [] + // if (paramList instanceof String) { + // paramList = [paramList] + // } + // def paramSets = paramList.collectMany{ _parseParamList(it, config) } + // TODO: be able to process param_list when it is a list of strings + def paramSets = _parseParamList(paramList, config) + if (paramSets.isEmpty()) { + paramSets = [[null, [:]]] + } + + /* combine arguments into channel */ + /**********************************/ + def processedParams = paramSets.indexed().collect{ index, tup -> + // Process ID + def id = tup[0] ?: globalID + + if (workflow.stubRun && !id) { + // if stub run, explicitly add an id if missing + id = "stub${index}" + } + assert id != null: "Each parameter set should have at least an 'id'" + + // Process params + def parValues = globalParams + tup[1] + // // Remove parameters which are null, if the default is also null + // parValues = parValues.collectEntries{paramName, paramValue -> + // parameterSettings = config.functionality.allArguments.find({it.plainName == paramName}) + // if ( paramValue != null || parameterSettings.get("default", null) != null ) { + // [paramName, paramValue] + // } + // } + parValues = parValues.collectEntries { name, value -> + def par = config.allArguments.find { it.plainName == name && (it.direction == "input" || it.type == "file") } + assert par != null : "Error in module '${key_}' id '${id}': '${name}' is not a valid input argument" + + if (par == null) { + return [:] + } + value = _checkArgumentType("input", par, value, "in module '$key_' id '$id'") + + [ name, value ] + } + + [id, parValues] + } + + // Check if ids (first element of each list) is unique + _checkUniqueIds(processedParams) + return processedParams +} + +/** + * Parse nextflow parameters based on settings defined in a viash config + * and return a nextflow channel. + * + * @param params Input parameters. Can optionaly contain a 'param_list' key that + * provides a list of arguments that can be split up into multiple events + * in the output channel possible formats of param_lists are: a csv file, + * json file, a yaml file or a yaml blob. Each parameters set (event) must + * have a unique ID. + * @param config A Map of the Viash configuration. This Map can be generated from the config file + * using the readConfig() function. + * + * @return A nextflow Channel with events. Events are formatted as a tuple that contains + * first contains the ID of the event and as second element holds a parameter map. + * + * + */ +def channelFromParams(Map params, Map config) { + def processedParams = _paramsToParamSets(params, config) + return Channel.fromList(processedParams) +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/channel/checkUniqueIds.nf' +def checkUniqueIds(Map args) { + def stopOnError = args.stopOnError == null ? args.stopOnError : true + + def idChecker = new IDChecker() + + return filter { tup -> + if (!idChecker.observe(tup[0])) { + if (stopOnError) { + error "Duplicate id: ${tup[0]}" + } else { + log.warn "Duplicate id: ${tup[0]}, removing duplicate entry" + return false + } + } + return true + } +} +// helper file: 'src/main/resources/io/viash/runners/nextflow/channel/preprocessInputs.nf' +// This helper file will be deprecated soon +preprocessInputsDeprecationWarningPrinted = false + +def preprocessInputsDeprecationWarning() { + if (!preprocessInputsDeprecationWarningPrinted) { + preprocessInputsDeprecationWarningPrinted = true + System.err.println("Warning: preprocessInputs() is deprecated and will be removed in Viash 0.9.0.") + } +} + +/** + * Generate a nextflow Workflow that allows processing a channel of + * Vdsl3 formatted events and apply a Viash config to them: + * - Gather default parameters from the Viash config and make + * sure that they are correctly formatted (see applyConfig method). + * - Format the input parameters (also using the applyConfig method). + * - Apply the default parameter to the input parameters. + * - Do some assertions: + * ~ Check if the event IDs in the channel are unique. + * + * The events in the channel are formatted as tuples, with the + * first element of the tuples being a unique id of the parameter set, + * and the second element containg the the parameters themselves. + * Optional extra elements of the tuples will be passed to the output as is. + * + * @param args A map that must contain a 'config' key that points + * to a parsed config (see readConfig()). Optionally, a + * 'key' key can be provided which can be used to create a unique + * name for the workflow process. + * + * @return A workflow that allows processing a channel of Vdsl3 formatted events + * and apply a Viash config to them. + */ +def preprocessInputs(Map args) { + preprocessInputsDeprecationWarning() + + def config = args.config + assert config instanceof Map : + "Error in preprocessInputs: config must be a map. " + + "Expected class: Map. Found: config.getClass() is ${config.getClass()}" + def key_ = args.key ?: config.name + + // Get different parameter types (used throughout this function) + def defaultArgs = config.allArguments + .findAll { it.containsKey("default") } + .collectEntries { [ it.plainName, it.default ] } + + map { tup -> + def id = tup[0] + def data = tup[1] + def passthrough = tup.drop(2) + + def new_data = (defaultArgs + data).collectEntries { name, value -> + def par = config.allArguments.find { it.plainName == name && (it.direction == "input" || it.type == "file") } + + if (par != null) { + value = _checkArgumentType("input", par, value, "in module '$key_' id '$id'") + } + + [ name, value ] + } + + [ id, new_data ] + passthrough + } +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/channel/runComponents.nf' +/** + * Run a list of components on a stream of data. + * + * @param components: list of Viash VDSL3 modules to run + * @param fromState: a closure, a map or a list of keys to extract from the input data. + * If a closure, it will be called with the id, the data and the component config. + * @param toState: a closure, a map or a list of keys to extract from the output data + * If a closure, it will be called with the id, the output data, the old state and the component config. + * @param filter: filter function to apply to the input. + * It will be called with the id, the data and the component config. + * @param id: id to use for the output data + * If a closure, it will be called with the id, the data and the component config. + * @param auto: auto options to pass to the components + * + * @return: a workflow that runs the components + **/ +def runComponents(Map args) { + log.warn("runComponents is deprecated, use runEach instead") + assert args.components: "runComponents should be passed a list of components to run" + + def components_ = args.components + if (components_ !instanceof List) { + components_ = [ components_ ] + } + assert components_.size() > 0: "pass at least one component to runComponents" + + def fromState_ = args.fromState + def toState_ = args.toState + def filter_ = args.filter + def id_ = args.id + + workflow runComponentsWf { + take: input_ch + main: + + // generate one channel per method + out_chs = components_.collect{ comp_ -> + def comp_config = comp_.config + + def filter_ch = filter_ + ? input_ch | filter{tup -> + filter_(tup[0], tup[1], comp_config) + } + : input_ch + def id_ch = id_ + ? filter_ch | map{tup -> + // def new_id = id_(tup[0], tup[1], comp_config) + def new_id = tup[0] + if (id_ instanceof String) { + new_id = id_ + } else if (id_ instanceof Closure) { + new_id = id_(new_id, tup[1], comp_config) + } + [new_id] + tup.drop(1) + } + : filter_ch + def data_ch = id_ch | map{tup -> + def new_data = tup[1] + if (fromState_ instanceof Map) { + new_data = fromState_.collectEntries{ key0, key1 -> + [key0, new_data[key1]] + } + } else if (fromState_ instanceof List) { + new_data = fromState_.collectEntries{ key -> + [key, new_data[key]] + } + } else if (fromState_ instanceof Closure) { + new_data = fromState_(tup[0], new_data, comp_config) + } + tup.take(1) + [new_data] + tup.drop(1) + } + def out_ch = data_ch + | comp_.run( + auto: (args.auto ?: [:]) + [simplifyInput: false, simplifyOutput: false] + ) + def post_ch = toState_ + ? out_ch | map{tup -> + def output = tup[1] + def old_state = tup[2] + def new_state = null + if (toState_ instanceof Map) { + new_state = old_state + toState_.collectEntries{ key0, key1 -> + [key0, output[key1]] + } + } else if (toState_ instanceof List) { + new_state = old_state + toState_.collectEntries{ key -> + [key, output[key]] + } + } else if (toState_ instanceof Closure) { + new_state = toState_(tup[0], output, old_state, comp_config) + } + [tup[0], new_state] + tup.drop(3) + } + : out_ch + + post_ch + } + + // mix all results + output_ch = + (out_chs.size == 1) + ? out_chs[0] + : out_chs[0].mix(*out_chs.drop(1)) + + emit: output_ch + } + + return runComponentsWf +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/channel/runEach.nf' +/** + * Run a list of components on a stream of data. + * + * @param components: list of Viash VDSL3 modules to run + * @param fromState: a closure, a map or a list of keys to extract from the input data. + * If a closure, it will be called with the id, the data and the component itself. + * @param toState: a closure, a map or a list of keys to extract from the output data + * If a closure, it will be called with the id, the output data, the old state and the component itself. + * @param filter: filter function to apply to the input. + * It will be called with the id, the data and the component itself. + * @param id: id to use for the output data + * If a closure, it will be called with the id, the data and the component itself. + * @param auto: auto options to pass to the components + * + * @return: a workflow that runs the components + **/ +def runEach(Map args) { + assert args.components: "runEach should be passed a list of components to run" + + def components_ = args.components + if (components_ !instanceof List) { + components_ = [ components_ ] + } + assert components_.size() > 0: "pass at least one component to runEach" + + def fromState_ = args.fromState + def toState_ = args.toState + def filter_ = args.filter + def runIf_ = args.runIf + def id_ = args.id + + assert !runIf_ || runIf_ instanceof Closure: "runEach: must pass a Closure to runIf." + + workflow runEachWf { + take: input_ch + main: + + // generate one channel per method + out_chs = components_.collect{ comp_ -> + def filter_ch = filter_ + ? input_ch | filter{tup -> + filter_(tup[0], tup[1], comp_) + } + : input_ch + def id_ch = id_ + ? filter_ch | map{tup -> + def new_id = id_ + if (new_id instanceof Closure) { + new_id = new_id(tup[0], tup[1], comp_) + } + assert new_id instanceof String : "Error in runEach: id should be a String or a Closure that returns a String. Expected: id instanceof String. Found: ${new_id.getClass()}" + [new_id] + tup.drop(1) + } + : filter_ch + def chPassthrough = null + def chRun = null + if (runIf_) { + def idRunIfBranch = id_ch.branch{ tup -> + run: runIf_(tup[0], tup[1], comp_) + passthrough: true + } + chPassthrough = idRunIfBranch.passthrough + chRun = idRunIfBranch.run + } else { + chRun = id_ch + chPassthrough = Channel.empty() + } + def data_ch = chRun | map{tup -> + def new_data = tup[1] + if (fromState_ instanceof Map) { + new_data = fromState_.collectEntries{ key0, key1 -> + [key0, new_data[key1]] + } + } else if (fromState_ instanceof List) { + new_data = fromState_.collectEntries{ key -> + [key, new_data[key]] + } + } else if (fromState_ instanceof Closure) { + new_data = fromState_(tup[0], new_data, comp_) + } + tup.take(1) + [new_data] + tup.drop(1) + } + def out_ch = data_ch + | comp_.run( + auto: (args.auto ?: [:]) + [simplifyInput: false, simplifyOutput: false] + ) + def post_ch = toState_ + ? out_ch | map{tup -> + def output = tup[1] + def old_state = tup[2] + def new_state = null + if (toState_ instanceof Map) { + new_state = old_state + toState_.collectEntries{ key0, key1 -> + [key0, output[key1]] + } + } else if (toState_ instanceof List) { + new_state = old_state + toState_.collectEntries{ key -> + [key, output[key]] + } + } else if (toState_ instanceof Closure) { + new_state = toState_(tup[0], output, old_state, comp_) + } + [tup[0], new_state] + tup.drop(3) + } + : out_ch + + def return_ch = post_ch + | concat(chPassthrough) + + return_ch + } + + // mix all results + output_ch = + (out_chs.size == 1) + ? out_chs[0] + : out_chs[0].mix(*out_chs.drop(1)) + + emit: output_ch + } + + return runEachWf +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/channel/safeJoin.nf' +/** + * Join sourceChannel to targetChannel + * + * This function joins the sourceChannel to the targetChannel. + * However, each id in the targetChannel must be present in the + * sourceChannel. If _meta.join_id exists in the targetChannel, that is + * used as an id instead. If the id doesn't match any id in the sourceChannel, + * an error is thrown. + */ + +def safeJoin(targetChannel, sourceChannel, key) { + def sourceIDs = new IDChecker() + + def sourceCheck = sourceChannel + | map { tup -> + sourceIDs.observe(tup[0]) + tup + } + def targetCheck = targetChannel + | map { tup -> + def id = tup[0] + + if (!sourceIDs.contains(id)) { + error ( + "Error in module '${key}' when merging output with original state.\n" + + " Reason: output with id '${id}' could not be joined with source channel.\n" + + " If the IDs in the output channel differ from the input channel,\n" + + " please set `tup[1]._meta.join_id to the original ID.\n" + + " Original IDs in input channel: ['${sourceIDs.getItems().join("', '")}'].\n" + + " Unexpected ID in the output channel: '${id}'.\n" + + " Example input event: [\"id\", [input: file(...)]],\n" + + " Example output event: [\"newid\", [output: file(...), _meta: [join_id: \"id\"]]]" + ) + } + // TODO: add link to our documentation on how to fix this + + tup + } + + sourceCheck.cross(targetChannel) + | map{ left, right -> + right + left.drop(1) + } +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/config/_processArgument.nf' +def _processArgument(arg) { + arg.multiple = arg.multiple != null ? arg.multiple : false + arg.required = arg.required != null ? arg.required : false + arg.direction = arg.direction != null ? arg.direction : "input" + arg.multiple_sep = arg.multiple_sep != null ? arg.multiple_sep : ";" + arg.plainName = arg.name.replaceAll("^-*", "") + + if (arg.type == "file") { + arg.must_exist = arg.must_exist != null ? arg.must_exist : true + arg.create_parent = arg.create_parent != null ? arg.create_parent : true + } + + // add default values to output files which haven't already got a default + if (arg.type == "file" && arg.direction == "output" && arg.default == null) { + def mult = arg.multiple ? "_*" : "" + def extSearch = "" + if (arg.default != null) { + extSearch = arg.default + } else if (arg.example != null) { + extSearch = arg.example + } + if (extSearch instanceof List) { + extSearch = extSearch[0] + } + def extSearchResult = extSearch.find("\\.[^\\.]+\$") + def ext = extSearchResult != null ? extSearchResult : "" + arg.default = "\$id.\$key.${arg.plainName}${mult}${ext}" + if (arg.multiple) { + arg.default = [arg.default] + } + } + + if (!arg.multiple) { + if (arg.default != null && arg.default instanceof List) { + arg.default = arg.default[0] + } + if (arg.example != null && arg.example instanceof List) { + arg.example = arg.example[0] + } + } + + if (arg.type == "boolean_true") { + arg.default = false + } + if (arg.type == "boolean_false") { + arg.default = true + } + + arg +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/config/addGlobalParams.nf' +def addGlobalArguments(config) { + def localConfig = [ + "argument_groups": [ + [ + "name": "Nextflow input-output arguments", + "description": "Input/output parameters for Nextflow itself. Please note that both publishDir and publish_dir are supported but at least one has to be configured.", + "arguments" : [ + [ + 'name': '--publish_dir', + 'required': true, + 'type': 'string', + 'description': 'Path to an output directory.', + 'example': 'output/', + 'multiple': false + ], + [ + 'name': '--param_list', + 'required': false, + 'type': 'string', + 'description': '''Allows inputting multiple parameter sets to initialise a Nextflow channel. A `param_list` can either be a list of maps, a csv file, a json file, a yaml file, or simply a yaml blob. + | + |* A list of maps (as-is) where the keys of each map corresponds to the arguments of the pipeline. Example: in a `nextflow.config` file: `param_list: [ ['id': 'foo', 'input': 'foo.txt'], ['id': 'bar', 'input': 'bar.txt'] ]`. + |* A csv file should have column names which correspond to the different arguments of this pipeline. Example: `--param_list data.csv` with columns `id,input`. + |* A json or a yaml file should be a list of maps, each of which has keys corresponding to the arguments of the pipeline. Example: `--param_list data.json` with contents `[ {'id': 'foo', 'input': 'foo.txt'}, {'id': 'bar', 'input': 'bar.txt'} ]`. + |* A yaml blob can also be passed directly as a string. Example: `--param_list "[ {'id': 'foo', 'input': 'foo.txt'}, {'id': 'bar', 'input': 'bar.txt'} ]"`. + | + |When passing a csv, json or yaml file, relative path names are relativized to the location of the parameter file. No relativation is performed when `param_list` is a list of maps (as-is) or a yaml blob.'''.stripMargin(), + 'example': 'my_params.yaml', + 'multiple': false, + 'hidden': true + ] + // TODO: allow multiple: true in param_list? + // TODO: allow to specify a --param_list_regex to filter the param_list? + // TODO: allow to specify a --param_list_from_state to remap entries in the param_list? + ] + ] + ] + ] + + return processConfig(_mergeMap(config, localConfig)) +} + +def _mergeMap(Map lhs, Map rhs) { + return rhs.inject(lhs.clone()) { map, entry -> + if (map[entry.key] instanceof Map && entry.value instanceof Map) { + map[entry.key] = _mergeMap(map[entry.key], entry.value) + } else if (map[entry.key] instanceof Collection && entry.value instanceof Collection) { + map[entry.key] += entry.value + } else { + map[entry.key] = entry.value + } + return map + } +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/config/generateHelp.nf' +def _generateArgumentHelp(param) { + // alternatives are not supported + // def names = param.alternatives ::: List(param.name) + + def unnamedProps = [ + ["required parameter", param.required], + ["multiple values allowed", param.multiple], + ["output", param.direction.toLowerCase() == "output"], + ["file must exist", param.type == "file" && param.must_exist] + ].findAll{it[1]}.collect{it[0]} + + def dflt = null + if (param.default != null) { + if (param.default instanceof List) { + dflt = param.default.join(param.multiple_sep != null ? param.multiple_sep : ", ") + } else { + dflt = param.default.toString() + } + } + def example = null + if (param.example != null) { + if (param.example instanceof List) { + example = param.example.join(param.multiple_sep != null ? param.multiple_sep : ", ") + } else { + example = param.example.toString() + } + } + def min = param.min?.toString() + def max = param.max?.toString() + + def escapeChoice = { choice -> + def s1 = choice.replaceAll("\\n", "\\\\n") + def s2 = s1.replaceAll("\"", """\\\"""") + s2.contains(",") || s2 != choice ? "\"" + s2 + "\"" : s2 + } + def choices = param.choices == null ? + null : + "[ " + param.choices.collect{escapeChoice(it.toString())}.join(", ") + " ]" + + def namedPropsStr = [ + ["type", ([param.type] + unnamedProps).join(", ")], + ["default", dflt], + ["example", example], + ["choices", choices], + ["min", min], + ["max", max] + ] + .findAll{it[1]} + .collect{"\n " + it[0] + ": " + it[1].replaceAll("\n", "\\n")} + .join("") + + def descStr = param.description == null ? + "" : + _paragraphWrap("\n" + param.description.trim(), 80 - 8).join("\n ") + + "\n --" + param.plainName + + namedPropsStr + + descStr +} + +// Based on Helper.generateHelp() in Helper.scala +def _generateHelp(config) { + def fun = config + + // PART 1: NAME AND VERSION + def nameStr = fun.name + + (fun.version == null ? "" : " " + fun.version) + + // PART 2: DESCRIPTION + def descrStr = fun.description == null ? + "" : + "\n\n" + _paragraphWrap(fun.description.trim(), 80).join("\n") + + // PART 3: Usage + def usageStr = fun.usage == null ? + "" : + "\n\nUsage:\n" + fun.usage.trim() + + // PART 4: Options + def argGroupStrs = fun.allArgumentGroups.collect{argGroup -> + def name = argGroup.name + def descriptionStr = argGroup.description == null ? + "" : + "\n " + _paragraphWrap(argGroup.description.trim(), 80-4).join("\n ") + "\n" + def arguments = argGroup.arguments.collect{arg -> + arg instanceof String ? fun.allArguments.find{it.plainName == arg} : arg + }.findAll{it != null} + def argumentStrs = arguments.collect{param -> _generateArgumentHelp(param)} + + "\n\n$name:" + + descriptionStr + + argumentStrs.join("\n") + } + + // FINAL: combine + def out = nameStr + + descrStr + + usageStr + + argGroupStrs.join("") + + return out +} + +// based on Format._paragraphWrap +def _paragraphWrap(str, maxLength) { + def outLines = [] + str.split("\n").each{par -> + def words = par.split("\\s").toList() + + def word = null + def line = words.pop() + while(!words.isEmpty()) { + word = words.pop() + if (line.length() + word.length() + 1 <= maxLength) { + line = line + " " + word + } else { + outLines.add(line) + line = word + } + } + if (words.isEmpty()) { + outLines.add(line) + } + } + return outLines +} + +def helpMessage(config) { + if (params.containsKey("help") && params.help) { + def mergedConfig = addGlobalArguments(config) + def helpStr = _generateHelp(mergedConfig) + println(helpStr) + exit 0 + } +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/config/processConfig.nf' +def processConfig(config) { + // set defaults for arguments + config.arguments = + (config.arguments ?: []).collect{_processArgument(it)} + + // set defaults for argument_group arguments + config.argument_groups = + (config.argument_groups ?: []).collect{grp -> + grp.arguments = (grp.arguments ?: []).collect{_processArgument(it)} + grp + } + + // create combined arguments list + config.allArguments = + config.arguments + + config.argument_groups.collectMany{it.arguments} + + // add missing argument groups (based on Functionality::allArgumentGroups()) + def argGroups = config.argument_groups + if (argGroups.any{it.name.toLowerCase() == "arguments"}) { + argGroups = argGroups.collect{ grp -> + if (grp.name.toLowerCase() == "arguments") { + grp = grp + [ + arguments: grp.arguments + config.arguments + ] + } + grp + } + } else { + argGroups = argGroups + [ + name: "Arguments", + arguments: config.arguments + ] + } + config.allArgumentGroups = argGroups + + config +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/config/readConfig.nf' + +def readConfig(file) { + def config = readYaml(file ?: moduleDir.resolve("config.vsh.yaml")) + processConfig(config) +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/functions/_resolveSiblingIfNotAbsolute.nf' +/** + * Resolve a path relative to the current file. + * + * @param str The path to resolve, as a String. + * @param parentPath The path to resolve relative to, as a Path. + * + * @return The path that may have been resovled, as a Path. + */ +def _resolveSiblingIfNotAbsolute(str, parentPath) { + if (str !instanceof String) { + return str + } + if (!_stringIsAbsolutePath(str)) { + return parentPath.resolveSibling(str) + } else { + return file(str, hidden: true) + } +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/functions/_stringIsAbsolutePath.nf' +/** + * Check whether a path as a string is absolute. + * + * In the past, we tried using `file(., relative: true).isAbsolute()`, + * but the 'relative' option was added in 22.10.0. + * + * @param path The path to check, as a String. + * + * @return Whether the path is absolute, as a boolean. + */ +def _stringIsAbsolutePath(path) { + def _resolve_URL_PROTOCOL = ~/^([a-zA-Z][a-zA-Z0-9]*:)?\\/.+/ + + assert path instanceof String + return _resolve_URL_PROTOCOL.matcher(path).matches() +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/functions/collectTraces.nf' +class CustomTraceObserver implements nextflow.trace.TraceObserver { + List traces + + CustomTraceObserver(List traces) { + this.traces = traces + } + + @Override + void onProcessComplete(nextflow.processor.TaskHandler handler, nextflow.trace.TraceRecord trace) { + def trace2 = trace.store.clone() + trace2.script = null + traces.add(trace2) + } + + @Override + void onProcessCached(nextflow.processor.TaskHandler handler, nextflow.trace.TraceRecord trace) { + def trace2 = trace.store.clone() + trace2.script = null + traces.add(trace2) + } +} + +def collectTraces() { + def traces = Collections.synchronizedList([]) + + // add custom trace observer which stores traces in the traces object + session.observers.add(new CustomTraceObserver(traces)) + + traces +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/functions/deepClone.nf' +/** + * Performs a deep clone of the given object. + * @param x an object + */ +def deepClone(x) { + iterateMap(x, {it instanceof Cloneable ? it.clone() : it}) +} +// helper file: 'src/main/resources/io/viash/runners/nextflow/functions/getPublishDir.nf' +def getPublishDir() { + return params.containsKey("publish_dir") ? params.publish_dir : + params.containsKey("publishDir") ? params.publishDir : + null +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/functions/getRootDir.nf' + +// Recurse upwards until we find a '.build.yaml' file +def _findBuildYamlFile(pathPossiblySymlink) { + def path = pathPossiblySymlink.toRealPath() + def child = path.resolve(".build.yaml") + if (java.nio.file.Files.isDirectory(path) && java.nio.file.Files.exists(child)) { + return child + } else { + def parent = path.getParent() + if (parent == null) { + return null + } else { + return _findBuildYamlFile(parent) + } + } +} + +// get the root of the target folder +def getRootDir() { + def dir = _findBuildYamlFile(meta.resources_dir) + assert dir != null: "Could not find .build.yaml in the folder structure" + dir.getParent() +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/functions/iterateMap.nf' +/** + * Recursively apply a function over the leaves of an object. + * @param obj The object to iterate over. + * @param fun The function to apply to each value. + * @return The object with the function applied to each value. + */ +def iterateMap(obj, fun) { + if (obj instanceof List && obj !instanceof String) { + return obj.collect{item -> + iterateMap(item, fun) + } + } else if (obj instanceof Map) { + return obj.collectEntries{key, item -> + [key.toString(), iterateMap(item, fun)] + } + } else { + return fun(obj) + } +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/functions/niceView.nf' +/** + * A view for printing the event of each channel as a YAML blob. + * This is useful for debugging. + */ +def niceView() { + workflow niceViewWf { + take: input + main: + output = input + | view{toYamlBlob(it)} + emit: output + } + return niceViewWf +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/readwrite/readCsv.nf' + +def readCsv(file_path) { + def output = [] + def inputFile = file_path !instanceof Path ? file(file_path, hidden: true) : file_path + + // todo: allow escaped quotes in string + // todo: allow single quotes? + def splitRegex = java.util.regex.Pattern.compile(''',(?=(?:[^"]*"[^"]*")*[^"]*$)''') + def removeQuote = java.util.regex.Pattern.compile('''"(.*)"''') + + def br = java.nio.file.Files.newBufferedReader(inputFile) + + def row = -1 + def header = null + while (br.ready() && header == null) { + def line = br.readLine() + row++ + if (!line.startsWith("#")) { + header = splitRegex.split(line, -1).collect{field -> + m = removeQuote.matcher(field) + m.find() ? m.replaceFirst('$1') : field + } + } + } + assert header != null: "CSV file should contain a header" + + while (br.ready()) { + def line = br.readLine() + row++ + if (line == null) { + br.close() + break + } + + if (!line.startsWith("#")) { + def predata = splitRegex.split(line, -1) + def data = predata.collect{field -> + if (field == "") { + return null + } + def m = removeQuote.matcher(field) + if (m.find()) { + return m.replaceFirst('$1') + } else { + return field + } + } + assert header.size() == data.size(): "Row $row should contain the same number as fields as the header" + + def dataMap = [header, data].transpose().collectEntries().findAll{it.value != null} + output.add(dataMap) + } + } + + output +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/readwrite/readJson.nf' +def readJson(file_path) { + def inputFile = file_path !instanceof Path ? file(file_path, hidden: true) : file_path + def jsonSlurper = new groovy.json.JsonSlurper() + jsonSlurper.parse(inputFile) +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/readwrite/readJsonBlob.nf' +def readJsonBlob(str) { + def jsonSlurper = new groovy.json.JsonSlurper() + jsonSlurper.parseText(str) +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/readwrite/readTaggedYaml.nf' +// Custom constructor to modify how certain objects are parsed from YAML +class CustomConstructor extends org.yaml.snakeyaml.constructor.Constructor { + Path root + + class ConstructPath extends org.yaml.snakeyaml.constructor.AbstractConstruct { + public Object construct(org.yaml.snakeyaml.nodes.Node node) { + String filename = (String) constructScalar(node); + if (root != null) { + return root.resolve(filename); + } + return java.nio.file.Paths.get(filename); + } + } + + CustomConstructor(org.yaml.snakeyaml.LoaderOptions options, Path root) { + super(options) + this.root = root + // Handling !file tag and parse it back to a File type + this.yamlConstructors.put(new org.yaml.snakeyaml.nodes.Tag("!file"), new ConstructPath()) + } +} + +def readTaggedYaml(Path path) { + def options = new org.yaml.snakeyaml.LoaderOptions() + def constructor = new CustomConstructor(options, path.getParent()) + def yaml = new org.yaml.snakeyaml.Yaml(constructor) + return yaml.load(path.text) +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/readwrite/readYaml.nf' +def readYaml(file_path) { + def inputFile = file_path !instanceof Path ? file(file_path, hidden: true) : file_path + def yamlSlurper = new org.yaml.snakeyaml.Yaml() + yamlSlurper.load(inputFile) +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/readwrite/readYamlBlob.nf' +def readYamlBlob(str) { + def yamlSlurper = new org.yaml.snakeyaml.Yaml() + yamlSlurper.load(str) +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/readwrite/toJsonBlob.nf' +String toJsonBlob(data) { + return groovy.json.JsonOutput.toJson(data) +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/readwrite/toTaggedYamlBlob.nf' +// Custom representer to modify how certain objects are represented in YAML +class CustomRepresenter extends org.yaml.snakeyaml.representer.Representer { + Path relativizer + + class RepresentPath implements org.yaml.snakeyaml.representer.Represent { + public String getFileName(Object obj) { + if (obj instanceof File) { + obj = ((File) obj).toPath(); + } + if (obj !instanceof Path) { + throw new IllegalArgumentException("Object: " + obj + " is not a Path or File"); + } + def path = (Path) obj; + + if (relativizer != null) { + return relativizer.relativize(path).toString() + } else { + return path.toString() + } + } + + public org.yaml.snakeyaml.nodes.Node representData(Object data) { + String filename = getFileName(data); + def tag = new org.yaml.snakeyaml.nodes.Tag("!file"); + return representScalar(tag, filename); + } + } + CustomRepresenter(org.yaml.snakeyaml.DumperOptions options, Path relativizer) { + super(options) + this.relativizer = relativizer + this.representers.put(sun.nio.fs.UnixPath, new RepresentPath()) + this.representers.put(Path, new RepresentPath()) + this.representers.put(File, new RepresentPath()) + } +} + +String toTaggedYamlBlob(data) { + return toRelativeTaggedYamlBlob(data, null) +} +String toRelativeTaggedYamlBlob(data, Path relativizer) { + def options = new org.yaml.snakeyaml.DumperOptions() + options.setDefaultFlowStyle(org.yaml.snakeyaml.DumperOptions.FlowStyle.BLOCK) + def representer = new CustomRepresenter(options, relativizer) + def yaml = new org.yaml.snakeyaml.Yaml(representer, options) + return yaml.dump(data) +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/readwrite/toYamlBlob.nf' +String toYamlBlob(data) { + def options = new org.yaml.snakeyaml.DumperOptions() + options.setDefaultFlowStyle(org.yaml.snakeyaml.DumperOptions.FlowStyle.BLOCK) + options.setPrettyFlow(true) + def yaml = new org.yaml.snakeyaml.Yaml(options) + def cleanData = iterateMap(data, { it instanceof Path ? it.toString() : it }) + return yaml.dump(cleanData) +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/readwrite/writeJson.nf' +void writeJson(data, file) { + assert data: "writeJson: data should not be null" + assert file: "writeJson: file should not be null" + file.write(toJsonBlob(data)) +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/readwrite/writeYaml.nf' +void writeYaml(data, file) { + assert data: "writeYaml: data should not be null" + assert file: "writeYaml: file should not be null" + file.write(toYamlBlob(data)) +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/states/findStates.nf' +def findStates(Map params, Map config) { + def auto_config = deepClone(config) + def auto_params = deepClone(params) + + auto_config = auto_config.clone() + // override arguments + auto_config.argument_groups = [] + auto_config.arguments = [ + [ + type: "string", + name: "--id", + description: "A dummy identifier", + required: false + ], + [ + type: "file", + name: "--input_states", + example: "/path/to/input/directory/**/state.yaml", + description: "Path to input directory containing the datasets to be integrated.", + required: true, + multiple: true, + multiple_sep: ";" + ], + [ + type: "string", + name: "--filter", + example: "foo/.*/state.yaml", + description: "Regex to filter state files by path.", + required: false + ], + // to do: make this a yaml blob? + [ + type: "string", + name: "--rename_keys", + example: ["newKey1:oldKey1", "newKey2:oldKey2"], + description: "Rename keys in the detected input files. This is useful if the input files do not match the set of input arguments of the workflow.", + required: false, + multiple: true, + multiple_sep: ";" + ], + [ + type: "string", + name: "--settings", + example: '{"output_dataset": "dataset.h5ad", "k": 10}', + description: "Global arguments as a JSON glob to be passed to all components.", + required: false + ] + ] + if (!(auto_params.containsKey("id"))) { + auto_params["id"] = "auto" + } + + // run auto config through processConfig once more + auto_config = processConfig(auto_config) + + workflow findStatesWf { + helpMessage(auto_config) + + output_ch = + channelFromParams(auto_params, auto_config) + | flatMap { autoId, args -> + + def globalSettings = args.settings ? readYamlBlob(args.settings) : [:] + + // look for state files in input dir + def stateFiles = args.input_states + + // filter state files by regex + if (args.filter) { + stateFiles = stateFiles.findAll{ stateFile -> + def stateFileStr = stateFile.toString() + def matcher = stateFileStr =~ args.filter + matcher.matches()} + } + + // read in states + def states = stateFiles.collect { stateFile -> + def state_ = readTaggedYaml(stateFile) + [state_.id, state_] + } + + // construct renameMap + if (args.rename_keys) { + def renameMap = args.rename_keys.collectEntries{renameString -> + def split = renameString.split(":") + assert split.size() == 2: "Argument 'rename_keys' should be of the form 'newKey:oldKey', or 'newKey:oldKey;newKey:oldKey' in case of multiple values" + split + } + + // rename keys in state, only let states through which have all keys + // also add global settings + states = states.collectMany{id, state -> + def newState = [:] + + for (key in renameMap.keySet()) { + def origKey = renameMap[key] + if (!(state.containsKey(origKey))) { + return [] + } + newState[key] = state[origKey] + } + + [[id, globalSettings + newState]] + } + } + + states + } + emit: + output_ch + } + + return findStatesWf +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/states/joinStates.nf' +def joinStates(Closure apply_) { + workflow joinStatesWf { + take: input_ch + main: + output_ch = input_ch + | toSortedList + | filter{ it.size() > 0 } + | map{ tups -> + def ids = tups.collect{it[0]} + def states = tups.collect{it[1]} + apply_(ids, states) + } + + emit: output_ch + } + return joinStatesWf +} +// helper file: 'src/main/resources/io/viash/runners/nextflow/states/publishStates.nf' +def collectFiles(obj) { + if (obj instanceof java.io.File || obj instanceof Path) { + return [obj] + } else if (obj instanceof List && obj !instanceof String) { + return obj.collectMany{item -> + collectFiles(item) + } + } else if (obj instanceof Map) { + return obj.collectMany{key, item -> + collectFiles(item) + } + } else { + return [] + } +} + +/** + * Recurse through a state and collect all input files and their target output filenames. + * @param obj The state to recurse through. + * @param prefix The prefix to prepend to the output filenames. + */ +def collectInputOutputPaths(obj, prefix) { + if (obj instanceof File || obj instanceof Path) { + def path = obj instanceof Path ? obj : obj.toPath() + def ext = path.getFileName().toString().find("\\.[^\\.]+\$") ?: "" + def newFilename = prefix + ext + return [[obj, newFilename]] + } else if (obj instanceof List && obj !instanceof String) { + return obj.withIndex().collectMany{item, ix -> + collectInputOutputPaths(item, prefix + "_" + ix) + } + } else if (obj instanceof Map) { + return obj.collectMany{key, item -> + collectInputOutputPaths(item, prefix + "." + key) + } + } else { + return [] + } +} + +def publishStates(Map args) { + def key_ = args.get("key") + def yamlTemplate_ = args.get("output_state", args.get("outputState", '$id.$key.state.yaml')) + + assert key_ != null : "publishStates: key must be specified" + + workflow publishStatesWf { + take: input_ch + main: + input_ch + | map { tup -> + def id_ = tup[0] + def state_ = tup[1] + + // the input files and the target output filenames + def inputoutputFilenames_ = collectInputOutputPaths(state_, id_ + "." + key_).transpose() + def inputFiles_ = inputoutputFilenames_[0] + def outputFilenames_ = inputoutputFilenames_[1] + + def yamlFilename = yamlTemplate_ + .replaceAll('\\$id', id_) + .replaceAll('\\$\\{id\\}', id_) + .replaceAll('\\$key', key_) + .replaceAll('\\$\\{key\\}', key_) + + // TODO: do the pathnames in state_ match up with the outputFilenames_? + + // convert state to yaml blob + def yamlBlob_ = toRelativeTaggedYamlBlob([id: id_] + state_, java.nio.file.Paths.get(yamlFilename)) + + [id_, yamlBlob_, yamlFilename, inputFiles_, outputFilenames_] + } + | publishStatesProc + emit: input_ch + } + return publishStatesWf +} +process publishStatesProc { + // todo: check publishpath? + publishDir path: "${getPublishDir()}/", mode: "copy" + tag "$id" + input: + tuple val(id), val(yamlBlob), val(yamlFile), path(inputFiles, stageAs: "_inputfile?/*"), val(outputFiles) + output: + tuple val(id), path{[yamlFile] + outputFiles} + script: + def copyCommands = [ + inputFiles instanceof List ? inputFiles : [inputFiles], + outputFiles instanceof List ? outputFiles : [outputFiles] + ] + .transpose() + .collectMany{infile, outfile -> + if (infile.toString() != outfile.toString()) { + [ + "[ -d \"\$(dirname '${outfile.toString()}')\" ] || mkdir -p \"\$(dirname '${outfile.toString()}')\"", + "cp -r '${infile.toString()}' '${outfile.toString()}'" + ] + } else { + // no need to copy if infile is the same as outfile + [] + } + } + """ +mkdir -p "\$(dirname '${yamlFile}')" +echo "Storing state as yaml" +echo '${yamlBlob}' > '${yamlFile}' +echo "Copying output files to destination folder" +${copyCommands.join("\n ")} +""" +} + + +// this assumes that the state contains no other values other than those specified in the config +def publishStatesByConfig(Map args) { + def config = args.get("config") + assert config != null : "publishStatesByConfig: config must be specified" + + def key_ = args.get("key", config.name) + assert key_ != null : "publishStatesByConfig: key must be specified" + + workflow publishStatesSimpleWf { + take: input_ch + main: + input_ch + | map { tup -> + def id_ = tup[0] + def state_ = tup[1] // e.g. [output: new File("myoutput.h5ad"), k: 10] + def origState_ = tup[2] // e.g. [output: '$id.$key.foo.h5ad'] + + // TODO: allow overriding the state.yaml template + // TODO TODO: if auto.publish == "state", add output_state as an argument + def yamlTemplate = params.containsKey("output_state") ? params.output_state : '$id.$key.state.yaml' + def yamlFilename = yamlTemplate + .replaceAll('\\$id', id_) + .replaceAll('\\$\\{id\\}', id_) + .replaceAll('\\$key', key_) + .replaceAll('\\$\\{key\\}', key_) + def yamlDir = java.nio.file.Paths.get(yamlFilename).getParent() + + // the processed state is a list of [key, value, inputPath, outputFilename] tuples, where + // - key is a String + // - value is any object that can be serialized to a Yaml (so a String/Integer/Long/Double/Boolean, a List, a Map, or a Path) + // - inputPath is a List[Path] + // - outputFilename is a List[String] + // - (key, value) are the tuples that will be saved to the state.yaml file + // - (inputPath, outputFilename) are the files that will be copied from src to dest (relative to the state.yaml) + def processedState = + config.allArguments + .findAll { it.direction == "output" } + .collectMany { par -> + def plainName_ = par.plainName + // if the state does not contain the key, it's an + // optional argument for which the component did + // not generate any output + if (!state_.containsKey(plainName_)) { + return [] + } + def value = state_[plainName_] + // if the parameter is not a file, it should be stored + // in the state as-is, but is not something that needs + // to be copied from the source path to the dest path + if (par.type != "file") { + return [[key: plainName_, value: value, inputPath: [], outputFilename: []]] + } + // if the orig state does not contain this filename, + // it's an optional argument for which the user specified + // that it should not be returned as a state + if (!origState_.containsKey(plainName_)) { + return [] + } + def filenameTemplate = origState_[plainName_] + // if the pararameter is multiple: true, fetch the template + if (par.multiple && filenameTemplate instanceof List) { + filenameTemplate = filenameTemplate[0] + } + // instantiate the template + def filename = filenameTemplate + .replaceAll('\\$id', id_) + .replaceAll('\\$\\{id\\}', id_) + .replaceAll('\\$key', key_) + .replaceAll('\\$\\{key\\}', key_) + if (par.multiple) { + // if the parameter is multiple: true, the filename + // should contain a wildcard '*' that is replaced with + // the index of the file + assert filename.contains("*") : "Module '${key_}' id '${id_}': Multiple output files specified, but no wildcard '*' in the filename: ${filename}" + def outputPerFile = value.withIndex().collect{ val, ix -> + def filename_ix = filename.replace("*", ix.toString()) + def value_ = java.nio.file.Paths.get(filename_ix) + // if id contains a slash + if (yamlDir != null) { + value_ = yamlDir.relativize(value_) + } + def inputPath = val instanceof File ? val.toPath() : val + [value: value_, inputPath: inputPath, outputFilename: filename_ix] + } + def transposedOutputs = ["value", "inputPath", "outputFilename"].collectEntries{ key -> + [key, outputPerFile.collect{dic -> dic[key]}] + } + return [[key: plainName_] + transposedOutputs] + } else { + def value_ = java.nio.file.Paths.get(filename) + // if id contains a slash + if (yamlDir != null) { + value_ = yamlDir.relativize(value_) + } + def inputPath = value instanceof File ? value.toPath() : value + return [[key: plainName_, value: value_, inputPath: [inputPath], outputFilename: [filename]]] + } + } + + def updatedState_ = processedState.collectEntries{[it.key, it.value]} + def inputPaths = processedState.collectMany{it.inputPath} + def outputFilenames = processedState.collectMany{it.outputFilename} + + // convert state to yaml blob + def yamlBlob_ = toTaggedYamlBlob([id: id_] + updatedState_) + + [id_, yamlBlob_, yamlFilename, inputPaths, outputFilenames] + } + | publishStatesProc + emit: input_ch + } + return publishStatesSimpleWf +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/states/setState.nf' +def setState(fun) { + assert fun instanceof Closure || fun instanceof Map || fun instanceof List : + "Error in setState: Expected process argument to be a Closure, a Map, or a List. Found: class ${fun.getClass()}" + + // if fun is a List, convert to map + if (fun instanceof List) { + // check whether fun is a list[string] + assert fun.every{it instanceof CharSequence} : "Error in setState: argument is a List, but not all elements are Strings" + fun = fun.collectEntries{[it, it]} + } + + // if fun is a map, convert to closure + if (fun instanceof Map) { + // check whether fun is a map[string, string] + assert fun.values().every{it instanceof CharSequence} : "Error in setState: argument is a Map, but not all values are Strings" + assert fun.keySet().every{it instanceof CharSequence} : "Error in setState: argument is a Map, but not all keys are Strings" + def funMap = fun.clone() + // turn the map into a closure to be used later on + fun = { id_, state_ -> + assert state_ instanceof Map : "Error in setState: the state is not a Map" + funMap.collectMany{newkey, origkey -> + if (state_.containsKey(origkey)) { + [[newkey, state_[origkey]]] + } else { + [] + } + }.collectEntries() + } + } + + map { tup -> + def id = tup[0] + def state = tup[1] + def unfilteredState = fun(id, state) + def newState = unfilteredState.findAll{key, val -> val != null} + [id, newState] + tup.drop(2) + } +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/workflowFactory/processAuto.nf' +// TODO: unit test processAuto +def processAuto(Map auto) { + // remove null values + auto = auto.findAll{k, v -> v != null} + + // check for unexpected keys + def expectedKeys = ["simplifyInput", "simplifyOutput", "transcript", "publish"] + def unexpectedKeys = auto.keySet() - expectedKeys + assert unexpectedKeys.isEmpty(), "unexpected keys in auto: '${unexpectedKeys.join("', '")}'" + + // check auto.simplifyInput + assert auto.simplifyInput instanceof Boolean, "auto.simplifyInput must be a boolean" + + // check auto.simplifyOutput + assert auto.simplifyOutput instanceof Boolean, "auto.simplifyOutput must be a boolean" + + // check auto.transcript + assert auto.transcript instanceof Boolean, "auto.transcript must be a boolean" + + // check auto.publish + assert auto.publish instanceof Boolean || auto.publish == "state", "auto.publish must be a boolean or 'state'" + + return auto.subMap(expectedKeys) +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/workflowFactory/processDirectives.nf' +def assertMapKeys(map, expectedKeys, requiredKeys, mapName) { + assert map instanceof Map : "Expected argument '$mapName' to be a Map. Found: class ${map.getClass()}" + map.forEach { key, val -> + assert key in expectedKeys : "Unexpected key '$key' in ${mapName ? mapName + " " : ""}map" + } + requiredKeys.forEach { requiredKey -> + assert map.containsKey(requiredKey) : "Missing required key '$key' in ${mapName ? mapName + " " : ""}map" + } +} + +// TODO: unit test processDirectives +def processDirectives(Map drctv) { + // remove null values + drctv = drctv.findAll{k, v -> v != null} + + // check for unexpected keys + def expectedKeys = [ + "accelerator", "afterScript", "beforeScript", "cache", "conda", "container", "containerOptions", "cpus", "disk", "echo", "errorStrategy", "executor", "machineType", "maxErrors", "maxForks", "maxRetries", "memory", "module", "penv", "pod", "publishDir", "queue", "label", "scratch", "storeDir", "stageInMode", "stageOutMode", "tag", "time" + ] + def unexpectedKeys = drctv.keySet() - expectedKeys + assert unexpectedKeys.isEmpty() : "Unexpected keys in process directive: '${unexpectedKeys.join("', '")}'" + + /* DIRECTIVE accelerator + accepted examples: + - [ limit: 4, type: "nvidia-tesla-k80" ] + */ + if (drctv.containsKey("accelerator")) { + assertMapKeys(drctv["accelerator"], ["type", "limit", "request", "runtime"], [], "accelerator") + } + + /* DIRECTIVE afterScript + accepted examples: + - "source /cluster/bin/cleanup" + */ + if (drctv.containsKey("afterScript")) { + assert drctv["afterScript"] instanceof CharSequence + } + + /* DIRECTIVE beforeScript + accepted examples: + - "source /cluster/bin/setup" + */ + if (drctv.containsKey("beforeScript")) { + assert drctv["beforeScript"] instanceof CharSequence + } + + /* DIRECTIVE cache + accepted examples: + - true + - false + - "deep" + - "lenient" + */ + if (drctv.containsKey("cache")) { + assert drctv["cache"] instanceof CharSequence || drctv["cache"] instanceof Boolean + if (drctv["cache"] instanceof CharSequence) { + assert drctv["cache"] in ["deep", "lenient"] : "Unexpected value for cache" + } + } + + /* DIRECTIVE conda + accepted examples: + - "bwa=0.7.15" + - "bwa=0.7.15 fastqc=0.11.5" + - ["bwa=0.7.15", "fastqc=0.11.5"] + */ + if (drctv.containsKey("conda")) { + if (drctv["conda"] instanceof List) { + drctv["conda"] = drctv["conda"].join(" ") + } + assert drctv["conda"] instanceof CharSequence + } + + /* DIRECTIVE container + accepted examples: + - "foo/bar:tag" + - [ registry: "reg", image: "im", tag: "ta" ] + is transformed to "reg/im:ta" + - [ image: "im" ] + is transformed to "im:latest" + */ + if (drctv.containsKey("container")) { + assert drctv["container"] instanceof Map || drctv["container"] instanceof CharSequence + if (drctv["container"] instanceof Map) { + def m = drctv["container"] + assertMapKeys(m, [ "registry", "image", "tag" ], ["image"], "container") + def part1 = + System.getenv('OVERRIDE_CONTAINER_REGISTRY') ? System.getenv('OVERRIDE_CONTAINER_REGISTRY') + "/" : + params.containsKey("override_container_registry") ? params["override_container_registry"] + "/" : // todo: remove? + m.registry ? m.registry + "/" : + "" + def part2 = m.image + def part3 = m.tag ? ":" + m.tag : ":latest" + drctv["container"] = part1 + part2 + part3 + } + } + + /* DIRECTIVE containerOptions + accepted examples: + - "--foo bar" + - ["--foo bar", "-f b"] + */ + if (drctv.containsKey("containerOptions")) { + if (drctv["containerOptions"] instanceof List) { + drctv["containerOptions"] = drctv["containerOptions"].join(" ") + } + assert drctv["containerOptions"] instanceof CharSequence + } + + /* DIRECTIVE cpus + accepted examples: + - 1 + - 10 + */ + if (drctv.containsKey("cpus")) { + assert drctv["cpus"] instanceof Integer + } + + /* DIRECTIVE disk + accepted examples: + - "1 GB" + - "2TB" + - "3.2KB" + - "10.B" + */ + if (drctv.containsKey("disk")) { + assert drctv["disk"] instanceof CharSequence + // assert drctv["disk"].matches("[0-9]+(\\.[0-9]*)? *[KMGTPEZY]?B") + // ^ does not allow closures + } + + /* DIRECTIVE echo + accepted examples: + - true + - false + */ + if (drctv.containsKey("echo")) { + assert drctv["echo"] instanceof Boolean + } + + /* DIRECTIVE errorStrategy + accepted examples: + - "terminate" + - "finish" + */ + if (drctv.containsKey("errorStrategy")) { + assert drctv["errorStrategy"] instanceof CharSequence + assert drctv["errorStrategy"] in ["terminate", "finish", "ignore", "retry"] : "Unexpected value for errorStrategy" + } + + /* DIRECTIVE executor + accepted examples: + - "local" + - "sge" + */ + if (drctv.containsKey("executor")) { + assert drctv["executor"] instanceof CharSequence + assert drctv["executor"] in ["local", "sge", "uge", "lsf", "slurm", "pbs", "pbspro", "moab", "condor", "nqsii", "ignite", "k8s", "awsbatch", "google-pipelines"] : "Unexpected value for executor" + } + + /* DIRECTIVE machineType + accepted examples: + - "n1-highmem-8" + */ + if (drctv.containsKey("machineType")) { + assert drctv["machineType"] instanceof CharSequence + } + + /* DIRECTIVE maxErrors + accepted examples: + - 1 + - 3 + */ + if (drctv.containsKey("maxErrors")) { + assert drctv["maxErrors"] instanceof Integer + } + + /* DIRECTIVE maxForks + accepted examples: + - 1 + - 3 + */ + if (drctv.containsKey("maxForks")) { + assert drctv["maxForks"] instanceof Integer + } + + /* DIRECTIVE maxRetries + accepted examples: + - 1 + - 3 + */ + if (drctv.containsKey("maxRetries")) { + assert drctv["maxRetries"] instanceof Integer + } + + /* DIRECTIVE memory + accepted examples: + - "1 GB" + - "2TB" + - "3.2KB" + - "10.B" + */ + if (drctv.containsKey("memory")) { + assert drctv["memory"] instanceof CharSequence + // assert drctv["memory"].matches("[0-9]+(\\.[0-9]*)? *[KMGTPEZY]?B") + // ^ does not allow closures + } + + /* DIRECTIVE module + accepted examples: + - "ncbi-blast/2.2.27" + - "ncbi-blast/2.2.27:t_coffee/10.0" + - ["ncbi-blast/2.2.27", "t_coffee/10.0"] + */ + if (drctv.containsKey("module")) { + if (drctv["module"] instanceof List) { + drctv["module"] = drctv["module"].join(":") + } + assert drctv["module"] instanceof CharSequence + } + + /* DIRECTIVE penv + accepted examples: + - "smp" + */ + if (drctv.containsKey("penv")) { + assert drctv["penv"] instanceof CharSequence + } + + /* DIRECTIVE pod + accepted examples: + - [ label: "key", value: "val" ] + - [ annotation: "key", value: "val" ] + - [ env: "key", value: "val" ] + - [ [label: "l", value: "v"], [env: "e", value: "v"]] + */ + if (drctv.containsKey("pod")) { + if (drctv["pod"] instanceof Map) { + drctv["pod"] = [ drctv["pod"] ] + } + assert drctv["pod"] instanceof List + drctv["pod"].forEach { pod -> + assert pod instanceof Map + // TODO: should more checks be added? + // See https://www.nextflow.io/docs/latest/process.html?highlight=directives#pod + // e.g. does it contain 'label' and 'value', or 'annotation' and 'value', or ...? + } + } + + /* DIRECTIVE publishDir + accepted examples: + - [] + - [ [ path: "foo", enabled: true ], [ path: "bar", enabled: false ] ] + - "/path/to/dir" + is transformed to [[ path: "/path/to/dir" ]] + - [ path: "/path/to/dir", mode: "cache" ] + is transformed to [[ path: "/path/to/dir", mode: "cache" ]] + */ + // TODO: should we also look at params["publishDir"]? + if (drctv.containsKey("publishDir")) { + def pblsh = drctv["publishDir"] + + // check different options + assert pblsh instanceof List || pblsh instanceof Map || pblsh instanceof CharSequence + + // turn into list if not already so + // for some reason, 'if (!pblsh instanceof List) pblsh = [ pblsh ]' doesn't work. + pblsh = pblsh instanceof List ? pblsh : [ pblsh ] + + // check elements of publishDir + pblsh = pblsh.collect{ elem -> + // turn into map if not already so + elem = elem instanceof CharSequence ? [ path: elem ] : elem + + // check types and keys + assert elem instanceof Map : "Expected publish argument '$elem' to be a String or a Map. Found: class ${elem.getClass()}" + assertMapKeys(elem, [ "path", "mode", "overwrite", "pattern", "saveAs", "enabled" ], ["path"], "publishDir") + + // check elements in map + assert elem.containsKey("path") + assert elem["path"] instanceof CharSequence + if (elem.containsKey("mode")) { + assert elem["mode"] instanceof CharSequence + assert elem["mode"] in [ "symlink", "rellink", "link", "copy", "copyNoFollow", "move" ] + } + if (elem.containsKey("overwrite")) { + assert elem["overwrite"] instanceof Boolean + } + if (elem.containsKey("pattern")) { + assert elem["pattern"] instanceof CharSequence + } + if (elem.containsKey("saveAs")) { + assert elem["saveAs"] instanceof CharSequence //: "saveAs as a Closure is currently not supported. Surround your closure with single quotes to get the desired effect. Example: '\{ foo \}'" + } + if (elem.containsKey("enabled")) { + assert elem["enabled"] instanceof Boolean + } + + // return final result + elem + } + // store final directive + drctv["publishDir"] = pblsh + } + + /* DIRECTIVE queue + accepted examples: + - "long" + - "short,long" + - ["short", "long"] + */ + if (drctv.containsKey("queue")) { + if (drctv["queue"] instanceof List) { + drctv["queue"] = drctv["queue"].join(",") + } + assert drctv["queue"] instanceof CharSequence + } + + /* DIRECTIVE label + accepted examples: + - "big_mem" + - "big_cpu" + - ["big_mem", "big_cpu"] + */ + if (drctv.containsKey("label")) { + if (drctv["label"] instanceof CharSequence) { + drctv["label"] = [ drctv["label"] ] + } + assert drctv["label"] instanceof List + drctv["label"].forEach { label -> + assert label instanceof CharSequence + // assert label.matches("[a-zA-Z0-9]([a-zA-Z0-9_]*[a-zA-Z0-9])?") + // ^ does not allow closures + } + } + + /* DIRECTIVE scratch + accepted examples: + - true + - "/path/to/scratch" + - '$MY_PATH_TO_SCRATCH' + - "ram-disk" + */ + if (drctv.containsKey("scratch")) { + assert drctv["scratch"] == true || drctv["scratch"] instanceof CharSequence + } + + /* DIRECTIVE storeDir + accepted examples: + - "/path/to/storeDir" + */ + if (drctv.containsKey("storeDir")) { + assert drctv["storeDir"] instanceof CharSequence + } + + /* DIRECTIVE stageInMode + accepted examples: + - "copy" + - "link" + */ + if (drctv.containsKey("stageInMode")) { + assert drctv["stageInMode"] instanceof CharSequence + assert drctv["stageInMode"] in ["copy", "link", "symlink", "rellink"] + } + + /* DIRECTIVE stageOutMode + accepted examples: + - "copy" + - "link" + */ + if (drctv.containsKey("stageOutMode")) { + assert drctv["stageOutMode"] instanceof CharSequence + assert drctv["stageOutMode"] in ["copy", "move", "rsync"] + } + + /* DIRECTIVE tag + accepted examples: + - "foo" + - '$id' + */ + if (drctv.containsKey("tag")) { + assert drctv["tag"] instanceof CharSequence + } + + /* DIRECTIVE time + accepted examples: + - "1h" + - "2days" + - "1day 6hours 3minutes 30seconds" + */ + if (drctv.containsKey("time")) { + assert drctv["time"] instanceof CharSequence + // todo: validation regex? + } + + return drctv +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/workflowFactory/processWorkflowArgs.nf' +def processWorkflowArgs(Map args, Map defaultWfArgs, Map meta) { + // override defaults with args + def workflowArgs = defaultWfArgs + args + + // check whether 'key' exists + assert workflowArgs.containsKey("key") : "Error in module '${meta.config.name}': key is a required argument" + + // if 'key' is a closure, apply it to the original key + if (workflowArgs["key"] instanceof Closure) { + workflowArgs["key"] = workflowArgs["key"](meta.config.name) + } + def key = workflowArgs["key"] + assert key instanceof CharSequence : "Expected process argument 'key' to be a String. Found: class ${key.getClass()}" + assert key ==~ /^[a-zA-Z_]\w*$/ : "Error in module '$key': Expected process argument 'key' to consist of only letters, digits or underscores. Found: ${key}" + + // check for any unexpected keys + def expectedKeys = ["key", "directives", "auto", "map", "mapId", "mapData", "mapPassthrough", "filter", "runIf", "fromState", "toState", "args", "renameKeys", "debug"] + def unexpectedKeys = workflowArgs.keySet() - expectedKeys + assert unexpectedKeys.isEmpty() : "Error in module '$key': unexpected arguments to the '.run()' function: '${unexpectedKeys.join("', '")}'" + + // check whether directives exists and apply defaults + assert workflowArgs.containsKey("directives") : "Error in module '$key': directives is a required argument" + assert workflowArgs["directives"] instanceof Map : "Error in module '$key': Expected process argument 'directives' to be a Map. Found: class ${workflowArgs['directives'].getClass()}" + workflowArgs["directives"] = processDirectives(defaultWfArgs.directives + workflowArgs["directives"]) + + // check whether directives exists and apply defaults + assert workflowArgs.containsKey("auto") : "Error in module '$key': auto is a required argument" + assert workflowArgs["auto"] instanceof Map : "Error in module '$key': Expected process argument 'auto' to be a Map. Found: class ${workflowArgs['auto'].getClass()}" + workflowArgs["auto"] = processAuto(defaultWfArgs.auto + workflowArgs["auto"]) + + // auto define publish, if so desired + if (workflowArgs.auto.publish == true && (workflowArgs.directives.publishDir != null ? workflowArgs.directives.publishDir : [:]).isEmpty()) { + // can't assert at this level thanks to the no_publish profile + // assert params.containsKey("publishDir") || params.containsKey("publish_dir") : + // "Error in module '${workflowArgs['key']}': if auto.publish is true, params.publish_dir needs to be defined.\n" + + // " Example: params.publish_dir = \"./output/\"" + def publishDir = getPublishDir() + + if (publishDir != null) { + workflowArgs.directives.publishDir = [[ + path: publishDir, + saveAs: "{ it.startsWith('.') ? null : it }", // don't publish hidden files, by default + mode: "copy" + ]] + } + } + + // auto define transcript, if so desired + if (workflowArgs.auto.transcript == true) { + // can't assert at this level thanks to the no_publish profile + // assert params.containsKey("transcriptsDir") || params.containsKey("transcripts_dir") || params.containsKey("publishDir") || params.containsKey("publish_dir") : + // "Error in module '${workflowArgs['key']}': if auto.transcript is true, either params.transcripts_dir or params.publish_dir needs to be defined.\n" + + // " Example: params.transcripts_dir = \"./transcripts/\"" + def transcriptsDir = + params.containsKey("transcripts_dir") ? params.transcripts_dir : + params.containsKey("transcriptsDir") ? params.transcriptsDir : + params.containsKey("publish_dir") ? params.publish_dir + "/_transcripts" : + params.containsKey("publishDir") ? params.publishDir + "/_transcripts" : + null + if (transcriptsDir != null) { + def timestamp = nextflow.Nextflow.getSession().getWorkflowMetadata().start.format('yyyy-MM-dd_HH-mm-ss') + def transcriptsPublishDir = [ + path: "$transcriptsDir/$timestamp/\${task.process.replaceAll(':', '-')}/\${id}/", + saveAs: "{ it.startsWith('.') ? it.replaceAll('^.', '') : null }", + mode: "copy" + ] + def publishDirs = workflowArgs.directives.publishDir != null ? workflowArgs.directives.publishDir : null ? workflowArgs.directives.publishDir : [] + workflowArgs.directives.publishDir = publishDirs + transcriptsPublishDir + } + } + + // if this is a stubrun, remove certain directives? + if (workflow.stubRun) { + workflowArgs.directives.keySet().removeAll(["publishDir", "cpus", "memory", "label"]) + } + + for (nam in ["map", "mapId", "mapData", "mapPassthrough", "filter", "runIf"]) { + if (workflowArgs.containsKey(nam) && workflowArgs[nam]) { + assert workflowArgs[nam] instanceof Closure : "Error in module '$key': Expected process argument '$nam' to be null or a Closure. Found: class ${workflowArgs[nam].getClass()}" + } + } + + // TODO: should functions like 'map', 'mapId', 'mapData', 'mapPassthrough' be deprecated as well? + for (nam in ["map", "mapData", "mapPassthrough", "renameKeys"]) { + if (workflowArgs.containsKey(nam) && workflowArgs[nam] != null) { + log.warn "module '$key': workflow argument '$nam' is deprecated and will be removed in Viash 0.9.0. Please use 'fromState' and 'toState' instead." + } + } + + // check fromState + workflowArgs["fromState"] = _processFromState(workflowArgs.get("fromState"), key, meta.config) + + // check toState + workflowArgs["toState"] = _processToState(workflowArgs.get("toState"), key, meta.config) + + // return output + return workflowArgs +} + +def _processFromState(fromState, key_, config_) { + assert fromState == null || fromState instanceof Closure || fromState instanceof Map || fromState instanceof List : + "Error in module '$key_': Expected process argument 'fromState' to be null, a Closure, a Map, or a List. Found: class ${fromState.getClass()}" + if (fromState == null) { + return null + } + + // if fromState is a List, convert to map + if (fromState instanceof List) { + // check whether fromstate is a list[string] + assert fromState.every{it instanceof CharSequence} : "Error in module '$key_': fromState is a List, but not all elements are Strings" + fromState = fromState.collectEntries{[it, it]} + } + + // if fromState is a map, convert to closure + if (fromState instanceof Map) { + // check whether fromstate is a map[string, string] + assert fromState.values().every{it instanceof CharSequence} : "Error in module '$key_': fromState is a Map, but not all values are Strings" + assert fromState.keySet().every{it instanceof CharSequence} : "Error in module '$key_': fromState is a Map, but not all keys are Strings" + def fromStateMap = fromState.clone() + def requiredInputNames = meta.config.allArguments.findAll{it.required && it.direction == "Input"}.collect{it.plainName} + // turn the map into a closure to be used later on + fromState = { it -> + def state = it[1] + assert state instanceof Map : "Error in module '$key_': the state is not a Map" + def data = fromStateMap.collectMany{newkey, origkey -> + // check whether newkey corresponds to a required argument + if (state.containsKey(origkey)) { + [[newkey, state[origkey]]] + } else if (!requiredInputNames.contains(origkey)) { + [] + } else { + throw new Exception("Error in module '$key_': fromState key '$origkey' not found in current state") + } + }.collectEntries() + data + } + } + + return fromState +} + +def _processToState(toState, key_, config_) { + if (toState == null) { + toState = { tup -> tup[1] } + } + + // toState should be a closure, map[string, string], or list[string] + assert toState instanceof Closure || toState instanceof Map || toState instanceof List : + "Error in module '$key_': Expected process argument 'toState' to be a Closure, a Map, or a List. Found: class ${toState.getClass()}" + + // if toState is a List, convert to map + if (toState instanceof List) { + // check whether toState is a list[string] + assert toState.every{it instanceof CharSequence} : "Error in module '$key_': toState is a List, but not all elements are Strings" + toState = toState.collectEntries{[it, it]} + } + + // if toState is a map, convert to closure + if (toState instanceof Map) { + // check whether toState is a map[string, string] + assert toState.values().every{it instanceof CharSequence} : "Error in module '$key_': toState is a Map, but not all values are Strings" + assert toState.keySet().every{it instanceof CharSequence} : "Error in module '$key_': toState is a Map, but not all keys are Strings" + def toStateMap = toState.clone() + def requiredOutputNames = config_.allArguments.findAll{it.required && it.direction == "Output"}.collect{it.plainName} + // turn the map into a closure to be used later on + toState = { it -> + def output = it[1] + def state = it[2] + assert output instanceof Map : "Error in module '$key_': the output is not a Map" + assert state instanceof Map : "Error in module '$key_': the state is not a Map" + def extraEntries = toStateMap.collectMany{newkey, origkey -> + // check whether newkey corresponds to a required argument + if (output.containsKey(origkey)) { + [[newkey, output[origkey]]] + } else if (!requiredOutputNames.contains(origkey)) { + [] + } else { + throw new Exception("Error in module '$key_': toState key '$origkey' not found in current output") + } + }.collectEntries() + state + extraEntries + } + } + + return toState +} + +// helper file: 'src/main/resources/io/viash/runners/nextflow/workflowFactory/workflowFactory.nf' +def _debug(workflowArgs, debugKey) { + if (workflowArgs.debug) { + view { "process '${workflowArgs.key}' $debugKey tuple: $it" } + } else { + map { it } + } +} + +// depends on: innerWorkflowFactory +def workflowFactory(Map args, Map defaultWfArgs, Map meta) { + def workflowArgs = processWorkflowArgs(args, defaultWfArgs, meta) + def key_ = workflowArgs["key"] + + workflow workflowInstance { + take: input_ + + main: + def chModified = input_ + | checkUniqueIds([:]) + | _debug(workflowArgs, "input") + | map { tuple -> + tuple = deepClone(tuple) + + if (workflowArgs.map) { + tuple = workflowArgs.map(tuple) + } + if (workflowArgs.mapId) { + tuple[0] = workflowArgs.mapId(tuple[0]) + } + if (workflowArgs.mapData) { + tuple[1] = workflowArgs.mapData(tuple[1]) + } + if (workflowArgs.mapPassthrough) { + tuple = tuple.take(2) + workflowArgs.mapPassthrough(tuple.drop(2)) + } + + // check tuple + assert tuple instanceof List : + "Error in module '${key_}': element in channel should be a tuple [id, data, ...otherargs...]\n" + + " Example: [\"id\", [input: file('foo.txt'), arg: 10]].\n" + + " Expected class: List. Found: tuple.getClass() is ${tuple.getClass()}" + assert tuple.size() >= 2 : + "Error in module '${key_}': expected length of tuple in input channel to be two or greater.\n" + + " Example: [\"id\", [input: file('foo.txt'), arg: 10]].\n" + + " Found: tuple.size() == ${tuple.size()}" + + // check id field + if (tuple[0] instanceof GString) { + tuple[0] = tuple[0].toString() + } + assert tuple[0] instanceof CharSequence : + "Error in module '${key_}': first element of tuple in channel should be a String\n" + + " Example: [\"id\", [input: file('foo.txt'), arg: 10]].\n" + + " Found: ${tuple[0]}" + + // match file to input file + if (workflowArgs.auto.simplifyInput && (tuple[1] instanceof Path || tuple[1] instanceof List)) { + def inputFiles = meta.config.allArguments + .findAll { it.type == "file" && it.direction == "input" } + + assert inputFiles.size() == 1 : + "Error in module '${key_}' id '${tuple[0]}'.\n" + + " Anonymous file inputs are only allowed when the process has exactly one file input.\n" + + " Expected: inputFiles.size() == 1. Found: inputFiles.size() is ${inputFiles.size()}" + + tuple[1] = [[ inputFiles[0].plainName, tuple[1] ]].collectEntries() + } + + // check data field + assert tuple[1] instanceof Map : + "Error in module '${key_}' id '${tuple[0]}': second element of tuple in channel should be a Map\n" + + " Example: [\"id\", [input: file('foo.txt'), arg: 10]].\n" + + " Expected class: Map. Found: tuple[1].getClass() is ${tuple[1].getClass()}" + + // rename keys of data field in tuple + if (workflowArgs.renameKeys) { + assert workflowArgs.renameKeys instanceof Map : + "Error renaming data keys in module '${key_}' id '${tuple[0]}'.\n" + + " Example: renameKeys: ['new_key': 'old_key'].\n" + + " Expected class: Map. Found: renameKeys.getClass() is ${workflowArgs.renameKeys.getClass()}" + assert tuple[1] instanceof Map : + "Error renaming data keys in module '${key_}' id '${tuple[0]}'.\n" + + " Expected class: Map. Found: tuple[1].getClass() is ${tuple[1].getClass()}" + + // TODO: allow renameKeys to be a function? + workflowArgs.renameKeys.each { newKey, oldKey -> + assert newKey instanceof CharSequence : + "Error renaming data keys in module '${key_}' id '${tuple[0]}'.\n" + + " Example: renameKeys: ['new_key': 'old_key'].\n" + + " Expected class of newKey: String. Found: newKey.getClass() is ${newKey.getClass()}" + assert oldKey instanceof CharSequence : + "Error renaming data keys in module '${key_}' id '${tuple[0]}'.\n" + + " Example: renameKeys: ['new_key': 'old_key'].\n" + + " Expected class of oldKey: String. Found: oldKey.getClass() is ${oldKey.getClass()}" + assert tuple[1].containsKey(oldKey) : + "Error renaming data keys in module '${key}' id '${tuple[0]}'.\n" + + " Key '$oldKey' is missing in the data map. tuple[1].keySet() is '${tuple[1].keySet()}'" + tuple[1].put(newKey, tuple[1][oldKey]) + } + tuple[1].keySet().removeAll(workflowArgs.renameKeys.collect{ newKey, oldKey -> oldKey }) + } + tuple + } + + + def chRun = null + def chPassthrough = null + if (workflowArgs.runIf) { + def runIfBranch = chModified.branch{ tup -> + run: workflowArgs.runIf(tup[0], tup[1]) + passthrough: true + } + chRun = runIfBranch.run + chPassthrough = runIfBranch.passthrough + } else { + chRun = chModified + chPassthrough = Channel.empty() + } + + def chRunFiltered = workflowArgs.filter ? + chRun | filter{workflowArgs.filter(it)} : + chRun + + def chArgs = workflowArgs.fromState ? + chRunFiltered | map{ + def new_data = workflowArgs.fromState(it.take(2)) + [it[0], new_data] + } : + chRunFiltered | map {tup -> tup.take(2)} + + // fill in defaults + def chArgsWithDefaults = chArgs + | map { tuple -> + def id_ = tuple[0] + def data_ = tuple[1] + + // TODO: could move fromState to here + + // fetch default params from functionality + def defaultArgs = meta.config.allArguments + .findAll { it.containsKey("default") } + .collectEntries { [ it.plainName, it.default ] } + + // fetch overrides in params + def paramArgs = meta.config.allArguments + .findAll { par -> + def argKey = key_ + "__" + par.plainName + params.containsKey(argKey) + } + .collectEntries { [ it.plainName, params[key_ + "__" + it.plainName] ] } + + // fetch overrides in data + def dataArgs = meta.config.allArguments + .findAll { data_.containsKey(it.plainName) } + .collectEntries { [ it.plainName, data_[it.plainName] ] } + + // combine params + def combinedArgs = defaultArgs + paramArgs + workflowArgs.args + dataArgs + + // remove arguments with explicit null values + combinedArgs + .removeAll{_, val -> val == null || val == "viash_no_value" || val == "force_null"} + + combinedArgs = _processInputValues(combinedArgs, meta.config, id_, key_) + + [id_, combinedArgs] + tuple.drop(2) + } + + // TODO: move some of the _meta.join_id wrangling to the safeJoin() function. + def chInitialOutput = chArgsWithDefaults + | _debug(workflowArgs, "processed") + // run workflow + | innerWorkflowFactory(workflowArgs) + // check output tuple + | map { id_, output_ -> + + // see if output map contains metadata + def meta_ = + output_ instanceof Map && output_.containsKey("_meta") ? + output_["_meta"] : + [:] + def join_id = meta_.join_id ?: id_ + + // remove metadata + output_ = output_.findAll{k, v -> k != "_meta"} + + // check value types + output_ = _processOutputValues(output_, meta.config, id_, key_) + + // simplify output if need be + if (workflowArgs.auto.simplifyOutput && output_.size() == 1) { + output_ = output_.values()[0] + } + + [join_id, id_, output_] + } + // | view{"chInitialOutput: ${it.take(3)}"} + + // join the output [prev_id, new_id, output] with the previous state [prev_id, state, ...] + def chNewState = safeJoin(chInitialOutput, chRunFiltered, key_) + // input tuple format: [join_id, id, output, prev_state, ...] + // output tuple format: [join_id, id, new_state, ...] + | map{ tup -> + def new_state = workflowArgs.toState(tup.drop(1).take(3)) + tup.take(2) + [new_state] + tup.drop(4) + } + + if (workflowArgs.auto.publish == "state") { + def chPublish = chNewState + // input tuple format: [join_id, id, new_state, ...] + // output tuple format: [join_id, id, new_state] + | map{ tup -> + tup.take(3) + } + + safeJoin(chPublish, chArgsWithDefaults, key_) + // input tuple format: [join_id, id, new_state, orig_state, ...] + // output tuple format: [id, new_state, orig_state] + | map { tup -> + tup.drop(1).take(3) + } + | publishStatesByConfig(key: key_, config: meta.config) + } + + // remove join_id and meta + chReturn = chNewState + | map { tup -> + // input tuple format: [join_id, id, new_state, ...] + // output tuple format: [id, new_state, ...] + tup.drop(1) + } + | _debug(workflowArgs, "output") + | concat(chPassthrough) + + emit: chReturn + } + + def wf = workflowInstance.cloneWithName(key_) + + // add factory function + wf.metaClass.run = { runArgs -> + workflowFactory(runArgs, workflowArgs, meta) + } + // add config to module for later introspection + wf.metaClass.config = meta.config + + return wf +} + +nextflow.enable.dsl=2 + +// START COMPONENT-SPECIFIC CODE + +// create meta object +meta = [ + "resources_dir": moduleDir.toRealPath().normalize(), + "config": processConfig(readJsonBlob('''{ + "name" : "bases2fastq", + "version" : "v0.3.0", + "authors" : [ + { + "name" : "Dries Schaumont", + "roles" : [ + "author", + "maintainer" + ], + "info" : { + "links" : { + "email" : "dries@data-intuitive.com", + "github" : "DriesSchaumont", + "orcid" : "0000-0002-4389-0440", + "linkedin" : "dries-schaumont" + }, + "organizations" : [ + { + "name" : "Data Intuitive", + "href" : "https://www.data-intuitive.com", + "role" : "Data Scientist" + } + ] + } + } + ], + "argument_groups" : [ + { + "name" : "Input", + "arguments" : [ + { + "type" : "file", + "name" : "--analysis_directory", + "description" : "Location of analysis directory", + "example" : [ + "input" + ], + "must_exist" : true, + "create_parent" : true, + "required" : true, + "direction" : "input", + "multiple" : false, + "multiple_sep" : ";" + }, + { + "type" : "file", + "name" : "--run_manifest", + "alternatives" : [ + "-r" + ], + "description" : "Location of run manifest to use instead of default RunManifest.csv found in analysis directory", + "must_exist" : true, + "create_parent" : true, + "required" : false, + "direction" : "input", + "multiple" : false, + "multiple_sep" : ";" + } + ] + }, + { + "name" : "Output", + "arguments" : [ + { + "type" : "file", + "name" : "--output_directory", + "alternatives" : [ + "-o" + ], + "description" : "Location to save output fastqs", + "example" : [ + "fastq_dir" + ], + "must_exist" : true, + "create_parent" : true, + "required" : true, + "direction" : "output", + "multiple" : false, + "multiple_sep" : ";" + }, + { + "type" : "file", + "name" : "--report", + "description" : "Output location for the HTML report", + "must_exist" : true, + "create_parent" : true, + "required" : false, + "direction" : "output", + "multiple" : false, + "multiple_sep" : ";" + }, + { + "type" : "file", + "name" : "--logs", + "description" : "Directory containing log files", + "example" : [ + "logs_dir" + ], + "must_exist" : true, + "create_parent" : true, + "required" : false, + "direction" : "output", + "multiple" : false, + "multiple_sep" : ";" + } + ] + }, + { + "name" : "Arguments", + "arguments" : [ + { + "type" : "string", + "name" : "--chemistry_version", + "description" : "Run parameters override, chemistry version.", + "required" : false, + "direction" : "input", + "multiple" : false, + "multiple_sep" : ";" + }, + { + "type" : "boolean_true", + "name" : "--demux_only", + "alternatives" : [ + "-d" + ], + "description" : "Generate demux files and indexing stats without generating FASTQ\n", + "direction" : "input" + }, + { + "type" : "boolean_true", + "name" : "--detect_adapters", + "description" : "Detect adapters sequences, overriding any sequences present in run manifest.\n", + "direction" : "input" + }, + { + "type" : "boolean_true", + "name" : "--error_on_missing", + "description" : "Terminate execution for a missing file (by default, missing files are\nskipped and execution continues). Also set by --strict.\n", + "direction" : "input" + }, + { + "type" : "string", + "name" : "--exclude_tile", + "alternatives" : [ + "-e" + ], + "description" : "Regex matching tile names to exclude. This flag can be specified multiple times. (e.g. L1.*C0[23]S.)\n", + "required" : false, + "direction" : "input", + "multiple" : true, + "multiple_sep" : ";" + }, + { + "type" : "string", + "name" : "--filter_mask", + "description" : "Run parameters override, custom pass filter mask.\n", + "required" : false, + "direction" : "input", + "multiple" : false, + "multiple_sep" : ";" + }, + { + "type" : "string", + "name" : "--flowcell_id", + "description" : "Run parameters override, flowcell ID.\n", + "required" : false, + "direction" : "input", + "multiple" : false, + "multiple_sep" : ";" + }, + { + "type" : "boolean_true", + "name" : "--force_index_orientation", + "description" : "Do not attempt to find orientation for I1/I2 reads (reverse complement).\nUse orientation given in run manifest.\n", + "direction" : "input" + }, + { + "type" : "boolean_true", + "name" : "--group_fastq", + "description" : "Group all FASTQ/stats/metrics for a project are in the project folder.\n", + "direction" : "input" + }, + { + "type" : "integer", + "name" : "--i1_cycles", + "description" : "Run parameters override, I1 cycles.\n", + "required" : false, + "min" : 1, + "direction" : "input", + "multiple" : false, + "multiple_sep" : ";" + }, + { + "type" : "integer", + "name" : "--i2_cycles", + "description" : "Run parameters override, I2 cycles\n", + "required" : false, + "min" : 1, + "direction" : "input", + "multiple" : false, + "multiple_sep" : ";" + }, + { + "type" : "string", + "name" : "--include_tile", + "alternatives" : [ + "-i" + ], + "description" : "Regex matching tile names to include. This flag\ncan be specified multiple times. (e.g. L1.*C0[23]S.)\n", + "required" : false, + "direction" : "input", + "multiple" : true, + "multiple_sep" : ";" + }, + { + "type" : "string", + "name" : "--kit_configuration", + "description" : "Run parameters override, kit configuration.\n", + "required" : false, + "direction" : "input", + "multiple" : false, + "multiple_sep" : ";" + }, + { + "type" : "boolean_true", + "name" : "--legacy_fastq", + "description" : "Legacy naming for FASTQ files (e.g. SampleName_S1_L001_R1_001.fastq.gz)\n", + "direction" : "input" + }, + { + "type" : "string", + "name" : "--log_level", + "alternatives" : [ + "-l" + ], + "description" : "Severity level for logging.\n", + "example" : [ + "INFO" + ], + "required" : false, + "choices" : [ + "DEBUG", + "INFO", + "WARNING", + "ERROR" + ], + "direction" : "input", + "multiple" : false, + "multiple_sep" : ";" + }, + { + "type" : "boolean_true", + "name" : "--no_error_on_invalid", + "description" : "Skip invalid files and continue execution. Overridden by --strict options\n", + "direction" : "input" + }, + { + "type" : "boolean_true", + "name" : "--no_projects", + "description" : "Disable project directories\n", + "direction" : "input" + }, + { + "type" : "integer", + "name" : "--num_unassigned", + "description" : "Max Number of unassigned sequences to report.\n", + "example" : [ + 30 + ], + "required" : false, + "min" : 0, + "max" : 1000, + "direction" : "input", + "multiple" : false, + "multiple_sep" : ";" + }, + { + "type" : "string", + "name" : "--preparation_workflow", + "description" : "Run parameters override, preparation workflow. \n", + "required" : false, + "direction" : "input", + "multiple" : false, + "multiple_sep" : ";" + }, + { + "type" : "boolean_true", + "name" : "--qc_only", + "description" : "Quickly generate run stats for single tile without generating FASTQ.\nUse --include_tile/--exclude_tile to define custom tile set.\n", + "direction" : "input" + }, + { + "type" : "integer", + "name" : "--r1_cycles", + "description" : "Run parameters override, R1 cycles.\n", + "required" : false, + "min" : 1, + "direction" : "input", + "multiple" : false, + "multiple_sep" : ";" + }, + { + "type" : "integer", + "name" : "--r2_cycles", + "description" : "Run parameters override, R2 cycles.\n", + "required" : false, + "min" : 1, + "direction" : "input", + "multiple" : false, + "multiple_sep" : ";" + }, + { + "type" : "boolean_true", + "name" : "--split_lanes", + "description" : "Split FASTQ files by lane.\n", + "direction" : "input" + }, + { + "type" : "boolean_true", + "name" : "--strict", + "description" : "In strict mode any invalid or missing input file will terminate execution \n(overrides no_error_on_invalid and sets --error_on_missing)\n", + "direction" : "input" + } + ] + } + ], + "resources" : [ + { + "type" : "bash_script", + "path" : "script.sh", + "is_executable" : true + } + ], + "description" : "Bases2Fastq demultiplexes sequencing data generated by Element Biosciences instruments and converts base calls into FASTQ files.\n", + "test_resources" : [ + { + "type" : "bash_script", + "path" : "test.sh", + "is_executable" : true + } + ], + "status" : "enabled", + "requirements" : { + "commands" : [ + "ps" + ] + }, + "keywords" : [ + "demultiplex", + "fastq", + "demux", + "Element Biosciences" + ], + "license" : "Proprietairy", + "links" : { + "repository" : "https://github.com/viash-hub/biobox", + "documentation" : "https://docs.elembio.io/docs/bases2fastq/introduction/" + }, + "runners" : [ + { + "type" : "executable", + "id" : "executable", + "docker_setup_strategy" : "ifneedbepullelsecachedbuild" + }, + { + "type" : "nextflow", + "id" : "nextflow", + "directives" : { + "tag" : "$id" + }, + "auto" : { + "simplifyInput" : true, + "simplifyOutput" : false, + "transcript" : false, + "publish" : false + }, + "config" : { + "labels" : { + "mem1gb" : "memory = 1000000000.B", + "mem2gb" : "memory = 2000000000.B", + "mem5gb" : "memory = 5000000000.B", + "mem10gb" : "memory = 10000000000.B", + "mem20gb" : "memory = 20000000000.B", + "mem50gb" : "memory = 50000000000.B", + "mem100gb" : "memory = 100000000000.B", + "mem200gb" : "memory = 200000000000.B", + "mem500gb" : "memory = 500000000000.B", + "mem1tb" : "memory = 1000000000000.B", + "mem2tb" : "memory = 2000000000000.B", + "mem5tb" : "memory = 5000000000000.B", + "mem10tb" : "memory = 10000000000000.B", + "mem20tb" : "memory = 20000000000000.B", + "mem50tb" : "memory = 50000000000000.B", + "mem100tb" : "memory = 100000000000000.B", + "mem200tb" : "memory = 200000000000000.B", + "mem500tb" : "memory = 500000000000000.B", + "mem1gib" : "memory = 1073741824.B", + "mem2gib" : "memory = 2147483648.B", + "mem4gib" : "memory = 4294967296.B", + "mem8gib" : "memory = 8589934592.B", + "mem16gib" : "memory = 17179869184.B", + "mem32gib" : "memory = 34359738368.B", + "mem64gib" : "memory = 68719476736.B", + "mem128gib" : "memory = 137438953472.B", + "mem256gib" : "memory = 274877906944.B", + "mem512gib" : "memory = 549755813888.B", + "mem1tib" : "memory = 1099511627776.B", + "mem2tib" : "memory = 2199023255552.B", + "mem4tib" : "memory = 4398046511104.B", + "mem8tib" : "memory = 8796093022208.B", + "mem16tib" : "memory = 17592186044416.B", + "mem32tib" : "memory = 35184372088832.B", + "mem64tib" : "memory = 70368744177664.B", + "mem128tib" : "memory = 140737488355328.B", + "mem256tib" : "memory = 281474976710656.B", + "mem512tib" : "memory = 562949953421312.B", + "cpu1" : "cpus = 1", + "cpu2" : "cpus = 2", + "cpu5" : "cpus = 5", + "cpu10" : "cpus = 10", + "cpu20" : "cpus = 20", + "cpu50" : "cpus = 50", + "cpu100" : "cpus = 100", + "cpu200" : "cpus = 200", + "cpu500" : "cpus = 500", + "cpu1000" : "cpus = 1000" + } + }, + "debug" : false, + "container" : "docker" + } + ], + "engines" : [ + { + "type" : "docker", + "id" : "docker", + "image" : "elembio/bases2fastq:2.1.0", + "target_registry" : "images.viash-hub.com", + "target_tag" : "v0.3.0", + "namespace_separator" : "/", + "setup" : [ + { + "type" : "apt", + "packages" : [ + "procps", + "tree" + ], + "interactive" : false + }, + { + "type" : "docker", + "run" : [ + "echo \\"bases2fastq: $(bases2fastq --version | cut -d' ' -f3)\\" > /var/software_versions.txt\n" + ] + } + ], + "test_setup" : [ + { + "type" : "apt", + "packages" : [ + "curl" + ], + "interactive" : false + } + ] + }, + { + "type" : "native", + "id" : "native" + } + ], + "build_info" : { + "config" : "/workdir/root/repo/src/bases2fastq/config.vsh.yaml", + "runner" : "nextflow", + "engine" : "docker|native", + "output" : "target/nextflow/bases2fastq", + "viash_version" : "0.9.0", + "git_commit" : "d86bd5cf62104af02caa852aacd352b1aa97ed60", + "git_remote" : "https://x-access-token:ghs_EwAUAMYJ0K4VBHlAEMs4ZP2OyQYqJM0PSfEO@github.com/viash-hub/biobox", + "git_tag" : "v0.2.0-29-gd86bd5c" + }, + "package_config" : { + "name" : "biobox", + "version" : "v0.3.0", + "description" : "A collection of bioinformatics tools for working with sequence data.\n", + "viash_version" : "0.9.0", + "source" : "src", + "target" : "target", + "config_mods" : [ + ".requirements.commands := ['ps']\n", + ".engines += { type: \\"native\\" }", + ".engines[.type == 'docker'].target_registry := 'images.viash-hub.com'", + ".engines[.type == 'docker'].target_tag := 'v0.3.0'" + ], + "keywords" : [ + "bioinformatics", + "modules", + "sequencing" + ], + "license" : "MIT", + "organization" : "vsh", + "links" : { + "repository" : "https://github.com/viash-hub/biobox", + "issue_tracker" : "https://github.com/viash-hub/biobox/issues" + } + } +}''')) +] + +// resolve dependencies dependencies (if any) + + +// inner workflow +// inner workflow hook +def innerWorkflowFactory(args) { + def rawScript = '''set -e +tempscript=".viash_script.sh" +cat > "$tempscript" << VIASHMAIN +#!/bin/bash + +## VIASH START +# The following code has been auto-generated by Viash. +$( if [ ! -z ${VIASH_PAR_ANALYSIS_DIRECTORY+x} ]; then echo "${VIASH_PAR_ANALYSIS_DIRECTORY}" | sed "s#'#'\\"'\\"'#g;s#.*#par_analysis_directory='&'#" ; else echo "# par_analysis_directory="; fi ) +$( if [ ! -z ${VIASH_PAR_RUN_MANIFEST+x} ]; then echo "${VIASH_PAR_RUN_MANIFEST}" | sed "s#'#'\\"'\\"'#g;s#.*#par_run_manifest='&'#" ; else echo "# par_run_manifest="; fi ) +$( if [ ! -z ${VIASH_PAR_OUTPUT_DIRECTORY+x} ]; then echo "${VIASH_PAR_OUTPUT_DIRECTORY}" | sed "s#'#'\\"'\\"'#g;s#.*#par_output_directory='&'#" ; else echo "# par_output_directory="; fi ) +$( if [ ! -z ${VIASH_PAR_REPORT+x} ]; then echo "${VIASH_PAR_REPORT}" | sed "s#'#'\\"'\\"'#g;s#.*#par_report='&'#" ; else echo "# par_report="; fi ) +$( if [ ! -z ${VIASH_PAR_LOGS+x} ]; then echo "${VIASH_PAR_LOGS}" | sed "s#'#'\\"'\\"'#g;s#.*#par_logs='&'#" ; else echo "# par_logs="; fi ) +$( if [ ! -z ${VIASH_PAR_CHEMISTRY_VERSION+x} ]; then echo "${VIASH_PAR_CHEMISTRY_VERSION}" | sed "s#'#'\\"'\\"'#g;s#.*#par_chemistry_version='&'#" ; else echo "# par_chemistry_version="; fi ) +$( if [ ! -z ${VIASH_PAR_DEMUX_ONLY+x} ]; then echo "${VIASH_PAR_DEMUX_ONLY}" | sed "s#'#'\\"'\\"'#g;s#.*#par_demux_only='&'#" ; else echo "# par_demux_only="; fi ) +$( if [ ! -z ${VIASH_PAR_DETECT_ADAPTERS+x} ]; then echo "${VIASH_PAR_DETECT_ADAPTERS}" | sed "s#'#'\\"'\\"'#g;s#.*#par_detect_adapters='&'#" ; else echo "# par_detect_adapters="; fi ) +$( if [ ! -z ${VIASH_PAR_ERROR_ON_MISSING+x} ]; then echo "${VIASH_PAR_ERROR_ON_MISSING}" | sed "s#'#'\\"'\\"'#g;s#.*#par_error_on_missing='&'#" ; else echo "# par_error_on_missing="; fi ) +$( if [ ! -z ${VIASH_PAR_EXCLUDE_TILE+x} ]; then echo "${VIASH_PAR_EXCLUDE_TILE}" | sed "s#'#'\\"'\\"'#g;s#.*#par_exclude_tile='&'#" ; else echo "# par_exclude_tile="; fi ) +$( if [ ! -z ${VIASH_PAR_FILTER_MASK+x} ]; then echo "${VIASH_PAR_FILTER_MASK}" | sed "s#'#'\\"'\\"'#g;s#.*#par_filter_mask='&'#" ; else echo "# par_filter_mask="; fi ) +$( if [ ! -z ${VIASH_PAR_FLOWCELL_ID+x} ]; then echo "${VIASH_PAR_FLOWCELL_ID}" | sed "s#'#'\\"'\\"'#g;s#.*#par_flowcell_id='&'#" ; else echo "# par_flowcell_id="; fi ) +$( if [ ! -z ${VIASH_PAR_FORCE_INDEX_ORIENTATION+x} ]; then echo "${VIASH_PAR_FORCE_INDEX_ORIENTATION}" | sed "s#'#'\\"'\\"'#g;s#.*#par_force_index_orientation='&'#" ; else echo "# par_force_index_orientation="; fi ) +$( if [ ! -z ${VIASH_PAR_GROUP_FASTQ+x} ]; then echo "${VIASH_PAR_GROUP_FASTQ}" | sed "s#'#'\\"'\\"'#g;s#.*#par_group_fastq='&'#" ; else echo "# par_group_fastq="; fi ) +$( if [ ! -z ${VIASH_PAR_I1_CYCLES+x} ]; then echo "${VIASH_PAR_I1_CYCLES}" | sed "s#'#'\\"'\\"'#g;s#.*#par_i1_cycles='&'#" ; else echo "# par_i1_cycles="; fi ) +$( if [ ! -z ${VIASH_PAR_I2_CYCLES+x} ]; then echo "${VIASH_PAR_I2_CYCLES}" | sed "s#'#'\\"'\\"'#g;s#.*#par_i2_cycles='&'#" ; else echo "# par_i2_cycles="; fi ) +$( if [ ! -z ${VIASH_PAR_INCLUDE_TILE+x} ]; then echo "${VIASH_PAR_INCLUDE_TILE}" | sed "s#'#'\\"'\\"'#g;s#.*#par_include_tile='&'#" ; else echo "# par_include_tile="; fi ) +$( if [ ! -z ${VIASH_PAR_KIT_CONFIGURATION+x} ]; then echo "${VIASH_PAR_KIT_CONFIGURATION}" | sed "s#'#'\\"'\\"'#g;s#.*#par_kit_configuration='&'#" ; else echo "# par_kit_configuration="; fi ) +$( if [ ! -z ${VIASH_PAR_LEGACY_FASTQ+x} ]; then echo "${VIASH_PAR_LEGACY_FASTQ}" | sed "s#'#'\\"'\\"'#g;s#.*#par_legacy_fastq='&'#" ; else echo "# par_legacy_fastq="; fi ) +$( if [ ! -z ${VIASH_PAR_LOG_LEVEL+x} ]; then echo "${VIASH_PAR_LOG_LEVEL}" | sed "s#'#'\\"'\\"'#g;s#.*#par_log_level='&'#" ; else echo "# par_log_level="; fi ) +$( if [ ! -z ${VIASH_PAR_NO_ERROR_ON_INVALID+x} ]; then echo "${VIASH_PAR_NO_ERROR_ON_INVALID}" | sed "s#'#'\\"'\\"'#g;s#.*#par_no_error_on_invalid='&'#" ; else echo "# par_no_error_on_invalid="; fi ) +$( if [ ! -z ${VIASH_PAR_NO_PROJECTS+x} ]; then echo "${VIASH_PAR_NO_PROJECTS}" | sed "s#'#'\\"'\\"'#g;s#.*#par_no_projects='&'#" ; else echo "# par_no_projects="; fi ) +$( if [ ! -z ${VIASH_PAR_NUM_UNASSIGNED+x} ]; then echo "${VIASH_PAR_NUM_UNASSIGNED}" | sed "s#'#'\\"'\\"'#g;s#.*#par_num_unassigned='&'#" ; else echo "# par_num_unassigned="; fi ) +$( if [ ! -z ${VIASH_PAR_PREPARATION_WORKFLOW+x} ]; then echo "${VIASH_PAR_PREPARATION_WORKFLOW}" | sed "s#'#'\\"'\\"'#g;s#.*#par_preparation_workflow='&'#" ; else echo "# par_preparation_workflow="; fi ) +$( if [ ! -z ${VIASH_PAR_QC_ONLY+x} ]; then echo "${VIASH_PAR_QC_ONLY}" | sed "s#'#'\\"'\\"'#g;s#.*#par_qc_only='&'#" ; else echo "# par_qc_only="; fi ) +$( if [ ! -z ${VIASH_PAR_R1_CYCLES+x} ]; then echo "${VIASH_PAR_R1_CYCLES}" | sed "s#'#'\\"'\\"'#g;s#.*#par_r1_cycles='&'#" ; else echo "# par_r1_cycles="; fi ) +$( if [ ! -z ${VIASH_PAR_R2_CYCLES+x} ]; then echo "${VIASH_PAR_R2_CYCLES}" | sed "s#'#'\\"'\\"'#g;s#.*#par_r2_cycles='&'#" ; else echo "# par_r2_cycles="; fi ) +$( if [ ! -z ${VIASH_PAR_SPLIT_LANES+x} ]; then echo "${VIASH_PAR_SPLIT_LANES}" | sed "s#'#'\\"'\\"'#g;s#.*#par_split_lanes='&'#" ; else echo "# par_split_lanes="; fi ) +$( if [ ! -z ${VIASH_PAR_STRICT+x} ]; then echo "${VIASH_PAR_STRICT}" | sed "s#'#'\\"'\\"'#g;s#.*#par_strict='&'#" ; else echo "# par_strict="; fi ) +$( if [ ! -z ${VIASH_META_NAME+x} ]; then echo "${VIASH_META_NAME}" | sed "s#'#'\\"'\\"'#g;s#.*#meta_name='&'#" ; else echo "# meta_name="; fi ) +$( if [ ! -z ${VIASH_META_FUNCTIONALITY_NAME+x} ]; then echo "${VIASH_META_FUNCTIONALITY_NAME}" | sed "s#'#'\\"'\\"'#g;s#.*#meta_functionality_name='&'#" ; else echo "# meta_functionality_name="; fi ) +$( if [ ! -z ${VIASH_META_RESOURCES_DIR+x} ]; then echo "${VIASH_META_RESOURCES_DIR}" | sed "s#'#'\\"'\\"'#g;s#.*#meta_resources_dir='&'#" ; else echo "# meta_resources_dir="; fi ) +$( if [ ! -z ${VIASH_META_EXECUTABLE+x} ]; then echo "${VIASH_META_EXECUTABLE}" | sed "s#'#'\\"'\\"'#g;s#.*#meta_executable='&'#" ; else echo "# meta_executable="; fi ) +$( if [ ! -z ${VIASH_META_CONFIG+x} ]; then echo "${VIASH_META_CONFIG}" | sed "s#'#'\\"'\\"'#g;s#.*#meta_config='&'#" ; else echo "# meta_config="; fi ) +$( if [ ! -z ${VIASH_META_TEMP_DIR+x} ]; then echo "${VIASH_META_TEMP_DIR}" | sed "s#'#'\\"'\\"'#g;s#.*#meta_temp_dir='&'#" ; else echo "# meta_temp_dir="; fi ) +$( if [ ! -z ${VIASH_META_CPUS+x} ]; then echo "${VIASH_META_CPUS}" | sed "s#'#'\\"'\\"'#g;s#.*#meta_cpus='&'#" ; else echo "# meta_cpus="; fi ) +$( if [ ! -z ${VIASH_META_MEMORY_B+x} ]; then echo "${VIASH_META_MEMORY_B}" | sed "s#'#'\\"'\\"'#g;s#.*#meta_memory_b='&'#" ; else echo "# meta_memory_b="; fi ) +$( if [ ! -z ${VIASH_META_MEMORY_KB+x} ]; then echo "${VIASH_META_MEMORY_KB}" | sed "s#'#'\\"'\\"'#g;s#.*#meta_memory_kb='&'#" ; else echo "# meta_memory_kb="; fi ) +$( if [ ! -z ${VIASH_META_MEMORY_MB+x} ]; then echo "${VIASH_META_MEMORY_MB}" | sed "s#'#'\\"'\\"'#g;s#.*#meta_memory_mb='&'#" ; else echo "# meta_memory_mb="; fi ) +$( if [ ! -z ${VIASH_META_MEMORY_GB+x} ]; then echo "${VIASH_META_MEMORY_GB}" | sed "s#'#'\\"'\\"'#g;s#.*#meta_memory_gb='&'#" ; else echo "# meta_memory_gb="; fi ) +$( if [ ! -z ${VIASH_META_MEMORY_TB+x} ]; then echo "${VIASH_META_MEMORY_TB}" | sed "s#'#'\\"'\\"'#g;s#.*#meta_memory_tb='&'#" ; else echo "# meta_memory_tb="; fi ) +$( if [ ! -z ${VIASH_META_MEMORY_PB+x} ]; then echo "${VIASH_META_MEMORY_PB}" | sed "s#'#'\\"'\\"'#g;s#.*#meta_memory_pb='&'#" ; else echo "# meta_memory_pb="; fi ) +$( if [ ! -z ${VIASH_META_MEMORY_KIB+x} ]; then echo "${VIASH_META_MEMORY_KIB}" | sed "s#'#'\\"'\\"'#g;s#.*#meta_memory_kib='&'#" ; else echo "# meta_memory_kib="; fi ) +$( if [ ! -z ${VIASH_META_MEMORY_MIB+x} ]; then echo "${VIASH_META_MEMORY_MIB}" | sed "s#'#'\\"'\\"'#g;s#.*#meta_memory_mib='&'#" ; else echo "# meta_memory_mib="; fi ) +$( if [ ! -z ${VIASH_META_MEMORY_GIB+x} ]; then echo "${VIASH_META_MEMORY_GIB}" | sed "s#'#'\\"'\\"'#g;s#.*#meta_memory_gib='&'#" ; else echo "# meta_memory_gib="; fi ) +$( if [ ! -z ${VIASH_META_MEMORY_TIB+x} ]; then echo "${VIASH_META_MEMORY_TIB}" | sed "s#'#'\\"'\\"'#g;s#.*#meta_memory_tib='&'#" ; else echo "# meta_memory_tib="; fi ) +$( if [ ! -z ${VIASH_META_MEMORY_PIB+x} ]; then echo "${VIASH_META_MEMORY_PIB}" | sed "s#'#'\\"'\\"'#g;s#.*#meta_memory_pib='&'#" ; else echo "# meta_memory_pib="; fi ) + +## VIASH END + +# Exit on error +set -eo pipefail + +# Unset parameters +unset_if_false=( + par_demux_only + par_detect_adapters + par_error_on_missing + par_group_fastq + par_legacy_fastq + par_no_error_on_invalid + par_no_projects + par_qc_only + par_split_lanes + par_skip_qc_report + par_strict + par_force_index_orientation +) + +for par in \\${unset_if_false[@]}; do + test_val="\\${!par}" + [[ "\\$test_val" == "false" ]] && unset \\$par +done + +# NOTE: --preparation-workflow is bugged in bases2fastq +args=( + \\${par_demux_only:+--demux-only} + \\${par_detect_adapters:+--detect-adapters} + \\${par_error_on_missing:+--error-on-missing} + \\${par_group_fastq:+--group-fastq} + \\${par_legacy_fastq:+--legacy-fastq} + \\${par_no_error_on_invalid:+--no-error-on-invalid} + \\${par_no_projects:+--no-projects} + \\${par_split_lanes:+--split-lanes} + \\${par_strict:+--strict} + \\${par_force_index_orientation:+--force-index-orientation} + \\${par_chemistry_version:+--chemistry-version "\\$par_chemistry_version"} + \\${par_filter_mask:+--filter-mask "\\$par_filter_mask"} + \\${par_flowcell_id:+--flowcell-id "\\$par_flowcell_id"} + \\${par_i1_cycles:+--i1-cycles "\\$par_i1_cycles"} + \\${par_i2_cycles:+--i2-cycles "\\$par_i2_cycles"} + \\${par_r1_cycles:+--r1-cycles "\\$par_r1_cycles"} + \\${par_r2_cycles:+--r2-cycles "\\$par_r2_cycles"} + \\${par_kit_configuration:+--kit-configuration "\\$par_kit_configuration"} + \\${par_log_level:+--log-level "\\$par_log_level"} + \\${par_num_unassigned:+--num-unassigned "\\$par_num_unassigned"} + \\${par_preparation_workflow:+--preparation-workflow "\\$par_preparation_workflow"} + \\${meta_cpus:+--num-threads "\\$meta_cpus"} + \\${par_run_manifest:+--run-manifest "\\$par_run_manifest"} +) + +# Create arrays for inputs that contain multiple arguments +IFS=";" read -ra exclude_tile <<< "\\$par_exclude_tile" +IFS=";" read -ra include_tile <<< "\\$par_include_tile" + +if [ -z "\\$par_report" ]; then + args+=( --skip-qc-report ) +fi + +for arg_value in "\\${exclude_tile[@]}"; do + args+=( "--exclude-tile" "\\$arg_value" ) +done + +for arg_value in "\\${include_tile[@]}"; do + args+=( "--include-tile" "\\$arg_value" ) +done + +echo "> Creating temporary directory." +# create temporary directory and clean up on exit +TMPDIR=\\$(mktemp -d "\\$meta_temp_dir/\\$meta_name-XXXXXX") +echo "> Created \\$TMPDIR" +function clean_up { + [[ -d "\\$TMPDIR" ]] && rm -rf "\\$TMPDIR" +} +trap clean_up EXIT + +args+=( "\\$par_analysis_directory" "\\$TMPDIR") +echo "> Running bases2fastq with arguments: \\${args[@]}" +bases2fastq \\${args[@]} +echo "> Done running sgdemux" + +echo "> Output folder:" +tree "\\$TMPDIR" + +echo "> Moving FASTQ files into final output directory" +mkdir -p "\\$par_output_directory/" +mv "\\$TMPDIR"/Samples/* --target-directory="\\$par_output_directory" + +if [ ! -z "\\$par_report" ]; then + echo "> Moving HTML report to the output (\\$par_report)" + mv "\\$TMPDIR"/*.html "\\$par_report" +else + echo " > Leaving reports alone" +fi + +# Logs is everything else +if [ ! -z "\\$par_logs" ]; then + mkdir -p "\\$par_logs" + echo "> Moving logs to their own location (\\$par_logs)" + mv "\\$TMPDIR/"* "\\$par_logs/" +else + echo "> Not moving logs" +fi +VIASHMAIN +bash "$tempscript" +''' + + return vdsl3WorkflowFactory(args, meta, rawScript) +} + + + +/** + * Generate a workflow for VDSL3 modules. + * + * This function is called by the workflowFactory() function. + * + * Input channel: [id, input_map] + * Output channel: [id, output_map] + * + * Internally, this workflow will convert the input channel + * to a format which the Nextflow module will be able to handle. + */ +def vdsl3WorkflowFactory(Map args, Map meta, String rawScript) { + def key = args["key"] + def processObj = null + + workflow processWf { + take: input_ + main: + + if (processObj == null) { + processObj = _vdsl3ProcessFactory(args, meta, rawScript) + } + + output_ = input_ + | map { tuple -> + def id = tuple[0] + def data_ = tuple[1] + + if (workflow.stubRun) { + // add id if missing + data_ = [id: 'stub'] + data_ + } + + // process input files separately + def inputPaths = meta.config.allArguments + .findAll { it.type == "file" && it.direction == "input" } + .collect { par -> + def val = data_.containsKey(par.plainName) ? data_[par.plainName] : [] + def inputFiles = [] + if (val == null) { + inputFiles = [] + } else if (val instanceof List) { + inputFiles = val + } else if (val instanceof Path) { + inputFiles = [ val ] + } else { + inputFiles = [] + } + if (!workflow.stubRun) { + // throw error when an input file doesn't exist + inputFiles.each{ file -> + assert file.exists() : + "Error in module '${key}' id '${id}' argument '${par.plainName}'.\n" + + " Required input file does not exist.\n" + + " Path: '$file'.\n" + + " Expected input file to exist" + } + } + inputFiles + } + + // remove input files + def argsExclInputFiles = meta.config.allArguments + .findAll { (it.type != "file" || it.direction != "input") && data_.containsKey(it.plainName) } + .collectEntries { par -> + def parName = par.plainName + def val = data_[parName] + if (par.multiple && val instanceof Collection) { + val = val.join(par.multiple_sep) + } + if (par.direction == "output" && par.type == "file") { + val = val + .replaceAll('\\$id', id) + .replaceAll('\\$\\{id\\}', id) + .replaceAll('\\$key', key) + .replaceAll('\\$\\{key\\}', key) + } + [parName, val] + } + + [ id ] + inputPaths + [ argsExclInputFiles, meta.resources_dir ] + } + | processObj + | map { output -> + def outputFiles = meta.config.allArguments + .findAll { it.type == "file" && it.direction == "output" } + .indexed() + .collectEntries{ index, par -> + def out = output[index + 1] + // strip dummy '.exitcode' file from output (see nextflow-io/nextflow#2678) + if (!out instanceof List || out.size() <= 1) { + if (par.multiple) { + out = [] + } else { + assert !par.required : + "Error in module '${key}' id '${output[0]}' argument '${par.plainName}'.\n" + + " Required output file is missing" + out = null + } + } else if (out.size() == 2 && !par.multiple) { + out = out[1] + } else { + out = out.drop(1) + } + [ par.plainName, out ] + } + + // drop null outputs + outputFiles.removeAll{it.value == null} + + [ output[0], outputFiles ] + } + emit: output_ + } + + return processWf +} + +// depends on: session? +def _vdsl3ProcessFactory(Map workflowArgs, Map meta, String rawScript) { + // autodetect process key + def wfKey = workflowArgs["key"] + def procKeyPrefix = "${wfKey}_process" + def scriptMeta = nextflow.script.ScriptMeta.current() + def existing = scriptMeta.getProcessNames().findAll{it.startsWith(procKeyPrefix)} + def numbers = existing.collect{it.replace(procKeyPrefix, "0").toInteger()} + def newNumber = (numbers + [-1]).max() + 1 + + def procKey = newNumber == 0 ? procKeyPrefix : "$procKeyPrefix$newNumber" + + if (newNumber > 0) { + log.warn "Key for module '${wfKey}' is duplicated.\n", + "If you run a component multiple times in the same workflow,\n" + + "it's recommended you set a unique key for every call,\n" + + "for example: ${wfKey}.run(key: \"foo\")." + } + + // subset directives and convert to list of tuples + def drctv = workflowArgs.directives + + // TODO: unit test the two commands below + // convert publish array into tags + def valueToStr = { val -> + // ignore closures + if (val instanceof CharSequence) { + if (!val.matches('^[{].*[}]$')) { + '"' + val + '"' + } else { + val + } + } else if (val instanceof List) { + "[" + val.collect{valueToStr(it)}.join(", ") + "]" + } else if (val instanceof Map) { + "[" + val.collect{k, v -> k + ": " + valueToStr(v)}.join(", ") + "]" + } else { + val.inspect() + } + } + + // multiple entries allowed: label, publishdir + def drctvStrs = drctv.collect { key, value -> + if (key in ["label", "publishDir"]) { + value.collect{ val -> + if (val instanceof Map) { + "\n$key " + val.collect{ k, v -> k + ": " + valueToStr(v) }.join(", ") + } else if (val == null) { + "" + } else { + "\n$key " + valueToStr(val) + } + }.join() + } else if (value instanceof Map) { + "\n$key " + value.collect{ k, v -> k + ": " + valueToStr(v) }.join(", ") + } else { + "\n$key " + valueToStr(value) + } + }.join() + + def inputPaths = meta.config.allArguments + .findAll { it.type == "file" && it.direction == "input" } + .collect { ', path(viash_par_' + it.plainName + ', stageAs: "_viash_par/' + it.plainName + '_?/*")' } + .join() + + def outputPaths = meta.config.allArguments + .findAll { it.type == "file" && it.direction == "output" } + .collect { par -> + // insert dummy into every output (see nextflow-io/nextflow#2678) + if (!par.multiple) { + ', path{[".exitcode", args.' + par.plainName + ']}' + } else { + ', path{[".exitcode"] + args.' + par.plainName + '}' + } + } + .join() + + // TODO: move this functionality somewhere else? + if (workflowArgs.auto.transcript) { + outputPaths = outputPaths + ', path{[".exitcode", ".command*"]}' + } else { + outputPaths = outputPaths + ', path{[".exitcode"]}' + } + + // create dirs for output files (based on BashWrapper.createParentFiles) + def createParentStr = meta.config.allArguments + .findAll { it.type == "file" && it.direction == "output" && it.create_parent } + .collect { par -> + def contents = "args[\"${par.plainName}\"] instanceof List ? args[\"${par.plainName}\"].join('\" \"') : args[\"${par.plainName}\"]" + "\${ args.containsKey(\"${par.plainName}\") ? \"mkdir_parent '\" + escapeText(${contents}) + \"'\" : \"\" }" + } + .join("\n") + + // construct inputFileExports + def inputFileExports = meta.config.allArguments + .findAll { it.type == "file" && it.direction.toLowerCase() == "input" } + .collect { par -> + def contents = "viash_par_${par.plainName} instanceof List ? viash_par_${par.plainName}.join(\"${par.multiple_sep}\") : viash_par_${par.plainName}" + "\n\${viash_par_${par.plainName}.empty ? \"\" : \"export VIASH_PAR_${par.plainName.toUpperCase()}='\" + escapeText(${contents}) + \"'\"}" + } + + // NOTE: if using docker, use /tmp instead of tmpDir! + def tmpDir = java.nio.file.Paths.get( + System.getenv('NXF_TEMP') ?: + System.getenv('VIASH_TEMP') ?: + System.getenv('VIASH_TMPDIR') ?: + System.getenv('VIASH_TEMPDIR') ?: + System.getenv('VIASH_TMP') ?: + System.getenv('TEMP') ?: + System.getenv('TMPDIR') ?: + System.getenv('TEMPDIR') ?: + System.getenv('TMP') ?: + '/tmp' + ).toAbsolutePath() + + // construct stub + def stub = meta.config.allArguments + .findAll { it.type == "file" && it.direction == "output" } + .collect { par -> + "\${ args.containsKey(\"${par.plainName}\") ? \"touch2 \\\"\" + (args[\"${par.plainName}\"] instanceof String ? args[\"${par.plainName}\"].replace(\"_*\", \"_0\") : args[\"${par.plainName}\"].join('\" \"')) + \"\\\"\" : \"\" }" + } + .join("\n") + + // escape script + def escapedScript = rawScript.replace('\\', '\\\\').replace('$', '\\$').replace('"""', '\\"\\"\\"') + + // publishdir assert + def assertStr = (workflowArgs.auto.publish == true) || workflowArgs.auto.transcript ? + """\nassert task.publishDir.size() > 0: "if auto.publish is true, params.publish_dir needs to be defined.\\n Example: --publish_dir './output/'" """ : + "" + + // generate process string + def procStr = + """nextflow.enable.dsl=2 + | + |def escapeText = { s -> s.toString().replaceAll("'", "'\\\"'\\\"'") } + |process $procKey {$drctvStrs + |input: + | tuple val(id)$inputPaths, val(args), path(resourcesDir, stageAs: ".viash_meta_resources") + |output: + | tuple val("\$id")$outputPaths, optional: true + |stub: + |\"\"\" + |touch2() { mkdir -p "\\\$(dirname "\\\$1")" && touch "\\\$1" ; } + |$stub + |\"\"\" + |script:$assertStr + |def parInject = args + | .findAll{key, value -> value != null} + | .collect{key, value -> "export VIASH_PAR_\${key.toUpperCase()}='\${escapeText(value)}'"} + | .join("\\n") + |\"\"\" + |# meta exports + |export VIASH_META_RESOURCES_DIR="\${resourcesDir}" + |export VIASH_META_TEMP_DIR="${['docker', 'podman', 'charliecloud'].any{ it == workflow.containerEngine } ? '/tmp' : tmpDir}" + |export VIASH_META_NAME="${meta.config.name}" + |# export VIASH_META_EXECUTABLE="\\\$VIASH_META_RESOURCES_DIR/\\\$VIASH_META_NAME" + |export VIASH_META_CONFIG="\\\$VIASH_META_RESOURCES_DIR/.config.vsh.yaml" + |\${task.cpus ? "export VIASH_META_CPUS=\$task.cpus" : "" } + |\${task.memory?.bytes != null ? "export VIASH_META_MEMORY_B=\$task.memory.bytes" : "" } + |if [ ! -z \\\${VIASH_META_MEMORY_B+x} ]; then + | export VIASH_META_MEMORY_KB=\\\$(( (\\\$VIASH_META_MEMORY_B+999) / 1000 )) + | export VIASH_META_MEMORY_MB=\\\$(( (\\\$VIASH_META_MEMORY_KB+999) / 1000 )) + | export VIASH_META_MEMORY_GB=\\\$(( (\\\$VIASH_META_MEMORY_MB+999) / 1000 )) + | export VIASH_META_MEMORY_TB=\\\$(( (\\\$VIASH_META_MEMORY_GB+999) / 1000 )) + | export VIASH_META_MEMORY_PB=\\\$(( (\\\$VIASH_META_MEMORY_TB+999) / 1000 )) + | export VIASH_META_MEMORY_KIB=\\\$(( (\\\$VIASH_META_MEMORY_B+1023) / 1024 )) + | export VIASH_META_MEMORY_MIB=\\\$(( (\\\$VIASH_META_MEMORY_KIB+1023) / 1024 )) + | export VIASH_META_MEMORY_GIB=\\\$(( (\\\$VIASH_META_MEMORY_MIB+1023) / 1024 )) + | export VIASH_META_MEMORY_TIB=\\\$(( (\\\$VIASH_META_MEMORY_GIB+1023) / 1024 )) + | export VIASH_META_MEMORY_PIB=\\\$(( (\\\$VIASH_META_MEMORY_TIB+1023) / 1024 )) + |fi + | + |# meta synonyms + |export VIASH_TEMP="\\\$VIASH_META_TEMP_DIR" + |export TEMP_DIR="\\\$VIASH_META_TEMP_DIR" + | + |# create output dirs if need be + |function mkdir_parent { + | for file in "\\\$@"; do + | mkdir -p "\\\$(dirname "\\\$file")" + | done + |} + |$createParentStr + | + |# argument exports${inputFileExports.join()} + |\$parInject + | + |# process script + |${escapedScript} + |\"\"\" + |} + |""".stripMargin() + + // TODO: print on debug + // if (workflowArgs.debug == true) { + // println("######################\n$procStr\n######################") + // } + + // write process to temp file + def tempFile = java.nio.file.Files.createTempFile("viash-process-${procKey}-", ".nf") + addShutdownHook { java.nio.file.Files.deleteIfExists(tempFile) } + tempFile.text = procStr + + // create process from temp file + def binding = new nextflow.script.ScriptBinding([:]) + def session = nextflow.Nextflow.getSession() + def parser = new nextflow.script.ScriptParser(session) + .setModule(true) + .setBinding(binding) + def moduleScript = parser.runScript(tempFile) + .getScript() + + // register module in meta + def module = new nextflow.script.IncludeDef.Module(name: procKey) + scriptMeta.addModule(moduleScript, module.name, module.alias) + + // retrieve and return process from meta + return scriptMeta.getProcess(procKey) +} + +// defaults +meta["defaults"] = [ + // key to be used to trace the process and determine output names + key: null, + + // fixed arguments to be passed to script + args: [:], + + // default directives + directives: readJsonBlob('''{ + "container" : { + "registry" : "images.viash-hub.com", + "image" : "vsh/biobox/bases2fastq", + "tag" : "v0.3.0" + }, + "tag" : "$id" +}'''), + + // auto settings + auto: readJsonBlob('''{ + "simplifyInput" : true, + "simplifyOutput" : false, + "transcript" : false, + "publish" : false +}'''), + + // Apply a map over the incoming tuple + // Example: `{ tup -> [ tup[0], [input: tup[1].output] ] + tup.drop(2) }` + map: null, + + // Apply a map over the ID element of a tuple (i.e. the first element) + // Example: `{ id -> id + "_foo" }` + mapId: null, + + // Apply a map over the data element of a tuple (i.e. the second element) + // Example: `{ data -> [ input: data.output ] }` + mapData: null, + + // Apply a map over the passthrough elements of a tuple (i.e. the tuple excl. the first two elements) + // Example: `{ pt -> pt.drop(1) }` + mapPassthrough: null, + + // Filter the channel + // Example: `{ tup -> tup[0] == "foo" }` + filter: null, + + // Choose whether or not to run the component on the tuple if the condition is true. + // Otherwise, the tuple will be passed through. + // Example: `{ tup -> tup[0] != "skip_this" }` + runIf: null, + + // Rename keys in the data field of the tuple (i.e. the second element) + // Will likely be deprecated in favour of `fromState`. + // Example: `[ "new_key": "old_key" ]` + renameKeys: null, + + // Fetch data from the state and pass it to the module without altering the current state. + // + // `fromState` should be `null`, `List[String]`, `Map[String, String]` or a function. + // + // - If it is `null`, the state will be passed to the module as is. + // - If it is a `List[String]`, the data will be the values of the state at the given keys. + // - If it is a `Map[String, String]`, the data will be the values of the state at the given keys, with the keys renamed according to the map. + // - If it is a function, the tuple (`[id, state]`) in the channel will be passed to the function, and the result will be used as the data. + // + // Example: `{ id, state -> [input: state.fastq_file] }` + // Default: `null` + fromState: null, + + // Determine how the state should be updated after the module has been run. + // + // `toState` should be `null`, `List[String]`, `Map[String, String]` or a function. + // + // - If it is `null`, the state will be replaced with the output of the module. + // - If it is a `List[String]`, the state will be updated with the values of the data at the given keys. + // - If it is a `Map[String, String]`, the state will be updated with the values of the data at the given keys, with the keys renamed according to the map. + // - If it is a function, a tuple (`[id, output, state]`) will be passed to the function, and the result will be used as the new state. + // + // Example: `{ id, output, state -> state + [counts: state.output] }` + // Default: `{ id, output, state -> output }` + toState: null, + + // Whether or not to print debug messages + // Default: `false` + debug: false +] + +// initialise default workflow +meta["workflow"] = workflowFactory([key: meta.config.name], meta.defaults, meta) + +// add workflow to environment +nextflow.script.ScriptMeta.current().addDefinition(meta.workflow) + +// anonymous workflow for running this module as a standalone +workflow { + // add id argument if it's not already in the config + // TODO: deep copy + def newConfig = deepClone(meta.config) + def newParams = deepClone(params) + + def argsContainsId = newConfig.allArguments.any{it.plainName == "id"} + if (!argsContainsId) { + def idArg = [ + 'name': '--id', + 'required': false, + 'type': 'string', + 'description': 'A unique id for every entry.', + 'multiple': false + ] + newConfig.arguments.add(0, idArg) + newConfig = processConfig(newConfig) + } + if (!newParams.containsKey("id")) { + newParams.id = "run" + } + + helpMessage(newConfig) + + channelFromParams(newParams, newConfig) + // make sure id is not in the state if id is not in the args + | map {id, state -> + if (!argsContainsId) { + [id, state.findAll{k, v -> k != "id"}] + } else { + [id, state] + } + } + | meta.workflow.run( + auto: [ publish: "state" ] + ) +} + +// END COMPONENT-SPECIFIC CODE diff --git a/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/bases2fastq/nextflow.config b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/bases2fastq/nextflow.config new file mode 100644 index 0000000..8f021dd --- /dev/null +++ b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/bases2fastq/nextflow.config @@ -0,0 +1,126 @@ +manifest { + name = 'bases2fastq' + mainScript = 'main.nf' + nextflowVersion = '!>=20.12.1-edge' + version = 'v0.3.0' + description = 'Bases2Fastq demultiplexes sequencing data generated by Element Biosciences instruments and converts base calls into FASTQ files.\n' + author = 'Dries Schaumont' +} + +process.container = 'nextflow/bash:latest' + +// detect tempdir +tempDir = java.nio.file.Paths.get( + System.getenv('NXF_TEMP') ?: + System.getenv('VIASH_TEMP') ?: + System.getenv('TEMPDIR') ?: + System.getenv('TMPDIR') ?: + '/tmp' +).toAbsolutePath() + +profiles { + no_publish { + process { + withName: '.*' { + publishDir = [ + enabled: false + ] + } + } + } + mount_temp { + docker.temp = tempDir + podman.temp = tempDir + charliecloud.temp = tempDir + } + docker { + docker.enabled = true + // docker.userEmulation = true + singularity.enabled = false + podman.enabled = false + shifter.enabled = false + charliecloud.enabled = false + } + singularity { + singularity.enabled = true + singularity.autoMounts = true + docker.enabled = false + podman.enabled = false + shifter.enabled = false + charliecloud.enabled = false + } + podman { + podman.enabled = true + docker.enabled = false + singularity.enabled = false + shifter.enabled = false + charliecloud.enabled = false + } + shifter { + shifter.enabled = true + docker.enabled = false + singularity.enabled = false + podman.enabled = false + charliecloud.enabled = false + } + charliecloud { + charliecloud.enabled = true + docker.enabled = false + singularity.enabled = false + podman.enabled = false + shifter.enabled = false + } +} + +process{ + withLabel: mem1gb { memory = 1000000000.B } + withLabel: mem2gb { memory = 2000000000.B } + withLabel: mem5gb { memory = 5000000000.B } + withLabel: mem10gb { memory = 10000000000.B } + withLabel: mem20gb { memory = 20000000000.B } + withLabel: mem50gb { memory = 50000000000.B } + withLabel: mem100gb { memory = 100000000000.B } + withLabel: mem200gb { memory = 200000000000.B } + withLabel: mem500gb { memory = 500000000000.B } + withLabel: mem1tb { memory = 1000000000000.B } + withLabel: mem2tb { memory = 2000000000000.B } + withLabel: mem5tb { memory = 5000000000000.B } + withLabel: mem10tb { memory = 10000000000000.B } + withLabel: mem20tb { memory = 20000000000000.B } + withLabel: mem50tb { memory = 50000000000000.B } + withLabel: mem100tb { memory = 100000000000000.B } + withLabel: mem200tb { memory = 200000000000000.B } + withLabel: mem500tb { memory = 500000000000000.B } + withLabel: mem1gib { memory = 1073741824.B } + withLabel: mem2gib { memory = 2147483648.B } + withLabel: mem4gib { memory = 4294967296.B } + withLabel: mem8gib { memory = 8589934592.B } + withLabel: mem16gib { memory = 17179869184.B } + withLabel: mem32gib { memory = 34359738368.B } + withLabel: mem64gib { memory = 68719476736.B } + withLabel: mem128gib { memory = 137438953472.B } + withLabel: mem256gib { memory = 274877906944.B } + withLabel: mem512gib { memory = 549755813888.B } + withLabel: mem1tib { memory = 1099511627776.B } + withLabel: mem2tib { memory = 2199023255552.B } + withLabel: mem4tib { memory = 4398046511104.B } + withLabel: mem8tib { memory = 8796093022208.B } + withLabel: mem16tib { memory = 17592186044416.B } + withLabel: mem32tib { memory = 35184372088832.B } + withLabel: mem64tib { memory = 70368744177664.B } + withLabel: mem128tib { memory = 140737488355328.B } + withLabel: mem256tib { memory = 281474976710656.B } + withLabel: mem512tib { memory = 562949953421312.B } + withLabel: cpu1 { cpus = 1 } + withLabel: cpu2 { cpus = 2 } + withLabel: cpu5 { cpus = 5 } + withLabel: cpu10 { cpus = 10 } + withLabel: cpu20 { cpus = 20 } + withLabel: cpu50 { cpus = 50 } + withLabel: cpu100 { cpus = 100 } + withLabel: cpu200 { cpus = 200 } + withLabel: cpu500 { cpus = 500 } + withLabel: cpu1000 { cpus = 1000 } +} + + diff --git a/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/bases2fastq/nextflow_schema.json b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/bases2fastq/nextflow_schema.json new file mode 100644 index 0000000..2342a39 --- /dev/null +++ b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/bases2fastq/nextflow_schema.json @@ -0,0 +1,394 @@ +{ +"$schema": "http://json-schema.org/draft-07/schema", +"title": "bases2fastq", +"description": "Bases2Fastq demultiplexes sequencing data generated by Element Biosciences instruments and converts base calls into FASTQ files.\n", +"type": "object", +"definitions": { + + + + "arguments" : { + "title": "Arguments", + "type": "object", + "description": "No description", + "properties": { + + + "chemistry_version": { + "type": + "string", + "description": "Type: `string`. Run parameters override, chemistry version", + "help_text": "Type: `string`. Run parameters override, chemistry version." + + } + + + , + "demux_only": { + "type": + "boolean", + "description": "Type: `boolean_true`, default: `false`. Generate demux files and indexing stats without generating FASTQ\n", + "help_text": "Type: `boolean_true`, default: `false`. Generate demux files and indexing stats without generating FASTQ\n" + , + "default":false + } + + + , + "detect_adapters": { + "type": + "boolean", + "description": "Type: `boolean_true`, default: `false`. Detect adapters sequences, overriding any sequences present in run manifest", + "help_text": "Type: `boolean_true`, default: `false`. Detect adapters sequences, overriding any sequences present in run manifest.\n" + , + "default":false + } + + + , + "error_on_missing": { + "type": + "boolean", + "description": "Type: `boolean_true`, default: `false`. Terminate execution for a missing file (by default, missing files are\nskipped and execution continues)", + "help_text": "Type: `boolean_true`, default: `false`. Terminate execution for a missing file (by default, missing files are\nskipped and execution continues). Also set by --strict.\n" + , + "default":false + } + + + , + "exclude_tile": { + "type": + "string", + "description": "Type: List of `string`, multiple_sep: `\";\"`. Regex matching tile names to exclude", + "help_text": "Type: List of `string`, multiple_sep: `\";\"`. Regex matching tile names to exclude. This flag can be specified multiple times. (e.g. L1.*C0[23]S.)\n" + + } + + + , + "filter_mask": { + "type": + "string", + "description": "Type: `string`. Run parameters override, custom pass filter mask", + "help_text": "Type: `string`. Run parameters override, custom pass filter mask.\n" + + } + + + , + "flowcell_id": { + "type": + "string", + "description": "Type: `string`. Run parameters override, flowcell ID", + "help_text": "Type: `string`. Run parameters override, flowcell ID.\n" + + } + + + , + "force_index_orientation": { + "type": + "boolean", + "description": "Type: `boolean_true`, default: `false`. Do not attempt to find orientation for I1/I2 reads (reverse complement)", + "help_text": "Type: `boolean_true`, default: `false`. Do not attempt to find orientation for I1/I2 reads (reverse complement).\nUse orientation given in run manifest.\n" + , + "default":false + } + + + , + "group_fastq": { + "type": + "boolean", + "description": "Type: `boolean_true`, default: `false`. Group all FASTQ/stats/metrics for a project are in the project folder", + "help_text": "Type: `boolean_true`, default: `false`. Group all FASTQ/stats/metrics for a project are in the project folder.\n" + , + "default":false + } + + + , + "i1_cycles": { + "type": + "integer", + "description": "Type: `integer`. Run parameters override, I1 cycles", + "help_text": "Type: `integer`. Run parameters override, I1 cycles.\n" + + } + + + , + "i2_cycles": { + "type": + "integer", + "description": "Type: `integer`. Run parameters override, I2 cycles\n", + "help_text": "Type: `integer`. Run parameters override, I2 cycles\n" + + } + + + , + "include_tile": { + "type": + "string", + "description": "Type: List of `string`, multiple_sep: `\";\"`. Regex matching tile names to include", + "help_text": "Type: List of `string`, multiple_sep: `\";\"`. Regex matching tile names to include. This flag\ncan be specified multiple times. (e.g. L1.*C0[23]S.)\n" + + } + + + , + "kit_configuration": { + "type": + "string", + "description": "Type: `string`. Run parameters override, kit configuration", + "help_text": "Type: `string`. Run parameters override, kit configuration.\n" + + } + + + , + "legacy_fastq": { + "type": + "boolean", + "description": "Type: `boolean_true`, default: `false`. Legacy naming for FASTQ files (e", + "help_text": "Type: `boolean_true`, default: `false`. Legacy naming for FASTQ files (e.g. SampleName_S1_L001_R1_001.fastq.gz)\n" + , + "default":false + } + + + , + "log_level": { + "type": + "string", + "description": "Type: `string`, example: `INFO`, choices: ``DEBUG`, `INFO`, `WARNING`, `ERROR``. Severity level for logging", + "help_text": "Type: `string`, example: `INFO`, choices: ``DEBUG`, `INFO`, `WARNING`, `ERROR``. Severity level for logging.\n", + "enum": ["DEBUG", "INFO", "WARNING", "ERROR"] + + + } + + + , + "no_error_on_invalid": { + "type": + "boolean", + "description": "Type: `boolean_true`, default: `false`. Skip invalid files and continue execution", + "help_text": "Type: `boolean_true`, default: `false`. Skip invalid files and continue execution. Overridden by --strict options\n" + , + "default":false + } + + + , + "no_projects": { + "type": + "boolean", + "description": "Type: `boolean_true`, default: `false`. Disable project directories\n", + "help_text": "Type: `boolean_true`, default: `false`. Disable project directories\n" + , + "default":false + } + + + , + "num_unassigned": { + "type": + "integer", + "description": "Type: `integer`, example: `30`. Max Number of unassigned sequences to report", + "help_text": "Type: `integer`, example: `30`. Max Number of unassigned sequences to report.\n" + + } + + + , + "preparation_workflow": { + "type": + "string", + "description": "Type: `string`. Run parameters override, preparation workflow", + "help_text": "Type: `string`. Run parameters override, preparation workflow. \n" + + } + + + , + "qc_only": { + "type": + "boolean", + "description": "Type: `boolean_true`, default: `false`. Quickly generate run stats for single tile without generating FASTQ", + "help_text": "Type: `boolean_true`, default: `false`. Quickly generate run stats for single tile without generating FASTQ.\nUse --include_tile/--exclude_tile to define custom tile set.\n" + , + "default":false + } + + + , + "r1_cycles": { + "type": + "integer", + "description": "Type: `integer`. Run parameters override, R1 cycles", + "help_text": "Type: `integer`. Run parameters override, R1 cycles.\n" + + } + + + , + "r2_cycles": { + "type": + "integer", + "description": "Type: `integer`. Run parameters override, R2 cycles", + "help_text": "Type: `integer`. Run parameters override, R2 cycles.\n" + + } + + + , + "split_lanes": { + "type": + "boolean", + "description": "Type: `boolean_true`, default: `false`. Split FASTQ files by lane", + "help_text": "Type: `boolean_true`, default: `false`. Split FASTQ files by lane.\n" + , + "default":false + } + + + , + "strict": { + "type": + "boolean", + "description": "Type: `boolean_true`, default: `false`. In strict mode any invalid or missing input file will terminate execution \n(overrides no_error_on_invalid and sets --error_on_missing)\n", + "help_text": "Type: `boolean_true`, default: `false`. In strict mode any invalid or missing input file will terminate execution \n(overrides no_error_on_invalid and sets --error_on_missing)\n" + , + "default":false + } + + +} +}, + + + "input" : { + "title": "Input", + "type": "object", + "description": "No description", + "properties": { + + + "analysis_directory": { + "type": + "string", + "description": "Type: `file`, required, example: `input`. Location of analysis directory", + "help_text": "Type: `file`, required, example: `input`. Location of analysis directory" + + } + + + , + "run_manifest": { + "type": + "string", + "description": "Type: `file`. Location of run manifest to use instead of default RunManifest", + "help_text": "Type: `file`. Location of run manifest to use instead of default RunManifest.csv found in analysis directory" + + } + + +} +}, + + + "output" : { + "title": "Output", + "type": "object", + "description": "No description", + "properties": { + + + "output_directory": { + "type": + "string", + "description": "Type: `file`, required, default: `$id.$key.output_directory.output_directory`, example: `fastq_dir`. Location to save output fastqs", + "help_text": "Type: `file`, required, default: `$id.$key.output_directory.output_directory`, example: `fastq_dir`. Location to save output fastqs" + , + "default":"$id.$key.output_directory.output_directory" + } + + + , + "report": { + "type": + "string", + "description": "Type: `file`, default: `$id.$key.report.report`. Output location for the HTML report", + "help_text": "Type: `file`, default: `$id.$key.report.report`. Output location for the HTML report" + , + "default":"$id.$key.report.report" + } + + + , + "logs": { + "type": + "string", + "description": "Type: `file`, default: `$id.$key.logs.logs`, example: `logs_dir`. Directory containing log files", + "help_text": "Type: `file`, default: `$id.$key.logs.logs`, example: `logs_dir`. Directory containing log files" + , + "default":"$id.$key.logs.logs" + } + + +} +}, + + + "nextflow input-output arguments" : { + "title": "Nextflow input-output arguments", + "type": "object", + "description": "Input/output parameters for Nextflow itself. Please note that both publishDir and publish_dir are supported but at least one has to be configured.", + "properties": { + + + "publish_dir": { + "type": + "string", + "description": "Type: `string`, required, example: `output/`. Path to an output directory", + "help_text": "Type: `string`, required, example: `output/`. Path to an output directory." + + } + + + , + "param_list": { + "type": + "string", + "description": "Type: `string`, example: `my_params.yaml`. Allows inputting multiple parameter sets to initialise a Nextflow channel", + "help_text": "Type: `string`, example: `my_params.yaml`. Allows inputting multiple parameter sets to initialise a Nextflow channel. A `param_list` can either be a list of maps, a csv file, a json file, a yaml file, or simply a yaml blob.\n\n* A list of maps (as-is) where the keys of each map corresponds to the arguments of the pipeline. Example: in a `nextflow.config` file: `param_list: [ [\u0027id\u0027: \u0027foo\u0027, \u0027input\u0027: \u0027foo.txt\u0027], [\u0027id\u0027: \u0027bar\u0027, \u0027input\u0027: \u0027bar.txt\u0027] ]`.\n* A csv file should have column names which correspond to the different arguments of this pipeline. Example: `--param_list data.csv` with columns `id,input`.\n* A json or a yaml file should be a list of maps, each of which has keys corresponding to the arguments of the pipeline. Example: `--param_list data.json` with contents `[ {\u0027id\u0027: \u0027foo\u0027, \u0027input\u0027: \u0027foo.txt\u0027}, {\u0027id\u0027: \u0027bar\u0027, \u0027input\u0027: \u0027bar.txt\u0027} ]`.\n* A yaml blob can also be passed directly as a string. Example: `--param_list \"[ {\u0027id\u0027: \u0027foo\u0027, \u0027input\u0027: \u0027foo.txt\u0027}, {\u0027id\u0027: \u0027bar\u0027, \u0027input\u0027: \u0027bar.txt\u0027} ]\"`.\n\nWhen passing a csv, json or yaml file, relative path names are relativized to the location of the parameter file. No relativation is performed when `param_list` is a list of maps (as-is) or a yaml blob.", + "hidden": true + + } + + +} +} +}, +"allOf": [ + + { + "$ref": "#/definitions/arguments" + }, + + { + "$ref": "#/definitions/input" + }, + + { + "$ref": "#/definitions/output" + }, + + { + "$ref": "#/definitions/nextflow input-output arguments" + } +] +} diff --git a/target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/bcl_convert/.config.vsh.yaml b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/bcl_convert/.config.vsh.yaml similarity index 97% rename from target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/bcl_convert/.config.vsh.yaml rename to target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/bcl_convert/.config.vsh.yaml index 1eb5edc..b107c50 100644 --- a/target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/bcl_convert/.config.vsh.yaml +++ b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/bcl_convert/.config.vsh.yaml @@ -1,5 +1,5 @@ name: "bcl_convert" -version: "v0.2.0" +version: "v0.3.0" authors: - name: "Toni Verbeiren" roles: @@ -386,7 +386,7 @@ engines: id: "docker" image: "debian:trixie-slim" target_registry: "images.viash-hub.com" - target_tag: "v0.2.0" + target_tag: "v0.3.0" namespace_separator: "/" setup: - type: "apt" @@ -418,11 +418,12 @@ build_info: output: "target/nextflow/bcl_convert" executable: "target/nextflow/bcl_convert/main.nf" viash_version: "0.9.0" - git_commit: "7e530218844c373048bc33de58f021b6460642e5" - git_remote: "https://x-access-token:ghs_kiUBq39QrAlnG6IaeAcTcXhllzqpOV4LDB3e@github.com/viash-hub/biobox" + git_commit: "d86bd5cf62104af02caa852aacd352b1aa97ed60" + git_remote: "https://x-access-token:ghs_EwAUAMYJ0K4VBHlAEMs4ZP2OyQYqJM0PSfEO@github.com/viash-hub/biobox" + git_tag: "v0.2.0-29-gd86bd5c" package_config: name: "biobox" - version: "v0.2.0" + version: "v0.3.0" description: "A collection of bioinformatics tools for working with sequence data.\n" info: null viash_version: "0.9.0" @@ -432,7 +433,7 @@ package_config: - ".requirements.commands := ['ps']\n" - ".engines += { type: \"native\" }" - ".engines[.type == 'docker'].target_registry := 'images.viash-hub.com'" - - ".engines[.type == 'docker'].target_tag := 'v0.2.0'" + - ".engines[.type == 'docker'].target_tag := 'v0.3.0'" keywords: - "bioinformatics" - "modules" diff --git a/target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/bcl_convert/main.nf b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/bcl_convert/main.nf similarity index 99% rename from target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/bcl_convert/main.nf rename to target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/bcl_convert/main.nf index 4c068af..e5f4ea9 100644 --- a/target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/bcl_convert/main.nf +++ b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/bcl_convert/main.nf @@ -1,4 +1,4 @@ -// bcl_convert v0.2.0 +// bcl_convert v0.3.0 // // This wrapper script is auto-generated by viash 0.9.0 and is thus a derivative // work thereof. This software comes with ABSOLUTELY NO WARRANTY from Data @@ -2809,7 +2809,7 @@ meta = [ "resources_dir": moduleDir.toRealPath().normalize(), "config": processConfig(readJsonBlob('''{ "name" : "bcl_convert", - "version" : "v0.2.0", + "version" : "v0.3.0", "authors" : [ { "name" : "Toni Verbeiren", @@ -3289,7 +3289,7 @@ meta = [ "id" : "docker", "image" : "debian:trixie-slim", "target_registry" : "images.viash-hub.com", - "target_tag" : "v0.2.0", + "target_tag" : "v0.3.0", "namespace_separator" : "/", "setup" : [ { @@ -3329,12 +3329,13 @@ meta = [ "engine" : "docker|native", "output" : "target/nextflow/bcl_convert", "viash_version" : "0.9.0", - "git_commit" : "7e530218844c373048bc33de58f021b6460642e5", - "git_remote" : "https://x-access-token:ghs_kiUBq39QrAlnG6IaeAcTcXhllzqpOV4LDB3e@github.com/viash-hub/biobox" + "git_commit" : "d86bd5cf62104af02caa852aacd352b1aa97ed60", + "git_remote" : "https://x-access-token:ghs_EwAUAMYJ0K4VBHlAEMs4ZP2OyQYqJM0PSfEO@github.com/viash-hub/biobox", + "git_tag" : "v0.2.0-29-gd86bd5c" }, "package_config" : { "name" : "biobox", - "version" : "v0.2.0", + "version" : "v0.3.0", "description" : "A collection of bioinformatics tools for working with sequence data.\n", "viash_version" : "0.9.0", "source" : "src", @@ -3343,7 +3344,7 @@ meta = [ ".requirements.commands := ['ps']\n", ".engines += { type: \\"native\\" }", ".engines[.type == 'docker'].target_registry := 'images.viash-hub.com'", - ".engines[.type == 'docker'].target_tag := 'v0.2.0'" + ".engines[.type == 'docker'].target_tag := 'v0.3.0'" ], "keywords" : [ "bioinformatics", @@ -3815,7 +3816,7 @@ meta["defaults"] = [ "container" : { "registry" : "images.viash-hub.com", "image" : "vsh/biobox/bcl_convert", - "tag" : "v0.2.0" + "tag" : "v0.3.0" }, "tag" : "$id" }'''), diff --git a/target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/bcl_convert/nextflow.config b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/bcl_convert/nextflow.config similarity index 99% rename from target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/bcl_convert/nextflow.config rename to target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/bcl_convert/nextflow.config index 20ea31b..6c28eac 100644 --- a/target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/bcl_convert/nextflow.config +++ b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/bcl_convert/nextflow.config @@ -2,7 +2,7 @@ manifest { name = 'bcl_convert' mainScript = 'main.nf' nextflowVersion = '!>=20.12.1-edge' - version = 'v0.2.0' + version = 'v0.3.0' description = 'Convert bcl files to fastq files using bcl-convert.\nInformation about upgrading from bcl2fastq via\n[Upgrading from bcl2fastq to BCL Convert](https://emea.support.illumina.com/bulletins/2020/10/upgrading-from-bcl2fastq-to-bcl-convert.html)\nand [BCL Convert Compatible Products](https://support.illumina.com/sequencing/sequencing_software/bcl-convert/compatibility.html)\n' author = 'Toni Verbeiren, Dorien Roosen' } diff --git a/target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/bcl_convert/nextflow_schema.json b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/bcl_convert/nextflow_schema.json similarity index 98% rename from target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/bcl_convert/nextflow_schema.json rename to target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/bcl_convert/nextflow_schema.json index 5fa9b05..2eec36d 100644 --- a/target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/bcl_convert/nextflow_schema.json +++ b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/bcl_convert/nextflow_schema.json @@ -240,7 +240,7 @@ "description": "Type: `file`, required, default: `$id.$key.output_directory.output_directory`, example: `fastq_dir`. Output directory containig fastq files", "help_text": "Type: `file`, required, default: `$id.$key.output_directory.output_directory`, example: `fastq_dir`. Output directory containig fastq files" , - "default": "$id.$key.output_directory.output_directory" + "default":"$id.$key.output_directory.output_directory" } @@ -271,7 +271,7 @@ "description": "Type: `file`, default: `$id.$key.reports.reports`, example: `reports_dir`. Reports directory", "help_text": "Type: `file`, default: `$id.$key.reports.reports`, example: `reports_dir`. Reports directory" , - "default": "$id.$key.reports.reports" + "default":"$id.$key.reports.reports" } @@ -282,7 +282,7 @@ "description": "Type: `file`, default: `$id.$key.logs.logs`, example: `logs_dir`. Reports directory", "help_text": "Type: `file`, default: `$id.$key.logs.logs`, example: `logs_dir`. Reports directory" , - "default": "$id.$key.logs.logs" + "default":"$id.$key.logs.logs" } diff --git a/target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/falco/.config.vsh.yaml b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/falco/.config.vsh.yaml similarity index 96% rename from target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/falco/.config.vsh.yaml rename to target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/falco/.config.vsh.yaml index b503611..89960cc 100644 --- a/target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/falco/.config.vsh.yaml +++ b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/falco/.config.vsh.yaml @@ -1,5 +1,5 @@ name: "falco" -version: "v0.2.0" +version: "v0.3.0" authors: - name: "Toni Verbeiren" roles: @@ -101,7 +101,7 @@ argument_groups: info: null direction: "input" - type: "boolean_true" - name: "--reverse_complliment" + name: "--reverse_complement" alternatives: - "-r" description: "[Falco only] The input is a \nreverse-complement. All modules will\ @@ -287,7 +287,7 @@ engines: id: "docker" image: "debian:trixie-slim" target_registry: "images.viash-hub.com" - target_tag: "v0.2.0" + target_tag: "v0.3.0" namespace_separator: "/" setup: - type: "apt" @@ -317,11 +317,12 @@ build_info: output: "target/nextflow/falco" executable: "target/nextflow/falco/main.nf" viash_version: "0.9.0" - git_commit: "7e530218844c373048bc33de58f021b6460642e5" - git_remote: "https://x-access-token:ghs_kiUBq39QrAlnG6IaeAcTcXhllzqpOV4LDB3e@github.com/viash-hub/biobox" + git_commit: "d86bd5cf62104af02caa852aacd352b1aa97ed60" + git_remote: "https://x-access-token:ghs_EwAUAMYJ0K4VBHlAEMs4ZP2OyQYqJM0PSfEO@github.com/viash-hub/biobox" + git_tag: "v0.2.0-29-gd86bd5c" package_config: name: "biobox" - version: "v0.2.0" + version: "v0.3.0" description: "A collection of bioinformatics tools for working with sequence data.\n" info: null viash_version: "0.9.0" @@ -331,7 +332,7 @@ package_config: - ".requirements.commands := ['ps']\n" - ".engines += { type: \"native\" }" - ".engines[.type == 'docker'].target_registry := 'images.viash-hub.com'" - - ".engines[.type == 'docker'].target_tag := 'v0.2.0'" + - ".engines[.type == 'docker'].target_tag := 'v0.3.0'" keywords: - "bioinformatics" - "modules" diff --git a/target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/falco/main.nf b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/falco/main.nf similarity index 99% rename from target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/falco/main.nf rename to target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/falco/main.nf index cebc361..ab359fc 100644 --- a/target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/falco/main.nf +++ b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/falco/main.nf @@ -1,4 +1,4 @@ -// falco v0.2.0 +// falco v0.3.0 // // This wrapper script is auto-generated by viash 0.9.0 and is thus a derivative // work thereof. This software comes with ABSOLUTELY NO WARRANTY from Data @@ -2808,7 +2808,7 @@ meta = [ "resources_dir": moduleDir.toRealPath().normalize(), "config": processConfig(readJsonBlob('''{ "name" : "falco", - "version" : "v0.2.0", + "version" : "v0.3.0", "authors" : [ { "name" : "Toni Verbeiren", @@ -2919,7 +2919,7 @@ meta = [ }, { "type" : "boolean_true", - "name" : "--reverse_complliment", + "name" : "--reverse_complement", "alternatives" : [ "-r" ], @@ -3131,7 +3131,7 @@ meta = [ "id" : "docker", "image" : "debian:trixie-slim", "target_registry" : "images.viash-hub.com", - "target_tag" : "v0.2.0", + "target_tag" : "v0.3.0", "namespace_separator" : "/", "setup" : [ { @@ -3170,12 +3170,13 @@ meta = [ "engine" : "docker|native", "output" : "target/nextflow/falco", "viash_version" : "0.9.0", - "git_commit" : "7e530218844c373048bc33de58f021b6460642e5", - "git_remote" : "https://x-access-token:ghs_kiUBq39QrAlnG6IaeAcTcXhllzqpOV4LDB3e@github.com/viash-hub/biobox" + "git_commit" : "d86bd5cf62104af02caa852aacd352b1aa97ed60", + "git_remote" : "https://x-access-token:ghs_EwAUAMYJ0K4VBHlAEMs4ZP2OyQYqJM0PSfEO@github.com/viash-hub/biobox", + "git_tag" : "v0.2.0-29-gd86bd5c" }, "package_config" : { "name" : "biobox", - "version" : "v0.2.0", + "version" : "v0.3.0", "description" : "A collection of bioinformatics tools for working with sequence data.\n", "viash_version" : "0.9.0", "source" : "src", @@ -3184,7 +3185,7 @@ meta = [ ".requirements.commands := ['ps']\n", ".engines += { type: \\"native\\" }", ".engines[.type == 'docker'].target_registry := 'images.viash-hub.com'", - ".engines[.type == 'docker'].target_tag := 'v0.2.0'" + ".engines[.type == 'docker'].target_tag := 'v0.3.0'" ], "keywords" : [ "bioinformatics", @@ -3219,7 +3220,7 @@ $( if [ ! -z ${VIASH_PAR_ADAPTERS+x} ]; then echo "${VIASH_PAR_ADAPTERS}" | sed $( if [ ! -z ${VIASH_PAR_LIMITS+x} ]; then echo "${VIASH_PAR_LIMITS}" | sed "s#'#'\\"'\\"'#g;s#.*#par_limits='&'#" ; else echo "# par_limits="; fi ) $( if [ ! -z ${VIASH_PAR_SUBSAMPLE+x} ]; then echo "${VIASH_PAR_SUBSAMPLE}" | sed "s#'#'\\"'\\"'#g;s#.*#par_subsample='&'#" ; else echo "# par_subsample="; fi ) $( if [ ! -z ${VIASH_PAR_BISULFITE+x} ]; then echo "${VIASH_PAR_BISULFITE}" | sed "s#'#'\\"'\\"'#g;s#.*#par_bisulfite='&'#" ; else echo "# par_bisulfite="; fi ) -$( if [ ! -z ${VIASH_PAR_REVERSE_COMPLLIMENT+x} ]; then echo "${VIASH_PAR_REVERSE_COMPLLIMENT}" | sed "s#'#'\\"'\\"'#g;s#.*#par_reverse_complliment='&'#" ; else echo "# par_reverse_complliment="; fi ) +$( if [ ! -z ${VIASH_PAR_REVERSE_COMPLEMENT+x} ]; then echo "${VIASH_PAR_REVERSE_COMPLEMENT}" | sed "s#'#'\\"'\\"'#g;s#.*#par_reverse_complement='&'#" ; else echo "# par_reverse_complement="; fi ) $( if [ ! -z ${VIASH_PAR_OUTDIR+x} ]; then echo "${VIASH_PAR_OUTDIR}" | sed "s#'#'\\"'\\"'#g;s#.*#par_outdir='&'#" ; else echo "# par_outdir="; fi ) $( if [ ! -z ${VIASH_PAR_FORMAT+x} ]; then echo "${VIASH_PAR_FORMAT}" | sed "s#'#'\\"'\\"'#g;s#.*#par_format='&'#" ; else echo "# par_format="; fi ) $( if [ ! -z ${VIASH_PAR_DATA_FILENAME+x} ]; then echo "${VIASH_PAR_DATA_FILENAME}" | sed "s#'#'\\"'\\"'#g;s#.*#par_data_filename='&'#" ; else echo "# par_data_filename="; fi ) @@ -3251,7 +3252,7 @@ set -eo pipefail [[ "\\$par_nogroup" == "false" ]] && unset par_nogroup [[ "\\$par_bisulfite" == "false" ]] && unset par_bisulfite -[[ "\\$par_reverse_compliment" == "false" ]] && unset par_reverse_compliment +[[ "\\$par_reverse_complement" == "false" ]] && unset par_reverse_complement IFS=";" read -ra input <<< \\$par_input @@ -3262,7 +3263,7 @@ IFS=";" read -ra input <<< \\$par_input \\${par_limits:+--limits "\\$par_limits"} \\\\ \\${par_subsample:+-subsample \\$par_subsample} \\\\ \\${par_bisulfite:+-bisulfite} \\\\ - \\${par_reverse_compliment:+-reverse-compliment} \\\\ + \\${par_reverse_complement:+-reverse-complement} \\\\ \\${par_outdir:+--outdir "\\$par_outdir"} \\\\ \\${par_format:+--format "\\$par_format"} \\\\ \\${par_data_filename:+-data-filename "\\$par_data_filename"} \\\\ @@ -3630,7 +3631,7 @@ meta["defaults"] = [ "container" : { "registry" : "images.viash-hub.com", "image" : "vsh/biobox/falco", - "tag" : "v0.2.0" + "tag" : "v0.3.0" }, "tag" : "$id" }'''), diff --git a/target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/falco/nextflow.config b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/falco/nextflow.config similarity index 99% rename from target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/falco/nextflow.config rename to target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/falco/nextflow.config index af116d2..1525bb8 100644 --- a/target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/falco/nextflow.config +++ b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/falco/nextflow.config @@ -2,7 +2,7 @@ manifest { name = 'falco' mainScript = 'main.nf' nextflowVersion = '!>=20.12.1-edge' - version = 'v0.2.0' + version = 'v0.3.0' description = 'A C++ drop-in replacement of FastQC to assess the quality of sequence read data' author = 'Toni Verbeiren' } diff --git a/target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/falco/nextflow_schema.json b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/falco/nextflow_schema.json similarity index 96% rename from target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/falco/nextflow_schema.json rename to target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/falco/nextflow_schema.json index 22f431e..8d40e41 100644 --- a/target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/falco/nextflow_schema.json +++ b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/falco/nextflow_schema.json @@ -40,7 +40,7 @@ "description": "Type: `boolean_true`, default: `false`. Disable grouping of bases for reads \u003e50bp", "help_text": "Type: `boolean_true`, default: `false`. Disable grouping of bases for reads \u003e50bp. \nAll reports will show data for every base in \nthe read. WARNING: When using this option, \nyour plots may end up a ridiculous size. You \nhave been warned!\n" , - "default": "False" + "default":false } @@ -91,18 +91,18 @@ "description": "Type: `boolean_true`, default: `false`. [Falco only] reads are whole genome \nbisulfite sequencing, and more Ts and fewer \nCs are therefore expected and will be \naccounted for in base content", "help_text": "Type: `boolean_true`, default: `false`. [Falco only] reads are whole genome \nbisulfite sequencing, and more Ts and fewer \nCs are therefore expected and will be \naccounted for in base content.\n" , - "default": "False" + "default":false } , - "reverse_complliment": { + "reverse_complement": { "type": "boolean", "description": "Type: `boolean_true`, default: `false`. [Falco only] The input is a \nreverse-complement", "help_text": "Type: `boolean_true`, default: `false`. [Falco only] The input is a \nreverse-complement. All modules will be \ntested by swapping A/T and C/G\n" , - "default": "False" + "default":false } @@ -123,7 +123,7 @@ "description": "Type: `file`, required, default: `$id.$key.outdir.outdir`, example: `output`. Create all output files in the specified \noutput directory", "help_text": "Type: `file`, required, default: `$id.$key.outdir.outdir`, example: `output`. Create all output files in the specified \noutput directory. FALCO-SPECIFIC: If the \ndirectory does not exists, the program will \ncreate it.\n" , - "default": "$id.$key.outdir.outdir" + "default":"$id.$key.outdir.outdir" } @@ -146,7 +146,7 @@ "description": "Type: `file`, default: `$id.$key.data_filename.data_filename`. [Falco only] Specify filename for FastQC \ndata output (TXT)", "help_text": "Type: `file`, default: `$id.$key.data_filename.data_filename`. [Falco only] Specify filename for FastQC \ndata output (TXT). If not specified, it will \nbe called fastq_data.txt in either the input \nfile\u0027s directory or the one specified in the \n--output flag. Only available when running \nfalco with a single input.\n" , - "default": "$id.$key.data_filename.data_filename" + "default":"$id.$key.data_filename.data_filename" } @@ -157,7 +157,7 @@ "description": "Type: `file`, default: `$id.$key.report_filename.report_filename`. [Falco only] Specify filename for FastQC \nreport output (HTML)", "help_text": "Type: `file`, default: `$id.$key.report_filename.report_filename`. [Falco only] Specify filename for FastQC \nreport output (HTML). If not specified, it \nwill be called fastq_report.html in either \nthe input file\u0027s directory or the one \nspecified in the --output flag. Only \navailable when running falco with a single \ninput.\n" , - "default": "$id.$key.report_filename.report_filename" + "default":"$id.$key.report_filename.report_filename" } @@ -168,7 +168,7 @@ "description": "Type: `file`, default: `$id.$key.summary_filename.summary_filename`. [Falco only] Specify filename for the short \nsummary output (TXT)", "help_text": "Type: `file`, default: `$id.$key.summary_filename.summary_filename`. [Falco only] Specify filename for the short \nsummary output (TXT). If not specified, it \nwill be called fastq_report.html in either \nthe input file\u0027s directory or the one \nspecified in the --output flag. Only \navailable when running falco with a single \ninput.\n" , - "default": "$id.$key.summary_filename.summary_filename" + "default":"$id.$key.summary_filename.summary_filename" } diff --git a/target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/multiqc/.config.vsh.yaml b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/multiqc/.config.vsh.yaml similarity index 97% rename from target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/multiqc/.config.vsh.yaml rename to target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/multiqc/.config.vsh.yaml index 4223169..1594fed 100644 --- a/target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/multiqc/.config.vsh.yaml +++ b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/multiqc/.config.vsh.yaml @@ -1,5 +1,5 @@ name: "multiqc" -version: "v0.2.0" +version: "v0.3.0" authors: - name: "Dorien Roosen" roles: @@ -433,7 +433,7 @@ engines: id: "docker" image: "quay.io/biocontainers/multiqc:1.21--pyhdfd78af_0" target_registry: "images.viash-hub.com" - target_tag: "v0.2.0" + target_tag: "v0.3.0" namespace_separator: "/" setup: - type: "docker" @@ -456,11 +456,12 @@ build_info: output: "target/nextflow/multiqc" executable: "target/nextflow/multiqc/main.nf" viash_version: "0.9.0" - git_commit: "7e530218844c373048bc33de58f021b6460642e5" - git_remote: "https://x-access-token:ghs_kiUBq39QrAlnG6IaeAcTcXhllzqpOV4LDB3e@github.com/viash-hub/biobox" + git_commit: "d86bd5cf62104af02caa852aacd352b1aa97ed60" + git_remote: "https://x-access-token:ghs_EwAUAMYJ0K4VBHlAEMs4ZP2OyQYqJM0PSfEO@github.com/viash-hub/biobox" + git_tag: "v0.2.0-29-gd86bd5c" package_config: name: "biobox" - version: "v0.2.0" + version: "v0.3.0" description: "A collection of bioinformatics tools for working with sequence data.\n" info: null viash_version: "0.9.0" @@ -470,7 +471,7 @@ package_config: - ".requirements.commands := ['ps']\n" - ".engines += { type: \"native\" }" - ".engines[.type == 'docker'].target_registry := 'images.viash-hub.com'" - - ".engines[.type == 'docker'].target_tag := 'v0.2.0'" + - ".engines[.type == 'docker'].target_tag := 'v0.3.0'" keywords: - "bioinformatics" - "modules" diff --git a/target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/multiqc/main.nf b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/multiqc/main.nf similarity index 99% rename from target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/multiqc/main.nf rename to target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/multiqc/main.nf index be592a2..e77abbd 100644 --- a/target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/multiqc/main.nf +++ b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/multiqc/main.nf @@ -1,4 +1,4 @@ -// multiqc v0.2.0 +// multiqc v0.3.0 // // This wrapper script is auto-generated by viash 0.9.0 and is thus a derivative // work thereof. This software comes with ABSOLUTELY NO WARRANTY from Data @@ -2808,7 +2808,7 @@ meta = [ "resources_dir": moduleDir.toRealPath().normalize(), "config": processConfig(readJsonBlob('''{ "name" : "multiqc", - "version" : "v0.2.0", + "version" : "v0.3.0", "authors" : [ { "name" : "Dorien Roosen", @@ -3335,7 +3335,7 @@ meta = [ "id" : "docker", "image" : "quay.io/biocontainers/multiqc:1.21--pyhdfd78af_0", "target_registry" : "images.viash-hub.com", - "target_tag" : "v0.2.0", + "target_tag" : "v0.3.0", "namespace_separator" : "/", "setup" : [ { @@ -3366,12 +3366,13 @@ meta = [ "engine" : "docker|native", "output" : "target/nextflow/multiqc", "viash_version" : "0.9.0", - "git_commit" : "7e530218844c373048bc33de58f021b6460642e5", - "git_remote" : "https://x-access-token:ghs_kiUBq39QrAlnG6IaeAcTcXhllzqpOV4LDB3e@github.com/viash-hub/biobox" + "git_commit" : "d86bd5cf62104af02caa852aacd352b1aa97ed60", + "git_remote" : "https://x-access-token:ghs_EwAUAMYJ0K4VBHlAEMs4ZP2OyQYqJM0PSfEO@github.com/viash-hub/biobox", + "git_tag" : "v0.2.0-29-gd86bd5c" }, "package_config" : { "name" : "biobox", - "version" : "v0.2.0", + "version" : "v0.3.0", "description" : "A collection of bioinformatics tools for working with sequence data.\n", "viash_version" : "0.9.0", "source" : "src", @@ -3380,7 +3381,7 @@ meta = [ ".requirements.commands := ['ps']\n", ".engines += { type: \\"native\\" }", ".engines[.type == 'docker'].target_registry := 'images.viash-hub.com'", - ".engines[.type == 'docker'].target_tag := 'v0.2.0'" + ".engines[.type == 'docker'].target_tag := 'v0.3.0'" ], "keywords" : [ "bioinformatics", @@ -3961,7 +3962,7 @@ meta["defaults"] = [ "container" : { "registry" : "images.viash-hub.com", "image" : "vsh/biobox/multiqc", - "tag" : "v0.2.0" + "tag" : "v0.3.0" }, "tag" : "$id" }'''), diff --git a/target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/multiqc/nextflow.config b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/multiqc/nextflow.config similarity index 99% rename from target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/multiqc/nextflow.config rename to target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/multiqc/nextflow.config index 2400f6a..194bf5a 100644 --- a/target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/multiqc/nextflow.config +++ b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/multiqc/nextflow.config @@ -2,7 +2,7 @@ manifest { name = 'multiqc' mainScript = 'main.nf' nextflowVersion = '!>=20.12.1-edge' - version = 'v0.2.0' + version = 'v0.3.0' description = 'MultiQC aggregates results from bioinformatics analyses across many samples into a single report.\nIt searches a given directory for analysis logs and compiles a HTML report. It\'s a general use tool, perfect for summarising the output from numerous bioinformatics tools.\n' author = 'Dorien Roosen' } diff --git a/target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/multiqc/nextflow_schema.json b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/multiqc/nextflow_schema.json similarity index 95% rename from target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/multiqc/nextflow_schema.json rename to target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/multiqc/nextflow_schema.json index 5f3f25e..6a3bd5c 100644 --- a/target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/multiqc/nextflow_schema.json +++ b/target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/multiqc/nextflow_schema.json @@ -40,7 +40,7 @@ "description": "Type: `file`, default: `$id.$key.output_report.html`, example: `multiqc_report.html`. Filepath of the generated report", "help_text": "Type: `file`, default: `$id.$key.output_report.html`, example: `multiqc_report.html`. Filepath of the generated report.\n" , - "default": "$id.$key.output_report.html" + "default":"$id.$key.output_report.html" } @@ -51,7 +51,7 @@ "description": "Type: `file`, default: `$id.$key.output_data.output_data`, example: `multiqc_data`. Output directory for parsed data files", "help_text": "Type: `file`, default: `$id.$key.output_data.output_data`, example: `multiqc_data`. Output directory for parsed data files. If not provided, parsed data will not be published.\n" , - "default": "$id.$key.output_data.output_data" + "default":"$id.$key.output_data.output_data" } @@ -62,7 +62,7 @@ "description": "Type: `file`, default: `$id.$key.output_plots.output_plots`, example: `multiqc_plots`. Output directory for generated plots", "help_text": "Type: `file`, default: `$id.$key.output_plots.output_plots`, example: `multiqc_plots`. Output directory for generated plots. If not provided, plots will not be published.\n" , - "default": "$id.$key.output_plots.output_plots" + "default":"$id.$key.output_plots.output_plots" } @@ -123,7 +123,7 @@ "description": "Type: `boolean_true`, default: `false`. Ignore symlinked directories and files", "help_text": "Type: `boolean_true`, default: `false`. Ignore symlinked directories and files" , - "default": "False" + "default":false } @@ -144,7 +144,7 @@ "description": "Type: `boolean_true`, default: `false`. Prepend directory to sample names to avoid clashing filenames", "help_text": "Type: `boolean_true`, default: `false`. Prepend directory to sample names to avoid clashing filenames" , - "default": "False" + "default":false } @@ -165,7 +165,7 @@ "description": "Type: `boolean_true`, default: `false`. Do not clean the sample names (leave as full file name)", "help_text": "Type: `boolean_true`, default: `false`. Do not clean the sample names (leave as full file name)" , - "default": "False" + "default":false } @@ -176,7 +176,7 @@ "description": "Type: `boolean_true`, default: `false`. Use the log filename as the sample name", "help_text": "Type: `boolean_true`, default: `false`. Use the log filename as the sample name" , - "default": "False" + "default":false } @@ -269,7 +269,7 @@ "description": "Type: `boolean_true`, default: `false`. Add analysis of how long MultiQC takes to run to the report\n", "help_text": "Type: `boolean_true`, default: `false`. Add analysis of how long MultiQC takes to run to the report\n" , - "default": "False" + "default":false } @@ -290,7 +290,7 @@ "description": "Type: `boolean_true`, default: `false`. Increase output verbosity", "help_text": "Type: `boolean_true`, default: `false`. Increase output verbosity.\n" , - "default": "False" + "default":false } @@ -301,7 +301,7 @@ "description": "Type: `boolean_true`, default: `false`. Only show log warnings\n", "help_text": "Type: `boolean_true`, default: `false`. Only show log warnings\n" , - "default": "False" + "default":false } @@ -312,7 +312,7 @@ "description": "Type: `boolean_true`, default: `false`. Don\u0027t catch exceptions, run additional code checks to help development", "help_text": "Type: `boolean_true`, default: `false`. Don\u0027t catch exceptions, run additional code checks to help development.\n" , - "default": "False" + "default":false } @@ -323,7 +323,7 @@ "description": "Type: `boolean_true`, default: `false`. Development mode", "help_text": "Type: `boolean_true`, default: `false`. Development mode. Do not compress and minimise JS, export uncompressed plot data.\n" , - "default": "False" + "default":false } @@ -334,7 +334,7 @@ "description": "Type: `boolean_true`, default: `false`. Require all explicitly requested modules to have log files", "help_text": "Type: `boolean_true`, default: `false`. Require all explicitly requested modules to have log files. If not, MultiQC will exit with an error.\n" , - "default": "False" + "default":false } @@ -345,7 +345,7 @@ "description": "Type: `boolean_true`, default: `false`. Don\u0027t upload generated report to MegaQC, even if MegaQC options are found", "help_text": "Type: `boolean_true`, default: `false`. Don\u0027t upload generated report to MegaQC, even if MegaQC options are found.\n" , - "default": "False" + "default":false } @@ -356,7 +356,7 @@ "description": "Type: `boolean_true`, default: `false`. Disable coloured log output", "help_text": "Type: `boolean_true`, default: `false`. Disable coloured log output.\n" , - "default": "False" + "default":false } @@ -387,7 +387,7 @@ "description": "Type: `boolean_true`, default: `false`. Use only flat plots (static images)", "help_text": "Type: `boolean_true`, default: `false`. Use only flat plots (static images).\n" , - "default": "False" + "default":false } @@ -398,7 +398,7 @@ "description": "Type: `boolean_true`, default: `false`. Use only interactive plots (in-browser Javascript)", "help_text": "Type: `boolean_true`, default: `false`. Use only interactive plots (in-browser Javascript).\n" , - "default": "False" + "default":false } @@ -409,7 +409,7 @@ "description": "Type: `boolean_true`, default: `false`. Force the parsed data directory to be created", "help_text": "Type: `boolean_true`, default: `false`. Force the parsed data directory to be created.\n" , - "default": "False" + "default":false } @@ -420,7 +420,7 @@ "description": "Type: `boolean_true`, default: `false`. Prevent the parsed data directory from being created", "help_text": "Type: `boolean_true`, default: `false`. Prevent the parsed data directory from being created.\n" , - "default": "False" + "default":false } @@ -431,7 +431,7 @@ "description": "Type: `boolean_true`, default: `false`. Compress the data directory", "help_text": "Type: `boolean_true`, default: `false`. Compress the data directory.\n" , - "default": "False" + "default":false } @@ -454,7 +454,7 @@ "description": "Type: `boolean_true`, default: `false`. Creates PDF report with the \u0027simple\u0027 template", "help_text": "Type: `boolean_true`, default: `false`. Creates PDF report with the \u0027simple\u0027 template. Requires Pandoc to be installed.\n" , - "default": "False" + "default":false } diff --git a/target/executable/io/interop_summary_to_csv/.config.vsh.yaml b/target/executable/io/interop_summary_to_csv/.config.vsh.yaml index 1b05983..3e03bab 100644 --- a/target/executable/io/interop_summary_to_csv/.config.vsh.yaml +++ b/target/executable/io/interop_summary_to_csv/.config.vsh.yaml @@ -141,9 +141,9 @@ build_info: output: "target/executable/io/interop_summary_to_csv" executable: "target/executable/io/interop_summary_to_csv/interop_summary_to_csv" viash_version: "0.9.0" - git_commit: "5cb13230bf682321226addce896a3015e8864913" - git_remote: "https://x-access-token:ghs_x4A4kChpmjRCoWA3E68PwNsGJxIsF40DBeTf@github.com/viash-hub/demultiplex" - git_tag: "v0.1.1-3-g5cb1323" + git_commit: "6e6be28b85ab619214ae05a017a33498c0dc8890" + git_remote: "https://x-access-token:ghs_iopCikoFK5KlWGbHHLIwAf82AMtbiI0fzew1@github.com/viash-hub/demultiplex" + git_tag: "v0.1.1-5-g6e6be28" package_config: name: "demultiplex" version: "main" diff --git a/target/executable/io/interop_summary_to_csv/interop_summary_to_csv b/target/executable/io/interop_summary_to_csv/interop_summary_to_csv index 0abf6f6..862e45c 100755 --- a/target/executable/io/interop_summary_to_csv/interop_summary_to_csv +++ b/target/executable/io/interop_summary_to_csv/interop_summary_to_csv @@ -470,9 +470,9 @@ tar -C /tmp/ --no-same-owner --no-same-permissions -xvf /tmp/interop.tar.gz && \ mv /tmp/interop-1.3.1-Linux-GNU/bin/index-summary /tmp/interop-1.3.1-Linux-GNU/bin/summary /usr/local/bin/ LABEL org.opencontainers.image.description="Companion container for running component io interop_summary_to_csv" -LABEL org.opencontainers.image.created="2024-11-06T17:42:24Z" +LABEL org.opencontainers.image.created="2024-12-05T10:21:34Z" LABEL org.opencontainers.image.source="https://github.com/viash-hub/demultiplex" -LABEL org.opencontainers.image.revision="5cb13230bf682321226addce896a3015e8864913" +LABEL org.opencontainers.image.revision="6e6be28b85ab619214ae05a017a33498c0dc8890" LABEL org.opencontainers.image.version="main" VIASHDOCKER diff --git a/target/executable/io/untar/.config.vsh.yaml b/target/executable/io/untar/.config.vsh.yaml index 8281ebb..5a7f887 100644 --- a/target/executable/io/untar/.config.vsh.yaml +++ b/target/executable/io/untar/.config.vsh.yaml @@ -148,9 +148,9 @@ build_info: output: "target/executable/io/untar" executable: "target/executable/io/untar/untar" viash_version: "0.9.0" - git_commit: "5cb13230bf682321226addce896a3015e8864913" - git_remote: "https://x-access-token:ghs_x4A4kChpmjRCoWA3E68PwNsGJxIsF40DBeTf@github.com/viash-hub/demultiplex" - git_tag: "v0.1.1-3-g5cb1323" + git_commit: "6e6be28b85ab619214ae05a017a33498c0dc8890" + git_remote: "https://x-access-token:ghs_iopCikoFK5KlWGbHHLIwAf82AMtbiI0fzew1@github.com/viash-hub/demultiplex" + git_tag: "v0.1.1-5-g6e6be28" package_config: name: "demultiplex" version: "main" diff --git a/target/executable/io/untar/untar b/target/executable/io/untar/untar index 50cac17..cb66d27 100755 --- a/target/executable/io/untar/untar +++ b/target/executable/io/untar/untar @@ -476,9 +476,9 @@ RUN apt-get update && \ rm -rf /var/lib/apt/lists/* LABEL org.opencontainers.image.description="Companion container for running component io untar" -LABEL org.opencontainers.image.created="2024-11-06T17:42:24Z" +LABEL org.opencontainers.image.created="2024-12-05T10:21:34Z" LABEL org.opencontainers.image.source="https://github.com/viash-hub/demultiplex" -LABEL org.opencontainers.image.revision="5cb13230bf682321226addce896a3015e8864913" +LABEL org.opencontainers.image.revision="6e6be28b85ab619214ae05a017a33498c0dc8890" LABEL org.opencontainers.image.version="main" VIASHDOCKER diff --git a/target/nextflow/dataflow/combine_samples/.config.vsh.yaml b/target/nextflow/dataflow/combine_samples/.config.vsh.yaml index 24aeeda..66881e0 100644 --- a/target/nextflow/dataflow/combine_samples/.config.vsh.yaml +++ b/target/nextflow/dataflow/combine_samples/.config.vsh.yaml @@ -19,7 +19,7 @@ argument_groups: create_parent: true required: true direction: "input" - multiple: false + multiple: true multiple_sep: ";" - type: "file" name: "--reverse_input" @@ -28,7 +28,7 @@ argument_groups: create_parent: true required: false direction: "input" - multiple: false + multiple: true multiple_sep: ";" - name: "Output arguments" arguments: @@ -139,9 +139,9 @@ build_info: output: "target/nextflow/dataflow/combine_samples" executable: "target/nextflow/dataflow/combine_samples/main.nf" viash_version: "0.9.0" - git_commit: "5cb13230bf682321226addce896a3015e8864913" - git_remote: "https://x-access-token:ghs_x4A4kChpmjRCoWA3E68PwNsGJxIsF40DBeTf@github.com/viash-hub/demultiplex" - git_tag: "v0.1.1-3-g5cb1323" + git_commit: "6e6be28b85ab619214ae05a017a33498c0dc8890" + git_remote: "https://x-access-token:ghs_iopCikoFK5KlWGbHHLIwAf82AMtbiI0fzew1@github.com/viash-hub/demultiplex" + git_tag: "v0.1.1-5-g6e6be28" package_config: name: "demultiplex" version: "main" diff --git a/target/nextflow/dataflow/combine_samples/main.nf b/target/nextflow/dataflow/combine_samples/main.nf index 62438a4..28e0d78 100644 --- a/target/nextflow/dataflow/combine_samples/main.nf +++ b/target/nextflow/dataflow/combine_samples/main.nf @@ -2827,7 +2827,7 @@ meta = [ "create_parent" : true, "required" : true, "direction" : "input", - "multiple" : false, + "multiple" : true, "multiple_sep" : ";" }, { @@ -2837,7 +2837,7 @@ meta = [ "create_parent" : true, "required" : false, "direction" : "input", - "multiple" : false, + "multiple" : true, "multiple_sep" : ";" } ] @@ -2972,9 +2972,9 @@ meta = [ "engine" : "native|native", "output" : "target/nextflow/dataflow/combine_samples", "viash_version" : "0.9.0", - "git_commit" : "5cb13230bf682321226addce896a3015e8864913", - "git_remote" : "https://x-access-token:ghs_x4A4kChpmjRCoWA3E68PwNsGJxIsF40DBeTf@github.com/viash-hub/demultiplex", - "git_tag" : "v0.1.1-3-g5cb1323" + "git_commit" : "6e6be28b85ab619214ae05a017a33498c0dc8890", + "git_remote" : "https://x-access-token:ghs_iopCikoFK5KlWGbHHLIwAf82AMtbiI0fzew1@github.com/viash-hub/demultiplex", + "git_tag" : "v0.1.1-5-g6e6be28" }, "package_config" : { "name" : "demultiplex", @@ -3031,8 +3031,8 @@ workflow run_wf { | groupTuple(by: 0, sort: "hash") | map {run_id, states -> // Gather the following state for all samples - def forward_fastqs = states.collect{it.forward_input} - def reverse_fastqs = states.collect{it.reverse_input}.findAll{it != null} + def forward_fastqs = states.collect{it.forward_input}.flatten() + def reverse_fastqs = states.collect{it.reverse_input}.findAll{it != null}.flatten() def resultState = [ "output_forward": forward_fastqs, diff --git a/target/nextflow/dataflow/combine_samples/nextflow_schema.json b/target/nextflow/dataflow/combine_samples/nextflow_schema.json index 245efb4..3f28f0d 100644 --- a/target/nextflow/dataflow/combine_samples/nextflow_schema.json +++ b/target/nextflow/dataflow/combine_samples/nextflow_schema.json @@ -27,8 +27,8 @@ "forward_input": { "type": "string", - "description": "Type: `file`, required. ", - "help_text": "Type: `file`, required. " + "description": "Type: List of `file`, required, multiple_sep: `\";\"`. ", + "help_text": "Type: List of `file`, required, multiple_sep: `\";\"`. " } @@ -37,8 +37,8 @@ "reverse_input": { "type": "string", - "description": "Type: `file`. ", - "help_text": "Type: `file`. " + "description": "Type: List of `file`, multiple_sep: `\";\"`. ", + "help_text": "Type: List of `file`, multiple_sep: `\";\"`. " } @@ -60,7 +60,7 @@ "description": "Type: List of `file`, required, default: `$id.$key.output_forward_*.output_forward_*`, multiple_sep: `\";\"`. ", "help_text": "Type: List of `file`, required, default: `$id.$key.output_forward_*.output_forward_*`, multiple_sep: `\";\"`. " , - "default": "$id.$key.output_forward_*.output_forward_*" + "default":"$id.$key.output_forward_*.output_forward_*" } @@ -71,7 +71,7 @@ "description": "Type: List of `file`, default: `$id.$key.output_reverse_*.output_reverse_*`, multiple_sep: `\";\"`. ", "help_text": "Type: List of `file`, default: `$id.$key.output_reverse_*.output_reverse_*`, multiple_sep: `\";\"`. " , - "default": "$id.$key.output_reverse_*.output_reverse_*" + "default":"$id.$key.output_reverse_*.output_reverse_*" } diff --git a/target/nextflow/dataflow/gather_fastqs_and_validate/.config.vsh.yaml b/target/nextflow/dataflow/gather_fastqs_and_validate/.config.vsh.yaml index 7a633ef..e45e3c2 100644 --- a/target/nextflow/dataflow/gather_fastqs_and_validate/.config.vsh.yaml +++ b/target/nextflow/dataflow/gather_fastqs_and_validate/.config.vsh.yaml @@ -33,7 +33,7 @@ argument_groups: create_parent: true required: true direction: "output" - multiple: false + multiple: true multiple_sep: ";" - type: "file" name: "--fastq_reverse" @@ -42,7 +42,7 @@ argument_groups: create_parent: true required: false direction: "output" - multiple: false + multiple: true multiple_sep: ";" resources: - type: "nextflow_script" @@ -133,9 +133,9 @@ build_info: output: "target/nextflow/dataflow/gather_fastqs_and_validate" executable: "target/nextflow/dataflow/gather_fastqs_and_validate/main.nf" viash_version: "0.9.0" - git_commit: "5cb13230bf682321226addce896a3015e8864913" - git_remote: "https://x-access-token:ghs_x4A4kChpmjRCoWA3E68PwNsGJxIsF40DBeTf@github.com/viash-hub/demultiplex" - git_tag: "v0.1.1-3-g5cb1323" + git_commit: "6e6be28b85ab619214ae05a017a33498c0dc8890" + git_remote: "https://x-access-token:ghs_iopCikoFK5KlWGbHHLIwAf82AMtbiI0fzew1@github.com/viash-hub/demultiplex" + git_tag: "v0.1.1-5-g6e6be28" package_config: name: "demultiplex" version: "main" diff --git a/target/nextflow/dataflow/gather_fastqs_and_validate/main.nf b/target/nextflow/dataflow/gather_fastqs_and_validate/main.nf index d0085f0..69ef4d5 100644 --- a/target/nextflow/dataflow/gather_fastqs_and_validate/main.nf +++ b/target/nextflow/dataflow/gather_fastqs_and_validate/main.nf @@ -2845,7 +2845,7 @@ meta = [ "create_parent" : true, "required" : true, "direction" : "output", - "multiple" : false, + "multiple" : true, "multiple_sep" : ";" }, { @@ -2855,7 +2855,7 @@ meta = [ "create_parent" : true, "required" : false, "direction" : "output", - "multiple" : false, + "multiple" : true, "multiple_sep" : ";" } ] @@ -2965,9 +2965,9 @@ meta = [ "engine" : "native|native", "output" : "target/nextflow/dataflow/gather_fastqs_and_validate", "viash_version" : "0.9.0", - "git_commit" : "5cb13230bf682321226addce896a3015e8864913", - "git_remote" : "https://x-access-token:ghs_x4A4kChpmjRCoWA3E68PwNsGJxIsF40DBeTf@github.com/viash-hub/demultiplex", - "git_tag" : "v0.1.1-3-g5cb1323" + "git_commit" : "6e6be28b85ab619214ae05a017a33498c0dc8890", + "git_remote" : "https://x-access-token:ghs_iopCikoFK5KlWGbHHLIwAf82AMtbiI0fzew1@github.com/viash-hub/demultiplex", + "git_tag" : "v0.1.1-5-g6e6be28" }, "package_config" : { "name" : "demultiplex", @@ -3027,9 +3027,11 @@ workflow run_wf { def original_id = id // Parse sample sheet for sample IDs + println "Processing run information file ${sample_sheet}" csv_lines = sample_sheet.splitCsv(header: false, sep: ',') csv_lines.any { csv_items -> if (csv_items.isEmpty()) { + // skip empty line return } def possible_header = csv_items[0] @@ -3037,22 +3039,40 @@ workflow run_wf { if (header) { if (start_parsing) { // Stop parsing when encountering the next header + println "Encountered next header '[${start_parsing}]', stopping parsing." return true } - if (header == "Data") { + // [Data] for illumina + // [Samples] for Element Biosciences + if (header in ["Data", "Samples"]) { + println "Found header [${header}], start parsing." start_parsing = true + return } } if (start_parsing) { - if ( !sample_id_column_index ) { - sample_id_column_index = csv_items.findIndexValues{it == "Sample_ID"} - assert sample_id_column_index != -1: - "Could not find column 'Sample_ID' in sample sheet!" + if ( sample_id_column_index == null) { + println "Looking for sample name column." + sample_id_column_index = csv_items.findIndexValues{it == "Sample_ID" || it == "SampleName"} + assert (!sample_id_column_index.isEmpty()): + "Could not find column 'Sample_ID' (Illumina) or 'SampleName' " + + "(Element Biosciences) in run information! Found: ${sample_id_column_index}" + assert sample_id_column_index.size() == 1, "Expected run information file to contain " + + "a column 'Sample_ID' or 'SampleName', not both. Found: ${sample_id_column_index}" + sample_id_column_index = sample_id_column_index[0] + println "Found sample names column '${csv_items[sample_id_column_index]}'." return } samples += csv_items[sample_id_column_index] } + // This return is important! (If 'true' is returned, the parsing stops.) + return } + assert start_parsing: + "Sample information file does not contain [Data] or [Samples] header!" + assert samples.size() > 1: + "Sample information file does not seem to contain any information about the samples!" + println "Finished processing run information file, found samples: ${samples}." println "Looking for fastq files in ${state.input}." def allfastqs = state.input.listFiles().findAll{it.isFile() && it.name ==~ /^.+\.fastq.gz$/} println "Found ${allfastqs.size()} fastq files, matching them to the following samples: ${samples}." @@ -3061,17 +3081,15 @@ workflow run_wf { def reverse_regex = ~/^${sample_id}_S(\d+)_(L(\d+)_)?R2_(\d+)\.fastq\.gz$/ def forward_fastq = state.input.listFiles().findAll{it.isFile() && it.name ==~ forward_regex} def reverse_fastq = state.input.listFiles().findAll{it.isFile() && it.name ==~ reverse_regex} - assert forward_fastq : "No forward fastq files were found for sample ${sample_id}" - assert forward_fastq.size() < 2: - "Found multiple forward fastq files corresponding to sample ${sample_id}: ${forward_fastq}" - assert reverse_fastq.size() < 2: - "Found multiple reverse fastq files corresponding to sample ${sample_id}: ${reverse_fastq}." - assert !forward_fastq.isEmpty(): - "Expected a forward fastq file to have been created correspondig to sample ${sample_id}." - // TODO: if one sample had reverse reads, the others must as well. - reverse_fastq = !reverse_fastq.isEmpty() ? reverse_fastq[0] : null + assert forward_fastq && !forward_fastq.isEmpty(): "No forward fastq files were found for sample ${sample_id}. " + + "All fastq files in directory: ${allfastqs.collect{it.name}}" + assert (reverse_fastq.isEmpty() || (forward_fastq.size() == reverse_fastq.size())): + "Expected equal number of forward and reverse fastq files for sample ${sample_id}. " + + "Found forward: ${forward_fastq} and reverse: ${reverse_fastq}." + println "Found ${forward_fastq.size()} forward and ${reverse_fastq.size()} reverse " + + "fastq files for sample ${sample_id}" def fastqs_state = [ - "fastq_forward": forward_fastq[0], + "fastq_forward": forward_fastq, "fastq_reverse": reverse_fastq, "_meta": [ "join_id": original_id ], ] diff --git a/target/nextflow/dataflow/gather_fastqs_and_validate/nextflow_schema.json b/target/nextflow/dataflow/gather_fastqs_and_validate/nextflow_schema.json index 1372e56..311299a 100644 --- a/target/nextflow/dataflow/gather_fastqs_and_validate/nextflow_schema.json +++ b/target/nextflow/dataflow/gather_fastqs_and_validate/nextflow_schema.json @@ -47,10 +47,10 @@ "fastq_forward": { "type": "string", - "description": "Type: `file`, required, default: `$id.$key.fastq_forward.fastq_forward`. ", - "help_text": "Type: `file`, required, default: `$id.$key.fastq_forward.fastq_forward`. " + "description": "Type: List of `file`, required, default: `$id.$key.fastq_forward_*.fastq_forward_*`, multiple_sep: `\";\"`. ", + "help_text": "Type: List of `file`, required, default: `$id.$key.fastq_forward_*.fastq_forward_*`, multiple_sep: `\";\"`. " , - "default": "$id.$key.fastq_forward.fastq_forward" + "default":"$id.$key.fastq_forward_*.fastq_forward_*" } @@ -58,10 +58,10 @@ "fastq_reverse": { "type": "string", - "description": "Type: `file`, default: `$id.$key.fastq_reverse.fastq_reverse`. ", - "help_text": "Type: `file`, default: `$id.$key.fastq_reverse.fastq_reverse`. " + "description": "Type: List of `file`, default: `$id.$key.fastq_reverse_*.fastq_reverse_*`, multiple_sep: `\";\"`. ", + "help_text": "Type: List of `file`, default: `$id.$key.fastq_reverse_*.fastq_reverse_*`, multiple_sep: `\";\"`. " , - "default": "$id.$key.fastq_reverse.fastq_reverse" + "default":"$id.$key.fastq_reverse_*.fastq_reverse_*" } diff --git a/target/nextflow/demultiplex/.config.vsh.yaml b/target/nextflow/demultiplex/.config.vsh.yaml index c01e53e..f30ff47 100644 --- a/target/nextflow/demultiplex/.config.vsh.yaml +++ b/target/nextflow/demultiplex/.config.vsh.yaml @@ -14,9 +14,11 @@ argument_groups: multiple: false multiple_sep: ";" - type: "file" - name: "--sample_sheet" - description: "Sample sheet as input for BCL Convert. If not specified,\nwill try\ - \ to autodetect the sample sheet in the input directory\n" + name: "--run_information" + description: "CSV file containing sample information, which will be used as \n\ + input for the demultiplexer. Canonically called 'SampleSheet.csv' (Illumina)\n\ + or 'RunManifest.csv' (Element Biosciences). If not specified,\nwill try to autodetect\ + \ the sample sheet in the input directory.\nRequires --demultiplexer to be set.\n" info: null must_exist: true create_parent: true @@ -24,6 +26,19 @@ argument_groups: direction: "input" multiple: false multiple_sep: ";" + - type: "string" + name: "--demultiplexer" + description: "Demultiplexer to use, choice depends on the provider\nof the instrument\ + \ that was used to generate the data.\nWhen not using --sample_sheet, specifying\ + \ this argument is not\nrequired.\n" + info: null + required: false + choices: + - "bases2fastq" + - "bclconvert" + direction: "input" + multiple: false + multiple_sep: ";" - name: "Output arguments" arguments: - type: "file" @@ -70,7 +85,11 @@ test_resources: - type: "nextflow_script" path: "test.nf" is_executable: true - entrypoint: "test_wf" + entrypoint: "test_illumina" +- type: "nextflow_script" + path: "test.nf" + is_executable: true + entrypoint: "test_bases2fastq" info: null status: "enabled" requirements: @@ -93,22 +112,27 @@ dependencies: repository: type: "vsh" repo: "biobox" - tag: "v0.2.0" + tag: "v0.3.0" +- name: "bases2fastq" + repository: + type: "vsh" + repo: "biobox" + tag: "v0.3.0" - name: "falco" repository: type: "vsh" repo: "biobox" - tag: "v0.2.0" + tag: "v0.3.0" - name: "multiqc" repository: type: "vsh" repo: "biobox" - tag: "v0.2.0" + tag: "v0.3.0" repositories: - type: "vsh" name: "bb" repo: "biobox" - tag: "v0.2.0" + tag: "v0.3.0" license: "MIT" links: repository: "https://github.com/viash-hub/demultiplex" @@ -186,17 +210,18 @@ build_info: output: "target/nextflow/demultiplex" executable: "target/nextflow/demultiplex/main.nf" viash_version: "0.9.0" - git_commit: "5cb13230bf682321226addce896a3015e8864913" - git_remote: "https://x-access-token:ghs_x4A4kChpmjRCoWA3E68PwNsGJxIsF40DBeTf@github.com/viash-hub/demultiplex" - git_tag: "v0.1.1-3-g5cb1323" + git_commit: "6e6be28b85ab619214ae05a017a33498c0dc8890" + git_remote: "https://x-access-token:ghs_iopCikoFK5KlWGbHHLIwAf82AMtbiI0fzew1@github.com/viash-hub/demultiplex" + git_tag: "v0.1.1-5-g6e6be28" dependencies: - "target/nextflow/io/untar" - "target/nextflow/dataflow/gather_fastqs_and_validate" - "target/nextflow/io/interop_summary_to_csv" - "target/nextflow/dataflow/combine_samples" - - "target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/bcl_convert" - - "target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/falco" - - "target/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/multiqc" + - "target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/bcl_convert" + - "target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/bases2fastq" + - "target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/falco" + - "target/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/multiqc" package_config: name: "demultiplex" version: "main" diff --git a/target/nextflow/demultiplex/main.nf b/target/nextflow/demultiplex/main.nf index 5a8cb2b..c655ed9 100644 --- a/target/nextflow/demultiplex/main.nf +++ b/target/nextflow/demultiplex/main.nf @@ -2823,14 +2823,27 @@ meta = [ }, { "type" : "file", - "name" : "--sample_sheet", - "description" : "Sample sheet as input for BCL Convert. If not specified,\nwill try to autodetect the sample sheet in the input directory\n", + "name" : "--run_information", + "description" : "CSV file containing sample information, which will be used as \ninput for the demultiplexer. Canonically called 'SampleSheet.csv' (Illumina)\nor 'RunManifest.csv' (Element Biosciences). If not specified,\nwill try to autodetect the sample sheet in the input directory.\nRequires --demultiplexer to be set.\n", "must_exist" : true, "create_parent" : true, "required" : false, "direction" : "input", "multiple" : false, "multiple_sep" : ";" + }, + { + "type" : "string", + "name" : "--demultiplexer", + "description" : "Demultiplexer to use, choice depends on the provider\nof the instrument that was used to generate the data.\nWhen not using --sample_sheet, specifying this argument is not\nrequired.\n", + "required" : false, + "choices" : [ + "bases2fastq", + "bclconvert" + ], + "direction" : "input", + "multiple" : false, + "multiple_sep" : ";" } ] }, @@ -2893,7 +2906,13 @@ meta = [ "type" : "nextflow_script", "path" : "test.nf", "is_executable" : true, - "entrypoint" : "test_wf" + "entrypoint" : "test_illumina" + }, + { + "type" : "nextflow_script", + "path" : "test.nf", + "is_executable" : true, + "entrypoint" : "test_bases2fastq" } ], "status" : "enabled", @@ -2932,7 +2951,15 @@ meta = [ "repository" : { "type" : "vsh", "repo" : "biobox", - "tag" : "v0.2.0" + "tag" : "v0.3.0" + } + }, + { + "name" : "bases2fastq", + "repository" : { + "type" : "vsh", + "repo" : "biobox", + "tag" : "v0.3.0" } }, { @@ -2940,7 +2967,7 @@ meta = [ "repository" : { "type" : "vsh", "repo" : "biobox", - "tag" : "v0.2.0" + "tag" : "v0.3.0" } }, { @@ -2948,7 +2975,7 @@ meta = [ "repository" : { "type" : "vsh", "repo" : "biobox", - "tag" : "v0.2.0" + "tag" : "v0.3.0" } } ], @@ -2957,7 +2984,7 @@ meta = [ "type" : "vsh", "name" : "bb", "repo" : "biobox", - "tag" : "v0.2.0" + "tag" : "v0.3.0" } ], "license" : "MIT", @@ -3049,9 +3076,9 @@ meta = [ "engine" : "native|native", "output" : "target/nextflow/demultiplex", "viash_version" : "0.9.0", - "git_commit" : "5cb13230bf682321226addce896a3015e8864913", - "git_remote" : "https://x-access-token:ghs_x4A4kChpmjRCoWA3E68PwNsGJxIsF40DBeTf@github.com/viash-hub/demultiplex", - "git_tag" : "v0.1.1-3-g5cb1323" + "git_commit" : "6e6be28b85ab619214ae05a017a33498c0dc8890", + "git_remote" : "https://x-access-token:ghs_iopCikoFK5KlWGbHHLIwAf82AMtbiI0fzew1@github.com/viash-hub/demultiplex", + "git_tag" : "v0.1.1-5-g6e6be28" }, "package_config" : { "name" : "demultiplex", @@ -3096,9 +3123,10 @@ include { untar } from "${meta.resources_dir}/../../nextflow/io/untar/main.nf" include { gather_fastqs_and_validate } from "${meta.resources_dir}/../../nextflow/dataflow/gather_fastqs_and_validate/main.nf" include { interop_summary_to_csv } from "${meta.resources_dir}/../../nextflow/io/interop_summary_to_csv/main.nf" include { combine_samples } from "${meta.resources_dir}/../../nextflow/dataflow/combine_samples/main.nf" -include { bcl_convert } from "${meta.root_dir}/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/bcl_convert/main.nf" -include { falco } from "${meta.root_dir}/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/falco/main.nf" -include { multiqc } from "${meta.root_dir}/dependencies/vsh/vsh/biobox/v0.2.0/nextflow/multiqc/main.nf" +include { bcl_convert } from "${meta.root_dir}/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/bcl_convert/main.nf" +include { bases2fastq } from "${meta.root_dir}/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/bases2fastq/main.nf" +include { falco } from "${meta.root_dir}/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/falco/main.nf" +include { multiqc } from "${meta.root_dir}/dependencies/vsh/vsh/biobox/v0.3.0/nextflow/multiqc/main.nf" // inner workflow // user-provided Nextflow code @@ -3127,22 +3155,79 @@ workflow run_wf { // Gather input files from folder | map {id, state -> def newState = [:] - if (!state.sample_sheet) { - def sample_sheet = state.input.resolve("SampleSheet.csv") - assert (sample_sheet && sample_sheet.isFile()): "Could not find 'SampleSheet.csv' file in input directory." - newState["sample_sheet"] = sample_sheet + println("Provided run information: ${state.run_information} and demultiplexer: ${state.demultiplexer}") + if (!state.run_information) { + println("Run information was not specified, auto-detecting...") + // The supported_platforms hashmap must be a 1-on-1 mapping + // Also, it's keys must be present in the 'choices' field + // for the 'run_information' argument in the viash config. + def supported_platforms = [ + "bclconvert": "SampleSheet.csv", // Illumina + "bases2fastq": "RunManifest.csv" // Element Biosciences + ] + def found_sample_information = supported_platforms.collectEntries{demultiplexer, filename -> + println("Checking if ${filename} can be found in input folder ${state.input}.") + def resolved_filename = state.input.resolve(filename) + if (!resolved_filename.isFile()) { + resolved_filename = null + } + println("Result after looking for run information for ${demultiplexer}: ${resolved_filename}.") + [demultiplexer, resolved_filename] + } + def demultiplexer = null + def run_information = null + found_sample_information.each{demultiplexer_candidate, file_path -> + if (file_path) { + // At this point, a candicate run information file was found. + assert !run_information: "Autodetection of run information " + + "(SampleSheet, RunManifest) failed: " + + "multiple candidate files found in input folder. " + + "Please specify one using --run_information." + run_information = file_path + demultiplexer = demultiplexer_candidate + } + } + + // When autodetecting, the run information should have been found + assert run_information: "No run information file (SampleSheet, RunManifest) " + + "found in input directory." + + // When autodetecting, the demultiplexer must be set if the run information was found + assert demultiplexer, "State error: the demultiplexer should have been autodetected. " + + "Please report this as a bug." + + // When autodetecting, the found demultiplexer must match + // with the demultiplexer that the user has provided (in case it was provided). + if (state.demultiplexer) { + assert state.demultiplexer == demultiplexer, + "Requested to use demultiplexer ${state.demultiplexer} " + + "but demultiplexer based on the autodetected run information " + "file ${run_information} seems to indicate that the demultiplexer " + "should be ${demultiplexer}. Either avoid specifying the demultiplexer " + "or override the autodetection of the run information by providing " + "the file." + } + println("Using run information ${run_information} and demultiplexer ${demultiplexer}") + // At this point, the autodetected state can override the user provided state. + newState = newState + [ + "run_information": run_information, + "demultiplexer": demultiplexer, + ] } - // Do not add InterOp to state because we generate the summary csv's in the next - // step based on the run dir, not the InterOp dir. - def interop_dir = state.input.resolve("InterOp") - assert interop_dir.isDirectory(): "Expected InterOp directory to be present." + if (newState.demultiplexer in ["bclconvert"]) { + // Do not add InterOp to state because we generate the summary csv's in the next + // step based on the run dir, not the InterOp dir. + def interop_dir = state.input.resolve("InterOp") + assert interop_dir.isDirectory(): "Expected InterOp directory to be present." + } def resultState = state + newState [id, resultState] } | interop_summary_to_csv.run( + runIf: {id, state -> state.demultiplexer in ["bclconvert"]}, directives: [label: ["lowmem", "verylowcpu"]], fromState: [ "input": "input", @@ -3154,16 +3239,40 @@ workflow run_wf { ) // run bcl_convert | bcl_convert.run( + runIf: {id, state -> state.demultiplexer in ["bclconvert"]}, directives: [label: ["highmem", "midcpu"]], fromState: [ "bcl_input_directory": "input", - "sample_sheet": "sample_sheet", + "sample_sheet": "run_information", "output_directory": "output", ], toState: {id, result, state -> def toAdd = [ - "output_bclconvert" : result.output_directory, - "bclconvert_reports": result.reports, + "output_demultiplexer" : result.output_directory, + "run_id": id, + ] + def newState = state + toAdd + return newState + } + ) + // run bases2fastq + | bases2fastq.run( + runIf: {id, state -> state.demultiplexer in ["bases2fastq"]}, + directives: [label: ["highmem", "midcpu"]], + fromState: [ + "analysis_directory": "input", + "run_manifest": "run_information", + "output_directory": "output", + ], + args: [ + "no_projects": true, // Do not put output files in a subfolder for project + //"split_lanes": true, + "legacy_fastq": true, // Illumina style output names + "group_fastq": true, // No subdir per sample + ], + toState: {id, result, state -> + def toAdd = [ + "output_demultiplexer" : result.output_directory, "run_id": id, ] def newState = state + toAdd @@ -3172,8 +3281,8 @@ workflow run_wf { ) | gather_fastqs_and_validate.run( fromState: [ - "input": "output_bclconvert", - "sample_sheet": "sample_sheet", + "input": "output_demultiplexer", + "sample_sheet": "run_information", ], toState: [ "fastq_forward": "fastq_forward", @@ -3214,15 +3323,18 @@ workflow run_wf { | multiqc.run( directives: [label: ["lowcpu", "lowmem"]], fromState: {id, state -> - [ - "input": [ - state.output_falco, + def new_state = [ + "input": [state.output_falco], + "output_report": state.output_multiqc, + "cl_config": 'sp: {fastqc/data: {fn: "*_fastqc_data.txt"}}' + ] + if (state.demultiplexer == "bclconvert") { + new_state["input"] += [ state.interop_run_summary.getParent(), state.interop_index_summary.getParent() - ], - "output_report": state.output_multiqc, - "cl_config": 'sp: {fastqc/data: {fn: "*_fastqc_data.txt"}}', - ] + ] + } + return new_state }, toState: { id, result, state -> state + [ "output_multiqc" : result.output_report ] @@ -3230,7 +3342,7 @@ workflow run_wf { ) | setState( [ - "output": "output_bclconvert", + "output": "output_demultiplexer", "output_falco": "output_falco", "output_multiqc": "output_multiqc" ] diff --git a/target/nextflow/demultiplex/nextflow_schema.json b/target/nextflow/demultiplex/nextflow_schema.json index 0216554..1ec0eff 100644 --- a/target/nextflow/demultiplex/nextflow_schema.json +++ b/target/nextflow/demultiplex/nextflow_schema.json @@ -24,11 +24,23 @@ , - "sample_sheet": { + "run_information": { "type": "string", - "description": "Type: `file`. Sample sheet as input for BCL Convert", - "help_text": "Type: `file`. Sample sheet as input for BCL Convert. If not specified,\nwill try to autodetect the sample sheet in the input directory\n" + "description": "Type: `file`. CSV file containing sample information, which will be used as \ninput for the demultiplexer", + "help_text": "Type: `file`. CSV file containing sample information, which will be used as \ninput for the demultiplexer. Canonically called \u0027SampleSheet.csv\u0027 (Illumina)\nor \u0027RunManifest.csv\u0027 (Element Biosciences). If not specified,\nwill try to autodetect the sample sheet in the input directory.\nRequires --demultiplexer to be set.\n" + + } + + + , + "demultiplexer": { + "type": + "string", + "description": "Type: `string`, choices: ``bases2fastq`, `bclconvert``. Demultiplexer to use, choice depends on the provider\nof the instrument that was used to generate the data", + "help_text": "Type: `string`, choices: ``bases2fastq`, `bclconvert``. Demultiplexer to use, choice depends on the provider\nof the instrument that was used to generate the data.\nWhen not using --sample_sheet, specifying this argument is not\nrequired.\n", + "enum": ["bases2fastq", "bclconvert"] + } @@ -50,7 +62,7 @@ "description": "Type: `file`, required, default: `$id.$key.output.output`. Directory to write fastq data to", "help_text": "Type: `file`, required, default: `$id.$key.output.output`. Directory to write fastq data to" , - "default": "$id.$key.output.output" + "default":"$id.$key.output.output" } @@ -61,7 +73,7 @@ "description": "Type: `file`, default: `$id.$key.output_falco.output_falco`. Directory to write falco output to", "help_text": "Type: `file`, default: `$id.$key.output_falco.output_falco`. Directory to write falco output to" , - "default": "$id.$key.output_falco.output_falco" + "default":"$id.$key.output_falco.output_falco" } @@ -72,7 +84,7 @@ "description": "Type: `file`, default: `$id.$key.output_multiqc.html`. Directory to write falco output to", "help_text": "Type: `file`, default: `$id.$key.output_multiqc.html`. Directory to write falco output to" , - "default": "$id.$key.output_multiqc.html" + "default":"$id.$key.output_multiqc.html" } diff --git a/target/nextflow/io/interop_summary_to_csv/.config.vsh.yaml b/target/nextflow/io/interop_summary_to_csv/.config.vsh.yaml index 66c35a2..c26efe2 100644 --- a/target/nextflow/io/interop_summary_to_csv/.config.vsh.yaml +++ b/target/nextflow/io/interop_summary_to_csv/.config.vsh.yaml @@ -141,9 +141,9 @@ build_info: output: "target/nextflow/io/interop_summary_to_csv" executable: "target/nextflow/io/interop_summary_to_csv/main.nf" viash_version: "0.9.0" - git_commit: "5cb13230bf682321226addce896a3015e8864913" - git_remote: "https://x-access-token:ghs_x4A4kChpmjRCoWA3E68PwNsGJxIsF40DBeTf@github.com/viash-hub/demultiplex" - git_tag: "v0.1.1-3-g5cb1323" + git_commit: "6e6be28b85ab619214ae05a017a33498c0dc8890" + git_remote: "https://x-access-token:ghs_iopCikoFK5KlWGbHHLIwAf82AMtbiI0fzew1@github.com/viash-hub/demultiplex" + git_tag: "v0.1.1-5-g6e6be28" package_config: name: "demultiplex" version: "main" diff --git a/target/nextflow/io/interop_summary_to_csv/main.nf b/target/nextflow/io/interop_summary_to_csv/main.nf index 13534c9..c7e3afa 100644 --- a/target/nextflow/io/interop_summary_to_csv/main.nf +++ b/target/nextflow/io/interop_summary_to_csv/main.nf @@ -2977,9 +2977,9 @@ meta = [ "engine" : "docker|native", "output" : "target/nextflow/io/interop_summary_to_csv", "viash_version" : "0.9.0", - "git_commit" : "5cb13230bf682321226addce896a3015e8864913", - "git_remote" : "https://x-access-token:ghs_x4A4kChpmjRCoWA3E68PwNsGJxIsF40DBeTf@github.com/viash-hub/demultiplex", - "git_tag" : "v0.1.1-3-g5cb1323" + "git_commit" : "6e6be28b85ab619214ae05a017a33498c0dc8890", + "git_remote" : "https://x-access-token:ghs_iopCikoFK5KlWGbHHLIwAf82AMtbiI0fzew1@github.com/viash-hub/demultiplex", + "git_tag" : "v0.1.1-5-g6e6be28" }, "package_config" : { "name" : "demultiplex", diff --git a/target/nextflow/io/interop_summary_to_csv/nextflow_schema.json b/target/nextflow/io/interop_summary_to_csv/nextflow_schema.json index c448f2a..ca1fafd 100644 --- a/target/nextflow/io/interop_summary_to_csv/nextflow_schema.json +++ b/target/nextflow/io/interop_summary_to_csv/nextflow_schema.json @@ -40,7 +40,7 @@ "description": "Type: `file`, required, default: `$id.$key.output_run_summary.output_run_summary`. ", "help_text": "Type: `file`, required, default: `$id.$key.output_run_summary.output_run_summary`. " , - "default": "$id.$key.output_run_summary.output_run_summary" + "default":"$id.$key.output_run_summary.output_run_summary" } @@ -51,7 +51,7 @@ "description": "Type: `file`, required, default: `$id.$key.output_index_summary.output_index_summary`. ", "help_text": "Type: `file`, required, default: `$id.$key.output_index_summary.output_index_summary`. " , - "default": "$id.$key.output_index_summary.output_index_summary" + "default":"$id.$key.output_index_summary.output_index_summary" } diff --git a/target/nextflow/io/untar/.config.vsh.yaml b/target/nextflow/io/untar/.config.vsh.yaml index 719bccb..ddb2ad2 100644 --- a/target/nextflow/io/untar/.config.vsh.yaml +++ b/target/nextflow/io/untar/.config.vsh.yaml @@ -148,9 +148,9 @@ build_info: output: "target/nextflow/io/untar" executable: "target/nextflow/io/untar/main.nf" viash_version: "0.9.0" - git_commit: "5cb13230bf682321226addce896a3015e8864913" - git_remote: "https://x-access-token:ghs_x4A4kChpmjRCoWA3E68PwNsGJxIsF40DBeTf@github.com/viash-hub/demultiplex" - git_tag: "v0.1.1-3-g5cb1323" + git_commit: "6e6be28b85ab619214ae05a017a33498c0dc8890" + git_remote: "https://x-access-token:ghs_iopCikoFK5KlWGbHHLIwAf82AMtbiI0fzew1@github.com/viash-hub/demultiplex" + git_tag: "v0.1.1-5-g6e6be28" package_config: name: "demultiplex" version: "main" diff --git a/target/nextflow/io/untar/main.nf b/target/nextflow/io/untar/main.nf index 4caa615..eb68ee4 100644 --- a/target/nextflow/io/untar/main.nf +++ b/target/nextflow/io/untar/main.nf @@ -2989,9 +2989,9 @@ meta = [ "engine" : "docker|native", "output" : "target/nextflow/io/untar", "viash_version" : "0.9.0", - "git_commit" : "5cb13230bf682321226addce896a3015e8864913", - "git_remote" : "https://x-access-token:ghs_x4A4kChpmjRCoWA3E68PwNsGJxIsF40DBeTf@github.com/viash-hub/demultiplex", - "git_tag" : "v0.1.1-3-g5cb1323" + "git_commit" : "6e6be28b85ab619214ae05a017a33498c0dc8890", + "git_remote" : "https://x-access-token:ghs_iopCikoFK5KlWGbHHLIwAf82AMtbiI0fzew1@github.com/viash-hub/demultiplex", + "git_tag" : "v0.1.1-5-g6e6be28" }, "package_config" : { "name" : "demultiplex", diff --git a/target/nextflow/io/untar/nextflow_schema.json b/target/nextflow/io/untar/nextflow_schema.json index 5ab4909..5363950 100644 --- a/target/nextflow/io/untar/nextflow_schema.json +++ b/target/nextflow/io/untar/nextflow_schema.json @@ -40,7 +40,7 @@ "description": "Type: `file`, required, default: `$id.$key.output.output`. Directory to write the contents of the ", "help_text": "Type: `file`, required, default: `$id.$key.output.output`. Directory to write the contents of the .tar file to." , - "default": "$id.$key.output.output" + "default":"$id.$key.output.output" }