Search in sources :

Example 1 with PartitionImpl

use of uk.ac.bbsrc.tgac.miso.core.data.impl.PartitionImpl in project miso-lims by miso-lims.

the class DefaultRunService method updateContainerFromNotification.

private boolean updateContainerFromNotification(final Run target, User user, SequencingContainerModel containerModel, String containerSerialNumber, final GetLaneContents getLaneContents, String positionName) throws IOException {
    if (LimsUtils.isStringBlankOrNull(containerSerialNumber)) {
        return false;
    }
    final Collection<SequencerPartitionContainer> containers = containerService.listByBarcode(containerSerialNumber);
    int laneCount = containerModel.getPartitionCount();
    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())));
    }
    switch(containers.size()) {
        case 0:
            SequencerPartitionContainer newContainer = containerModel.getPlatformType().createContainer();
            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()));
            updatePartitionContents(getLaneContents, newContainer);
            RunPosition newRunPos = new RunPosition();
            newRunPos.setRun(target);
            newRunPos.setContainer(newContainer);
            newRunPos.setPosition(position);
            target.getRunPositions().clear();
            target.getRunPositions().add(newRunPos);
            return true;
        case 1:
            SequencerPartitionContainer container = containers.iterator().next();
            boolean isMutated = false;
            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));
            }
            // only update container model from fallback to non-fallback
            if (container.getModel().isFallback() && !containerModel.isFallback() && container.getModel().getId() != containerModel.getId()) {
                container.setModel(containerModel);
                isMutated = true;
            }
            if (target.getSequencerPartitionContainers().stream().noneMatch(c -> c.getId() == container.getId())) {
                target.addSequencerPartitionContainer(container, position);
                updatePartitionContents(getLaneContents, container);
                isMutated = true;
            }
            return isMutated;
        default:
            throw new IllegalArgumentException("Multiple containers with same identifier: " + containerSerialNumber);
    }
}
Also used : SequencingContainerModel(uk.ac.bbsrc.tgac.miso.core.data.impl.SequencingContainerModel) PaginationFilter(uk.ac.bbsrc.tgac.miso.core.util.PaginationFilter) LoggerFactory(org.slf4j.LoggerFactory) KitDescriptorService(uk.ac.bbsrc.tgac.miso.core.service.KitDescriptorService) Autowired(org.springframework.beans.factory.annotation.Autowired) MisoNamingException(uk.ac.bbsrc.tgac.miso.core.exception.MisoNamingException) RunPartition(uk.ac.bbsrc.tgac.miso.core.data.RunPartition) KitType(uk.ac.bbsrc.tgac.miso.core.data.type.KitType) NotImplementedException(org.apache.commons.lang.NotImplementedException) SequencerPartitionContainer(uk.ac.bbsrc.tgac.miso.core.data.SequencerPartitionContainer) NamingScheme(uk.ac.bbsrc.tgac.miso.core.service.naming.NamingScheme) Note(com.eaglegenomics.simlims.core.Note) JsonNode(com.fasterxml.jackson.databind.JsonNode) RunPartitionAliquotService(uk.ac.bbsrc.tgac.miso.core.service.RunPartitionAliquotService) KitDescriptor(uk.ac.bbsrc.tgac.miso.core.data.impl.kit.KitDescriptor) ValidationException(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationException) ConstraintViolationException(org.hibernate.exception.ConstraintViolationException) Predicate(java.util.function.Predicate) DeletionStore(uk.ac.bbsrc.tgac.miso.core.store.DeletionStore) Partition(uk.ac.bbsrc.tgac.miso.core.data.Partition) Collectors(java.util.stream.Collectors) PartitionImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.PartitionImpl) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) SequencingParametersService(uk.ac.bbsrc.tgac.miso.core.service.SequencingParametersService) InstrumentService(uk.ac.bbsrc.tgac.miso.core.service.InstrumentService) PoolService(uk.ac.bbsrc.tgac.miso.core.service.PoolService) ChangeLogService(uk.ac.bbsrc.tgac.miso.core.service.ChangeLogService) RunService(uk.ac.bbsrc.tgac.miso.core.service.RunService) OxfordNanoporeRun(uk.ac.bbsrc.tgac.miso.core.data.OxfordNanoporeRun) InstrumentModel(uk.ac.bbsrc.tgac.miso.core.data.InstrumentModel) Barcodable(uk.ac.bbsrc.tgac.miso.core.data.Barcodable) IntStream(java.util.stream.IntStream) User(com.eaglegenomics.simlims.core.User) java.util(java.util) AuthorizationManager(uk.ac.bbsrc.tgac.miso.core.security.AuthorizationManager) RunStore(uk.ac.bbsrc.tgac.miso.persistence.RunStore) SequencerPartitionContainerChangeLog(uk.ac.bbsrc.tgac.miso.core.data.impl.changelog.SequencerPartitionContainerChangeLog) HealthType(uk.ac.bbsrc.tgac.miso.core.data.type.HealthType) InstrumentDataManglingPolicy(uk.ac.bbsrc.tgac.miso.core.data.InstrumentDataManglingPolicy) SequencingContainerModelService(uk.ac.bbsrc.tgac.miso.core.service.SequencingContainerModelService) IlluminaRun(uk.ac.bbsrc.tgac.miso.core.data.IlluminaRun) UserService(uk.ac.bbsrc.tgac.miso.core.service.UserService) SolidRun(uk.ac.bbsrc.tgac.miso.core.data.SolidRun) Run(uk.ac.bbsrc.tgac.miso.core.data.Run) Service(org.springframework.stereotype.Service) GetLaneContents(uk.ac.bbsrc.tgac.miso.core.data.GetLaneContents) LimsUtils(uk.ac.bbsrc.tgac.miso.core.util.LimsUtils) RunChangeLog(uk.ac.bbsrc.tgac.miso.core.data.impl.changelog.RunChangeLog) ContainerService(uk.ac.bbsrc.tgac.miso.core.service.ContainerService) NamingSchemeHolder(uk.ac.bbsrc.tgac.miso.core.service.naming.NamingSchemeHolder) RunPartitionService(uk.ac.bbsrc.tgac.miso.core.service.RunPartitionService) ValidationError(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationError) Logger(org.slf4j.Logger) InstrumentPosition(uk.ac.bbsrc.tgac.miso.core.data.InstrumentPosition) LS454Run(uk.ac.bbsrc.tgac.miso.core.data.LS454Run) WhineyFunction(uk.ac.bbsrc.tgac.miso.core.util.WhineyFunction) ExceptionUtils(org.apache.commons.lang.exception.ExceptionUtils) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) SequencingParameters(uk.ac.bbsrc.tgac.miso.core.data.SequencingParameters) AuthorizationException(uk.ac.bbsrc.tgac.miso.core.security.AuthorizationException) Consumer(java.util.function.Consumer) RunPosition(uk.ac.bbsrc.tgac.miso.core.data.impl.RunPosition) FileAttachmentService(uk.ac.bbsrc.tgac.miso.core.service.FileAttachmentService) ValidationUtils(uk.ac.bbsrc.tgac.miso.service.impl.ValidationUtils) PaginatedDataSource(uk.ac.bbsrc.tgac.miso.core.util.PaginatedDataSource) Instrument(uk.ac.bbsrc.tgac.miso.core.data.Instrument) Transactional(org.springframework.transaction.annotation.Transactional) SopService(uk.ac.bbsrc.tgac.miso.core.service.SopService) SequencerPartitionContainer(uk.ac.bbsrc.tgac.miso.core.data.SequencerPartitionContainer) RunPosition(uk.ac.bbsrc.tgac.miso.core.data.impl.RunPosition) PartitionImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.PartitionImpl) InstrumentPosition(uk.ac.bbsrc.tgac.miso.core.data.InstrumentPosition)

Example 2 with PartitionImpl

use of uk.ac.bbsrc.tgac.miso.core.data.impl.PartitionImpl in project miso-lims by miso-lims.

the class Dtos method to.

public static RunPartitionAliquot to(@Nonnull RunPartitionAliquotDto from) {
    RunPartitionAliquot to = new RunPartitionAliquot();
    PlatformType platform = PlatformType.valueOf(from.getPlatformType());
    setObject(to::setRun, platform::createRun, from.getRunId());
    setObject(to::setPartition, PartitionImpl::new, from.getPartitionId());
    setObject(to::setAliquot, LibraryAliquot::new, from.getAliquotId());
    setObject(to::setPurpose, RunPurpose::new, from.getRunPurposeId());
    setObject(to::setQcStatus, RunLibraryQcStatus::new, from.getQcStatusId());
    setString(to::setQcNote, from.getQcNote());
    setBoolean(to::setDataReview, from.getDataReview(), true);
    return to;
}
Also used : RunPurpose(uk.ac.bbsrc.tgac.miso.core.data.impl.RunPurpose) RunPartitionAliquot(uk.ac.bbsrc.tgac.miso.core.data.RunPartitionAliquot) PartitionImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.PartitionImpl) IonTorrentRunDto(uk.ac.bbsrc.tgac.miso.dto.run.IonTorrentRunDto) QcHierarchyNodeDto(uk.ac.bbsrc.tgac.miso.dto.dashi.QcHierarchyNodeDto) RunPositionDto(uk.ac.bbsrc.tgac.miso.dto.run.RunPositionDto) PacBioRunDto(uk.ac.bbsrc.tgac.miso.dto.run.PacBioRunDto) Ls454RunDto(uk.ac.bbsrc.tgac.miso.dto.run.Ls454RunDto) IlluminaNotificationDto(ca.on.oicr.gsi.runscanner.dto.IlluminaNotificationDto) OxfordNanoporeRunDto(uk.ac.bbsrc.tgac.miso.dto.run.OxfordNanoporeRunDto) IlluminaRunDto(uk.ac.bbsrc.tgac.miso.dto.run.IlluminaRunDto) NotificationDto(ca.on.oicr.gsi.runscanner.dto.NotificationDto) OxfordNanoporeNotificationDto(ca.on.oicr.gsi.runscanner.dto.OxfordNanoporeNotificationDto) RunDto(uk.ac.bbsrc.tgac.miso.dto.run.RunDto) SolidRunDto(uk.ac.bbsrc.tgac.miso.dto.run.SolidRunDto) OrderAliquotDto(uk.ac.bbsrc.tgac.miso.dto.PoolOrderDto.OrderAliquotDto) TransferLibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferLibraryAliquot) WorksetLibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.workset.WorksetLibraryAliquot) OrderLibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.OrderLibraryAliquot) DetailedLibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.DetailedLibraryAliquot) LibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryAliquot) PlatformType(uk.ac.bbsrc.tgac.miso.core.data.type.PlatformType) RunLibraryQcStatus(uk.ac.bbsrc.tgac.miso.core.data.RunLibraryQcStatus)

Example 3 with PartitionImpl

use of uk.ac.bbsrc.tgac.miso.core.data.impl.PartitionImpl in project miso-lims by miso-lims.

the class Dtos method to.

public static Partition to(@Nonnull PartitionDto dto) {
    Partition to = new PartitionImpl();
    to.setId(dto.getId());
    return to;
}
Also used : RunPartition(uk.ac.bbsrc.tgac.miso.core.data.Experiment.RunPartition) Partition(uk.ac.bbsrc.tgac.miso.core.data.Partition) PartitionImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.PartitionImpl)

Example 4 with PartitionImpl

use of uk.ac.bbsrc.tgac.miso.core.data.impl.PartitionImpl in project miso-lims by miso-lims.

the class EditSequencerPartitionContainerController method setupNewForm.

@GetMapping(value = "/new/{modelId}")
public ModelAndView setupNewForm(@PathVariable("modelId") Long modelId, ModelMap model) throws IOException {
    SequencingContainerModel containerModel = containerModelService.get(modelId);
    if (containerModel == null)
        throw new NotFoundException("No container model found for ID " + modelId.toString());
    SequencerPartitionContainer container = containerModel.getPlatformType().createContainer();
    container.setModel(containerModel);
    model.put("title", "New " + containerModel.getPlatformType().getContainerName());
    container.setPartitions(IntStream.range(0, containerModel.getPartitionCount()).mapToObj(number -> new PartitionImpl(container, number + 1)).collect(Collectors.toList()));
    return setupForm(container, model);
}
Also used : SequencerPartitionContainer(uk.ac.bbsrc.tgac.miso.core.data.SequencerPartitionContainer) SequencingContainerModel(uk.ac.bbsrc.tgac.miso.core.data.impl.SequencingContainerModel) NotFoundException(org.springframework.security.acls.model.NotFoundException) PartitionImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.PartitionImpl) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

PartitionImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.PartitionImpl)4 Partition (uk.ac.bbsrc.tgac.miso.core.data.Partition)2 SequencerPartitionContainer (uk.ac.bbsrc.tgac.miso.core.data.SequencerPartitionContainer)2 IlluminaNotificationDto (ca.on.oicr.gsi.runscanner.dto.IlluminaNotificationDto)1 NotificationDto (ca.on.oicr.gsi.runscanner.dto.NotificationDto)1 OxfordNanoporeNotificationDto (ca.on.oicr.gsi.runscanner.dto.OxfordNanoporeNotificationDto)1 Note (com.eaglegenomics.simlims.core.Note)1 User (com.eaglegenomics.simlims.core.User)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 IOException (java.io.IOException)1 java.util (java.util)1 Consumer (java.util.function.Consumer)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1 NotImplementedException (org.apache.commons.lang.NotImplementedException)1 ExceptionUtils (org.apache.commons.lang.exception.ExceptionUtils)1