biocore / biom-format

The Biological Observation Matrix (BIOM) Format Project
http://biom-format.org
Other
90 stars 95 forks source link

biom convert is missing a switch to force overwrite of existing output #557

Closed maasha closed 8 years ago

maasha commented 9 years ago

This is biom-format==2.1

$ biom convert -i otu.tab -o otu.json --table-type="OTU table" --to-json
/usr/local/lib/python2.7/site-packages/biom/util.py:30: UserWarning: h5py is not available
  warn("h5py is not available")
Traceback (most recent call last):
  File "/usr/local/bin/pyqi", line 184, in <module>
    optparse_main(cmd_obj, argv[1:])
  File "/usr/local/lib/python2.7/site-packages/pyqi/core/interfaces/optparse/__init__.py", line 275, in optparse_main
    result = optparse_cmd(local_argv[1:])
  File "/usr/local/lib/python2.7/site-packages/pyqi/core/interface.py", line 41, in __call__
    return self._output_handler(cmd_result)
  File "/usr/local/lib/python2.7/site-packages/pyqi/core/interfaces/optparse/__init__.py", line 250, in _output_handler
    opt_value)
  File "/usr/local/lib/python2.7/site-packages/biom/interfaces/optparse/output_handler.py", line 59, in write_biom_table
    raise IOError("Output path '%s' already exists." % option_value)
IOError: Output path 'otu.json' already exists.
wasade commented 9 years ago

Good catch, thanks!

Jorge-C commented 9 years ago

Also, one thing that bothers me is that the existence of an existing file with the same name is only checked after conversion, so you're e.g. converting a big table, it does all the work and then errors out at the very end :(

wasade commented 9 years ago

Agree

On Mon, Nov 10, 2014 at 11:29 AM, Jorge Cañardo Alastuey < notifications@github.com> wrote:

Also, one thing that bothers me is that the existence of an existing file with the same name is only checked after conversion, so you're e.g. converting a big table, it does all the work and then errors out at the very end :(

— Reply to this email directly or view it on GitHub https://github.com/biocore/biom-format/issues/557#issuecomment-62430193.

wasade commented 9 years ago

@Jorge-C, unfortunately, it is difficult to do the check prior to conversion due to the way pyqi is currently structured. This will be deferred until the change to click.

@gregcaporaso, what's your take on doing a -f for force? Should we just overwrite or require an explicit -f. I ask because I think this was previously discussed with qiime

gregcaporaso commented 9 years ago

I think I like -f to overwrite here, since users could easily overwrite an existing file that might not be easy to reproduce (unlike e.g. for summarize-table, where the existing file is easy to reproduce, though of course this is a little subjective).

wasade commented 9 years ago

I'll see if this is not painful to add with pyqi. If it's straight forward, I'll put it in

wasade commented 9 years ago

Not straightforward to support as the Command does not get the output path, and the output handler cannot get added options. Differing to when BIOM uses click.

gregcaporaso commented 9 years ago

Sounds good, thanks for checking!

On Wed, Nov 19, 2014 at 10:37 AM, Daniel McDonald notifications@github.com wrote:

Not straightforward to support as the Command does not get the output path, and the output handler cannot get added options. Differing to when BIOM uses click.

Reply to this email directly or view it on GitHub https://github.com/biocore/biom-format/issues/557#issuecomment-63680301.

jairideout commented 8 years ago

Fixed in #668.