Question: append to column in bedfile
0
gravatar for a.rex
3.2 years ago by
a.rex210
a.rex210 wrote:

I have a bed file that looks like this:

scaffold1        206     262   loc.00001       +       .
scaffold1        749     1391  loc.00001       +       .
scaffold1        1549    1595  loc.00001       +       .
scaffold1        2090    2657  loc.00001       +       .
scaffold1        3013    3065  loc.00001       +       .
scaffold1        3315    3371  loc.00001       +       .

I wish to append the transcript id's in linux with a peak id so that it looks like this:

scaffold1        206     262   loc.00001_peak1        +       .
scaffold1        749     1391  loc.00001_peak2        +       .
scaffold1        1549    1595  loc.00001_peak3        +       .
scaffold1        2090    2657  loc.00001_peak4        +       .
scaffold1        3013    3065  loc.00001_peak5        +       .
scaffold1        3315    3371  loc.00001_peak6        +       .

I have used the following command to add peak_ids to the file. I just don't know how to conjugate it to the column itself.

awk '{printf "peak_%d\t%s\n", NR, $0}' int.bed > int.new.bed

file formating bedfile • 836 views
ADD COMMENTlink modified 3.2 years ago by Devon Ryan94k • written 3.2 years ago by a.rex210
5
gravatar for Devon Ryan
3.2 years ago by
Devon Ryan94k
Freiburg, Germany
Devon Ryan94k wrote:

awk 'BEGIN{OFS="\t"}{$4=sprintf("%s_peak%i",$4, NR); print}' input.bed > output.bed

ADD COMMENTlink written 3.2 years ago by Devon Ryan94k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1089 users visited in the last hour