nucleotide extraction using coordinates
1
0
Entering edit mode
5.9 years ago

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

next-gen • 1.6k views
ADD COMMENT
2
Entering edit mode

The answer to your question is probably bedtools getfasta

ADD REPLY
4
Entering edit mode
5.9 years ago

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

ADD COMMENT
1
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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)
ADD REPLY
0
Entering edit mode

is it $2,$2+2 or $2-1,$2+1 as user want start, start+1 for $2?

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

keep bed format in view, while creating new bed @OP.

ADD REPLY
0
Entering edit mode

this simple method is working well. thanks for king suggestion.

ADD REPLY

Login before adding your answer.

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