ete
ete copied to clipboard
Added values to synonyms table
Added common names
and authority
values to the synonyms table and created get_synonyms()
to retrieve them. Fix #382
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.
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.
Thank you!
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.
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