phac-nml / mob-suite

MOB-suite: Software tools for clustering, reconstruction and typing of plasmids from draft assemblies
Apache License 2.0
124 stars 33 forks source link

NamesToTaxIDs() missing 1 required positional argument: 'ETE3DBTAXAFILE' #132

Closed k-krakowski closed 1 year ago

k-krakowski commented 1 year ago

Running mob_cluster command results in: NamesToTaxIDs() missing 1 required positional argument: 'ETE3DBTAXAFILE'. The error is in mob_cluster.py in line 528 -> taxids = NamesToTaxIDs(organisms) You can add ETE3DBTAXAFILE into constants.py, import it in utils.py and remove ETE3DBTAXAFILE from all functions arguments in utils.py. That should solve this issue.

ggl2151 commented 1 year ago

Hello, I also encountered the same problem, but I don't know how add ETE3DBTAXAFILE into constants.py. Is it like this. ETE3DBTAXAFILE = os.path.abspath("/home/guest504/miniconda3/lib/python3.8/site-packages/mob_suite-3.1.4-py3.8.egg/mob_suite/databases" + "/taxa.sqlite") Next, I entered 'from mob_suite.constants import ETE3DBTAXAFILE' in the utils.py Last, I want to remove ETE3DBTAXAFILE from all functions arguments in utils.py. But I found that there are too many ETE3DBTAXAFILEs in the utils.py, and I don't know how to delete them. Should I just delete the ETE3DBTAXAFILE string or should I also delete its related functions.I would be very grateful if you could answer.

kbessonov1984 commented 1 year ago

Hi, we have patched this issue in mob_typer and mob_recon previously (see issue #128 ) but not for the mob_cluster. All is needed is to provide the ETE3DBTAXAFILE with the path pointing to the taxa.sqlite file as a second argument to the NamesToTaxIDs(names,ETE3DBTAXAFILE) function located in utils.py file on line 528.

Here is a temporary manual fix:

  1. Modify the line 528 by adding the 2nd argument as a named constant ETE3DBTAXAFILE

    taxids = NamesToTaxIDs(organisms, ETE3DBTAXAFILE)
  2. Import default path to the database defined by default_database_dir variable by modifying line 19 and appending the missing variable. This will make sure it will a portable solution

      from mob_suite.constants import LOG_FORMAT, ACS_LETTER_VALUES, ACS_FORMAT_VALUES, ACS_VALUES_TO_LETTERS, MAX_ACS_VALUE, \
        MOB_TYPER_REPORT_HEADER, MOB_CLUSTER_INFO_HEADER, default_database_dir
  3. Optionally add the -d parameter to the list of existing parameters on lines 36-56 in case your databases folder is located elsewhere

      parser.add_argument('-d', '--database_directory',
                            default=default_database_dir,
                            required=False,
                            help='Directory you want to use for your databases. If the databases are not already '
                                 'downloaded, they will be downloaded automatically. Defaults to {}'.format(
                                default_database_dir))
  4. Define the ETE3DBTAXAFILE constant by adding these 2 lines of code in the main() somewhere after the line 447 so that the -d parameter will be defined by this point

     database_dir = os.path.abspath(args.database_directory)
     ETE3DBTAXAFILE = os.path.abspath(database_dir + "/taxa.sqlite")
ggl2151 commented 1 year ago

Yep, that fixed it. Thank you sir!
Also, let me remind my partner who has the same problem as me to pay attention to a small issue, NamesToTaxIDs(names,ETE3DBTAXAFILE) function located in mob_cluster.py on line 528.

jrober84 commented 1 year ago

The code update has been incorporated into MOB-cluster and will be part of the next release