Skip to content

Commit 4bfc0c1

Browse files
committed
Merge branch 'develop' of github.com:samtools/bcftools into develop
2 parents 0b5e2b3 + 2ebe686 commit 4bfc0c1

File tree

6 files changed

+43
-20
lines changed

6 files changed

+43
-20
lines changed

NEWS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ Changes affecting specific commands:
2323
when the site is monoallelic in both query and genotype file. The new option --keep-refs
2424
allows to always include monoallelic sites.
2525

26+
- Fix an error in parsing -i/-e command line options where the `qry:` and `gt:` prefix was
27+
not stripped (#2432)
28+
29+
* bcftools mpileup
30+
31+
- Make `-d, --max-depth 0` set the depth to unlimited (#2435)
32+
2633
* bcftools norm
2734

2835
- Make the -i/-e filtering option work for all options, such as line merging and

doc/bcftools.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2308,7 +2308,8 @@ those scenarios.
23082308
This behavior was problematic when working with a combination of
23092309
single- and multi-sample bams, therefore in *bcftools mpileup* the user
23102310
is given the full control (and responsibility), and an informative message
2311-
is printed instead [250]
2311+
is printed instead. Passing zero for this option sets it to the highest possible
2312+
value, effectively removing the depth limit [250]
23122313

23132314
*-E, --redo-BAQ*::
23142315
Recalculate BAQ on the fly, ignore existing BQ tags

mpileup.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -930,11 +930,19 @@ static int mpileup(mplp_conf_t *conf)
930930
// init mpileup
931931
conf->iter = bam_mplp_init(conf->nfiles, mplp_func, (void**)conf->mplp_data);
932932
if ( conf->flag & MPLP_SMART_OVERLAPS ) bam_mplp_init_overlaps(conf->iter);
933-
fprintf(stderr, "[%s] maximum number of reads per input file set to -d %d\n", __func__, conf->max_depth);
934-
if ( (double)conf->max_depth * conf->nfiles > 1<<20)
935-
fprintf(stderr, "Warning: Potential memory hog, up to %.0fM reads in the pileup!\n", (double)conf->max_depth*conf->nfiles);
936-
if ( (double)conf->max_depth * conf->nfiles / nsmpl < 250 )
937-
fprintf(stderr, "Note: The maximum per-sample depth with -d %d is %.1fx\n", conf->max_depth,(double)conf->max_depth * conf->nfiles / nsmpl);
933+
if ( !conf->max_depth )
934+
{
935+
conf->max_depth = INT_MAX;
936+
fprintf(stderr, "[%s] Max depth set to maximum value (%d)\n", __func__, INT_MAX);
937+
}
938+
else
939+
{
940+
fprintf(stderr, "[%s] maximum number of reads per input file set to -d %d\n", __func__, conf->max_depth);
941+
if ( (double)conf->max_depth * conf->nfiles > 1<<20)
942+
fprintf(stderr, "Warning: Potential memory hog, up to %.0fM reads in the pileup!\n", (double)conf->max_depth*conf->nfiles);
943+
if ( (double)conf->max_depth * conf->nfiles / nsmpl < 250 )
944+
fprintf(stderr, "Note: The maximum per-sample depth with -d %d is %.1fx\n", conf->max_depth,(double)conf->max_depth * conf->nfiles / nsmpl);
945+
}
938946
bam_mplp_set_maxcnt(conf->iter, conf->max_depth);
939947
conf->max_indel_depth = conf->max_indel_depth * nsmpl;
940948
conf->bcf_rec = bcf_init1();

test/norm.vcf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
##INFO=<ID=ISTR,Number=1,Type=String,Description="Test String in INFO">
3636
##INFO=<ID=END,Number=1,Type=Integer,Description="End position">
3737
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT XY00001 XY00002
38+
1 60 . A T 999 PASS AN=4;AC=4 GT 0/0 0/1
3839
1 105 . TAAACCCTAAA TAA,TAACCCTAAA 999 PASS INDEL;AN=4;AC=2,2;DP=19;ISTR=SomeString;XRF=1e+06,2e+06,500000;XRI=1111,2222,5555;XRS=AAA,BBB,DDD;XAF=1e+06,500000;XAI=1111,5555;XAS=AAA,DDD;XGF=1e+06,2e+06,3e+06,500000,.,9e+09;XGI=1111,2222,3333,5555,.,9999;XGS=A,B,C,E,.,F GT:PL:DP:FRF:FRI:FRS:FAF:FAI:FAS:FGF:FGI:FGS 1/2:1,2,3,4,5,6:1:1e+06,2e+06,500000:1111,2222,5555:AAAA,BBB,CC:1e+06,500000:1111,5555:A,BB:1e+06,2e+06,3e+06,500000,.,9e+09:1111,2222,3333,5555,.,9999:A,BB,CCC,EEEE,.,FFFFF 1/2:1,2,3,4,5,6:1:1e+06,2e+06,500000:1111,2222,5555:AAAA,BBB,CC:1e+06,500000:1111,5555:A,BB:1e+06,2e+06,3e+06,500000,.,9e+09:1111,2222,3333,5555,.,9999:A,BB,CCC,EEEE,.,FFFFF
3940
2 1 . GGGCGTCTCATAGCTGGAGCAATGGCGAGCGCCTGGACAAGGGAGGGGAAGGGGTTCTTATTACTGACGCGGGTAGCCCCTACTGCTGTGTGGTTCCCCTATTTTTTTTTTTTTCTTTTTGAGACGGAGTCTCGCTCTGTCACCCAGGCTGGAGTGCAGTGGCACAATCTCGGCTCACTGCAAGCTCCACCT ACGT 999 PASS INDEL;AN=4;AC=2;END=192 GT:DP 1/0:1 1/0:1
4041
2 101 . ATTTTTTTTTTTTT ATTTTTTTTTTTTTTT 999 PASS INDEL;AN=4;AC=4;END=114 GT:DP 1/1:1 1/1:1

vcfgtcheck.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,13 +1324,13 @@ int main_vcfgtcheck(int argc, char *argv[])
13241324
if ( !strncasecmp("gt:",optarg,3) )
13251325
{
13261326
if ( args->gt_filter_str ) error("Error: only one -i or -e expression can be given for gt:, and they cannot be combined\n");
1327-
args->gt_filter_str = optarg;
1327+
args->gt_filter_str = optarg+3;
13281328
args->gt_filter_logic |= FLT_EXCLUDE;
13291329
}
13301330
else if ( !strncasecmp("qry:",optarg,4) )
13311331
{
13321332
if ( args->qry_filter_str ) error("Error: only one -i or -e expression can be given for qry:, and they cannot be combined\n");
1333-
args->qry_filter_str = optarg;
1333+
args->qry_filter_str = optarg+4;
13341334
args->qry_filter_logic |= FLT_EXCLUDE;
13351335
}
13361336
else
@@ -1355,13 +1355,13 @@ int main_vcfgtcheck(int argc, char *argv[])
13551355
if ( !strncasecmp("gt:",optarg,3) )
13561356
{
13571357
if ( args->gt_filter_str ) error("Error: only one -i or -e expression can be given for gt:, and they cannot be combined\n");
1358-
args->gt_filter_str = optarg;
1358+
args->gt_filter_str = optarg+3;
13591359
args->gt_filter_logic |= FLT_INCLUDE;
13601360
}
13611361
else if ( !strncasecmp("qry:",optarg,4) )
13621362
{
13631363
if ( args->qry_filter_str ) error("Error: only one -i or -e expression can be given for qry:, and they cannot be combined\n");
1364-
args->qry_filter_str = optarg;
1364+
args->qry_filter_str = optarg+4;
13651365
args->qry_filter_logic |= FLT_INCLUDE;
13661366
}
13671367
else

vcfnorm.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2328,8 +2328,8 @@ static void destroy_data(args_t *args)
23282328
if ( args->mseq ) free(args->seq);
23292329
}
23302330

2331-
2332-
static void normalize_line(args_t *args, bcf1_t *line)
2331+
// return 0 on success, -1 if line was skipped (due to ref mismatch)
2332+
static int normalize_line(args_t *args, bcf1_t *line)
23332333
{
23342334
if ( args->fai )
23352335
{
@@ -2346,7 +2346,7 @@ static void normalize_line(args_t *args, bcf1_t *line)
23462346
if ( ret==ERR_REF_MISMATCH && args->check_ref & CHECK_REF_SKIP )
23472347
{
23482348
args->nskipped++;
2349-
return;
2349+
return -1;
23502350
}
23512351
if ( ret==ERR_DUP_ALLELE )
23522352
{
@@ -2388,9 +2388,10 @@ static void normalize_line(args_t *args, bcf1_t *line)
23882388
}
23892389
if ( !args->filter_pass || args->atomize!=SPLIT ) break;
23902390
}
2391+
return 0;
23912392
}
23922393

2393-
// return 0 on success, 1 when done
2394+
// return 0 on success, 1 when done, -1 if line skipped
23942395
static int split_and_normalize(args_t *args)
23952396
{
23962397
if ( !bcf_sr_next_line(args->files) ) return 1;
@@ -2408,8 +2409,7 @@ static int split_and_normalize(args_t *args)
24082409
if ( args->mrows_op!=MROWS_SPLIT || line->n_allele<=2 || !args->filter_pass )
24092410
{
24102411
// normal operation, no splitting
2411-
normalize_line(args, line);
2412-
return 0;
2412+
return normalize_line(args, line);
24132413
}
24142414

24152415
// any restrictions on variant types to split?
@@ -2418,8 +2418,7 @@ static int split_and_normalize(args_t *args)
24182418
int type = args->mrows_collapse==COLLAPSE_SNPS ? VCF_SNP : VCF_INDEL;
24192419
if ( !(bcf_get_variant_types(line) & type) )
24202420
{
2421-
normalize_line(args, line);
2422-
return 0;
2421+
return normalize_line(args, line);
24232422
}
24242423
}
24252424

@@ -2428,7 +2427,11 @@ static int split_and_normalize(args_t *args)
24282427

24292428
int j;
24302429
for (j=0; j<args->ntmp_lines; j++)
2431-
normalize_line(args, args->tmp_lines[j]);
2430+
{
2431+
int ret = normalize_line(args, args->tmp_lines[j]);
2432+
if (ret)
2433+
return ret;
2434+
}
24322435

24332436
return 0;
24342437
}
@@ -2453,7 +2456,10 @@ static void normalize_vcf(args_t *args)
24532456
int done = 0;
24542457
while (1)
24552458
{
2456-
done = split_and_normalize(args);
2459+
do
2460+
{
2461+
done = split_and_normalize(args);
2462+
} while (done < 0); // Skipped line
24572463
if ( done ) break; // no more lines available
24582464
int i = args->rbuf.f;
24592465
int j = rbuf_last(&args->rbuf);

0 commit comments

Comments
 (0)