private InstrumentPosition findPosition(long id, Instrument instrument) { return instrument.getInstrumentModel().getPositions().stream() .filter(p -> p.getId() == id) .findFirst().orElse(null); }
public boolean isFull() { return getRunPositions().size() >= sequencer.getInstrumentModel().getNumContainers(); }
@Override protected void makeColumns(Run run, Partition partition, PoolableElementView dilution, String userName, String[] output) { output[0] = dilution.getLibraryName(); output[1] = dilution.getLibraryAlias(); final Optional<Index> firstIndex = dilution.getIndices().stream().filter(i -> i.getPosition() == 1).findFirst(); output[2] = firstIndex.map(Index::getName).orElse(""); output[3] = firstIndex.map(Index::getSequence).orElse(""); final Optional<Index> secondIndex = dilution.getIndices().stream().filter(i -> i.getPosition() == 2).findFirst(); output[4] = secondIndex.map(Index::getName).orElse(""); output[5] = secondIndex.map(Index::getSequence) .map(run.getSequencer().getInstrumentModel().getDataManglingPolicy() == InstrumentDataManglingPolicy.I5_RC ? SampleSheet::reverseComplement : Function.identity()) .orElse(""); }
private boolean updateSequencingParameters(final Run target, User user, Predicate<SequencingParameters> filterParameters, final Instrument sequencer) throws IOException { // If the sequencing parameters haven't been updated by a human, see if we can find exactly one that matches. if (!target.didSomeoneElseChangeColumn("parameters", user)) { List<SequencingParameters> possibleParameters = sequencingParametersService.getForInstrumentModel(sequencer.getInstrumentModel().getId()).stream() .filter(parameters -> !parameters.getName().startsWith("Custom")).filter(filterParameters).collect(Collectors.toList()); if (possibleParameters.size() == 1) { if (target.getSequencingParameters() == null || possibleParameters.get(0).getId() != target.getSequencingParameters().getId()) { target.setSequencingParameters(possibleParameters.get(0)); return true; } } } return false; }
@Override protected void makeColumns(Run run, Partition p, PoolableElementView dilution, String userName, String[] output) { output[0] = p.getSequencerPartitionContainer().getIdentificationBarcode(); output[1] = p.getPartitionNumber().toString(); output[2] = String.format("%d_%s_%s", p.getSequencerPartitionContainer().getId(), dilution.getLibraryName(), dilution.getDilutionName()); output[3] = dilution.getSampleAlias().replaceAll("\\s", ""); output[4] = dilution.getIndices().stream()// .sorted(Comparator.comparingInt(Index::getPosition))// .map(i -> { if (run.getSequencer().getInstrumentModel().getDataManglingPolicy() == InstrumentDataManglingPolicy.I5_RC && i.getPosition() == 2) { return reverseComplement(i.getSequence()); } return i.getSequence(); })// .collect(Collectors.joining("-")); output[5] = dilution.getLibraryDescription(); output[6] = "N"; output[7] = "NA"; output[8] = userName; }
InstrumentPosition position = null; if (!isStringEmptyOrNull(positionName)) { position = target.getSequencer().getInstrumentModel().getPositions().stream() .filter(pos -> positionName.equals(pos.getAlias())) .findFirst().orElseThrow(() -> new IllegalArgumentException(String.format("Unknown position '%s' for platform '%s'", positionName, target.getSequencer().getInstrumentModel().getAlias())));
private List<InstrumentStatus> map(List<InstrumentPositionStatus> positions) { Map<Long, InstrumentStatus> statusByInstrumentId = new HashMap<>(); for (InstrumentPositionStatus position : positions) { if (!statusByInstrumentId.containsKey(position.getInstrument().getId())) { InstrumentStatus status = new InstrumentStatus(); status.setInstrument(position.getInstrument()); statusByInstrumentId.put(position.getInstrument().getId(), status); } InstrumentStatus existing = statusByInstrumentId.get(position.getInstrument().getId()); if (position.getPosition() == null) { InstrumentPosition nullPosition = new InstrumentPosition(); nullPosition.setAlias("n/a"); nullPosition.setInstrumentModel(position.getInstrument().getInstrumentModel()); position.setPosition(nullPosition); } if (existing.getPositions().containsKey(position.getPosition())) { // there are likely multiple runs with the same start date Run moreRecent = getMoreRecentRun(existing.getPositions().get(position.getPosition()), position.getRun()); existing.getPositions().put(position.getPosition(), moreRecent); } else { existing.getPositions().put(position.getPosition(), position.getRun()); } } return new ArrayList<>(statusByInstrumentId.values()); }
} else if (arrayRun.getInstrument().getInstrumentModel().getInstrumentType() != InstrumentType.ARRAY_SCANNER) { errors.add(new ValidationError("instrument", "Instrument must be an array scanner"));
private void validateChanges(Run before, Run changed) throws IOException { List<ValidationError> errors = new ArrayList<>(); if (!changed.getHealth().isDone()) { changed.setCompletionDate(null); } else if (changed.getCompletionDate() == null) { errors.add(new ValidationError("completionDate", "Completion date must be provided for finished run")); } if (before != null) { if (before.getCompletionDate() != null && changed.getCompletionDate() != null && !changed.getCompletionDate().equals(before.getCompletionDate()) && !authorizationManager.isAdminUser()) { errors.add(new ValidationError("completionDate", "Only admin may change completion date")); } if (before.getStartDate() != null && changed.getStartDate() != null && !changed.getStartDate().equals(before.getStartDate()) && !authorizationManager.isAdminUser()) { errors.add(new ValidationError("completionDate", "Only admin may change start date")); } } InstrumentModel platform = changed.getSequencer().getInstrumentModel(); for (RunPosition position : changed.getRunPositions()) { if (position.getPosition() != null && !platform.getPositions().contains(position.getPosition())) { errors.add(new ValidationError( String.format("Platform %s does not have a position %s", platform.getAlias(), position.getPosition()))); } } if (!errors.isEmpty()) { throw new ValidationException(errors); } }
private void applyChanges(Instrument target, Instrument source) { target.setInstrumentModel(source.getInstrumentModel()); target.setName(source.getName()); target.setSerialNumber(source.getSerialNumber()); target.setDateCommissioned(source.getDateCommissioned()); target.setDateDecommissioned(source.getDateDecommissioned()); target.setUpgradedInstrument(source.getUpgradedInstrument()); }
public static InstrumentDto asDto(@Nonnull Instrument from) { InstrumentDto dto = new InstrumentDto(); dto.setId(from.getId()); dto.setDateCommissioned(formatDate(from.getDateCommissioned())); dto.setDateDecommissioned(formatDate(from.getDateDecommissioned())); dto.setName(from.getName()); dto.setInstrumentModel(asDto(from.getInstrumentModel())); dto.setSerialNumber(from.getSerialNumber()); if (from.getDateDecommissioned() == null) { if (from.isOutOfService()) { dto.setStatus("Out of Service"); } else { dto.setStatus("Production"); } } else if (from.getUpgradedInstrument() != null) { dto.setStatus("Upgraded"); } else { dto.setStatus("Retired"); } return dto; }
SequencingContainerModel model = containerModelService.find(sequencer.getInstrumentModel(), containerModel, laneCount); if (model == null) { throw new IllegalArgumentException(
dto.setPlatformType(from.getSequencer().getInstrumentModel().getPlatformType().getKey()); } else { dto.setPlatformType("");