Add a new `estimate --index` command to compare observed k-mer sharing against a random-sequence model using a Poisson-binomial distribution. Introduce the `row_presence_histogram` API to support this analysis across various matrix types. Update documentation and dependencies accordingly. - Add `src/obikstats/src/null_model.rs` implementing `SharingNullModel` and `SharingRow` for computing cumulative probabilities and false discovery rates based on a Poisson-binomial distribution. - Add `src/obikstats/src/sharing.rs` defining `GenomeSharing` and `SharingSpectrum` to compute k-mer sharing spectra using parallel map-reduce. - Add `src/obikmer/src/cmd/estimate/sharing.rs` with `run` and `write_csv` to execute sharing estimation and output CSV results containing observed, expected, and deviation metrics. - Modify `src/obikmer/src/cmd/estimate/mod.rs` to support the new `--index` subcommand, adding `EstimateArgs` fields for index path, presence threshold, and output file. - Add `src/obicompactvec/src/row_histogram.rs` implementing `row_presence_histogram` for `PersistentIntMatrix`, `PersistentBitMatrix`, and sparse matrices to count rows present in exactly $j$ columns. - Update `src/obikindex/src/layer/content_layer.rs` and `src/obikindex/src/layer/typed_layer.rs` to expose the new `row_presence_histogram` method, dispatching based on layer type. - Add tests in `src/obicompactvec/src/tests/bitmatrix.rs`, `intmatrix.rs`, and `sparse.rs` to verify `count_geq` and `row_presence_histogram` against naive implementations for various matrix structures. - Update `UserDocMD/theory/kmer_indexing/kmers.md` to document the Poisson-binomial approach, $D_r$ bounds, and FDR calculations, replacing previous binomial approximations. - Update `UserDocMD/usage/estimate.md` to describe the two uses of `estimate`: parameter estimation and index comparison via `--index`. - Add `wiki` target to `Makefile` for regenerating documentation from user docs. - Bump `obikmer` package version from 1.4.5 to 1.4.6 in `Cargo.toml` and `Cargo.lock`.
141 lines
4.8 KiB
Makefile
141 lines
4.8 KiB
Makefile
VENV := .venv
|
|
PYTHON := $(VENV)/bin/python
|
|
PIP := $(VENV)/bin/pip
|
|
MKDOCS := $(VENV)/bin/mkdocs
|
|
|
|
CARGO_DIR := src
|
|
|
|
DOC_DIR := DevDocMD
|
|
DOC_FILE := mkdocs.yml
|
|
DOC_SITE := DevDoc
|
|
DOC_PORT := 8001
|
|
|
|
DOC_USER_DIR := UserDocMD
|
|
DOC_USER_FILE := mkdocs-user.yml
|
|
DOC_USER_SITE := doc
|
|
DOC_USER_PORT := 8002
|
|
|
|
# ── virtualenv ────────────────────────────────────────────────────────────────
|
|
|
|
$(VENV)/bin/activate:
|
|
python3 -m venv $(VENV)
|
|
|
|
$(MKDOCS): $(VENV)/bin/activate
|
|
$(PIP) install --quiet --upgrade pip
|
|
$(PIP) install --quiet \
|
|
livereload watchdog \
|
|
mkdocs mkdocs-material \
|
|
mkdocs-mermaid2-plugin \
|
|
mkdocs-bibtex
|
|
$(PIP) install --quiet --upgrade InSilicoSeq
|
|
|
|
# ── obikmer binary ───────────────────────────────────────────────────────────
|
|
|
|
PROFILE_FILE := profile.pb
|
|
PPROF_PORT := 8081
|
|
|
|
.PHONY: obikmer
|
|
obikmer:
|
|
cargo build --release --manifest-path $(CARGO_DIR)/Cargo.toml --bin obikmer
|
|
|
|
.PHONY: debug
|
|
debug:
|
|
cargo build --manifest-path $(CARGO_DIR)/Cargo.toml --bin obikmer
|
|
|
|
# One-shot converter of indexes built with ptr_hash 1.x (see tools/migrate-mphf).
|
|
# Standalone crate, outside the src/ workspace, with its own Cargo.lock/target.
|
|
MIGRATE_MPHF_DIR := tools/migrate-mphf
|
|
|
|
.PHONY: migrate-mphf
|
|
migrate-mphf:
|
|
cargo build --release --manifest-path $(MIGRATE_MPHF_DIR)/Cargo.toml
|
|
|
|
.PHONY: clean-migrate-mphf
|
|
clean-migrate-mphf:
|
|
rm -rf $(MIGRATE_MPHF_DIR)/target
|
|
|
|
.PHONY: profile-build
|
|
profile-build:
|
|
cargo build --release --manifest-path $(CARGO_DIR)/Cargo.toml \
|
|
--bin obikmer --features obikmer/profiling
|
|
|
|
.PHONY: profile-view
|
|
profile-view:
|
|
go tool pprof -http=127.0.0.1:$(PPROF_PORT) $(PROFILE_FILE)
|
|
# ── documentation ─────────────────────────────────────────────────────────────
|
|
|
|
.PHONY: doc
|
|
doc: $(MKDOCS)
|
|
$(MKDOCS) build -f $(DOC_FILE)
|
|
|
|
.PHONY: doc-serve
|
|
doc-serve: $(MKDOCS)
|
|
$(MKDOCS) serve -f $(DOC_FILE) \
|
|
--dev-addr=127.0.0.1:$(DOC_PORT) \
|
|
--livereload
|
|
.PHONY: clean-doc
|
|
clean-doc:
|
|
rm -rf $(DOC_SITE)/
|
|
|
|
.PHONY: doc-user
|
|
doc-user: $(MKDOCS)
|
|
$(MKDOCS) build -f $(DOC_USER_FILE)
|
|
|
|
.PHONY: doc-user-serve
|
|
doc-user-serve: $(MKDOCS)
|
|
$(MKDOCS) serve -f $(DOC_USER_FILE) \
|
|
--dev-addr=127.0.0.1:$(DOC_USER_PORT) \
|
|
--livereload
|
|
|
|
.PHONY: clean-doc-user
|
|
clean-doc-user:
|
|
rm -rf $(DOC_USER_SITE)/
|
|
|
|
# Regenerates the Gitea/Forgejo wiki (a separate repository, checked out next
|
|
# to this one) from the user documentation. Only rewrites its working tree:
|
|
# committing and pushing it stays a manual step. Not part of `clean`.
|
|
DOC_WIKI_DIR := ../obikmer.wiki
|
|
|
|
.PHONY: wiki
|
|
wiki:
|
|
@command -v pmotransdoc >/dev/null || { echo "pmotransdoc not found in PATH" >&2; exit 1; }
|
|
@test -d $(DOC_WIKI_DIR)/.git || { echo "$(DOC_WIKI_DIR) is not a git checkout of the wiki" >&2; exit 1; }
|
|
pmotransdoc $(DOC_USER_DIR) $(DOC_WIKI_DIR)
|
|
|
|
.PHONY: clean
|
|
clean: clean-doc clean-doc-user
|
|
rm -rf $(VENV)
|
|
|
|
# ── release ───────────────────────────────────────────────────────────────────
|
|
|
|
CARGO_TOML := $(CARGO_DIR)/obikmer/Cargo.toml
|
|
|
|
.PHONY: bump-version
|
|
bump-version:
|
|
@current=$$(grep '^version = ' $(CARGO_TOML) | head -n 1 | sed 's/version = "\(.*\)"/\1/'); \
|
|
if [ -n "$(RELEASE)" ]; then \
|
|
new_version="$(RELEASE)"; \
|
|
else \
|
|
major=$$(echo $$current | cut -d. -f1); \
|
|
minor=$$(echo $$current | cut -d. -f2); \
|
|
patch=$$(echo $$current | cut -d. -f3); \
|
|
new_patch=$$((patch + 1)); \
|
|
new_version="$$major.$$minor.$$new_patch"; \
|
|
fi; \
|
|
echo "Version: $$current -> $$new_version"; \
|
|
sed -i.bak "s/^version = \"$$current\"/version = \"$$new_version\"/" $(CARGO_TOML) && \
|
|
rm $(CARGO_TOML).bak
|
|
|
|
.PHONY: release
|
|
release: bump-version
|
|
@jj auto-doc
|
|
@jj git push --change @
|
|
@new_version=$$(grep '^version = ' $(CARGO_TOML) | head -n 1 | sed 's/version = "\(.*\)"/\1/'); \
|
|
git_hash=$$(jj log -r @ --no-graph -T 'commit_id'); \
|
|
commits=$$(jj log -r 'latest(tags())..@' --no-graph -T 'description ++ "\n"' 2>/dev/null || \
|
|
jj log --no-graph -T 'description ++ "\n"' --limit 30); \
|
|
notes=$$(printf 'Write concise markdown release notes for obikmer (a Rust kmer genomics tool). Be technical and direct. Base them strictly on these commit messages:\n\n%s' "$$commits" | aichat 2>/dev/null); \
|
|
tag_msg="$${notes:-Release v$$new_version}"; \
|
|
git tag -a "v$$new_version" -m "$$tag_msg" "$$git_hash" && \
|
|
git push origin "v$$new_version"
|