NCBITaxa() failing

489 views
Skip to first unread message

Jeff Bowman

unread,
Aug 14, 2020, 1:22:16 AM8/14/20
to The ETE toolkit
ete3 has been working great for me, but the NCBITaxa() function is suddenly failing at the "Inserting synonyms" step.  Traceback pasted below.  I tried a fresh install of ete3 on a different computer with the same result.

Inserting synonyms:      30000 Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jsbowman/.local/lib/python3.6/site-packages/ete3/ncbi_taxonomy/ncbiquery.py", line 110, in __init__
    self.update_taxonomy_database(taxdump_file)
  File "/home/jsbowman/.local/lib/python3.6/site-packages/ete3/ncbi_taxonomy/ncbiquery.py", line 129, in update_taxonomy_database
    update_db(self.dbfile)
  File "/home/jsbowman/.local/lib/python3.6/site-packages/ete3/ncbi_taxonomy/ncbiquery.py", line 760, in update_db
    upload_data(dbfile)
  File "/home/jsbowman/.local/lib/python3.6/site-packages/ete3/ncbi_taxonomy/ncbiquery.py", line 802, in upload_data
    db.execute("INSERT INTO synonym (taxid, spname) VALUES (?, ?);", (taxid, spname))
sqlite3.IntegrityError: UNIQUE constraint failed: synonym.spname, synonym.taxid

fransua

unread,
Aug 14, 2020, 7:31:51 PM8/14/20
to The ETE toolkit
Hi Jeff,
just bumped into the same error.
A quick and dirty fix for me was to replace the line in ete:

db.execute("INSERT INTO synonym (taxid, spname) VALUES (?, ?);", (taxid, spname))



by:
db.execute("INSERT OR REPLACE INTO synonym (taxid, spname) VALUES (?, ?);", (taxid, spname))




before running your script again delete you ncbi DB (usually in ~/.etetoolkit/taxa.sqlite*)

cheers

francois

Jeff Bowman

unread,
Aug 15, 2020, 9:45:16 AM8/15/20
to The ETE toolkit
Excellent, thanks Francois!

Jeff

linshuc...@gmail.com

unread,
Aug 25, 2020, 7:02:46 AM8/25/20
to The ETE toolkit
it works!!! thx!!!

pablo...@gmail.com

unread,
Sep 9, 2020, 1:40:06 PM9/9/20
to The ETE toolkit
Thank you!

jan.d...@gmail.com

unread,
Jan 19, 2021, 7:06:41 AM1/19/21
to The ETE toolkit
Hi all,
I think this happens because of the "COLLATE NOCASE" statement used for creating the synonym table. Consequently taxid/synonym pairs that appear as identical because the case is not considered for comparison .. cause a SQLite insertion error..
So you can either delete this statement, or include the line :
db.execute("INSERT INTO synonym (taxid, spname) VALUES (?, ?);", (taxid, spname))
in a try / except block like this:
         try: db.execute("INSERT INTO synonym (taxid, spname) VALUES (?, ?);", (taxid, spname))
         except: print(i,taxid,spname)
That way you really don't modify the expected ouput of ete3 and get track of the taxid/synonym pairs that were skipped.
Jan

jan.d...@gmail.com

unread,
Jan 19, 2021, 7:06:44 AM1/19/21
to The ETE toolkit


Le mercredi 9 septembre 2020 19:40:06 UTC+2, pablo...@gmail.com a écrit :
Reply all
Reply to author
Forward
0 new messages