Coder Social home page Coder Social logo

cvua-rrw / taxidtools Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 2.0 1.03 MB

Python library to deal with taxonomic IDs and lineages from the NCBI's Taxdump files

Home Page: https://cvua-rrw.github.io/taxidtools/

License: BSD 3-Clause "New" or "Revised" License

Python 99.25% Dockerfile 0.75%
taxonomy taxdump lineage ancestry taxids lineages ncbi-taxonomy ncbi python python-library

taxidtools's People

Contributors

gregdenay avatar

Watchers

 avatar

taxidtools's Issues

Add support for merged and deleted nodes

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)

Writing Taxonomy to json deletes children

the Node._children argument is deleted during json creation.
Will be fixed in the next version.

Workaround meanwhile is to reload the json file that was just created.

Retrieve Taxid from name

Provided that names are unique, provide a method that returns the Taxid for a given node name.

May need to implement a reversing of the dictionnary for that.

BUG: taxonomy.getAncestry('taxid') does not redirect old taxid to new node with pruned taxonomy

First, thank you for this great toolkit, it's super convenient.

I think I might be dealing with a bug.
Version used: 3.1.1

Steps to reproduce:

  1. download taxdump
  2. Run code:
import taxidTools as txd

TAXDUMP = '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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.