Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tgaspe committed Aug 28, 2024
1 parent 43f6bf2 commit bb0f817
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 9 deletions.
3 changes: 1 addition & 2 deletions src/bcftools/bcftools_annotate/config.vsh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ argument_groups:
- name: --rename_annotations
type: file
description: |
rename annotations according to the map in file, with "old_name new_name\n" pairs separated by whitespaces,
each on a separate line. The old name must be prefixed with the annotation type: INFO, FORMAT, or FILTER.
Rename annotations: TYPE/old\tnew, where TYPE is one of FILTER,INFO,FORMAT.
- name: --rename_chromosomes
type: file
Expand Down
4 changes: 2 additions & 2 deletions src/bcftools/bcftools_annotate/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ bcftools annotate \
${par_regions:+-r "$par_regions"} \
${par_regions_file:+-R "$par_regions_file"} \
${par_regions_overlap:+--regions-overlap "$par_regions_overlap"} \
${par_rename_annotations:+--rename-annotations "$par_rename_annotations"} \
${par_rename_chromosomes:+--rename-chromosomes "$par_rename_chromosomes"} \
${par_rename_annotations:+--rename-annots "$par_rename_annotations"} \
${par_rename_chromosomes:+--rename-chrs "$par_rename_chromosomes"} \
${par_samples:+-s "$par_samples"} \
${par_single_overlaps:+--single-overlaps} \
${par_threads:+--threads "$par_threads"} \
Expand Down
68 changes: 63 additions & 5 deletions src/bcftools/bcftools_annotate/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ cat <<EOF > "$TMPDIR/annots.tsv"
1 752722 752722 FooValue2 67890
EOF

cat <<EOF > "$TMPDIR/rename.tsv"
INFO/. Luigi
EOF

bgzip $TMPDIR/annots.tsv
tabix -s1 -b2 -e3 $TMPDIR/annots.tsv.gz

Expand All @@ -55,14 +59,19 @@ cat <<EOF > "$TMPDIR/header.hdr"
##INFO=<ID=BAR,Number=1,Type=Integer,Description="Some description">
EOF

cat <<EOF > "$TMPDIR/rename_chrm.tsv"
1 chr1
2 chr2
EOF

# Test 1: Remove ID annotations
mkdir "$TMPDIR/test1" && pushd "$TMPDIR/test1" > /dev/null

echo "> Run bcftools_annotate remove annotations"
"$meta_executable" \
--input "../example.vcf" \
--output "annotated.vcf" \
--remove "ID"
--remove "ID" \

# checks
assert_file_exists "annotated.vcf"
Expand Down Expand Up @@ -108,10 +117,59 @@ echo "- test3 succeeded -"

popd > /dev/null

# echo
# cat "annotated.vcf"
# echo
# exit 0
# Test 4:
mkdir "$TMPDIR/test4" && pushd "$TMPDIR/test4" > /dev/null

echo "> Run bcftools_annotate with --rename-annotations option"
"$meta_executable" \
--input "../example.vcf" \
--output "annotated.vcf" \
--rename_annotations "../rename.tsv"

# checks
assert_file_exists "annotated.vcf"
assert_file_not_empty "annotated.vcf"
assert_file_contains "annotated.vcf" "##bcftools_annotateCommand=annotate --rename-annots ../rename.tsv -o annotated.vcf"
echo "- test4 succeeded -"

popd > /dev/null

# Test 5: Rename chromosomes
mkdir "$TMPDIR/test5" && pushd "$TMPDIR/test5" > /dev/null

echo "> Run bcftools_annotate with --rename-chromosomes option"
"$meta_executable" \
--input "../example.vcf" \
--output "annotated.vcf" \
--rename_chromosomes "../rename_chrm.tsv"

# checks
assert_file_exists "annotated.vcf"
assert_file_not_empty "annotated.vcf"
assert_file_contains "annotated.vcf" "chr1"
echo "- test5 succeeded -"

popd > /dev/null

# Test 6: Sample option
mkdir "$TMPDIR/test6" && pushd "$TMPDIR/test6" > /dev/null

echo "> Run bcftools_annotate with -s option"
"$meta_executable" \
--input "../example.vcf" \
--output "annotated.vcf" \
--samples "SAMPLE1"

# checks
assert_file_exists "annotated.vcf"
assert_file_not_empty "annotated.vcf"
assert_file_contains "annotated.vcf" "##bcftools_annotateCommand=annotate -s SAMPLE1 -o annotated.vcf ../example.vcf"
echo "- test6 succeeded -"

popd > /dev/null




echo "---- All tests succeeded! ----"
exit 0

0 comments on commit bb0f817

Please sign in to comment.