This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to write a proper bed file to extract sequence?

Hi, I have manually created a bed file to extract the sequences from a fasta file. But it is showing the following error message. How can I solve it?

-bash-4.2$ cat pAcr_extract.bed
PSE305_1 20001 20479
PSE305_1 20306 20479
PSE305_1 20001 20303
AZPAE14907_contig_18_1 20001 20479
AZPAE14907_contig_18_1 20001 20303
WH-SGI-V-07178_contig3_1 20001 20303
WH-SGI-V-07178_contig3_1 20306 20479
bash-4.2$ bedtools getfasta -fi pAcr_extract.fasta -bed pAcr_extract.bed  -fo pAcr_extract.fasta.out
 It looks as though you have less than 3 columns at line: 1.  Are you sure your files are tab-delimited?
bed file covertor extract_seq

1 answer

bedtools is complaining about your file not being tab-delimited, try the following on your file if you have awk in your terminal to avoid making it again manually with tabs since I'm assuming its a big file:

cat pAcr_extract.bed | awk 'BEGIN{OFS="\t";} {print $1,$2,$3;}' > pAcr_extract_tab.bed

now try using bedools again with the newly created file in the -bed option.

Here a more general way for converting one ore more whitespaces into tabs using sed.

$ sed 's/  \+/\t/g' input > output

fin swimmer

Log in to answer this question.