Skip to content

Commit 63c9e6c

Browse files
committed
[view] removed --unmapped option, use region '*'
1 parent 24b59d1 commit 63c9e6c

File tree

2 files changed

+16
-29
lines changed

2 files changed

+16
-29
lines changed

etc/bash_completion.d/sambamba

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@ _sambamba()
1010
elif [[ $cur == -* ]]; then
1111
case "$subcommand" in
1212
view)
13-
COMPREPLY=( $(compgen -W "-F -f -h -H -I -c -U -S -p \
14-
-l -o -t -s --filter= \
15-
--format= --with-header --header \
13+
COMPREPLY=( $(compgen -W "-F -f -h -H -I -c -S -p \
14+
-l -o -t -s --filter= --header \
15+
--format= --with-header --count \
1616
--reference-info --show-progress \
17-
--count --unmapped --sam-input \
17+
--sam-input --output-filename= \
1818
--nthreads= --compression-level= \
19-
--subsample= --subsampling-seed= \
20-
--output-filename=" -- $cur))
19+
--subsample= --subsampling-seed=" -- $cur) )
2120
;;
2221
index)
2322
COMPREPLY=( $(compgen -W "-p -t --nthreads= --show-progress" -- $cur) )

sambamba/view.d

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ void printUsage() {
5959
stderr.writeln(" output to stdout only reference names and lengths in JSON");
6060
stderr.writeln(" -c, --count");
6161
stderr.writeln(" output to stdout only count of matching records, hHI are ignored");
62-
stderr.writeln(" -U, --unmapped");
63-
stderr.writeln(" output reads with RNAME = *; available for indexed BAM only");
6462
stderr.writeln(" -v, --valid");
6563
stderr.writeln(" output only valid alignments");
6664
stderr.writeln(" -S, --sam-input");
@@ -107,7 +105,6 @@ bool with_header;
107105
bool header_only;
108106
bool reference_info_only;
109107
bool count_only;
110-
bool unmapped_only;
111108
bool skip_invalid_alignments;
112109
bool is_sam;
113110

@@ -140,7 +137,6 @@ int view_main(string[] args) {
140137
"header|H", &header_only,
141138
"reference-info|I", &reference_info_only,
142139
"count|c", &count_only,
143-
"unmapped|U", &unmapped_only,
144140
"valid|v", &skip_invalid_alignments,
145141
"sam-input|S", &is_sam,
146142
"show-progress|p", &show_progress,
@@ -202,18 +198,6 @@ int sambambaMain(T)(T _bam, TaskPool pool, string[] args)
202198
return 0;
203199
}
204200

205-
static if (is(T == SamReader)) {
206-
if (unmapped_only) {
207-
stderr.writeln("--unmapped option is available only for indexed BAMs");
208-
return -1;
209-
}
210-
}
211-
212-
if (unmapped_only && args.length > 2) {
213-
stderr.writeln("--unmapped option can't be used together with regions");
214-
return -1;
215-
}
216-
217201
if (header_only && !count_only) {
218202
// write header to stdout
219203
(new HeaderSerializer(stdout, format)).writeln(bam.header);
@@ -271,10 +255,7 @@ int sambambaMain(T)(T _bam, TaskPool pool, string[] args)
271255
runProcessor(bam, reads, read_filter);
272256
bar.finish();
273257
} else {
274-
if (unmapped_only)
275-
runProcessor(bam, bam.unmappedReads(), read_filter);
276-
else
277-
runProcessor(bam, bam.reads!withoutOffsets(), read_filter);
258+
runProcessor(bam, bam.reads!withoutOffsets(), read_filter);
278259
}
279260
} else { // SamFile
280261
runProcessor(bam, bam.reads, read_filter);
@@ -286,12 +267,19 @@ int sambambaMain(T)(T _bam, TaskPool pool, string[] args)
286267
if (args.length > 2) {
287268
auto regions = map!parseRegion(args[2 .. $]);
288269

289-
alias ReturnType!(ReferenceSequence.opSlice) AlignmentRange;
270+
alias InputRange!BamReadBlock AlignmentRange;
290271
auto alignment_ranges = new AlignmentRange[regions.length];
291272

292273
size_t i = 0;
293-
foreach (ref r; regions) {
294-
alignment_ranges[i++] = bam[r.reference][r.beg .. r.end];
274+
foreach (region_description; args[2 .. $]) {
275+
AlignmentRange range;
276+
if (region_description == "*") {
277+
range = bam.unmappedReads().inputRangeObject;
278+
} else {
279+
auto r = parseRegion(region_description);
280+
range = bam[r.reference][r.beg .. r.end].inputRangeObject;
281+
}
282+
alignment_ranges[i++] = range;
295283
}
296284

297285
auto reads = joiner(alignment_ranges);

0 commit comments

Comments
 (0)