code: def aggregate(self):
          
          for report in self.reportset:
              printtime('Processing {}'.format(report.split('.')[0]), self.start)
              # Initialise the header for each report - MLST is different, as the header is different for each
              # MLST scheme. This provides a generic header instead
              header = '' if report != 'mlst.csv' else 'Strain,Genus,SequenceType,Matches,1,2,3,4,5,6,7\n'
              # Initialise a string to hold the data for each report
              data = ''
              # Open the aggregated report
              with open(os.path.join(self.reportpath, report), 'w') as aggregate:
                  for sample in self.runmetadata.samples:
                      # Try to open the report for this run
                      try:
                          #
                          with open(os.path.join(sample.general.reportpath, report), 'r') as runreport:
                              # Only get the header from the first file
                              if not header:
                                  header = runreport.readline()
                              else:
                                  for row in runreport:
                                      # The final entry in a report does not have a newline character. Add \n as required
                                      if not row.endswith('\n'):
                                          row += '\n'
                                      # For certain reports, the header row is printed above each strain - ignore multiple
                                      # instances of the header
                                      if row.split(',')[0] != header.split(',')[0]:
                                          # Add the row to the string of data
                                          data += row
                      except IOError:
                          pass
                  # Write the strings to the aggregate report file
                  aggregate.write(header)
                  aggregate.write(data)
docs: Aggregate all reports of the same type into a master report