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

mob_typer -d with not-yet-initialized db path fails #150

Closed phyden closed 1 year ago

phyden commented 1 year ago

Hi,

I stumbled across an issue regarding -d argument of mob_typer.

To reproduce this error: I installed mobsuite v 3.1.6 using

mamba create -c conda-forge -c bioconda -p /path/to/conda/mobsuite-conda mob_typer

and tried to run mob_typer specifying a different db-path which did not exist at this time. The reason is, that I would like to have the environment and the database on separate paths. However, running this code produced a weird error message, telling me that -i and -o are invalid arguments. mob_typer -i contigs.fa -o mobtyper_results.txt -d /db/mobsuite/typer

cmd-output:

2023-08-23 14:39:24,717 mob_suite.mob_typer INFO: Running Mob-typer version 3.1.6 [in /path/to/conda/mobsuite-conda/lib/python3.8/site-packages/mob_suite/mob_typer.py:173]
2023-08-23 14:39:24,717 mob_suite.mob_typer INFO: Processing fasta file contigs.fa [in /path/to/conda/mobsuite-conda/lib/python3.8/site-packages/mob_suite/mob_typer.py:175]
2023-08-23 14:39:24,718 mob_suite.mob_typer INFO: SUCCESS: Found program blastn at /path/to/conda/mobsuite-conda/bin/blastn [in /path/to/conda/mobsuite-conda/lib/python3.8/site-packages/mob_suite/utils.py:592]
2023-08-23 14:39:24,718 mob_suite.mob_typer INFO: SUCCESS: Found program makeblastdb at /path/to/conda/mobsuite-conda/bin/makeblastdb [in /path/to/conda/mobsuite-conda/lib/python3.8/site-packages/mob_suite/utils.py:592]
2023-08-23 14:39:24,718 mob_suite.mob_typer INFO: SUCCESS: Found program tblastn at /path/to/conda/mobsuite-conda/bin/tblastn [in /path/to/conda/mobsuite-conda/lib/python3.8/site-packages/mob_suite/utils.py:592]
2023-08-23 14:39:24,718 mob_suite.mob_typer INFO: Warning! Needed database missing "/db/mobsuite/typer/rep.dna.fas" [in /path/to/conda/mobsuite-conda/lib/python3.8/site-packages/mob_suite/mob_typer.py:321]
usage: mob_typer [-h] [-d DATABASE_DIRECTORY] [-v] [-V]
mob_typer: error: unrecognized arguments: -i contigs.fa -o mobtyper_results.txt

I was puzzled by this message, but it seems that the usage printed is actually the one from mob_init. So apparently the parameters just get forwarded into mob_init, which couldn't handle these additional arguments. The solution in my case was to just run mob_init -d /db/mobsuite/typer first and retried the mob_typer command, which ran to completion. However, due to the misleading usage-message I was very confused in the first place and thought I'd report this minor issue.

br Patrick

kbessonov1984 commented 1 year ago

Hi, looks like your database directory is missing the rep.dna.fas file or not initialized by mob_init -d <path to your external dir>. Also make sure your database external directory has all files downloaded and initialized by mob_init utility and the status.txt file is present.

https://github.com/phac-nml/mob-suite/blob/c2eec3800d0328d5da307ef2d163cf4f0194e109/mob_suite/utils.py#L662

Also check these similar issues https://github.com/phac-nml/mob-suite/issues/121 and https://github.com/phac-nml/mob-suite/issues/7

Hope you will soon resolve your issue

phyden commented 1 year ago

Thanks for your quick response. I did manage to resolve the issue by running mob_init instead of blindly using mob_typer without pre-fetching the database.

But I wanted to communicate this issue because the fall-back solution of mob_typer calling mob_init fails because mob_init tries to again parse the commandline-args which are not recognized by this argparser (-i and -o)

You could resolve this by changing the way arguments are parsed in mob_init like in this SO-post:

args, unknown = parser.parse_known_args()
kbessonov1984 commented 1 year ago

Fixed in release 3.1.7