avierstr / amplicon_sorter

Sorts amplicons from Nanopore sequencing data based on similarity
32 stars 8 forks source link

unescaped % characters causing problems #12

Closed russellsmithies closed 1 year ago

russellsmithies commented 1 year ago

There some unescaped '%' characters in amplicon_sorter.py in the argument parsing section that cause this error

Traceback (most recent call last):
  File "/amplicon_sorter/amplicon_sorter.py", line 1821, in <module>
    args = get_arguments()
  File "/amplicon_sorter/amplicon_sorter.py", line 167, in get_arguments
    args = parser.parse_args()
  File "/usr/lib/python3.8/argparse.py", line 1780, in parse_args
    args, argv = self.parse_known_args(args, namespace)
  File "/usr/lib/python3.8/argparse.py", line 1812, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "/usr/lib/python3.8/argparse.py", line 2018, in _parse_known_args
    start_index = consume_optional(start_index)
  File "/usr/lib/python3.8/argparse.py", line 1958, in consume_optional
    take_action(action, args, option_string)
  File "/usr/lib/python3.8/argparse.py", line 1886, in take_action
    action(self, namespace, argument_values, option_string)
  File "/usr/lib/python3.8/argparse.py", line 1056, in __call__
    parser.print_help()
  File "/usr/lib/python3.8/argparse.py", line 2506, in print_help
    self._print_message(self.format_help(), file)
  File "/usr/lib/python3.8/argparse.py", line 2490, in format_help
    return formatter.format_help()
  File "/usr/lib/python3.8/argparse.py", line 294, in format_help
    help = self._root_section.format_help()
  File "/usr/lib/python3.8/argparse.py", line 225, in format_help
    item_help = join([func(*args) for func, args in self.items])
  File "/usr/lib/python3.8/argparse.py", line 225, in <listcomp>
    item_help = join([func(*args) for func, args in self.items])
  File "/usr/lib/python3.8/argparse.py", line 225, in format_help
    item_help = join([func(*args) for func, args in self.items])
  File "/usr/lib/python3.8/argparse.py", line 225, in <listcomp>
    item_help = join([func(*args) for func, args in self.items])
  File "/usr/lib/python3.8/argparse.py", line 541, in _format_action
    help_text = self._expand_help(action)
  File "/usr/lib/python3.8/argparse.py", line 633, in _expand_help
    return self._get_help_string(action) % params
ValueError: unsupported format character ')' (0x29) at index 23

It's this section here where the troublesome characters reside:

parser.add_argument('-ldc', '--length_diff_consensus', type = range_limited_float_0_200, 
                        required=False, default=8.0 ,
                        help='Length difference (in %) allowed between consensuses to\
                            COMBINE groups based on the consensus sequence\
                                (value between 0 and 200). Default=8.0 %')  

As they're just help docs I suggest changing them to the word 'percent' .

avierstr commented 1 year ago

Thanks for the notice. Fixed in version 2023_03_24