Fix whitespace in test script and add merge consistency tests

This commit fixes minor whitespace issues in the test script and adds new tests to ensure merge attribute consistency between in-memory and on-disk paths.

- Removed trailing spaces in log messages
- Added tests for merge consistency between in-memory and on-disk paths
- These tests catch a bug where shared classifier in on-disk dereplication path caused incorrect merged attributes
This commit is contained in:
Eric Coissac
2026-02-08 18:08:13 +01:00
parent 1a28d5ed64
commit 08490420a2

View File

@@ -195,6 +195,59 @@ else
((failed++))
fi
##
## Test merge attributes consistency between in-memory and on-disk paths
## This test catches the bug where the shared classifier in the on-disk
## dereplication path caused incorrect merged attributes.
##
((ntest++))
if obiuniq -m a -m b --in-memory \
"${TEST_DIR}/touniq.fasta" \
> "${TMPDIR}/touniq_u_merge_mem.fasta" 2>/dev/null
then
log "OBIUniq merge in-memory: running OK"
((success++))
else
log "OBIUniq merge in-memory: running failed"
((failed++))
fi
((ntest++))
if obiuniq -m a -m b --chunk-count 4 \
"${TEST_DIR}/touniq.fasta" \
> "${TMPDIR}/touniq_u_merge_disk.fasta" 2>/dev/null
then
log "OBIUniq merge on-disk: running OK"
((success++))
else
log "OBIUniq merge on-disk: running failed"
((failed++))
fi
# Extract sorted annotations (JSON attributes) from both outputs
# to compare merge results independently of sequence ordering
grep '^>' "${TMPDIR}/touniq_u_merge_mem.fasta" \
| sed 's/^>seq[0-9]* //' \
| sort \
> "${TMPDIR}/touniq_u_merge_mem.json"
grep '^>' "${TMPDIR}/touniq_u_merge_disk.fasta" \
| sed 's/^>seq[0-9]* //' \
| sort \
> "${TMPDIR}/touniq_u_merge_disk.json"
((ntest++))
if diff "${TMPDIR}/touniq_u_merge_mem.json" \
"${TMPDIR}/touniq_u_merge_disk.json" > /dev/null
then
log "OBIUniq merge on-disk vs in-memory: result OK"
((success++))
else
log "OBIUniq merge on-disk vs in-memory: result failed"
((failed++))
fi
#########################################
#
# At the end of the tests