Skip to content

Commit

Permalink
Fix intersection/union of variant filters bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ramari16 committed Jan 2, 2024
1 parent 08f66ba commit 66c2055
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,16 @@ public BigInteger runGetPatientMask(DistributableQuery distributableQuery) {
List<VariantIndex> 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
Expand Down Expand Up @@ -183,6 +189,7 @@ private List<VariantIndex> getVariantIndicesForCategoryFilter(Map.Entry<String,
List<String> infoKeys = filterInfoCategoryKeys(values, infoStore);

if(infoKeys.size()>1) {
// These should be ANDed
return infoKeys.stream()
.map(key -> variantIndexCache.get(column, key))
.collect(Collectors.toList());
Expand Down

0 comments on commit 66c2055

Please sign in to comment.