Skip to content

Commit

Permalink
Exclude features outside transcript boundaries
Browse files Browse the repository at this point in the history
Resolves #2323
  • Loading branch information
pd3 committed Dec 11, 2024
1 parent 3351124 commit d6cf97b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Changes affecting specific commands:

- The command `convert --gvcf2vcf` was not filling the REF allele when BCF was output (#243)

* bcftools csq

- Check the input GFF for features outside transcript boundaries (#2323)

* bcftools query

- The functions used in -i/-e filtering expressions (such as SUM, MEDIAN, etc) can be
Expand Down
13 changes: 11 additions & 2 deletions gff.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* The MIT License
Copyright (c) 2023 Genome Research Ltd.
Copyright (c) 2023-2024 Genome Research Ltd.
Author: Petr Danecek <[email protected]>
Expand Down Expand Up @@ -122,7 +122,7 @@ struct gff_t_

struct {
int unknown_chr,unknown_tscript_biotype,unknown_strand,unknown_phase,duplicate_id;
int unknown_cds_phase,incomplete_cds,wrong_phase,overlapping_cds;
int unknown_cds_phase,incomplete_cds,wrong_phase,overlapping_cds,ftr_out_of_bounds;
} warned;
};

Expand Down Expand Up @@ -1010,7 +1010,16 @@ int gff_parse(gff_t *gff)
khint_t k = kh_get(int2tscript, aux->id2tr, (int)ftr->trid);
if ( k==kh_end(aux->id2tr) ) continue; // no corresponding transcript registered, must be an unsupported biotype

// check whether the feature respects transcript's beg,end coordinates
gf_tscript_t *tr = kh_val(aux->id2tr,k);
if ( ftr->beg < tr->beg || ftr->end > tr->end )
{
if ( !gff->warned.ftr_out_of_bounds || gff->verbosity > 1 )
fprintf(stderr,"Warning: The GFF contains features outside the transcript boundaries .. %s\n",gff_id2string(gff,transcript,tr->id));
gff->warned.ftr_out_of_bounds++;
continue;
}

tr->used = 1;
tr->gene->used = 1;

Expand Down

0 comments on commit d6cf97b

Please sign in to comment.