@Override public boolean equals(Object obj) { if (obj == null) return false; if (obj == this) return true; if (!(obj instanceof SequencerPartitionContainer)) return false; SequencerPartitionContainer them = (SequencerPartitionContainer) obj; // If not saved, then compare resolved actual objects. Otherwise just compare IDs. if (getId() == SequencerPartitionContainerImpl.UNSAVED_ID || them.getId() == SequencerPartitionContainerImpl.UNSAVED_ID) { return getIdentificationBarcode().equals(them.getIdentificationBarcode()); } else { return getId() == them.getId(); } }
@Override public void applyChanges(SequencerPartitionContainer source, SequencerPartitionContainer managed) throws IOException { managed.setIdentificationBarcode(source.getIdentificationBarcode()); managed.setDescription(source.getDescription()); managed.setClusteringKit(source.getClusteringKit()); managed.setMultiplexingKit(source.getMultiplexingKit()); if (LimsUtils.isOxfordNanoporeContainer(managed)) { applyOxfordNanoporeChanges((OxfordNanoporeContainer) source, (OxfordNanoporeContainer) managed); } for (Partition sourcePartition : source.getPartitions()) { for (Partition managedPartition : managed.getPartitions()) { if (sourcePartition == null || managedPartition == null) { throw new IOException("Partition from " + (sourcePartition == null ? "client" : "database") + " is null."); } if (sourcePartition.getId() == managedPartition.getId()) { Pool sourcePool = sourcePartition.getPool(); Pool managedPool = managedPartition.getPool(); if (sourcePool == null) { managedPartition.setPool(null); } else if (managedPool == null || sourcePool.getId() != managedPool.getId()) { managedPartition.setPool(poolService.get(sourcePool.getId())); } break; } } } }
@Override public void setId(Long id) { sequencerPartitionContainer.setId(id); }
@Override public ValidationResult validateDeletion(SequencerPartitionContainer object) { ValidationResult result = new ValidationResult(); if (object.getRunPositions() != null && !object.getRunPositions().isEmpty()) { result.addError(new ValidationError(String.format("Container %s (%s) is used in %d run(s)", object.getId(), object.getIdentificationBarcode(), object.getRunPositions().size()))); } return result; } }
public static ContainerDto asDto(@Nonnull SequencerPartitionContainer from, boolean includePartitions, boolean includePoolContents) { ContainerDto dto = new ContainerDto(); dto.setId(from.getId()); dto.setIdentificationBarcode(from.getIdentificationBarcode()); dto.setModel(asDto(from.getModel())); Run lastRun = from.getLastRun(); if (lastRun != null) { dto.setLastRunAlias(lastRun.getAlias()); dto.setLastRunId(lastRun.getId()); dto.setLastSequencerId(lastRun.getSequencer().getId()); dto.setLastSequencerName(lastRun.getSequencer().getName()); } if (from.getLastModified() != null) { dto.setLastModified(formatDateTime(from.getLastModified())); } if (from.getClusteringKit() != null) { dto.setClusteringKit(asDto(from.getClusteringKit())); } if (from.getMultiplexingKit() != null) { dto.setMultiplexingKit(asDto(from.getMultiplexingKit())); } if (includePartitions) { dto.setPartitions(asPartitionDtos(from.getPartitions(), includePoolContents)); } return dto; }
case 0: SequencerPartitionContainer newContainer = new SequencerPartitionContainerImpl(user); newContainer.setModel(containerModel); newContainer.setCreator(user); newContainer.setIdentificationBarcode(containerSerialNumber); newContainer.setPartitionLimit(laneCount); newContainer.setPartitions(IntStream.range(0, laneCount) .mapToObj(i -> new PartitionImpl(newContainer, i + 1)) .collect(Collectors.toList())); case 1: SequencerPartitionContainer container = containers.iterator().next(); if (container.getPartitions().size() != laneCount) { throw new IllegalArgumentException(String.format("The container %s has %d partitions, but %d were detected by the scanner.", containerSerialNumber, container.getPartitions().size(), laneCount)); if (target.getSequencerPartitionContainers().stream().noneMatch(c -> c.getId() == container.getId())) { target.addSequencerPartitionContainer(container, position); updatePartitionContents(getLaneContents, container);
container.setModel(containerModelService.get(container.getModel().getId())); if (container.getClusteringKit() != null) { KitDescriptor descriptor = kitService.getKitDescriptorById(container.getClusteringKit().getId()); if (descriptor.getKitType() != KitType.CLUSTERING) { throw new IllegalArgumentException(descriptor.getName() + " is not a clustering kit."); container.setClusteringKit(descriptor); if (container.getMultiplexingKit() != null) { KitDescriptor descriptor = kitService.getKitDescriptorById(container.getMultiplexingKit().getId()); if (descriptor.getKitType() != KitType.MULTIPLEXING) { throw new IllegalArgumentException(descriptor.getName() + " is not a multiplexing kit."); container.setMultiplexingKit(descriptor);
@Override public void execute(WorkflowExecutor workflowExecutor) throws IOException { if (!isComplete()) throw new IllegalStateException("Workflow is not complete"); SequencerPartitionContainer spc; if (containerStep.isExistingContainer()) { spc = containerStep.getContainer(); } else { spc = new SequencerPartitionContainerImpl(); SequencingContainerModel model = containerModelStep.getModel(); spc.setModel(model); spc.setIdentificationBarcode(containerStep.getBarcode()); spc.setPartitionLimit(model.getPartitionCount()); } for (int i = 0; i < partitionSteps.size(); ++i) { spc.getPartitionAt(i + 1).setPool(partitionSteps.get(i).getPool()); } workflowExecutor.save(spc); }
@Override public Long getId() { return sequencerPartitionContainer.getId(); }
private String getContainerName() { if (containerStep == null) { return "Sequencing Container"; } else { return containerStep.getInput().getModel().getPlatformType().getContainerName(); } }
@Override public SequencerPartitionContainer update(SequencerPartitionContainer container) throws IOException { SequencerPartitionContainer managed = get(container.getId()); authorizationManager.throwIfNotWritable(managed); applyChanges(container, managed); managed.setChangeDetails(authorizationManager.getCurrentUser()); loadChildEntities(managed); return containerDao.save(managed); }
public String createSampleSheet(Run run, User user) { final List<String> columns = getColumns().collect(Collectors.toList()); return header(run) + Stream.concat(// Stream.of(String.join(",", columns)), // run.getSequencerPartitionContainers().stream()// .flatMap(container -> container.getPartitions().stream())// .filter(partition -> partition.getPool() != null)// .flatMap(partition -> createRowsForPartition(run, user, columns, partition))) .collect(Collectors.joining("\n")); }
public String getBarcode() { return containerStep == null ? stringStep.getInput() : containerStep.getInput().getIdentificationBarcode(); } }
@Override protected void populate(Element xml, Pair<PoolableElementView, Partition> entry) { Run r = entry.getValue().getSequencerPartitionContainer().getLastRun(); xml.setAttribute("alias", "L00" + entry.getValue().getPartitionNumber() + ":" + entry.getKey().getDilutionName() + ":" + r.getAlias()); xml.setAttribute("run_center", centreName); if (r.getHealth() == HealthType.Completed) { xml.setAttribute("run_date", DF_TIMESTAMP.format(r.getCompletionDate())); } xml.setAttribute("center_name", centreName); for (Experiment e : submission.getExperiments()) { Element experimentRef = xml.getOwnerDocument().createElementNS(null, "EXPERIMENT_REF"); experimentRef.setAttribute("refname", e.getAlias()); experimentRef.setAttribute("refcenter", centreName); xml.appendChild(experimentRef); } Element dataBlock = xml.getOwnerDocument().createElementNS(null, "DATA_BLOCK"); dataBlock.setAttribute("sector", Integer.toString(entry.getValue().getPartitionNumber())); if (entry.getValue().getPool().getPoolDilutions().size() > 1) { // multiplexed dataBlock.setAttribute("member_name", entry.getKey().getDilutionName()); } }
@Override public List<String> processInput(int stepNumber, ProgressStep step) { if (stepNumber == 0) { step.accept(containerStep); containerModelStep.cancelInput(); for (PartitionStep partitionStep : partitionSteps) { partitionStep.cancelInput(); } if (containerStep.isExistingContainer()) { resetPartitionSteps(containerStep.getContainer().getModel()); } } else if (stepNumber == 1) { if (containerStep.isExistingContainer()) { step.accept(partitionSteps.get(0)); } else { step.accept(containerModelStep); resetPartitionSteps(containerModelStep.getModel()); } } else { int partitionIndex = asPartitionIndex(stepNumber); step.accept(partitionSteps.get(partitionIndex)); } return Collections.emptyList(); }
private void updatePartitionContents(final GetLaneContents getLaneContents, SequencerPartitionContainer newContainer) { newContainer.getPartitions().stream().filter(partition -> partition.getPool() == null) .forEach(partition -> getLaneContents.getLaneContents(partition.getPartitionNumber()).filter(s -> !LimsUtils.isStringBlankOrNull(s)) .map(WhineyFunction.rethrow(poolService::getByBarcode)).ifPresent(partition::setPool)); }
@Override public String getConfirmMessage() { List<Pool> poolsScanned = partitionSteps.stream().map(PartitionStep::getPool).filter(Objects::nonNull).collect(Collectors.toList()); if (poolsScanned.isEmpty()) { if (containerStep.isExistingContainer()) { return String.format("Remove all pools from %s '%s'?", getContainerName(), containerStep.getContainer().getIdentificationBarcode()); } else { return String.format("Create empty %s '%s'?", getContainerName(), containerStep.getBarcode()); } } else { if (containerStep.isExistingContainer()) { return String.format("Add pools to existing %s '%s'?", getContainerName(), containerStep.getContainer().getIdentificationBarcode()); } else { return String.format("Create %s '%s'?", getContainerName(), containerStep.getBarcode()); } } }
@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; }
@Override public SequencerPartitionContainer save(SequencerPartitionContainer container) throws IOException { if (container.getId() == SequencerPartitionContainerImpl.UNSAVED_ID) { return create(container); } else { return update(container); } }