Skip to content

Commit

Permalink
Fix bug where 0 patients was assumed all patients in genomic processing
Browse files Browse the repository at this point in the history
  • Loading branch information
ramari16 committed Jan 26, 2024
1 parent 22129ae commit 120152f
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,12 @@ protected Set<Integer> applyBooleanLogic(List<Set<Integer>> filteredIdSets) {
protected Set<Integer> idSetsForEachFilter(Query query) {
DistributableQuery distributableQuery = getDistributableQuery(query);

if (!distributableQuery.getPatientIds().isEmpty() && distributableQuery.hasFilters()) {
// NULL (representing no phenotypic filters, i.e. all patients) or not empty patient ID sets require a genomic query.
// Otherwise, short circuit and return no patients
if ((distributableQuery.getPatientIds() == null || !distributableQuery.getPatientIds().isEmpty()) && distributableQuery.hasFilters()) {
Mono<BigInteger> patientMaskForVariantInfoFilters = genomicProcessor.getPatientMask(distributableQuery);
return patientMaskForVariantInfoFilters.map(genomicProcessor::patientMaskToPatientIdSet).block();
}

return distributableQuery.getPatientIds();
}

Expand All @@ -154,17 +155,12 @@ private DistributableQuery getDistributableQuery(Query query) {
patientIdSets.add(new HashSet<>()); // if an invalid path is supplied, no patients should match.
}

Set<Integer> phenotypicPatientSet;
Set<Integer> phenotypicPatientSet = null;
//AND logic to make sure all patients match each filter
if(!patientIdSets.isEmpty()) {
phenotypicPatientSet = applyBooleanLogic(patientIdSets);
} else {
// if there are no patient filters, use all patients.
// todo: we should not have to send these
phenotypicPatientSet = genomicProcessor.getPatientIds().stream()
.map(String::trim)
.map(Integer::parseInt)
.collect(Collectors.toSet());
// if there are no patient filters, represent with null. 0 patients means no patients matched the filter
}
distributableQuery.setVariantInfoFilters(query.getVariantInfoFilters());
distributableQuery.setPatientIds(phenotypicPatientSet);
Expand Down Expand Up @@ -197,6 +193,9 @@ public Set<Integer> getPatientSubsetForQuery(Query query) {
}else {
idList = new TreeSet<>(applyBooleanLogic(patientIdSet));
}*/
if (patientIdSet == null) {
return phenotypeMetaStore.getPatientIds();
}
return patientIdSet;
}

Expand Down

0 comments on commit 120152f

Please sign in to comment.