text: user2594: I have a bed file that contains a list of regions and I would like to extract only the exon regions from a GTF/GFF file that are contained in the given regions.
  Is there a simple command or tool that I can use for that?
  
  user73: Bedtools intersect will do this:
  
  By far, the most common question asked of two sets of genomic features is whether or not any of the features in the two sets “overlap” with one another. This is known as feature intersection. bedtools intersect allows one to screen for overlaps between two sets of genomic features. Moreover, it allows one to have fine control as to how the intersections are reported. bedtools intersect works with both BED/GFF/VCF and BAM files as input.
  
  https://bedtools.readthedocs.io/en/latest/content/tools/intersect.html
  
  user776: You could use BEDOPS:
  $ gtf2bed < annotations.gtf | grep -wF exon > exons.bed
  $ sort-bed myRegions.unsorted.bed > myRegions.bed
  $ bedops --element-of 100% exons.bed myRegions.bed > answer.bed
  
  Or as a one-liner, which is even faster:
  $ bedops --element-of 100% <(gtf2bed < annotations.gtf | grep -wF exon) <(sort-bed myRegions.unsorted.bed) > answer.bed
  
  The --element-of 100% argument requires that the exon fall entirely within a region in the myRegions set. This is the most stringent requirement. The most relaxed requirement would be one base of overlap: --element-of 1. You can adjust to either extreme, or to values in between, depending on your criteria.
  
original_text: 2594: <p>I have a bed file that contains a list of regions and I would like to extract only the exon regions from a GTF/GFF file that are contained in the given regions.</p>
  <p>Is there a simple command or tool that I can use for that?</p>
   73: <p>Bedtools <code>intersect</code> will do this:</p>
  <blockquote>
  <p>By far, the most common question asked of two sets of genomic features is whether or not any of the features in the two sets “overlap” with one another. This is known as feature intersection. bedtools intersect allows one to screen for overlaps between two sets of genomic features. Moreover, it allows one to have fine control as to how the intersections are reported. bedtools intersect works with both BED/GFF/VCF and BAM files as input.</p>
  </blockquote>
  <p><a href="https://bedtools.readthedocs.io/en/latest/content/tools/intersect.html" rel="nofollow noreferrer">https://bedtools.readthedocs.io/en/latest/content/tools/intersect.html</a></p>
   776: <p>You could use <a href="https://github.com/bedops/bedops" rel="noreferrer">BEDOPS</a>:</p>
  <pre><code>$ gtf2bed &lt; annotations.gtf | grep -wF exon &gt; exons.bed
  $ sort-bed myRegions.unsorted.bed &gt; myRegions.bed
  $ bedops --element-of 100% exons.bed myRegions.bed &gt; answer.bed
  </code></pre>
  <p>Or as a one-liner, which is even faster:</p>
  <pre><code>$ bedops --element-of 100% &lt;(gtf2bed &lt; annotations.gtf | grep -wF exon) &lt;(sort-bed myRegions.unsorted.bed) &gt; answer.bed
  </code></pre>
  <p>The <code>--element-of 100%</code> argument requires that the exon fall entirely within a region in the <code>myRegions</code> set. This is the most stringent requirement. The most relaxed requirement would be one base of overlap: <code>--element-of 1</code>. You can adjust to either extreme, or to values in between, depending on your criteria.</p>
  