Skip to content

Add opt-in orientation-preserving lookup - #108

Open
adamant-pwn wants to merge 14 commits into
jermp:masterfrom
ratschlab:upstream/orientation-preserving-lookup
Open

adamant-pwn wants to merge 14 commits into
jermp:masterfrom
ratschlab:upstream/orientation-preserving-lookup

Conversation

@adamant-pwn

Copy link
Copy Markdown
Contributor

Depends on #102. The orientation change touches the bucket lookup that #102 refactors, so this branch is built on it. Once #102 is merged, the diff here reduces to the orientation change.

MetaGraph’s BASIC graphs assign distinct IDs to a k-mer and its reverse complement. This adds opt-in build_configuration::preserve_orientation support while keeping the existing boolean lookup API. With this option enabled, lookup(kmer, false) requires the stored orientation. lookup(kmer, true) also accepts the reverse complement and prefers a forward match when both are present. Exact duplicate k-mers remain unsupported.

The index format stays v6 unless the option is used. Dictionaries built without it are byte-identical to those written by master, so existing readers load them unchanged. A sha256 comparison on five of the bundled datasets, one of them weighted, confirmed this. Resaving a v6 index also reproduces the original file. Dictionaries built with the option are saved as v7, which is the v6 layout plus a one-byte orientation flag. Readers that only know v6 reject these files with the existing major-version error, so they never treat an oriented index as canonical. Old readers validate only the major version, so a flag stored anywhere else would be ignored by them.

Prepared with AI assistance.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant