Answers.Body: <p>You could grab exons via Gencode v27 (hg38) GFF annotations and convert them to BED via <a href="https://github.com/bedops/bedops" rel="nofollow noreferrer">BEDOPS</a> <code>convert2bed</code>/<code>gff2bed</code>:</p>
  
  <pre><code>$ wget -qO- ftp://ftp.sanger.ac.uk/pub/gencode/Gencode_human/release_27/gencode.v27.annotation.gff3.gz \
      | gunzip --stdout - \
      | awk '$3 == "exon"' \
      | convert2bed -i gff - \
      &gt; exons.bed
  </code></pre>
  
  <p>Then use <code>grep</code> to filter exons against your list of gene names:</p>
  
  <pre><code>$ grep -w -f hgnc.txt exons.bed &gt; exons.filtered.bed
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-18T21:31:43.607Z
Answers.LastActivityDate: 2018-02-18T21:31:43.607Z
Answers.UserDisplayName: Alex Reynolds
Answers.Body: <p>If you need a 3-column BED, you can just use standard Unix tools:</p>
  
  <pre class="lang-sh prettyprint-override"><code>curl ftp://ftp.sanger.ac.uk/pub/gencode/Gencode_human/release_27/gencode.v27.annotation.gtf.gz \
    | gzip -dc \
    | grep -wFf list.txt \
    | awk -vFS="\t" '$3=="exon"{print $1"\t"($4-1)"\t"$5"\t"$9}' &gt; out-3.bed
  </code></pre>
  
  <p>If you need a 12-column BED:</p>
  
  <pre class="lang-sh prettyprint-override"><code># install k8 and paftools.js
  curl -L http://bit.ly/k8-024 | tar -jxf -
  cp k8-0.2.4/k8-`uname -s` k8
  git clone https://github.com/lh3/minimap2
  # actual command line:
  curl ftp://ftp.sanger.ac.uk/pub/gencode/Gencode_human/release_27/gencode.v27.annotation.gtf.gz \
    | ./k8 minimap2/misc/paftools.js gff2bed - \
    | grep -wFf list.txt &gt; out-12.bed
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-19T14:28:25.703Z
Answers.LastActivityDate: 2018-02-19T14:28:25.703Z
Answers.UserDisplayName: user172818
Body: <p>I have a set of gene names in HGNC standard and I want to get all their exons (in BED format) from the UCSC browser but it seems like the browser doesn't index genes by their HGNC name. How can I do that?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-02-18T21:22:10.650Z
Comments.Text: Does it have to be UCSC? This is trivial with biomart.
Comments.UserDisplayName: Devon Ryan
Tags: <ucsc><genome-browser><exon>
Title: Get gene exons from UCSC browser by HGNC name
ThreadText: # Get gene exons from UCSC browser by HGNC name
  
  (Asked by: username_0 on 2018-02-18)
  
  I have a set of gene names in HGNC standard and I want to get all their exons (in BED format) from the UCSC browser but it seems like the browser doesn't index genes by their HGNC name. How can I do that?
  
  **Tags:** ucsc, genome-browser, exon
  
  > **Comments:**
  > **username_1**: Does it have to be UCSC? This is trivial with biomart.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2018-02-18. Score: 2 | Accepted answer
  
  You could grab exons via Gencode v27 (hg38) GFF annotations and convert them to BED via [BEDOPS](https://github.com/bedops/bedops) `convert2bed`/`gff2bed`:
  
  ```
  $ wget -qO- ftp://ftp.sanger.ac.uk/pub/gencode/Gencode_human/release_27/gencode.v27.annotation.gff3.gz \
      | gunzip --stdout - \
      | awk '$3 == "exon"' \
      | convert2bed -i gff - \
      > exons.bed
  
  ```
  
  Then use `grep` to filter exons against your list of gene names:
  
  ```
  $ grep -w -f hgnc.txt exons.bed > exons.filtered.bed
  
  ```
  
  
  ---
  
  ### Answer by username_3 on 2018-02-19. Score: 2
  
  If you need a 3-column BED, you can just use standard Unix tools:
  
  ```sh
  curl ftp://ftp.sanger.ac.uk/pub/gencode/Gencode_human/release_27/gencode.v27.annotation.gtf.gz \
    | gzip -dc \
    | grep -wFf list.txt \
    | awk -vFS="\t" '$3=="exon"{print $1"\t"($4-1)"\t"$5"\t"$9}' > out-3.bed
  
  ```
  
  If you need a 12-column BED:
  
  ```sh
  # install k8 and paftools.js
  curl -L http://bit.ly/k8-024 | tar -jxf -
  cp k8-0.2.4/k8-`uname -s` k8
  git clone https://github.com/lh3/minimap2
  # actual command line:
  curl ftp://ftp.sanger.ac.uk/pub/gencode/Gencode_human/release_27/gencode.v27.annotation.gtf.gz \
    | ./k8 minimap2/misc/paftools.js gff2bed - \
    | grep -wFf list.txt > out-12.bed
  
  ```
  
  
  ---
  
  