[Resolved] Adding a unique ID column to a bed file
1
0
Entering edit mode
9.0 years ago
giroudpaul ▴ 70

Hello

I have this kind of bed file :

chr1    39630894    39631095    +
chr1    158409432    158409633    +
chr10    75600726    75600927    +
chr13    10359410    10359611    +
chr13    10448814    10449015    +
chr13    64450832    64451033    +
chr14    110276447    110276648    +

I need to add a first column with a unique identifier in order to annotate this file using Homer.

Adding the column is not the problem, but I don't know how to create a column with a unique id such as peaks_X with X being the line number of my bed file for example.

I thought of using a for loop, but it's not that easy in unix. I can retrieve the number of line with wc -l, but I don't know how to set the condition: add from 1 to wc -l file.bed

Anyone see an easy way to do this with unix, perl, or anything ?

Thank you!

bed data-managment • 3.0k views
ADD COMMENT
2
Entering edit mode
9.0 years ago
giroudpaul ▴ 70

Found solution alone:

awk '{printf "peak_%d\t%s\n", NR, $0}' < test.bed
ADD COMMENT

Login before adding your answer.

Traffic: 1643 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6