-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodonpdx.py
More file actions
executable file
·223 lines (212 loc) · 5.27 KB
/
codonpdx.py
File metadata and controls
executable file
·223 lines (212 loc) · 5.27 KB
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#!/usr/bin/env python
import argparse
import codonpdx.calc
import codonpdx.clearresults
import codonpdx.count
import codonpdx.insert
import codonpdx.mirror
import codonpdx.queueJobs
import sys
# create the top-level parser
parser = argparse.ArgumentParser(prog='codonpdx',
description='Codonpdx command line utility.')
parser.add_argument('--version', action='version', version='%(prog)s 1.0')
subparsers = parser.add_subparsers(help='Sub-command descriptions:')
# create the parser for the "count" command
parserCount = subparsers.add_parser(
'count',
help='Count the codons of a file and produce JSON '
'output containing the results.'
)
parserCount.add_argument(
'-i',
'--infile',
nargs='?',
type=argparse.FileType('rU'),
default=sys.stdin,
help='A file containing sequence data.'
)
parserCount.add_argument(
'-g',
'--gzip',
action='store_true',
default=False,
help='Indicates the input is gzipped.'
)
parserCount.add_argument(
'-j',
'--job',
required=True,
help='The UUID for the job if this process is placing its results into '
'the results table.'
)
parserCount.add_argument(
'-f',
'--format',
choices=['fasta', 'genbank'],
help='The file format.'
)
parserCount.add_argument(
'-p',
'--pretty',
action='store_true',
help='Print the JSON in a pretty, more human-readable way.'
)
parserCount.add_argument(
'-o',
'--output',
nargs='?',
type=argparse.FileType('w'),
default=sys.stdout,
help='Where to place the output JSON.'
)
parserCount.add_argument(
'-s',
'--shuffle',
action='store_true',
default=False,
help='Indicates whether to generate a shuffled codon count'
)
parserCount.set_defaults(
func=codonpdx.count.count
)
# create the parser for the "insert" command
parserLoadDB = subparsers.add_parser(
'insert',
help='Insert organism codon count JSON information into a sequence '
'database.'
)
parserLoadDB.add_argument(
'-d',
'--dbname',
choices=['refseq', 'genbank'],
help='The database table to store the count information in.'
)
parserLoadDB.add_argument(
'-i',
'--infile',
nargs='?',
type=argparse.FileType('r'),
default=sys.stdin,
help='The file to to read the JSON data from. Defaults to standard input.'
)
parserLoadDB.set_defaults(
func=codonpdx.insert.insert
)
# create the parser for the "nsertInput" command
parserLoadDB = subparsers.add_parser(
'insertInput',
help='Insert organism codon count JSON information into the input.'
)
parserLoadDB.add_argument(
'-i',
'--infile',
nargs='?',
type=argparse.FileType('r'),
default=sys.stdin,
help='The file to to read the JSON data from. Defaults to standard input.'
)
parserLoadDB.add_argument(
'-j',
'--job',
required=True,
help='The UUID for the job if this process is placing its results into '
'the results table.'
)
parserLoadDB.set_defaults(
func=codonpdx.insert.insertinput
)
# create the parser for the "calc" command
parserCalcScore = subparsers.add_parser(
'calc',
help='Compare an organism to all other organisms in a given sequence '
'database.'
)
parserCalcScore.add_argument(
'-d',
'--dbname',
choices=['refseq', 'genbank'],
help='The sequence database to compare the organism to.'
)
parserCalcScore.add_argument(
'-v',
'--virus',
required=True,
help='The accession.version number of the organism to compare.'
)
parserCalcScore.add_argument(
'-w',
'--virusdb',
choices=['input', 'refseq', 'genbank'],
default='input',
help='The database table where the input virus resides.'
)
parserCalcScore.add_argument(
'-o',
'--output',
action='store_true',
help='Output scores to stdout instead of storing in the results table.'
)
parserCalcScore.add_argument(
'-j',
'--job',
required=True,
help='The UUID for the job if this process is placing its results into '
'the results table.'
)
parserCalcScore.set_defaults(
func=codonpdx.calc.calc
)
# create the mirror subcommand
parserMirror = subparsers.add_parser(
'mirror',
help='Mirror remote codon repository'
)
parserMirror.add_argument(
'-d',
'--dbname',
required=True,
choices=['refseq', 'genbank'],
help='The repository to mirror'
)
parserMirror.set_defaults(
func=codonpdx.mirror.mirror
)
# create the queueJobs subcommand
parserQueueJobs = subparsers.add_parser(
'queueJobs',
help='Count and load repository codon counts into postgres'
)
parserQueueJobs.add_argument(
'-d',
'--dbname',
required=True,
choices=['refseq', 'genbank'],
help='The repository to parse'
)
parserQueueJobs.add_argument(
'-f',
'--format',
choices=['fasta', 'genbank'],
help='The file format.'
)
parserQueueJobs.set_defaults(
func=codonpdx.queueJobs.queueJobs
)
# create the queueJobs subcommand
parserClearResults = subparsers.add_parser(
'clearResults',
help='clear the results table of data older than a week'
)
parserClearResults.add_argument(
'-d',
'--days',
type=int,
default=7,
help='Number of days to remove, default: 7'
)
parserClearResults.set_defaults(
func=codonpdx.clearresults.clear
)
args = parser.parse_args()
args.func(args)