Skip to content

Commit

Permalink
Dynamically calculate sample identifiers in study view filter helper
Browse files Browse the repository at this point in the history
  • Loading branch information
dippindots committed Dec 19, 2024
1 parent 0bc04ff commit 8607377
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public static StudyViewFilterHelper build(@Nullable StudyViewFilter studyViewFil
private final StudyViewFilter studyViewFilter;
private final CategorizedGenericAssayDataCountFilter categorizedGenericAssayDataCountFilter;
private final List<CustomSampleIdentifier> customDataSamples;
private final String[] filteredSampleIdentifiers;
private final List<String> involvedCancerStudies;

private StudyViewFilterHelper(@NonNull StudyViewFilter studyViewFilter,
Expand All @@ -66,13 +65,6 @@ private StudyViewFilterHelper(@NonNull StudyViewFilter studyViewFilter,
this.categorizedGenericAssayDataCountFilter = extractGenericAssayDataCountFilters(studyViewFilter, genericAssayProfilesMap);
this.customDataSamples = customDataSamples;
this.involvedCancerStudies = involvedCancerStudies;
if (studyViewFilter != null && studyViewFilter.getSampleIdentifiers() != null) {
this.filteredSampleIdentifiers = studyViewFilter.getSampleIdentifiers().stream()
.map(sampleIdentifier -> sampleIdentifier.getStudyId() + "_" + sampleIdentifier.getSampleId())
.toArray(String[]::new);
} else {
this.filteredSampleIdentifiers = new String[0];
}
}

public StudyViewFilter studyViewFilter() {
Expand All @@ -88,7 +80,13 @@ public List<CustomSampleIdentifier> customDataSamples() {
}

public String[] filteredSampleIdentifiers() {
return this.filteredSampleIdentifiers;
if (studyViewFilter != null && studyViewFilter.getSampleIdentifiers() != null) {
return studyViewFilter.getSampleIdentifiers().stream()
.map(sampleIdentifier -> sampleIdentifier.getStudyId() + "_" + sampleIdentifier.getSampleId())
.toArray(String[]::new);
} else {
return new String[0];
}
}

public List<String> involvedCancerStudies() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ public class CustomSampleIdentifier extends SampleIdentifier implements Serializ

private boolean isFilteredOut = false;
private String value;

private String uniqueSampleId;

public boolean getIsFilteredOut() {
Expand All @@ -32,6 +31,6 @@ public String getUniqueSampleId() {
if (getStudyId() != null && getSampleId() != null) {
return getStudyId() + "_" + getSampleId();
}
return null; // or return a default value if either studyId or sampleId is null
return null; // or return null if either studyId or sampleId is null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@
)

</if>

<if test="studyViewFilterHelper.filteredSampleIdentifiers != null and studyViewFilterHelper.filteredSampleIdentifiers.length > 0">
<bind name="filteredSampleIdentifiers" value="studyViewFilterHelper.filteredSampleIdentifiers()" />
<if test="filteredSampleIdentifiers != null and filteredSampleIdentifiers.length > 0">
INTERSECT
SELECT sample_unique_id
FROM sample_derived
WHERE sample_unique_id IN
(
#{studyViewFilterHelper.filteredSampleIdentifiers, typeHandler=org.apache.ibatis.type.ArrayTypeHandler}
#{filteredSampleIdentifiers, typeHandler=org.apache.ibatis.type.ArrayTypeHandler}
)
</if>
<if test="studyViewFilterHelper.studyViewFilter.customDataFilters != null and !studyViewFilterHelper.studyViewFilter.customDataFilters.isEmpty() and studyViewFilterHelper.customDataSamples != null">
Expand Down

0 comments on commit 8607377

Please sign in to comment.