@Test public void queryByFamilyWithoutStudy() throws CatalogException { VariantQueryException e = VariantQueryException.missingStudyFor("family", "f1", Collections.emptyList()); thrown.expectMessage(e.getMessage()); thrown.expect(e.getClass()); queryUtils.parseQuery(new Query(FAMILY.key(), "f1"), sessionId); }
@Test public void testGetAllVariants_fileNotFound() { VariantQueryException e = VariantQueryException.missingStudyForFile("-1", Collections.singletonList(studyConfiguration.getStudyName())); thrown.expectMessage(e.getMessage()); thrown.expect(e.getClass()); count(new Query(FILE.key(), -1)); // assertEquals("There is no file with ID -1", 0, numResults); }
@Test public void testGetAllVariants_functionalScore_wrongValue() { String value = "cadd_scaled<=A"; VariantQueryException expected = VariantQueryException.malformedParam(ANNOT_FUNCTIONAL_SCORE, value); thrown.expect(expected.getClass()); thrown.expectMessage(expected.getMessage()); query(new Query(ANNOT_FUNCTIONAL_SCORE.key(), value), null); }
@Test public void testGetAllVariants_conservationScoreWrongValue() { VariantQueryException e = VariantQueryException.malformedParam(ANNOT_CONSERVATION, "phastCons<a"); thrown.expect(e.getClass()); thrown.expectMessage(e.getMessage()); query(new Query(ANNOT_CONSERVATION.key(), "phastCons<a"), null); }
@Test public void testGetAllVariants_functionalScore_wrongSource() { String value = "cad<=0.5"; VariantQueryException expected = VariantQueryException.malformedParam(ANNOT_FUNCTIONAL_SCORE, value); thrown.expect(expected.getClass()); thrown.expectMessage(expected.getMessage()); query(new Query(ANNOT_FUNCTIONAL_SCORE.key(), value), null); }
@Test public void testGetAllVariants_conservationScoreWrongSource() { VariantQueryException e = VariantQueryException.malformedParam(ANNOT_CONSERVATION, "phast<0.5"); thrown.expect(e.getClass()); thrown.expectMessage(e.getMessage()); query(new Query(ANNOT_CONSERVATION.key(), "phast<0.5"), null); }
@Test public void testFailTraitWithoutSearch() throws StorageEngineException { VariantQueryException exception = VariantQueryException.unsupportedVariantQueryFilter(VariantQueryParam.ANNOT_TRAIT, variantStorageEngine.getStorageEngineId()); thrown.expect(exception.getClass()); thrown.expectMessage(exception.getMessage()); variantStorageEngine.doIntersectWithSearch(new Query(ANNOT_TRAIT.key(), "myTrait"), new QueryOptions(USE_SEARCH_INDEX, VariantStorageEngine.UseSearchIndex.NO)); }
@Test public void parseWrongFormat() { QueryOptions queryOptions = new QueryOptions(); Query query = new Query(); query.put(STUDY.key(), studyName); query.put(FORMAT.key(), "NA12877:AC>200"); try { solrQueryParser.parse(query, queryOptions); } catch (VariantQueryException e) { System.out.println("Success, exception caught!! " + e.getMessage()); return; } fail(); }
@Test public void queryByFamilyMissingModeOfInheritance() throws CatalogException { VariantQueryException e = VariantQueryException.malformedParam(FAMILY_PHENOTYPE, "asdf", "Require parameter \"family\" and \"modeOfInheritance\" to use \"familyDisease\"."); thrown.expectMessage(e.getMessage()); thrown.expect(e.getClass()); queryUtils.parseQuery(new Query(STUDY.key(), "s1").append(FAMILY.key(), "f1").append(FAMILY_PHENOTYPE.key(), "asdf"), sessionId); }
@Test public void testGetAllVariants_cohorts_fail1() throws Exception { VariantQueryException expected = VariantQueryException.cohortNotFound("cohort5_dont_exists", 1, studyConfiguration.getCohortIds().keySet()); thrown.expect(expected.getClass()); thrown.expectMessage(expected.getMessage()); queryResult = query(new Query(STUDY.key(), 1) .append(COHORT.key(), "!cohort5_dont_exists"), null); }
@Test public void testFailSearchNotAvailable() throws StorageEngineException { VariantQueryException exception = new VariantQueryException("Unable to use search index. SearchEngine is not available"); thrown.expect(exception.getClass()); thrown.expectMessage(exception.getMessage()); variantStorageEngine.getConfiguration().getSearch().setActive(false); variantStorageEngine.doIntersectWithSearch(new Query(ANNOT_TRAIT.key(), "myTrait"), new QueryOptions(USE_SEARCH_INDEX, VariantStorageEngine.UseSearchIndex.YES)); }
@Test public void testGetAllVariants_genes() { Query query = new Query(GENE.key(), "FLG-AS1"); QueryResult<Variant> result = query(query, new QueryOptions()); assertThat(result, everyResult(allVariants, hasAnnotation(hasGenes(Collections.singletonList("FLG-AS1"))))); for (Variant variant : result.getResult()) { System.out.println("variant = " + variant); } query = new Query(GENE.key(), "WRONG_GENE"); VariantQueryException exception = VariantQueryException.geneNotFound("WRONG_GENE"); thrown.expect(exception.getClass()); thrown.expectMessage(exception.getMessage()); result = query(query, new QueryOptions()); }
@Test public void sampleWrongRelease() throws Exception { VariantQueryException e = VariantCatalogQueryUtils.wrongReleaseException(VariantQueryParam.SAMPLE, "sample3", 1); thrown.expectMessage(e.getMessage()); thrown.expect(e.getClass()); queryUtils.parseQuery(new Query(VariantQueryParam.SAMPLE.key(), "sample3") .append(VariantQueryParam.STUDY.key(), "s1") .append(VariantQueryParam.RELEASE.key(), 1), sessionId).toJson(); }
@Test public void includeFileWrongRelease() throws Exception { VariantQueryException e = VariantCatalogQueryUtils.wrongReleaseException(VariantQueryParam.INCLUDE_FILE, "file3.vcf", 1); thrown.expectMessage(e.getMessage()); thrown.expect(e.getClass()); queryUtils.parseQuery(new Query(VariantQueryParam.INCLUDE_FILE.key(), "file3.vcf") .append(VariantQueryParam.STUDY.key(), "s1") .append(VariantQueryParam.RELEASE.key(), 1), sessionId).toJson(); }
@Test public void fileWrongRelease() throws Exception { VariantQueryException e = VariantCatalogQueryUtils.wrongReleaseException(VariantQueryParam.FILE, "file3.vcf", 1); thrown.expectMessage(e.getMessage()); thrown.expect(e.getClass()); queryUtils.parseQuery(new Query(VariantQueryParam.FILE.key(), "file3.vcf") .append(VariantQueryParam.STUDY.key(), "s1") .append(VariantQueryParam.RELEASE.key(), 1), sessionId).toJson(); }
@Test public void cohortWrongRelease() throws Exception { VariantQueryException e = VariantCatalogQueryUtils.wrongReleaseException(VariantQueryParam.COHORT, "c2", 1); thrown.expectMessage(e.getMessage()); thrown.expect(e.getClass()); queryUtils.parseQuery(new Query(VariantQueryParam.COHORT.key(), "c2") .append(VariantQueryParam.STUDY.key(), "s1") .append(VariantQueryParam.RELEASE.key(), 1), sessionId).toJson(); }
@Test public void includeSampleWrongRelease() throws Exception { VariantQueryException e = VariantCatalogQueryUtils.wrongReleaseException(VariantQueryParam.INCLUDE_SAMPLE, "sample3", 1); thrown.expectMessage(e.getMessage()); thrown.expect(e.getClass()); queryUtils.parseQuery(new Query(VariantQueryParam.INCLUDE_SAMPLE.key(), "sample3") .append(VariantQueryParam.STUDY.key(), "s1") .append(VariantQueryParam.RELEASE.key(), 1), sessionId).toJson(); }
@Test public void cohortStatsWrongRelease() throws Exception { VariantQueryException e = VariantCatalogQueryUtils.wrongReleaseException(VariantQueryParam.STATS_MAF, "c2", 1); thrown.expectMessage(e.getMessage()); thrown.expect(e.getClass()); queryUtils.parseQuery(new Query(VariantQueryParam.STATS_MAF.key(), "c2>0.2") .append(VariantQueryParam.STUDY.key(), "s1") .append(VariantQueryParam.RELEASE.key(), 1), sessionId).toJson(); }
@Test public void queryByFamilyUnknownDisease() throws CatalogException { VariantQueryException e = VariantQueryException.malformedParam(FAMILY_PHENOTYPE, "asdf", "Available phenotypes: [phenotype]"); thrown.expectMessage(e.getMessage()); thrown.expect(e.getClass()); queryUtils.parseQuery(new Query(STUDY.key(), "s1") .append(FAMILY.key(), "f1") .append(MODE_OF_INHERITANCE.key(), "monoallelic") .append(FAMILY_PHENOTYPE.key(), "asdf"), sessionId); }
@Test public void testGetAllVariants_mixInfoFileOperators() { VariantQueryResult<Variant> allVariants = dbAdaptor.get(new Query() .append(VariantQueryParam.INCLUDE_STUDY.key(), "S_1") .append(VariantQueryParam.INCLUDE_SAMPLE.key(), "NA12877,NA12878") .append(VariantQueryParam.INCLUDE_FILE.key(), file12877 + "," + file12878), options); thrown.expect(VariantQueryException.class); thrown.expectMessage(VariantQueryException.mixedAndOrOperators(FILE, INFO).getMessage()); query = new Query(STUDY.key(), "S_1") .append(FILE.key(), file12877 + OR + file12878) .append(INFO.key(), "1K.end.platinum-genomes-vcf-NA12877_S1.genome.vcf.gz:HaplotypeScore<10" + AND + "1K.end.platinum-genomes-vcf-NA12878_S1.genome.vcf.gz:DP>100"); queryResult = query(query, new QueryOptions()); System.out.println("queryResult.getNumResults() = " + queryResult.getNumResults()); assertThat(queryResult, everyResult(allVariants, withStudy("S_1", allOf( withFileId(file12877, withAttribute("HaplotypeScore", asNumber(lt(10))) ), withFileId(file12878, withAttribute("DP", asNumber(gt(100))) ) )))); }