-
Notifications
You must be signed in to change notification settings - Fork 2
/
olivar
executable file
·200 lines (184 loc) · 8.97 KB
/
olivar
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
__author__ = 'Michael X. Wang'
__version__ = '1.2.1'
import argparse
from olivar import build, tiling, save, validate
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--version', '-v', action='version', version='%(prog)s v' + __version__)
subparsers = parser.add_subparsers(dest='subparser_name', help='sub-commands')
# build
build_parser = subparsers.add_parser('build', help='Build Olivar design reference.')
build_parser.add_argument(
'fasta_path', type=str, metavar='fasta-file',
help='Path to the FASTA reference sequence.')
build_parser.add_argument(
'--var', '-v', type=str, default=None, metavar='<string>',
help='Optional, path to the csv file of SNP coordinates and frequencies. Required columns: "START", "STOP", "FREQ". "FREQ" is considered as 1.0 if empty. Coordinates are 1-based.')
build_parser.add_argument(
'--db', '-d', type=str, default=None, metavar='<string>',
help='Optional, path to the BLAST database. Note that this path should end with the name of the BLAST database (e.g., "example_input/Human/GRCh38_primary").')
build_parser.add_argument(
'--output', '-o', type=str, default='./', metavar='<string>',
help='Output directory (output to current directory by default).')
build_parser.add_argument(
'--title', '-t', type=str, default=None, metavar='<string>',
help='Name of the Olivar reference file [FASTA record ID].')
build_parser.add_argument(
'--threads', '-p', type=int, default=1, metavar='<int>',
help='Number of threads [1].')
# tiling
tiling_parser = subparsers.add_parser('tiling', help='Design tiled amplicons based on a previously generated Olivar reference.')
tiling_parser.add_argument(
'ref_path', type=str, metavar='olvr-path',
help='Path to the Olivar reference file (.olvr), or the directory of reference files for multiple targets')
tiling_parser.add_argument(
'--output', '-o', type=str, default='./', metavar='<string>',
help='Output path (output to current directory by default).')
tiling_parser.add_argument(
'--title', '-t', type=str, default='olivar-design', metavar='<string>',
help='Name of design [olivar-design].')
tiling_parser.add_argument(
'--max-amp-len', type=int, default=420, metavar='<int>',
help='Maximum amplicon length [420].')
tiling_parser.add_argument(
'--min-amp-len', type=int, default=None, metavar='<int>',
help='Minimum amplicon length. 0.9*{max-amp-len} if not provided. Minimum 120.')
tiling_parser.add_argument(
'--w-egc', type=float, default=1.0, metavar='<float>',
help='Weight for extreme GC content [1.0].')
tiling_parser.add_argument(
'--w-lc', type=float, default=1.0, metavar='<float>',
help='Weight for low sequence complexity [1.0].')
tiling_parser.add_argument(
'--w-ns', type=float, default=1.0, metavar='<float>',
help='Weight for non-specificity [1.0].')
tiling_parser.add_argument(
'--w-var', type=float, default=1.0, metavar='<float>',
help='Weight for variations [1.0].')
tiling_parser.add_argument(
'--temperature', type=float, default=60.0, metavar='<float>',
help='PCR annealing temperature [60.0].')
tiling_parser.add_argument(
'--salinity', type=float, default=0.18, metavar='<float>',
help='Concentration of monovalent ions in units of molar [0.18].')
tiling_parser.add_argument(
'--dg-max', type=float, default=-11.8, metavar='<float>',
help='Maximum free energy change of a primer in kcal/mol [-11.8].')
tiling_parser.add_argument(
'--min-gc', type=float, default=0.2, metavar='<float>',
help='Minimum GC content of a primer [0.2].')
tiling_parser.add_argument(
'--max-gc', type=float, default=0.75, metavar='<float>',
help='Maximum GC content of a primer [0.75].')
tiling_parser.add_argument(
'--min-complexity', type=float, default=0.4, metavar='<float>',
help='Minimum sequence complexity of a primer [0.4].')
tiling_parser.add_argument(
'--max-len', type=int, default=36, metavar='<int>',
help='Maximum length of a primer [36].')
tiling_parser.add_argument(
'--check-var', action='store_true',
help="Filter out primer candidates with variations within 5nt of 3' end. \
NOT recommended when a lot of variations are provided, \
since this would significantly reduce the number of primer candidates. ")
tiling_parser.add_argument(
'--fp-prefix', type=str, default='', metavar='<DNA>',
help='Prefix of forward primer.')
tiling_parser.add_argument(
'--rp-prefix', type=str, default='', metavar='<DNA>',
help='Prefix of reverse primer.')
tiling_parser.add_argument(
'--seed', type=int, default=10, metavar='<int>',
help='Random seed for optimizing primer design regions and primer dimer [10].')
tiling_parser.add_argument(
'--threads', '-p', type=int, default=1, metavar='<int>',
help='Number of threads [1].')
# save
save_parser = subparsers.add_parser('save', help='Load from a previous Olivar design file (.olvd) and save output files.')
save_parser.add_argument(
'design_path', type=str, metavar='olvd-file',
help='Path to the Olivar design file (.olvd)')
save_parser.add_argument(
'--output', '-o', type=str, default='./', metavar='<string>',
help='Output path (output to current directory by default).')
# validate
validate_parser = subparsers.add_parser('validate', help='Validate existing multiplexed PCR primers.')
validate_parser.add_argument(
'primer_pool', type=str, metavar='csv-file',
help='Path to the csv file of a primer pool. Required columns: "amp_id" (amplicon name), "fP" (sequence of forward primer), "rP" (sequence of reverse primer).')
validate_parser.add_argument(
'--pool', type=int, default=1, metavar='<int>',
help='Primer pool number [1].')
validate_parser.add_argument(
'--db', '-d', type=str, default=None, metavar='<string>',
help='Optional, path to the BLAST database. Note that this path should end with the name of the BLAST database (e.g., "example_input/Human/GRCh38_primary").')
validate_parser.add_argument(
'--output', '-o', type=str, default='./', metavar='<string>',
help='Output path (output to current directory by default).')
validate_parser.add_argument(
'--title', '-t', type=str, default='olivar-val', metavar='<string>',
help='Name of validation [olivar-val].')
validate_parser.add_argument(
'--max-amp-len', type=int, default=1500, metavar='<int>',
help='Maximum length of predicted non-specific amplicon [1500]. Ignored is no BLAST database is provided.')
validate_parser.add_argument(
'--temperature', type=float, default=60.0, metavar='<float>',
help='PCR annealing temperature [60.0].')
validate_parser.add_argument(
'--threads', '-p', type=int, default=1, metavar='<int>',
help='Number of threads [1].')
args = parser.parse_args()
if args.subparser_name == 'build':
build(
fasta_path=args.fasta_path,
var_path=args.var,
BLAST_db=args.db,
out_path=args.output,
title=args.title,
threads=args.threads
)
elif args.subparser_name == 'tiling':
tiling(
ref_path=args.ref_path,
out_path=args.output,
title=args.title,
max_amp_len=args.max_amp_len,
min_amp_len=args.min_amp_len,
w_egc=args.w_egc,
w_lc=args.w_lc,
w_ns=args.w_ns,
w_var=args.w_var,
temperature=args.temperature,
salinity=args.salinity,
dG_max=args.dg_max,
min_GC=args.min_gc,
max_GC=args.max_gc,
min_complexity=args.min_complexity,
max_len=args.max_len,
check_var=args.check_var,
fP_prefix=args.fp_prefix,
rP_prefix=args.rp_prefix,
seed=args.seed,
threads=args.threads
)
elif args.subparser_name == 'save':
save(
design_out=args.design_path,
out_path=args.output
)
elif args.subparser_name == 'validate':
validate(
primer_pool=args.primer_pool,
pool=args.pool,
BLAST_db=args.db,
out_path=args.output,
title=args.title,
max_amp_len=args.max_amp_len,
temperature=args.temperature,
threads=args.threads
)
else:
print('A sub-command needs to be specified (build, tiling, save, validate).')
print("Use '--help' to print detailed descriptions of command line arguments")