Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ete4/ncbi_taxonomy/ncbiquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 18 additions & 0 deletions tests/slow/test_ncbiquery_force_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
2 changes: 1 addition & 1 deletion tests/test_ncbiquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down