Skip to content

Commit

Permalink
Update changelog flagstats
Browse files Browse the repository at this point in the history
  • Loading branch information
emmarousseau committed Mar 29, 2024
1 parent ae3164e commit 8a5d9d7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@

* `star/star_align_reads`: Align reads to a reference genome (PR #22).

* `samtools`:
- `samtools/flagstat`: Counts the number of alignments in SAM/BAM/CRAM files for each FLAG type (PR #31).

## MAJOR CHANGES

## MINOR CHANGES
Expand Down
2 changes: 1 addition & 1 deletion src/samtools/flagstat/config.vsh.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: samtools_flagstat
namespace: samtools
description: Counts the number of alignments in SAM/BAM/CRAM files for each FLAG type..
description: Counts the number of alignments in SAM/BAM/CRAM files for each FLAG type.
keywords: [ stats, mapping, counts, bam, sam, cram]
links:
homepage: https://www.htslib.org/
Expand Down
29 changes: 15 additions & 14 deletions src/samtools/flagstat/test.sh
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
#!/bin/bash

test_dir="${meta_resources_dir}test_data"
echo ">>> Testing $meta_functionality_name"

"$meta_executable" \
--bam "$meta_resources_dir/test_data/a.bam" \
--bai "$meta_resources_dir/test_data/a.bam.bai" \
--output "$meta_resources_dir/test_data/a.flagstat"
--bam "$test_dir/a.bam" \
--bai "$test_dir/a.bam.bai" \
--output "$test_dir/a.flagstat"

echo ">>> Checking whether output exists"
[ ! -f "$meta_resources_dir/test_data/a.flagstat" ] && echo "File 'a.flagstat' does not exist!" && exit 1
[ ! -f "$test_dir/a.flagstat" ] && echo "File 'a.flagstat' does not exist!" && exit 1

echo ">>> Checking whether output is non-empty"
[ ! -s "$meta_resources_dir/test_data/a.flagstat" ] && echo "File 'a.flagstat' is empty!" && exit 1
[ ! -s "$test_dir/a.flagstat" ] && echo "File 'a.flagstat' is empty!" && exit 1

echo ">>> Checking whether output is correct"
diff "$meta_resources_dir/test_data/a.flagstat" "$meta_resources_dir/test_data/a_ref.flagstat" || \
diff "$test_dir/a.flagstat" "$test_dir/a_ref.flagstat" || \
(echo "Output file chr19.flagstat does not match expected output" && exit 1)

rm "$meta_resources_dir/test_data/a.flagstat"
rm "$test_dir/a.flagstat"

############################################################################################

echo ">>> Testing $meta_functionality_name with singletons in the input"

"$meta_executable" \
--bam "$meta_resources_dir/test_data/test.paired_end.sorted.bam" \
--bai "$meta_resources_dir/test_data/test.paired_end.sorted.bam.bai" \
--output "$meta_resources_dir/test_data/test.paired_end.sorted.flagstat"
--bam "$test_dir/test.paired_end.sorted.bam" \
--bai "$test_dir/test.paired_end.sorted.bam.bai" \
--output "$test_dir/test.paired_end.sorted.flagstat"

echo ">>> Checking whether output exists"
[ ! -f "$meta_resources_dir/test_data/test.paired_end.sorted.flagstat" ] && echo "File 'test.paired_end.sorted.flagstat' does not exist!" && exit 1
[ ! -f "$test_dir/test.paired_end.sorted.flagstat" ] && echo "File 'test.paired_end.sorted.flagstat' does not exist!" && exit 1

echo ">>> Checking whether output is non-empty"
[ ! -s "$meta_resources_dir/test_data/test.paired_end.sorted.flagstat" ] && echo "File 'test.paired_end.sorted.flagstat' is empty!" && exit 1
[ ! -s "$test_dir/test.paired_end.sorted.flagstat" ] && echo "File 'test.paired_end.sorted.flagstat' is empty!" && exit 1

echo ">>> Checking whether output is correct"
diff "$meta_resources_dir/test_data/test.paired_end.sorted.flagstat" "$meta_resources_dir/test_data/test_ref.paired_end.sorted.flagstat" || \
diff "$test_dir/test.paired_end.sorted.flagstat" "$test_dir/test_ref.paired_end.sorted.flagstat" || \
(echo "Output file chr19.flagstat does not match expected output" && exit 1)

rm "$meta_resources_dir/test_data/test.paired_end.sorted.flagstat"
rm "$test_dir/test.paired_end.sorted.flagstat"


echo "All tests succeeded!"
Expand Down

0 comments on commit 8a5d9d7

Please sign in to comment.