I am trying to extract fasta sequences from a genome using a bed file (homemade). The bed file looks like this (tab separated):
LQNS02278165.1 13104710 13109495 +
LQNS02278165.1 9139127 9142308 +
LQNS02278165.1 13665793 13666495 +
LQNS02278165.1 9143024 9144041 +
LQNS02278165.1 9221339 9222957 -
LQNS02278165.1 9220085 9220713 -
LQNS02278165.1 12608731 12609200 +
LQNS02278165.1 9144041 9144734 +
LQNS02278165.1 13666286 13666752 +
LQNS02278165.1 13655380 13655764 +
I am running bedtools getfasta with option force strandedness (-s) but this is not working. The output I get is not taking the strand into account as it should. Any suggestions ?
bedtools getfasta -s -fo strand_genome.fa -fi genome.fa -bed f.blast_genome.bed -fullHeader
>LQNS02278165.1:13104710-13109495()
AAAAAAA....
>LQNS02278165.1:9139127-9142308()
AAAAAAA....
>LQNS02278165.1:13665793-13666495()
AAAAAAA....
>LQNS02278165.1:9143024-9144041()
AAAAAAA....
>LQNS02278165.1:9221339-9222957()
AAAAAAA....
THANKS!
According to bed format, the strand is on the 6th column, so in your example just move the strand to the 6th column:
cat test.fa
>chr01
ACCGGTT
cat test.bed
chr01 0 4 . . +
chr01 0 4 . . -
bedtools getfasta -s -fi test.fa -bed test.bed
>chr01:0-4(+)
AACC
>chr01:0-4(-)
GGTT