I changed from optparse to argparse but when I try to run it I get the following error:
if not option_string[0] in self.prefix_chars:
IndexError: string index out of range
My code is:
usage = "%prog -f <fasta TFs> -a <database all> -s <database small> -d <pfam database> [options]"
version = "1.0.1"
description = " "
epilog = " "\
" "
parser = argparse.ArgumentParser(usage=usage, description=description,
version="%prog "+version, epilog=epilog)
# options for running the program
# TF file
parser.add_argument("-f", "", dest="TF", metavar="<file>",
help="input file with transcription factors")
parser.set_defaults(fasta=None)
I can't find where this error comes from, how can fix this?
In argparse you can't pass empty argument strings to add_argument. argparse is trying to find a valid prefix_char (eg "-" or "--") in the empty string you pass (""), causing the error. Try this instead:
parser.add_argument("-f", dest="TF", metavar="<file>",
help="input file with transcription factors")
获取此错误的唯一方法是请求不存在的索引 - 在这种情况下, option_string
必须为空。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.