With relation to the other bioconductor question I would point you towards these packages;
- VariantAnnotation: Provides functionality for reading and manipulating vcf files.
- GenomicRanges: Provides functionality for creating genome intervals. Also provides overlap functions for calculating overlaps between various ranges.
- rtracklayer: Allows you to easily change formats between different biological file formats.
- AnnotationHub: Makes many common and uncommon annotation files available in the R terminal in various formats such as TxDb, OrgDb etc. etc.
Here's a tutorial very similar to what you are asking for. It utilises some of the packages mentioned above. Principally, AnnotationHub, GenomicRanges and VariantAnnotation.
If you want the manual of these packages, they are available on the linked pages.