Skip to content

Commit b10a2c8

Browse files
daviesrobjkbonfield
authored andcommitted
Adjust snp-ins-del code for the revised bcf_has_variant_type API
1 parent 6c66ae3 commit b10a2c8

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

plugins/smpl-stats.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,9 @@ static void process_record(args_t *args, bcf1_t *rec, flt_stats_t *flt)
394394
error("The GT index is out of range at %s:%"PRId64" in %s\n", bcf_seqname(args->hdr,rec),(int64_t) rec->pos+1,args->hdr->samples[j]);
395395

396396
if ( args->ac[als[j]]==1 ) { stats->nsingleton++; site_singleton = 1; }
397-
398-
if ( bcf_has_variant_type(rec, als[j], VCF_SNP|VCF_MNP, subset) )
397+
int var_type = bcf_has_variant_type(rec, als[j], VCF_SNP|VCF_MNP|VCF_INDEL);
398+
if ( var_type < 0 ) error("bcf_has_variant_type() failed");
399+
if ( var_type & (VCF_SNP|VCF_MNP) )
399400
{
400401
int k = 0;
401402
while ( rec->d.allele[0][k] && rec->d.allele[als[j]][k] )
@@ -410,7 +411,7 @@ static void process_record(args_t *args, bcf1_t *rec, flt_stats_t *flt)
410411
k++;
411412
}
412413
}
413-
else if ( bcf_has_variant_type(rec, als[j], VCF_INDEL, exact) ) has_indel = 1;
414+
else if ( var_type == VCF_INDEL ) has_indel = 1;
414415
}
415416
if ( has_ts ) { stats->nts++; site_has_ts = 1; }
416417
if ( has_tv ) { stats->ntv++; site_has_tv = 1; }

vcfmerge.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2753,7 +2753,8 @@ int can_merge(args_t *args)
27532753
id = line->d.id;
27542754
else
27552755
{
2756-
int var_type = bcf_get_variant_types(line);
2756+
int var_type = bcf_has_variant_types(line, VCF_ANY, bcf_match_overlap);
2757+
if (var_type < 0) error("bcf_has_variant_types() failed.");
27572758
if ( args->collapse==COLLAPSE_SNP_INS_DEL )
27582759
{
27592760
// need to distinguish between ins and del so strip the VCF_INDEL flag
@@ -2794,7 +2795,8 @@ int can_merge(args_t *args)
27942795

27952796
bcf1_t *line = buf->lines[j]; // ptr to reader's buffer or gvcf buffer
27962797

2797-
int line_type = bcf_get_variant_types(line);
2798+
int line_type = bcf_has_variant_types(line, VCF_ANY, bcf_match_overlap);
2799+
if (line_type < 0) error("bcf_has_variant_types() failed.");
27982800
line_type = line_type ? line_type<<2 : 2;
27992801

28002802
// select relevant lines
@@ -2911,7 +2913,8 @@ void stage_line(args_t *args)
29112913
{
29122914
if ( buf->rec[j].skip ) continue; // done or not compatible
29132915
if ( args->collapse&COLLAPSE_ANY ) break; // anything can be merged
2914-
int line_type = bcf_get_variant_types(buf->lines[j]);
2916+
int line_type = bcf_has_variant_types(buf->lines[j], VCF_ANY, bcf_match_overlap);
2917+
if (line_type < 0) error("bcf_has_variant_types() failed.");
29152918
if ( maux->var_types&snp_mask && line_type&VCF_SNP && (args->collapse&COLLAPSE_SNPS) ) break;
29162919
if ( maux->var_types&indel_mask && line_type&VCF_INDEL && (args->collapse&COLLAPSE_INDELS) ) break;
29172920
if ( maux->var_types&ins_mask && line_type&VCF_INS && (args->collapse&COLLAPSE_SNP_INS_DEL) ) break;

vcfstats.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -706,8 +706,10 @@ static void do_indel_stats(args_t *args, stats_t *stats, bcf_sr_t *reader)
706706
for (i=1; i<line->n_allele; i++)
707707
{
708708
if ( args->first_allele_only && i>1 ) break;
709-
if ( !bcf_has_variant_type(line,i,VCF_INDEL,exact) ) continue;
710-
int len = line->d.var[i].n;
709+
int is_indel = bcf_has_variant_type(line,i,VCF_INDEL);
710+
if (is_indel < 0) error("bcf_has_variant_type() failed.");
711+
if ( !is_indel ) continue;
712+
int len = bcf_variant_length(line, i);
711713

712714
#if IRC_STATS
713715
// Indel repeat consistency

0 commit comments

Comments
 (0)