From 4cd76eeadad471f8ecc6be3a4864d4820a8620a8 Mon Sep 17 00:00:00 2001 From: Kat Steinke Date: Wed, 5 Aug 2026 09:43:03 +0200 Subject: [PATCH 1/2] ncbiquery.py: allow specifying NCBI taxdump file to be downloaded --- ete4/ncbi_taxonomy/ncbiquery.py | 2 +- tests/slow/test_ncbiquery_force_download.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ete4/ncbi_taxonomy/ncbiquery.py b/ete4/ncbi_taxonomy/ncbiquery.py index 5048003bb..1e8ebd4e0 100644 --- a/ete4/ncbi_taxonomy/ncbiquery.py +++ b/ete4/ncbi_taxonomy/ncbiquery.py @@ -674,8 +674,8 @@ def update_db(dbfile, targz_file=None): os.makedirs(basepath) if not targz_file: - update_local_taxdump(DEFAULT_TAXDUMP) targz_file = DEFAULT_TAXDUMP + update_local_taxdump(targz_file) tar = tarfile.open(targz_file, 'r') t, synonyms = load_ncbi_tree_from_dump(tar) diff --git a/tests/slow/test_ncbiquery_force_download.py b/tests/slow/test_ncbiquery_force_download.py index 0e5bf4337..47b3b722e 100644 --- a/tests/slow/test_ncbiquery_force_download.py +++ b/tests/slow/test_ncbiquery_force_download.py @@ -2,6 +2,10 @@ Test the functionality of ncbiquery.py. To run with pytest. """ +import os + +import pytest + from ete4 import ETE_DATA_HOME from ete4.ncbi_taxonomy import ncbiquery @@ -12,3 +16,17 @@ def test_update_database(): ncbiquery.update_db(DATABASE_PATH) # It will download the full NCBI taxa database and process it. Slow! # Should raise an error if things go wrong. + +@pytest.fixture(autouse=True) +def clean_taxdump(): + # remove the taxdump if it exists + taxdump_location = ETE_DATA_HOME + '/tests/test_ncbiquery.taxdump.tar.gz' + if os.path.exists(taxdump_location): + os.remove(taxdump_location) + +def test_update_with_taxdump(): + # update the db while using a custom location for the taxdump + taxdump_location = ETE_DATA_HOME + '/tests/test_ncbiquery.taxdump.tar.gz' + assert not os.path.exists(taxdump_location) + ncbiquery.update_db(DATABASE_PATH, taxdump_location) + assert os.path.exists(taxdump_location) \ No newline at end of file From 31b0339bddb3d805c91f97c602de69111928a9ee Mon Sep 17 00:00:00 2001 From: Kat Steinke Date: Wed, 5 Aug 2026 09:46:28 +0200 Subject: [PATCH 2/2] tests: expect unclassified Pan sp. added Feb 2026 as descendant of Pan --- tests/test_ncbiquery.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_ncbiquery.py b/tests/test_ncbiquery.py index 3663a756d..2f7a1bccf 100644 --- a/tests/test_ncbiquery.py +++ b/tests/test_ncbiquery.py @@ -122,7 +122,7 @@ def test_ncbiquery(): assert set(out) == {63221, 741158, 2665953, 1425170, 2813599} out = ncbi.get_descendant_taxa('9596', intermediate_nodes=False, rank_limit='species') - assert set(out) == {9597, 9598} + assert set(out) == {9597, 9598, 3612878} def test_get_topology():