eggnogdb / eggnog-mapper

Fast genome-wide functional annotation through orthology assignment
http://eggnog-mapper.embl.de
GNU Affero General Public License v3.0
571 stars 105 forks source link

Setting custom database directory for download_eggnog_data.py does not work with custom directory #499

Open ndeimler99 opened 8 months ago

ndeimler99 commented 8 months ago

Running the command "download_eggnog_data.py -y --data_dir ./data" does not work. I have tried creating an empty "data" directory. Both result in the following error message.

"usage: download_eggnog_data.py [-h] [-D] [-F] [-P] [-M] [-H] [-d HMMER_DBS] [--dbname DBNAME] [-y] [-f] [-s] [-q] [--data_dir] download_eggnog_data.py: error: argument --data_dir: invalid existing_dir value: './data'"

The command works as expected when run without --data_dir

Cantalapiedra commented 6 months ago

Dear @ndeimler99 ,

The code checking this is:

def existing_dir(dname):
    dname = os.path.realpath(dname)
    if os.path.isdir(dname):
        return dname
    else:
        raise TypeError('not a valid directory "%s"' %dname)

I created a test script, like this:

#!/usr/bin/env python

import os, sys

def existing_dir(dname):
    dname = os.path.realpath(dname)
    if os.path.isdir(dname):
        return dname
    else:
        raise TypeError('not a valid directory "%s"' %dname)

dname = sys.argv[1]
print(dname)

mydir = existing_dir(dname)
print(mydir)

In linux command-line, I run:

./test_dir.py ./data
./data
Traceback (most recent call last):
  File "/home/cantalapiedra/test_dir/./test_dir.py", line 15, in <module>
    mydir = existing_dir(dname)
  File "/home/cantalapiedra/test_dir/./test_dir.py", line 10, in existing_dir
    raise TypeError('not a valid directory "%s"' %dname)
TypeError: not a valid directory "/home/cantalapiedra/test_dir/data"

and

mkdir data
./test_dir.py ./data
./data
/home/cantalapiedra/test_dir/data

Does this work for you?

Best, Carlos