Created
November 3, 2015 18:28
-
-
Save sahilseth/f91553f6f617f91363e7 to your computer and use it in GitHub Desktop.
Adding chr to a GTF file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
awk '{ if($1 !~ /^#/){print "chr"$0} else{print $0} }' Homo_sapiens.GRCh37.75.gtf |
This will add chr in front of every line, irrespective of what's on that line, though....
Thank you!
Thanks. For avoiding non-chromosomal regions, like repeats or mitochondrial, I just added an "or" (pipe) [A-Z ] to the regex:
/^#|[A-Z]/
These regions usually start with a capital letter instead of a number.
X and Y would be excluded with that. Instead, you can use this:
awk '{ if($1 ~ /^[0-9]+$/ || $1 ~ /^(X|Y)$/){print "chr"$0} else{print $0} }' yourfile.gtf
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks.It worked.