Repository navigation
Fix ranks like "domain" being rewritten to "no rank" on save - #83
Merged
Merged
Conversation
TaxRank::to_ncbi_rank had a catch-all arm that mapped Domain and ~20 other variants to "no rank". The NCBI and JSON writers go through it, so round-tripping a current NCBI taxdump silently lost those ranks. Share one exhaustive string table between Display and to_ncbi_rank, add from_str entries for the variants that previously could never be written, and assert in tests that every rank round-trips unchanged.
audy
marked this pull request as ready for review
November 5, 2026 00:00
pkonieczny
approved these changes
Nov 5, 2026
jairideout
approved these changes
Nov 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
TaxRank::to_ncbi_rankhad a catch-all_ => "no rank"arm.Domain,Subdomain,Realm, theDivisionfamily,Legion/Cohortvariants and ~20 others fell through it. Both the NCBI writer and the JSON serializer use it, so saving or round-tripping a current NCBI taxdump (where Bacteria/Archaea/Eukaryota aredomain) silently rewrote those ranks tono rank. Reads looked fine because the Pythonrankproperty goes throughDisplay, which was exhaustive.Fix
Displaytable intoTaxRank::as_strand have bothDisplayandto_ncbi_rankdelegate to it. A variant without a string is now a compile error.from_strentries for variants that previously could never be written and so were never parsed: superdivision, division, subdivision, infradivision, series fish, series lepidoptera, group lepidoptera, subseries botany, individual."division"was intentionally unmapped before because it is ambiguous with botanical phylum. It now maps toTaxRank::Divisionso the library can read back what it writes. Happy to revert that one if you prefer the error.is_ok; the NCBI fixture usesdomainfor Bacteria and asserts the rank survives save/load. Confirmed that assertion fails onmaster(Unspecified) and passes here.