ete icon indicating copy to clipboard operation
ete copied to clipboard

Added values to synonyms table

Open bilalix opened this issue 6 years ago • 5 comments

Added common names and authority values to the synonyms table and created get_synonyms() to retrieve them. Fix #382

bilalix avatar Oct 30 '18 14:10 bilalix

Hi @jhcepas @fransua , any chance to see this merged in ete3? It is a little change that make the library very usefull. Thanks in advance.

cpommier avatar Mar 19 '20 20:03 cpommier

yes. Sorry we didn't find time to work on requests for a long time. We are now working on a new release and this addon sounds good. @dengzq1234 could you review and merge if everything is ok? I think we migth need a unitest function before merge though.

jhcepas avatar Mar 20 '20 15:03 jhcepas

Thank you!

cpommier avatar Mar 20 '20 16:03 cpommier

Hi, I'm using ETE3 package for getting common names and scientific names for NCBI id's. Currently, I'm working on extracting synonyms. Is there any chance that you will update it with 'get_synonym'? That would be really helpful.

Anoosha-Sehar avatar Apr 03 '21 09:04 Anoosha-Sehar

Until this is merged, I was able to manually create this as a separate method below:

def get_synonyms(ncbi, taxids):
    id2syn = {}
    # since they could be more than one synonym
    # we first create a dictionary filled with taxonID
    # and have an array of values/synonyms
    for tax in taxids:
        id2syn[tax] = []
    query = ",".join(['"%s"' % v for v in taxids])
    cmd = "select taxid, spname FROM synonym WHERE taxid IN (%s);" % query
    result = ncbi.db.execute(cmd)
    for tax, synonym in result.fetchall():
        if synonym:
            id2syn[tax].append(synonym)
    return id2syn

This works the same as this PR, except you need to pass the ncbi database object as the first parameter

chanind avatar Jul 24 '23 21:07 chanind