/** * Return a String of the position, given the position as two integers representing the row and column. Examples: * assertTrue(getPositionString(0, 0).equals("A01")) assertTrue(getPositionString(25, 0).equals("Z01")) assertTrue(getPositionString(0, * 11).equals("A12")) * * @param integer * representations of the row and column where 0 <= row <= 25 and 0 <= column <= 98 * @return String representation of the row and column * @throws IllegalArgumentException * if the row and column do not meet the following conditions: 0 <= row <= 25, 0 <= column <= 98 */ public static String getPositionString(int row, int column) { return getPositionString(toRowChar(row), column); }
/** * Extracts the row number from a box position reference in String form ("A01") * * @param position * the position reference * @return the row number, between 0 and 25 inclusive * @throws IllegalArgumentException * if this is not a valid String reference to a box position */ public static int getRowNumber(String position) { validateReference(position); return fromRowChar(position.charAt(0)); }
/** * {@link VisionMateScanner} expects a one-based row number, but BoxUtils.getRowNumber converts it to zero-based. This method * increments by one to account for this. * * @param position String like "A02" */ @Override public String getBarcode(String position) { return getBarcode(BoxUtils.getRowNumber(position) +1, BoxUtils.getColumnNumber(position)); }
/** * Extracts the row character from a box position reference in String form ("A01") * * @param position * the position reference * @return an alphabetic letter, taken from the first character of the position reference, and made uppercase if neccessary * @throws IllegalArgumentException * if this is not a valid String reference to a box position */ public static char getRowChar(String position) { validateReference(position); return normalizeLetter(position.charAt(0)); }
public static String makeLocationLabel(BoxableView boxable) { return makeLocationLabel(boxable.isDiscarded(), boxable.getLocationBarcode(), boxable.getBoxAlias(), boxable.getBoxPosition(), boxable.getBoxLocationBarcode()); }
public Stream<String> positionStream() { return IntStream.range(0, rows * columns).mapToObj(x -> BoxUtils.getPositionString(x / columns, x % columns)); }
dto.setLocationLabel(BoxUtils.makeLocationLabel(from)); if (from.getBox() != null) { dto.setBox(asDto(from.getBox(), includeBoxPositions)); dto.setSampleBoxPositionLabel(BoxUtils.makeBoxPositionLabel(from.getSample().getBox().getAlias(), from.getSample().getBoxPosition()));
private void validate(String position) { if (!position.matches("[A-Z][0-9][0-9]")) throw new IllegalArgumentException("Position " + position + " does not match [A-Z][0-9][0-9]"); if (BoxUtils.fromRowChar(position.charAt(0)) >= getSize().getRows()) throw new IndexOutOfBoundsException("Row letter too large!" + position); int col = BoxUtils.tryParseInt(position.substring(1, 3)); if (col <= 0 || col > getSize().getColumns()) throw new IndexOutOfBoundsException("Column value too large!"); }
public boolean isColumnNonZero(String position) { return BoxUtils.tryParseInt(position.substring(1, 3)) != 0; }
/** * Return the integer representation of a character which represents a row of a Box. * * A -> 0, B -> 1, ... , Z -> 25 * * @param character * representation of the row * @return integer representation of the row * @throws IllegalArgumentException * if the given character is not in the Alphabet */ public static int fromRowChar(char letter) { return normalizeLetter(letter) - 'A'; }
/** * Extracts the column number from a box position reference in String form ("A01") * * @param position * the position reference * @return the column number, between 0 and 25 inclusive * @throws IllegalArgumentException * if this is not a valid String reference to a box position */ public static int getColumnNumber(String position) { validateReference(position); return Integer.parseInt(position.substring(1, position.length())); }
public static String makeLocationLabel(Boxable boxable) { return makeLocationLabel(boxable.isDiscarded(), boxable.getLocationBarcode(), boxable.getBox() == null ? null : boxable.getBox().getAlias(), boxable.getBoxPosition(), boxable.getBox() == null ? null : boxable.getBox().getLocationBarcode()); }
@Override public Map<String, String> getBarcodesMap() { String[][] array = scan.getBarcodes(); Map<String, String> map = new HashMap<>(); for (int row = 0; row < array.length; row++) { for (int col = 0; col < array[row].length; col++) { map.put(BoxUtils.getPositionString(row, col), array[row][col]); } } return map; }
@Override public boolean isValidPosition(String position) { if (!position.matches("[A-Z][0-9][0-9]")) return false; if (BoxUtils.fromRowChar(position.charAt(0)) >= getSize().getRows()) return false; int col = BoxUtils.tryParseInt(position.substring(1, 3)); if (col < 0 || col > getSize().getColumns()) return false; // columns are zero-indexed in database return true; }
public boolean isColumnNonZero(String position) { return BoxUtils.tryParseInt(position.substring(1, 3)) != 0; }
dto.setLocationLabel(BoxUtils.makeLocationLabel(from)); if (from.getBox() != null) { dto.setBox(asDto(from.getBox(), includeBoxPositions));
@Override public List<String> getReadErrorPositions() { final String[][] barcodes = scan.getBarcodes(); final String noRead = scan.getNoReadLabel(); List<String> positions = new ArrayList<>(); for (int row = 0; row < barcodes.length; row++) { for (int col = 0; col < barcodes[row].length; col++) { if (noRead.equals(barcodes[row][col])) positions.add(BoxUtils.getPositionString(row, col)); } } return positions; }
private static DilutionDto asDto(@Nonnull LibraryDilution from, @Nonnull LibraryDto libraryDto, boolean includeBoxPositions) { DilutionDto dto = new DilutionDto(); dto.setId(from.getId()); dto.setName(from.getName()); dto.setDilutionUserName(from.getCreator().getFullName()); dto.setConcentration(from.getConcentration() == null ? null : from.getConcentration().toString()); dto.setConcentrationUnits(from.getConcentrationUnits()); dto.setVolume(from.getVolume() == null ? null : from.getVolume().toString()); dto.setVolumeUnits(from.getVolumeUnits()); dto.setNgUsed(from.getNgUsed() == null ? null : from.getNgUsed().toString()); dto.setVolumeUsed(from.getVolumeUsed() == null ? null : from.getVolumeUsed().toString()); if (from.getCreationDate() != null) { dto.setCreationDate(formatDate(from.getCreationDate())); } dto.setIdentificationBarcode(from.getIdentificationBarcode()); dto.setLocationLabel(BoxUtils.makeLocationLabel(from)); if (from.getTargetedSequencing() != null) { dto.setTargetedSequencingId(from.getTargetedSequencing().getId()); } dto.setLibrary(libraryDto); if (from.getBox() != null) { dto.setBox(asDto(from.getBox(), includeBoxPositions)); dto.setBoxPosition(from.getBoxPosition()); } dto.setDiscarded(from.isDiscarded()); return dto; }
public static BoxableDto asDto(@Nonnull BoxableView from) { BoxableDto dto = new BoxableDto(); dto.setId(from.getId().getTargetId()); dto.setAlias(from.getAlias()); dto.setBoxAlias(from.getBoxAlias()); dto.setBoxPosition(BoxUtils.makeLocationLabel(from)); dto.setCoordinates(from.getBoxPosition()); dto.setDiscarded(from.isDiscarded()); dto.setIdentificationBarcode(from.getIdentificationBarcode()); dto.setName(from.getName()); dto.setVolume(from.getVolume()); dto.setEntityType(from.getId().getTargetType()); dto.setSampleClassId(from.getSampleClassId()); return dto; }
dto.setIdentificationBarcode(from.getIdentificationBarcode()); dto.setLocationBarcode(from.getLocationBarcode()); dto.setLocationLabel(BoxUtils.makeLocationLabel(from)); if (from.getBox() != null) { dto.setBox(asDto(from.getBox(), includeBoxPositions));