Files
obiskim/benchmark/simulate_skim.sh
T
Eric Coissac 917cb26186
Release / create-release (push) Successful in 32s
Release / build-linux-x86_64 (push) Successful in 6m18s
Release / build-macos-arm64 (push) Failing after 2m15s
refactor: rename project from obikmer to obiskim
Update the project name, binary, and all associated documentation, scripts, and configuration files from `obikmer` to `obiskim`. This change ensures consistency across the codebase, including lock files, VCF outputs, benchmark targets, and user-facing documentation.

- Update `mkdocs.yml` and `.crate-kit/VERSION` to reflect the new project name and version 0.3.4.
- Rename all references in `DevDocMD/` documentation, including architecture, implementation, and theory sections, from `obikmer` to `obiskim`.
- Update `UserDocMD/` files to use `.obiskim.lock` and `.obiskim.gate` for lock files, and update VCF contig IDs to `obiskim_<partition>_<layer>`.
- Modify `benchmark/` scripts and Makefiles to use `obiskim` binary names and `obiskim_dist/` directories for distribution and comparison tasks.
- Update `prompts/` files to reference the `obiskim` repository and commands instead of `obikmer`.
- Rename temporary directories in `scripts/` smoke tests from `obikmer_*` to `obiskim_*`.
- Update `src/obikphylo/src/siblings/algorithms/alignment_vcf.rs` to use `obiskim` in VCF source identifiers and assertions.
- Update `src/obiskim/Cargo.toml` version to 1.4.9 and update `src/obiskim/src/cmd/phylo/args/outputs.rs` documentation.
- Update `src/obisys/src/lock.rs` to use `.obiskim.lock`, `.obiskim.gate`, and `.obiskim.promote` file names.
2026-12-01 18:17:47 +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}/obiskim_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"