code: def _reads_per_position(bam_in, loci_file, out_dir):
      
      data = Counter()
      a = pybedtools.BedTool(bam_in)
      b = pybedtools.BedTool(loci_file)
      c = a.intersect(b, s=True, bed=True, wo=True)
      for line in c:
          end = int(line[1]) + 1 + int(line[2]) if line[5] == "+" else int(line[1]) + 1
          start = int(line[1]) + 1 if line[5] == "+" else int(line[1]) + 1 + int(line[2])
          side5 = "%s\t5p\t%s" % (line[15], start)
          side3 = "%s\t3p\t%s" % (line[15], end)
          data[side5] += 1
          data[side3] += 1
  
      counts_reads = op.join(out_dir, 'locus_readpos.counts')
      with open(counts_reads, 'w') as out_handle:
          for k in data:
              print(k, file=out_handle, end="")
  
      return counts_reads
docs: Create input for compute entropy