code: def metric_calculator(tpf, fpf, P, N, metric_list, anal=True):
      
  
      metrics = {}
  
      # build dictionary to store performance metrics
      for vs_metric in [float(x) for x in metric_list if '.' in x]:
          if N >= 1 / vs_metric:
              # enrichment factor (ef) dictionary {#_of_req_decoys : [FPF,EF]}
              metrics[round(vs_metric * N)] = [vs_metric, 0]
  
      # non enrichment factor dictionary {'name' : ['name',value]}
      for vs_metric in [x for x in metric_list if '.' not in x]:
          metrics[vs_metric] = [vs_metric, 0, 0, 0]
  
      # calculate enrichment factors & auc
      metrics['AUC'][1] = 0
  
      for index in range(len(tpf)):
          # calculate and assign enrichment factors
          if N * fpf[index] in metrics.keys() and N * fpf[index] > 0:
              ef = tpf[index] / fpf[index]
              metrics[N * fpf[index]][1] = ef
  
          # calculate auc
          if fpf[index] != fpf[index - 1]:
              metrics['AUC'][1] = tpf[index] + metrics['AUC'][1]
  
      metrics['AUC'][1] = metrics['AUC'][1] / N
  
      # reshape metrics dictionary, discarding the #_of_req_decoys, i.e: {'fpf',[value,low,high]}
      reshaped = {}
      for k,v in metrics.iteritems():
              if type(v) is float or type(v) is int:
                  reshaped[k] = v
              else:
                  reshaped[v[0]] = v[1:]
  
      return reshaped
docs: Calculates VS metrics & (optionally) their 95% conficdence limits