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);
}
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;
}
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;
}
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;
}
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);
}
Aggregations