<p>Via <a href="https://github.com/bedops/bedops" rel="nofollow noreferrer">BEDOPS</a>:</p>

<pre><code>$ gff2bed &lt; annotations.gff &gt; annotations.bed
$ vcf2bed &lt; snps.vcf &gt; snps.bed
$ bedmap --echo --echo-map-id-uniq snps.bed annotations.bed &gt; answer.bed
</code></pre>

<p>This can be reduced to a one-liner if you're using <code>bash</code>:</p>

<pre><code>$ bedmap --echo --echo-map-id-uniq &lt;(vcf2bed &lt; snps.vcf) &lt;(gff2bed &lt; annotations.gff) &gt; answer.bed
</code></pre>

CC BY-SA 3.0
2017-06-21T11:10:55.837Z
2017-06-21T11:10:55.837Z
Alex Reynolds
<p>I have a VCF file with SNPs from a bacterial genome and want to find if the SNPs are located inside genes, is there some CLI-tool where you can pass a VCF file and a gff or gbk file and it returns the name of the genes?</p>

CC BY-SA 3.0
2017-06-21T11:16:36.923Z
Please show us an example of your inputs. What format are your SNPs in? Are they in a proper VCF file? Are they in some other format one per line? Many per line? Do you want a command line solution? an online graphical tool? Please [edit] your question and clarify.
terdon
<snp>
Find gene at position from gff or gbk file
# Find gene at position from gff or gbk file

(Asked by: username_0 on 2017-06-21)

I have a VCF file with SNPs from a bacterial genome and want to find if the SNPs are located inside genes, is there some CLI-tool where you can pass a VCF file and a gff or gbk file and it returns the name of the genes?

**Tags:** snp
> **Comments:**
> **username_1**: Please show us an example of your inputs. What format are your SNPs in? Are they in a proper VCF file? Are they in some other format one per line? Many per line? Do you want a command line solution? an online graphical tool? Please [edit] your question and clarify.  

---

## 1 answers

### Answer by username_2 on 2017-06-21. Score: 3 | Accepted answer

Via BEDOPS:
$ gff2bed < annotations.gff > annotations.bed
$ vcf2bed < snps.vcf > snps.bed
$ bedmap --echo --echo-map-id-uniq snps.bed annotations.bed > answer.bed

This can be reduced to a one-liner if you're using bash:
$ bedmap --echo --echo-map-id-uniq <(vcf2bed < snps.vcf) <(gff2bed < annotations.gff) > answer.bed


---

