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

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

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

Query.size介绍

暂无

代码示例

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

public static Set<VariantQueryParam> validParams(Query query) {
  Set<VariantQueryParam> params = new HashSet<>(query == null ? 0 : query.size());
  for (VariantQueryParam queryParam : values()) {
    if (isValidParam(query, queryParam)) {
      params.add(queryParam);
    }
  }
  return params;
}

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

private Bson parseQuery(Query query) {
  logger.debug("Parsing query...");
  Bson filtersBson = null;
  // No filtering parameters mean all records
  if (query.size() > 0) {
    Bson commonFiltersBson = getCommonFilters(query);
    Set<String> sourceContent = query.getAsStringList(QueryParams.SOURCE.key()) != null
        ? new HashSet<>(query.getAsStringList(QueryParams.SOURCE.key())) : null;
    List<Bson> sourceSpecificFilterList = new ArrayList<>();
    getClinvarFilters(query, sourceContent, sourceSpecificFilterList);
    getCosmicFilters(query, sourceContent, sourceSpecificFilterList);
    getGwasFilters(query, sourceContent, sourceSpecificFilterList);
    if (sourceSpecificFilterList.size() > 0 && commonFiltersBson != null) {
      List<Bson> filtersBsonList = new ArrayList<>();
      filtersBsonList.add(commonFiltersBson);
      filtersBsonList.add(Filters.or(sourceSpecificFilterList));
      filtersBson = Filters.and(filtersBsonList);
    } else if (commonFiltersBson != null) {
      filtersBson = commonFiltersBson;
    } else if (sourceSpecificFilterList.size() > 0) {
      filtersBson = Filters.or(sourceSpecificFilterList);
    }
  }
  if (filtersBson != null) {
    return filtersBson;
  } else {
    return new Document();
  }
}

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

private Bson parseQuery(Query query) {
  logger.debug("Parsing query...");
  Bson filtersBson = null;
  // No filtering parameters mean all records
  if (query.size() > 0) {
    Bson commonFiltersBson = getCommonFilters(query);
    Set<String> sourceContent = query.getAsStringList(QueryParams.SOURCE.key()) != null
        ? new HashSet<>(query.getAsStringList(QueryParams.SOURCE.key())) : null;
    List<Bson> sourceSpecificFilterList = new ArrayList<>();
    getClinvarFilters(query, sourceContent, sourceSpecificFilterList);
    getCosmicFilters(query, sourceContent, sourceSpecificFilterList);
    getGwasFilters(query, sourceContent, sourceSpecificFilterList);
    if (sourceSpecificFilterList.size() > 0 && commonFiltersBson != null) {
      List<Bson> filtersBsonList = new ArrayList<>();
      filtersBsonList.add(commonFiltersBson);
      filtersBsonList.add(Filters.or(sourceSpecificFilterList));
      filtersBson = Filters.and(filtersBsonList);
    } else if (commonFiltersBson != null) {
      filtersBson = commonFiltersBson;
    } else if (sourceSpecificFilterList.size() > 0) {
      filtersBson = Filters.or(sourceSpecificFilterList);
    }
  }
  if (filtersBson != null) {
    return filtersBson;
  } else {
    return new Document();
  }
}

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

@Override
public QueryResult<AlignmentGlobalStats> stats(Path path, Path workspace, Query query, QueryOptions options) throws Exception {
  FileUtils.checkFile(path);
  StopWatch watch = StopWatch.createStarted();
  if (options == null) {
    options = new QueryOptions();
  }
  if (options.size() == 0 && query.size() == 0) {
    return stats(path, workspace);
  }
  Region region = parseRegion(query);
  AlignmentFilters alignmentFilters = parseQuery(query);
  AlignmentOptions alignmentOptions = parseQueryOptions(options);
  BamManager alignmentManager = new BamManager(path);
  AlignmentGlobalStats alignmentGlobalStats = alignmentManager.stats(region, alignmentFilters, alignmentOptions);
  watch.stop();
  return new QueryResult<>("Get stats", (int) watch.getTime(), 1, 1, "", "", Arrays.asList(alignmentGlobalStats));
}

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

@Test
public void testCreatePermissionRules() throws CatalogException {
  PermissionRule rules = new PermissionRule("rules1", new Query("a", "b"), Arrays.asList("user2", "user3"),
      Arrays.asList("VIEW", "UPDATE"));
  QueryResult<PermissionRule> permissionRulesQueryResult = catalogManager.getStudyManager().createPermissionRule(
      studyFqn, Study.Entity.SAMPLES, rules, sessionIdUser);
  assertEquals(1, permissionRulesQueryResult.getNumResults());
  assertEquals("rules1", permissionRulesQueryResult.first().getId());
  assertEquals(1, permissionRulesQueryResult.first().getQuery().size());
  assertEquals(2, permissionRulesQueryResult.first().getMembers().size());
  assertEquals(2, permissionRulesQueryResult.first().getPermissions().size());
  // Add new permission rules object
  rules.setId("rules2");
  permissionRulesQueryResult = catalogManager.getStudyManager().createPermissionRule(studyFqn, Study.Entity.SAMPLES, rules,
      sessionIdUser);
  assertEquals(1, permissionRulesQueryResult.getNumResults());
  assertEquals(rules, permissionRulesQueryResult.first());
}

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

@Test
public void parseSampleAnnotationQuery() throws Exception {
  Query query = CatalogUtils.parseSampleAnnotationQuery("age>20;" + SampleDBAdaptor.QueryParams.PHENOTYPES.key() + "=hpo:123,hpo:456;" + SampleDBAdaptor.QueryParams.ID.key() + "=smith", SampleDBAdaptor.QueryParams::getParam);
  assertEquals(3, query.size());
  assertTrue(query.containsKey(SampleDBAdaptor.QueryParams.ID.key()));
  assertEquals("=smith", query.getString(SampleDBAdaptor.QueryParams.ID.key()));
  assertTrue(query.containsKey(SampleDBAdaptor.QueryParams.ANNOTATION.key()));
  assertEquals("annotation.age>20", query.getString(SampleDBAdaptor.QueryParams.ANNOTATION.key()));
  assertTrue(query.containsKey(SampleDBAdaptor.QueryParams.PHENOTYPES.key()));
  assertEquals("=hpo:123,hpo:456", query.getString(SampleDBAdaptor.QueryParams.PHENOTYPES.key()));
}

相关文章