Skip to content

Instantly share code, notes, and snippets.

@juanesarango
Last active December 24, 2018 19:38
Show Gist options
  • Save juanesarango/94b1fc1c2710627e6aca26d42ea9a5d3 to your computer and use it in GitHub Desktop.
Save juanesarango/94b1fc1c2710627e6aca26d42ea9a5d3 to your computer and use it in GitHub Desktop.
Change notation of chromosomes chr1 for 1 in a bedfile

Having a bedfile like:

initial.bed

chr8	41510743	41513272	uc003xoi.3_exon_0_0_chr8_41510744_r	0	-
chr8	41518947	41519082	uc003xoi.3_exon_1_0_chr8_41518948_r	0	-
chr8	41519393	41519459	uc003xoi.3_exon_2_0_chr8_41519394_r	0	-
chr8	41521176	41521260	uc003xoi.3_exon_3_0_chr8_41521177_r	0	-

I want to get it like:

expected.bed

8	41510743	41513272	uc003xoi.3_exon_0_0_chr8_41510744_r	0	-
8	41518947	41519082	uc003xoi.3_exon_1_0_chr8_41518948_r	0	-
8	41519393	41519459	uc003xoi.3_exon_2_0_chr8_41519394_r	0	-
8	41521176	41521260	uc003xoi.3_exon_3_0_chr8_41521177_r	0	-

Run: sed 's/^chr//g' initial.bed > expected.bed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment