private void queryGeneCT(String gene, String so, Query query, Matcher<VariantAnnotation> regionMatcher) { logger.info(query.toJson()); queryResult = query(query, null); logger.info(" -> numResults " + queryResult.getNumResults()); Matcher<String> geneMatcher; List<String> genes = Arrays.asList(gene.split(",")); if (gene.contains(",")) { geneMatcher = anyOf(genes.stream().map(CoreMatchers::is).collect(Collectors.toList())); } else { geneMatcher = is(gene); } assertThat(queryResult, everyResult(allVariants, hasAnnotation( anyOf( allOf( hasAnyGeneOf(genes), withAny("consequence type", VariantAnnotation::getConsequenceTypes, allOf( with("gene", ConsequenceType::getGeneName, geneMatcher), withAny("SO", ConsequenceType::getSequenceOntologyTerms, with("accession", SequenceOntologyTerm::getAccession, is(so)))))) , allOf( regionMatcher, // not(hasAnyGeneOf(genes)), hasSO(hasItem(so)) ))))); }
assertThat(queryResult, everyResult(allVariants, hasAnnotation(hasSO(hasItem("SO:0001566"))))); assertThat(queryResult, numResults(gt(0))); assertThat(queryResult, everyResult(allVariants, hasAnnotation(hasSO(hasItem("SO:0001566"))))); assertThat(queryResult, numResults(gt(0))); assertThat(queryResult, everyResult(allVariants, hasAnnotation(hasSO(anyOf(hasItem("SO:0001566"), hasItem("SO:0001583")))))); assertThat(queryResult, numResults(gt(0))); assertThat(queryResult, everyResult(allVariants, hasAnnotation(hasSO(anyOf(hasItem("SO:0001566"), hasItem("SO:0001583")))))); assertThat(queryResult, numResults(gt(0))); assertThat(queryResult, everyResult(allVariants, hasAnnotation(hasSO(anyOf(hasItem("SO:0001566"), hasItem("SO:0001583")))))); assertThat(queryResult, numResults(gt(0))); assertThat(queryResult, everyResult(allVariants, hasAnnotation(hasSO(allOf(hasItem("SO:0001566"), hasItem("SO:0001583")))))); assertThat(queryResult, numResults(gt(0)));
@Test public void testGetAllVariants_ct_gene() { queryGeneCT("BIRC6", "SO:0001566"); // Should return 0 results queryGeneCT("BIRC6", "SO:0001583"); queryGeneCT("DNAJC6", "SO:0001819"); queryGeneCT("SH2D5", "SO:0001632"); queryGeneCT("ERMAP,SH2D5", "SO:0001632"); queryGeneCT("ERMAP,SH2D5", "SO:0001632", new Query() .append(ANNOT_XREF.key(), "ERMAP,SH2D5,7:100807230:G:T") .append(ANNOT_CONSEQUENCE_TYPE.key(), "SO:0001632"), at("7:100807230:G:T")); queryGeneCT("ERMAP,SH2D5", "SO:0001632", new Query() .append(GENE.key(), "ERMAP") .append(ANNOT_XREF.key(), "SH2D5,rs12345") .append(ANNOT_CONSEQUENCE_TYPE.key(), "SO:0001632"), with("id", VariantAnnotation::getId, is("rs1171830"))); queryGeneCT("ERMAP,SH2D5", "SO:0001632", new Query() .append(ANNOT_XREF.key(), "ERMAP,rs1171830,SH2D5,RCV000036856,7:100807230:G:T,COSM3760638") .append(ANNOT_CONSEQUENCE_TYPE.key(), "SO:0001632"), anyOf( with("id", VariantAnnotation::getId, is("rs1171830")), at("7:100807230:G:T"))); assertThat(query(new Query(ANNOT_XREF.key(), "rs1171830").append(ANNOT_CONSEQUENCE_TYPE.key(), "SO:0001566"), null), everyResult(allVariants, allOf( with("id", Variant::getId, is("rs1171830")), hasAnnotation(hasSO(hasItem(is("SO:0001566"))))))); }