本文整理了Java中org.opencb.commons.datastore.core.Query
类的一些代码示例,展示了Query
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query
类的具体详情如下:
包路径:org.opencb.commons.datastore.core.Query
类名称:Query
暂无
代码示例来源:origin: opencb/opencga
public VariantQueryResult<Variant> intersect(Query query, QueryOptions queryOptions, List<String> studyIds, String sessionId)
throws CatalogException, IOException, StorageEngineException {
Query intersectQuery = new Query(query);
intersectQuery.put(VariantQueryParam.STUDY.key(), String.join(VariantQueryUtils.AND, studyIds));
return get(intersectQuery, queryOptions, sessionId);
}
代码示例来源:origin: opencb/opencga
@Override
public QueryResult<Individual> get(long individualId, QueryOptions options, String userId)
throws CatalogDBException, CatalogAuthorizationException {
long studyId = getStudyId(individualId);
Query query = new Query()
.append(QueryParams.UID.key(), individualId)
.append(QueryParams.STUDY_UID.key(), studyId)
.append(QueryParams.STATUS_NAME.key(), "!=" + Status.DELETED);
return get(query, options, userId);
}
代码示例来源:origin: org.opencb.cellbase/cellbase-lib
private void createClinvarClinicalSignificanceQuery(Query query, List<Bson> andBsonList) {
if (query != null && query.getString(QueryParams.CLINVARCLINSIG.key()) != null
&& !query.getString(QueryParams.CLINVARCLINSIG.key()).isEmpty()) {
createOrQuery(query.getAsStringList(QueryParams.CLINVARCLINSIG.key()).stream()
.map((clinicalSignificanceString) -> clinicalSignificanceString.replace("_", " "))
.collect(Collectors.toList()),
"clinvarSet.referenceClinVarAssertion.clinicalSignificance.description", andBsonList);
}
}
代码示例来源:origin: opencb/opencga
/**
* Checks if the query contains any annotation query.
*
* @param query Query object.
* @return whether query contains an annotation query or not.
*/
public boolean containsAnnotationQuery(Query query) {
if (query == null || query.isEmpty()) {
return false;
}
return query.containsKey(Constants.ANNOTATION);
}
代码示例来源:origin: org.opencb.cellbase/cellbase-lib
private void createImprecisePositionQuery(Query query, String leftQueryParam, String rightQueryParam,
String leftLimitMongoField, String righLimitMongoField,
List<Bson> andBsonList) {
if (query != null && query.getString(leftQueryParam) != null && !query.getString(leftQueryParam).isEmpty()
&& query.getString(rightQueryParam) != null && !query.getString(rightQueryParam).isEmpty()) {
int leftQueryValue = query.getInt(leftQueryParam);
int rightQueryValue = query.getInt(rightQueryParam);
andBsonList.add(Filters.lte(leftLimitMongoField, rightQueryValue));
andBsonList.add(Filters.gte(righLimitMongoField, leftQueryValue));
}
}
代码示例来源:origin: org.opencb.cellbase/cellbase-lib
protected void createOrQuery(Query query, String queryParam, String mongoDbField, List<Bson> andBsonList,
QueryValueType queryValueType) {
if (query != null && query.getString(queryParam) != null && !query.getString(queryParam).isEmpty()) {
switch (queryValueType) {
case INTEGER:
createOrQuery(query.getAsIntegerList(queryParam), mongoDbField, andBsonList);
break;
default:
createOrQuery(query.getAsStringList(queryParam), mongoDbField, andBsonList);
}
}
}
代码示例来源:origin: opencb/opencga
@Test
public void queriesWithRelease() throws Exception {
System.out.println(queryUtils.parseQuery(new Query(STUDY.key(), "s1").append(VariantQueryParam.SAMPLE.key(), "sample2").append(VariantQueryParam.RELEASE.key(), 2), sessionId).toJson());
System.out.println(queryUtils.parseQuery(new Query(STUDY.key(), "s1").append(VariantQueryParam.SAMPLE.key(), "sample2").append(VariantQueryParam.RELEASE.key(), 1), sessionId).toJson());
System.out.println(queryUtils.parseQuery(new Query(STUDY.key(), "s1").append(VariantQueryParam.INCLUDE_SAMPLE.key(), "sample2").append(VariantQueryParam.RELEASE.key(), 1), sessionId).toJson());
System.out.println(queryUtils.parseQuery(new Query(STUDY.key(), "s1").append(VariantQueryParam.FILE.key(), "file1.vcf").append(VariantQueryParam.RELEASE.key(), 1), sessionId).toJson());
System.out.println(queryUtils.parseQuery(new Query(STUDY.key(), "s1").append(VariantQueryParam.STATS_MAF.key(), "c1>0.1").append(VariantQueryParam.RELEASE.key(), 1), sessionId).toJson());
System.out.println(queryUtils.parseQuery(new Query(STUDY.key(), "s1").append(VariantQueryParam.GENOTYPE.key(), "sample1:HOM_ALT,sample2:HET_REF").append(VariantQueryParam.RELEASE.key(), 1), sessionId).toJson());
}
代码示例来源:origin: opencb/opencga
private void filterOutDeleted(Query query) {
if (!query.containsKey(QueryParams.STATUS_NAME.key())) {
query.append(QueryParams.STATUS_NAME.key(), "!=" + Status.DELETED);
}
}
代码示例来源: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
@Override
public void delete(long id) throws CatalogDBException {
Query query = new Query(QueryParams.ID.key(), id);
delete(query);
}
代码示例来源: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 Document getStudyDocument(Query query) throws CatalogDBException {
// Get the study document
Query studyQuery = new Query()
.append(StudyDBAdaptor.QueryParams.UID.key(), query.getLong(FamilyDBAdaptor.QueryParams.STUDY_UID.key()));
QueryResult<Document> queryResult = dbAdaptorFactory.getCatalogStudyDBAdaptor().nativeGet(studyQuery, QueryOptions.empty());
if (queryResult.getNumResults() == 0) {
throw new CatalogDBException("Study " + query.getLong(FamilyDBAdaptor.QueryParams.STUDY_UID.key()) + " not found");
}
return queryResult.first();
}
}
代码示例来源: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
@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/cellbase
private void createPhenotypeQuery(Query query, List<Bson> andBsonList) {
if (query != null && query.getString(QueryParams.TRAIT.key()) != null
&& !query.getString(QueryParams.TRAIT.key()).isEmpty()) {
andBsonList.add(Filters.text(query.getString(QueryParams.TRAIT.key())));
}
}
代码示例来源: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
private Document getStudyDocument(Query query) throws CatalogDBException {
// Get the study document
Query studyQuery = new Query(StudyDBAdaptor.QueryParams.UID.key(), query.getLong(QueryParams.STUDY_UID.key()));
QueryResult<Document> queryResult = dbAdaptorFactory.getCatalogStudyDBAdaptor().nativeGet(studyQuery, QueryOptions.empty());
if (queryResult.getNumResults() == 0) {
throw new CatalogDBException("Study " + query.getLong(QueryParams.STUDY_UID.key()) + " not found");
}
return queryResult.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()));
}
代码示例来源:origin: opencb/opencga
private List<String> getStudyIds(String userId, Query query) throws CatalogException {
List<String> studyIds = new ArrayList<>();
if (query != null && query.containsKey(ClinicalVariantEngine.QueryParams.STUDY.key())) {
String study = query.getString(ClinicalVariantEngine.QueryParams.STUDY.key());
List<String> studies = Arrays.asList(study.split(","));
studyIds = catalogManager.getStudyManager().resolveIds(studies, userId)
.stream()
.map(Study::getFqn)
.collect(Collectors.toList());
}
return studyIds;
}
代码示例来源:origin: org.opencb.commons/commons-datastore-mongodb
public static Bson createAutoFilter(String mongoDbField, String queryParam, Query query, QueryParam.Type type)
throws NumberFormatException {
Bson filter = null;
if (query != null && query.containsKey(queryParam)) {
List<String> values = query.getAsStringList(queryParam);
LogicalOperator operator = LogicalOperator.OR;
if (values.size() == 1) {
operator = checkOperator(values.get(0));
}
filter = createAutoFilter(mongoDbField, queryParam, query, type, operator);
}
return filter;
}
内容来源于网络,如有侵权,请联系作者删除!