Create a .csv file with the strain name, and the number of core genes present/the total number of core genes

def reporter(self):
        """
        Create a .csv file with the strain name, and the number of core genes present/the total number of core genes
        """
        with open(os.path.join(self.reportpath, 'Escherichia_core.csv'), 'w') as report:
            data = 'Strain,Genes Present/Total\n'
            for sample in self.runmetadata.samples:
                # Convert the set to a list for JSON serialization
                sample[self.analysistype].coreset = list(sample[self.analysistype].coreset)
                sample[self.analysistype].coreresults = '{cs}/{cg}'.format(cs=len(sample[self.analysistype].coreset),
                                                                           cg=len(self.coregenomes))
                # Add strain name, the number of core genes present, and the number of total core genes to the string
                data += '{sn},{cr}\n'.format(sn=sample.name,
                                             cr=sample[self.analysistype].coreresults)
            report.write(data)

        for sample in self.metadata:
            # Remove the messy blast results and set/list of core genes from the object
            try:
                delattr(sample[self.analysistype], "blastresults")
            except AttributeError:
                pass
            try:
                delattr(sample[self.analysistype], 'coreset')
            except AttributeError:
                pass