jodyphelan / TBProfiler

Profiling tool for Mycobacterium tuberculosis to detect ressistance and strain type from WGS data
GNU General Public License v3.0
102 stars 42 forks source link

TBProfiler load_library cannot find newly created tbdb #313

Open ryanjameskennedy opened 7 months ago

ryanjameskennedy commented 7 months ago

Upon running the following command:

tb-profiler load_library test

The following error was returned:

Traceback (most recent call last):
  File "/data/bnf/sw/miniconda3/envs/tbprofiler/bin/tb-profiler", line 565, in <module>
    args.func(args)
  File "/data/bnf/sw/miniconda3/envs/tbprofiler/bin/tb-profiler", line 213, in main_load_library
    pp.load_db(variables_file,args.software_name,source_dir=source_dir)
  File "/data/bnf/sw/miniconda3/envs/tbprofiler/lib/python3.12/site-packages/pathogenprofiler/db.py", line 564, in load_db
    shutil.copyfile(source,target)
  File "/data/bnf/sw/miniconda3/envs/tbprofiler/lib/python3.12/shutil.py", line 260, in copyfile
    with open(src, 'rb') as fsrc:
         ^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/test.fasta'

The run works if you provide the filepath to the tbdb and the prefix to your newly created tbdb as so:

tb-profiler load_library /path/to/tbdb/test

But this is not the format provided on your README . Using the --dir command also doesn't work. Changing this line to the following solves the error:

source_dir = os.path.realpath(args.dir)

I can create a quick PR to correct this and fix the README if you're too busy:)

jodyphelan commented 7 months ago

Hi @ryanjameskennedy

Thanks for letting me know about this. If you could create a PR that would be amazing!

ryanjameskennedy commented 6 months ago

Also realised that dependencies for create_db (like pysam) are missing from the singularity image from galaxy project. An install_requires could be added to setup.py as follows:

 install_requires=["pysam", "python>=3.8", "pathogen-profiler", "joblib", "tqdm", "rich-argparse", "jinja2", "docxtpl", "filelock"],

This in combination with a requirements.txt file could perfectly solve this problem. Unless I have misunderstood something?

jodyphelan commented 5 months ago

I'm planning to upgrade the installation to use pyproject.toml instead of setup.py. So will add the dependancies in there.

ryanjameskennedy commented 5 months ago

If you haven't gotten around to it I can give it a go next week:)