From 6a07f1ebde2dd7c9b5ab34615e9e7e12c510163c Mon Sep 17 00:00:00 2001 From: emmarousseau Date: Thu, 9 May 2024 17:20:50 +0200 Subject: [PATCH] add a 4th test, fix option names in the script --- CHANGELOG.md | 2 +- src/samtools/samtools_view/config.vsh.yaml | 9 ++++++--- src/samtools/samtools_view/script.sh | 7 ++++--- src/samtools/samtools_view/test.sh | 8 ++++---- src/samtools/samtools_view/test_data/a.forward | 3 +++ 5 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 src/samtools/samtools_view/test_data/a.forward diff --git a/CHANGELOG.md b/CHANGELOG.md index 98a3b7c6..29911e86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,7 +41,7 @@ - `samtools/samtools_index`: Index SAM/BAM/CRAM files (PR #35). - `samtools/samtools_sort`: Sort SAM/BAM/CRAM files (PR #36). - `samtools/samtools_stats`: Reports alignment summary statistics for a BAM file (PR #39). - - `samtools/samtools_view`: Views and converts SAM/BAM/CRAM files (PR #45). + - `samtools/samtools_view`: Views and converts SAM/BAM/CRAM files (PR #48). ## MAJOR CHANGES diff --git a/src/samtools/samtools_view/config.vsh.yaml b/src/samtools/samtools_view/config.vsh.yaml index f9d90bc4..86ebc8a4 100644 --- a/src/samtools/samtools_view/config.vsh.yaml +++ b/src/samtools/samtools_view/config.vsh.yaml @@ -49,7 +49,6 @@ argument_groups: description: | Only output alignments overlapping the input BED FILE [null]. - name: --region_file - alternatives: --regions_file type: file description: | Use an index and multi-region iterator to only output alignments overlapping the input BED FILE. @@ -108,13 +107,13 @@ argument_groups: with a known suffix. - name: --uncompressed alternatives: -u + type: boolean_true description: | Output uncompressed data. This also changes the default output format to BAM, but this can be overridden by the explicit format options or using a filename with a known suffix. This option saves time spent on compression/decompression and is thus preferred when the output is piped to another samtools command. - type: boolean_true - name: --with_header type: boolean_true description: | @@ -135,7 +134,7 @@ argument_groups: type: boolean_true description: | Instead of printing the alignments, only count them and print the total number. - All filter options, such as --require-flags, --excl-flags, and --min-MQ, are taken + All filter options, such as --require_flags, --excl_flags, and --min_MQ, are taken into account. The --unmap option is ignored in this mode. - name: --output_unselected alternatives: -U @@ -329,6 +328,10 @@ argument_groups: type: string description: | Specify a single output file format option in the form of OPTION or OPTION=VALUE. + - name: --write_index + type: boolean_true + description: | + Automatically index the output files. resources: - type: bash_script diff --git a/src/samtools/samtools_view/script.sh b/src/samtools/samtools_view/script.sh index 30435315..5bbabf21 100644 --- a/src/samtools/samtools_view/script.sh +++ b/src/samtools/samtools_view/script.sh @@ -18,7 +18,8 @@ set -e [[ "$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 samtools view \ ${par_bam:+-b} \ @@ -48,8 +49,8 @@ samtools view \ ${par_min_qlen:+-m "$par_min_qlen"} \ ${par_expr:+-e "$par_expr"} \ ${par_require_flags:+-f "$par_require_flags"} \ - ${par_exclude_flags:+-F "$par_exclude_flags"} \ - ${par_incl_flags:+--rf "$par_include_flags"} \ + ${par_excl_flags:+-F "$par_excl_flags"} \ + ${par_incl_flags:+--rf "$par_incl_flags"} \ ${par_excl_all_flags:+-G "$par_excl_all_flags"} \ ${par_subsample:+--subsample "$par_subsample"} \ ${par_subsample_seed:+--subsample-seed "$par_subsample_seed"} \ diff --git a/src/samtools/samtools_view/test.sh b/src/samtools/samtools_view/test.sh index e7a8604b..1de29a7c 100644 --- a/src/samtools/samtools_view/test.sh +++ b/src/samtools/samtools_view/test.sh @@ -1,7 +1,7 @@ #!/bin/bash test_dir="${meta_resources_dir}/test_data" -temp_dir="${meta_resources_dir}/tmp" +temp_dir="${meta_resources_dir}/out" ############################################################################################ @@ -24,7 +24,7 @@ diff <(samtools view "$temp_dir/a.bam") <(samtools view "$test_dir/a.bam") || \ ############################################################################################ -echo ">>> Test 2: ${meta_functionality_name} with --output_format CRAM" +echo ">>> Test 2: ${meta_functionality_name} with CRAM format output" "$meta_executable" \ --cram \ @@ -67,8 +67,8 @@ echo ">>> Test 4: ${meta_functionality_name} including only the forward reads fr "$meta_executable" \ --output "$temp_dir/a.forward" \ - --excl_flags "147" \ - --input "$test_dir/a.sam" + --excl_flags "0x80" \ + --input "$test_dir/a.sam" echo ">>> Checking whether output exists" [ ! -f "$temp_dir/a.forward" ] && echo "File 'a.forward' does not exist!" && exit 1 diff --git a/src/samtools/samtools_view/test_data/a.forward b/src/samtools/samtools_view/test_data/a.forward new file mode 100644 index 00000000..766d4f20 --- /dev/null +++ b/src/samtools/samtools_view/test_data/a.forward @@ -0,0 +1,3 @@ +a1 99 xx 1 1 10M = 11 20 AAAAAAAAAA ********** +b1 99 xx 1 1 10M = 11 20 AAAAAAAAAA ********** +c1 99 xx 1 1 10M = 11 20 AAAAAAAAAA **********