Bedtools problem : It looks as though you have less than 3 columns at line: 1. Are you sure your files are tab-delimited
2
0
Entering edit mode
5.2 years ago
Tomm • 0

I am trying to run bedtools on my tab-delimited file but it still show me an error : It looks as though you have less than 3 columns at line: 1. Are you sure your files are tab-delimited?.

The command I run:

bedtools getfasta -fi fasta.fa -bed list.bed -fo results

my BED file looks like -->

scaffold_1000       9060  9912
scaffold_101084   600   2116
scaffold_101084   750   2330
scaffold_101084   800   2200
scaffold_101084   800   2300

What should I do next?

bedtools fasta • 8.7k views
ADD COMMENT
0
Entering edit mode

Hi Tomm,

Check your bed file with sed -n 'l' there you'll see all control characters.

Was the original file made in Windows? If so try dos2unix.

Cheers,

Michael

ADD REPLY
0
Entering edit mode
5.2 years ago
rthapa ▴ 90

You can try removing the extra space using;

sed 's/[[:space:]]*$//' input.bed > output.bed
ADD COMMENT
0
Entering edit mode

Thank you for commenting , it didn't work .. what else you think i should do ?

ADD REPLY
2
Entering edit mode

Could you try converting your text file to bed file using,

awk -F"[:-]" 'BEGIN{ OFS="\t"; }{ print $1, $2, $3;}' bed.txt > bed.bed

and then removing the space,

sed 's/[[:space:]]*$//' input.bed > output.bed
ADD REPLY
0
Entering edit mode

How did you produce that BED (including code)?

Also try tr -d " " < your.bed > new.bed

ADD REPLY
0
Entering edit mode

this command just smashing the three columns together , didn't work also. I just did it in vim , and then just used awk command .

ADD REPLY
0
Entering edit mode

There you have your problem. If your file was tab-delimited the result would be

tr -d " " < foo.bed 
chr1    1   10

as the command only removes whitespaces but not tabs. This means your file is whitespace- rather than tab-delimited.

What you can also try is:

awk 'OFS=" " {print $1"\t", $2"\t", $3}' your.bed | tr -d " "

This will first make sure that there are any tabs between the columns and then remove all whitespaces. If this does not work, tell how the BED was generated.

ADD REPLY
0
Entering edit mode
18 months ago
Michael • 0

I ran into this issue. It was caused by the FASTA data being included in the GFF3 file I was working with. I truncated the file starting at the line that begun "##FASTA".

See: https://github.com/arq5x/bedtools2/issues/235

ADD COMMENT

Login before adding your answer.

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