public static void main(String[] args) { File envisionFile = new File("./resources/envision-example 1.xls"); Sheet sheet = StringTable.openWorkSheet(envisionFile).getSheetAt(0); Point bckndTablePos = StringTable.findNextPlatePosition(sheet, new Point(1, 1)); Point corTablePos = StringTable.findNextPlatePosition( sheet, new Point((int) bckndTablePos.getX(), (int) (bckndTablePos.getY() + 1))); Rectangle tableBounds = StringTable.guessPlateBounds(sheet, corTablePos); StringTable table = StringTable.readStringGridFromExcel(tableBounds, sheet); System.err.println("starting point is" + corTablePos); System.err.println("table-bounds are" + tableBounds); System.err.println("the table is " + table); // envisionFile = StringTable.readStringGridFromCsv(envisionFile, ",", new Point(2, 4), // new Point(25, 19)) }
public void parseFile(Plate plate, String attributeName, File envisionFile) { Sheet sheet = StringTable.openWorkSheet(envisionFile).getSheetAt(0); Point tableTopLeftPos = StringTable.findNextPlatePosition(sheet, new Point(1, 1)); int numSkipTables = propTableIndex.getIntValue() - 1; while (tableTopLeftPos != null && numSkipTables > 0) { tableTopLeftPos = StringTable.findNextPlatePosition( sheet, new Point((int) tableTopLeftPos.getX(), (int) (tableTopLeftPos.getY() + 1))); numSkipTables--; } if (tableTopLeftPos == null) { throw new RuntimeException("Could not find readout-table in file " + envisionFile); } Rectangle tableBounds = StringTable.guessPlateBounds(sheet, tableTopLeftPos); StringTable envisionTable = StringTable.readStringGridFromExcel(tableBounds, sheet); // either set the plate dimensions or validate them if (plate.getNumRows() < 0) { plate.setNumColumns(envisionTable.getWidth() - 1); plate.setNumRows(envisionTable.getHeight() - 1); } else { assert envisionTable.getWidth() - 1 == plate.getNumColumns(); assert envisionTable.getHeight() - 1 == plate.getNumRows(); } for (int colIndex = 0; colIndex < plate.getNumColumns(); colIndex++) { for (int rowIndex = 0; rowIndex < plate.getNumRows(); rowIndex++) { int plateRow = rowIndex + 1; // this inversion looks weired but it is correct int plateColumn = colIndex + 1; Well well = plate.getWell(plateColumn, plateRow); if (well == null) { well = new Well(); well.setPlateRow(plateRow); well.setPlateColumn(plateColumn); well.setPlate(plate); plate.addWell(well); } Double readout = ScreenImportUtils.parseDouble(envisionTable.get(plateRow, plateColumn)); if (readout != null) { well.getWellStatistics().put(attributeName, readout); } } } }