org.opencb.commons.datastore.core.Query.remove()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(13.7k)|赞(0)|评价(0)|浏览(94)

本文整理了Java中org.opencb.commons.datastore.core.Query.remove方法的一些代码示例,展示了Query.remove的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.remove方法的具体详情如下:
包路径:org.opencb.commons.datastore.core.Query
类名称:Query
方法名:remove

Query.remove介绍

暂无

代码示例

代码示例来源:origin: opencb/opencga

/**
 * Changes the format of the queries. Queries retrieved from the WS come as "annotation": "nestedKey.subkey=5,sex=male".
 * That will be changed to "annotation.nestedKey.subkey" : "=5"; "annotation.sex": "=male"
 *
 * @param queryKey queryKey
 * @param query queryObject
 */
public static void fixComplexQueryParam(String queryKey, Query query) {
  if (!query.containsKey(queryKey)) {
    return;
  }
  List<String> valueList = query.getAsStringList(queryKey, ";");
  for (String annotation : valueList) {
    Matcher matcher = ANNOTATION_PATTERN.matcher(annotation);
    String key;
    String queryValueString;
    if (matcher.find()) {
      key = matcher.group(1);
      if (!key.startsWith(queryKey + ".")) {
        key = queryKey + "." + key;
      }
      queryValueString = matcher.group(2);
      query.append(key, queryValueString);
    }
  }
  // Remove the current query
  query.remove(queryKey);
}

代码示例来源:origin: opencb/opencga

private void fixQueryObject(Study study, Query query, String sessionId) throws CatalogException {
  // The individuals introduced could be either ids or names. As so, we should use the smart resolutor to do this.
  if (StringUtils.isNotEmpty(query.getString(SampleDBAdaptor.QueryParams.INDIVIDUAL.key()))) {
    MyResources<Individual> resource = catalogManager.getIndividualManager().getUids(
        query.getAsStringList(SampleDBAdaptor.QueryParams.INDIVIDUAL.key()), study.getFqn(), sessionId);
    query.put(SampleDBAdaptor.QueryParams.INDIVIDUAL_UID.key(), resource.getResourceList().stream().map(Individual::getUid)
        .collect(Collectors.toList()));
    query.remove(SampleDBAdaptor.QueryParams.INDIVIDUAL.key());
  }
}

代码示例来源:origin: opencb/opencga

private void fixQueryObject(Study study, Query query, String sessionId) throws CatalogException {
  if (query.containsKey("inputFiles")) {
    MyResources<File> resource = catalogManager.getFileManager().getUids(query.getAsStringList("inputFiles"), study.getFqn(),
        sessionId);
    query.put(JobDBAdaptor.QueryParams.INPUT_UID.key(), resource.getResourceList().stream().map(File::getUid)
        .collect(Collectors.toList()));
    query.remove("inputFiles");
  }
  if (query.containsKey("outputFiles")) {
    MyResources<File> resource = catalogManager.getFileManager().getUids(query.getAsStringList("outputFiles"), study.getFqn(),
        sessionId);
    query.put(JobDBAdaptor.QueryParams.OUTPUT_UID.key(), resource.getResourceList().stream().map(File::getUid)
        .collect(Collectors.toList()));
    query.remove("outputFiles");
  }
}

代码示例来源:origin: opencb/opencga

void fixQueryObject(Study study, Query query, String sessionId) throws CatalogException {
  if (StringUtils.isNotEmpty(query.getString(FileDBAdaptor.QueryParams.ID.key()))) {
    MyResources<File> uids = getUids(query.getAsStringList(FileDBAdaptor.QueryParams.ID.key()), study.getFqn(), sessionId);
    query.remove(FileDBAdaptor.QueryParams.ID.key());
    query.put(FileDBAdaptor.QueryParams.UID.key(), uids.getResourceList().stream().map(File::getUid).collect(Collectors.toList()));
  }
  // The samples introduced could be either ids or names. As so, we should use the smart resolutor to do this.
  if (StringUtils.isNotEmpty(query.getString(FileDBAdaptor.QueryParams.SAMPLES.key()))) {
    MyResources<Sample> resource = catalogManager.getSampleManager().getUids(
        query.getAsStringList(FileDBAdaptor.QueryParams.SAMPLES.key()), study.getFqn(), sessionId);
    query.put(FileDBAdaptor.QueryParams.SAMPLE_UIDS.key(), resource.getResourceList().stream().map(Sample::getUid)
        .collect(Collectors.toList()));
    query.remove(FileDBAdaptor.QueryParams.SAMPLES.key());
  }
}

代码示例来源:origin: opencb/opencga

private void fixQueryObject(Study study, Query query, String sessionId) throws CatalogException {
  if (query.containsKey(CohortDBAdaptor.QueryParams.SAMPLES.key())) {
    // First look for the sample ids.
    MyResources<Sample> samples = catalogManager.getSampleManager()
        .getUids(query.getAsStringList(CohortDBAdaptor.QueryParams.SAMPLES.key()), study.getFqn(), sessionId);
    query.remove(CohortDBAdaptor.QueryParams.SAMPLES.key());
    query.append(CohortDBAdaptor.QueryParams.SAMPLE_UIDS.key(), samples.getResourceList().stream().map(Sample::getUid)
        .collect(Collectors.toList()));
  }
}

代码示例来源:origin: opencb/opencga

bsonQueryList.add(Filters.or(samplesQuery));
query.remove(idQueried);
query.remove(VERSION);

代码示例来源:origin: opencb/opencga

query.remove(ProjectDBAdaptor.QueryParams.STUDY.key());
if (CollectionUtils.isNotEmpty(idList)) {
  query.put(ProjectDBAdaptor.QueryParams.STUDY_UID.key(), StringUtils.join(idList, ","));

代码示例来源:origin: opencb/opencga

private void fixQuery(Study study, Query query, String sessionId) throws CatalogException {
  if (StringUtils.isNotEmpty(query.getString(IndividualDBAdaptor.QueryParams.FATHER.key()))) {
    MyResource resource = getUid(query.getString(IndividualDBAdaptor.QueryParams.FATHER.key()), study.getFqn(), sessionId);
    query.remove(IndividualDBAdaptor.QueryParams.FATHER.key());
    query.append(IndividualDBAdaptor.QueryParams.FATHER_UID.key(), resource.getResource().getUid());
  }
  if (StringUtils.isNotEmpty(query.getString(IndividualDBAdaptor.QueryParams.MOTHER.key()))) {
    MyResource resource = getUid(query.getString(IndividualDBAdaptor.QueryParams.MOTHER.key()), study.getFqn(), sessionId);
    query.remove(IndividualDBAdaptor.QueryParams.MOTHER.key());
    query.append(IndividualDBAdaptor.QueryParams.MOTHER_UID.key(), resource.getResource().getUid());
  }
  if (StringUtils.isNotEmpty(query.getString(IndividualDBAdaptor.QueryParams.SAMPLES.key()))) {
    MyResources<Sample> resource = catalogManager.getSampleManager().getUids(
        query.getString(IndividualDBAdaptor.QueryParams.SAMPLES.key()), study.getFqn(), sessionId);
    query.remove(IndividualDBAdaptor.QueryParams.SAMPLES.key());
    query.append(IndividualDBAdaptor.QueryParams.SAMPLE_UIDS.key(), resource.getResourceList().stream().map(Sample::getUid)
        .collect(Collectors.toList()));
  }
}

代码示例来源:origin: opencb/opencga

@Override
public Query preProcessQuery(Query originalQuery, QueryOptions options) throws StorageEngineException {
  Query query = super.preProcessQuery(originalQuery, options);
  StudyConfigurationManager studyConfigurationManager = getStudyConfigurationManager();
  List<String> studyNames = studyConfigurationManager.getStudyNames(QueryOptions.empty());
  CellBaseUtils cellBaseUtils = getCellBaseUtils();
  if (isValidParam(query, STUDY) && studyNames.size() == 1) {
    query.remove(STUDY.key());
  }
  convertGoToGeneQuery(query, cellBaseUtils);
  convertExpressionToGeneQuery(query, cellBaseUtils);
  convertGenesToRegionsQuery(query, cellBaseUtils);
  return query;
}

代码示例来源:origin: opencb/opencga

query.remove(FamilyDBAdaptor.QueryParams.MEMBERS.key());
    sessionId);
query.remove(IndividualDBAdaptor.QueryParams.SAMPLES.key());
if (individualResult.getNumResults() == 0) {

代码示例来源:origin: opencb/opencga

/**
 * Copy the given query and remove all uncovered params.
 *
 * @param query Query
 * @return      Query for the search engine
 */
public static Query getSearchEngineQuery(Query query) {
  Collection<VariantQueryParam> uncoveredParams = uncoveredParams(query);
  Query searchEngineQuery = new Query(query);
  for (VariantQueryParam uncoveredParam : uncoveredParams) {
    searchEngineQuery.remove(uncoveredParam.key());
  }
  searchEngineQuery.put(INCLUDE_SAMPLE.key(), NONE);
  searchEngineQuery.put(INCLUDE_FILE.key(), NONE);
  searchEngineQuery.put(INCLUDE_FORMAT.key(), NONE);
  searchEngineQuery.put(INCLUDE_GENOTYPE.key(), false);
  return searchEngineQuery;
}

代码示例来源:origin: opencb/opencga

@Override
public QueryResult groupBy(@Nullable String studyStr, Query query, List<String> fields, QueryOptions options, String sessionId)
    throws CatalogException {
  query = ParamUtils.defaultObject(query, Query::new);
  options = ParamUtils.defaultObject(options, QueryOptions::new);
  if (fields == null || fields.size() == 0) {
    throw new CatalogException("Empty fields parameter.");
  }
  String userId = userManager.getUserId(sessionId);
  Study study = catalogManager.getStudyManager().resolveId(studyStr, userId);
  // Fix query if it contains any annotation
  AnnotationUtils.fixQueryAnnotationSearch(study, userId, query, authorizationManager);
  AnnotationUtils.fixQueryOptionAnnotation(options);
  // Add study id to the query
  query.put(SampleDBAdaptor.QueryParams.STUDY_UID.key(), study.getUid());
  if (StringUtils.isNotEmpty(query.getString(SampleDBAdaptor.QueryParams.INDIVIDUAL.key()))) {
    String individualStr = query.getString(SampleDBAdaptor.QueryParams.INDIVIDUAL.key());
    if (NumberUtils.isCreatable(individualStr) && Long.parseLong(individualStr) <= 0) {
      query.put(SampleDBAdaptor.QueryParams.INDIVIDUAL_UID.key(), -1);
    } else {
      MyResource resource = catalogManager.getIndividualManager().getUid(individualStr, studyStr, sessionId);
      query.put(SampleDBAdaptor.QueryParams.INDIVIDUAL_UID.key(), resource.getResource().getUid());
    }
    query.remove(SampleDBAdaptor.QueryParams.INDIVIDUAL.key());
  }
  QueryResult queryResult = sampleDBAdaptor.groupBy(query, fields, options, userId);
  return ParamUtils.defaultObject(queryResult, QueryResult::new);
}

代码示例来源:origin: org.opencb.cellbase/cellbase-core

private boolean[] getRegulatoryRegionOverlaps(String chromosome, Integer start, Integer end) {
  QueryOptions queryOptions = new QueryOptions();
  queryOptions.add("exclude", "_id");
  queryOptions.add("include", "chromosome");
  queryOptions.add("limit", "1");
  // 0: overlaps any regulatory region type
  // 1: overlaps transcription factor binding site
  boolean[] overlapsRegulatoryRegion = {false, false};
  String regionString = toRegionString(chromosome, start, end);
  Query query = new Query(REGION, regionString);
  QueryResult<RegulatoryFeature> queryResult = regulationDBAdaptor
      .get(query.append(REGULATORY_REGION_FEATURE_TYPE_ATTRIBUTE, TF_BINDING_SITE), queryOptions);
  // Overlaps transcription factor binding site - it's therefore a regulatory variant
  if (queryResult.getNumResults() == 1) {
    overlapsRegulatoryRegion[0] = true;
    overlapsRegulatoryRegion[1] = true;
  // Does not overlap transcription factor binding site - check any other regulatory region type
  } else {
    query.remove(REGULATORY_REGION_FEATURE_TYPE_ATTRIBUTE);
    queryResult = regulationDBAdaptor.get(query, queryOptions);
    // Does overlap other types of regulatory regions
    if (queryResult.getNumResults() == 1) {
      overlapsRegulatoryRegion[0] = true;
    }
  }
  return overlapsRegulatoryRegion;
}

代码示例来源:origin: opencb/cellbase

private boolean[] getRegulatoryRegionOverlaps(String chromosome, Integer start, Integer end) {
  QueryOptions queryOptions = new QueryOptions();
  queryOptions.add("exclude", "_id");
  queryOptions.add("include", "chromosome");
  queryOptions.add("limit", "1");
  // 0: overlaps any regulatory region type
  // 1: overlaps transcription factor binding site
  boolean[] overlapsRegulatoryRegion = {false, false};
  String regionString = toRegionString(chromosome, start, end);
  Query query = new Query(REGION, regionString);
  QueryResult<RegulatoryFeature> queryResult = regulationDBAdaptor
      .get(query.append(REGULATORY_REGION_FEATURE_TYPE_ATTRIBUTE, TF_BINDING_SITE), queryOptions);
  // Overlaps transcription factor binding site - it's therefore a regulatory variant
  if (queryResult.getNumResults() == 1) {
    overlapsRegulatoryRegion[0] = true;
    overlapsRegulatoryRegion[1] = true;
  // Does not overlap transcription factor binding site - check any other regulatory region type
  } else {
    query.remove(REGULATORY_REGION_FEATURE_TYPE_ATTRIBUTE);
    queryResult = regulationDBAdaptor.get(query, queryOptions);
    // Does overlap other types of regulatory regions
    if (queryResult.getNumResults() == 1) {
      overlapsRegulatoryRegion[0] = true;
    }
  }
  return overlapsRegulatoryRegion;
}

代码示例来源:origin: opencb/opencga

@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;
}

代码示例来源:origin: opencb/opencga

.getUid(query.getString(ClinicalAnalysisDBAdaptor.QueryParams.FAMILY.key()), study.getFqn(), sessionId);
query.put(ClinicalAnalysisDBAdaptor.QueryParams.FAMILY_UID.key(), familyResource.getResource().getUid());
query.remove(ClinicalAnalysisDBAdaptor.QueryParams.FAMILY.key());
    sessionId);
query.put(ClinicalAnalysisDBAdaptor.QueryParams.SAMPLE_UID.key(), sampleResource.getResource().getUid());
query.remove("sample");
    .getUid(query.getString(ClinicalAnalysisDBAdaptor.QueryParams.PROBAND.key()), study.getFqn(), sessionId);
query.put(ClinicalAnalysisDBAdaptor.QueryParams.PROBAND_UID.key(), probandResource.getResource().getUid());
query.remove(ClinicalAnalysisDBAdaptor.QueryParams.PROBAND.key());
    .getUid(query.getString(ClinicalAnalysisDBAdaptor.QueryParams.GERMLINE.key()), study.getFqn(), sessionId);
query.put(ClinicalAnalysisDBAdaptor.QueryParams.GERMLINE_UID.key(), resource.getResource().getUid());
query.remove(ClinicalAnalysisDBAdaptor.QueryParams.GERMLINE.key());
    .getUid(query.getString(ClinicalAnalysisDBAdaptor.QueryParams.SOMATIC.key()), study.getFqn(), sessionId);
query.put(ClinicalAnalysisDBAdaptor.QueryParams.SOMATIC_UID.key(), resource.getResource().getUid());
query.remove(ClinicalAnalysisDBAdaptor.QueryParams.SOMATIC.key());

代码示例来源:origin: opencb/opencga

finalQuery.remove(QueryParams.INDIVIDUAL_UID.key());

代码示例来源:origin: opencb/opencga

tmpQuery.remove(Constants.ALL_VERSIONS);

代码示例来源:origin: opencb/opencga

tmpQuery.remove(Constants.ALL_VERSIONS);

代码示例来源:origin: opencb/opencga

tmpQuery.remove(Constants.ALL_VERSIONS);

相关文章