diff --git a/_viash.yaml b/_viash.yaml index 4b90754..7b9341e 100644 --- a/_viash.yaml +++ b/_viash.yaml @@ -7,7 +7,7 @@ links: issue_tracker: https://github.com/viash-hub/playground/issues repository: https://github.com/viash-hub/playground -viash_version: 0.9.0-RC6 +viash_version: 0.9.0 config_mods: | .requirements.commands := ['ps'] diff --git a/src/mapping_and_qc/config.vsh.yaml b/src/mapping_and_qc/config.vsh.yaml index 55e9975..2e1677e 100644 --- a/src/mapping_and_qc/config.vsh.yaml +++ b/src/mapping_and_qc/config.vsh.yaml @@ -1,5 +1,6 @@ name: mapping_and_qc description: Run STAR and QC + argument_groups: - name: Input arguments arguments: @@ -27,7 +28,6 @@ resources: path: main.nf entrypoint: run_wf - dependencies: - name: cutadapt repository: bb @@ -45,6 +45,7 @@ repositories: type: vsh repo: vsh/biobox tag: main + runners: - type: nextflow diff --git a/target/nextflow/mapping_and_qc/.config.vsh.yaml b/target/nextflow/mapping_and_qc/.config.vsh.yaml index ef29179..4ba8b6a 100644 --- a/target/nextflow/mapping_and_qc/.config.vsh.yaml +++ b/target/nextflow/mapping_and_qc/.config.vsh.yaml @@ -161,8 +161,8 @@ build_info: engine: "native|native" output: "target/nextflow/mapping_and_qc" executable: "target/nextflow/mapping_and_qc/main.nf" - viash_version: "0.9.0-RC6" - git_commit: "d87d344d4e46dc6f938e57a009607946ed31447c" + viash_version: "0.9.0" + git_commit: "32dc80723acb5d5861c7acd7c6c07ef4cd1a6ee7" git_remote: "https://github.com/viash-hub/playground" dependencies: - "target/dependencies/vsh/vsh/biobox/main/nextflow/cutadapt" @@ -176,7 +176,7 @@ package_config: description: "A collection of bioinformatics pipelines to illustrate the use of\ \ biobox (and biotools).\n" info: null - viash_version: "0.9.0-RC6" + viash_version: "0.9.0" source: "src" target: "target" config_mods: diff --git a/target/nextflow/mapping_and_qc/main.nf b/target/nextflow/mapping_and_qc/main.nf index 2602439..b61ca3c 100644 --- a/target/nextflow/mapping_and_qc/main.nf +++ b/target/nextflow/mapping_and_qc/main.nf @@ -1,8 +1,8 @@ // mapping_and_qc main // -// This wrapper script is auto-generated by viash 0.9.0-RC6 and is thus a -// derivative work thereof. This software comes with ABSOLUTELY NO WARRANTY from -// Data Intuitive. +// 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 @@ -760,8 +760,11 @@ def runEach(Map args) { 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: @@ -783,7 +786,20 @@ def runEach(Map args) { [new_id] + tup.drop(1) } : filter_ch - def data_ch = id_ch | map{tup -> + 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 -> @@ -821,8 +837,11 @@ def runEach(Map args) { [tup[0], new_state] + tup.drop(3) } : out_ch + + def return_ch = post_ch + | concat(chPassthrough) - post_ch + return_ch } // mix all results @@ -1598,8 +1617,8 @@ def findStates(Map params, Map config) { // 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,newKey:oldKey'" + 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 } @@ -1709,7 +1728,9 @@ def publishStates(Map args) { 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_? @@ -1780,7 +1801,9 @@ def publishStatesByConfig(Map args) { 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 @@ -1822,7 +1845,9 @@ def publishStatesByConfig(Map args) { // 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 @@ -2626,30 +2651,31 @@ def workflowFactory(Map args, Map defaultWfArgs, Map meta) { tuple } - def chModifiedFiltered = workflowArgs.filter ? - chModified | filter{workflowArgs.filter(it)} : - chModified def chRun = null def chPassthrough = null if (workflowArgs.runIf) { - def runIfBranch = chModifiedFiltered.branch{ tup -> + def runIfBranch = chModified.branch{ tup -> run: workflowArgs.runIf(tup[0], tup[1]) passthrough: true } chRun = runIfBranch.run chPassthrough = runIfBranch.passthrough } else { - chRun = chModifiedFiltered + chRun = chModified chPassthrough = Channel.empty() } + def chRunFiltered = workflowArgs.filter ? + chRun | filter{workflowArgs.filter(it)} : + chRun + def chArgs = workflowArgs.fromState ? - chRun | map{ + chRunFiltered | map{ def new_data = workflowArgs.fromState(it.take(2)) [it[0], new_data] } : - chRun | map {tup -> tup.take(2)} + chRunFiltered | map {tup -> tup.take(2)} // fill in defaults def chArgsWithDefaults = chArgs @@ -2720,7 +2746,7 @@ def workflowFactory(Map args, Map defaultWfArgs, Map meta) { // | view{"chInitialOutput: ${it.take(3)}"} // join the output [prev_id, new_id, output] with the previous state [prev_id, state, ...] - def chNewState = safeJoin(chInitialOutput, chModifiedFiltered, key_) + 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 -> @@ -2988,15 +3014,15 @@ meta = [ "runner" : "nextflow", "engine" : "native|native", "output" : "target/nextflow/mapping_and_qc", - "viash_version" : "0.9.0-RC6", - "git_commit" : "d87d344d4e46dc6f938e57a009607946ed31447c", + "viash_version" : "0.9.0", + "git_commit" : "32dc80723acb5d5861c7acd7c6c07ef4cd1a6ee7", "git_remote" : "https://github.com/viash-hub/playground" }, "package_config" : { "name" : "playground", "version" : "main", "description" : "A collection of bioinformatics pipelines to illustrate the use of biobox (and biotools).\n", - "viash_version" : "0.9.0-RC6", + "viash_version" : "0.9.0", "source" : "src", "target" : "target", "config_mods" : [ diff --git a/test_data.sh b/test_data.sh index 52faa90..89dc1ee 100755 --- a/test_data.sh +++ b/test_data.sh @@ -12,56 +12,56 @@ if [ ! -f "$TEST_DATA_DIR/SRR1569895_1.fastq" ] || [ ! -f "$TEST_DATA_DIR/SRR156 docker run -t --rm -v $PWD:/output:rw -w /output/test_data ncbi/sra-tools fasterq-dump -e 2 -p SRR1569895 fi if [ ! -f "$TEST_DATA_DIR/SRR1570800_1.fastq" ] || [ ! -f "$TEST_DATA_DIR/SRR1570800_2.fastq" ]; then - docker run -t --rm -v $PWD:/output:rw -w /output/test_data ncbi/sra-tools fasterq-dump -e 2 -p SRR1570800 + docker run -t --rm -v $PWD:/output:rw -w /output/test_data ncbi/sra-tools fasterq-dump -e 2 -p SRR1570800 fi -head -n 10000 "$TEST_DATA_DIR/SRR1569895_1.fastq" > "$TEST_DATA_DIR/SRR1569895_1_subsample.fastq" -head -n 10000 "$TEST_DATA_DIR/SRR1569895_2.fastq" > "$TEST_DATA_DIR/SRR1569895_2_subsample.fastq" -head -n 10000 "$TEST_DATA_DIR/SRR1570800_1.fastq" > "$TEST_DATA_DIR/SRR1570800_1_subsample.fastq" -head -n 10000 "$TEST_DATA_DIR/SRR1570800_2.fastq" > "$TEST_DATA_DIR/SRR1570800_2_subsample.fastq" +head -n 10000 "$TEST_DATA_DIR/SRR1569895_1.fastq" >"$TEST_DATA_DIR/SRR1569895_1_subsample.fastq" +head -n 10000 "$TEST_DATA_DIR/SRR1569895_2.fastq" >"$TEST_DATA_DIR/SRR1569895_2_subsample.fastq" +head -n 10000 "$TEST_DATA_DIR/SRR1570800_1.fastq" >"$TEST_DATA_DIR/SRR1570800_1_subsample.fastq" +head -n 10000 "$TEST_DATA_DIR/SRR1570800_2.fastq" >"$TEST_DATA_DIR/SRR1570800_2_subsample.fastq" export NXF_SCM_FILE="$TEST_DATA_DIR/scm.config" -cat > $NXF_SCM_FILE << EOF +cat >$NXF_SCM_FILE < "$TEST_DATA_DIR/S288C_reference_genome_Current_Release/S288C_reference_sequence_R64-5-1_20240529.fsa" -gunzip -c "$TEST_DATA_DIR/S288C_reference_genome_Current_Release/saccharomyces_cerevisiae_R64-5-1_20240529.gff.gz" > "$TEST_DATA_DIR/S288C_reference_genome_Current_Release/saccharomyces_cerevisiae_R64-5-1_20240529.gff" +gunzip -c "$TEST_DATA_DIR/S288C_reference_genome_Current_Release/S288C_reference_sequence_R64-5-1_20240529.fsa.gz" >"$TEST_DATA_DIR/S288C_reference_genome_Current_Release/S288C_reference_sequence_R64-5-1_20240529.fsa" +gunzip -c "$TEST_DATA_DIR/S288C_reference_genome_Current_Release/saccharomyces_cerevisiae_R64-5-1_20240529.gff.gz" >"$TEST_DATA_DIR/S288C_reference_genome_Current_Release/saccharomyces_cerevisiae_R64-5-1_20240529.gff" sed -i -e 's/^.*chromosome=\(.*\)\]$/>chr\1/' "$TEST_DATA_DIR/S288C_reference_genome_Current_Release/S288C_reference_sequence_R64-5-1_20240529.fsa" if [ ! -d "$TEST_DATA_DIR/S288C_reference_genome_Current_Release_STAR" ]; then nextflow run vsh/biobox -hub vsh -r main -main-script target/nextflow/star/star_genome_generate/main.nf \ - -profile docker \ - --genome_fasta_files "$TEST_DATA_DIR/S288C_reference_genome_Current_Release/S288C_reference_sequence_R64-5-1_20240529.fsa" \ - --sjdb_gtf_file "$TEST_DATA_DIR/S288C_reference_genome_Current_Release/saccharomyces_cerevisiae_R64-5-1_20240529.gff" \ - --sjdb_gtf_tag_exon_parent_transcript Parent \ - --sjdb_overhang 100 \ - --publish_dir "$TEST_DATA_DIR" \ - --sjdb_gtf_feature_exon noncoding_exon \ - --index S288C_reference_genome_Current_Release_STAR + -profile docker \ + --genome_fasta_files "$TEST_DATA_DIR/S288C_reference_genome_Current_Release/S288C_reference_sequence_R64-5-1_20240529.fsa" \ + --sjdb_gtf_file "$TEST_DATA_DIR/S288C_reference_genome_Current_Release/saccharomyces_cerevisiae_R64-5-1_20240529.gff" \ + --sjdb_gtf_tag_exon_parent_transcript Parent \ + --sjdb_overhang 100 \ + --publish_dir "$TEST_DATA_DIR" \ + --sjdb_gtf_feature_exon noncoding_exon \ + --index S288C_reference_genome_Current_Release_STAR fi PARAMS_FILE=params_file.yaml -cat > $PARAMS_FILE << EOF +cat >$PARAMS_FILE <