def getArgs():
"""
Parses command line arguments and returns them to the caller
"""
__version__ = 'v0.2.5'
parser = argparse.ArgumentParser()
parser._action_groups.pop()
required = parser.add_argument_group('Required arguments')
required.add_argument('-i', '--input', required=True, metavar='<FILE>', help='Input file in FASTA format')
optional = parser.add_argument_group('Optional arguments')
optional.add_argument('-o', '--output', type=argparse.FileType('w'), metavar='<FILE>', default=sys.stdout, help='Output file name. Default: Input file name + _perf.tsv')
optional.add_argument('-a', '--analyse', action='store_true', default=False, help='Generate a summary HTML report.')
cutoff_group = optional.add_mutually_exclusive_group()
cutoff_group.add_argument('-l', '--min-length', type=int, metavar='<INT>', help='Minimum length cutoff of repeat')
cutoff_group.add_argument('-u', '--min-units', metavar='INT or FILE', help="Minimum number of repeating units to be considered. Can be an integer or a file specifying cutoffs for different motif sizes.")
optional.add_argument('-rep', '--repeats', type=argparse.FileType('r'), metavar='<FILE>', help='File with list of repeats (Not allowed with -m and/or -M)')
optional.add_argument('-m', '--min-motif-size', type=int, metavar='<INT>', help='Minimum size of a repeat motif in bp (Not allowed with -rep)')
optional.add_argument('-M', '--max-motif-size', type=int, metavar='<INT>', help='Maximum size of a repeat motif in bp (Not allowed with -rep)')
optional.add_argument('-s', '--min-seq-length', type=int, metavar = '<INT>', default=0, help='Minimum size of sequence length for consideration (in bp)')
optional.add_argument('-S', '--max-seq-length', type=float, metavar='<FLOAT>', default=inf, help='Maximum size of sequence length for consideration (in bp)')
seqid_group = optional.add_mutually_exclusive_group()
seqid_group.add_argument('-f', '--filter-seq-ids', metavar='<FILE>')
seqid_group.add_argument('-F', '--target-seq-ids', metavar='<FILE>')
optional.add_argument('--version', action='version', version='PERF ' + __version__)
args = parser.parse_args()
if args.repeats and (args.min_motif_size or args.max_motif_size):
parser.error("-rep is not allowed with -m/-M")
if args.repeats is None:
if args.min_motif_size is None:
args.min_motif_size = 1
if args.max_motif_size is None:
args.max_motif_size = 6
if args.output.name == "<stdout>":
args.output = open(splitext(args.input)[0] + '_perf.tsv', 'w')
return args
评论列表
文章目录