mob-suite icon indicating copy to clipboard operation
mob-suite copied to clipboard

Bug: `--database_directory` not working in `mob_recon`

Open schorlton opened this issue 2 years ago • 4 comments

Issue

Bug

Specifying --database_directory to mob_recon causes it to error with the following:

Traceback (most recent call last):
  File "/opt/conda/envs/test/bin/mob_recon", line 8, in <module>
    sys.exit(main())
  File "/opt/conda/envs/test/lib/python3.8/site-packages/mob_suite/mob_recon.py", line 1096, in main
    dbstatus = ETE3_db_status_check(1, ETE3_LOCK_FILE, ETE3DBTAXAFILE, logging)
  File "/opt/conda/envs/test/lib/python3.8/site-packages/mob_suite/utils.py", line 460, in ETE3_db_status_check
    ncbi = NCBITaxa(dbfile=ETE3DBTAXAFILE)
  File "/opt/conda/envs/test/lib/python3.8/site-packages/ete3/ncbi_taxonomy/ncbiquery.py", line 115, in __init__
    raise ValueError("Cannot open taxonomy database: %s" % self.dbfile)
ValueError: Cannot open taxonomy database: /opt/conda/envs/test/lib/python3.8/site-packages/mob_suite/databases/taxa.sqlite

Fix

ETE3DBTAXAFILE should be dynamically set if the --database_directory arg is set: https://github.com/phac-nml/mob-suite/blob/1d735b30053b45457a59c277c8d996ab86e0347c/mob_suite/mob_recon.py#L1096 whereas instead it is imported from constants: https://github.com/phac-nml/mob-suite/blob/1d735b30053b45457a59c277c8d996ab86e0347c/mob_suite/mob_recon.py#L14-L18

Thanks for your help in fixing!

schorlton avatar Mar 28 '22 14:03 schorlton

Thank you for reporting. Yes, right now the taxa.sqlite path defined by ETE3DBTAXAFILE is permanently set to the default database directory located inside the mob-suite package directory. I agree that this should be redefined dynamically by --database_directory parameter. Will include this fix in next release. As temporary fix you can redefine constant with new path in https://github.com/phac-nml/mob-suite/blob/39317225fcbd0a98fd1f1bd663d91932ae0fae8e/mob_suite/constants.py#L147

kbessonov1984 avatar Mar 28 '22 14:03 kbessonov1984

Perfect, looking forward to the next release! Yes, we also just symlinked in the file to where mob_recon was looking for it for now. Thanks again!

schorlton avatar Mar 28 '22 14:03 schorlton

Version 3.1.0 will implement this update, thank you for pointing this out!

jrober84 avatar May 25 '22 22:05 jrober84

Hi @jrober84, thanks for your hard work. It's actually not clear to me that this issue was resolved? It looks like MOB-suite still looks for the ETE3 file in the default database location, and does not dynamically set it: https://github.com/phac-nml/mob-suite/blob/3.1.0/mob_suite/constants.py#L174. Indeed, when I try running mob-recon specifying a custom database location, it fails because of this.

schorlton avatar Jun 04 '22 18:06 schorlton

My apologies for the delay, v. 3.1.1 should propagate the ETE3DBTAXAFILE variable correctly to all of the downstream functions and fix this issue

jrober84 avatar Jan 25 '23 21:01 jrober84