Mercurial > repos > jpetteng > ectyper
comparison ecoli_serotyping/commandLineOptions.py @ 6:fe3ceb5c4214 draft
Uploaded
| author | jpetteng |
|---|---|
| date | Fri, 05 Jan 2018 15:43:14 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 5:a202cc394af8 | 6:fe3ceb5c4214 |
|---|---|
| 1 #!/usr/bin/env python | |
| 2 | |
| 3 import argparse | |
| 4 | |
| 5 | |
| 6 def parse_command_line(args=None): | |
| 7 """ | |
| 8 The options for both the serotyper, and virulence finder. | |
| 9 The returned object is used by both, but the options do not | |
| 10 necessarily apply to both. | |
| 11 | |
| 12 Args: | |
| 13 args: Optional args to be passed to argparse.parse_args() | |
| 14 | |
| 15 Returns: | |
| 16 The populated argparse Namespace | |
| 17 """ | |
| 18 | |
| 19 def check_percentage(value): | |
| 20 """ | |
| 21 type checker for percentage input | |
| 22 """ | |
| 23 ivalue = int(value) | |
| 24 if ivalue <= 0 or ivalue > 100: | |
| 25 raise argparse.ArgumentTypeError( | |
| 26 "{0} is an invalid positive int percentage value".format(value) | |
| 27 ) | |
| 28 return ivalue | |
| 29 | |
| 30 parser = argparse.ArgumentParser() | |
| 31 parser.add_argument( | |
| 32 "-i", | |
| 33 "--input", | |
| 34 help="Location of new file(s). Can be a single file or \ | |
| 35 a directory", | |
| 36 required=True | |
| 37 ) | |
| 38 | |
| 39 parser.add_argument( | |
| 40 "-d", | |
| 41 "--percentIdentity", | |
| 42 type=check_percentage, | |
| 43 help="Percentage of identity wanted to use against the\ | |
| 44 database. From 0 to 100, default is 90%%.", | |
| 45 default=90 | |
| 46 ) | |
| 47 | |
| 48 parser.add_argument( | |
| 49 "-l", | |
| 50 "--percentLength", | |
| 51 type=check_percentage, | |
| 52 help="Percentage of length wanted to use against the \ | |
| 53 database. From 0 to 100, default is 50%%.", | |
| 54 default=50 | |
| 55 ) | |
| 56 | |
| 57 parser.add_argument( | |
| 58 "--verify", | |
| 59 action="store_true", | |
| 60 help="Enable E. Coli. verification" | |
| 61 ) | |
| 62 | |
| 63 parser.add_argument( | |
| 64 "-s", | |
| 65 "--species", | |
| 66 action="store_true", | |
| 67 help="Enable species identification when non-ecoli genome is found\n\ | |
| 68 Note: refseq downloading is required when running this option for the first time." | |
| 69 ) | |
| 70 | |
| 71 parser.add_argument( | |
| 72 '--detailed', | |
| 73 action='store_true', | |
| 74 help='Enable detailed output' | |
| 75 ) | |
| 76 | |
| 77 parser.add_argument( | |
| 78 "-o", | |
| 79 "--output", | |
| 80 help="Directory location of output files." | |
| 81 ) | |
| 82 | |
| 83 if args is None: | |
| 84 return parser.parse_args() | |
| 85 return parser.parse_args(args) |
