Skip to content

Commit

Permalink
Merge pull request #2556 from opencb/TASK-7439
Browse files Browse the repository at this point in the history
TASK-7439 - Variant Browsers shows a VariantQueryException when running aggregation stats
  • Loading branch information
jtarraga authored Mar 3, 2025
2 parents f8c8336 + c037e30 commit 2bb8e03
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
Expand Down Expand Up @@ -224,6 +225,48 @@ public void testSpecialCharacter() throws Exception {
}
}

@Test
public void testTypeFacet() throws Exception {
int limit = 500;

VariantStorageMetadataManager scm = variantStorageEngine.getMetadataManager();

solr.configure(variantStorageEngine);
VariantSearchManager variantSearchManager = variantStorageEngine.getVariantSearchManager();

System.out.println(smallInputUri.getPath());

List<Variant> variants = getVariants(limit);
List<Variant> annotatedVariants = annotatedVariants(variants);

metadataManager.createStudy("s1");

String collection = solr.coreName;
variantSearchManager.create(collection);

variantSearchManager.insert(collection, annotatedVariants);

QueryOptions queryOptions = new QueryOptions();
String facet = "type[INDEL,SNV]";
queryOptions.put(QueryOptions.FACET, facet);
DataResult<FacetField> facetQueryResult = variantSearchManager.facetedQuery(collection, new Query(), queryOptions);
String s = JacksonUtils.getDefaultObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(facetQueryResult);
System.out.println(s);

FacetField facetField = facetQueryResult.first();
Assert.assertEquals(499, facetField.getCount());
Assert.assertEquals(2, facetField.getBuckets().size());
Assert.assertTrue(facetField.getBuckets().stream().map(FacetField.Bucket::getValue).collect(Collectors.toList()).contains("SNV"));
Assert.assertTrue(facetField.getBuckets().stream().map(FacetField.Bucket::getValue).collect(Collectors.toList()).contains("INDEL"));
for (FacetField.Bucket bucket : facetField.getBuckets()) {
if (bucket.getValue().equals("SNV")) {
Assert.assertEquals(490, bucket.getCount());
} else if (bucket.getValue().equals("INDEL")) {
Assert.assertEquals(9, bucket.getCount());
}
}
}

@Test
public void testGeneFacet() throws Exception {
int limit = 500;
Expand Down

0 comments on commit 2bb8e03

Please sign in to comment.