diff --git a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/ShesmuSample.java b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/ShesmuSample.java index 274bade..a2457a7 100644 --- a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/ShesmuSample.java +++ b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/ShesmuSample.java @@ -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; /** @@ -16,11 +13,13 @@ 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); } @@ -28,17 +27,22 @@ 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); @@ -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; + } + + } } diff --git a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/ShesmuSequencing.java b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/ShesmuSequencing.java index 16b891a..3f31107 100644 --- a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/ShesmuSequencing.java +++ b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/ShesmuSequencing.java @@ -40,7 +40,7 @@ public Set getLimsIds() { return limsIds; } - public Boolean isComplete() { + public boolean isComplete() { return complete; } @@ -52,7 +52,7 @@ public static class Builder { private String test; private Set limsIds; private MetricCategory type; - private boolean complete; + private Boolean complete; public ShesmuSequencing build() { return new ShesmuSequencing(this); @@ -73,7 +73,7 @@ public Builder limsIds(Set limsIds) { return this; } - public Builder complete(boolean complete) { + public Builder complete(Boolean complete) { this.complete = complete; return this; } diff --git a/cardea-data/src/test/java/ca/on/oicr/gsi/cardea/JacksonTest.java b/cardea-data/src/test/java/ca/on/oicr/gsi/cardea/JacksonTest.java index b5cc6cf..037dfb1 100644 --- a/cardea-data/src/test/java/ca/on/oicr/gsi/cardea/JacksonTest.java +++ b/cardea-data/src/test/java/ca/on/oicr/gsi/cardea/JacksonTest.java @@ -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) { @@ -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") diff --git a/cardea-server/src/main/java/ca/on/oicr/gsi/cardea/server/service/CaseService.java b/cardea-server/src/main/java/ca/on/oicr/gsi/cardea/server/service/CaseService.java index d7868ac..7fac1dc 100644 --- a/cardea-server/src/main/java/ca/on/oicr/gsi/cardea/server/service/CaseService.java +++ b/cardea-server/src/main/java/ca/on/oicr/gsi/cardea/server/service/CaseService.java @@ -127,44 +127,47 @@ public Set getShesmuCases() { public Set 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 getSequencingForShesmuCase(Case kase){ + private Set getSequencingForShesmuCase(Case kase) { Set 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 samples, MetricCategory type, long reqId, String name){ + private ShesmuSequencing makeShesmuSequencing(List samples, MetricCategory type, + long reqId, String name) { Set 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; @@ -172,9 +175,10 @@ private ShesmuSequencing makeShesmuSequencing(List samples, MetricCatego 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()); } } @@ -182,11 +186,19 @@ private ShesmuSequencing makeShesmuSequencing(List samples, MetricCatego 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 getLimsIusIdsForShesmu(Case kase) { @@ -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) diff --git a/changes/add_qc_failed_field.md b/changes/add_qc_failed_field.md new file mode 100644 index 0000000..4f21e5a --- /dev/null +++ b/changes/add_qc_failed_field.md @@ -0,0 +1 @@ +Field qcFailed on sequencing items in shesmu detailed cases \ No newline at end of file