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

[GLT-4274] added omitted run samples to Dimsum case data #56

Merged
merged 2 commits into from
Nov 6, 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
12 changes: 12 additions & 0 deletions cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/CaseData.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ public class CaseData {
private final Map<Long, Assay> assaysById;
private final List<Case> cases;
private final List<OmittedSample> omittedSamples;
private final List<OmittedRunSample> omittedRunSamples;
private final ZonedDateTime timestamp;

private CaseData(Builder builder) {
this.assaysById = unmodifiableMap(builder.assaysById);
this.cases = unmodifiableList(builder.cases);
this.omittedSamples = unmodifiableList(builder.omittedSamples);
this.omittedRunSamples = unmodifiableList(builder.omittedRunSamples);
this.timestamp = requireNonNull(builder.timestamp);
}

Expand All @@ -37,6 +39,10 @@ public List<OmittedSample> getOmittedSamples() {
return omittedSamples;
}

public List<OmittedRunSample> getOmittedRunSamples() {
return omittedRunSamples;
}

public ZonedDateTime getTimestamp() {
return timestamp;
}
Expand All @@ -46,6 +52,7 @@ public static class Builder {
private Map<Long, Assay> assaysById;
private List<Case> cases;
private List<OmittedSample> omittedSamples;
private List<OmittedRunSample> omittedRunSamples;
private ZonedDateTime timestamp;

public CaseData build() {
Expand All @@ -67,6 +74,11 @@ public Builder omittedSamples(List<OmittedSample> omittedSamples) {
return this;
}

public Builder omittedRunSamples(List<OmittedRunSample> omittedRunSamples) {
this.omittedRunSamples = omittedRunSamples;
return this;
}

public Builder timestamp(ZonedDateTime timestamp) {
this.timestamp = timestamp;
return this;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
package ca.on.oicr.gsi.cardea.data;

import static java.util.Objects.requireNonNull;
import java.time.LocalDate;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;

/**
* Immutable OmittedRunSample
*/
@JsonDeserialize(builder = OmittedRunSample.Builder.class)
public class OmittedRunSample {

private final String id;
private final String name;
private final long runId;
private final int sequencingLane;
private final LocalDate qcDate;
private final Boolean qcPassed;
private final String qcReason;
private final String qcNote;
private final String qcUser;
private final LocalDate dataReviewDate;
private final Boolean dataReviewPassed;
private final String dataReviewUser;

private OmittedRunSample(Builder builder) {
this.id = requireNonNull(builder.id);
this.name = requireNonNull(builder.name);
this.runId = requireNonNull(builder.runId);
this.sequencingLane = requireNonNull(builder.sequencingLane);
this.qcPassed = builder.qcPassed;
this.qcReason = builder.qcReason;
this.qcNote = builder.qcNote;
this.qcUser = builder.qcUser;
this.qcDate = builder.qcDate;
this.dataReviewPassed = builder.dataReviewPassed;
this.dataReviewUser = builder.dataReviewUser;
this.dataReviewDate = builder.dataReviewDate;
}

public String getId() {
return id;
}

public String getName() {
return name;
}

public long getRunId() {
return runId;
}

public int getSequencingLane() {
return sequencingLane;
}

public LocalDate getQcDate() {
return qcDate;
}

public Boolean getQcPassed() {
return qcPassed;
}

public String getQcReason() {
return qcReason;
}

public String getQcNote() {
return qcNote;
}

public String getQcUser() {
return qcUser;
}

public LocalDate getDataReviewDate() {
return dataReviewDate;
}

public Boolean getDataReviewPassed() {
return dataReviewPassed;
}

public String getDataReviewUser() {
return dataReviewUser;
}

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

private String id;
private String name;
private Long runId;
private Integer sequencingLane;
private LocalDate qcDate;
private Boolean qcPassed;
private String qcReason;
private String qcNote;
private String qcUser;
private LocalDate dataReviewDate;
private Boolean dataReviewPassed;
private String dataReviewUser;

public OmittedRunSample build() {
return new OmittedRunSample(this);
}

public Builder id(String id) {
this.id = id;
return this;
}

public Builder name(String name) {
this.name = name;
return this;
}

public Builder runId(Long runId) {
this.runId = runId;
return this;
}

public Builder sequencingLane(Integer sequencingLane) {
this.sequencingLane = sequencingLane;
return this;
}

public Builder qcDate(LocalDate qcDate) {
this.qcDate = qcDate;
return this;
}

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

public Builder qcReason(String qcReason) {
this.qcReason = qcReason;
return this;
}

public Builder qcNote(String qcNote) {
this.qcNote = qcNote;
return this;
}

public Builder qcUser(String qcUser) {
this.qcUser = qcUser;
return this;
}

public Builder dataReviewDate(LocalDate dataReviewDate) {
this.dataReviewDate = dataReviewDate;
return this;
}

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

public Builder dataReviewUser(String dataReviewUser) {
this.dataReviewUser = dataReviewUser;
return this;
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@

/**
* Immutable RunAndLibraries
*
* This is being moved to Dimsum because its only intended use is for data transformation within
* Dimsum
*/
@JsonDeserialize(builder = RunAndLibraries.Builder.class)
@Deprecated(forRemoval = true)
public class RunAndLibraries {

private Set<Sample> fullDepthSequencings;
Expand Down
87 changes: 65 additions & 22 deletions cardea-data/src/test/java/ca/on/oicr/gsi/cardea/JacksonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,14 @@ public void testCaseSerializeDeserialize() throws Exception {
assertCaseEqual(original, deserialized);
}

@org.junit.jupiter.api.Test
public void testOmittedRunSampleSerializeDeserialize() throws Exception {
OmittedRunSample original = makeOmittedRunSample();
String serialized = mapper.writeValueAsString(original);
OmittedRunSample deserialized = mapper.readerFor(OmittedRunSample.class).readValue(serialized);
assertOmittedRunSampleEqual(original, deserialized);
}

@org.junit.jupiter.api.Test
public void testShesmuCaseSerializeDeserialize() throws Exception {
ShesmuCase original = makeShesmuCase();
Expand All @@ -177,7 +185,8 @@ public void testShesmuCaseSerializeDeserialize() throws Exception {
public void testShesmuDetailedCaseSerializeDeserialize() throws Exception {
ShesmuDetailedCase original = makeShesmuDetailedCase();
String serialized = mapper.writeValueAsString(original);
ShesmuDetailedCase deserialized = mapper.readerFor(ShesmuDetailedCase.class).readValue(serialized);
ShesmuDetailedCase deserialized =
mapper.readerFor(ShesmuDetailedCase.class).readValue(serialized);
assertShesmuDetailedCaseEqual(original, deserialized);
}

Expand Down Expand Up @@ -479,6 +488,21 @@ private static void assertCaseEqual(Case one, Case two) {
assertEquals(one.getPauseDays(), two.getPauseDays());
}

private static void assertOmittedRunSampleEqual(OmittedRunSample one, OmittedRunSample two) {
assertEquals(one.getId(), two.getId());
assertEquals(one.getName(), two.getName());
assertEquals(one.getRunId(), two.getRunId());
assertEquals(one.getSequencingLane(), two.getSequencingLane());
assertEquals(one.getQcPassed(), two.getQcPassed());
assertEquals(one.getQcReason(), two.getQcReason());
assertEquals(one.getQcNote(), two.getQcNote());
assertEquals(one.getQcUser(), two.getQcUser());
assertEquals(one.getQcDate(), two.getQcDate());
assertEquals(one.getDataReviewPassed(), two.getDataReviewPassed());
assertEquals(one.getDataReviewUser(), two.getDataReviewUser());
assertEquals(one.getDataReviewDate(), two.getDataReviewDate());
}

private static void assertShesmuCaseEqual(ShesmuCase one, ShesmuCase two) {
assertEquals(one.getAssayName(), two.getAssayName());
assertEquals(one.getAssayVersion(), two.getAssayVersion());
Expand All @@ -490,7 +514,8 @@ private static void assertShesmuCaseEqual(ShesmuCase one, ShesmuCase two) {
assertEquals(one.getRequisitionName(), two.getRequisitionName());
}

private static void assertShesmuDetailedCaseEqual(ShesmuDetailedCase one, ShesmuDetailedCase two) {
private static void assertShesmuDetailedCaseEqual(ShesmuDetailedCase one,
ShesmuDetailedCase two) {
assertEquals(one.getAssayName(), two.getAssayName());
assertEquals(one.getAssayVersion(), two.getAssayVersion());
assertEquals(one.getCaseIdentifier(), two.getCaseIdentifier());
Expand All @@ -499,7 +524,8 @@ private static void assertShesmuDetailedCaseEqual(ShesmuDetailedCase one, Shesmu
assertEquals(one.getCaseStatus(), two.getCaseStatus());
assertEquals(one.getCompletedDate(), two.getCompletedDate());
assertEquals(one.getSequencing().size(), two.getSequencing().size());
assertShesmuTestEqual(one.getSequencing().iterator().next(), two.getSequencing().iterator().next());
assertShesmuTestEqual(one.getSequencing().iterator().next(),
two.getSequencing().iterator().next());
assertEquals(one.getRequisitionId(), two.getRequisitionId());
assertEquals(one.getRequisitionName(), two.getRequisitionName());
}
Expand Down Expand Up @@ -796,6 +822,23 @@ private static Case makeCase() {
.build();
}

private static OmittedRunSample makeOmittedRunSample() {
return new OmittedRunSample.Builder()
.id("123_4_LDI567")
.name("Joe")
.runId(123L)
.sequencingLane(4)
.qcPassed(true)
.qcReason("Good stuff")
.qcNote("This is my note")
.qcUser("Me")
.qcDate(LocalDate.now().minusDays(1L))
.dataReviewPassed(true)
.dataReviewUser("Someone else")
.dataReviewDate(LocalDate.now())
.build();
}

private static ShesmuCase makeShesmuCase() {
Set<String> limsIds = new HashSet<>();
limsIds.add("ID1");
Expand All @@ -817,28 +860,28 @@ private static ShesmuDetailedCase makeShesmuDetailedCase() {
Set<ShesmuSequencing> sequencing = new HashSet<>();
Set<ShesmuSample> limsIds = new HashSet<>();
limsIds.add(new ShesmuSample.Builder()
.id("ID1")
.supplemental(false)
.build());
.id("ID1")
.supplemental(false)
.build());
sequencing.add(new ShesmuSequencing.Builder()
.test("Some Test")
.limsIds(limsIds)
.complete(true)
.type(MetricCategory.LIBRARY_QUALIFICATION)
.build());
.test("Some Test")
.limsIds(limsIds)
.complete(true)
.type(MetricCategory.LIBRARY_QUALIFICATION)
.build());

return new ShesmuDetailedCase.Builder()
.assayName("Assay")
.assayVersion("2.0")
.caseIdentifier("CASE10")
.stopped(false)
.paused(false)
.caseStatus(CaseStatus.COMPLETED)
.completedDateLocal(LocalDate.of(2024, 1, 13))
.sequencing(sequencing)
.requisitionId(1L)
.requisitionName("Some Req")
.build();
.assayName("Assay")
.assayVersion("2.0")
.caseIdentifier("CASE10")
.stopped(false)
.paused(false)
.caseStatus(CaseStatus.COMPLETED)
.completedDateLocal(LocalDate.of(2024, 1, 13))
.sequencing(sequencing)
.requisitionId(1L)
.requisitionName("Some Req")
.build();
}

}
Loading
Loading