Skip to content

Commit ca95dfe

Browse files
jkbonfieldpd3
authored andcommitted
Add short option -W for --write-index.
Given --write-index now takes an optional argument, and optional long options are --long-opt=arg and short options are -larg, I chose to also accept -l=arg for the sake of consistency and ease of documentation. The standard -larg still works too. If we wish to stick strictly to the normal conventions, then this is a trivial change in version.c (and a search and replace in the documentation). Also fix formatting bug in bcftools merge man page section leading to a lot of underlined text. Fixes #2139
1 parent 142fd1a commit ca95dfe

27 files changed

+141
-141
lines changed

csq.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3330,7 +3330,7 @@ static const char *usage(void)
33303330
" --targets-overlap 0|1|2 Include if POS in the region (0), record overlaps (1), variant overlaps (2) [0]\n"
33313331
" --threads INT Use multithreading with <int> worker threads [0]\n"
33323332
" -v, --verbose INT Verbosity level 0-2 [1]\n"
3333-
" --write-index[=FMT] Automatically index the output files [off]\n"
3333+
" -W, --write-index[=FMT] Automatically index the output files [off]\n"
33343334
"\n"
33353335
"Example:\n"
33363336
" bcftools csq -f hs37d5.fa -g Homo_sapiens.GRCh37.82.gff3.gz in.vcf\n"
@@ -3381,7 +3381,7 @@ int main_csq(int argc, char *argv[])
33813381
{"targets-file",1,0,'T'},
33823382
{"targets-overlap",required_argument,NULL,5},
33833383
{"no-version",no_argument,NULL,3},
3384-
{"write-index",optional_argument,NULL,6},
3384+
{"write-index",optional_argument,NULL,'W'},
33853385
{"dump-gff",required_argument,NULL,7},
33863386
{"unify-chr-names",required_argument,NULL,8},
33873387
{0,0,0,0}
@@ -3390,7 +3390,7 @@ int main_csq(int argc, char *argv[])
33903390
int regions_overlap = 1;
33913391
int targets_overlap = 0;
33923392
char *targets_list = NULL, *regions_list = NULL, *tmp;
3393-
while ((c = getopt_long(argc, argv, "?hr:R:t:T:i:e:f:o:O:g:s:S:p:qc:ln:bB:v:",loptions,NULL)) >= 0)
3393+
while ((c = getopt_long(argc, argv, "?hr:R:t:T:i:e:f:o:O:g:s:S:p:qc:ln:bB:v:W::",loptions,NULL)) >= 0)
33943394
{
33953395
switch (c)
33963396
{
@@ -3472,7 +3472,7 @@ int main_csq(int argc, char *argv[])
34723472
targets_overlap = parse_overlap_option(optarg);
34733473
if ( targets_overlap < 0 ) error("Could not parse: --targets-overlap %s\n",optarg);
34743474
break;
3475-
case 6 :
3475+
case 'W':
34763476
if (!(args->write_index = write_index_parse(optarg)))
34773477
error("Unsupported index format '%s'\n", optarg);
34783478
break;

doc/bcftools.txt

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,9 @@ Such a file can be easily created from a VCF using:
303303
Use multithreading with 'INT' worker threads. The option is currently used only for the compression of the
304304
output stream, only when '--output-type' is 'b' or 'z'. Default: 0.
305305

306-
*--write-index[=FMT]*::
307-
Automatically index the output files. FMT is optional and can be
308-
one of tbi or csi depending on output file format. Defaults to
306+
*-W*['FMT']*, -W*[='FMT']*, --write-index*[='FMT']::
307+
Automatically index the output files. 'FMT' is optional and can be
308+
one of "tbi" or "csi" depending on output file format. Defaults to
309309
CSI unless specified otherwise. Can be used only for compressed
310310
BCF and VCF output.
311311

@@ -512,9 +512,9 @@ Add or remove annotations.
512512
"^INFO/FOO,INFO/BAR" (and similarly for FORMAT and FILTER).
513513
"INFO" can be abbreviated to "INF" and "FORMAT" to "FMT".
514514

515-
*--write-index[=FMT]*::
516-
Automatically index the output file. FMT is optional and can be
517-
one of tbi or csi depending on output file format.
515+
*-W*['FMT']*, -W*[='FMT']*, --write-index*[='FMT']::
516+
Automatically index the output file. 'FMT' is optional and can be
517+
one of "tbi" or "csi" depending on output file format.
518518

519519
*Examples:*
520520
----
@@ -619,9 +619,9 @@ demand. The original calling model can be invoked with the *-c* option.
619619
*--threads* 'INT'::
620620
see *<<common_options,Common Options>>*
621621

622-
*--write-index[=FMT]*::
623-
Automatically index the output file. FMT is optional and can be
624-
one of tbi or csi depending on output file format.
622+
*-W*['FMT']*, -W*[='FMT']*, --write-index*[='FMT']::
623+
Automatically index the output file. 'FMT' is optional and can be
624+
one of "tbi" or "csi" depending on output file format.
625625

626626
==== Input/output options:
627627

@@ -900,9 +900,9 @@ are concatenated without being recompressed, which is very fast..
900900
*--threads* 'INT'::
901901
see *<<common_options,Common Options>>*
902902

903-
*--write-index[=FMT]*::
904-
Automatically index the output file. FMT is optional and can be
905-
one of tbi or csi depending on output file format.
903+
*-W*['FMT']*, -W*[='FMT']*, --write-index*[='FMT']::
904+
Automatically index the output file. 'FMT' is optional and can be
905+
one of "tbi" or "csi" depending on output file format.
906906

907907

908908
[[consensus]]
@@ -1057,9 +1057,9 @@ Note that the *-H, --haplotype* option requires the *-s, --samples* option, unle
10571057
*--targets-overlap* '0'|'1'|'2'::
10581058
see *<<common_options,Common Options>>*
10591059

1060-
*--write-index[=FMT]*::
1061-
Automatically index the output file. FMT is optional and can be
1062-
one of tbi or csi depending on output file format.
1060+
*-W*['FMT']*, -W*[='FMT']*, --write-index*[='FMT']::
1061+
Automatically index the output file. 'FMT' is optional and can be
1062+
one of "tbi" or "csi" depending on output file format.
10631063

10641064
==== VCF output options:
10651065

@@ -1459,9 +1459,9 @@ output VCF and are ignored for the prediction analysis.
14591459
and VCF, such as "chrX" vs "X". The chromosome names in the output VCF will match
14601460
that of the input VCF. The default is to attempt the automatic translation.
14611461

1462-
*--write-index[=FMT]*::
1463-
Automatically index the output file. FMT is optional and can be
1464-
one of tbi or csi depending on output file format.
1462+
*-W*['FMT']*, -W*[='FMT']*, --write-index*[='FMT']::
1463+
Automatically index the output file. 'FMT' is optional and can be
1464+
one of "tbi" or "csi" depending on output file format.
14651465

14661466
*Examples:*
14671467
----
@@ -1630,9 +1630,9 @@ And similarly here, the second is filtered:
16301630
*--threads* 'INT'::
16311631
see *<<common_options,Common Options>>*
16321632

1633-
*--write-index[=FMT]*::
1634-
Automatically index the output file. FMT is optional and can be
1635-
one of tbi or csi depending on output file format.
1633+
*-W*['FMT']*, -W*[='FMT']*, --write-index*[='FMT']::
1634+
Automatically index the output file. 'FMT' is optional and can be
1635+
one of "tbi" or "csi" depending on output file format.
16361636

16371637

16381638

@@ -1930,8 +1930,8 @@ in the other files.
19301930
comma-separated list of input files to output given as 1-based indices. With *-p* and no
19311931
*-w*, all files are written.
19321932

1933-
*--write-index[=FMT]*::
1934-
Automatically index the output file. FMT is optional and defaults
1933+
*-W*['FMT']*, -W*[='FMT']*, --write-index*[='FMT']::
1934+
Automatically index the output file. 'FMT' is optional and defaults
19351935
to tbi for vcf.gz and csi for bcf. This is done automatically
19361936
with the *-p* option if the output format is compressed.
19371937

@@ -2041,7 +2041,7 @@ For "vertical" merge take a look at *<<concat,bcftools concat>>* or *<<norm,bcft
20412041

20422042
*-m, --merge* 'snps'|'indels'|'both'|'snp-ins-del'|'all'|'none'|'id'[,'*']::
20432043
The option controls what types of multiallelic records can be created. If single asterisk
2044-
'*' is appended, the unobserved allele '<*>' or '<NON_REF>' will be removed at variant sites;
2044+
'\*' is appended, the unobserved allele '<*>' or '<NON_REF>' will be removed at variant sites;
20452045
if two asterisks '**' are appended, the unobserved allele will be removed all sites.
20462046
----
20472047
-m none .. no new multiallelics, output multiple records instead
@@ -2090,9 +2090,9 @@ For "vertical" merge take a look at *<<concat,bcftools concat>>* or *<<norm,bcft
20902090
*--threads* 'INT'::
20912091
see *<<common_options,Common Options>>*
20922092

2093-
*--write-index[=FMT]*::
2094-
Automatically index the output file. FMT is optional and can be
2095-
one of tbi or csi depending on output file format.
2093+
*-W*['FMT']*, -W*[='FMT']*, --write-index*[='FMT']::
2094+
Automatically index the output file. 'FMT' is optional and can be
2095+
one of "tbi" or "csi" depending on output file format.
20962096

20972097
[[mpileup]]
20982098
=== bcftools mpileup ['OPTIONS'] *-f* 'ref.fa' 'in.bam' ['in2.bam' [...]]
@@ -2355,9 +2355,9 @@ INFO/DPR .. Deprecated in favor of INFO/AD; Number of high-quality bases for
23552355
used by the earlier Bcftools releases. For excample BQBZ becomes
23562356
BQB.
23572357

2358-
*--write-index[=FMT]*::
2359-
Automatically index the output file. FMT is optional and can be
2360-
one of tbi or csi depending on output file format.
2358+
*-W*['FMT']*, -W*[='FMT']*, --write-index*[='FMT']::
2359+
Automatically index the output file. 'FMT' is optional and can be
2360+
one of "tbi" or "csi" depending on output file format.
23612361

23622362
==== Options for SNP/INDEL genotype likelihood computation
23632363

@@ -2645,9 +2645,9 @@ the *<<fasta_ref,--fasta-ref>>* option is supplied.
26452645
maximum distance between two records to consider when locally
26462646
sorting variants which changed position during the realignment
26472647

2648-
*--write-index[=FMT]*::
2649-
Automatically index the output file. FMT is optional and can be
2650-
one of tbi or csi depending on output file format.
2648+
*-W*['FMT']*, -W*[='FMT']*, --write-index*[='FMT']::
2649+
Automatically index the output file. 'FMT' is optional and can be
2650+
one of "tbi" or "csi" depending on output file format.
26512651

26522652
[[plugin]]
26532653

@@ -2705,9 +2705,9 @@ the usage examples that each plugin comes with.
27052705
*--threads* 'INT'::
27062706
see *<<common_options,Common Options>>*
27072707

2708-
*--write-index[=FMT]*::
2709-
Automatically index the output file. FMT is optional and can be
2710-
one of tbi or csi depending on output file format.
2708+
*-W*['FMT']*, -W*[='FMT']*, --write-index*[='FMT']::
2709+
Automatically index the output file. 'FMT' is optional and can be
2710+
one of "tbi" or "csi" depending on output file format.
27112711

27122712
==== Plugin options:
27132713

@@ -3342,9 +3342,9 @@ Transition probabilities:
33423342
Use this directory to store temporary files. If the last six characters of the string DIR are XXXXXX,
33433343
then these are replaced with a string that makes the directory name unique.
33443344

3345-
*--write-index[=FMT]*::
3346-
Automatically index the output file. FMT is optional and can be
3347-
one of tbi or csi depending on output file format.
3345+
*-W*['FMT']*, -W*[='FMT']*, --write-index*[='FMT']::
3346+
Automatically index the output file. 'FMT' is optional and can be
3347+
one of "tbi" or "csi" depending on output file format.
33483348

33493349

33503350

@@ -3493,9 +3493,9 @@ Convert between VCF and BCF. Former *bcftools subset*.
34933493
*--threads* 'INT'::
34943494
see *<<common_options,Common Options>>*
34953495

3496-
*--write-index[=FMT]*::
3497-
Automatically index the output file. FMT is optional and can be
3498-
one of tbi or csi depending on output file format.
3496+
*-W*['FMT']*, -W*[='FMT']*, --write-index*[='FMT']::
3497+
Automatically index the output file. 'FMT' is optional and can be
3498+
one of "tbi" or "csi" depending on output file format.
34993499

35003500

35013501
==== Subset options:

mpileup.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,7 @@ static void print_usage(FILE *fp, const mplp_conf_t *mplp)
12581258
" -O, --output-type TYPE 'b' compressed BCF; 'u' uncompressed BCF;\n"
12591259
" 'z' compressed VCF; 'v' uncompressed VCF; 0-9 compression level [v]\n"
12601260
" --threads INT Use multithreading with INT worker threads [0]\n"
1261-
" --write-index[=FMT] Automatically index the output files [off]\n"
1261+
" -W, --write-index[=FMT] Automatically index the output files [off]\n"
12621262
"\n"
12631263
"SNP/INDEL genotype likelihoods options:\n"
12641264
" -X, --config STR Specify platform profile (use \"-X list\" for details)\n"
@@ -1447,15 +1447,15 @@ int main_mpileup(int argc, char *argv[])
14471447
{"seed", required_argument, NULL, 13},
14481448
{"ambig-reads", required_argument, NULL, 14},
14491449
{"ar", required_argument, NULL, 14},
1450-
{"write-index",optional_argument,NULL,21},
1450+
{"write-index",optional_argument,NULL,'W'},
14511451
{"del-bias", required_argument, NULL, 23},
14521452
{"poly-mqual", no_argument, NULL, 24},
14531453
{"no-poly-mqual", no_argument, NULL, 26},
14541454
{"score-vs-ref",required_argument, NULL, 27},
14551455
{"seqq-offset", required_argument, NULL, 28},
14561456
{NULL, 0, NULL, 0}
14571457
};
1458-
while ((c = getopt_long(argc, argv, "Ag:f:r:R:q:Q:C:BDd:L:b:P:po:e:h:Im:F:EG:6O:xa:s:S:t:T:M:X:U",lopts,NULL)) >= 0) {
1458+
while ((c = getopt_long(argc, argv, "Ag:f:r:R:q:Q:C:BDd:L:b:P:po:e:h:Im:F:EG:6O:xa:s:S:t:T:M:X:UW::",lopts,NULL)) >= 0) {
14591459
switch (c) {
14601460
case 'x': mplp.flag &= ~MPLP_SMART_OVERLAPS; break;
14611461
case 16 :
@@ -1596,7 +1596,7 @@ int main_mpileup(int argc, char *argv[])
15961596
}
15971597
break;
15981598
case 20: mplp.indels_v20 = 1; mplp.edlib = 0; break;
1599-
case 21:
1599+
case 'W':
16001600
if (!(mplp.write_index = write_index_parse(optarg)))
16011601
error("Unsupported index format '%s'\n", optarg);
16021602
break;

plugins/contrast.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static const char *usage_text(void)
110110
" -t, --targets REG Similar to -r but streams rather than index-jumps\n"
111111
" -T, --targets-file FILE Similar to -R but streams rather than index-jumps\n"
112112
" --targets-overlap 0|1|2 Include if POS in the region (0), record overlaps (1), variant overlaps (2) [0]\n"
113-
" --write-index[=FMT] Automatically index the output files [off]\n"
113+
" -W, --write-index[=FMT] Automatically index the output files [off]\n"
114114
"\n"
115115
"Example:\n"
116116
" # Test if any of the samples a,b is different from the samples c,d,e\n"
@@ -487,12 +487,12 @@ int run(int argc, char **argv)
487487
{"targets",1,0,'t'},
488488
{"targets-file",1,0,'T'},
489489
{"targets-overlap",required_argument,NULL,4},
490-
{"write-index",optional_argument,NULL,5},
490+
{"write-index",optional_argument,NULL,'W'},
491491
{NULL,0,NULL,0}
492492
};
493493
int c;
494494
char *tmp;
495-
while ((c = getopt_long(argc, argv, "O:o:i:e:r:R:t:T:0:1:a:f:",loptions,NULL)) >= 0)
495+
while ((c = getopt_long(argc, argv, "O:o:i:e:r:R:t:T:0:1:a:f:W::",loptions,NULL)) >= 0)
496496
{
497497
switch (c)
498498
{
@@ -538,7 +538,7 @@ int run(int argc, char **argv)
538538
args->targets_overlap = parse_overlap_option(optarg);
539539
if ( args->targets_overlap < 0 ) error("Could not parse: --targets-overlap %s\n",optarg);
540540
break;
541-
case 5 :
541+
case 'W':
542542
if (!(args->write_index = write_index_parse(optarg)))
543543
error("Unsupported index format '%s'\n", optarg);
544544
break;

plugins/gvcfz.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static const char *usage_text(void)
102102
" -g, --group-by EXPR Group gVCF blocks according to the expression\n"
103103
" -o, --output FILE Write gVCF output to the FILE\n"
104104
" -O, --output-type u|b|v|z[0-9] u/b: un/compressed BCF, v/z: un/compressed VCF, 0-9: compression level [v]\n"
105-
" --write-index[=FMT] Automatically index the output files [off]\n"
105+
" -W, --write-index[=FMT] Automatically index the output files [off]\n"
106106
"Examples:\n"
107107
" # Compress blocks by GQ and DP. Multiple blocks separated by a semicolon can be defined\n"
108108
" bcftools +gvcfz input.bcf -g'PASS:GQ>60 & DP<20; PASS:GQ>40 & DP<15; Flt1:QG>20; Flt2:-'\n"
@@ -335,12 +335,12 @@ int run(int argc, char **argv)
335335
{"stats",required_argument,NULL,'s'},
336336
{"output",required_argument,NULL,'o'},
337337
{"output-type",required_argument,NULL,'O'},
338-
{"write-index",optional_argument,NULL,1},
338+
{"write-index",optional_argument,NULL,'W'},
339339
{NULL,0,NULL,0}
340340
};
341341
int c;
342342
char *tmp;
343-
while ((c = getopt_long(argc, argv, "vr:R:t:T:o:O:g:i:e:a",loptions,NULL)) >= 0)
343+
while ((c = getopt_long(argc, argv, "vr:R:t:T:o:O:g:i:e:aW::",loptions,NULL)) >= 0)
344344
{
345345
switch (c)
346346
{
@@ -371,7 +371,7 @@ int run(int argc, char **argv)
371371
if ( *tmp || args->clevel<0 || args->clevel>9 ) error("Could not parse argument: --compression-level %s\n", optarg+1);
372372
}
373373
break;
374-
case 1 :
374+
case 'W':
375375
if (!(args->write_index = write_index_parse(optarg)))
376376
error("Unsupported index format '%s'\n", optarg);
377377
break;

plugins/isecGT.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static const char *usage_text(void)
6969
" -R, --regions-file FILE Restrict to regions listed in a file\n"
7070
" -t, --targets REGION Similar to -r but streams rather than index-jumps\n"
7171
" -T, --targets-file FILE Similar to -R but streams rather than index-jumps\n"
72-
" --write-index[=FMT] Automatically index the output files [off]\n"
72+
" -W, --write-index[=FMT] Automatically index the output files [off]\n"
7373
"\n";
7474
}
7575

@@ -87,12 +87,12 @@ int run(int argc, char **argv)
8787
{"targets-file",required_argument,NULL,'T'},
8888
{"output",required_argument,NULL,'o'},
8989
{"output-type",required_argument,NULL,'O'},
90-
{"write-index",optional_argument,NULL,1},
90+
{"write-index",optional_argument,NULL,'W'},
9191
{NULL,0,NULL,0}
9292
};
9393
int c;
9494
char *tmp;
95-
while ((c = getopt_long(argc, argv, "o:O:r:R:t:T:",loptions,NULL)) >= 0)
95+
while ((c = getopt_long(argc, argv, "o:O:r:R:t:T:W::",loptions,NULL)) >= 0)
9696
{
9797
switch (c)
9898
{
@@ -119,7 +119,7 @@ int run(int argc, char **argv)
119119
case 'R': args->regions_list = optarg; args->regions_is_file = 1; break;
120120
case 't': args->targets_list = optarg; break;
121121
case 'T': args->targets_list = optarg; args->targets_is_file = 1; break;
122-
case 1 :
122+
case 'W':
123123
if (!(args->write_index = write_index_parse(optarg)))
124124
error("Unsupported index format '%s'\n", optarg);
125125
break;

plugins/mendelian2.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ static const char *usage_text(void)
142142
" -T, --targets-file FILE Similar to -R but streams rather than index-jumps\n"
143143
" --targets-overlap 0|1|2 Include if POS in the region (0), record overlaps (1), variant overlaps (2) [0]\n"
144144
" --no-version Do not append version and command line to the header\n"
145-
" --write-index[=FMT] Automatically index the output files [off]\n"
145+
" -W, --write-index[=FMT] Automatically index the output files [off]\n"
146146
"\n"
147147
"Options:\n"
148148
" -m, --mode c|[adeEgmMS] Output mode, the default is `-m c`. Multiple modes can be combined in VCF/BCF\n"
@@ -798,12 +798,12 @@ int run(int argc, char **argv)
798798
{"targets-overlap",required_argument,NULL,15},
799799
{"include",required_argument,0,'i'},
800800
{"exclude",required_argument,0,'e'},
801-
{"write-index",optional_argument,NULL,3},
801+
{"write-index",optional_argument,NULL,'W'},
802802
{0,0,0,0}
803803
};
804804
int c;
805805
char *tmp;
806-
while ((c = getopt_long(argc, argv, "?hp:P:m:o:O:i:e:t:T:r:R:",loptions,NULL)) >= 0)
806+
while ((c = getopt_long(argc, argv, "?hp:P:m:o:O:i:e:t:T:r:R:W::",loptions,NULL)) >= 0)
807807
{
808808
switch (c)
809809
{
@@ -858,7 +858,7 @@ int run(int argc, char **argv)
858858
case 'p': args->pfm = optarg; break;
859859
case 1 : args->rules_str = optarg; break;
860860
case 2 : args->rules_fname = optarg; break;
861-
case 3 :
861+
case 'W':
862862
if (!(args->write_index = write_index_parse(optarg)))
863863
error("Unsupported index format '%s'\n", optarg);
864864
break;

0 commit comments

Comments
 (0)