kblin / ncbi-genome-download

Scripts to download genomes from the NCBI FTP servers
Apache License 2.0
956 stars 174 forks source link

Using ncbi-genome-download package #231

Closed ChillarAnand closed 3 months ago

ChillarAnand commented 3 months ago

Describe the bug Unable to pass options to ngd.download()

Downloading genomes for fungi
Traceback (most recent call last):
  File "/Users/chillaranand/homebrew/Caskroom/mambaforge/base/envs/bio3.8/bin/kdb", line 8, in <module>
    sys.exit(main())
  File "/Users/chillaranand/homebrew/Caskroom/mambaforge/base/envs/bio3.8/lib/python3.8/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/Users/chillaranand/homebrew/Caskroom/mambaforge/base/envs/bio3.8/lib/python3.8/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/Users/chillaranand/homebrew/Caskroom/mambaforge/base/envs/bio3.8/lib/python3.8/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/chillaranand/homebrew/Caskroom/mambaforge/base/envs/bio3.8/lib/python3.8/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/Users/chillaranand/homebrew/Caskroom/mambaforge/base/envs/bio3.8/lib/python3.8/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/chillaranand/projects/kraken-db-builder/kdb.py", line 130, in main
    download_genomes(context, db_type)
  File "/Users/chillaranand/projects/kraken-db-builder/kdb.py", line 116, in download_genomes
    ngd.download(group='bacteria', format='fasta')
  File "/Users/chillaranand/homebrew/Caskroom/mambaforge/base/envs/bio3.8/lib/python3.8/site-packages/ncbi_genome_download/core.py", line 165, in download
    config = NgdConfig.from_kwargs(**kwargs)
  File "/Users/chillaranand/homebrew/Caskroom/mambaforge/base/envs/bio3.8/lib/python3.8/site-packages/ncbi_genome_download/config.py", line 325, in from_kwargs
    raise ValueError("Unrecognized option(s): {}".format(kwargs.keys()))
ValueError: Unrecognized option(s): dict_keys(['group', 'format'])

Affected version 0.3.3

To Reproduce Steps to reproduce the behavior:

    ngd.download(group='bacteria', format='fasta')

Expected behavior It should accept kwargs

Additional context https://github.com/AvilPage/kraken-db-builder/

I am using ncbi-genome-download package for kraken-db-builder to download genomes.

ChillarAnand commented 3 months ago

I tried running the command via subprocess.run. Unfortunately, progress-bar details are not showing up when running via subprocess.

https://github.com/AvilPage/kraken-db-builder/blob/master/kdb.py#L121

kblin commented 3 months ago

the keyword args you're looking for are groups and file_formats.

kblin commented 3 months ago

like ngd.download(groups="bacteria", file_formats="fasta")

ChillarAnand commented 3 months ago

That worked. Thank you!

Screenshot 2024-08-05 at 18 54 52

If you can add this example to readme, that would be great.