Found what I needed in an R pacakge and in another Biostars question/answer.
How To Write Data In A Granges Object To A Bed File.
https://www.bioconductor.org/packages/release/bioc/html/GenomicFeatures.html
Resulting script.
Somehow the start positions in the granges object already where 0 based, so did not subtract 1bp extra for the start positions.
library(GenomicFeatures)
txdb <- makeTxDbFromGFF('input.gtf')
all.introns <- intronicParts(txdb)
gr <- all.introns
df_start_splice_slop_10 <- data.frame(seqnames=seqnames(gr),
starts=start(gr)-10,
ends=start(gr)+10,
names=c(rep(".", length(gr))),
scores=c(rep(".", length(gr))),
strands=strand(gr))
df_stop_splice_slop_10 <- data.frame(seqnames=seqnames(gr),
starts=end(gr)-10,
ends=end(gr)+10,
names=c(rep(".", length(gr))),
scores=c(rep(".", length(gr))),
strands=strand(gr))
df_splice_slop_10 <- rbind(df_start_splice_slop_10, df_stop_splice_slop_10)
df_splice_slop_10$starts <- format(df_splice_slop_10$starts, scientific = FALSE, trim = TRUE)
df_splice_slop_10$ends <- format(df_splice_slop_10$ends, scientific = FALSE, trim = TRUE)
write.table(df_splice_slop_10, file="input_gene_model_splice_slop_10.bed", quote=F, sep="\t", row.names=F, col.names=F)
Use bedtools sort and merge to merge the overlapping slop regions in the bed file caused by very small introns.
Then use bcftools filter to label variants within 10bp of splice junctions using this bed file.