Files
obiskim/benchmark/simulate_skim.sh
T
Eric Coissac 42d5b881ec refactor: rename obikmer to obiskim
Rename the `obikmer` binary, crate, and documentation to `obiskim`. This change updates all references in source code, build scripts, CI workflows, and user documentation to reflect the new tool name.

- Move `src/obikmer` to `src/obiskim`, renaming the package and binary in `Cargo.toml` and updating `main.rs` and `cli.rs` to use the new name.
- Update `src/Cargo.toml` and `src/Cargo.lock` to replace the `obikmer` workspace member with `obiskim`.
- Update `Makefile` targets (`build`, `release`, `debug`, `profile-build`) and variables (`CARGO_TOML`, `bump-version`) to build and manage `obiskim`.
- Update `.gitea/workflows/release.yml` to build and upload `obiskim` artifacts for Linux and macOS.
- Rename all files in `src/obiskim/src/cmd/` from `obikmer` to `obiskim` paths, updating error messages and help text in `index/mod.rs`, `phylo/args/mod.rs`, and `phylo/tnt.rs`.
- Update documentation in `UserDocMD/` (including `index.md`, `installation.md`, `architecture.md`, and usage guides) to reference `obiskim` commands and behavior.
- Update `benchmark/` scripts and Python verification tools to use `obiskim` binary paths and arguments.
- Update `scripts/` (including `smoke_test_*.sh`, `bench_merge_oracle.sh`, and Docker debug scripts) to test and build `obiskim`.
- Update comments and error messages in library crates (`obicompactvec`, `obifastwrite`, `obikentropy`, `obikfilter`, `obikindex`, `obikindexer`, `obikphylo`, `obikselect`, `obikseq`, `obiread`, `obisys`) to reference `obiskim`.
2026-12-01 18:15:13 +01:00

58 lines
2.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# Genome-skimming test bed: re-simulate the benchmark genomes at a low
# coverage, index each specimen, and merge them into one presence index.
#
# Usage: simulate_skim.sh (env: COVERAGE=1 SEED=1 CPUS=...)
#
# The genome → specimen mapping is read from deps.mk (same source of truth
# as the Makefile pipeline); the pipeline's own run/ tree is left untouched.
# Output: run/skim_${COVERAGE}x_s${SEED}/
# simulated_data/<species>/<strain>/reads_R{1,2}.fastq.gz
# specimen_index_presence/<species>--<strain>/
# global_index_presence/
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ISS="${SCRIPT_DIR}/../.venv/bin/iss"
BINARY="${SCRIPT_DIR}/../src/target/release/obiskim"
COVERAGE="${COVERAGE:-1}"
SEED="${SEED:-1}"
READ_LENGTH=150
CPUS="${CPUS:-$(sysctl -n hw.logicalcpu 2>/dev/null || nproc 2>/dev/null || echo 2)}"
OUT="${SCRIPT_DIR}/run/skim_${COVERAGE}x_s${SEED}"
mkdir -p "${OUT}/simulated_data" "${OUT}/specimen_index_presence"
tmp_fasta=$(mktemp "${TMPDIR:-/tmp}/obikmer_skim_XXXXXX.fna")
trap 'rm -f "${tmp_fasta}"' EXIT
# lines of the form run/simulated_data/<species>/<strain>/reads_R1.fastq.gz: run/genomes/<file>
sed -nE 's#^run/simulated_data/([^/]+)/([^/]+)/reads_R1\.fastq\.gz: (run/genomes/[^ ]+)$#\1 \2 \3#p' \
"${SCRIPT_DIR}/deps.mk" | sort -u | while read -r species strain genome; do
specimen="${species}--${strain}"
reads_dir="${OUT}/simulated_data/${species}/${strain}"
index_dir="${OUT}/specimen_index_presence/${specimen}"
mkdir -p "${reads_dir}"
gzip -dc "${SCRIPT_DIR}/${genome}" > "${tmp_fasta}"
genome_size=$(grep -v "^>" "${tmp_fasta}" | tr -d '[:space:]' | wc -c | tr -d ' ')
n_reads=$(python3 -c "import math; print(math.ceil(${COVERAGE} * ${genome_size} / (2 * ${READ_LENGTH})))")
echo "[${specimen}] genome=${genome_size} bp → ${n_reads} read pairs (${COVERAGE}x, seed ${SEED})"
"${ISS}" generate \
--genomes "${tmp_fasta}" --model HiSeq --n_reads "${n_reads}" \
--cpus "${CPUS}" --seed "${SEED}" --compress \
--output "${reads_dir}/reads" 2>/dev/null
rm -f "${reads_dir}"/reads.iss.tmp.*.vcf
"${BINARY}" index --output "${index_dir}" --force --theta 0 \
--label "${specimen}" --meta "species=${species}" \
"${reads_dir}/reads_R1.fastq.gz" "${reads_dir}/reads_R2.fastq.gz" 2>/dev/null
done
mapfile -t sources < <(find "${OUT}/specimen_index_presence" -mindepth 1 -maxdepth 1 -type d | sort)
echo "Merging ${#sources[@]} presence indexes → ${OUT}/global_index_presence"
"${BINARY}" merge --output "${OUT}/global_index_presence" --force --force-presence \
"${sources[@]}" 2>/dev/null
echo "Done: ${OUT}/global_index_presence"