-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path_samtools
executable file
·306 lines (282 loc) · 7.4 KB
/
_samtools
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
#compdef samtools
# Usage: samtools <command> [options]
# see _samtools way below for the entrypoint
_samtools-collate() {
local ret=1
local -a args
args+=(
'-O[output to stdout]'
'-u[uncompressed BAM output]'
'-l+[compression level; default: 1]:int:'
'-n+[number of temporary files; default: 64]:int:'
'*:files:_files'
)
_arguments -w -s -S $args[@] && ret=0
return ret
}
_samtools-bedcov() {
_arguments '*:files:_files'
return 0
}
_samtools-calmd() {
local ret=1
local -a args
args+=(
# FIXME
# my version of samtools outputs the help for fillmd‽
'*:files:_files'
)
_arguments -w -s -S $args[@] && ret=0
return ret
}
_samtools-cat() {
local ret=1
local -a args
args+=(
'-h+[-h header.sam]:file:_files'
'-o+[-o out.bam]:file:_files'
'*:files:_files'
)
_arguments -w -s -S $args[@] && ret=0
return ret
}
_samtools-depth() {
local ret=1
local -a args
args+=(
'-b+[list of positions or regions]:bed:_files'
'-f+[list of input BAM filenames, one per line]:list:_files'
'-l+[minQLen]:int:'
'-q+[base quality threshold]:int:'
'-Q+[mapping quality threshold]:int:'
'-r+[chr:from-to]:region:'
'*:files:_files'
)
_arguments -w -s -S $args[@] && ret=0
return ret
}
_samtools-faidx() {
_arguments '*:files:_files'
return 0
}
_samtools-fixmate() {
local ret=1
local -a args
args+=(
'-r[remove unmapped reads and secondary alignments]'
'*:files:_files'
)
_arguments -w -s -S $args[@] && ret=0
return ret
}
_samtools-flagstat() {
_arguments '*:files:_files'
return 0
}
_samtools-idxstats() {
_arguments '*:files:_files'
return 0
}
_samtools-index() {
_arguments '*:files:_files'
return 0
}
_samtools-merge() {
local ret=1
local -a args
args+=(
'-1[compress level 1]'
'-@[number of BAM compression thread]:int:'
'-f[overwrite the output BAM if exist]'
'-h[copy the header in FILE to <out.bam>]:FILE:_files'
'-l+[compression level, from 0 to 9]:int:'
'-n[sort by read names]'
'-r[attach RG tag (inferred from file names)]'
'-R+[merge file in the specified region]:str:'
'-u[uncompressed BAM output]'
'*:files:_files'
)
_arguments -w -s -S $args[@] && ret=0
return ret
}
_samtools-mpileup() {
_arguments '*:files:_files'
return 0
}
_samtools-phase() {
local ret=1
local -a args
args+=(
'-A[drop reads with ambiguous phase]'
'-b+[prefix of BAMs to output (default: null)]:str:'
'-D+[max read depth (default: 256)]:int:'
'-F[do not attempt to fix chimeras]'
'-k+[block length (default: 13)]:int:'
'-Q+[min base quality in het calling (default: 13)]:int:'
'-q+[min het phred-LOD (default: 37)]:int:'
'*:files:_files'
)
_arguments -w -s -S $args[@] && ret=0
return ret
}
_samtools-reheader() {
_arguments '*:files:_files'
return 0
}
_samtools-rmdup() {
local ret=1
local -a args
args+=(
'-s[rmdup for SE reads]'
'-S[treat PE reads as SE]'
'*:files:_files'
)
_arguments -w -s -S $args[@] && ret=0
return ret
}
_samtools-sort() {
local ret=1
local -a args
args+=(
'-@[number of sorting and compression thread (default: 1)]:int:'
'-f[use <out.prefix> as full file name instead of prefix]'
'-l+[compression level, from 0 to 9 (default: -1)]:int:'
'-m+[max memory per thread; suffix K/M/G recognize (default: 768M)]:int:'
'-n[sort by read name]'
'-t[sort by value of TAG, uses position as secondary index (or read name if -n is set)]:str:'
'-o+[write final output to FILE]:files:_files'
'-O+[output format]:str:(SAM BAM CRAM)'
'*:files:_files'
)
_arguments -w -s -S $args[@] && ret=0
return ret
}
_samtools-targetcut() {
local ret=1
local -a args
args+=(
'-0+[-0 em0]:em0:'
'-1+[-1 em1]:em1:'
'-2+[-2 em2]:em2:'
'-f+[-f ref]:ref:'
'-i+[-i inPen]:inPen:'
'-Q+[-Q minQ]:minQ:'
'*:files:_files'
)
_arguments -w -s -S $args[@] && ret=0
return ret
}
_samtools-tview() {
local ret=1
local -a args
args+=(
'-d+[output format]:display:((
C\:Curses
H\:Html
T\:Text
))'
'-p+[got directly to this position]:chr pos:'
'-s+[display only reads from this sample or group]:str:'
'*:files:_files'
)
_arguments -w -s -S $args[@] && ret=0
return ret
}
_samtools-view() {
local ret=1
local -a args
args+=(
'-1[fast compression (force -b)]'
'-?[longer help]'
'-@[number of BAM compression threads (default: 0)]:int:'
'-B[collapse the backward CIGAR operation]'
'-b[output BAM]'
'-c[print only the count of matching records]'
'-C[output CRAM (requires -T)]'
'-F+[filtering flag, 0 for unset (default: 0)]:flag:->flags'
'-f+[required flag, 0 for unset (default: 0)]:flag:->flags'
'-h[print header for the SAM output]'
'-H[print header only (no alignments)]'
'-l+[only output reads in library STR (default: null)]:str:'
'-L+[output alignments overlapping the input BED FILE (default: null)]:file:_files'
'-M[use the multi-region iterator]'
'-N+[output only alignments with read name listed in FILE]:file:_files'
'-o+[output file name (default: stdout)]:file:_files'
'-O+[output format]:str:(SAM BAM CRAM)'
'-P[Retrieve pairs even when the mate is outside of the requested region]'
'-q+[minimum mapping quality (default: 0)]:int:'
'-R+[list of read groups to be outputted (default: null)]:file:_files'
'-r+[only output reads in read group STR (default: null)]:str:'
'-s+[fraction of templates to subsample; integer part as seed (default: -1)]:float:'
'-S[input format is auto-detected]'
'-t+[list of reference names and lengths (force -S) (default: null)]:file:_files'
'-T+[reference sequence file (default: null)]:file:_files'
'-u[uncompressed BAM output (force -b)]'
'-U+[output reads not selected by filters to FILE]:file:_files'
'-x[read tag to strip]:str:'
'*:files:_files'
)
_arguments -w -s -S $args[@] && ret=0
case "$state" in
(flags)
_values -s , 'flags' unmap munmap secondary supplementary qcfail dup paired proper_pair reverse mreverse read1 read2
;;
esac
return ret
}
_samtools() {
local ret=1
local -a args
if ((CURRENT == 2)); then
args+=(
'1:command:((
# samtools v1.8
# -- Indexing
dict:create\ a\ sequence\ dictionary\ file
faidx:index/extract\ FASTA
index:index\ alignment
# -- Editing
calmd:recalculate\ MD/NM\ tags\ and\ \"=\"\ bases
fixmate:fix\ mate\ information
reheader:replace\ BAM\ header
targetcut:cut\ fosmid\ regions\ \(for\ fosmid\ pool\ only\)
addreplacerg:adds\ or\ replaces\ RG\ tags
markdup:mark\ duplicates
collate:shuffle\ and\ group\ alignments\ by\ name
cat:concatenate\ BAMs
merge:merge\ sorted\ alignments
mpileup:multi\-way\ pileup
sort:sort\ alignment\ file
split:splits\ a\ file\ by\ read\ group
quickcheck:quickly\ check\ if\ SAM/BAM/CRAM\ file\ appears\ intact
fastq:converts\ a\ BAM\ to\ a\ FASTQ
fasta:converts\ a\ BAM\ to\ a\ FASTA
# -- Statistics
bedcov:read\ depth\ per\ BED\ region
depth:compute\ the\ depth
flagstat:simple\ stats
idxstats:BAM\ index\ stats
phase:phase\ heterozygotes
stats:generate\ stats\ \(former\ bamcheck\)
# -- Viewing
flags:explain\ BAM\ flags
tview:text\ alignment\ viewer
view:SAM\<\-\>BAM\<\-\>CRAM\ conversion
depad:convert\ padded\ BAM\ to\ unpadded\ BAM
# deprecated?
rmdup:remove\ PCR\ duplicates
))'
'(- *)--help[Display help message]'
)
_arguments $args[@] && ret=0
return ret
else
# delegate to sub commands
local subcmd=_samtools-$words[2]
if ! _call_function ret $subcmd ; then
_message "unknown sub-command: $words[2]"
fi
return ret
fi
}
_samtools