def colouredResults(self): """Outputs an Excel file with a summary table, a sample table, and a plate sheet for each plate.""" if self.__checkResults(): title = "Excel filename..." exportFileName, f = QtGui.QFileDialog.getSaveFileName(self, title, self.path) exportFileName = exportFileName.split(".")[0] crops = list(np.unique(self.resultsTable.table["Crop"])) groupsLists = [groups[crop] for crop in crops] incGroups = [item for sublist in groupsLists for item in sublist] incGroups = incGroups + ["Unknown", "Negative"] included = self.resultsTable.table[self.resultsTable.table["Include"] == True] exportTable = included[["Plate ID", "Plate Name", "Well", "Result", "Group"]].reset_index(drop=True) statsTable = self.__getStatsTable(exportTable, incGroups, "Plate ID") statsTable["Ind"] = statsTable.index.values plates = statsTable[["Plate ID", "Plate Name"]] ok = True while (plates["Plate Name"].str.len() > 23).any() and ok: plates, ok = ShortenPlateNamesDialog.run(plates) statsTable = statsTable.set_index("Plate ID") exportTable = exportTable.set_index("Plate ID") plates = plates.set_index("Plate ID") statsTable.update(plates) exportTable.update(plates) statsTable = statsTable.reset_index() exportTable = exportTable.reset_index() if ok: workBook = ExportWorkbook() workBook.addStatsPage(incGroups, statsTable) workBook.addSamplePage(exportTable) workBook.addPlateSheets(statsTable, exportTable, incGroups) workBook.save(exportFileName + ".xls")
def outputHarvestSheets(self): """Outputs harvest spreadsheets.""" title = "Excel filename..." exportFileName, f = QtGui.QFileDialog.getSaveFileName(self, title, self.path) exportFileName = exportFileName.split(".")[0] workBook = ExportWorkbook() sampleTable = self.resultsTable.table.merge(self.infoTable.table, on=["Plate ID", "Well"], suffixes=("", "_y")) workBook.addHarvestSheets(sampleTable) workBook.save(exportFileName + ".xls")
def niceKeaSpreadsheet(self): """Outputs Results and Kea data to a spreadsheet.""" if self.__checkResults(): title = "Excel filename..." exportFileName, f = QtGui.QFileDialog.getSaveFileName(self, title, self.path) exportFileName = exportFileName.split(".")[0] columns = ["Plate ID", "Plate Kea", "Well", "Sample ID", "PlantID", "Group"] table = ( self.resultsTable.table.set_index(["Plate ID", "Well"]) .join(self.infoTable.table.set_index(["Plate ID", "Well"]), rsuffix="i") .reset_index() ) table = table[columns] table["Ind"] = table.index.values workBook = ExportWorkbook() workBook.addKeaTable(table) workBook.save(exportFileName + ".xls")