[med-svn] [Git][med-team/sortmerna][master] d/tests: run the binary end-to-end against the upstream test data
Andreas Tille (@tille)
gitlab at salsa.debian.org
Mon Oct 19 19:49:52 BST 2026
Andreas Tille pushed to branch master at Debian Med / sortmerna
Commits:
ac280c2d by Andreas Tille at 2026-10-19T18:00:45+02:00
d/tests: run the binary end-to-end against the upstream test data
Replace the disabled, indexdb_rna-based checks with real invocations of
the packaged sortmerna binary: the upstream tiny and small data sets are
aligned and compared byte-for-byte with the golden FASTA, SAM and BLAST
outputs, and a gzip-compressed reads file exercises the rapidarchive
decompression path. This allows dropping the superficial restriction.
Closes: #1072346
- - - - -
5 changed files:
- debian/changelog
- debian/examples
- debian/rules
- debian/tests/control
- debian/tests/run-unit-test
Changes:
=====================================
debian/changelog
=====================================
@@ -18,6 +18,10 @@ sortmerna (7.1.0-1) UNRELEASED; urgency=medium
which needs static parasail/rocksdb not available in Debian
* d/copyright: drop the ssw.c stanza, SSW was removed upstream
* d/man/sortmerna.1: update for the 7.1.0 command line
+ * d/tests: rewrite the autopkgtest to run the binary end-to-end against the
+ upstream tiny/small reference data (FASTA, SAM, BLAST and gzip input) and
+ drop the "superficial" restriction.
+ Closes: #1072346
-- Andreas Tille <tille at debian.org> Mon, 19 Oct 2026 14:40:30 +0200
=====================================
debian/examples
=====================================
@@ -1 +1,2 @@
-tests/sortmerna/*
\ No newline at end of file
+tests/sortmerna
+tests/golden
=====================================
debian/rules
=====================================
@@ -28,7 +28,7 @@ execute_after_dh_installexamples:
; for cxxfile in *.cpp \
; do iconv -f ISO-8859-15 -t UTF-8 \
< $${cxxfile} \
- > $(DTMP)/usr/share/doc/sortmerna/examples/$${cxxfile} \
+ > $(DTMP)/usr/share/doc/sortmerna/examples/sortmerna/$${cxxfile} \
; done
execute_after_dh_fixperms:
=====================================
debian/tests/control
=====================================
@@ -1,3 +1,3 @@
Tests: run-unit-test
-Depends: @
-Restrictions: allow-stderr, superficial
+Depends: @, diffutils
+Restrictions: allow-stderr
=====================================
debian/tests/run-unit-test
=====================================
@@ -1,199 +1,108 @@
#!/bin/bash
set -e
+set -o pipefail
pkg=sortmerna
export LC_ALL=C.UTF-8
+
+SRC=$(pwd)
+
if [ "${AUTOPKGTEST_TMP}" = "" ] ; then
AUTOPKGTEST_TMP=$(mktemp -d /tmp/${pkg}-test.XXXXXX)
- # Double quote below to expand the temporary directory variable now versus
- # later is on purpose.
- # shellcheck disable=SC2064
trap "rm -rf ${AUTOPKGTEST_TMP}" 0 INT QUIT ABRT PIPE TERM
fi
cp -a /usr/share/doc/${pkg}/examples/* "${AUTOPKGTEST_TMP}"
+# test_data is to large to bloat the package examples
+cp -a "test_data" "${AUTOPKGTEST_TMP}"
cd "${AUTOPKGTEST_TMP}"
-gunzip -r *
-mkdir temp output
-
-echo '=== Test 0 (superficial verifications) ==='
-sortmerna --version
-sortmerna -h
-# FIXME: following test items have become irrelevant with contemporary
-# sortmerna usage. Ideally these should be updated so it is possible to
-# drop the superficial marking associated to the present autopkgtest.
-# In the meantime, tests are stopped at this early point.
-exit
-
-echo === Test 1 ===
-echo Writing to --tmpdir
-indexdb_rna --ref data/ref_GQ099317_forward_and_rc.fasta,output/test1 --tmpdir temp
-if [ -f output/test1.kmer_0.dat ] && \
- [ -f output/test1.bursttrie_0.dat ] && \
- [ -f output/test1.pos_0.dat ] && \
- [ -f output/test1.stats ]; then
- echo PASS
-else
- echo FAIL
-fi
-
-echo
-echo === Test 2 ===
-echo Indexing a database using SortMeRNA
-indexdb_rna --ref data/gg_13_8_ref_set.fasta,output/test2
-if [ -f output/test2.kmer_0.dat ] && \
- [ -f output/test2.bursttrie_0.dat ] && \
- [ -f output/test2.pos_0.dat ] && \
- [ -f output/test2.stats ]; then
- echo PASS
-else
- echo FAIL
-fi
-
-echo
-echo === Test 3 ===
-echo Test indexing a database using SortMeRNA with m = 0.05, that is 7 parts
-indexdb_rna --ref data/gg_13_8_ref_set.fasta,output/test3 -m 0.05
-if [ -f output/test3.kmer_0.dat ] && \
- [ -f output/test3.kmer_1.dat ] && \
- [ -f output/test3.kmer_2.dat ] && \
- [ -f output/test3.kmer_3.dat ] && \
- [ -f output/test3.kmer_4.dat ] && \
- [ -f output/test3.kmer_5.dat ] && \
- [ -f output/test3.kmer_6.dat ] && \
- [ -f output/test3.bursttrie_0.dat ] && \
- [ -f output/test3.bursttrie_1.dat ] && \
- [ -f output/test3.bursttrie_2.dat ] && \
- [ -f output/test3.bursttrie_3.dat ] && \
- [ -f output/test3.bursttrie_4.dat ] && \
- [ -f output/test3.bursttrie_5.dat ] && \
- [ -f output/test3.bursttrie_6.dat ] && \
- [ -f output/test3.pos_0.dat ] && \
- [ -f output/test3.pos_1.dat ] && \
- [ -f output/test3.pos_2.dat ] && \
- [ -f output/test3.pos_3.dat ] && \
- [ -f output/test3.pos_4.dat ] && \
- [ -f output/test3.pos_5.dat ] && \
- [ -f output/test3.pos_6.dat ] && \
- [ -f output/test3.stats ]; then
- echo PASS
-else
- echo FAIL
-fi
-
-echo
-echo Generating index files for the remaining tests.
-# Tests 4, 5, 6
-indexdb_rna --ref data/silva-bac-16s-database-id85.fasta,output/bac.idx:data/silva-arc-16s-database-id95.fasta,output/arc.idx
-# Tests 7 and 8
-indexdb_rna --ref data/silva-bac-16s-database-id85.fasta,output/bac_250.idx --max_pos 250
-# Test 9
-indexdb_rna --ref data/ref_GQ099317_forward_and_rc.fasta,output/GQ099317.idx
-echo Done
-
+fail() {
+ echo "FAIL: $*" >&2
+ exit 1
+}
+
+# compare_golden <produced> <golden> <description>
+compare_golden() {
+ if ! diff -u "$2" "$1" ; then
+ fail "$3"
+ fi
+ echo "PASS: $3"
+}
+
+# The arguments below are the ones that produced the upstream golden files,
+# as recorded in the @PG line of tests/golden/*/aligned.sam.
+echo "=== Test 1: tiny database, FASTA/FASTQ, SAM and BLAST output ==="
+sortmerna --ref test_data/test_ref.fasta \
+ --reads test_data/test_read.fasta \
+ --workdir WORKDIR \
+ --aligned WORKDIR/aligned \
+ --other WORKDIR/other \
+ --threads 1 --num_alignments 1 --blast "1 cigar qcov" \
+ --fastx --sam --match 2 --mismatch -3 --gap_open 5 \
+ --gap_ext 2 -N -3 -L 18
+
+for f in aligned.fa aligned.blast aligned.sam ; do
+ [ -f "WORKDIR/${f}" ] || fail "missing WORKDIR/${f}"
+done
+compare_golden WORKDIR/aligned.fa \
+ "${SRC}/tests/golden/tiny/aligned.fa" \
+ "tiny: aligned.fa matches golden output"
+compare_golden WORKDIR/aligned.blast \
+ "${SRC}/tests/golden/tiny/aligned.blast" \
+ "tiny: aligned.blast matches golden output"
+# The SAM header contains the command line and is not part of the comparison.
+grep -v '^@' WORKDIR/aligned.sam > sam_tiny.got
+grep -v '^@' "${SRC}/tests/golden/tiny/aligned.sam" > sam_tiny.exp
+compare_golden sam_tiny.got sam_tiny.exp \
+ "tiny: aligned.sam matches golden output"
echo
-echo === Test 4 ===
-echo Test sortmerna on 3 reads against arc-16s and bac-16s databases.
-echo 2/3 reads match both arc-16s and bac-16s and 1/3 is a random read.
-sortmerna --ref data/silva-bac-16s-database-id85.fasta,output/bac.idx:data/silva-arc-16s-database-id95.fasta,output/arc.idx \
- --aligned output/test4aligned \
- --reads data/set7_arc_bac_16S_database_match.fasta \
- --log --fastx
-if [ -f output/test4aligned.fasta ] && \
- [ -f output/test4aligned.log ]; then
- echo PASS
-else
- echo FAIL
-fi
+echo "=== Test 2: small database, aligned and non-aligned output ==="
+sortmerna --ref test_data/silva-arc-16s-database-id95.fasta \
+ --reads test_data/set7_arc_bac_16S_database_match.fasta \
+ --workdir WORKDIR2 \
+ --aligned WORKDIR2/aligned \
+ --other WORKDIR2/other \
+ --threads 1 --num_alignments 1 --blast "1 cigar qcov" \
+ --fastx --sam --match 2 --mismatch -3 --gap_open 5 \
+ --gap_ext 2 -N -3 -L 18
+
+for f in aligned.fa aligned.blast aligned.sam other.fa ; do
+ [ -f "WORKDIR2/${f}" ] || fail "missing WORKDIR2/${f}"
+done
+compare_golden WORKDIR2/aligned.fa \
+ "${SRC}/tests/golden/small/aligned.fa" \
+ "small: aligned.fa matches golden output"
+compare_golden WORKDIR2/aligned.blast \
+ "${SRC}/tests/golden/small/aligned.blast" \
+ "small: aligned.blast matches golden output"
+grep -v '^@' WORKDIR2/aligned.sam > sam_small.got
+grep -v '^@' "${SRC}/tests/golden/small/aligned.sam" > sam_small.exp
+compare_golden sam_small.got sam_small.exp \
+ "small: aligned.sam matches golden output"
+compare_golden WORKDIR2/other.fa \
+ "${SRC}/tests/golden/small/other.fa" \
+ "small: other.fa matches golden output"
echo
-echo === Test 5 ===
-echo Test sortmerna on simulated data, 10000 reads with 1% error - --aligned,
-echo 10000 reads with 10% error - de novo, 10000 reads random - --other
-echo Conditions: reference index and input query FASTA file both processed as one section.
-sortmerna --ref data/silva-bac-16s-database-id85.fasta,output/bac.idx \
- --aligned output/test5aligned --other output/test5other \
- --reads data/set5_simulated_amplicon_silva_bac_16s.fasta \
- --id 0.97 --coverage 0.97 --log --otu_map --de_novo_otu --blast "1 cigar qcov" --fastx
-if [ -f output/test5aligned.blast ] && \
- [ -f output/test5aligned.fasta ] && \
- [ -f output/test5aligned.log ] && \
- [ -f output/test5aligned_denovo.fasta ] && \
- [ -f output/test5aligned_otus.txt ] && \
- [ -f output/test5other.fasta ]; then
- echo PASS
-else
- echo FAIL
-fi
+echo "=== Test 3: gzip-compressed reads (rapidarchive) ==="
+gzip -c test_data/test_read.fasta > reads.fasta.gz
+sortmerna --ref test_data/test_ref.fasta \
+ --reads reads.fasta.gz \
+ --workdir WORKDIR3 \
+ --aligned WORKDIR3/aligned \
+ --other WORKDIR3/other \
+ --threads 1 --num_alignments 1 --blast "1 cigar qcov" \
+ --fastx --sam --match 2 --mismatch -3 --gap_open 5 \
+ --gap_ext 2 -N -3 -L 18 --zip-out 0
+
+[ -f WORKDIR3/aligned.fa ] || fail "missing WORKDIR3/aligned.fa"
+compare_golden WORKDIR3/aligned.fa \
+ "${SRC}/tests/golden/tiny/aligned.fa" \
+ "gzip: decompressed reads produce the golden alignment"
echo
-echo === Test 6 ===
-echo Test sortmerna on simulated data, 10000 reads with 1% error - --aligned,
-echo 10000 reads with 10% error - de novo, 10000 reads random - --other
-echo Conditions: reference index processed as one unit and input query FASTA file in 6 sections.
-sortmerna --ref data/silva-bac-16s-database-id85.fasta,output/bac.idx \
- --aligned output/test6aligned --other output/test6other \
- --reads data/set5_simulated_amplicon_silva_bac_16s.fasta \
- --id 0.97 --coverage 0.97 --log --otu_map --de_novo_otu --blast "1 cigar qcov" --fastx -m 1
-if [ -f output/test6aligned.blast ] && \
- [ -f output/test6aligned.fasta ] && \
- [ -f output/test6aligned.log ] && \
- [ -f output/test6aligned_denovo.fasta ] && \
- [ -f output/test6aligned_otus.txt ] && \
- [ -f output/test6other.fasta ]; then
- echo PASS
-else
- echo FAIL
-fi
-
-echo
-echo === Test 7 ===
-echo Test outputting FASTA file for de novo clustering using environmental data.
-echo Conditions: input FASTA file is processed in one mapped section.
-sortmerna --ref data/silva-bac-16s-database-id85.fasta,output/bac_250.idx \
- --aligned output/test7aligned --id 0.97 --coverage 0.97 --log \
- --otu_map --de_novo_otu --fastx --reads data/set2_environmental_study_550_amplicon.fasta
-if [ -f output/test7aligned.fasta ] && \
- [ -f output/test7aligned.log ] && \
- [ -f output/test7aligned_denovo.fasta ] && \
- [ -f output/test7aligned_otus.txt ]; then
- echo PASS
-else
- echo FAIL
-fi
-
-echo
-echo === Test 8 ===
-echo Test outputting FASTQ files for merged mate pair reads.
-sortmerna --ref data/silva-bac-16s-database-id85.fasta,output/bac_250.idx \
- --aligned output/test8aligned --other output/test8nonaligned \
- --fastx --reads data/set4_mate_pairs_metatranscriptomics.fastq --log
-sortmerna --ref data/silva-bac-16s-database-id85.fasta,output/bac_250.idx \
- --aligned output/test8aligned --other output/test8nonaligned \
- --paired_in --fastx --reads data/set4_mate_pairs_metatranscriptomics.fastq --log
-sortmerna --ref data/silva-bac-16s-database-id85.fasta,output/bac_250.idx \
- --aligned output/test8aligned --other output/test8nonaligned \
- --paired_out --fastx --reads data/set4_mate_pairs_metatranscriptomics.fastq --log
-if [ -f output/test8aligned.fastq ] && \
- [ -f output/test8aligned.log ] && \
- [ -f output/test8nonaligned.fastq ]; then
- echo PASS
-else
- echo FAIL
-fi
-
-echo
-echo === Test 9 ===
-echo Test SortMeRNAs option --num_alignments 0 which should
-echo search both forward and reverse-complement query for alignments
-sortmerna --ref data/ref_GQ099317_forward_and_rc.fasta,output/GQ099317.idx \
- --aligned output/test9aligned --reads data/illumina_GQ099317.fasta --num_alignments 0 --sam
-if [ -f output/test9aligned.sam ]; then
- echo PASS
-else
- echo FAIL
-fi
+echo "All tests passed."
View it on GitLab: https://salsa.debian.org/med-team/sortmerna/-/commit/ac280c2d10ca081b6dda60f8063c691e4dd59403
--
View it on GitLab: https://salsa.debian.org/med-team/sortmerna/-/commit/ac280c2d10ca081b6dda60f8063c691e4dd59403
You're receiving this email because of your account on salsa.debian.org. Manage all notifications: https://salsa.debian.org/-/profile/notifications | Help: https://salsa.debian.org/help
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20261019/56a2087d/attachment-0001.htm>
More information about the debian-med-commit
mailing list