The information present in the delnodes.dmp and merged.dmp files should be (optionaly?) leveraged by the ncbi constructor to:
redirect old taxid to the new Node
raise an informative error when trying to access a deleted Node
Test cases:
2923454 should point to 89248 (Equus quagga)
Any taxid in delnodes should raise anerror
This could be implemented by introducing new BaseNode subclasses.
The Taxonomy __getitem__ method could then check the BaseNode subclass and return the correct object (redirected to another Node for merged nodes or raise anerror for deleted nodes)
importtaxidToolsastxdTAXDUMP='path_to_taxdump/'tax=txd.read_taxdump(
f'{TAXDUMP}nodes.dmp',
f'{TAXDUMP}rankedlineage.dmp',
f'{TAXDUMP}merged.dmp'
)
# Prune to only keep embryophyta to avoid ambiguity.tax_pruned=tax.copy()
tax_pruned.prune(3193)
# Get ancestry of "Liliaceae" from pruned taxonomy. Throws an error. tax_id_pruned=tax_pruned.getTaxid('Liliaceae')
tax_pruned.getAncestry(tax_id_pruned) # Throws an error.# Get ancestry of "Liliaceae" from original taxonomy. Works fine.tax_id=tax.getTaxid('Liliaceae')
tax.getAncestry(tax_id) # Works fine.# Both taxonomy ids are the same.tax_id==tax_id_pruned