def process_anchor_start(regions_fn, to_count_fn,
                         anchor_to=ANCHOR_START, normalize=False,
                         verbose=False):
  """
  :return: list where each element is the number of hits at that location
           relative to the start of the regions.
  """
  res = []
  possible = []
  trees = intervalTrees(to_count_fn, verbose=verbose)
  for region in BEDIterator(regions_fn, verbose=verbose):
    if normalize:
      for i in range(0, len(region)):
        while len(possible) <= i:
          possible.append(0)
        possible[i] += 1

    if region.chrom not in trees:
      continue
    hits = trees[region.chrom].intersectingInterval(region.start, region.end)
    for h in hits:
      abs_pos = h.start
      if abs_pos < region.start or abs_pos >= region.end:
        continue
      rel_pos = __to_relative(abs_pos, region, anchor_to)
      assert(rel_pos < len(region))

      while(len(res) <= rel_pos):
        res.append(0)
      res[rel_pos] += 1

  if normalize:
    __norm_counts(res, possible)
  return res
def process_anchor_start ( regions_fn , to_count_fn , anchor_to = ANCHOR_START , normalize = False , verbose = False ) : res = [ ] possible = [ ] trees = intervalTrees ( to_count_fn , verbose = verbose ) for region in BEDIterator ( regions_fn , verbose = verbose ) : if normalize : for i in range ( 0 , len ( region ) ) : while len ( possible ) <= i : possible . append ( 0 ) possible [ i ] += 1 if region . chrom not in trees : continue hits = trees [ region . chrom ] . intersectingInterval ( region . start , region . end ) for h in hits : abs_pos = h . start if abs_pos < region . start or abs_pos >= region . end : continue rel_pos = __to_relative ( abs_pos , region , anchor_to ) assert ( rel_pos < len ( region ) ) while ( len ( res ) <= rel_pos ) : res . append ( 0 ) res [ rel_pos ] += 1 if normalize : __norm_counts ( res , possible ) return res
:return: list where each element is the number of hits at that location
           relative to the start of the regions.