Search in sources :

Example 1 with PoolElement

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

the class PoolImplTest method addElement.

private void addElement(PoolImpl pool, Index index1, Index index2) {
    ListLibraryAliquotView ldi = new ListLibraryAliquotView();
    ldi.setParentLibrary(new ParentLibrary());
    ldi.getParentLibrary().setIndex1(index1);
    ldi.getParentLibrary().setIndex2(index2);
    PoolElement element = new PoolElement(pool, ldi);
    pool.getPoolContents().add(element);
}
Also used : ParentLibrary(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentLibrary) ListLibraryAliquotView(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ListLibraryAliquotView) PoolElement(uk.ac.bbsrc.tgac.miso.core.data.impl.view.PoolElement)

Example 2 with PoolElement

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

the class DefaultPoolService method getMismatchesWithOrders.

private List<ValidationError> getMismatchesWithOrders(Pool pool, List<PoolOrder> poolOrders) throws IOException {
    Set<Long> poolAliquotIds = new HashSet<>();
    List<ValidationError> errors = new LinkedList<>();
    for (PoolElement pe : pool.getPoolContents()) {
        poolAliquotIds.add(pe.getAliquot().getId());
        for (ParentAliquot parent = pe.getAliquot().getParentAliquot(); parent != null; parent = parent.getParentAliquot()) {
            poolAliquotIds.add(parent.getId());
        }
    }
    for (PoolOrder order : poolOrders) {
        for (OrderLibraryAliquot orderAliquot : order.getOrderLibraryAliquots()) {
            if (!poolAliquotIds.contains(orderAliquot.getAliquot().getId())) {
                String errorMessage = String.format("Pool must contain library aliquot '%s', as specified by pool order '%s'", orderAliquot.getAliquot().getAlias(), order.getAlias());
                errors.add(new ValidationError("poolElements", errorMessage));
            }
        }
    }
    return errors;
}
Also used : PoolOrder(uk.ac.bbsrc.tgac.miso.core.data.impl.PoolOrder) OrderLibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.OrderLibraryAliquot) PoolElement(uk.ac.bbsrc.tgac.miso.core.data.impl.view.PoolElement) ValidationError(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationError) ParentAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentAliquot) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet)

Example 3 with PoolElement

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

the class Dtos method asDto.

public static PoolDto asDto(@Nonnull Pool from, boolean includeContents, boolean includeBoxPositions, IndexChecker indexChecker) {
    PoolDto dto = new PoolDto();
    dto.setId(from.getId());
    dto.setName(from.getName());
    dto.setAlias(from.getAlias());
    dto.setDescription(from.getDescription());
    setString(dto::setConcentration, from.getConcentration());
    setInteger(dto::setDnaSize, from.getDnaSize(), true);
    dto.setConcentrationUnits(from.getConcentrationUnits());
    dto.setQcPassed(from.getQcPassed());
    dto.setCreationDate(formatDate(from.getCreationDate()));
    setString(dto::setVolume, from.getVolume());
    dto.setVolumeUnits(from.getVolumeUnits());
    if (from.getPlatformType() != null) {
        dto.setPlatformType(from.getPlatformType().name());
    }
    dto.setLongestIndex(from.getLongestIndex());
    dto.setLastModified(formatDateTime(from.getLastModified()));
    dto.setLibraryAliquotCount(from.getPoolContents().size());
    if (includeContents) {
        Set<LibraryAliquotDto> pooledElements = new HashSet<>();
        for (PoolElement element : from.getPoolContents()) {
            LibraryAliquotDto ldi = asDto(element.getAliquot());
            ldi.setProportion(element.getProportion());
            pooledElements.add(ldi);
        }
        dto.setPooledElements(pooledElements);
        if (indexChecker != null) {
            dto.setDuplicateIndicesSequences(indexChecker.getDuplicateIndicesSequences(from));
            dto.setDuplicateIndices(dto.getDuplicateIndicesSequences() != null && !dto.getDuplicateIndicesSequences().isEmpty());
            dto.setNearDuplicateIndicesSequences(indexChecker.getNearDuplicateIndicesSequences(from));
            dto.setNearDuplicateIndices(dto.getNearDuplicateIndicesSequences() != null && !dto.getNearDuplicateIndicesSequences().isEmpty());
        }
    } else {
        dto.setPooledElements(Collections.emptySet());
        if (indexChecker != null) {
            dto.setDuplicateIndices(indexChecker.getDuplicateIndicesSequences(from) != null && !indexChecker.getDuplicateIndicesSequences(from).isEmpty());
            dto.setNearDuplicateIndices(indexChecker.getNearDuplicateIndicesSequences(from) != null && !indexChecker.getNearDuplicateIndicesSequences(from).isEmpty());
        }
    }
    dto.setHasEmptySequence(from.hasLibrariesWithoutIndex());
    dto.setIdentificationBarcode(from.getIdentificationBarcode());
    dto.setLocationLabel(BoxUtils.makeLocationLabel(from));
    if (from.getBox() != null) {
        dto.setBox(asDto(from.getBox(), includeBoxPositions));
        dto.setBoxPosition(from.getBoxPosition());
    }
    dto.setDiscarded(from.isDiscarded());
    dto.setHasLowQualityLibraries(from.getHasLowQualityMembers());
    dto.setPrioritySubprojectAliases(from.getPrioritySubprojectAliases());
    return dto;
}
Also used : PoolElement(uk.ac.bbsrc.tgac.miso.core.data.impl.view.PoolElement) HashSet(java.util.HashSet)

Example 4 with PoolElement

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

the class Dtos method to.

public static Pool to(@Nonnull PoolDto dto) {
    PoolImpl to = new PoolImpl();
    setLong(to::setId, dto.getId(), false);
    to.setAlias(dto.getAlias());
    setBigDecimal(to::setConcentration, dto.getConcentration());
    to.setConcentrationUnits(dto.getConcentrationUnits());
    setInteger(to::setDnaSize, dto.getDnaSize(), true);
    to.setCreationDate(parseDate(dto.getCreationDate()));
    to.setDescription(dto.getDescription());
    to.setIdentificationBarcode(dto.getIdentificationBarcode());
    to.setDiscarded(dto.isDiscarded());
    setBigDecimal(to::setVolume, dto.getVolume());
    to.setVolumeUnits(dto.getVolumeUnits());
    setObject(to::setPlatformType, dto.getPlatformType(), pt -> PlatformType.valueOf(pt));
    if (dto.getPooledElements() != null) {
        to.setPoolElements(dto.getPooledElements().stream().map(aliquot -> {
            ListLibraryAliquotView view = new ListLibraryAliquotView();
            view.setId(aliquot.getId());
            view.setName(aliquot.getName());
            setBigDecimal(view::setVolumeUsed, aliquot.getVolumeUsed());
            PoolElement link = new PoolElement(to, view);
            if (aliquot.getProportion() != null) {
                link.setProportion(aliquot.getProportion());
            }
            return link;
        }).collect(Collectors.toSet()));
    }
    to.setQcPassed(dto.getQcPassed());
    to.setBoxPosition((PoolBoxPosition) makeBoxablePosition(dto, to));
    if (dto.isMergeChild())
        to.makeMergeChild();
    return to;
}
Also used : ListLibraryAliquotView(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ListLibraryAliquotView) PoolElement(uk.ac.bbsrc.tgac.miso.core.data.impl.view.PoolElement) 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) PoolImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.PoolImpl)

Example 5 with PoolElement

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

the class RunRestController method getSpreadsheet.

@PostMapping(value = "/spreadsheet")
@ResponseBody
public HttpEntity<byte[]> getSpreadsheet(@RequestBody SpreadsheetRequest request, HttpServletResponse response, UriComponentsBuilder uriBuilder) throws IOException {
    // Note: not retrieving persisted run-libraries, so QC data will be missing
    List<Run> runs = runService.listByIdList(request.getIds());
    List<RunPartitionAliquot> runLibraries = new ArrayList<>();
    for (Run run : runs) {
        for (RunPosition runPosition : run.getRunPositions()) {
            for (Partition partition : runPosition.getContainer().getPartitions()) {
                if (partition.getPool() != null) {
                    for (PoolElement element : partition.getPool().getPoolContents()) {
                        LibraryAliquot aliquot = libraryAliquotService.get(element.getAliquot().getId());
                        runLibraries.add(new RunPartitionAliquot(run, partition, aliquot));
                    }
                }
            }
        }
    }
    return MisoWebUtils.generateSpreadsheet(request, runLibraries.stream(), detailedSample, RunLibrarySpreadsheets::valueOf, response);
}
Also used : RunPartition(uk.ac.bbsrc.tgac.miso.core.data.RunPartition) Partition(uk.ac.bbsrc.tgac.miso.core.data.Partition) RunLibrarySpreadsheets(uk.ac.bbsrc.tgac.miso.core.data.spreadsheet.RunLibrarySpreadsheets) RunPosition(uk.ac.bbsrc.tgac.miso.core.data.impl.RunPosition) PoolElement(uk.ac.bbsrc.tgac.miso.core.data.impl.view.PoolElement) RunPartitionAliquot(uk.ac.bbsrc.tgac.miso.core.data.RunPartitionAliquot) ArrayList(java.util.ArrayList) Run(uk.ac.bbsrc.tgac.miso.core.data.Run) LibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryAliquot) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

PoolElement (uk.ac.bbsrc.tgac.miso.core.data.impl.view.PoolElement)13 ListLibraryAliquotView (uk.ac.bbsrc.tgac.miso.core.data.impl.view.ListLibraryAliquotView)5 Pool (uk.ac.bbsrc.tgac.miso.core.data.Pool)4 HashSet (java.util.HashSet)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 Service (org.springframework.stereotype.Service)2 Transactional (org.springframework.transaction.annotation.Transactional)2 PutMapping (org.springframework.web.bind.annotation.PutMapping)2 Partition (uk.ac.bbsrc.tgac.miso.core.data.Partition)2 Run (uk.ac.bbsrc.tgac.miso.core.data.Run)2 RunPartition (uk.ac.bbsrc.tgac.miso.core.data.RunPartition)2 RunPartitionAliquot (uk.ac.bbsrc.tgac.miso.core.data.RunPartitionAliquot)2 LibraryAliquot (uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryAliquot)2 OrderLibraryAliquot (uk.ac.bbsrc.tgac.miso.core.data.impl.OrderLibraryAliquot)2 PoolOrder (uk.ac.bbsrc.tgac.miso.core.data.impl.PoolOrder)2 RunPosition (uk.ac.bbsrc.tgac.miso.core.data.impl.RunPosition)2