diff --git a/CHANGELOG.md b/CHANGELOG.md index 73bc0b07..09ab5a00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,12 +29,18 @@ - `bedtools/bedtools_sort`: Sorts a feature file (bed/gff/vcf) by chromosome and other criteria (PR #98). +* `agat/agat_convert_embl2gff`: convert an EMBL file into GFF format (PR #99). + ## MINOR CHANGES * `busco` components: update BUSCO to `5.7.1` (PR #72). * Update CI to reusable workflow in `viash-io/viash-actions` (PR #86). +* Update several components in order to avoid duplicate code when using `unset` on boolean arguments (PR #133). + +* Bump viash to `0.9.0-RC7` (PR #134) + ## DOCUMENTATION * Extend the contributing guidelines (PR #82): diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cee4249a..a32b680c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -320,6 +320,31 @@ Notes: * If your tool allows for multiple inputs using a separator other than `;` (which is the default Viash multiple separator), you can substitute these values with a command like: `par_disable_filters=$(echo $par_disable_filters | tr ';' ',')`. +* If you have a lot of boolean variables that you would like to unset when the value is `false`, you can avoid duplicate code by using the following syntax: + +```bash +unset_if_false=( + par_argument_1 + par_argument_2 + par_argument_3 + par_argument_4 +) + +for par in ${unset_if_false[@]}; do + test_val="${!par}" + [[ "$test_val" == "false" ]] && unset $par +done +``` + +this code is equivalent to + +```bash +[[ "$par_argument_1" == "false" ]] && unset par_argument_1 +[[ "$par_argument_2" == "false" ]] && unset par_argument_2 +[[ "$par_argument_3" == "false" ]] && unset par_argument_3 +[[ "$par_argument_4" == "false" ]] && unset par_argument_4 +``` + ### Step 12: Create test script diff --git a/_viash.yaml b/_viash.yaml index 9a240c24..ab4f3828 100644 --- a/_viash.yaml +++ b/_viash.yaml @@ -7,7 +7,7 @@ links: issue_tracker: https://github.com/viash-hub/biobox/issues repository: https://github.com/viash-hub/biobox -viash_version: 0.9.0-RC6 +viash_version: 0.9.0-RC7 config_mods: | .requirements.commands := ['ps'] diff --git a/src/agat/agat_convert_embl2gff/config.vsh.yaml b/src/agat/agat_convert_embl2gff/config.vsh.yaml new file mode 100644 index 00000000..99ceec46 --- /dev/null +++ b/src/agat/agat_convert_embl2gff/config.vsh.yaml @@ -0,0 +1,84 @@ +name: agat_convert_embl2gff +namespace: agat +description: | + The script takes an EMBL file as input, and will translate it in gff format. +keywords: [gene annotations, GFF conversion] +links: + homepage: https://github.com/NBISweden/AGAT + documentation: https://agat.readthedocs.io/en/latest/tools/agat_convert_embl2gff.html + issue_tracker: https://github.com/NBISweden/AGAT/issues + repository: https://github.com/NBISweden/AGAT +references: + doi: 10.5281/zenodo.3552717 +license: GPL-3.0 +authors: + - __merge__: /src/_authors/leila_paquay.yaml + roles: [ author, maintainer ] + +argument_groups: + - name: Inputs + arguments: + - name: --embl + description: Input EMBL file that will be read. + type: file + required: true + direction: input + example: input.embl + - name: Outputs + arguments: + - name: --output + alternatives: [-o, --out, --outfile, --gff] + description: Output GFF file. If no output file is specified, the output will be written to STDOUT. + type: file + direction: output + required: false + example: output.gff + - name: Arguments + arguments: + - name: --emblmygff3 + description: | + Means that the EMBL flat file comes from the EMBLmyGFF3 software. This is an EMBL format dedicated for submission and contains particularity to deal with. This parameter is needed to get a proper sequence id in the GFF3 from an embl made with EMBLmyGFF3. + type: boolean_true + - name: --primary_tag + alternatives: [--pt, -t] + description: | + List of "primary tag". Useful to discard or keep specific features. Multiple tags must be comma-separated. + type: string + multiple: true + required: false + example: [tag1, tag2] + - name: --discard + alternatives: [-d] + description: | + Means that primary tags provided by the option "primary_tag" will be discarded. + type: boolean_true + - name: --keep + alternatives: [-k] + description: | + Means that only primary tags provided by the option "primary_tag" will be kept. + type: boolean_true + - name: --config + alternatives: [-c] + description: | + Input agat config file. By default AGAT takes as input agat_config.yaml file from the working directory if any, otherwise it takes the original agat_config.yaml shipped with AGAT. To get the agat_config.yaml locally type: "agat config --expose". The --config option gives you the possibility to use your own AGAT config file (located elsewhere or named differently). + type: file + required: false + example: custom_agat_config.yaml +resources: + - type: bash_script + path: script.sh +test_resources: + - type: bash_script + path: test.sh + - type: file + path: test_data +engines: + - type: docker + image: quay.io/biocontainers/agat:1.4.0--pl5321hdfd78af_0 + setup: + - type: docker + run: | + agat --version | sed 's/AGAT\s\(.*\)/agat: "\1"/' > /var/software_versions.txt +runners: + - type: executable + - type: nextflow \ No newline at end of file diff --git a/src/agat/agat_convert_embl2gff/help.txt b/src/agat/agat_convert_embl2gff/help.txt new file mode 100644 index 00000000..5fce4939 --- /dev/null +++ b/src/agat/agat_convert_embl2gff/help.txt @@ -0,0 +1,78 @@ + ```sh +agat_convert_embl2gff.pl --help +``` + + ------------------------------------------------------------------------------ +| Another GFF Analysis Toolkit (AGAT) - Version: v1.4.0 | +| https://github.com/NBISweden/AGAT | +| National Bioinformatics Infrastructure Sweden (NBIS) - www.nbis.se | + ------------------------------------------------------------------------------ + + +Name: + agat_converter_embl2gff.pl + +Description: + The script takes an EMBL file as input, and will translate it in gff + format. + +Usage: + agat_converter_embl2gff.pl --embl infile.embl [ -o outfile ] + +Options: + --embl Input EMBL file that will be read + + --emblmygff3 + Bolean - Means that the EMBL flat file comes from the EMBLmyGFF3 + software. This is an EMBL format dedicated for submission and + contains particularity to deal with. This parameter is needed to + get a proper sequence id in the GFF3 from an embl made with + EMBLmyGFF3. + + --primary_tag, --pt, -t + List of "primary tag". Useful to discard or keep specific + features. Multiple tags must be coma-separated. + + -d Bolean - Means that primary tags provided by the option + "primary_tag" will be discarded. + + -k Bolean - Means that only primary tags provided by the option + "primary_tag" will be kept. + + -o, --output, --out, --outfile or --gff + Output GFF file. If no output file is specified, the output will + be written to STDOUT. + + -c or --config + String - Input agat config file. By default AGAT takes as input + agat_config.yaml file from the working directory if any, + otherwise it takes the orignal agat_config.yaml shipped with + AGAT. To get the agat_config.yaml locally type: "agat config + --expose". The --config option gives you the possibility to use + your own AGAT config file (located elsewhere or named + differently). + + -h or --help + Display this helpful text. + +Feedback: + Did you find a bug?: + Do not hesitate to report bugs to help us keep track of the bugs and + their resolution. Please use the GitHub issue tracking system available + at this address: + + https://github.com/NBISweden/AGAT/issues + + Ensure that the bug was not already reported by searching under Issues. + If you're unable to find an (open) issue addressing the problem, open a new one. + Try as much as possible to include in the issue when relevant: + - a clear description, + - as much relevant information as possible, + - the command used, + - a data sample, + - an explanation of the expected behaviour that is not occurring. + + Do you want to contribute?: + You are very welcome, visit this address for the Contributing + guidelines: + https://github.com/NBISweden/AGAT/blob/master/CONTRIBUTING.md diff --git a/src/agat/agat_convert_embl2gff/script.sh b/src/agat/agat_convert_embl2gff/script.sh new file mode 100644 index 00000000..63ab8df0 --- /dev/null +++ b/src/agat/agat_convert_embl2gff/script.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +## VIASH START +## VIASH END + + +# unset flags +[[ "$par_emblmygff3" == "false" ]] && unset par_emblmygff3 +[[ "$par_discard" == "false" ]] && unset par_discard +[[ "$par_keep" == "false" ]] && unset par_keep + +# replace ';' with ',' +par_primary_tag=$(echo $par_primary_tag | tr ';' ',') + +# run agat_convert_embl2gff +agat_convert_embl2gff.pl \ + --embl "$par_embl" \ + -o "$par_output" \ + ${par_emblmygff3:+--emblmygff3} \ + ${par_primary_tag:+--primary_tag "${par_primary_tag}"} \ + ${par_discard:+-d} \ + ${par_keep:+-k} \ + ${par_config:+--config "${par_config}"} diff --git a/src/agat/agat_convert_embl2gff/test.sh b/src/agat/agat_convert_embl2gff/test.sh new file mode 100644 index 00000000..81d24aaa --- /dev/null +++ b/src/agat/agat_convert_embl2gff/test.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +## VIASH START +## VIASH END + +test_dir="${meta_resources_dir}/test_data" +out_dir="${meta_resources_dir}/out_data" + +echo "> Run $meta_name with test data and --emblmygff3" +"$meta_executable" \ + --embl "$test_dir/agat_convert_embl2gff_1.embl" \ + --output "$out_dir/output.gff" \ + --emblmygff3 + +echo ">> Checking output" +[ ! -f "$out_dir/output.gff" ] && echo "Output file output.gff does not exist" && exit 1 + +echo ">> Check if output is empty" +[ ! -s "$out_dir/output.gff" ] && echo "Output file output.gff is empty" && exit 1 + +echo ">> Check if output matches expected output" +diff "$out_dir/output.gff" "$test_dir/agat_convert_embl2gff_1.gff" +if [ $? -ne 0 ]; then + echo "Output file output.gff does not match expected output" + exit 1 +fi + +echo "> Test successful" \ No newline at end of file diff --git a/src/agat/agat_convert_embl2gff/test_data/agat_convert_embl2gff_1.embl b/src/agat/agat_convert_embl2gff/test_data/agat_convert_embl2gff_1.embl new file mode 100644 index 00000000..aa4f50aa --- /dev/null +++ b/src/agat/agat_convert_embl2gff/test_data/agat_convert_embl2gff_1.embl @@ -0,0 +1,51 @@ +ID patatrac; SV 1; circular; genomic DNA; XXX; PRO; 317941 BP. +XX +AC XXX; +XX +AC * _ERS324955|SC|contig000001 +XX +PR Project:PRJEBNNNN; +XX +DE XXX +XX +RN [1] +RP 1-2149 +RA XXX; +RT ; +RL Submitted {(DD-MMM-YYYY)} to the INSDC. +XX +FH Key Location/Qualifiers +FH +FT source 1..588788 +FT /organism={"scientific organism name"} +FT /mol_type={"in vivo molecule type of sequence"} +XX +SQ Sequence 588788 BP; 101836 A; 193561 C; 192752 G; 100639 T; 0 other; + tgcgtactcg aagagacgcg cccagattat ataagggcgt cgtctcgagg ccgacggcgc 60 + gccggcgagt acgcgtgatc cacaacccga agcgaccgtc gggagaccga gggtcgtcga 120 + gggtggatac gttcctgcct tcgtgccggg aaacggccga agggaacgtg gcgacctgcg 180 +// +ID fdssf; SV 1; circular; genomic DNA; XXX; PRO; 317941 BP. +XX +AC XXX; +XX +AC * _ERS344554 +XX +PR Project:PRJEBNNNN; +XX +DE XXX +XX +RN [1] +RP 1-2149 +RA XXX; +RT ; +RL Submitted {(DD-MMM-YYYY)} to the INSDC. +XX +FH Key Location/Qualifiers +FH +FT source 1..588788 +FT /organism={"scientific organism name"} +FT /mol_type={"in vivo molecule type of sequence"} +XX +SQ Sequence 588788 BP; 101836 A; 193561 C; 192752 G; 100639 T; 0 other; + TTTTTTTTTT aagagacgcg cccagattat ataagggcgt cgtctcgagg ccgacggcgc 60 diff --git a/src/agat/agat_convert_embl2gff/test_data/agat_convert_embl2gff_1.gff b/src/agat/agat_convert_embl2gff/test_data/agat_convert_embl2gff_1.gff new file mode 100644 index 00000000..f6893022 --- /dev/null +++ b/src/agat/agat_convert_embl2gff/test_data/agat_convert_embl2gff_1.gff @@ -0,0 +1,10 @@ +##gff-version 3 +ERS324955|SC|contig000001 EMBL/GenBank/SwissProt source 1 588788 . + 1 mol_type={"in vivo molecule type of sequence"};organism={"scientific organism name"} +ERS344554 EMBL/GenBank/SwissProt source 1 588788 . + 1 mol_type={"in vivo molecule type of sequence"};organism={"scientific organism name"} +##FASTA +>ERS324955|SC|contig000001 XXX +TGCGTACTCGAAGAGACGCGCCCAGATTATATAAGGGCGTCGTCTCGAGGCCGACGGCGCGCCGGCGAGTACGCGTGATC +CACAACCCGAAGCGACCGTCGGGAGACCGAGGGTCGTCGAGGGTGGATACGTTCCTGCCTTCGTGCCGGGAAACGGCCGA +AGGGAACGTGGCGACCTGCG +>ERS344554 XXX +TTTTTTTTTTAAGAGACGCGCCCAGATTATATAAGGGCGTCGTCTCGAGGCCGACGGCGC diff --git a/src/agat/agat_convert_embl2gff/test_data/script.sh b/src/agat/agat_convert_embl2gff/test_data/script.sh new file mode 100755 index 00000000..7ddbce5b --- /dev/null +++ b/src/agat/agat_convert_embl2gff/test_data/script.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# clone repo +if [ ! -d /tmp/agat_source ]; then + git clone --depth 1 --single-branch --branch master https://github.com/NBISweden/AGAT /tmp/agat_source +fi + +# copy test data +cp -r /tmp/agat_source/t/scripts_output/in/agat_convert_embl2gff_1.embl src/agat/agat_convert_embl2gff/test_data/agat_convert_embl2gff_1.embl +cp -r /tmp/agat_source/t/scripts_output/out/agat_convert_embl2gff_1.gff src/agat/agat_convert_embl2gff/test_data/agat_convert_embl2gff_1.gff \ No newline at end of file diff --git a/src/bedtools/bedtools_intersect/script.sh b/src/bedtools/bedtools_intersect/script.sh index 2141859d..04a8d854 100644 --- a/src/bedtools/bedtools_intersect/script.sh +++ b/src/bedtools/bedtools_intersect/script.sh @@ -3,27 +3,34 @@ ## VIASH START ## VIASH END -[[ "$par_write_a" == "false" ]] && unset par_write_a -[[ "$par_write_b" == "false" ]] && unset par_write_b -[[ "$par_left_outer_join" == "false" ]] && unset par_left_outer_join -[[ "$par_write_overlap" == "false" ]] && unset par_write_overlap -[[ "$par_write_overlap_plus" == "false" ]] && unset par_write_overlap_plus -[[ "$par_report_A_if_no_overlap" == "false" ]] && unset par_report_A_if_no_overlap -[[ "$par_number_of_overlaps_A" == "false" ]] && unset par_number_of_overlaps_A -[[ "$par_report_no_overlaps_A" == "false" ]] && unset par_report_no_overlaps_A -[[ "$par_uncompressed_bam" == "false" ]] && unset par_uncompressed_bam -[[ "$par_same_strand" == "false" ]] && unset par_same_strand -[[ "$par_opposite_strand" == "false" ]] && unset par_opposite_strand -[[ "$par_reciprocal_overlap" == "false" ]] && unset par_reciprocal_overlap -[[ "$par_either_overlap" == "false" ]] && unset par_either_overlap -[[ "$par_split" == "false" ]] && unset par_split -[[ "$par_nonamecheck" == "false" ]] && unset par_nonamecheck -[[ "$par_sorted" == "false" ]] && unset par_sorted -[[ "$par_filenames" == "false" ]] && unset par_filenames -[[ "$par_sortout" == "false" ]] && unset par_sortout -[[ "$par_bed" == "false" ]] && unset par_bed -[[ "$par_header" == "false" ]] && unset par_header -[[ "$par_no_buffer_output" == "false" ]] && unset par_no_buffer_output +unset_if_false=( + par_write_a + par_write_b + par_left_outer_join + par_write_overlap + par_write_overlap_plus + par_report_A_if_no_overlap + par_number_of_overlaps_A + par_report_no_overlaps_A + par_uncompressed_bam + par_same_strand + par_opposite_strand + par_reciprocal_overlap + par_either_overlap + par_split + par_nonamecheck + par_sorted + par_filenames + par_sortout + par_bed + par_no_buffer_output +) + +for par in ${unset_if_false[@]}; do + test_val="${!par}" + [[ "$test_val" == "false" ]] && unset $par +done + # Create input array IFS=";" read -ra input <<< $par_input_b diff --git a/src/bedtools/bedtools_sort/script.sh b/src/bedtools/bedtools_sort/script.sh index e7f712d7..0d0b9b54 100644 --- a/src/bedtools/bedtools_sort/script.sh +++ b/src/bedtools/bedtools_sort/script.sh @@ -4,13 +4,20 @@ ## VIASH END # Unset parameters -[[ "$par_sizeA" == "false" ]] && unset par_sizeA -[[ "$par_sizeD" == "false" ]] && unset par_sizeD -[[ "$par_chrThenSizeA" == "false" ]] && unset par_chrThenSizeA -[[ "$par_chrThenSizeD" == "false" ]] && unset par_chrThenSizeD -[[ "$par_chrThenScoreA" == "false" ]] && unset par_chrThenScoreA -[[ "$par_chrThenScoreD" == "false" ]] && unset par_chrThenScoreD -[[ "$par_header" == "false" ]] && unset par_header +unset_if_false=( + par_sizeA + par_sizeD + par_chrThenSizeA + par_chrThenSizeD + par_chrThenScoreA + par_chrThenScoreD + par_header +) + +for par in ${unset_if_false[@]}; do + test_val="${!par}" + [[ "$test_val" == "false" ]] && unset $par +done # Execute bedtools sort with the provided arguments bedtools sort \ diff --git a/src/busco/busco_run/script.sh b/src/busco/busco_run/script.sh index a0ef24de..673ccd0b 100644 --- a/src/busco/busco_run/script.sh +++ b/src/busco/busco_run/script.sh @@ -3,18 +3,24 @@ ## VIASH START ## VIASH END +unset_if_false=( + par_tar + par_force + par_quiet + par_restart + par_auto_lineage + par_auto_lineage_euk + par_auto_lineage_prok + par_augustus + par_long + par_scaffold_composition + par_miniprot +) -[[ "$par_tar" == "false" ]] && unset par_tar -[[ "$par_force" == "false" ]] && unset par_force -[[ "$par_quiet" == "false" ]] && unset par_quiet -[[ "$par_restart" == "false" ]] && unset par_restart -[[ "$par_auto_lineage" == "false" ]] && unset par_auto_lineage -[[ "$par_auto_lineage_euk" == "false" ]] && unset par_auto_lineage_euk -[[ "$par_auto_lineage_prok" == "false" ]] && unset par_auto_lineage_prok -[[ "$par_augustus" == "false" ]] && unset par_augustus -[[ "$par_long" == "false" ]] && unset par_long -[[ "$par_scaffold_composition" == "false" ]] && unset par_scaffold_composition -[[ "$par_miniprot" == "false" ]] && unset par_miniprot +for par in ${unset_if_false[@]}; do + test_val="${!par}" + [[ "$test_val" == "false" ]] && unset $par +done tmp_dir=$(mktemp -d -p "$meta_temp_dir" busco_XXXXXXXXX) prefix=$(openssl rand -hex 8) diff --git a/src/fastp/script.sh b/src/fastp/script.sh index 4bb37c87..557f7ac3 100644 --- a/src/fastp/script.sh +++ b/src/fastp/script.sh @@ -4,25 +4,32 @@ ## VIASH END # disable flags -[[ "$par_disable_adapter_trimming" == "false" ]] && unset par_disable_adapter_trimming -[[ "$par_detect_adapter_for_pe" == "false" ]] && unset par_detect_adapter_for_pe -[[ "$par_merge" == "false" ]] && unset par_merge -[[ "$par_include_unmerged" == "false" ]] && unset par_include_unmerged -[[ "$par_interleaved_in" == "false" ]] && unset par_interleaved_in -[[ "$par_fix_mgi_id" == "false" ]] && unset par_fix_mgi_id -[[ "$par_phred64" == "false" ]] && unset par_phred64 -[[ "$par_dont_overwrite" == "false" ]] && unset par_dont_overwrite -[[ "$par_verbose" == "false" ]] && unset par_verbose -[[ "$par_dedup" == "false" ]] && unset par_dedup -[[ "$par_dont_eval_duplication" == "false" ]] && unset par_dont_eval_duplication -[[ "$par_trim_poly_g" == "false" ]] && unset par_trim_poly_g -[[ "$par_disable_trim_poly_g" == "false" ]] && unset par_disable_trim_poly_g -[[ "$par_trim_poly_x" == "false" ]] && unset par_trim_poly_x -[[ "$par_disable_quality_filtering" == "false" ]] && unset par_disable_quality_filtering -[[ "$par_disable_length_filtering" == "false" ]] && unset par_disable_length_filtering -[[ "$par_low_complexity_filter" == "false" ]] && unset par_low_complexity_filter -[[ "$par_umi" == "false" ]] && unset par_umi -[[ "$par_overrepresentation_analysis" == "false" ]] && unset par_overrepresentation_analysis +unset_if_false=( + par_disable_adapter_trimming + par_detect_adapter_for_pe + par_merge + par_include_unmerged + par_interleaved_in + par_fix_mgi_id + par_phred64 + par_dont_overwrite + par_verbose + par_dedup + par_dont_eval_duplication + par_trim_poly_g + par_disable_trim_poly_g + par_trim_poly_x + par_disable_quality_filtering + par_disable_length_filtering + par_low_complexity_filter + par_umi + par_overrepresentation_analysis +) + +for par in ${unset_if_false[@]}; do + test_val="${!par}" + [[ "$test_val" == "false" ]] && unset $par +done # run command fastp \ diff --git a/src/featurecounts/script.sh b/src/featurecounts/script.sh index 2e54feb3..53f8c63f 100644 --- a/src/featurecounts/script.sh +++ b/src/featurecounts/script.sh @@ -19,24 +19,31 @@ par_feature_type=$(echo $par_feature_type | tr ',' ';') par_extra_attributes=$(echo $par_extra_attributes | tr ',' ';') # unset flag variables -[[ "$par_feature_level" == "false" ]] && unset par_feature_level -[[ "$par_overlapping" == "false" ]] && unset par_overlapping -[[ "$par_largest_overlap" == "false" ]] && unset par_largest_overlap -[[ "$par_multi_mapping" == "false" ]] && unset par_multi_mapping -[[ "$par_fraction" == "false" ]] && unset par_fraction -[[ "$par_split_only" == "false" ]] && unset par_split_only -[[ "$par_non_split_only" == "false" ]] && unset par_non_split_only -[[ "$par_primary" == "false" ]] && unset par_primary -[[ "$par_ignore_dup" == "false" ]] && unset par_ignore_dup -[[ "$par_paired" == "false" ]] && unset par_paired -[[ "$par_count_read_pairs" == "false" ]] && unset par_count_read_pairs -[[ "$par_both_aligned" == "false" ]] && unset par_both_aligned -[[ "$par_check_pe_dist" == "false" ]] && unset par_check_pe_dist -[[ "$par_same_strand" == "false" ]] && unset par_same_strand -[[ "$par_donotsort" == "false" ]] && unset par_donotsort -[[ "$par_by_read_group" == "false" ]] && unset par_by_read_group -[[ "$par_long_reads" == "false" ]] && unset par_long_reads -[[ "$par_verbose" == "false" ]] && unset par_verbose +unset_if_false=( + par_feature_level + par_overlapping + par_largest_overlap + par_multi_mapping + par_fraction + par_split_only + par_non_split_only + par_primary + par_ignore_dup + par_paired + par_count_read_pairs + par_both_aligned + par_check_pe_dist + par_same_strand + par_donotsort + par_by_read_group + par_long_reads + par_verbose +) + +for par in ${unset_if_false[@]}; do + test_val="${!par}" + [[ "$test_val" == "false" ]] && unset $par +done IFS=";" read -ra input <<< $par_input diff --git a/src/gffread/script.sh b/src/gffread/script.sh index cd4abf14..fab9e521 100644 --- a/src/gffread/script.sh +++ b/src/gffread/script.sh @@ -4,51 +4,58 @@ ## VIASH END # unset flags -[[ "$par_coding" == "false" ]] && unset par_coding -[[ "$par_strict_range" == "false" ]] && unset par_strict_range -[[ "$par_no_single_exon" == "false" ]] && unset par_no_single_exon -[[ "$par_no_exon_attrs" == "false" ]] && unset par_no_exon_attrs -[[ "$par_nc" == "false" ]] && unset par_nc -[[ "$par_ignore_locus" == "false" ]] && unset par_ignore_locus -[[ "$par_description" == "false" ]] && unset par_description -[[ "$par_sort_alpha" == "false" ]] && unset par_sort_alpha -[[ "$par_keep_genes" == "false" ]] && unset par_keep_genes -[[ "$par_keep_attrs" == "false" ]] && unset par_keep_attrs -[[ "$par_keep_exon_attrs" == "false" ]] && unset par_keep_exon_attrs -[[ "$par_keep_comments" == "false" ]] && unset par_keep_comments -[[ "$par_process_other" == "false" ]] && unset par_process_other -[[ "$par_rm_stop_codons" == "false" ]] && unset par_rm_stop_codons -[[ "$par_adj_cds_start" == "false" ]] && unset par_adj_cds_start -[[ "$par_opposite_strand" == "false" ]] && unset par_opposite_strand -[[ "$par_coding_status" == "false" ]] && unset par_coding_status -[[ "$par_add_hasCDS" == "false" ]] && unset par_add_hasCDS -[[ "$par_adj_stop" == "false" ]] && unset par_adj_stop -[[ "$par_rm_noncanon" == "false" ]] && unset par_rm_noncanon -[[ "$par_complete_cds" == "false" ]] && unset par_complete_cds -[[ "$par_no_pseudo" == "false" ]] && unset par_no_pseudo -[[ "$par_in_bed" == "false" ]] && unset par_in_bed -[[ "$par_in_tlf" == "false" ]] && unset par_in_tlf -[[ "$par_stream" == "false" ]] && unset par_stream -[[ "$par_merge" == "false" ]] && unset par_merge -[[ "$par_rm_redundant" == "false" ]] && unset par_rm_redundant -[[ "$par_no_boundary" == "false" ]] && unset par_no_boundary -[[ "$par_no_overlap" == "false" ]] && unset par_no_overlap -[[ "$par_force_exons" == "false" ]] && unset par_force_exons -[[ "$par_gene2exon" == "false" ]] && unset par_gene2exon -[[ "$par_t_adopt" == "false" ]] && unset par_t_adopt -[[ "$par_decode" == "false" ]] && unset par_decode -[[ "$par_merge_exons" == "false" ]] && unset par_merge_exons -[[ "$par_junctions" == "false" ]] && unset par_junctions -[[ "$par_w_nocds" == "false" ]] && unset par_w_nocds -[[ "$par_tr_cds" == "false" ]] && unset par_tr_cds -[[ "$par_w_coords" == "false" ]] && unset par_w_coords -[[ "$par_stop_dot" == "false" ]] && unset par_stop_dot -[[ "$par_id_version" == "false" ]] && unset par_id_version -[[ "$par_gtf_output" == "false" ]] && unset par_gtf_output -[[ "$par_bed" == "false" ]] && unset par_bed -[[ "$par_tlf" == "false" ]] && unset par_tlf -[[ "$par_expose_dups" == "false" ]] && unset par_expose_dups -[[ "$par_cluster_only" == "false" ]] && unset par_cluster_only +unset_if_false=( + par_coding + par_strict_range + par_no_single_exon + par_no_exon_attrs + par_nc + par_ignore_locus + par_description + par_sort_alpha + par_keep_genes + par_keep_attrs + par_keep_exon_attrs + par_keep_comments + par_process_other + par_rm_stop_codons + par_adj_cds_start + par_opposite_strand + par_coding_status + par_add_hasCDS + par_adj_stop + par_rm_noncanon + par_complete_cds + par_no_pseudo + par_in_bed + par_in_tlf + par_stream + par_merge + par_rm_redundant + par_no_boundary + par_no_overlap + par_force_exons + par_gene2exon + par_t_adopt + par_decode + par_merge_exons + par_junctions + par_w_nocds + par_tr_cds + par_w_coords + par_stop_dot + par_id_version + par_gtf_output + par_bed + par_tlf + par_expose_dups + par_cluster_only +) + +for par in ${unset_if_false[@]}; do + test_val="${!par}" + [[ "$test_val" == "false" ]] && unset $par +done # if par_table is not empty, replace ";" with "," par_table=$(echo "$par_table" | tr ';' ',') diff --git a/src/lofreq/call/script.sh b/src/lofreq/call/script.sh index 863fe986..ca229194 100644 --- a/src/lofreq/call/script.sh +++ b/src/lofreq/call/script.sh @@ -4,21 +4,28 @@ ## VIASH END # Unset all parameters that are set to "false" -[[ "$par_no_baq" == "false" ]] && unset par_no_baq -[[ "$par_no_idaq" == "false" ]] && unset par_no_idaq -[[ "$par_del_baq" == "false" ]] && unset par_del_baq -[[ "$par_no_ext_baq" == "false" ]] && unset par_no_ext_baq -[[ "$par_no_mq" == "false" ]] && unset par_no_mq -[[ "$par_call_indels" == "false" ]] && unset par_call_indels -[[ "$par_only_indels" == "false" ]] && unset par_only_indels -[[ "$par_src_qual" == "false" ]] && unset par_src_qual -[[ "$par_illumina_13" == "false" ]] && unset par_illumina_13 -[[ "$par_use_orphan" == "false" ]] && unset par_use_orphan -[[ "$par_plp_summary_only" == "false" ]] && unset par_plp_summary_only -[[ "$par_no_default_filter" == "false" ]] && unset par_no_default_filter -[[ "$par_force_overwrite" == "false" ]] && unset par_force_overwrite -[[ "$par_verbose" == "false" ]] && unset par_verbose -[[ "$par_debug" == "false" ]] && unset par_debug +unset_if_false=( + par_no_baq + par_no_idaq + par_del_baq + par_no_ext_baq + par_no_mq + par_call_indels + par_only_indels + par_src_qual + par_illumina_13 + par_use_orphan + par_plp_summary_only + par_no_default_filter + par_force_overwrite + par_verbose + par_debug +) + +for par in ${unset_if_false[@]}; do + test_val="${!par}" + [[ "$test_val" == "false" ]] && unset $par +done # Run lofreq call lofreq call \ diff --git a/src/multiqc/script.sh b/src/multiqc/script.sh index ad8c1c0c..5806fa1d 100755 --- a/src/multiqc/script.sh +++ b/src/multiqc/script.sh @@ -1,26 +1,32 @@ #!/bin/bash # disable flags -[[ "$par_ignore_symlinks" == "false" ]] && unset par_ignore_symlinks -[[ "$par_dirs" == "false" ]] && unset par_dirs -[[ "$par_full_names" == "false" ]] && unset par_full_names -[[ "$par_fn_as_s_name" == "false" ]] && unset par_fn_as_s_name -[[ "$par_profile_runtime" == "false" ]] && unset par_profile_runtime -[[ "$par_verbose" == "false" ]] && unset par_verbose -[[ "$par_quiet" == "false" ]] && unset par_quiet -[[ "$par_strict" == "false" ]] && unset par_strict -[[ "$par_development" == "false" ]] && unset par_development -[[ "$par_require_logs" == "false" ]] && unset par_require_logs -[[ "$par_no_megaqc_upload" == "false" ]] && unset par_no_megaqc_upload -[[ "$par_no_ansi" == "false" ]] && unset par_no_ansi -[[ "$par_flat" == "false" ]] && unset par_flat -[[ "$par_interactive" == "false" ]] && unset par_interactive -[[ "$par_static_plot_export" == "false" ]] && unset par_static_plot_export -[[ "$par_data_dir" == "false" ]] && unset par_data_dir -[[ "$par_no_data_dir" == "false" ]] && unset par_no_data_dir -[[ "$par_zip_data_dir" == "false" ]] && unset par_zip_data_dir -[[ "$par_pdf" == "false" ]] && unset par_pdf +unset_if_false=( + par_ignore_symlinks + par_dirs + par_full_names + par_fn_as_s_name + par_profile_runtime + par_verbose + par_quiet + par_strict + par_development + par_require_logs + par_no_megaqc_upload + par_no_ansi + par_flat + par_interactive + par_static_plot_export + par_data_dir + par_no_data_dir + par_zip_data_dir + par_pdf +) +for par in ${unset_if_false[@]}; do + test_val="${!par}" + [[ "$test_val" == "false" ]] && unset $par +done # handle inputs out_dir=$(dirname "$par_output_report") diff --git a/src/salmon/salmon_index/script.sh b/src/salmon/salmon_index/script.sh index c2b9e7a0..5b1c4d76 100644 --- a/src/salmon/salmon_index/script.sh +++ b/src/salmon/salmon_index/script.sh @@ -5,12 +5,19 @@ set -e ## VIASH START ## VIASH END -[[ "$par_gencode" == "false" ]] && unset par_gencode -[[ "$par_features" == "false" ]] && unset par_features -[[ "$par_keep_duplicates" == "false" ]] && unset par_keep_duplicates -[[ "$par_keep_fixed_fasta" == "false" ]] && unset par_keep_fixed_fasta -[[ "$par_sparse" == "false" ]] && unset par_sparse -[[ "$par_no_clip" == "false" ]] && unset par_no_clip +unset_if_false=( + par_gencode + par_features + par_keep_duplicates + par_keep_fixed_fasta + par_sparse + par_no_clip +) + +for par in ${unset_if_false[@]}; do + test_val="${!par}" + [[ "$test_val" == "false" ]] && unset $par +done tmp_dir=$(mktemp -d -p "$meta_temp_dir" "${meta_functionality_name}_XXXXXX") mkdir -p "$tmp_dir/temp" diff --git a/src/salmon/salmon_quant/script.sh b/src/salmon/salmon_quant/script.sh index 4c9f69d5..47cba1b9 100644 --- a/src/salmon/salmon_quant/script.sh +++ b/src/salmon/salmon_quant/script.sh @@ -4,49 +4,55 @@ set -e ## VIASH START ## VIASH END +unset_if_false=( + par_discard_orphans + par_ont + par_seq_bias + par_gc_bias + par_pos_bias + par_meta + par_discard_orphans_quasi + par_disable_chaining_heuristic + par_allow_dovetail + par_recover_orphans + par_mimicBT2 + par_mimic_strictBT2 + par_softclip + par_softclip_overhangs + par_full_length_alignment + par_hard_filter + par_write_mappings + par_write_qualities + par_alternative_init_mode + par_skip_quant + par_dump_eq + par_dump_eq_weights + par_reduce_GC_memory + par_init_uniform + par_no_length_correction + par_no_effective_length_correction + par_no_single_frag_prob + par_no_frag_length_dist + par_no_bias_length_threshold + par_useEM + par_useVBOpt + par_no_Gamma_draw + par_bootstrap_reproject + par_quiet + par_per_transcript_prior + par_per_nucleotide_prior + par_write_orphan_links + par_write_unmapped_names + par_no_error_model + par_sample_out + par_sample_unaligned + par_gencode +) -[[ "$par_discard_orphans" == "false" ]] && unset par_discard_orphans -[[ "$par_ont" == "false" ]] && unset par_ont -[[ "$par_seq_bias" == "false" ]] && unset par_seq_bias -[[ "$par_gc_bias" == "false" ]] && unset par_gc_bias -[[ "$par_pos_bias" == "false" ]] && unset par_pos_bias -[[ "$par_meta" == "false" ]] && unset par_meta -[[ "$par_discard_orphans_quasi" == "false" ]] && unset par_discard_orphans_quasi -[[ "$par_disable_chaining_heuristic" == "false" ]] && unset par_disable_chaining_heuristic -[[ "$par_allow_dovetail" == "false" ]] && unset par_allow_dovetail -[[ "$par_recover_orphans" == "false" ]] && unset par_recover_orphans -[[ "$par_mimicBT2" == "false" ]] && unset par_mimicBT2 -[[ "$par_mimic_strictBT2" == "false" ]] && unset par_mimic_strictBT2 -[[ "$par_softclip" == "false" ]] && unset par_softclip -[[ "$par_softclip_overhangs" == "false" ]] && unset par_softclip_overhangs -[[ "$par_full_length_alignment" == "false" ]] && unset par_full_length_alignment -[[ "$par_hard_filter" == "false" ]] && unset par_hard_filter -[[ "$par_write_mappings" == "false" ]] && unset par_write_mappings -[[ "$par_write_qualities" == "false" ]] && unset par_write_qualities -[[ "$par_alternative_init_mode" == "false" ]] && unset par_alternative_init_mode -[[ "$par_skip_quant" == "false" ]] && unset par_skip_quant -[[ "$par_dump_eq" == "false" ]] && unset par_dump_eq -[[ "$par_dump_eq_weights" == "false" ]] && unset par_dump_eq_weights -[[ "$par_reduce_GC_memory" == "false" ]] && unset par_reduce_GC_memory -[[ "$par_init_uniform" == "false" ]] && unset par_init_uniform -[[ "$par_no_length_correction" == "false" ]] && unset par_no_length_correction -[[ "$par_no_effective_length_correction" == "false" ]] && unset par_no_effective_length_correction -[[ "$par_no_single_frag_prob" == "false" ]] && unset par_no_single_frag_prob -[[ "$par_no_frag_length_dist" == "false" ]] && unset par_no_frag_length_dist -[[ "$par_no_bias_length_threshold" == "false" ]] && unset par_no_bias_length_threshold -[[ "$par_useEM" == "false" ]] && unset par_useEM -[[ "$par_useVBOpt" == "false" ]] && unset par_useVBOpt -[[ "$par_no_Gamma_draw" == "false" ]] && unset par_no_Gamma_draw -[[ "$par_bootstrap_reproject" == "false" ]] && unset par_bootstrap_reproject -[[ "$par_quiet" == "false" ]] && unset par_quiet -[[ "$par_per_transcript_prior" == "false" ]] && unset par_per_transcript_prior -[[ "$par_per_nucleotide_prior" == "false" ]] && unset par_per_nucleotide_prior -[[ "$par_write_orphan_links" == "false" ]] && unset par_write_orphan_links -[[ "$par_write_unmapped_names" == "false" ]] && unset par_write_unmapped_names -[[ "$par_no_error_model" == "false" ]] && unset par_no_error_model -[[ "$par_sample_out" == "false" ]] && unset par_sample_out -[[ "$par_sample_unaligned" == "false" ]] && unset par_sample_unaligned -[[ "$par_gencode" == "false" ]] && unset par_gencode +for par in ${unset_if_false[@]}; do + test_val="${!par}" + [[ "$test_val" == "false" ]] && unset $par +done IFS=";" read -ra unmated_reads <<< $par_unmated_reads IFS=";" read -ra mates1 <<< $par_mates1 diff --git a/src/samtools/samtools_fastq/script.sh b/src/samtools/samtools_fastq/script.sh index 0cad9cfe..e05da9b0 100644 --- a/src/samtools/samtools_fastq/script.sh +++ b/src/samtools/samtools_fastq/script.sh @@ -5,11 +5,18 @@ set -e -[[ "$par_no_suffix" == "false" ]] && unset par_no_suffix -[[ "$par_suffix" == "false" ]] && unset par_suffix -[[ "$par_use_oq" == "false" ]] && unset par_use_oq -[[ "$par_copy_tags" == "false" ]] && unset par_copy_tags -[[ "$par_casava" == "false" ]] && unset par_casava +unset_if_false=( + par_no_suffix + par_suffix + par_use_oq + par_copy_tags + par_casava +) + +for par in ${unset_if_false[@]}; do + test_val="${!par}" + [[ "$test_val" == "false" ]] && unset $par +done if [[ "$meta_name" == "samtools_fasta" ]]; then subcommand=fasta diff --git a/src/samtools/samtools_sort/script.sh b/src/samtools/samtools_sort/script.sh index 94836c18..a8b3ce0f 100644 --- a/src/samtools/samtools_sort/script.sh +++ b/src/samtools/samtools_sort/script.sh @@ -5,15 +5,22 @@ set -e -[[ "$par_uncompressed" == "false" ]] && unset par_uncompressed -[[ "$par_minimiser" == "false" ]] && unset par_minimiser -[[ "$par_not_reverse" == "false" ]] && unset par_not_reverse -[[ "$par_homopolymers" == "false" ]] && unset par_homopolymers -[[ "$par_natural_sort" == "false" ]] && unset par_natural_sort -[[ "$par_ascii_sort" == "false" ]] && unset par_ascii_sort -[[ "$par_template_coordinate" == "false" ]] && unset par_template_coordinate -[[ "$par_write_index" == "false" ]] && unset par_write_index -[[ "$par_no_PG" == "false" ]] && unset par_no_PG +unset_if_false=( + par_uncompressed + par_minimiser + par_not_reverse + par_homopolymers + par_natural_sort + par_ascii_sort + par_template_coordinate + par_write_index + par_no_PG +) + +for par in ${unset_if_false[@]}; do + test_val="${!par}" + [[ "$test_val" == "false" ]] && unset $par +done samtools sort \ diff --git a/src/samtools/samtools_view/script.sh b/src/samtools/samtools_view/script.sh index c3911b48..7608844b 100644 --- a/src/samtools/samtools_view/script.sh +++ b/src/samtools/samtools_view/script.sh @@ -5,21 +5,29 @@ set -e -[[ "$par_bam" == "false" ]] && unset par_bam -[[ "$par_cram" == "false" ]] && unset par_cram -[[ "$par_fast" == "false" ]] && unset par_fast -[[ "$par_uncompressed" == "false" ]] && unset par_uncompressed -[[ "$par_with_header" == "false" ]] && unset par_with_header -[[ "$par_header_only" == "false" ]] && unset par_header_only -[[ "$par_no_header" == "false" ]] && unset par_no_header -[[ "$par_count" == "false" ]] && unset par_count -[[ "$par_unmap" == "false" ]] && unset par_unmap -[[ "$par_use_index" == "false" ]] && unset par_use_index -[[ "$par_fetch_pairs" == "false" ]] && unset par_fetch_pairs -[[ "$par_customized_index" == "false" ]] && unset par_customized_index -[[ "$par_no_PG" == "false" ]] && unset par_no_PG -[[ "$par_write_index" == "false" ]] && unset par_write_index -[[ "$par_remove_B" == "false" ]] && unset par_remove_B +unset_if_false=( + par_bam + par_cram + par_fast + par_uncompressed + par_with_header + par_header_only + par_no_header + par_count + par_unmap + par_use_index + par_fetch_pairs + par_customized_index + par_no_PG + par_write_index + par_remove_B +) + +for par in ${unset_if_false[@]}; do + test_val="${!par}" + [[ "$test_val" == "false" ]] && unset $par +done + samtools view \ ${par_bam:+-b} \ diff --git a/src/umi_tools/umi_tools_dedup/script.sh b/src/umi_tools/umi_tools_dedup/script.sh index d57a5e76..3f3bdc89 100644 --- a/src/umi_tools/umi_tools_dedup/script.sh +++ b/src/umi_tools/umi_tools_dedup/script.sh @@ -7,19 +7,26 @@ set -e test_dir="${metal_executable}/test_data" -[[ "$par_paired" == "false" ]] && unset par_paired -[[ "$par_in_sam" == "false" ]] && unset par_in_sam -[[ "$par_out_sam" == "false" ]] && unset par_out_sam -[[ "$par_spliced_is_unique" == "false" ]] && unset par_spliced_is_unique -[[ "$par_per_gene" == "false" ]] && unset par_per_gene -[[ "$par_per_contig" == "false" ]] && unset par_per_contig -[[ "$par_per_cell" == "false" ]] && unset par_per_cell -[[ "$par_no_sort_output" == "false" ]] && unset par_no_sort_output -[[ "$par_buffer_whole_contig" == "false" ]] && unset par_buffer_whole_contig -[[ "$par_ignore_umi" == "false" ]] && unset par_ignore_umi -[[ "$par_subset" == "false" ]] && unset par_subset -[[ "$par_log2stderr" == "false" ]] && unset par_log2stderr -[[ "$par_read_length" == "false" ]] && unset par_read_length +unset_if_false=( + par_paired + par_in_sam + par_out_sam + par_spliced_is_unique + par_per_gene + par_per_contig + par_per_cell + par_no_sort_output + par_buffer_whole_contig + par_ignore_umi + par_subset + par_log2stderr + par_read_length +) + +for par in ${unset_if_false[@]}; do + test_val="${!par}" + [[ "$test_val" == "false" ]] && unset $par +done umi_tools dedup \ --stdin "$par_input" \ diff --git a/src/umi_tools/umi_tools_extract/script.sh b/src/umi_tools/umi_tools_extract/script.sh index 5e41865d..4514860e 100644 --- a/src/umi_tools/umi_tools_extract/script.sh +++ b/src/umi_tools/umi_tools_extract/script.sh @@ -5,14 +5,19 @@ set -exo pipefail -test_dir="${metal_executable}/test_data" +unset_if_false=( + par_error_correct_cell + par_reconcile_pairs + par_three_prime + par_ignore_read_pair_suffixes + par_timeit_header + par_log2stderr +) -[[ "$par_error_correct_cell" == "false" ]] && unset par_error_correct_cell -[[ "$par_reconcile_pairs" == "false" ]] && unset par_reconcile_pairs -[[ "$par_three_prime" == "false" ]] && unset par_three_prime -[[ "$par_ignore_read_pair_suffixes" == "false" ]] && unset par_ignore_read_pair_suffixes -[[ "$par_timeit_header" == "false" ]] && unset par_timeit_header -[[ "$par_log2stderr" == "false" ]] && unset par_log2stderr +for par in ${unset_if_false[@]}; do + test_val="${!par}" + [[ "$test_val" == "false" ]] && unset $par +done # Check if we have the correct number of input files and patterns for paired-end or single-end reads