code: def geneseekrsummary(self):
          logging.info('Creating predicted plasmid-borne gene summary table')
          with open(os.path.join(self.reportpath, 'plasmid_borne_summary.csv'), 'w') as pbs:
              data = 'Strain,Gene,PercentIdentity,Contig,Location,PlasmidIncompatibilitySets\n'
              for sample in self.metadata:
                  result_bool = False
                  inc_dict = dict()
                  for primarykey, results in sample[self.analysistype].report_dict.items():
                      try:
                          inc = results['cluster_id']
                          rep = str(results['rep_type']).replace(',', ';') if str(results['rep_type']) != 'nan' else 'ND'
                          try:
                              inc_dict[inc].add(rep)
                          except KeyError:
                              inc_dict[inc] = set()
                              inc_dict[inc].add(rep)
                      except KeyError:
                          pass
                  for primarykey, results in sample[self.analysistype].report_dict.items():
                      try:
                          contig = results['contig_id'].split('|')[1]
                          if contig.split('_')[1].startswith('length'):
                              contig = contig.split('_')[0]
                          for gene, result_dict in sample.geneseekr_results.sampledata.items():
                              if contig == result_dict['query_id']:
                                  percent_identity = result_dict['PercentIdentity']
                                  if float(result_dict['PercentIdentity']) >= self.cutoff:
                                      result_bool = True
                                      data += '{sn},'.format(sn=sample.name)
                                      data += '{gene},{pi},{contig},{cid},{inc}\n'\
                                          .format(gene=gene,
                                                  pi=percent_identity,
                                                  contig=contig,
                                                  cid=results['cluster_id'],
                                                  inc=';'.join(sorted(inc_dict[str(results['cluster_id'])])))
                      except KeyError:
                          pass
                  if not result_bool:
                      data += '{sn}\n'.format(sn=sample.name)
              pbs.write(data)