From 878495e7d014c4307b88d212c99d7eed67094221 Mon Sep 17 00:00:00 2001 From: vasudeva8 Date: Thu, 11 Sep 2025 13:34:26 +0100 Subject: [PATCH] uses macro to check missing allele --- csq.c | 10 +++++----- filter.c | 2 +- plugins/check-sparsity.c | 2 +- plugins/guess-ploidy.c | 2 +- plugins/mendelian2.c | 4 ++-- plugins/missing2ref.c | 2 +- plugins/setGT.c | 2 +- plugins/trio-switch-rate.c | 4 ++-- vcfbuf.c | 6 +++--- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/csq.c b/csq.c index ac3da86ba..9572fd32b 100644 --- a/csq.c +++ b/csq.c @@ -3182,9 +3182,9 @@ int test_cds(args_t *args, bcf1_t *rec, vbuf_t *vbuf) for (ismpl=0; ismplsmpl->n; ismpl++) { int32_t *gt = args->gt_arr + args->smpl->idx[ismpl]*ngts; - if ( gt[0]==bcf_gt_missing ) continue; + if ( bcf_gt_is_missing(gt[0]) ) continue; - if ( ngts>1 && gt[1]!=bcf_gt_missing && gt[1]!=bcf_int32_vector_end && bcf_gt_allele(gt[0])!=bcf_gt_allele(gt[1]) ) + if ( ngts>1 && !bcf_gt_is_missing(gt[1]) && gt[1]!=bcf_int32_vector_end && bcf_gt_allele(gt[0])!=bcf_gt_allele(gt[1]) ) { if ( args->phase==PHASE_MERGE ) { @@ -3206,7 +3206,7 @@ int test_cds(args_t *args, bcf1_t *rec, vbuf_t *vbuf) for (ihap=0; ihapgt_arr + args->smpl->idx[i]*ngt; for (j=0; jtype.vcf_ial ) continue; csq_print_text(args, csq, args->smpl->idx[i],j+1); @@ -3326,7 +3326,7 @@ void csq_stage(args_t *args, csq_t *csq, bcf1_t *rec) int32_t *gt = args->gt_arr + args->smpl->idx[i]*ngt; for (j=0; jtype.vcf_ial ) continue; diff --git a/filter.c b/filter.c index d66d7fe28..9d66a7b4b 100644 --- a/filter.c +++ b/filter.c @@ -1397,7 +1397,7 @@ static void filters_set_nmissing(filter_t *flt, bcf1_t *line, token_t *tok) { \ type_t val = convert(&ptr[j * sizeof(type_t)]); \ if ( val==is_vector_end ) break; \ - if ( val==bcf_gt_missing ) { nmissing++; break; } \ + if ( bcf_gt_is_missing(val) ) { nmissing++; break; } \ } \ } \ } diff --git a/plugins/check-sparsity.c b/plugins/check-sparsity.c index 5a2d8adbc..309292cb2 100644 --- a/plugins/check-sparsity.c +++ b/plugins/check-sparsity.c @@ -206,7 +206,7 @@ static void test_region(args_t *args, char *reg) int8_t *ptr = (int8_t*) (fmt_gt->p + args->smpl[i]*fmt_gt->size); int ial = 0; for (ial=0; ialn; ial++) - if ( ptr[ial]==bcf_gt_missing || ptr[ial]==bcf_int8_vector_end ) break; + if ( bcf_gt_is_missing(ptr[ial]) || ptr[ial]==bcf_int8_vector_end ) break; if ( ial==0 ) continue; // missing if ( ++args->nsites[i] < args->min_sites ) continue; if ( i+1nsmpl ) diff --git a/plugins/guess-ploidy.c b/plugins/guess-ploidy.c index d2ecafb00..617acb054 100644 --- a/plugins/guess-ploidy.c +++ b/plugins/guess-ploidy.c @@ -167,7 +167,7 @@ void process_region_guess(args_t *args) int32_t *ptr = args->arr + ismpl*ngt; double *tmp = args->tmpf + ismpl*3; - if ( ptr[0]==bcf_gt_missing ) + if ( bcf_gt_is_missing(ptr[0]) ) { tmp[0] = -1; continue; diff --git a/plugins/mendelian2.c b/plugins/mendelian2.c index 6ff53a5b1..837b97da2 100644 --- a/plugins/mendelian2.c +++ b/plugins/mendelian2.c @@ -566,12 +566,12 @@ static int parse_gt(int32_t *gt, int ngt, uint64_t *a, uint64_t *b) { *a = *b = 0; - if ( gt[0]==bcf_gt_missing || gt[0]==bcf_int32_vector_end ) return 0; + if ( bcf_gt_is_missing(gt[0]) || gt[0]==bcf_int32_vector_end ) return 0; *a |= 1<custom.gt[i]==MINOR_ALLELE ) new_allele = args->custom.m_allele; else if ( args->custom.gt[i]==MAJOR_ALLELE ) new_allele = args->custom.M_allele; - else if ( args->custom.gt[i]==X_VAF_ALLELE ) new_allele = args->custom.x_vaf_allele==bcf_gt_missing ? nals : bcf_gt_allele(args->custom.x_vaf_allele); + else if ( args->custom.gt[i]==X_VAF_ALLELE ) new_allele = bcf_gt_is_missing(args->custom.x_vaf_allele) ? nals : bcf_gt_allele(args->custom.x_vaf_allele); else if ( args->custom.gt[i]==MISSING_ALLELE ) new_allele = nals; // this is to trigger the `new_allele = bcf_gt_missing` branch below else new_allele = args->custom.gt[i]; if ( new_allele >= nals ) // cannot set, the requested index is bigger than there are alleles in ALT diff --git a/plugins/trio-switch-rate.c b/plugins/trio-switch-rate.c index 564bca679..7e472df87 100644 --- a/plugins/trio-switch-rate.c +++ b/plugins/trio-switch-rate.c @@ -182,8 +182,8 @@ int parse_genotype(gt_t *gt, int32_t *ptr); inline int parse_genotype(gt_t *gt, int32_t *ptr) { - if ( ptr[0]==bcf_gt_missing ) return 0; - if ( ptr[1]==bcf_gt_missing ) return 0; + if ( bcf_gt_is_missing(ptr[0]) ) return 0; + if ( bcf_gt_is_missing(ptr[1]) ) return 0; if ( ptr[1]==bcf_int32_vector_end ) return 0; gt->phased = bcf_gt_is_phased(ptr[1]) ? 1 : 0; gt->a = bcf_gt_allele(ptr[0]); if ( gt->a > 1 ) return 0; // consider only the first two alleles at biallelic sites diff --git a/vcfbuf.c b/vcfbuf.c index 4dee727e8..54d394ef9 100644 --- a/vcfbuf.c +++ b/vcfbuf.c @@ -842,7 +842,7 @@ static double _estimate_af(int8_t *ptr, int size, int nvals, int nsamples) { for (j=0; jn; j++) { if ( aptr[j]==bcf_int8_vector_end ) break; - if ( aptr[j]==bcf_gt_missing ) + if ( bcf_gt_is_missing(aptr[j]) ) { if ( !buf->ld.rand_missing ) break; if ( hts_drand48() >= aaf ) adsg += 1; @@ -922,7 +922,7 @@ static int _calc_r2_ld(vcfbuf_t *buf, bcf1_t *arec, bcf1_t *brec, vcfbuf_ld_t *l for (j=0; jn; j++) { if ( bptr[j]==bcf_int8_vector_end ) break; - if ( bptr[j]==bcf_gt_missing ) + if ( bcf_gt_is_missing(bptr[j]) ) { if ( !buf->ld.rand_missing ) break; if ( hts_drand48() >= baf ) bdsg += 1;