Skip to content

Commit

Permalink
add unit tests for fetchClinicalDataCounts / fetchClinicalDataBinCounts
Browse files Browse the repository at this point in the history
  • Loading branch information
cbioportal import user committed Jan 3, 2025
1 parent 2c489b4 commit 82cc2b6
Show file tree
Hide file tree
Showing 3 changed files with 276 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ public List<ClinicalDataCountItem> fetchClinicalDataCounts(List<String> studyIds
Map<String, List<ClinicalDataCount>> clinicalDataCountMap = clinicalDataCounts.stream()
.collect(Collectors.groupingBy(ClinicalDataCount::getAttributeId));

// Used to calculate number of missing values for patient attributes
List<Patient> patients = new ArrayList<Patient>();
if (!patientAttributeIds.isEmpty()) {
patients.addAll(patientService.getPatientsOfSamples(studyIds, sampleIds));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ public List<ClinicalDataCountItem> cachedClinicalDataCounts(ClinicalDataCountFil
studyViewFilterUtil.removeSelfFromFilter(attributes.get(0).getAttributeId(), studyViewFilter);
}
List<SampleIdentifier> filteredSampleIdentifiers = studyViewFilterApplier.apply(studyViewFilter);

if (filteredSampleIdentifiers.isEmpty()) {
return new ArrayList<>();
}
List<String> studyIds = new ArrayList<>();
List<String> sampleIds = new ArrayList<>();
studyViewFilterUtil.extractStudyAndSampleIds(filteredSampleIdentifiers, studyIds, sampleIds);

List<ClinicalDataCountItem> result = clinicalDataService.fetchClinicalDataCounts(
studyIds, sampleIds, attributes.stream().map(a -> a.getAttributeId()).collect(Collectors.toList()));

Expand All @@ -97,4 +97,14 @@ public List<ClinicalDataBin> cachedFetchClinicalDataBinCounts(ClinicalDataBinCou
false
);
}

private List<String> filterStudyIds(List<String> requestedStudyIds) {
var result = new ArrayList<String>();
for (String studyId : requestedStudyIds) {
if (visibleStudies.contains(studyId)) {
result.add(studyId);
}
}
return requestedStudyIds;
}
}
Loading

0 comments on commit 82cc2b6

Please sign in to comment.