nextgenusfs / funannotate

Eukaryotic Genome Annotation Pipeline
http://funannotate.readthedocs.io
BSD 2-Clause "Simplified" License
300 stars 82 forks source link

funannotate annotate with interproscan input: KeyError: 'FUNANNOTATE_DB' #905

Open abretaud opened 1 year ago

abretaud commented 1 year ago

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/__funannotate@1.8.15/bin/python /_conda/envs/__funannotate@1.8.15/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/__funannotate@1.8.15/lib/python3.8/site-packages/funannotate/aux_scripts/iprscan2annotations.py", line 109, in <module>
    main()
  File "/_conda/envs/__funannotate@1.8.15/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/__funannotate@1.8.15/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)

xvazquezc commented 1 year ago

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
abretaud commented 1 year ago

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

novigit commented 8 months ago

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.

nextgenusfs commented 8 months ago

This sounds like a bug, it can be fixed I just need to find some time....