Skip to content

Instantly share code, notes, and snippets.

@cbp44
Last active September 14, 2023 07:49
Show Gist options
  • Save cbp44/98251bc46648f9281a082a0161dd6e9b to your computer and use it in GitHub Desktop.
Save cbp44/98251bc46648f9281a082a0161dd6e9b to your computer and use it in GitHub Desktop.
Convert GTF to TSS BED file
#!/bin/sh
# Creates a sorted BED file with all transcript TSS locations with the Ensembl transcript id for the name column
# This script does this for the Mouse vM19 annotaions, but should work just fine with Human GTF as well
wget ftp://ftp.ebi.ac.uk/pub/databases/gencode/Gencode_mouse/release_M19/gencode.vM19.annotation.gtf.gz
zcat gencode.vM19.annotation.gtf.gz | awk 'OFS="\t" {if ($3=="transcript") {if ($7 == "+") {print $1,$4-1,$4,$12,".",$7} else {print $1,$5-1,$5,$12,".",$7}}}' | tr -d '";' | sort -k1,1V -k2,2n > gencode.vM19.annotation.tss.bed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment