keep bed format in view, while creating new bed @OP.
Dear all,
i have following coordinate file
chr1 329728 329839 -
chr1 330066 330757 -
chr1 581256 581357 +
from this file i want to derive specific nucleotides such that for coordinate 329728 i should get 2 nucleotides of 329728 and 329729 coordinate (i.e one nucleotide from this coordinate along with next nucleotide) and for 329839, 2 nucleotides 329838 and 329839 ( i.e one nucleotide from this coordinate along with one previous nucleotide)
can anyone kindly suggest command/script/tool for this purpose???
kind help will highly be appreciated. many thanks
1 answer
I would create a new bed like this :
chr1 329728 329729
chr1 329838 329839
chr1 330066 330067
chr1 330756 330757
...
Then use bedtools getfasta on this new bed file
I would create a new bed like this :
$ awk -v OFS="\t" '{print $1,$2,$2+2,$4"\n"$1,$3-1,$3+1,$4}' input.bed > output.bed
Take care that the bed format uses 0-based, half-open intervals.
fin swimmer
maybe this would work :
bedtools getfasta -fi genome.fa -bed <(echo awk -v OFS="\t" '{print $1,$2,$2+2,$4"\n"$1,$3-1,$3+1,$4}' input.bed)
is it $2,$2+2 or $2-1,$2+1 as user want start, start+1 for $2?
As the coordinates in bed files are half-open it should be $2,$2+2. Half-open means the start position is included in the interval but not the end position.
But I don't know whether the OP is aware about the common problem with 0-based vs. 1-based coordinates and half-open vs. closed intervalls. So it might be neccessary do adopt the awk command to get correct coordinates of interest.
fin swimmer
this simple method is working well. thanks for king suggestion.
Log in to answer this question.
The answer to your question is probably bedtools getfasta