siminegroup / E2EDNA2

GNU General Public License v3.0
17 stars 7 forks source link

Bug: Mysterious error when using invalid mode #13

Closed schackartk closed 2 years ago

schackartk commented 2 years ago

If the mode is misspelled or an invalid choice, an excpetion occurs:

$ python main.py --run_num=1 --mode='fulldock' --aptamerSeq='GCGCGCGCGATATATAT' --ligand='my_ligand.pdb' --ligandType='other' --ligandSeq=''
Traceback (most recent call last):
  File "main.py", line 229, in <module>
    opendna = opendna(params)  # instantiate the class
  File "/home/ken/personal/E2EDNA2/opendna.py", line 52, in __init__
    if self.actionDict['make workdir']:
KeyError: 'make workdir'

The exception doesn't seem to mention the invalid --mode, so the user may be confused as to what happened.

I have confirmed that this runs fine once the mode name is corrected.

This issue is resolved in #8 by using argparse and specifying the valid choices. Here is what is displayed from the code in that pull request:

$ ./main.py -r 1 -m 'fulldock' -a aptamers/my_aptamer.txt -l my_ligand.pdb -t other -f
usage: main.py [-h] [-f] -r INT -m MODE -a SEQ -l PDB [-t TYPE] [-s SEQ]
               [-d RUN] [-p DEV] [-w DIR] [-md DIR] [-mb MMB]
main.py: error: argument -m/--mode: invalid choice: 'fulldock' (choose from '2d structure', '3d coarse', '3d smooth', 'coarse dock', 'smooth dock', 'free aptamer', 'full dock', 'full binding')
taoliu032 commented 2 years ago

Nicely done! Thanks! Yeah, there wasn't explicit validation of the --mode argument.