code: def amrsummary(self):
          logging.info('Creating AMR summary table from ResFinder and MOB-recon outputs')
          with open(os.path.join(self.reportpath, 'amr_summary.csv'), 'w') as amr:
              data = 'Strain,Gene,Allele,Resistance,PercentIdentity,Contig,Location,PlasmidIncompatibilitySets\n'
              for sample in self.metadata:
                  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 amr_result in sample.resfinder_assembled.sampledata:
                              if contig == str(amr_result[-1]):
                                  data += '{sn},'.format(sn=sample.name)
                                  data += '{amr},{mob}\n'\
                                      .format(amr=','.join(str(res) if str(res) != 'nan' else 'ND' for res in
                                                           amr_result[0:4]),
                                              mob=','.join(str(res) if str(res) != 'nan' else 'ND' for res in
                                                           [contig, results['cluster_id'],
                                                            ';'.join(sorted(inc_dict[str(results['cluster_id'])]))
                                                            ]
                                                           )
                                              )
                      except KeyError:
                          pass
              amr.write(data)