BedtoBam error: Why is this?
1
0
Entering edit mode
6.0 years ago
jaqx008 ▴ 110

Hello every one, I repeatedly encountered this error whie trying to get bam from bed using the command below. I have tried to see solutions from previous question but it hasnt worked. also consulted the command usage and no way.

bedtools bedtobam -i x.bed -g y.fasta > x.bam

the error is also shown below, what am I doing wrong or what is wrong with my fasta file?

Less than the req'd two fields were encountered in the genome file (y.fasta) at line 1. Exiting.

RNA-Seq bedtobam getfasta Bedtools • 4.1k views
ADD COMMENT
1
Entering edit mode

What makes you think the argument to -g is a fasta file? Documentation suggests differently. Googling for "bedtools genome file" should put you on the right track.

ADD REPLY
0
Entering edit mode

Are you sure -g expects fasta? If I remember correct it only requires chromosome sizes file in 2 columns.

ADD REPLY
0
Entering edit mode

The usage says -g <genome> . then it say fai should work with bedtools in the documentation

ADD REPLY
0
Entering edit mode

fai is the index file of your reference sequence file. You can create it with samtools faidx <genome>. And this file works, because the first two columns in this file contain exactly the information bedtools expect - the sequence name and it's length.

fin swimmer

ADD REPLY
2
Entering edit mode
6.0 years ago

a genome file is not a fasta file. https://bedtools.readthedocs.io/en/latest/content/general-usage.html#genome-file-format

which simply lists the names of the chromosomes (or scaffolds, etc.) and their size (in basepairs).

ADD COMMENT
0
Entering edit mode

I was able to get the bam by first getting the genome file (from the command below) that has only chr name and length then using this in the bedtobam command.

cat file.fa | awk '$0 ~ ">" {print c; c=0;printf substr($0,2,100) "\t"; } $0 !~ ">" {c+=length($0);} END { print c; }' > xx.genome

Thanks

ADD REPLY

Login before adding your answer.

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