public static VariantQueryException sampleNotFound(Object sample, Object study) { return new VariantQueryException("Sample " + sample + " not found in study " + study); }
public VariantQueryResult<Variant> get(Query query, QueryOptions options) { try { return (VariantQueryResult<Variant>) getOrIterator(query, options, false); } catch (StorageEngineException e) { throw VariantQueryException.internalException(e); } }
public static VariantQueryException mixedAndOrOperators(VariantQueryParam param, String value) { return VariantQueryException.malformedParam(param, value, "Unable to mix AND (" + AND + ") and OR (" + OR + ") in the same query."); }
public static VariantQueryException missingStudyForSamples(Collection<String> samples, Collection<String> availableStudies) { if (samples.size() == 1) { return missingStudyForSample(samples.iterator().next(), availableStudies); } return new VariantQueryException("Unknown samples " + samples + ". Please, specify the study belonging." + (availableStudies == null || availableStudies.isEmpty() ? "" : " Available studies: " + availableStudies)); }
private int parseInteger(Object value, VariantQueryParam param, String rawValue) { if (value instanceof Number) { return ((Number) value).intValue(); } else { try { return Integer.parseInt(value.toString()); } catch (NumberFormatException e) { if (param != null) { throw VariantQueryException.malformedParam(param, rawValue); } else { throw new VariantQueryException("Error parsing integer value '" + value + '\'', e); } } } }
String[] split = splitOperator(sift); if (StringUtils.isNotEmpty(split[0])) { throw VariantQueryException.malformedParam(ANNOT_SIFT, sift); throw VariantQueryException.malformedParam(ANNOT_SIFT, "Conflict with parameter \"" + ANNOT_PROTEIN_SUBSTITUTION.key() + "\""); String[] split = splitOperator(polyphen); if (StringUtils.isNotEmpty(split[0])) { throw VariantQueryException.malformedParam(ANNOT_POLYPHEN, polyphen); throw VariantQueryException.malformedParam(ANNOT_SIFT, "Conflict with parameter \"" + ANNOT_PROTEIN_SUBSTITUTION.key() + "\""); String sampleName = entry.getKey(); if (defaultStudyConfiguration == null) { throw VariantQueryException.missingStudyForSample(sampleName, getStudyConfigurationManager().getStudyNames(null)); throw VariantQueryException.sampleNotFound(sampleName, defaultStudyConfiguration.getStudyName()); VariantFileHeaderComplexLine line = defaultStudyConfiguration.getVariantHeaderLine("FORMAT", split[0]); if (line == null) { throw VariantQueryException.malformedParam(FORMAT, query.getString(FORMAT.key()), "FORMAT field \"" + split[0] + "\" not found. Available keys in study: " + defaultStudyConfiguration.getVariantHeaderLines("FORMAT").keySet()); QueryOperation fileOperator = checkOperator(query.getString(FILE.key())); if (fileOperator != null && pair.getKey() != fileOperator) { throw VariantQueryException.mixedAndOrOperators(FILE, INFO);
Integer fileId = studyConfigurationManager.getFileIdPair(value, false, defaultStudyConfiguration).getValue(); if (fileId == null) { throw VariantQueryException.fileNotFound(value, defaultStudyConfiguration.getStudyName()); throw VariantQueryException.missingStudyForFile(fileId.toString(), studyConfigurationManager.getStudyNames(null)); for (Map.Entry<String, String> entry : infoMap.entrySet()) { if (defaultStudyConfiguration == null) { throw VariantQueryException.missingStudyForFile(entry.getKey(), studyConfigurationManager.getStudyNames(null)); throw VariantQueryException.unsupportedVariantQueryFilter(FORMAT, MongoDBVariantStorageEngine.STORAGE_ENGINE_ID); throw VariantQueryException.incompatibleSampleAndGenotypeOperators(); throw VariantQueryException.malformedParam(SAMPLE, samples, "Unsupported negated samples"); .getValue(); if (fileId == null) { throw VariantQueryException.fileNotFound(value, defaultStudyConfiguration.getStudyName());
if (regions != null && !regions.isEmpty()) { if (regions.size() > 1) { throw VariantQueryException.malformedParam(REGION, regions.toString(), "Unsupported multiple region filter"); List<String> ids = query.getAsStringList(ID.key()); if (ids.size() != 1) { throw VariantQueryException.malformedParam(ID, ids.toString(), "Unsupported multiple variant ids filter"); scan.setTimeRange(ts, Long.MAX_VALUE); } catch (IOException e) { throw VariantQueryException.internalException(e); throw VariantQueryException.missingStudyForSample(entry.getKey().toString(), studyNames); throw VariantQueryException.unsupportedVariantQueryFilter(GENOTYPE, query.getString(GENOTYPE.key()), "Unable to negate genotypes."); } else if (genotypes.stream().anyMatch(VariantQueryUtils::isNegated)) { throw VariantQueryException.malformedParam(GENOTYPE, query.getString(GENOTYPE.key()), "Can not mix negated and not negated genotypes"); } else { throw VariantQueryException.unsupportedVariantQueryFilter(SAMPLE, "hbase-native-query");
if (!filterValues.isEmpty()) { if (CollectionUtils.isEmpty(includeFiles)) { throw VariantQueryException.malformedParam(FILTER, value, "Missing \"" + FILE.key() + "\" filter"); if (!qualValues.isEmpty()) { if (CollectionUtils.isEmpty(includeFiles)) { throw VariantQueryException.malformedParam(QUAL, value, "Missing \"" + FILE.key() + "\" filter"); throw new VariantQueryException("Unexpected error"); } else if (fileOperation.equals(QueryOperation.AND)) { sb.append(" AND "); studyConfiguration = defaultStudyConfiguration; } else { throw VariantQueryException.malformedParam(COHORT, query.getString((COHORT.key())), "Expected {study}:{cohort}"); throw VariantQueryException.incompatibleSampleAndGenotypeOperators(); if (defaultStudyConfiguration == null) { List<String> studyNames = studyConfigurationManager.getStudyNames(null); throw VariantQueryException.missingStudyForSample(entry.getKey().toString(), studyNames); negated = true; } else if (genotypes.stream().anyMatch(VariantQueryUtils::isNegated)) { throw VariantQueryException.malformedParam(GENOTYPE, query.getString(GENOTYPE.key()), "Can not mix negated and not negated genotypes"); } else { int release = query.getInt(RELEASE.key(), -1);
throw new VariantQueryException("Could not found samples with this annotation: " + sampleAnnotation); String familyId = query.getString(FAMILY.key()); if (StringUtils.isEmpty(defaultStudyStr)) { throw VariantQueryException.missingStudyFor("family", familyId, null); throw VariantQueryException.malformedParam(FAMILY, familyId, "Empty family"); throw VariantQueryException.malformedParam(FAMILY, familyId, "Only one member of the family is indexed in storage"); } else if (sampleUids.isEmpty()) { throw VariantQueryException.malformedParam(FAMILY, familyId, "Family not indexed in storage"); throw VariantQueryException.malformedParam(MODE_OF_INHERITANCE, query.getString(MODE_OF_INHERITANCE.key()), "Can not be used along with filter \"" + GENOTYPE.key() + '"'); throw VariantQueryException.malformedParam(MODE_OF_INHERITANCE, query.getString(MODE_OF_INHERITANCE.key()), "Can not be used along with filter \"" + SAMPLE.key() + '"'); throw VariantQueryException.malformedParam(FAMILY, familyId, "Family doesn't have phenotypes"); throw VariantQueryException.malformedParam(FAMILY, familyId, "Some individuals from this family have multiple indexed samples"); .orElse(null); if (phenotype == null) { throw VariantQueryException.malformedParam(FAMILY_PHENOTYPE, phenotypeId, "Available phenotypes: " + family.getPhenotypes() .stream()
@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); }
throw new VariantQueryException("Unable to use search index. SearchEngine is not available"); } else if (VariantQueryUtils.isValidParam(query, VariantQueryParam.ANNOT_TRAIT)) { throw VariantQueryException.unsupportedVariantQueryFilter(VariantQueryParam.ANNOT_TRAIT, getStorageEngineId(), "Search engine is required.");
if (StringUtils.isNotEmpty(query.getString(key))) { if (studies == null) { throw VariantQueryException.malformedParam(VariantQueryParam.STUDY, "", "Missing study parameter when " + " filtering by 'genotype'"); throw VariantQueryException.internalException(e); if (StringUtils.isNotEmpty(query.getString(key))) { if (studies == null) { throw VariantQueryException.malformedParam(VariantQueryParam.FORMAT, query.getString(VariantQueryParam.FORMAT.key()), "Missing study parameter when filtering by 'format'"); throw VariantQueryException.malformedParam(VariantQueryParam.FORMAT, query.getString(VariantQueryParam.FORMAT.key()), "Only one format name (and it has to be 'DP') is permitted in Solr search"); throw VariantQueryException.malformedParam(VariantQueryParam.FORMAT, query.getString(VariantQueryParam.FORMAT.key()), "Invalid format value"); first = false; } else { throw VariantQueryException.malformedParam(VariantQueryParam.FORMAT, query.getString(VariantQueryParam.FORMAT.key()), "Only format name 'DP' is permitted in Solr search");
public List<Scan> parseQueryMultiRegion(SelectVariantElements selectElements, Query query, QueryOptions options) { VariantQueryXref xrefs = VariantQueryUtils.parseXrefs(query); if (!xrefs.getOtherXrefs().isEmpty()) { throw VariantQueryException.unsupportedVariantQueryFilter(VariantQueryParam.ANNOT_XREF, HadoopVariantStorageEngine.STORAGE_ENGINE_ID, "Only variant ids are supported with HBase native query"); } else if (!xrefs.getIds().isEmpty()) { throw VariantQueryException.unsupportedVariantQueryFilter(VariantQueryParam.ID, HadoopVariantStorageEngine.STORAGE_ENGINE_ID, "Only variant ids are supported with HBase native query"); scans.add(scan); } catch (IOException e) { throw VariantQueryException.internalException(e); scans.add(scan); } catch (IOException e) { throw VariantQueryException.internalException(e);
Integer fileId = StudyConfigurationManager.getFileIdFromStudy(file, studyConfiguration, true); if (fileId == null) { throw VariantQueryException.fileNotFound(file, study); archiveHelper = getArchiveHelper(studyId, fileId); } catch (IOException | StorageEngineException e) { throw VariantQueryException.internalException(e); return new VariantHadoopArchiveDBIterator(resScan, archiveHelper, options).setRegion(region); } catch (IOException e) { throw VariantQueryException.internalException(e); return table.getScanner(scan); } catch (IOException e) { throw VariantQueryException.internalException(e); throw VariantQueryException.internalException(e); throw VariantQueryException.internalException(e);
String[] split = VariantQueryUtils.splitStudyResource(s); if (defaultStudyConfiguration == null && split.length == 1) { throw VariantQueryException.malformedParam(COHORT, s, "Expected {study}:{cohort}"); } else { String study; cohortId = StudyConfigurationManager.getCohortIdFromStudy(cohort, defaultStudyConfiguration); if (cohortId == null) { throw VariantQueryException.cohortNotFound(cohort, defaultStudyConfiguration.getStudyId(), defaultStudyConfiguration.getCohortIds().keySet());
throw VariantQueryException.mixedAndOrOperators(param, stringValue); } else { operation = QueryOperation.AND; throw VariantQueryException.mixedAndOrOperators(param, stringValue); } else { operation = QueryOperation.OR; } else { if (key.isEmpty()) { throw VariantQueryException.malformedParam(param, stringValue);
throw VariantQueryException.geneNotFound(String.join(",", missingGenes)); throw VariantQueryException.internalException(e);
@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)); }
public static void validateAnnotationQuery(Query query) { if (query == null) { return; } List<VariantQueryParam> acceptedParams = Arrays.asList(ID, REGION); List<VariantQueryParam> ignoredParams = Arrays.asList(INCLUDE_STUDY, INCLUDE_SAMPLE, INCLUDE_FILE); Set<VariantQueryParam> queryParams = VariantQueryUtils.validParams(query); queryParams.removeAll(acceptedParams); queryParams.removeAll(ignoredParams); if (!queryParams.isEmpty()) { // System.out.println("query.toJson() = " + query.toJson()); throw VariantQueryException.unsupportedVariantQueryFilters(queryParams, "Accepted params when querying annotation are : " + acceptedParams.stream() .map(QueryParam::key) .collect(Collectors.toList())); } List<String> invalidValues = new LinkedList<>(); for (String s : query.getAsStringList(ID.key())) { if (!VariantQueryUtils.isVariantId(s)) { invalidValues.add(s); break; } } if (!invalidValues.isEmpty()) { throw VariantQueryException.malformedParam(ID, invalidValues.toString(), "Only variants supported: chrom:start:ref:alt"); } }