This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Bedtools problem : It looks as though you have less than 3 columns at line: 1. Are you sure your files are tab-delimited

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

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

2 answers

You can try removing the extra space using;

sed 's/[[:space:]]*$//' input.bed > output.bed

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

How did you produce that BED (including code)?

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

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

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.

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

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

Log in to answer this question.