/** * Build an OR/AND-condition with all consequence types from the input list. It uses the VariantDBAdaptorUtils * to parse the consequence type (accession or term) into an integer. * * @param cts List of consequence types * @param op Boolean operator (OR / AND) * @return OR/AND-condition string */ private String buildConsequenceTypeOrAnd(List<String> cts, String op) { StringBuilder sb = new StringBuilder(); for (String ct : cts) { if (sb.length() > 0) { sb.append(op); } sb.append("soAcc:\"").append(VariantQueryUtils.parseConsequenceType(ct)).append("\""); } return sb.toString(); }
/** * Build the condition: genes AND cts. * * @param genes List of genes * @param cts List of consequence types * @return OR/AND condition string */ private String buildGeneAndConsequenceType(List<String> genes, List<String> cts) { // in the VariantSearchModel the (gene AND ct) is modeled in the field: geneToSoAcc:gene_ct // and if there are multiple genes and consequence types, we have to build the combination of all of them in a OR expression StringBuilder sb = new StringBuilder(); for (String gene: genes) { for (String ct: cts) { if (sb.length() > 0) { sb.append(" OR "); } sb.append("geneToSoAcc:\"").append(gene).append("_").append(VariantQueryUtils.parseConsequenceType(ct)) .append("\""); } } return sb.toString(); }
@Test public void testParseSO() throws Exception { assertEquals(1587, parseConsequenceType("stop_gained")); assertEquals(1587, parseConsequenceType("1587")); assertEquals(1587, parseConsequenceType("SO:00001587")); }
@Test public void testParseWrongSONumber2() throws Exception { thrown.expect(VariantQueryException.class); parseConsequenceType("SO:9999999"); }
@Test public void testParseWrongSOTerm() throws Exception { thrown.expect(VariantQueryException.class); parseConsequenceType("wrong_so"); }
@Test public void testParseWrongSONumber() throws Exception { thrown.expect(VariantQueryException.class); parseConsequenceType("9999999"); }
for (String gene : genes) { for (String so : soList) { int soNumber = parseConsequenceType(so); gnSoSet.add(VariantAnnotationToPhoenixConverter.buildGeneSO(gene, soNumber));
for (SequenceOntologyTerm sequenceOntologyTerm : consequenceType.getSequenceOntologyTerms()) { String accession = sequenceOntologyTerm.getAccession(); int so = parseConsequenceType(accession); addNotNull(soList, so);
for (String gene : variantQueryXref.getGenes()) { for (String so : soList) { int soNumber = parseConsequenceType(so); gnSo.add(DocumentToVariantAnnotationConverter.buildGeneSO(gene, soNumber));