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

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

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

QueryParam.key介绍

暂无

代码示例

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

protected static void addParam(ObjectMap query, QueryParam key, Collection value) {
  if (CollectionUtils.isNotEmpty(value)) {
    query.put(key.key(), value);
  }
}

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

protected static void addParam(ObjectMap query, QueryParam key, boolean value) {
  if (value) {
    query.put(key.key(), true);
  }
}

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

public static VariantQueryException unsupportedVariantQueryFilter(QueryParam param, String storageEngineId, String extra) {
  return new VariantQueryException("Unsupported variant query filter '" + param.key()
      + "' with storage engine '" + storageEngineId + "'."
      + (StringUtils.isEmpty(extra) ? "" : (' ' + extra)));
}

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

public static VariantQueryException missingParam(QueryParam queryParam, String message) {
  return new VariantQueryException("Missing param \"" + queryParam.key() + "\" . "
      +  message);
}

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

public static VariantQueryException malformedParam(QueryParam queryParam, String value, String message) {
  return new VariantQueryException("Malformed \"" + queryParam.key() + "\" query : \"" + value + "\". "
      +  message);
}

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

protected VariantDBIterator getVariantsToIndex(boolean overwrite, Query query, QueryOptions queryOptions, VariantDBAdaptor dbAdaptor)
    throws StorageEngineException {
  if (!overwrite) {
    query.put(VariantQueryUtils.VARIANTS_TO_INDEX.key(), true);
  }
  return dbAdaptor.iterator(query, queryOptions);
}

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

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

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

public static void convertGenesToRegionsQuery(Query query, CellBaseUtils cellBaseUtils) {
  VariantQueryXref variantQueryXref = VariantQueryUtils.parseXrefs(query);
  List<String> genes = variantQueryXref.getGenes();
  if (!genes.isEmpty()) {
    List<Region> regions = cellBaseUtils.getGeneRegion(genes);
    regions = mergeRegions(regions);
    query.put(ANNOT_GENE_REGIONS.key(), regions);
  }
}

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

private List<Region> getRegions(Query query) {
  List<Region> regions = new ArrayList<>();
  if (isValidParam(query, REGION)) {
    regions.addAll(Region.parseRegions(query.getString(REGION.key())));
  }
  if (isValidParam(query, ANNOT_GENE_REGIONS)) {
    regions.addAll(Region.parseRegions(query.getString(ANNOT_GENE_REGIONS.key())));
  }
  regions = mergeRegions(regions);
  return regions;
}

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

public QueryResult<ProjectMetadata.VariantAnnotationMetadata> getAnnotationMetadata(String name, String project, String sessionId)
    throws StorageEngineException, CatalogException, IOException {
  Query query = new Query(VariantCatalogQueryUtils.PROJECT.key(), project);
  return secure(query, empty(), sessionId, (engine) -> engine.getAnnotationMetadata(name));
}

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

@Test
public void testQueryProject() throws Exception {
  Query query = new Query(VariantCatalogQueryUtils.PROJECT.key(), projectId);
  QueryResult<Variant> result = variantManager.get(query, new QueryOptions(), sessionId);
  System.out.println("result.getNumResults() = " + result.getNumResults());
  System.out.println("result.getResult().size() = " + result.getResult().size());
  for (Variant variant : result.getResult()) {
    System.out.println("variant = " + variant);
  }
}

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

@Test
public void queryByFamilyUnknownDisease() throws CatalogException {
  VariantQueryException e = VariantQueryException.malformedParam(FAMILY_PHENOTYPE, "asdf", "Available phenotypes: [phenotype]");
  thrown.expectMessage(e.getMessage());
  thrown.expect(e.getClass());
  queryUtils.parseQuery(new Query(STUDY.key(), "s1")
      .append(FAMILY.key(), "f1")
      .append(MODE_OF_INHERITANCE.key(), "monoallelic")
      .append(FAMILY_PHENOTYPE.key(), "asdf"), sessionId);
}

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

@Test
public void queryByFamilyWithoutStudy() throws CatalogException {
  VariantQueryException e = VariantQueryException.missingStudyFor("family", "f1", Collections.emptyList());
  thrown.expectMessage(e.getMessage());
  thrown.expect(e.getClass());
  queryUtils.parseQuery(new Query(FAMILY.key(), "f1"), sessionId);
}

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

@Test
public void queryByFamilyNotFound() throws CatalogException {
  CatalogException e = new CatalogException("Family asdf not found");
  thrown.expectMessage(e.getMessage());
  thrown.expect(e.getClass());
  queryUtils.parseQuery(new Query(STUDY.key(), "s1").append(FAMILY.key(), "asdf").append(FAMILY_PHENOTYPE.key(), "asdf"), sessionId);
}

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

@Test
public void queryByFamilyMissingModeOfInheritance() throws CatalogException {
  VariantQueryException e = VariantQueryException.malformedParam(FAMILY_PHENOTYPE, "asdf", "Require parameter \"family\" and \"modeOfInheritance\" to use \"familyDisease\".");
  thrown.expectMessage(e.getMessage());
  thrown.expect(e.getClass());
  queryUtils.parseQuery(new Query(STUDY.key(), "s1").append(FAMILY.key(), "f1").append(FAMILY_PHENOTYPE.key(), "asdf"), sessionId);
}

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

public Project getProjectFromQuery(Query query, String sessionId, QueryOptions options) throws CatalogException {
  if (isValidParam(query, VariantCatalogQueryUtils.PROJECT)) {
    String project = query.getString(VariantCatalogQueryUtils.PROJECT.key());
    return catalogManager.getProjectManager().get(project, options, sessionId).first();
  } else {
    String studyFqn = getAnyStudy(query, sessionId);
    String project = catalogManager.getStudyManager().getProjectFqn(studyFqn);
    return catalogManager.getProjectManager().get(new Query(ProjectDBAdaptor.QueryParams.FQN.key(), project), options, sessionId)
        .first();
  }
}

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

@Test
public void queryByPanel() throws Exception {
  Query query = queryUtils.parseQuery(new Query(STUDY.key(), "s1").append(PANEL.key(), "MyPanel"), sessionId);
  assertEquals(Arrays.asList("BRCA2","CADM1","CTBP2P1","ADSL"), query.getAsList(GENE.key()));
  query = queryUtils.parseQuery(new Query(STUDY.key(), "s1").append(PANEL.key(), "MyPanel").append(GENE.key(), "ASDF"), sessionId);
  assertEquals(Arrays.asList("BRCA2","CADM1","CTBP2P1","ADSL", "ASDF"), query.getAsList(GENE.key()));
}

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

@Test
public void queryByFamily() throws Exception {
  Query query = queryUtils.parseQuery(new Query(STUDY.key(), "s1").append(FAMILY.key(), "f1"), sessionId);
  assertEquals(Arrays.asList("sample1", "sample2", "sample3", "sample4"), query.getAsStringList(SAMPLE.key()));
  assertFalse(VariantQueryUtils.isValidParam(query, GENOTYPE));
  query = queryUtils.parseQuery(new Query(STUDY.key(), "s1").append(FAMILY.key(), "f1").append(MODE_OF_INHERITANCE.key(), "MONOALLELIC"), sessionId);
  assertEquals("sample3:0/1,1/1;sample4:0/0;sample1:0/0;sample2:0/0", query.getString(GENOTYPE.key()));
  assertFalse(VariantQueryUtils.isValidParam(query, SAMPLE));
}

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

@Test
public void queryByPanelNotFound() throws Exception {
  CatalogException e = new CatalogException("Panel MyPanel_wrong not found");
  thrown.expectMessage(e.getMessage());
  thrown.expect(e.getClass());
  queryUtils.parseQuery(new Query(STUDY.key(), "s1").append(PANEL.key(), "MyPanel_wrong"), sessionId);
}

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

@Test
public void getAnyStudy() throws Exception {
  assertEquals("user@p1:s1", queryUtils.getAnyStudy(new Query(PROJECT.key(), "p1"), sessionId));
  assertEquals("user@p2:p2s2", queryUtils.getAnyStudy(new Query(PROJECT.key(), "p2"), sessionId));
  assertEquals("user@p2:p2s2", queryUtils.getAnyStudy(new Query(STUDY.key(), "p2s2"), sessionId));
  assertEquals("user@p2:p2s2", queryUtils.getAnyStudy(new Query(INCLUDE_STUDY.key(), "p2s2"), sessionId));
  assertEquals("user@p2:p2s2", queryUtils.getAnyStudy(new Query(STUDY.key(), "p2s2").append(INCLUDE_STUDY.key(), "all"), sessionId));
  thrown.expect(CatalogException.class);
  thrown.expectMessage("Multiple projects");
  queryUtils.getAnyStudy(new Query(), sessionId);
}

相关文章

QueryParam类方法