def countPeaks( contig, start, end, samfiles, offsets = None):

    nreads, counts = getCounts( contig, start, end, samfiles, offsets )

    # nreads can be 0 if the intervals overlap only slightly
    # and due to the binning, no reads are actually in the overlap region.
    # However, these intervals should be small and have already be deleted via 
    # the merge_min_interval_length cutoff, so I keep the assertion.
    assert nreads > 0, "no reads in interval %s:%i-%i" % (contig, start, end)

    length = end - start            
    nprobes = nreads
    avgval = numpy.mean( counts )
    peakval = max(counts)

    # set other peak parameters
    peaks = numpy.array( range(0,length) )[ counts >= peakval ]
    npeaks = len( peaks )
    # peakcenter is median coordinate between peaks
    # such that it is a valid peak in the middle
    peakcenter = start + peaks[npeaks//2] 

    return npeaks, peakcenter, length, avgval, peakval, nreads

############################################################
############################################################
############################################################
##
############################################################
[<channel>] <name|url> [<name|url> ...]
dataset/ETHPy150Open CGATOxford/cgat/obsolete/pipeline_vitaminD_intervals.py/countPeaks--crossover with--dataset/ETHPy150Open ProgVal/Limnoria/plugins/RSS/plugin.py/RSS.announce.add