0

I am having trouble trying to convert a BED file (A text file format used to store genomic regions as coordinates and associated annotations in which the data are presented in the form of columns separated by spaces or tabs). My file is separated by four white spaces and I think that is giving an error with one program that doesn't like this format. So I need to replace these 4 white spaces in one tab space.

I have tried this

tr '    ' \\t < input.bed > output.bed

But I think the command what is doing is to put 4 tabs

input.bed

1    201359013   201359255   NM_000364_exon_0_0_chr1_201359014_r 0   -
1    201359622   201359663   NM_000364_exon_1_0_chr1_201359623_r 0   -
1    201361278   201361369   NM_000364_exon_2_0_chr1_201361279_r 0   -
1    201361912   201362022   NM_000364_exon_3_0_chr1_201361913_r 0   -

Actually, you could see that between the first and second column there is 4 spaces and between the second and third there is 3 white spaces, then 3 white spaces then 1 white space and before the last column 3 white spaces.

When run the previous command I got this

output.bed

1               201359013           201359255           NM_000364_exon_0_0_chr1_201359014_r 0           -
1               201359622           201359663           NM_000364_exon_1_0_chr1_201359623_r 0           -
1               201361278           201361369           NM_000364_exon_2_0_chr1_201361279_r 0           -
1               201361912           201362022           NM_000364_exon_3_0_chr1_201361913_r 0           -
1               201363295           201363406           NM_000364_exon_4_0_chr1_201363296_r 0           -

Instead of

tr '    ' \\t < input.bed > output.bed

I tried this

tr ' ' \\t < input.bed > output.bed

But the result looks the same to me

1               201359013           201359255           NM_000364_exon_0_0_chr1_201359014_r 0           -
1               201359622           201359663           NM_000364_exon_1_0_chr1_201359623_r 0           -
1               201361278           201361369           NM_000364_exon_2_0_chr1_201361279_r 0           -
1               201361912           201362022           NM_000364_exon_3_0_chr1_201361913_r 0           -
1               201363295           201363406           NM_000364_exon_4_0_chr1_201363296_r 0           -


Monkiky
  • 173
  • 5

0 Answers0