def getCounts( contig, start, end, samfiles, offsets = [] ):
    assert len(offsets) == 0 or len(samfiles) == len(offsets)

    length = end - start
    counts = numpy.zeros( length )

    nreads = 0

    if offsets:
        # if offsets are given, shift tags. 
        for samfile, offset in zip(samfiles,offsets):

            # for peak counting I follow the MACS protocoll,
            # see the function def __tags_call_peak in PeakDetect.py
            # In words
            # Only take the start of reads (taking into account the strand)
            # add d/2=offset to each side of peak and start accumulate counts.

            # for counting, extend reads by offset
            # on + strand shift tags upstream
            # i.e. look at the downstream window
            xstart, xend = max(0, start - offset), max(0, end - offset)
            for read in samfile.fetch( contig, xstart, xend ):
                if read.is_reverse: continue
                nreads += 1
                rstart = max( 0, read.pos - xstart - offset)
                rend = min( length, read.pos - xstart + offset) 
                counts[ rstart:rend ] += 1

            # on the - strand, shift tags downstream
            xstart, xend = max(0, start + offset), max(0, end + offset)
            for read in samfile.fetch( contig, xstart, xend ):
                if not read.is_reverse: continue
                nreads += 1
                rstart = max( 0, read.pos + read.rlen - xstart - offset)
                rend = min( length, read.pos + read.rlen - xstart + offset) 
                counts[ rstart:rend ] += 1
    else:
        for samfile in samfiles:
            for read in samfile.fetch( contig, start, end ):
                nreads += 1
                rstart = max( 0, read.pos - start )
                rend = min( length, read.pos - start + read.rlen ) 
                counts[ rstart:rend ] += 1
    return nreads, counts

############################################################
############################################################
############################################################
Given a list of FileContent objects, return a FilesContent object.
dataset/ETHPy150Open CGATOxford/cgat/obsolete/pipeline_vitaminD_intervals.py/getCounts--crossover with--dataset/ETHPy150Open pantsbuild/pants/src/python/pants/engine/exp/fs.py/files_content