-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcommandLineOptions.py
186 lines (159 loc) · 5.21 KB
/
commandLineOptions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/usr/bin/env python
import argparse
from ectyper import __version__
import json
import ectyper.definitions as definitions
def parse_command_line(args=None):
"""
Options for E. coli serotype prediction.
Args:
args: Optional args to be passed to argparse.parse_args()
Returns:
The populated argparse Namespace
"""
def check_percentage(value):
"""
type checker for percentage input
"""
try:
ivalue = int(value)
except ValueError:
raise argparse.ArgumentTypeError(
"{0} is not an integer. A valid positive integer percentage value is required".format(value)
)
if ivalue <= 0 or ivalue > 100:
raise argparse.ArgumentTypeError(
"{0} is an invalid positive integer percentage value".format(value)
)
return ivalue
def checkdbversion():
with open(file=definitions.SEROTYPE_ALLELE_JSON) as fp:
database = json.load(fp)
return database["version"]
dbversion = checkdbversion()
parser = argparse.ArgumentParser(
description='ectyper v{} antigen database v{}. Prediction of Escherichia coli serotype, pathotype and shiga toxin tying from '
'raw reads'
' or assembled genome sequences. The default settings are recommended.'.format(__version__, dbversion)
)
parser.add_argument(
"-V",
"--version",
action='version',
version="%(prog)s {} running database version {}".format(__version__,dbversion)
)
parser.add_argument(
"-i",
"--input",
help="Location of E. coli genome file(s). Can be a single file, a \
comma-separated list of files, or a directory",
required=True,
nargs="+"
)
parser.add_argument(
"--longreads",
action="store_true",
default=False,
help="Enable for raw long reads FASTQ inputs (ONT, PacBio, other sequencing platforms). [default %(default)s]"
)
parser.add_argument(
"--maxdirdepth",
help="Maximum number of directories to descend when searching an input directory of files [default %(default)s levels]. Only works on path inputs not containing '*' wildcard",
default=0,
type=int,
required=False
)
parser.add_argument(
"-c",
"--cores",
type=int,
help="The number of cores to run ectyper with",
default=1
)
parser.add_argument(
"-opid",
"--percentIdentityOtype",
type=check_percentage,
help="Percent identity required for an O antigen allele match [default %(default)s]",
default=95
)
parser.add_argument(
"-hpid",
"--percentIdentityHtype",
type=check_percentage,
help="Percent identity required for an H antigen allele match [default %(default)s]",
default=95
)
parser.add_argument(
"-opcov",
"--percentCoverageOtype",
type=check_percentage,
help="Minimum percent coverage required for an O antigen allele match [default %(default)s]",
default=90
)
parser.add_argument(
"-hpcov",
"--percentCoverageHtype",
type=check_percentage,
help="Minimum percent coverage required for an H antigen allele match [default %(default)s]",
default=50
)
parser.add_argument(
"--verify",
action="store_true",
help="Enable E. coli species verification"
)
parser.add_argument(
"-o",
"--output",
help="Directory location of output files"
)
parser.add_argument(
"-r",
"--reference",
default=definitions.SPECIES_ID_SKETCH,
help="Location of pre-computed MASH sketch for species identification. If provided, "
"genomes "
"identified as non-E. coli will have their species identified "
"using "
"MASH dist"
)
parser.add_argument(
"-s",
"--sequence",
action="store_true",
help="Prints the allele sequences if enabled as the final columns of "
"the output"
)
parser.add_argument(
"--debug",
action="store_true",
help="Print more detailed log including debug messages"
)
parser.add_argument(
"--dbpath",
help="Path to a custom database of O and H antigen alleles in JSON format.\n"
)
parser.add_argument(
"--pathotype",
action="store_true",
help="Predict E.coli pathotype and Shiga toxin subtype(s) if present\n"
)
parser.add_argument(
"-pathpid",
"--percentIdentityPathotype",
type=check_percentage,
help="Minimum percent identity required for a pathotype reference allele match [default: %(default)s]",
default=90
)
parser.add_argument(
"-pathpcov",
"--percentCoveragePathotype",
type=check_percentage,
help="Minimum percent coverage required for a pathotype reference allele match [default: %(default)s]",
default=50
)
if args is None:
return parser.parse_args()
else:
return parser.parse_args(args)