Skip to content
Snippets Groups Projects
Commit 67dc4e05 authored by Amandine  PERRIN's avatar Amandine PERRIN
Browse files

cutN must be a positive number

parent c681dc17
No related branches found
No related tags found
No related merge requests found
......@@ -479,7 +479,7 @@ def build_parser(parser):
optional.add_argument("--nbcont", dest="nbcont", type=utils_argparse.cont_num, default=999,
help=("Maximum number of contigs allowed to keep a genome. "
"Default is 999."))
optional.add_argument("--cutn", dest="cutn", type=int, default=5,
optional.add_argument("--cutn", dest="cutn", type=utils_argparse.positive_int, default=5,
help=("By default, each genome will be cut into new contigs when "
"at least 5 'N' in a row are found in its sequence. "
"If you don't want to "
......
......@@ -312,7 +312,7 @@ def build_parser(parser):
"By default, it will be saved in your "
"out_dir/tmp_files.")
)
general.add_argument("--cutn", dest="cutn", type=int, default=5,
general.add_argument("--cutn", dest="cutn", type=utils_argparse.positive_int, default=5,
help=("By default, each genome will be cut into new contigs when "
"at least 5 'N' in a row are found in its sequence. "
"If you don't want to "
......
......@@ -99,3 +99,15 @@ def thread_num(param):
elif param == 0:
return nb_cpu
return param
def positive_int(param):
try:
param = int(param)
except ValueError:
msg = f"error: argument --cutn: invalid int value: '{param}'"
raise argparse.ArgumentTypeError(msg)
if param < 0:
msg = f"error: argument --cutn must be a positive integer: invalid int value: '{param}'"
raise argparse.ArgumentTypeError(msg)
return param
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment