Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add qcFailed field to shesmu detailed cases #57

Merged
merged 3 commits into from
Nov 20, 2024
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 @@ -3,9 +3,6 @@
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;

import java.util.Set;

import static java.util.Collections.unmodifiableSet;
import static java.util.Objects.requireNonNull;

/**
Expand All @@ -16,29 +13,36 @@ public class ShesmuSample {

private final String id;
private final boolean supplemental;
private final boolean qcFailed;


private ShesmuSample(Builder builder) {
this.id = requireNonNull(builder.id);
this.supplemental = requireNonNull(builder.supplemental);
this.qcFailed = requireNonNull(builder.qcFailed);
djcooke marked this conversation as resolved.
Show resolved Hide resolved
}


public String getId() {
return id;
}

public Boolean isSupplemental() {
public boolean isSupplemental() {
return supplemental;
}

public boolean isQcFailed() {
return qcFailed;
}



@JsonPOJOBuilder(withPrefix = "")
public static class Builder {

private String id;
private boolean supplemental;
private Boolean supplemental;
private Boolean qcFailed;

public ShesmuSample build() {
return new ShesmuSample(this);
Expand All @@ -50,10 +54,16 @@ public Builder id(String id) {
return this;
}

public Builder supplemental(boolean supplemental) {
public Builder supplemental(Boolean supplemental) {
this.supplemental = supplemental;
return this;
}

public Builder qcFailed(Boolean qcFailed) {
this.qcFailed = qcFailed;
return this;
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public Set<ShesmuSample> getLimsIds() {
return limsIds;
}

public Boolean isComplete() {
public boolean isComplete() {
return complete;
}

Expand All @@ -52,7 +52,7 @@ public static class Builder {
private String test;
private Set<ShesmuSample> limsIds;
private MetricCategory type;
private boolean complete;
private Boolean complete;

public ShesmuSequencing build() {
return new ShesmuSequencing(this);
Expand All @@ -73,7 +73,7 @@ public Builder limsIds(Set<ShesmuSample> limsIds) {
return this;
}

public Builder complete(boolean complete) {
public Builder complete(Boolean complete) {
this.complete = complete;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ private static void assertShesmuDetailedCaseEqual(ShesmuDetailedCase one,
private static void assertShesmuSampleEqual(ShesmuSample one, ShesmuSample two) {
assertEquals(one.getId(), two.getId());
assertEquals(one.isSupplemental(), two.isSupplemental());
assertEquals(one.isQcFailed(), two.isQcFailed());
}

private static void assertShesmuTestEqual(ShesmuSequencing one, ShesmuSequencing two) {
Expand Down Expand Up @@ -862,6 +863,7 @@ private static ShesmuDetailedCase makeShesmuDetailedCase() {
limsIds.add(new ShesmuSample.Builder()
.id("ID1")
.supplemental(false)
.qcFailed(false)
.build());
sequencing.add(new ShesmuSequencing.Builder()
.test("Some Test")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,66 +127,78 @@ public Set<ShesmuCase> getShesmuCases() {

public Set<ShesmuDetailedCase> getShesmuDetailedCases() {
return caseData.getCases().stream()
.filter(kase -> kase.getTests().stream()
.anyMatch(test -> !test.getFullDepthSequencings().isEmpty()
|| test.getLibraryQualifications().stream()
.anyMatch(sample -> sample.getRun() != null)))
.map(kase -> convertCaseToShesmuDetailedCase(kase))
.collect(Collectors.toSet());
.filter(kase -> kase.getTests().stream()
.anyMatch(test -> !test.getFullDepthSequencings().isEmpty()
|| test.getLibraryQualifications().stream()
.anyMatch(sample -> sample.getRun() != null)))
.map(kase -> convertCaseToShesmuDetailedCase(kase))
.collect(Collectors.toSet());
}

private Set<ShesmuSequencing> getSequencingForShesmuCase(Case kase){
private Set<ShesmuSequencing> getSequencingForShesmuCase(Case kase) {

Set<ShesmuSequencing> sequencings = new HashSet<>();
final long reqId = kase.getRequisition().getId();

for (Test test : kase.getTests()) {

ShesmuSequencing fullDepthSeq = makeShesmuSequencing(test.getFullDepthSequencings(), MetricCategory.FULL_DEPTH_SEQUENCING, reqId, test.getName());
ShesmuSequencing fullDepthSeq = makeShesmuSequencing(test.getFullDepthSequencings(),
MetricCategory.FULL_DEPTH_SEQUENCING, reqId, test.getName());
if (fullDepthSeq != null) {
sequencings.add(fullDepthSeq);
}

ShesmuSequencing libraryQual = makeShesmuSequencing(test.getLibraryQualifications(), MetricCategory.LIBRARY_QUALIFICATION, reqId, test.getName());
ShesmuSequencing libraryQual = makeShesmuSequencing(test.getLibraryQualifications(),
MetricCategory.LIBRARY_QUALIFICATION, reqId, test.getName());
if (libraryQual != null) {
sequencings.add(libraryQual);
}
};
} ;

return sequencings;
}

private ShesmuSequencing makeShesmuSequencing(List<Sample> samples, MetricCategory type, long reqId, String name){
private ShesmuSequencing makeShesmuSequencing(List<Sample> samples, MetricCategory type,
long reqId, String name) {

Set<ShesmuSample> shesmuSamples = new HashSet<>();

boolean hasPassed = false;
boolean hasWaiting = false;
for (Sample sample : samples){
for (Sample sample : samples) {

if (sample.getDataReviewPassed() == null || sample.getQcPassed() == null){
if (sample.getDataReviewPassed() == null || sample.getQcPassed() == null) {
hasWaiting = true;
} else if (sample.getDataReviewPassed() && sample.getQcPassed()) {
hasPassed = true;
}

if (!(sample.getRun() == null && type.equals(MetricCategory.LIBRARY_QUALIFICATION))) {
shesmuSamples.add(new ShesmuSample.Builder()
.id(sample.getId())
.supplemental(!Objects.equals(sample.getRequisitionId(), reqId))
.build());
.id(sample.getId())
.supplemental(!Objects.equals(sample.getRequisitionId(), reqId))
.qcFailed(getQcFailed(sample))
.build());
}
}

if (shesmuSamples.isEmpty()) {
return null;
}
return new ShesmuSequencing.Builder()
.test(name)
.limsIds(shesmuSamples)
.complete((hasPassed && !hasWaiting))
.type(type)
.build();
.test(name)
.limsIds(shesmuSamples)
.complete((hasPassed && !hasWaiting))
.type(type)
.build();
}

private boolean getQcFailed(Sample sample) {
Run run = sample.getRun();
return ((sample.getDataReviewPassed() == false)
|| (sample.getQcPassed() == false)
|| (run.getDataReviewPassed() == false)
|| (run.getQcPassed() == false));
}

private Set<String> getLimsIusIdsForShesmu(Case kase) {
Expand Down Expand Up @@ -242,17 +254,17 @@ private ShesmuCase convertCaseToShesmuCase(Case kase) {

private ShesmuDetailedCase convertCaseToShesmuDetailedCase(Case kase) {
return new ShesmuDetailedCase.Builder()
.assayName(caseData.getAssaysById().get(kase.getAssayId()).getName())
.assayVersion(caseData.getAssaysById().get(kase.getAssayId()).getVersion())
.caseIdentifier(kase.getId())
.caseStatus(getCaseStatus(kase))
.paused(kase.getRequisition().isPaused())
.stopped(kase.getRequisition().isStopped())
.completedDateLocal(getCompletedDate(kase))
.requisitionId(kase.getRequisition().getId())
.requisitionName(kase.getRequisition().getName())
.sequencing(getSequencingForShesmuCase(kase))
.build();
.assayName(caseData.getAssaysById().get(kase.getAssayId()).getName())
.assayVersion(caseData.getAssaysById().get(kase.getAssayId()).getVersion())
.caseIdentifier(kase.getId())
.caseStatus(getCaseStatus(kase))
.paused(kase.getRequisition().isPaused())
.stopped(kase.getRequisition().isStopped())
.completedDateLocal(getCompletedDate(kase))
.requisitionId(kase.getRequisition().getId())
.requisitionName(kase.getRequisition().getName())
.sequencing(getSequencingForShesmuCase(kase))
.build();
}

@Scheduled(fixedDelay = 1L, timeUnit = TimeUnit.MINUTES)
Expand Down
1 change: 1 addition & 0 deletions changes/add_qc_failed_field.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Field qcFailed on sequencing items in shesmu detailed cases
Loading