text: user15741: I am trying to split my .bed/.fa file genomic segments into arbitrary smaller overlapping intervals:
  Consider a typical line/row in my *.bed file as follows:
  chrom. $\ \ \ \ \ $  start $\ \ \ \ \ \ \ \ \ \ \ \ $ end
  chr7 $\ \ \ $   127471196 $\ \ \ $    127472363$\ \ \ $      ...
  The start and end genomic positions include 1167 base pairs for this line. I need to extend this line, for example, into multiple lines where each line covers exactly 500bp like below:
  chr7 $\ \ \ $    127471196 $\ \ \ $    127471696 $\ \ \ $       ...
  chr7 $\ \ \ $    127471863  $\ \ \ $   127472363 $\ \ \ $       ...
  
  While each line covers 500pb, between the two new lines they both include the same "range" of genomic positions as the original line including some overlap which is fine (and desired)
  Is there an existing tool (perhaps part of bedtools?) that can do something like this?
  I know there is the bedops tool that does ALMOST this using the --chop option, where it takes the original segment x1:x2 and chops the original segment into specified fixed bp length intervals, however, if there is any left over towards the end is creates a new non-standard length segment (i.e. x1:x2=10bp and chop length=3, it will give you 4 segments that are length 3, 3, 3 and 1 - what I am looking for is something that adjusts for the last remainder and outputs segments of length 3,3,3 and 3 where the last length 3 segment is right adjusted, while the first three segments are left adjusted or better yet it gives the user the choice of precise redefinition of segment coordinates y1,y2,y3 and y4).  Thank you.
  
  user776: You can run --chop with -x to excise the last piece, adding the --stagger to size the chopped pieces as needed, e.g.:
  $ echo -e 'chr1\t0\t10' | bedops --chop 3 --stagger 2 -x -
  chr1    0       3
  chr1    2       5
  chr1    4       7
  chr1    6       9
  
  Adjust parameters to taste.
  https://bedops.readthedocs.io/en/latest/content/reference/set-operations/bedops.html#chop-w-chop
  https://bedops.readthedocs.io/en/latest/content/reference/set-operations/bedops.html#stagger-stagger
  https://bedops.readthedocs.io/en/latest/content/reference/set-operations/bedops.html#exclude-x
  
original_text: 15741: <p>I am trying to split my <em>.bed/</em>.fa file genomic segments into arbitrary smaller overlapping intervals:</p>
  <p>Consider a typical line/row in my *.bed file as follows:</p>
  <p>chrom. <span class="math-container">$\ \ \ \ \ $</span>  start <span class="math-container">$\ \ \ \ \ \ \ \ \ \ \ \ $</span> end</p>
  <p>chr7 <span class="math-container">$\ \ \ $</span>   127471196 <span class="math-container">$\ \ \ $</span>    127472363<span class="math-container">$\ \ \ $</span>      ...</p>
  <p>The start and end genomic positions include 1167 base pairs for this line. I need to extend this line, for example, into multiple lines where each line covers exactly 500bp like below:</p>
  <p>chr7 <span class="math-container">$\ \ \ $</span>    127471196 <span class="math-container">$\ \ \ $</span>    127471696 <span class="math-container">$\ \ \ $</span>       ...</p>
  <p>chr7 <span class="math-container">$\ \ \ $</span>    127471863  <span class="math-container">$\ \ \ $</span>   127472363 <span class="math-container">$\ \ \ $</span>       ...</p>
  <p><a href="https://i.stack.imgur.com/Ws3ts.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ws3ts.png" alt="![enter image description here" /></a></p>
  <p>While each line covers 500pb, between the two new lines they both include the same &quot;range&quot; of genomic positions as the original line including some overlap which is fine (and desired)</p>
  <p>Is there an existing tool (perhaps part of bedtools?) that can do something like this?</p>
  <p>I know there is the <strong>bedops</strong> tool that does ALMOST this using the --chop option, where it takes the original segment x1:x2 and chops the original segment into specified fixed bp length intervals, however, if there is any left over towards the end is creates a new non-standard length segment (i.e. x1:x2=10bp and chop length=3, it will give you 4 segments that are length 3, 3, 3 and 1 - what I am looking for is something that adjusts for the last remainder and outputs segments of length 3,3,3 and 3 where the last length 3 segment is right adjusted, while the first three segments are left adjusted or better yet it gives the user the choice of precise redefinition of segment coordinates y1,y2,y3 and y4).  Thank you.</p>
   776: <p>You can run <code>--chop</code> with <code>-x</code> to excise the last piece, adding the <code>--stagger</code> to size the chopped pieces as needed, e.g.:</p>
  <pre><code>$ echo -e 'chr1\t0\t10' | bedops --chop 3 --stagger 2 -x -
  chr1    0       3
  chr1    2       5
  chr1    4       7
  chr1    6       9
  </code></pre>
  <p>Adjust parameters to taste.</p>
  <p><a href="https://bedops.readthedocs.io/en/latest/content/reference/set-operations/bedops.html#chop-w-chop" rel="nofollow noreferrer">https://bedops.readthedocs.io/en/latest/content/reference/set-operations/bedops.html#chop-w-chop</a></p>
  <p><a href="https://bedops.readthedocs.io/en/latest/content/reference/set-operations/bedops.html#stagger-stagger" rel="nofollow noreferrer">https://bedops.readthedocs.io/en/latest/content/reference/set-operations/bedops.html#stagger-stagger</a></p>
  <p><a href="https://bedops.readthedocs.io/en/latest/content/reference/set-operations/bedops.html#exclude-x" rel="nofollow noreferrer">https://bedops.readthedocs.io/en/latest/content/reference/set-operations/bedops.html#exclude-x</a></p>
  