BED file: how to split/join into fragments of fixed length that take only portions INSIDE the intervals ?
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 intervals.
• 3,255 views
•
link
1 answer
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.
• 0 views
•
link
Log in to answer this question.
I know that this is not the answer you're looking for but maybe you should try to write a little
perl/python/awkscript to do it.If there is no quick way, I will have to spend time and do it.
Reading more carefully about
--staggerand--chopoperation ofbedops, they may actually can do what I want.No, bedops doesn't do what I want: