Skip to content

Commit

Permalink
Replace organism id with biological replicate (#789)
Browse files Browse the repository at this point in the history
  • Loading branch information
wow-such-code committed Aug 19, 2024
1 parent 39e38b2 commit 83699ff
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private Specification<SamplePreview> generateExperimentIdandFilterSpecification(
Specification<SamplePreview> isBlankSpec = SamplePreviewSpecs.isBlank(filter);
Specification<SamplePreview> experimentIdSpec = SamplePreviewSpecs.experimentIdEquals(
experimentId);
Specification<SamplePreview> organismIdSpec = SamplePreviewSpecs.organismIdContains(filter);
Specification<SamplePreview> biologialReplicateSpec = SamplePreviewSpecs.biologicalReplicateContains(filter);
Specification<SamplePreview> sampleCodeSpec = SamplePreviewSpecs.sampleCodeContains(filter);
Specification<SamplePreview> sampleNameSpec = SamplePreviewSpecs.sampleNameContains(filter);
Specification<SamplePreview> batchLabelSpec = SamplePreviewSpecs.batchLabelContains(filter);
Expand All @@ -80,7 +80,7 @@ private Specification<SamplePreview> generateExperimentIdandFilterSpecification(
filter);
Specification<SamplePreview> commentSpec = SamplePreviewSpecs.commentContains(filter);
Specification<SamplePreview> containsFilterSpec = Specification.anyOf(sampleCodeSpec,
sampleNameSpec, organismIdSpec, batchLabelSpec, conditionSpec, speciesSpec,
sampleNameSpec, biologialReplicateSpec, batchLabelSpec, conditionSpec, speciesSpec,
specimenSpec, analyteSpec, analysisMethodContains, commentSpec);
Specification<SamplePreview> isDistinctSpec = SamplePreviewSpecs.isDistinct();
return Specification.where(experimentIdSpec).and(isBlankSpec)
Expand Down Expand Up @@ -158,9 +158,9 @@ private static Specification<SamplePreview> ontologyColumnContains(String col, S
};
}

public static Specification<SamplePreview> organismIdContains(String filter) {
public static Specification<SamplePreview> biologicalReplicateContains(String filter) {
return (root, query, builder) ->
builder.like(root.get("organismId"), "%" + filter + "%");
builder.like(root.get("biologicalReplicate"), "%" + filter + "%");
}

public static Specification<SamplePreview> speciesContains(String filter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ public record SampleUpdateRequest(SampleId sampleId, SampleInformation sampleInf
/**
* Sample update request.
* <p>
* @param sampleName a human-readable semantic descriptor of the sample
* @param organismId optional identifier of the sample's source patient or organism
* @param sampleName a human-readable semantic descriptor of the sample
* @param biologicalReplicate optional identifier of the sample's source patient or organism, to
* be able to group biological replicates
* @param analysisMethod analysis method to be performed
* @param experimentalGroup the experimental group the sample is part of
* @param species the species the sample belongs to
* @param specimen the specimen the sample belongs to.
* @param analyte the analyte the sample belongs to
* @param comment comment relating to the sample
*/
public record SampleInformation(String sampleName, String organismId,
public record SampleInformation(String sampleName, String biologicalReplicate,
AnalysisMethod analysisMethod,
ExperimentalGroup experimentalGroup, OntologyTerm species,
OntologyTerm specimen, OntologyTerm analyte,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class SamplePreview {
private String sampleName;

@Column(name = "organism_id")
private String organismId;
private String biologicalReplicate;
private String comment;
@Column(name = "analysis_method")
private String analysisMethod;
Expand All @@ -58,7 +58,7 @@ protected SamplePreview() {
}

private SamplePreview(ExperimentId experimentId, SampleId sampleId, String sampleCode,
String batchLabel, String sampleName, String organismId,
String batchLabel, String sampleName, String biologicalReplicate,
ExperimentalGroup experimentalGroup, OntologyTerm species,
OntologyTerm specimen, OntologyTerm analyte, String analysisMethod, String comment) {
Objects.requireNonNull(experimentId);
Expand All @@ -83,40 +83,40 @@ private SamplePreview(ExperimentId experimentId, SampleId sampleId, String sampl
this.analysisMethod = analysisMethod;
// optional columns
this.comment = comment;
this.organismId = organismId;
this.biologicalReplicate = biologicalReplicate;
}

/**
* Creates a new instance of a SamplePreview object.
*
* @param experimentId the {@link ExperimentId} of the associated experiment
* @param sampleId the {@link SampleId} from which this preview was created
* @param sampleCode the {@link SampleCode} associated with this SamplePreview
* @param batchLabel the label of the {@link Batch} which contains the {@link Sample}
* associated with this preview
* associated with this preview
* @param sampleName the name of the {@link Sample} associated with this preview
* @param organismId optional identifier of the patient or organism a {@link Sample} was taken of
* @param experimentalGroup the {@link ExperimentalGroup} for the {@link Sample} associated with
* this preview
* @param species the {@link OntologyTerm} for the species of this {@link Sample}
* associated with this preview
* @param specimen the {@link OntologyTerm} for the specimen of this {@link Sample}
* associated with this preview
* @param analyte the {@link OntologyTerm} for the analyte of this {@link Sample}
* associated with this preview
* @param analysisMethod the analysis method to be performed for this {@link Sample}
* @param comment an optional comment pertaining to the associated {@link Sample}
* @param experimentId the {@link ExperimentId} of the associated experiment
* @param sampleId the {@link SampleId} from which this preview was created
* @param sampleCode the {@link SampleCode} associated with this SamplePreview
* @param batchLabel the label of the {@link Batch} which contains the {@link Sample}
* associated with this preview
* @param sampleName the name of the {@link Sample} associated with this preview
* @param biologicalReplicate optional identifier of the patient or organism a {@link Sample}
* was taken of. Used to group biological replicates
* @param experimentalGroup the {@link ExperimentalGroup} for the {@link Sample} associated with
* this preview
* @param species the {@link OntologyTerm} for the species of this {@link Sample}
* associated with this preview
* @param specimen the {@link OntologyTerm} for the specimen of this {@link Sample}
* associated with this preview
* @param analyte the {@link OntologyTerm} for the analyte of this {@link Sample}
* associated with this preview
* @param analysisMethod the analysis method to be performed for this {@link Sample}
* @param comment an optional comment pertaining to the associated {@link Sample}
* @return the sample preview
*/
public static SamplePreview create(ExperimentId experimentId, SampleId sampleId,
String sampleCode,
String batchLabel,
String sampleName, String organismId, ExperimentalGroup experimentalGroup,
String sampleName, String biologicalReplicate, ExperimentalGroup experimentalGroup,
OntologyTerm species, OntologyTerm specimen, OntologyTerm analyte,
String analysisMethod, String comment) {
return new SamplePreview(experimentId, sampleId, sampleCode, batchLabel,
sampleName, organismId, experimentalGroup, species, specimen, analyte, analysisMethod,
sampleName, biologicalReplicate, experimentalGroup, species, specimen, analyte, analysisMethod,
comment);
}

Expand Down Expand Up @@ -160,8 +160,8 @@ public String comment() {
return comment;
}

public String organismId() {
return organismId;
public String biologicalReplicate() {
return biologicalReplicate;
}

public ExperimentalGroup experimentalGroup() {
Expand All @@ -180,7 +180,7 @@ public boolean equals(Object o) {
return Objects.equals(experimentId, that.experimentId) && Objects.equals(
sampleCode, that.sampleCode) && Objects.equals(sampleId, that.sampleId)
&& Objects.equals(batchLabel, that.batchLabel) && Objects.equals(sampleName,
that.sampleName) && Objects.equals(organismId, that.organismId)
that.sampleName) && Objects.equals(biologicalReplicate, that.biologicalReplicate)
&& Objects.equals(species, that.species) && Objects.equals(specimen,
that.specimen) && Objects.equals(analyte, that.analyte) && Objects.equals(
experimentalGroup, that.experimentalGroup) && Objects.equals(analysisMethod,
Expand All @@ -190,7 +190,7 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
return Objects.hash(experimentId, sampleCode, sampleId, batchLabel,
sampleName, organismId,
sampleName, biologicalReplicate,
species, specimen, analyte, experimentalGroup, analysisMethod, comment);
}

Expand All @@ -202,7 +202,7 @@ public String toString() {
", sampleId='" + sampleId + '\'' +
", batchLabel='" + batchLabel + '\'' +
", sampleName='" + sampleName + '\'' +
", organismId='" + organismId + '\'' +
", biologicalReplicate='" + biologicalReplicate + '\'' +
", species='" + species + '\'' +
", specimen='" + specimen + '\'' +
", analyte='" + analyte + '\'' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class Sample {
private SampleId id;
private String label;
@Column(name = "organism_id")
private String organismId;
private String biologicalReplicate;
private String comment;

@Column(name = "analysis_method")
Expand All @@ -58,13 +58,13 @@ public class Sample {
private SampleOrigin sampleOrigin;

private Sample(SampleId id, SampleCode sampleCode, BatchId assignedBatch, String label,
String organismId, ExperimentId experimentId, Long experimentalGroupId,
String biologicalReplicate, ExperimentId experimentId, Long experimentalGroupId,
SampleOrigin sampleOrigin,
AnalysisMethod analysisMethod, String comment) {
this.id = id;
this.sampleCode = Objects.requireNonNull(sampleCode);
this.label = label;
this.organismId = organismId;
this.biologicalReplicate = biologicalReplicate;
this.experimentId = experimentId;
this.experimentalGroupId = experimentalGroupId;
this.sampleOrigin = sampleOrigin;
Expand All @@ -89,7 +89,7 @@ public static Sample create(SampleCode sampleCode,
Objects.requireNonNull(sampleRegistrationRequest);
SampleId sampleId = SampleId.create();
return new Sample(sampleId, sampleCode, sampleRegistrationRequest.assignedBatch(),
sampleRegistrationRequest.label(), sampleRegistrationRequest.organismId(),
sampleRegistrationRequest.label(), sampleRegistrationRequest.biologicalReplicate(),
sampleRegistrationRequest.experimentId(), sampleRegistrationRequest.experimentalGroupId(),
sampleRegistrationRequest.sampleOrigin(),
sampleRegistrationRequest.analysisMethod(), sampleRegistrationRequest.comment());
Expand Down Expand Up @@ -119,8 +119,8 @@ public String label() {
return this.label;
}

public String organismId() {
return this.organismId;
public String biologicalReplicate() {
return this.biologicalReplicate;
}

public Optional<String> comment() {
Expand All @@ -147,8 +147,8 @@ public void setLabel(String label) {
this.label = label;
}

public void setOrganismId(String organismId) {
this.organismId = organismId;
public void setBiologicalReplicate(String biologicalReplicate) {
this.biologicalReplicate = biologicalReplicate;
}

public void setComment(String comment) {
Expand All @@ -165,7 +165,7 @@ public void setSampleOrigin(SampleOrigin sampleOrigin) {

public void update(SampleUpdateRequest sampleInfo) {
setLabel(sampleInfo.sampleInformation().sampleName());
setOrganismId(sampleInfo.sampleInformation().organismId());
setBiologicalReplicate(sampleInfo.sampleInformation().biologicalReplicate());
setAnalysisMethod(sampleInfo.sampleInformation().analysisMethod());
setSampleOrigin(SampleOrigin.create(sampleInfo.sampleInformation().species(),
sampleInfo.sampleInformation().specimen(), sampleInfo.sampleInformation().analyte()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
* Serves as a parameter object for sample creation.
*
* @param label a human-readable semantic descriptor of the sample
* @param organismId optional identifier of the patient or organism a sample was taken of
* @param biologicalReplicate optional identifier of the patient or organism a sample was taken of.
* Used to group biological replicates
* @param assignedBatch the assigned batch
* @param experimentId the experiment reference
* @param experimentalGroupId the experimental group id the sample is part of
Expand All @@ -19,16 +20,16 @@
*
* @since 1.0.0
*/
public record SampleRegistrationRequest(String label, String organismId, BatchId assignedBatch,
public record SampleRegistrationRequest(String label, String biologicalReplicate, BatchId assignedBatch,
ExperimentId experimentId, Long experimentalGroupId,
SampleOrigin sampleOrigin, AnalysisMethod analysisMethod,
String comment) {

public SampleRegistrationRequest(String label, String organismId, BatchId assignedBatch,
public SampleRegistrationRequest(String label, String biologicalReplicate, BatchId assignedBatch,
ExperimentId experimentId, Long experimentalGroupId,
SampleOrigin sampleOrigin, AnalysisMethod analysisMethod, String comment) {
this.label = Objects.requireNonNull(label);
this.organismId = organismId;
this.biologicalReplicate = biologicalReplicate;
this.assignedBatch = Objects.requireNonNull(assignedBatch);
this.experimentId = Objects.requireNonNull(experimentId);
this.experimentalGroupId = Objects.requireNonNull(experimentalGroupId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void updateSamples(Project project, Collection<SampleUpdateRequest> updat
.filter(sampleUpdateRequest -> sampleUpdateRequest.sampleId().equals(sample.sampleId()))
.findFirst().orElseThrow();
sample.setLabel(sampleInfo.sampleInformation().sampleName());
sample.setOrganismId(sampleInfo.sampleInformation().organismId());
sample.setBiologicalReplicate(sampleInfo.sampleInformation().biologicalReplicate());
sample.setAnalysisMethod(sampleInfo.sampleInformation().analysisMethod());
sample.setSampleOrigin(SampleOrigin.create(sampleInfo.sampleInformation().species(),
sampleInfo.sampleInformation().specimen(), sampleInfo.sampleInformation().analyte()));
Expand Down
Binary file modified user-interface/src/main/bundles/dev.bundle
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ private static Grid<SamplePreview> createSampleGrid() {
.setTooltipGenerator(SamplePreview::sampleName)
.setAutoWidth(true)
.setResizable(true);
sampleGrid.addColumn(SamplePreview::organismId)
.setHeader("Organism ID")
.setSortProperty("organismId")
.setTooltipGenerator(SamplePreview::organismId)
sampleGrid.addColumn(SamplePreview::biologicalReplicate)
.setHeader("Biological Replicate")
.setSortProperty("biologicalReplicate")
.setTooltipGenerator(SamplePreview::biologicalReplicate)
.setAutoWidth(true)
.setResizable(true);
sampleGrid.addColumn(SamplePreview::batchLabel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ private List<SampleRegistrationRequest> generateSampleRequestsFromSampleInfo(Bat
List<SampleRegistrationRequest> sampleRegistrationRequests;
sampleRegistrationRequests = sampleInfos.stream()
.map(sample -> new SampleRegistrationRequest(
sample.getSampleName(), sample.getOrganismId(),
sample.getSampleName(), sample.getBiologicalReplicate(),
batchId,
context.experimentId().orElseThrow(),
sample.getExperimentalGroup().id(),
Expand All @@ -247,7 +247,7 @@ private List<SampleRegistrationRequest> generateSampleRequestsFromSampleInfo(Bat
private SampleUpdateRequest generateSampleUpdateRequestFromSampleInfo(
SampleInfo sampleInfo) {
return new SampleUpdateRequest(sampleInfo.getSampleId(), new SampleInformation(
sampleInfo.getSampleName(), sampleInfo.getOrganismId(),
sampleInfo.getSampleName(), sampleInfo.getBiologicalReplicate(),
sampleInfo.getAnalysisToBePerformed(),
sampleInfo.getExperimentalGroup(),
sampleInfo.getSpecies(), sampleInfo.getSpecimen(), sampleInfo.getAnalyte(),
Expand Down Expand Up @@ -353,7 +353,7 @@ private SampleBatchInformationSpreadsheet.SampleInfo convertSampleToSampleInfo(S
/*We currently allow replicates independent of experimental groups which is why we have to parse all replicates */
return SampleBatchInformationSpreadsheet.SampleInfo.create(sample.sampleId(),
sample.sampleCode(), sample.analysisMethod(),
sample.label(), sample.organismId(), experimentalGroup, sample.sampleOrigin()
sample.label(), sample.biologicalReplicate(), experimentalGroup, sample.sampleOrigin()
.getSpecies(), sample.sampleOrigin().getSpecimen(), sample.sampleOrigin().getAnalyte(),
sample.comment().orElse(""));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public byte[] getContent() {
TSVBuilder<SamplePreview> tsvBuilder = new TSVBuilder<>(samples);
tsvBuilder.addColumn("Sample ID", SamplePreview::sampleCode);
tsvBuilder.addColumn("Sample Name", SamplePreview::sampleName);
tsvBuilder.addColumn("Organism ID", SamplePreview::organismId);
tsvBuilder.addColumn("Biological Replicate", SamplePreview::biologicalReplicate);
tsvBuilder.addColumn("Batch", SamplePreview::batchLabel);
tsvBuilder.addColumn("Species", sample -> sample.species().getLabel());
tsvBuilder.addColumn("Specimen", sample -> sample.specimen().getLabel());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ private void createSampleInfoEntry(SamplePreview sample, Row sampleRow,
var labelCol = sampleRow.createCell(SamplePreviewColumn.LABEL.column());
labelCol.setCellValue(sample.sampleName());

var organismIdCol = sampleRow.createCell(SamplePreviewColumn.ORGANISM_ID.column());
organismIdCol.setCellValue(sample.organismId());
var bioRepCol = sampleRow.createCell(SamplePreviewColumn.BIOLOGICAL_REPLICATE.column());
bioRepCol.setCellValue(sample.biologicalReplicate());

var batchCol = sampleRow.createCell(SamplePreviewColumn.BATCH.column());
batchCol.setCellValue(sample.batchLabel());
Expand Down Expand Up @@ -162,7 +162,7 @@ enum SamplePreviewColumn {

SAMPLE_ID("Sample ID", 0),
LABEL("Sample Name", 1),
ORGANISM_ID("Organism ID", 2),
BIOLOGICAL_REPLICATE("Biological Replicate", 2),
BATCH("Batch", 3),
SPECIES("Species", 4),
SPECIMEN("Specimen", 5),
Expand Down
Loading

0 comments on commit 83699ff

Please sign in to comment.