From 66c205534216fdf7307a0104f48ffd097f56525f Mon Sep 17 00:00:00 2001 From: Ryan Amari Date: Tue, 2 Jan 2024 09:23:19 -0800 Subject: [PATCH] Fix intersection/union of variant filters bug --- .../hpds/processing/GenomicProcessorNodeImpl.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/GenomicProcessorNodeImpl.java b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/GenomicProcessorNodeImpl.java index 9d2e4e39..e11a1be6 100644 --- a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/GenomicProcessorNodeImpl.java +++ b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/GenomicProcessorNodeImpl.java @@ -89,10 +89,16 @@ public BigInteger runGetPatientMask(DistributableQuery distributableQuery) { List variantSets = getVariantsMatchingFilters(filter); log.info("Found " + variantSets.size() + " groups of sets for patient identification"); if(!variantSets.isEmpty()) { - // INTERSECT all the variant sets. - intersectionOfInfoFilters = variantSets.get(0); + // todo: and/or distinction missing + VariantIndex unionOfVariantSets = new SparseVariantIndex(Set.of()); for(VariantIndex variantSet : variantSets) { - intersectionOfInfoFilters = intersectionOfInfoFilters.intersection(variantSet); + unionOfVariantSets = unionOfVariantSets.union(variantSet); + } + + if (intersectionOfInfoFilters == null) { + intersectionOfInfoFilters = unionOfVariantSets; + } else { + intersectionOfInfoFilters = intersectionOfInfoFilters.intersection(unionOfVariantSets); } } else { // todo: create an empty variant index implementation @@ -183,6 +189,7 @@ private List getVariantIndicesForCategoryFilter(Map.Entry infoKeys = filterInfoCategoryKeys(values, infoStore); if(infoKeys.size()>1) { + // These should be ANDed return infoKeys.stream() .map(key -> variantIndexCache.get(column, key)) .collect(Collectors.toList());