def histogrammer (input, output, Nfactor, minrange, maxrange):
  IN = open (input)
  OUT = open (output, "w")
  Nfactor=float(Nfactor)
  print >> OUT, field_controle(input)
  hist_dict = defaultdict(lambda: defaultdict(lambda: defaultdict(int))) # hist_dic[item][forward/reverse][size 15-30nt]=count, with the enormous "autovivification" trick !!!
  for line in IN:
    fields = line.split()
    if fields[1] == "+":
      polarity = "red"
    else:
      polarity = "darkblue"
    item = fields[2]
    size = len(fields[4])
    if polarity == "red":
      hist_dict[item][polarity][size] += 1
    else:
      hist_dict[item][polarity][size] -= 1
  IN.close()
  for item in sorted(hist_dict):
    for polarity in ["red","darkblue"]:
      for size in range(minrange,maxrange+1):
        print >> OUT, (polarity, size, hist_dict[item][polarity][size]*Nfactor, item) % "%s\t%s\t%f\t%s" 
  OUT.close()
dataset/ETHPy150Open ARTbio/tools-artbio/unstable/local_tools/histogrammer_v2.py/histogrammer/swapped operands of `%`