funannotate annotate with interproscan input: KeyError: 'FUNANNOTATE_DB'
Are you using the latest release? yes, 1.8.15 from conda
Describe the bug
Running funannotate annotate command with an interproscan.xml input file, I get this error:
[Apr 25 02:04 PM]: Parsing InterProScan5 XML file
[Apr 25 02:04 PM]: CMD ERROR: /_conda/envs/[email protected]/bin/python /_conda/envs/[email protected]/lib/python3.8/site-packages/funannotate/aux_scripts/iprscan2annotations.py output/annotate_misc/iprscan.xml output/annotate_misc/annotations.iprscan.txt
[Apr 25 02:04 PM]: Traceback (most recent call last):
File "/_conda/envs/[email protected]/lib/python3.8/site-packages/funannotate/aux_scripts/iprscan2annotations.py", line 109, in <module>
main()
File "/_conda/envs/[email protected]/lib/python3.8/site-packages/funannotate/aux_scripts/iprscan2annotations.py", line 36, in main
for item in obo_parser.OBOReader(os.path.join(os.environ["FUNANNOTATE_DB"],
File "/_conda/envs/[email protected]/lib/python3.8/os.py", line 675, in __getitem__
raise KeyError(key) from None
KeyError: 'FUNANNOTATE_DB'
Apparently this line expects a FUNANNOTATE_DB which does not exist in my case (I used the --database option of funannotate annotate)
Try running this before running funannotate:
export FUNANNOTATE_DB=/path/to/funannotate/db
Alternatively, you can add a couple of files in your conda environment so the FUNANNOTATE_DB variable is set automatically when loaded.
The first one sets FUNANNOTATE_DB when you activate the environment:
touch /path/to/miniconda3/envs/funannotate/etc/conda/activate.d/funannotate.sh
and add the command to the activate.d/funannotate.sh:
export FUNANNOTATE_DB=/path/to/funannotate/db
And a second file so conda can unload the variable, when you deactivate the environment:
touch /path/to/miniconda3/envs/funannotate/etc/conda/deactivate.d/funannotate.sh
and add this to the deactivate.d/funannotate.sh:
unset FUNANNOTATE_DB
Yep I know I can do it, but when running funannotate annotate --database xxxx, funannotate sets the FUNANNOTATE_DB internally before calling other scripts. I would expect it to do the same when it calls iprscan2annotations.py
I'm getting the same error. I agree with @abretaud that it is very odd that funannotate expects an environment variable $FUNANNOTATE_DB to be set when there is a command line variable --database which should override that.
This sounds like a bug, it can be fixed I just need to find some time....