Skip to content

Commit 2a61cd4

Browse files
committed
Merge branch 'develop' of github.com:samtools/bcftools into develop
2 parents 78ed055 + df99320 commit 2a61cd4

30 files changed

+371
-171
lines changed

bcftools.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,15 @@ void error(const char *format, ...) HTS_NORETURN HTS_FORMAT(HTS_PRINTF_FMT, 1, 2
5050
void error_errno(const char *format, ...) HTS_NORETURN HTS_FORMAT(HTS_PRINTF_FMT, 1, 2);
5151

5252
// For on the fly index creation with --write-index
53-
int init_index(htsFile *fh, bcf_hdr_t *hdr, const char *fname, char **idx_fname);
53+
int init_index2(htsFile *fh, bcf_hdr_t *hdr, const char *fname,
54+
char **idx_fname, int idx_fmt);
55+
int init_index(htsFile *fh, bcf_hdr_t *hdr, const char *fname,
56+
char **idx_fname);
57+
58+
// Used to set args->write_index in CLI.
59+
// It will be true if set correctly.
60+
// Note due to HTS_FMT_CSI being zero we have to use an additional bit.
61+
int write_index_parse(char *arg);
5462

5563
void bcf_hdr_append_version(bcf_hdr_t *hdr, int argc, char **argv, const char *cmd);
5664
const char *hts_bcf_wmode(int file_type);

configure.ac

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,11 @@ AS_IF([test "$enable_perl_filters" != "no" ], [dnl
245245
PERL_CCOPTS="`perl -MExtUtils::Embed -e ccopts | sed 's,-arch i386,,'`"
246246
PERL_LIBS="`perl -MExtUtils::Embed -e ldopts | sed 's,-arch i386,,'`"
247247
fi
248+
AS_CASE([$PERL_LIBS],
249+
[*redhat/redhat-hardened-ld*],[[
250+
PERL_CCOPTS="`echo $PERL_CCOPTS | sed 's,-specs=[a-z/]*/redhat/redhat-hardened-[a-z0-9]* *,,g'`"
251+
PERL_LIBS="`echo $PERL_LIBS | sed 's,-specs=[a-z/]*/redhat/redhat-hardened-[a-z0-9]* *,,g'`"]
252+
AC_MSG_NOTICE([removing -specs=...redhat-hardened... from Perl options])])
248253
AC_SUBST([PERL_CCOPTS])
249254
AC_SUBST([PERL_LIBS])
250255

csq.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,9 @@ void init_data(args_t *args)
554554
if ( args->hdr_nsmpl )
555555
bcf_hdr_printf(args->hdr,"##FORMAT=<ID=%s,Number=.,Type=Integer,Description=\"Bitmask of indexes to INFO/BCSQ, with interleaved first/second haplotype. Use \\\"bcftools query -f'[%%CHROM\\t%%POS\\t%%SAMPLE\\t%%TBCSQ\\n]'\\\" to translate.\">",args->bcsq_tag);
556556
if ( bcf_hdr_write(args->out_fh, args->hdr)!=0 ) error("[%s] Error: cannot write the header to %s\n", __func__,args->output_fname?args->output_fname:"standard output");
557-
if ( args->write_index && init_index(args->out_fh,args->hdr,args->output_fname,&args->index_fn)<0 ) error("Error: failed to initialise index for %s\n",args->output_fname);
557+
if ( init_index2(args->out_fh,args->hdr,args->output_fname,
558+
&args->index_fn, args->write_index) < 0 )
559+
error("Error: failed to initialise index for %s\n",args->output_fname);
558560
}
559561
if ( args->verbosity > 0 ) fprintf(stderr,"Calling...\n");
560562
}
@@ -3328,7 +3330,7 @@ static const char *usage(void)
33283330
" --targets-overlap 0|1|2 Include if POS in the region (0), record overlaps (1), variant overlaps (2) [0]\n"
33293331
" --threads INT Use multithreading with <int> worker threads [0]\n"
33303332
" -v, --verbose INT Verbosity level 0-2 [1]\n"
3331-
" --write-index Automatically index the output files [off]\n"
3333+
" -W, --write-index[=FMT] Automatically index the output files [off]\n"
33323334
"\n"
33333335
"Example:\n"
33343336
" bcftools csq -f hs37d5.fa -g Homo_sapiens.GRCh37.82.gff3.gz in.vcf\n"
@@ -3379,7 +3381,7 @@ int main_csq(int argc, char *argv[])
33793381
{"targets-file",1,0,'T'},
33803382
{"targets-overlap",required_argument,NULL,5},
33813383
{"no-version",no_argument,NULL,3},
3382-
{"write-index",no_argument,NULL,6},
3384+
{"write-index",optional_argument,NULL,'W'},
33833385
{"dump-gff",required_argument,NULL,7},
33843386
{"unify-chr-names",required_argument,NULL,8},
33853387
{0,0,0,0}
@@ -3388,7 +3390,7 @@ int main_csq(int argc, char *argv[])
33883390
int regions_overlap = 1;
33893391
int targets_overlap = 0;
33903392
char *targets_list = NULL, *regions_list = NULL, *tmp;
3391-
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)
33923394
{
33933395
switch (c)
33943396
{
@@ -3470,7 +3472,10 @@ int main_csq(int argc, char *argv[])
34703472
targets_overlap = parse_overlap_option(optarg);
34713473
if ( targets_overlap < 0 ) error("Could not parse: --targets-overlap %s\n",optarg);
34723474
break;
3473-
case 6 : args->write_index = 1; break;
3475+
case 'W':
3476+
if (!(args->write_index = write_index_parse(optarg)))
3477+
error("Unsupported index format '%s'\n", optarg);
3478+
break;
34743479
case 7 : args->dump_gff = optarg; break;
34753480
case 8 :
34763481
if ( !strcmp(optarg,"0") ) args->unify_chr_names = 0;
@@ -3490,7 +3495,7 @@ int main_csq(int argc, char *argv[])
34903495
}
34913496
else fname = argv[optind];
34923497
if ( argc - optind>1 ) error("%s", usage());
3493-
if ( !args->fa_fname ) error("Missing the --fa-ref option\n");
3498+
if ( !args->fa_fname ) error("Missing the --fasta-ref option\n");
34943499
if ( !args->gff_fname ) error("Missing the --gff option\n");
34953500
args->sr = bcf_sr_init();
34963501
if ( targets_list )

doc/bcftools.txt

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,11 @@ 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*::
307-
Automatically index the output files. Can be used only for compressed BCF and VCF output.
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
309+
CSI unless specified otherwise. Can be used only for compressed
310+
BCF and VCF output.
308311

309312

310313
[[annotate]]
@@ -509,8 +512,9 @@ Add or remove annotations.
509512
"^INFO/FOO,INFO/BAR" (and similarly for FORMAT and FILTER).
510513
"INFO" can be abbreviated to "INF" and "FORMAT" to "FMT".
511514

512-
*--write-index*::
513-
Automatically index the output file
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.
514518

515519
*Examples:*
516520
----
@@ -615,8 +619,9 @@ demand. The original calling model can be invoked with the *-c* option.
615619
*--threads* 'INT'::
616620
see *<<common_options,Common Options>>*
617621

618-
*--write-index*::
619-
Automatically index the output file
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.
620625

621626
==== Input/output options:
622627

@@ -895,8 +900,9 @@ are concatenated without being recompressed, which is very fast..
895900
*--threads* 'INT'::
896901
see *<<common_options,Common Options>>*
897902

898-
*--write-index*::
899-
Automatically index the output file
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.
900906

901907

902908
[[consensus]]
@@ -1051,8 +1057,9 @@ Note that the *-H, --haplotype* option requires the *-s, --samples* option, unle
10511057
*--targets-overlap* '0'|'1'|'2'::
10521058
see *<<common_options,Common Options>>*
10531059

1054-
*--write-index*::
1055-
Automatically index the output file
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.
10561063

10571064
==== VCF output options:
10581065

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

1455-
*--write-index*::
1456-
Automatically index the output file
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.
14571465

14581466
*Examples:*
14591467
----
@@ -1622,8 +1630,9 @@ And similarly here, the second is filtered:
16221630
*--threads* 'INT'::
16231631
see *<<common_options,Common Options>>*
16241632

1625-
*--write-index*::
1626-
Automatically index the output file
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.
16271636

16281637

16291638

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

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

19271938
==== Examples:
19281939

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

20312042
*-m, --merge* 'snps'|'indels'|'both'|'snp-ins-del'|'all'|'none'|'id'[,'*']::
20322043
The option controls what types of multiallelic records can be created. If single asterisk
2033-
'*' 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;
20342045
if two asterisks '**' are appended, the unobserved allele will be removed all sites.
20352046
----
20362047
-m none .. no new multiallelics, output multiple records instead
@@ -2079,8 +2090,9 @@ For "vertical" merge take a look at *<<concat,bcftools concat>>* or *<<norm,bcft
20792090
*--threads* 'INT'::
20802091
see *<<common_options,Common Options>>*
20812092

2082-
*--write-index*::
2083-
Automatically index the output file
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.
20842096

20852097
[[mpileup]]
20862098
=== bcftools mpileup ['OPTIONS'] *-f* 'ref.fa' 'in.bam' ['in2.bam' [...]]
@@ -2343,8 +2355,9 @@ INFO/DPR .. Deprecated in favor of INFO/AD; Number of high-quality bases for
23432355
used by the earlier Bcftools releases. For excample BQBZ becomes
23442356
BQB.
23452357

2346-
*--write-index*::
2347-
Automatically index the output file
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.
23482361

23492362
==== Options for SNP/INDEL genotype likelihood computation
23502363

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

2635-
*--write-index*::
2636-
Automatically index the output file
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.
26372651

26382652
[[plugin]]
26392653

@@ -2691,8 +2705,9 @@ the usage examples that each plugin comes with.
26912705
*--threads* 'INT'::
26922706
see *<<common_options,Common Options>>*
26932707

2694-
*--write-index*::
2695-
Automatically index the output file
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.
26962711

26972712
==== Plugin options:
26982713

@@ -3333,8 +3348,9 @@ Transition probabilities:
33333348
Use this directory to store temporary files. If the last six characters of the string DIR are XXXXXX,
33343349
then these are replaced with a string that makes the directory name unique.
33353350

3336-
*--write-index*::
3337-
Automatically index the output file
3351+
*-W*['FMT']*, -W*[='FMT']*, --write-index*[='FMT']::
3352+
Automatically index the output file. 'FMT' is optional and can be
3353+
one of "tbi" or "csi" depending on output file format.
33383354

33393355

33403356

@@ -3483,8 +3499,9 @@ Convert between VCF and BCF. Former *bcftools subset*.
34833499
*--threads* 'INT'::
34843500
see *<<common_options,Common Options>>*
34853501

3486-
*--write-index*::
3487-
Automatically index the output file
3502+
*-W*['FMT']*, -W*[='FMT']*, --write-index*[='FMT']::
3503+
Automatically index the output file. 'FMT' is optional and can be
3504+
one of "tbi" or "csi" depending on output file format.
34883505

34893506

34903507
==== Subset options:

filter.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3682,7 +3682,8 @@ static filter_t *filter_init_(bcf_hdr_t *hdr, const char *str, int exit_on_error
36823682
if ( !out[i].tag ) continue;
36833683
if ( out[i].setter==filters_set_type )
36843684
{
3685-
if ( i+1==nout ) error("Could not parse the expression: %s\n", filter->str);
3685+
if ( i+1==nout || !out[i+1].key )
3686+
error("Could not parse the expression: %s\n", filter->str);
36863687
int itok, ival;
36873688
if ( out[i+1].tok_type==TOK_EQ || out[i+1].tok_type==TOK_NE ) ival = i - 1, itok = i + 1;
36883689
else if ( out[i+1].tok_type==TOK_LIKE || out[i+1].tok_type==TOK_NLIKE ) ival = i - 1, itok = i + 1;

mpileup.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,9 @@ static int mpileup(mplp_conf_t *conf)
863863
for (i=0; i<nsmpl; i++)
864864
bcf_hdr_add_sample(conf->bcf_hdr, smpl[i]);
865865
if ( bcf_hdr_write(conf->bcf_fp, conf->bcf_hdr)!=0 ) error("[%s] Error: failed to write the header to %s\n",__func__,conf->output_fname?conf->output_fname:"standard output");
866-
if ( conf->write_index && init_index(conf->bcf_fp,conf->bcf_hdr,conf->output_fname,&conf->index_fn)<0 ) error("Error: failed to initialise index for %s\n",conf->output_fname);
866+
if ( init_index2(conf->bcf_fp,conf->bcf_hdr,conf->output_fname,
867+
&conf->index_fn, conf->write_index) < 0 )
868+
error("Error: failed to initialise index for %s\n",conf->output_fname);
867869

868870
conf->bca = bcf_call_init(-1., conf->min_baseQ, conf->max_baseQ,
869871
conf->delta_baseQ);
@@ -1256,7 +1258,7 @@ static void print_usage(FILE *fp, const mplp_conf_t *mplp)
12561258
" -O, --output-type TYPE 'b' compressed BCF; 'u' uncompressed BCF;\n"
12571259
" 'z' compressed VCF; 'v' uncompressed VCF; 0-9 compression level [v]\n"
12581260
" --threads INT Use multithreading with INT worker threads [0]\n"
1259-
" --write-index Automatically index the output files [off]\n"
1261+
" -W, --write-index[=FMT] Automatically index the output files [off]\n"
12601262
"\n"
12611263
"SNP/INDEL genotype likelihoods options:\n"
12621264
" -X, --config STR Specify platform profile (use \"-X list\" for details)\n"
@@ -1445,15 +1447,15 @@ int main_mpileup(int argc, char *argv[])
14451447
{"seed", required_argument, NULL, 13},
14461448
{"ambig-reads", required_argument, NULL, 14},
14471449
{"ar", required_argument, NULL, 14},
1448-
{"write-index",no_argument,NULL,21},
1450+
{"write-index",optional_argument,NULL,'W'},
14491451
{"del-bias", required_argument, NULL, 23},
14501452
{"poly-mqual", no_argument, NULL, 24},
14511453
{"no-poly-mqual", no_argument, NULL, 26},
14521454
{"score-vs-ref",required_argument, NULL, 27},
14531455
{"seqq-offset", required_argument, NULL, 28},
14541456
{NULL, 0, NULL, 0}
14551457
};
1456-
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) {
14571459
switch (c) {
14581460
case 'x': mplp.flag &= ~MPLP_SMART_OVERLAPS; break;
14591461
case 16 :
@@ -1594,7 +1596,10 @@ int main_mpileup(int argc, char *argv[])
15941596
}
15951597
break;
15961598
case 20: mplp.indels_v20 = 1; mplp.edlib = 0; break;
1597-
case 21: mplp.write_index = 1; break;
1599+
case 'W':
1600+
if (!(mplp.write_index = write_index_parse(optarg)))
1601+
error("Unsupported index format '%s'\n", optarg);
1602+
break;
15981603
case 22: mplp.edlib = 1; mplp.indels_v20 = 0; break;
15991604
case 25: mplp.edlib = 0; break;
16001605
case 28:

plugins/contrast.c

Lines changed: 10 additions & 5 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 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"
@@ -236,7 +236,9 @@ static void init_data(args_t *args)
236236
args->out_fh = hts_open(args->output_fname ? args->output_fname : "-", wmode);
237237
if ( args->out_fh == NULL ) error("Can't write to \"%s\": %s\n", args->output_fname, strerror(errno));
238238
if ( bcf_hdr_write(args->out_fh, args->hdr_out)!=0 ) error("[%s] Error: cannot write to %s\n", __func__,args->output_fname);
239-
if ( args->write_index && init_index(args->out_fh,args->hdr_out,args->output_fname,&args->index_fn)<0 ) error("Error: failed to initialise index for %s\n",args->output_fname);
239+
if ( init_index2(args->out_fh,args->hdr_out,args->output_fname,
240+
&args->index_fn, args->write_index)<0 )
241+
error("Error: failed to initialise index for %s\n",args->output_fname);
240242

241243
if ( args->max_AC_str )
242244
{
@@ -485,12 +487,12 @@ int run(int argc, char **argv)
485487
{"targets",1,0,'t'},
486488
{"targets-file",1,0,'T'},
487489
{"targets-overlap",required_argument,NULL,4},
488-
{"write-index",no_argument,NULL,5},
490+
{"write-index",optional_argument,NULL,'W'},
489491
{NULL,0,NULL,0}
490492
};
491493
int c;
492494
char *tmp;
493-
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)
494496
{
495497
switch (c)
496498
{
@@ -536,7 +538,10 @@ int run(int argc, char **argv)
536538
args->targets_overlap = parse_overlap_option(optarg);
537539
if ( args->targets_overlap < 0 ) error("Could not parse: --targets-overlap %s\n",optarg);
538540
break;
539-
case 5 : args->write_index = 1; break;
541+
case 'W':
542+
if (!(args->write_index = write_index_parse(optarg)))
543+
error("Unsupported index format '%s'\n", optarg);
544+
break;
540545
case 'h':
541546
case '?':
542547
default: error("%s", usage_text()); break;

0 commit comments

Comments
 (0)