Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yuifu/cb7e136f47f7e876477764a4b9328e72 to your computer and use it in GitHub Desktop.
Save yuifu/cb7e136f47f7e876477764a4b9328e72 to your computer and use it in GitHub Desktop.
GTFファイルからTSVを作成する

テスト用GTFファイルの作成

wget -O - ftp://ftp.ebi.ac.uk/pub/databases/gencode/Gencode_human/release_34/gencode.v34.annotation.gtf.gz | gunzip | head -n 1000 > test.gtf

GTFファイルから gene_id, gene_name のTSVを作る

awk 'BEGIN{OFS="\t"; print "gene_id\tgene_name"} $3=="gene"{gsub(/[";]/, ""); print $10,$14}' test.gtf > test.gtf.gene_name.tsv

GTFファイルから gene body のBEDを作る

awk 'BEGIN{OFS="\t"} $3=="gene"{gsub(/[";]/, ""); s=$4-1; print $1,s,$5,$10,0,$7}' test.gtf > test.gtf.bed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment