diff --git a/src/bcftools/bcftools_concat/config.vsh.yaml b/src/bcftools/bcftools_concat/config.vsh.yaml index a092c20f..601c8417 100644 --- a/src/bcftools/bcftools_concat/config.vsh.yaml +++ b/src/bcftools/bcftools_concat/config.vsh.yaml @@ -30,8 +30,12 @@ argument_groups: alternatives: -i type: file multiple: true - description: Input VCF/BCF file. - required: true + description: Input VCF/BCF files to concatenate. + + - name: --file_list + alternatives: -f + type: file + description: Read the list of VCF/BCF files from a file, one file name per line. - name: Outputs arguments: @@ -60,14 +64,9 @@ argument_groups: - name: --remove_duplicates alternatives: -d type: string - choices: ['snps', 'indels', 'both', 'all', 'exact'] + choices: ['snps', 'indels', 'both', 'all', 'exact', 'none'] description: | Output duplicate records present in multiple files only once: . - - - name: --file_list - alternatives: -f - type: file - description: Read the list of files from a file. - name: --ligate alternatives: -l diff --git a/src/bcftools/bcftools_concat/script.sh b/src/bcftools/bcftools_concat/script.sh index df593a42..bcf6f2c5 100644 --- a/src/bcftools/bcftools_concat/script.sh +++ b/src/bcftools/bcftools_concat/script.sh @@ -23,6 +23,12 @@ for par in ${unset_if_false[@]}; do [[ "$test_val" == "false" ]] && unset $par done +# Check to see whether the par_input or the par_file_list is set +if [[ -z "${par_input}" && -z "${par_file_list}" ]]; then + echo "Error: One of the parameters '--input' or '--file_list' must be used." + exit 1 +fi + # Create input array IFS=";" read -ra input <<< $par_input @@ -31,7 +37,6 @@ bcftools concat \ ${par_allow_overlaps:+-a} \ ${par_compact_PS:+-c} \ ${par_remove_duplicates:+-d "$par_remove_duplicates"} \ - ${par_file_list:+-f "$par_file_list"} \ ${par_ligate:+-l} \ ${par_ligate_force:+--ligate-force} \ ${par_ligate_warn:+--ligate-warn} \ @@ -46,4 +51,5 @@ bcftools concat \ ${meta_cpus:+--threads "$meta_cpus"} \ ${par_verbose:+-v "$par_verbose"} \ -o $par_output \ + ${par_file_list:+-f "$par_file_list"} \ ${input[@]} \ \ No newline at end of file diff --git a/src/bcftools/bcftools_concat/test.sh b/src/bcftools/bcftools_concat/test.sh index 00e6fedc..50f97ada 100644 --- a/src/bcftools/bcftools_concat/test.sh +++ b/src/bcftools/bcftools_concat/test.sh @@ -39,7 +39,7 @@ cat < "$TMPDIR/example.vcf" ##contig= #CHROM POS ID REF ALT QUAL FILTER INFO FORMAT SAMPLE1 1 752567 llama G C,A . . . . 1/2 -1 752722 . G A,AAA . . . . ./. +1 752752 . G A,AAA . . . . ./. EOF bgzip -c $TMPDIR/example.vcf > $TMPDIR/example.vcf.gz @@ -53,6 +53,14 @@ cat < "$TMPDIR/example_2.vcf" 1 752739 . G A,AAA . . . . ./. EOF +bgzip -c $TMPDIR/example_2.vcf > $TMPDIR/example_2.vcf.gz +tabix -p vcf $TMPDIR/example_2.vcf.gz + +cat < "$TMPDIR/file_list.txt" +$TMPDIR/example.vcf.gz +$TMPDIR/example_2.vcf.gz +EOF + # Test 1: Default test mkdir "$TMPDIR/test1" && pushd "$TMPDIR/test1" > /dev/null @@ -72,6 +80,66 @@ echo "- test1 succeeded -" popd > /dev/null +# Test 2: Allow overlaps, compact PS and remove duplicates +mkdir "$TMPDIR/test2" && pushd "$TMPDIR/test2" > /dev/null + +echo "> Run bcftools_concat test with allow overlaps, and remove duplicates" +"$meta_executable" \ + --input "../example.vcf.gz" \ + --input "../example_2.vcf.gz" \ + --output "concatenated.vcf" \ + --allow_overlaps \ + --remove_duplicates 'none' \ +# &> /dev/null + +# checks +assert_file_exists "concatenated.vcf" +assert_file_not_empty "concatenated.vcf" +assert_file_contains "concatenated.vcf" "concat -a -d none -o concatenated.vcf ../example.vcf.gz ../example_2.vcf.gz" +echo "- test2 succeeded -" + +popd > /dev/null + + +# Test 3: Ligate, ligate force and ligate warn +mkdir "$TMPDIR/test3" && pushd "$TMPDIR/test3" > /dev/null + +echo "> Run bcftools_concat test with ligate, ligate force and ligate warn" +"$meta_executable" \ + --input "../example.vcf.gz" \ + --input "../example_2.vcf.gz" \ + --output "concatenated.vcf" \ + --ligate \ + --compact_PS \ +# &> /dev/null + + +# checks +assert_file_exists "concatenated.vcf" +assert_file_not_empty "concatenated.vcf" +assert_file_contains "concatenated.vcf" "concat -c -l -o concatenated.vcf ../example.vcf.gz ../example_2.vcf.gz" +echo "- test3 succeeded -" + +popd > /dev/null + +# Test 4: file list with ligate force and ligate warn +mkdir "$TMPDIR/test4" && pushd "$TMPDIR/test4" > /dev/null + +echo "> Run bcftools_concat test with file list, ligate force and ligate warn" +"$meta_executable" \ + --file_list "../file_list.txt" \ + --output "concatenated.vcf" \ + --ligate_force \ +# &> /dev/null + +# checks +assert_file_exists "concatenated.vcf" +assert_file_not_empty "concatenated.vcf" +assert_file_contains "concatenated.vcf" "concat --ligate-force -o concatenated.vcf -f ../file_list.txt" +echo "- test4 succeeded -" + +popd > /dev/null + echo "---- All tests succeeded! ----" exit 0