Repository: zyxue/ncbitax2lin

Issue:
NCBI changed taxnomy - no longer has superkingdom
See here for news: [https://ncbiinsights.ncbi.nlm.nih.gov/2024/06/04/changes-ncbi-taxonomy-classifications/](https://ncbiinsights.ncbi.nlm.nih.gov/2024/06/04/changes-ncbi-taxonomy-classifications/)
This means that ncbitax2lin no longer works with the most recent NCBI tax dump data.
Perhaps it's as easy as changing superkingdom with domain?

Discussion:
@cclough: also encountered this@zyxue: PR is welcome.

@ocstringham , could you please paste the error you encounter when running ncbitax2lin with the most recent NCBI tax dump data?@zyxue: sorry for delay. this should be fixed in 2.4.1 now https://pypi.org/project/ncbitax2lin/#history@ocstringham: Thank you!

Solution patch:
diff --git a/ncbitax2lin/__init__.py b/ncbitax2lin/__init__.py
index b8b019d..0c409a0 100644
--- a/ncbitax2lin/__init__.py
+++ b/ncbitax2lin/__init__.py
@@ -1,3 +1,3 @@
 """__init__.py for this project"""
 
-__version__ = "2.0.2"
+__version__ = "2.4.1"
diff --git a/ncbitax2lin/data_io.py b/ncbitax2lin/data_io.py
index 9d43a3b..158cb99 100644
--- a/ncbitax2lin/data_io.py
+++ b/ncbitax2lin/data_io.py
@@ -88,9 +88,17 @@ def read_names_and_nodes(names_file: str, nodes_file: str) -> pd.DataFrame:
 
 def write_lineages_to_disk(df_lineages: pd.DataFrame, output_path: str) -> None:
     """Gzip lineages and write them to disk"""
+    # superkingdom has been renamed to domain in
+    # https://ncbiinsights.ncbi.nlm.nih.gov/2024/06/04/changes-ncbi-taxonomy-classifications/
+    domain_col = "domain"
+
+    # For backwards compatibility with older taxdumps.
+    if "superkingdom" in df_lineages:
+        domain_col = "superkingdom"
+
     cols = [
         "tax_id",
-        "superkingdom",
+        domain_col,
         "phylum",
         "class",
         "order",
diff --git a/pyproject.toml b/pyproject.toml
index f63c13f..ae2794a 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
 [tool.poetry]
 name = "ncbitax2lin"
-version = "2.3.1"
+version = "2.4.1"
 description = "A tool that converts NCBI taxonomy dump into lineages"
 authors = ["Zhuyi Xue <zhuyi.xue@alum.utoronto.ca>"]
 readme = "README.md"


Test patch:
diff --git a/tests/test___init__.py b/tests/test___init__.py
index 1d4dc85..0689f54 100644
--- a/tests/test___init__.py
+++ b/tests/test___init__.py
@@ -1,7 +1,8 @@
 """tests for __init__.py"""
+
 # pylint: disable=protected-access, missing-function-docstring
 from ncbitax2lin import __version__
 
 
 def test_version() -> None:
-    assert __version__ == "2.0.2"
+    assert __version__ == "2.4.1"