code: def vcf_to_df_worker(arg):
      
      canvasvcf, exonbed, i = arg
      logging.debug("Working on job {}: {}".format(i, canvasvcf))
      samplekey = op.basename(canvasvcf).split(".")[0].rsplit('_', 1)[0]
      d = {'SampleKey': samplekey}
  
      exons = BedTool(exonbed)
      cn = parse_segments(canvasvcf)
      overlaps = exons.intersect(cn, wao=True)
      gcn_store = {}
      for ov in overlaps:
          # Example of ov.fields:
          # [u'chr1', u'11868', u'12227', u'ENSG00000223972.5',
          # u'ENST00000456328.2', u'transcribed_unprocessed_pseudogene',
          # u'DDX11L1', u'.', u'-1', u'-1', u'.', u'0']
          gene_name = "|".join((ov.fields[6], ov.fields[3], ov.fields[5]))
          if gene_name not in gcn_store:
              gcn_store[gene_name] = defaultdict(int)
  
          cn = ov.fields[-2]
          if cn == ".":
              continue
          cn = int(cn)
          if cn > 10:
              cn = 10
          amt = int(ov.fields[-1])
          gcn_store[gene_name][cn] += amt
  
      for k, v in sorted(gcn_store.items()):
          v_mean, v_median = counter_mean_and_median(v)
          d[k + ".avgcn"] = v_mean
          d[k + ".medcn"] = v_median
      cleanup()
      return d
docs: Convert CANVAS vcf to a dict, single thread