Skip to content

Commit

Permalink
Add test from nf-core
Browse files Browse the repository at this point in the history
  • Loading branch information
emmarousseau committed Mar 24, 2024
1 parent 9d90924 commit ae3164e
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
23 changes: 21 additions & 2 deletions src/samtools/flagstat/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,27 @@ diff "$meta_resources_dir/test_data/a.flagstat" "$meta_resources_dir/test_data/a

rm "$meta_resources_dir/test_data/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"

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

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

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" || \
(echo "Output file chr19.flagstat does not match expected output" && exit 1)

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


echo
echo "All tests succeeded!"
exit 0
11 changes: 10 additions & 1 deletion src/samtools/flagstat/test_data/script.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
#!/bin/bash

# Download test data from snakemake wrapper

wget https://raw.githubusercontent.com/snakemake/snakemake-wrappers/3a4f7004281efc176fd9af732ad88d00c47d432d/bio/samtools/flagstat/test/mapped/a.bam
samtools index a.bam
samtools index a.bam
# samtools flagstat a.bam > a_ref.flagstat


# Download test data from nf-core module

wget https://github.com/nf-core/test-datasets/raw/modules/data/genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam
wget https://github.com/nf-core/test-datasets/raw/modules/data/genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam.bai
# samtools flagstat test.paired_end.sorted.bam > test_ref.paired_end.sorted.flagstat
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
200 + 0 in total (QC-passed reads + QC-failed reads)
0 + 0 secondary
0 + 0 supplementary
0 + 0 duplicates
197 + 0 mapped (98.50% : N/A)
200 + 0 paired in sequencing
100 + 0 read1
100 + 0 read2
192 + 0 properly paired (96.00% : N/A)
194 + 0 with itself and mate mapped
3 + 0 singletons (1.50% : N/A)
0 + 0 with mate mapped to a different chr
0 + 0 with mate mapped to a different chr (mapQ>=5)

0 comments on commit ae3164e

Please sign in to comment.