So I know Consensus CDS has the genomic locations of exons, however, only of the exons in the CDS. Everything before or after is not included.

NIH variation viewer has those (kinda-) radio buttons next to the gene name, and when you hover over them, you do get to see the genomic locations of the exons. But this method isn't very scalable.

Does anyone know an easy, scalable way of retrieving the genomic locations of exon for a certain gene?

  • 2
    $\begingroup$ Not all exons are necessarily included in the CDS. On top of that, the first exon often is not translated completely, and only a part of the exon is part of the CDS. $\endgroup$
    – mrPuzzle
    Commented Jan 18, 2022 at 9:20
  • $\begingroup$ Ah, sure, you are right. Somehow my brain sometimes switches the words around. Never mind me. $\endgroup$ Commented Jan 18, 2022 at 10:18

2 Answers 2


Perhaps you could use this (assuming hg38) as a lookup table:

$ wget -qO- https://ftp.ebi.ac.uk/pub/databases/gencode/Gencode_human/release_39/gencode.v39.annotation.gff3.gz \
    | gunzip -c \
    | grep -wF exon \
    | convert2bed --input=gff --attribute-key="gene_name" - \
    > gencode.v39.exons.bed

If you prefer to search for an Ensembl accession ID, you can remove the --attribute-key="gene_name" option. Otherwise, this puts the HGNC symbol into the ID column.

The preceding step takes about 30 seconds. Once you have made this lookup file, you can search it for exons of any gene of interest. Using MYC as an example:

$ awk -v FS="\t" -v OFS="\t" '($5=="MYC")' gencode.v39.exons.bed > answer.bed

You can then further filter that by transcript or other attributes, etc.


I'd use biomart on ensembl.org


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.