protected List<String> getValuesToValidate(List<String> rawValues) { return rawValues.stream() .map(value -> { value = isNegated(value) ? removeNegation(value) : value; String[] strings = VariantQueryUtils.splitOperator(value); boolean withComparisionOperator = strings[0] != null; if (withComparisionOperator) { value = strings[0]; } return value; }) .collect(Collectors.toList()); }
private DBObject[] getFileFilterDBObjects(String key, List<String> filterValues) { DBObject[] regexList = new DBObject[filterValues.size()]; for (int i = 0; i < filterValues.size(); i++) { String filter = filterValues.get(i); boolean negated = isNegated(filter); if (negated) { filter = removeNegation(filter); } if (filter.contains(VCFConstants.FILTER_CODE_SEPARATOR) || filter.equals(VCFConstants.PASSES_FILTERS_v4)) { if (!negated) { regexList[i] = new BasicDBObject(key, filter); } else { regexList[i] = new BasicDBObject(key, new BasicDBObject("$ne", filter)); } } else { if (!negated) { regexList[i] = new BasicDBObject(key, new BasicDBObject("$regex", filter)); } else { regexList[i] = new BasicDBObject(key, new BasicDBObject("$not", Pattern.compile(filter))); } } } return regexList; }
public Integer getStudyId(Object studyObj, boolean skipNegated, Map<String, Integer> studies) { Integer studyId; if (studyObj instanceof Integer) { studyId = ((Integer) studyObj); } else { String studyName = studyObj.toString(); if (isNegated(studyName)) { //Skip negated studies if (skipNegated) { return null; } else { studyName = removeNegation(studyName); } } if (StringUtils.isNumeric(studyName)) { studyId = Integer.parseInt(studyName); } else { Integer value = studies.get(studyName); if (value == null) { throw VariantQueryException.studyNotFound(studyName, studies.keySet()); } studyId = value; } } if (!studies.containsValue(studyId)) { throw VariantQueryException.studyNotFound(studyId, studies.keySet()); } return studyId; }
/** * Parse the genotype filter. * * @param sampleGenotypes Genotypes filter value * @param map Initialized map to be filled with the sample to list of genotypes * @return QueryOperation between samples */ public static QueryOperation parseGenotypeFilter(String sampleGenotypes, Map<Object, List<String>> map) { Pair<QueryOperation, Map<String, String>> pair = parseMultiKeyValueFilter(GENOTYPE, sampleGenotypes); for (Map.Entry<String, String> entry : pair.getValue().entrySet()) { List<String> gts = splitValue(entry.getValue(), QueryOperation.OR); boolean anyNegated = false; boolean allNegated = true; for (String gt : gts) { if (isNegated(gt)) { anyNegated = true; } else { allNegated = false; } } if (!allNegated && anyNegated) { throw VariantQueryException.malformedParam(GENOTYPE, sampleGenotypes); } map.put(entry.getKey(), gts); } return pair.getKey(); }
public static boolean isValidParam(Query query, QueryParam param, boolean discardNegated) { boolean validParam = isValidParam(query, param); if (!discardNegated || !validParam) { return validParam; } else { String strValue = query.getString(param.key()); return splitValue(strValue, checkOperator(strValue)) .stream() .anyMatch((v) -> !isNegated(v)); // Discard negated } }
if (isNegated(str)) { str = removeNegation(str);
public static boolean isOutputMultiStudy(Query query, QueryOptions options, Collection<?> studies) { Set<VariantField> fields = VariantField.getIncludeFields(options); if (!fields.contains(VariantField.STUDIES)) { return false; } else if (isValidParam(query, INCLUDE_STUDY)) { String includeStudy = query.getString(VariantQueryParam.INCLUDE_STUDY.key()); if (NONE.equals(includeStudy)) { return false; } else if (ALL.equals(includeStudy)) { return studies.size() > 1; } else { return query.getAsList(VariantQueryParam.INCLUDE_STUDY.key()).size() > 1; } } else if (isValidParam(query, STUDY)) { String value = query.getString(VariantQueryParam.STUDY.key()); long numStudies = splitValue(value, checkOperator(value)).stream().filter(s -> !isNegated(s)).count(); return numStudies > 1; } else { return studies.size() > 1; } }
samples = splitValue(value, checkOperator(value)) .stream() .filter((v) -> !isNegated(v)) // Discard negated .collect(Collectors.toList());
includeFiles = splitValue(files, checkOperator(files)) .stream() .filter(value -> !isNegated(value)) .collect(Collectors.toList());
if (elem instanceof String && isNegated((String) elem)) { T mapped = map.apply((S) removeNegation((String) elem)); if (mapped instanceof Collection) { List<Object> list = new ArrayList<>(values.size()); for (S elem : values) { if (elem instanceof String && isNegated((String) elem)) { throw new VariantQueryException("Unable to use negate (!) operator in OR sequences (<it_1>(,<it_n>)*)"); } else { if (elem instanceof String && isNegated((String) elem)) { T mapped = map.apply((S) removeNegation((String) elem)); if (mapped instanceof Collection) {
valid &= !isNegated(gt);
String study = iterator.next(); Integer studyId = studyConfigurationManager.getStudyId(study, false, studies); if (isNegated(study)) { sb.append("\"").append(getStudyColumn(studyId).column()).append("\" IS NULL "); } else { if (isNegated(file)) { for (int i = 0; i < filterValues.size(); i++) { String filter = checkStringValue(filterValues.get(i)); boolean negated = isNegated(filter); if (negated) { filter = removeNegation(filter); for (String cohort : query.getAsStringList(COHORT.key())) { boolean negated = false; if (isNegated(cohort)) { cohort = removeNegation(cohort); negated = true;
} else { String sampleStr = sampleObj.toString(); if (isNegated(sampleStr)) { sampleStr = removeNegation(sampleStr);
} else { sampleIds = samples.stream() .map(sample -> isNegated(sample) ? removeNegation(sample) : sample) .map(sample -> studyConfigurationManager.getSampleId(sample, studyConfiguration)).collect(Collectors.toList()); file = isNegated(file) ? removeNegation(file) : file; Integer fileId = StudyConfigurationManager.getFileIdFromStudy(file, studyConfiguration); if (fileId == null) {
.filter(value -> !isNegated(value)) .map(value -> { Integer fileId = studyConfigurationManager.getFileIdPair(value, false, defaultStudyConfiguration).getValue(); if (isNegated(sample)) { throw VariantQueryException.malformedParam(SAMPLE, samples, "Unsupported negated samples"); for (String genotype : genotypes) { if (isNegated(genotype)) { if (defaultGenotypes.contains(removeNegation(genotype))) { canFilterSampleByFile = true; boolean negated = isNegated(genotype); if (negated) { genotype = removeNegation(genotype);
if (isNegated(fileStr)) { //Skip negated studies if (skipNegated) { return null;
@Override public Query preProcessQuery(Query originalQuery, QueryOptions options) throws StorageEngineException { Query query = super.preProcessQuery(originalQuery, options); List<String> studyNames = studyConfigurationManager.getStudyNames(QueryOptions.empty()); CellBaseUtils cellBaseUtils = getCellBaseUtils(); if (isValidParam(query, VariantQueryParam.STUDY) && studyNames.size() == 1 && !isNegated(query.getString(VariantQueryParam.STUDY.key())) && !isValidParam(query, FILE) && !isValidParam(query, FILTER) && !isValidParam(query, QUAL) && !isValidParam(query, INFO) && !isValidParam(query, SAMPLE) && !isValidParam(query, FORMAT) && !isValidParam(query, GENOTYPE)) { query.remove(VariantQueryParam.STUDY.key()); } convertGoToGeneQuery(query, cellBaseUtils); convertExpressionToGeneQuery(query, cellBaseUtils); return query; }
Pair<Integer, Integer> fileIdPair = studyConfigurationManager.getFileIdPair(file, false, defaultStudyConfiguration); byte[] column = buildFileColumnKey(fileIdPair.getKey(), fileIdPair.getValue()); if (isNegated(file)) { subFilters.addFilter(missingColumnFilter(column)); } else { Integer studyId = studyConfigurationManager.getStudyId(studyStr, null); byte[] column = VariantPhoenixHelper.getStudyColumn(studyId).bytes(); if (isNegated(studyStr)) { subFilters.addFilter(missingColumnFilter(column)); scan.addColumn(family, column);