Handle NCBI taxdump members with a leading './' (fixes #810)#813
Open
apoorvdarshan wants to merge 1 commit into
Open
Handle NCBI taxdump members with a leading './' (fixes #810)#813apoorvdarshan wants to merge 1 commit into
apoorvdarshan wants to merge 1 commit into
Conversation
Tarballs created with GNU tar (e.g. `tar -c -C dir .`) name their members like `./names.dmp`, `./nodes.dmp` and `./merged.dmp`. The extractfile() lookups used the bare name and raised `KeyError: "filename 'names.dmp' not found"`, so NCBITaxa(taxdump_file=...) failed to build the database. Add a small extractfile_dmp() helper that falls back to the './'-prefixed member name, and use it at the three .dmp call sites. Add a regression test covering both plain and './'-prefixed tarballs. Fixes etetoolkit#810.
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.
Summary
NCBITaxa(taxdump_file=...)fails when the taxdump tarball is created with GNU tar (e.g.tar -c -C dir .), because such archives name their members with a leading./(./names.dmp,./nodes.dmp,./merged.dmp). The code inete4/ncbi_taxonomy/ncbiquery.pylooked those members up by their bare name, sotarfileraised:This reproduces on the current
ete4branch (commit9562dfb, the same one referenced in #810).Fix
Add a small
extractfile_dmp(tar, name)helper that first tries the bare member name and, onKeyError, falls back to the'./'-prefixed name. It is used at the three.dmpextraction sites (names.dmp,nodes.dmp,merged.dmp). The change is localized and does not affect the existing (non-prefixed) tarballs.Tests
Added
test_extract_dmp_with_leading_dotslashintests/test_ncbiquery.py, parametrized over both plain and'./'-prefixed members. It builds a minimal in-memory taxdump, runsupdate_db, and checks the resulting database. The'./'case fails onmain/ete4before the fix (KeyError) and passes after. The fulltest_ncbiquery.pysuite (9 tests) passes.Fixes #810.
Disclosure: prepared with AI assistance; reviewed and verified locally.