code: def evaluate(args):
      
      from jcvi.formats.sizes import Sizes
  
      p = OptionParser(evaluate.__doc__)
      p.add_option("--query",
                   help="Chromosome location [default: %default]")
      opts, args = p.parse_args(args)
  
      if len(args) != 3:
          sys.exit(not p.print_help())
  
      prediction, reality, fastafile = args
      query = opts.query
      prediction = mergeBed(prediction)
      reality = mergeBed(reality)
      sizes = Sizes(fastafile)
      sizesfile = sizes.filename
  
      prediction_complement = complementBed(prediction, sizesfile)
      reality_complement = complementBed(reality, sizesfile)
  
      TPbed = intersectBed(prediction, reality)
      FPbed = intersectBed(prediction, reality_complement)
      FNbed = intersectBed(prediction_complement, reality)
      TNbed = intersectBed(prediction_complement, reality_complement)
      beds = (TPbed, FPbed, FNbed, TNbed)
  
      if query:
          subbeds = []
          rr = query_to_range(query, sizes)
          ce = 'echo "{0}"'.format("\t".join(str(x) for x in rr))
          for b in beds:
              subbed = ".".join((b, query))
              cmd = ce + " | intersectBed -a stdin -b {0}".format(b)
              sh(cmd, outfile=subbed)
              subbeds.append(subbed)
          beds = subbeds
  
      be = BedEvaluate(*beds)
      print(be, file=sys.stderr)
  
      if query:
          for b in subbeds:
              os.remove(b)
  
      return be
docs: %prog evaluate prediction.bed reality.bed fastafile
  
      Make a truth table like:
              True    False  --- Reality
      True    TP      FP
      False   FN      TN
       |----Prediction
  
      Sn = TP / (all true in reality) = TP / (TP + FN)
      Sp = TP / (all true in prediction) = TP / (TP + FP)
      Ac = (TP + TN) / (TP + FP + FN + TN)