def aggregate(self, experimentID, user): """ Aggregate the GFP scores and send report """ gfps = GFP.objects.filter(experiment_id=experimentID) log.debug("RUNNING aggregate: initialize method") algorithm = Algorithm() algorithm = algorithm.getAlgorithm("NV") algorithm.loadDataAggregate() algorithm.aggregate(gfps, experimentID) experiment = Experiment.objects.filter(id=experimentID) log.debug("RUNNING aggregate: start report") report = Report(experimentID) filename = REPORT_DIR + "sapling_gfp_report_" + slugify(experiment[0].Name) + "_" + str(experimentID) + ".pdf" report.generateReport(filename) del report subject = "SAPLING report: " + experiment[0].Name body = "Dear " + user.first_name + " "+ user.last_name + ",\n\n" body += "Please find attached a report of your experiment " + experiment[0].Name + ".\n\n" body += "Regards,\n SAPLING" email = EmailMessage(subject=subject, body=body, from_email="*****@*****.**", to=[user.email]) reportname = "sapling_gfp_report_" + slugify(experiment[0].Name) + "_" + str(experimentID) + ".pdf" handle = open(filename, 'rb') email.attach(reportname, handle.read(), "application/pdf") enrichname = "Enrichment_GeneList_GO_" + str(experimentID) + ".csv" filename = REPORT_DIR + "Enrichment_GeneList_GO_" + str(experimentID) + ".csv" handle = open(filename, 'rb') email.attach(enrichname, handle.read(), "text/csv") email.send() handle.close() log.debug("DONE Aggregate")