run_resfinder.py errors with no arguments

Issue #66 resolved
Peter Cock created an issue

The new-user experience could be improved.

Using resfinder 4.1.6 on Linux:

$ python run_resfinder.py 
Traceback (most recent call last):
  File "run_resfinder.py", line 197, in <module>
    sample_name = os.path.basename(args.inputfastq[0])
TypeError: 'NoneType' object is not subscriptable

Or:

$ ./run_resfinder.py 
Traceback (most recent call last):
  File "./run_resfinder.py", line 197, in <module>
    sample_name = os.path.basename(args.inputfastq[0])
TypeError: 'NoneType' object is not subscriptable

It would be sensible to just show the help text if no arguments are given, or version information, or at least a short message suggest running with -h instead.

Comments (5)

  1. CGE Helpdesk

    Dear Peter,

    Thank you for your interest in ResFinder.

    The latest ResFinder version (4.1.9) prints the relevant arguments to add to the command line if no input files are given.

    Best,
    Karen, CGE Helpdesk

  2. Peter Cock reporter

    I see the change made in 7c26c8dee4b2736883d880ab625807d784638373 but that looks wrong - n Python ``A or B is None`` means ``A or (B is None)`` not ``(A is None) or (B is None)``.

    $ python3 run_resfinder.py -ifa example.fasta
    ERROR: No input file given. Please provide path(s) to input file(s) either using --inputfasta or --inputfastq.
    

    Also comparing the arguments to None is unusual style, perhaps just evaluating as a boolean would suffice, as in if not (args.inputfasta or args.inputfastq):

  3. Log in to comment