bed file in bad format
3
0
Entering edit mode
7.2 years ago
biostarsb ▴ 30

Hi,

i have a bed file, when i use cat -e

chr4     177604691   177713895 $
chr1     223967595   224033674 $
chr1     43766566    43788781 $
chr16    11361714    11363160 $
chr11    120973375   121061515 $
chr4     70706930    70725870 $
chr9     108424738   108425385 $

can any one help me to delete the "" at the end of lines ?

Thank you.

RNA-Seq • 1.4k views
ADD COMMENT
3
Entering edit mode
7.2 years ago

The awk command can be used to strip off trailing whitespace.

Compare:

$ echo -e "chrN\t100\t200\tfoo " | cat -e
chrN    100 200 foo $

with:

$ echo -e "chrN\t100\t200\tfoo " | awk 'BEGIN{OFS="\t"}{print $1,$2,$3,$4}' | cat -e
chrN    100 200 foo$

For a three-column file:

$ awk 'BEGIN{OFS="\t"}{print $1,$2,$3}' bad.bed3 | sort-bed - > good.sorted.bed3
ADD COMMENT
2
Entering edit mode
7.2 years ago
d-cameron ★ 2.9k

If you just want to remove columns, the cut command is the simplest approach:

echo -e "chrN\t100\t200\tfoo " | cut -f 1-3
ADD COMMENT
2
Entering edit mode
7.2 years ago
GenoMax 142k

sed 's/\ $//g' your_file > new_file should also work.

ADD COMMENT

Login before adding your answer.

Traffic: 1416 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