Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public enum ReleaseColumn implements TsvColumn<ReleaseEntry> {
Tissue_coverage(ReleaseEntry::getCoverage, ReleaseFileOption.Visium),
Permeabilisation_time(ReleaseEntry::getPermTime, ReleaseFileOption.Visium),
Cq_value(ReleaseEntry::getCq, ReleaseFileOption.Visium),
qPCR_comment(ReleaseEntry::getQpcrComment, ReleaseFileOption.Visium),
Number_of_amplification_cycles(ReleaseEntry::getAmplificationCycles, ReleaseFileOption.Visium),
Visium_concentration(ReleaseEntry::getVisiumConcentration, ReleaseFileOption.Visium),
Visium_concentration_type(ReleaseEntry::getVisiumConcentrationType, ReleaseFileOption.Visium),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class ReleaseEntry {
private String reagentPlateType;
private String reagentSource;
private String cq;
private String qpcrComment;
private String visiumConcentration;
private String visiumConcentrationType;
private String sizeRange;
Expand Down Expand Up @@ -186,6 +187,14 @@ public void setCq(String cq) {
this.cq = cq;
}

public String getQpcrComment() {
return this.qpcrComment;
}

public void setQpcrComment(String qpcrComment) {
this.qpcrComment = qpcrComment;
}

public String getVisiumConcentration() {
return this.visiumConcentration;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public ReleaseFileContent getReleaseFileContent(Collection<Integer> releaseIds,
if (options.contains(ReleaseFileOption.Visium)) {
loadVisiumBarcodes(entries, ancestry);
loadSizeRanges(entries, slotIds);
loadQpcrComments(entries, ancestry);
}
if (options.contains(ReleaseFileOption.Histology)) {
loadRnaAnalysis(entries, slotIds);
Expand Down Expand Up @@ -984,6 +985,33 @@ public void loadImagingQcComments(Collection<ReleaseEntry> entries, Ancestry anc
}
}


/** Loads comments from qpcr operations */
public void loadQpcrComments(Collection<ReleaseEntry> entries, Ancestry ancestry) {
OperationType qpcrOpType = opTypeRepo.getByName("qPCR results");
Set<Integer> allSlotIds = ancestry.keySet().stream().map(SlotSample::slotId).collect(toSet());
List<Operation> ops = opRepo.findAllByOperationTypeAndDestinationSlotIdIn(qpcrOpType, allSlotIds);
if (ops.isEmpty()) {
return;
}
List<OperationComment> opcoms = opComRepo.findAllByOperationIdIn(ops.stream().map(Operation::getId).collect(toList()));
Map<SlotIdSampleId, List<OperationComment>> slotIdComs = opcoms.stream()
.collect(groupingBy(oc -> new SlotIdSampleId(oc.getSlotId(), oc.getSampleId())));
for (ReleaseEntry entry : entries) {
SlotSample key = new SlotSample(entry.getSlot(), entry.getSample());
Set<OperationComment> entryOcs = new HashSet<>();
for (SlotSample ss : ancestry.ancestors(key)) {
List<OperationComment> ocs = slotIdComs.get(new SlotIdSampleId(ss.slotId(), ss.sampleId()));
if (!nullOrEmpty(ocs)) {
entryOcs.addAll(ocs);
}
}
if (!nullOrEmpty(entryOcs)) {
entry.setQpcrComment(joinComments(entryOcs.stream()));
}
}
}

/**
* Sets various measurements for the release entries.
* The measurements may be recorded on the specified slot, or any ancestral slot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public class TestReleaseMutation {
@Transactional
public void testRelease() throws Exception {
Stream.of("Probe hybridisation Xenium", "Probe hybridisation QC", "Xenium analyser",
"Xenium analyser QC", "DV200 analysis", "RIN analysis", "Paraffin processing")
"Xenium analyser QC", "DV200 analysis", "RIN analysis", "Paraffin processing", "qPCR results")
.forEach(name -> entityCreator.createOpType(name, null, OperationTypeFlag.IN_PLACE));
Work work1 = entityCreator.createWork(null, null, null, null, null);
Donor donor = entityCreator.createDonor("DONOR1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ public void testGetReleaseFileContent(StorageDetail detail, boolean includeVisiu
doNothing().when(service).loadSectionComments(any());
doNothing().when(service).loadVisiumBarcodes(any(), any());
doNothing().when(service).loadSizeRanges(any(), any());
doNothing().when(service).loadQpcrComments(any(), any());
doNothing().when(service).loadXeniumFields(any(), any());
doNothing().when(service).loadSolutions(any());
doNothing().when(service).loadFlags(any());
Expand Down Expand Up @@ -227,6 +228,7 @@ public void testGetReleaseFileContent(StorageDetail detail, boolean includeVisiu
verify(service).loadSectionComments(entries);
verify(service, times(includeVisium ? 1 : 0)).loadVisiumBarcodes(entries, ancestry);
verify(service, times(includeVisium ? 1 : 0)).loadSizeRanges(entries, slotIds);
verify(service, times(includeVisium ? 1 : 0)).loadQpcrComments(entries, ancestry);
verify(service).loadXeniumFields(entries, slotIds);
verify(service).loadSolutions(entries);
verify(service).loadFlags(entries);
Expand Down Expand Up @@ -814,6 +816,39 @@ public void testLoadStains() {
verify(service).loadImagingQcComments(entries, ancestry, Set.of(100,101));
}

@Test
public void testLoadQpcrComments() {
setupLabware();
OperationType opType = EntityFactory.makeOperationType("qPCR results", null);
when(mockOpTypeRepo.getByName(any())).thenReturn(opType);
Labware lw3 = EntityFactory.makeLabware(EntityFactory.getTubeType(), sample);
Labware lw4 = EntityFactory.makeLabware(EntityFactory.getTubeType(), sample);
Ancestry ancestry = makeAncestry(lw3, sample, lw2, sample, lw2, sample, lw1, sample);
ancestry.put(new SlotSample(lw4.getFirstSlot(), sample), Set.of());
List<Operation> qpcrOps = IntStream.of(3,4).mapToObj(i -> {
Operation op = new Operation();
op.setId(i);
return op;
}).toList();
when(mockOpRepo.findAllByOperationTypeAndDestinationSlotIdIn(any(), any())).thenReturn(qpcrOps);
List<OperationComment> opComs = List.of(
new OperationComment(10, new Comment(1, "Banana", "c"), 3, sample.getId(), lw1.getFirstSlot().getId(), null),
new OperationComment(11, new Comment(2, "Custard", "c"), 4, sample.getId(), lw2.getFirstSlot().getId(), null)
);
when(mockOpComRepo.findAllByOperationIdIn(any())).thenReturn(opComs);
List<ReleaseEntry> entries = List.of(
new ReleaseEntry(lw3, lw3.getFirstSlot(), sample),
new ReleaseEntry(lw4, lw4.getFirstSlot(), sample)
);
service.loadQpcrComments(entries, ancestry);
verify(mockOpTypeRepo).getByName("qPCR results");
Set<Integer> allSlotIds = ancestry.keySet().stream().map(SlotSample::slotId).collect(toSet());
verify(mockOpRepo).findAllByOperationTypeAndDestinationSlotIdIn(opType, allSlotIds);
verify(mockOpComRepo).findAllByOperationIdIn(List.of(3,4));
assertThat(entries.get(0).getQpcrComment()).isIn("Banana. Custard.", "Custard. Banana.");
assertThat(entries.get(1).getQpcrComment()).isNullOrEmpty();
}

@Test
public void testLoadImagingQcComments() {
setupLabware();
Expand Down
Loading