Question: BED file: how to split/join into fragments of fixed length that take only portions INSIDE the intervals ?
0
gravatar for biocyberman
5.4 years ago by
biocyberman810
Denmark
biocyberman810 wrote:

I have been looking at `bedtools` and `bedops` to do the following thing but haven't figured out:

Input bed:

chr1    1000    2000    geneA    0    +
chr1    2100    2500    geneB    0    +
chr1    2800    3200    geneC    0    +
chr1    3700    4600    geneD    0    +

Output by 500 bases fragments inside those BED intervals:

chr1    1000    1500    geneA    0    + # split action
chr1    1500    2000    geneA    0    + # split action
chr1    2100    2900    geneB,geneC    0    + # join action: 400 from 2100 - 2500, and 100 from 2800 - 2900
chr1    2900    3900    geneC,geneD    0    + # join action: 300 from 2900 - 3200, and 200 from 3700 - 3900
chr1    3900    4400    geneD    0    + # split action
chr1    4400    4600    geneD    0    + # split action, take the rest

 

For simplicity, input bed do not have overlapping invervals.

bedops bed bedtools • 1.7k views
ADD COMMENTlink modified 5.4 years ago by Alex Reynolds31k • written 5.4 years ago by biocyberman810
1

I know that this is not the answer you're looking for but maybe you should try to write a little perl/python/awk script to do it.

ADD REPLYlink modified 5.4 years ago • written 5.4 years ago by iraun3.8k

If there is no quick way, I will have to spend time and do it. 

Reading more carefully about --stagger and --chop operation of bedops, they may actually can do what I want.

ADD REPLYlink modified 5.4 years ago • written 5.4 years ago by biocyberman810

No, bedops doesn't do what I want: 

bedops --chop 500 test.bedops.bed                                                                                                                         
chr1    1000    1500
chr1    1500    2000
chr1    2100    2500 # only take 400 and stops
chr1    2800    3200 # start anew
chr1    3700    4200 # start anew
chr1    4200    4600 # only take 400 and stops

 

ADD REPLYlink written 5.4 years ago by biocyberman810
0
gravatar for Alex Reynolds
5.4 years ago by
Alex Reynolds31k
Seattle, WA USA
Alex Reynolds31k wrote:

As mentioned, you need to write a script to do this, because you are not applying the same operation to all input intervals equally. For instance, some elements get one split operation, other elements get a different split operation. You will likely need to write custom logic to decide how to apply your desired operations.

ADD COMMENTlink modified 5.4 years ago • written 5.4 years ago by Alex Reynolds31k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1738 users visited in the last hour