How split regions in half to get at most 1000 bp length?
1
0
Entering edit mode
3.0 years ago
star ▴ 350

I have a table of genomic regions that I would like to split them in half until all regions are in at most 1000 bp long.

I have tried the bedops --chop 1000 data but it doesn`t work and it gave me some regions with 1 bp length.

Data : 
chr   start end   length   center of region
chr1   500   3000  2500         1750   
chr2   100   1100  1000         600
chr4   20    1900  1880         960


results:
chr    start end   length
chr1   500   1125    625
chr1   1125  1750    625
chr1   1750  2375    625
chr1   2375  3000    625
chr2   100   1100    1000
chr4   20    960     940
chr4   960    1900   940
split linux bedtools R chop • 601 views
ADD COMMENT
0
Entering edit mode
3.0 years ago

with

function dump(C,S,E)
    {
    if( E-S <= 1000) {
        printf("%s\t%d\t%d\n",C,S,E);
        }
    else
        {
        dump(C,S,S+(E-S)/2);
        dump(C,S+(E-S)/2,E);
        }
    }

    {
    dump($1,int($2),int($3));
    }

usage

awk -f script.awk < input.bed

ADD COMMENT

Login before adding your answer.

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