本文整理了Java中org.opencb.commons.datastore.core.Query.append
方法的一些代码示例,展示了Query.append
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.append
方法的具体详情如下:
包路径:org.opencb.commons.datastore.core.Query
类名称:Query
方法名:append
暂无
代码示例来源:origin: opencb/opencga
@Override
public Query generateQuery(Query query) {
String value = IntStream.range(0, getArity())
.mapToObj(i -> terms.get(random.nextInt(terms.size())))
.collect(Collectors.joining(","));
query.append(queryKey, value);
return query;
}
代码示例来源: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: 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
private void filterOutDeleted(Query query) {
if (!query.containsKey(QueryParams.STATUS_NAME.key())) {
query.append(QueryParams.STATUS_NAME.key(), "!=" + Status.DELETED);
}
}
代码示例来源:origin: opencb/opencga
@Override
public QueryResult<File> get(long fileId, QueryOptions options) throws CatalogDBException {
checkId(fileId);
Query query = new Query()
.append(QueryParams.UID.key(), fileId)
.append(QueryParams.STUDY_UID.key(), getStudyIdByFileId(fileId));
return get(query, options);
}
代码示例来源:origin: opencb/opencga
/**
* At the moment it does not clean external references to itself.
*/
@Override
public QueryResult<Job> get(long jobId, QueryOptions options) throws CatalogDBException {
checkId(jobId);
Query query = new Query(QueryParams.UID.key(), jobId).append(QueryParams.STATUS_NAME.key(), "!=" + Status.DELETED)
.append(QueryParams.STUDY_UID.key(), getStudyId(jobId));
return get(query, options);
}
代码示例来源:origin: opencb/opencga
@Override
public QueryResult<Panel> get(long panelUid, QueryOptions options) throws CatalogDBException {
checkUid(panelUid);
Query query = new Query(QueryParams.UID.key(), panelUid).append(QueryParams.STATUS_NAME.key(), "!=" + Status.DELETED)
.append(QueryParams.STUDY_UID.key(), getStudyId(panelUid));
return get(query, options);
}
代码示例来源:origin: opencb/opencga
@Override
public long getId(long projectId, String studyAlias) throws CatalogDBException {
Query query1 = new Query(QueryParams.PROJECT_ID.key(), projectId).append(QueryParams.ID.key(), studyAlias);
QueryOptions queryOptions = new QueryOptions(MongoDBCollection.INCLUDE, QueryParams.UID.key());
QueryResult<Study> studyQueryResult = get(query1, queryOptions);
List<Study> studies = studyQueryResult.getResult();
return studies == null || studies.isEmpty() ? -1 : studies.get(0).getUid();
}
代码示例来源:origin: opencb/opencga
@Override
public QueryResult<Study> get(long studyId, QueryOptions options) throws CatalogDBException {
checkId(studyId);
Query query = new Query(QueryParams.UID.key(), studyId).append(QueryParams.STATUS_NAME.key(), "!=" + Status.DELETED);
return get(query, options);
}
代码示例来源:origin: opencb/opencga
private void filterOutDeleted(Query query) {
if (!query.containsKey(QueryParams.STATUS_NAME.key()) && !query.containsKey(QueryParams.UID.key())) {
query.append(QueryParams.STATUS_NAME.key(), "!=" + File.FileStatus.TRASHED + ";!=" + Status.DELETED + ";!="
+ File.FileStatus.REMOVED + ";!=" + File.FileStatus.PENDING_DELETE + ";!=" + File.FileStatus.DELETING);
}
}
代码示例来源:origin: opencb/opencga
@Override
public QueryResult<Interpretation> get(long interpretationId, QueryOptions options) throws CatalogDBException {
checkId(interpretationId);
return get(new Query(QueryParams.UID.key(), interpretationId).append(QueryParams.STUDY_UID.key(),
getStudyId(interpretationId)), options);
}
代码示例来源:origin: opencb/opencga
@Test
public void testQueryNegatedGenotypes() {
Document mongoQuery = parser.parseQuery(new Query().append(STUDY.key(), "study_1")
.append(GENOTYPE.key(), "sample_10101" + IS + NOT + "1/1"));
Document expected = new Document(STUDIES_FIELD + '.' + STUDYID_FIELD, 1)
.append("$and", Collections.singletonList(ANY));
checkEqualDocuments(expected, mongoQuery);
}
代码示例来源:origin: opencb/opencga
@Test
public void testGetBySampleName() throws Exception {
query = new Query()
.append(VariantQueryParam.STUDY.key(), "S_1")
.append(VariantQueryParam.SAMPLE.key(), "NA12877");
queryResult = query(query, options);
VariantQueryResult<Variant> allVariants = dbAdaptor.get(new Query()
.append(VariantQueryParam.INCLUDE_STUDY.key(), "S_1")
.append(VariantQueryParam.INCLUDE_SAMPLE.key(), "NA12877")
.append(VariantQueryParam.INCLUDE_FILE.key(), file12877), options);
assertThat(queryResult, everyResult(allVariants, withStudy("S_1", allOf(withFileId(file12877), withSampleData("NA12877", "GT", containsString("1"))))));
}
代码示例来源: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 fileNotIndexed() throws Exception {
thrown.expectMessage("not indexed");
thrown.expect(VariantQueryException.class);
queryUtils.parseQuery(new Query(VariantQueryParam.FILE.key(), "file5.vcf")
.append(VariantQueryParam.STUDY.key(), "s1")
.append(VariantQueryParam.RELEASE.key(), 1), sessionId).toJson();
}
代码示例来源:origin: opencb/opencga
@Test
public void cohortStatsWrongRelease() throws Exception {
VariantQueryException e = VariantCatalogQueryUtils.wrongReleaseException(VariantQueryParam.STATS_MAF, "c2", 1);
thrown.expectMessage(e.getMessage());
thrown.expect(e.getClass());
queryUtils.parseQuery(new Query(VariantQueryParam.STATS_MAF.key(), "c2>0.2")
.append(VariantQueryParam.STUDY.key(), "s1")
.append(VariantQueryParam.RELEASE.key(), 1), sessionId).toJson();
}
代码示例来源:origin: opencb/opencga
@Test
public void testQueryExcludeSamples() throws Exception {
QueryOptions queryOptions = new QueryOptions(QueryOptions.EXCLUDE, VariantField.STUDIES_SAMPLES_DATA);
Query query = new Query();
// Without studies
Map<String, List<Sample>> longListMap = variantManager.checkSamplesPermissions(query, queryOptions, mockVariantDBAdaptor().getStudyConfigurationManager(), sessionId);
Assert.assertEquals(Collections.singletonMap(studyFqn, Collections.emptyList()), longListMap);
// With studies
query.append(VariantQueryParam.STUDY.key(), studyFqn);
longListMap = variantManager.checkSamplesPermissions(query, queryOptions, mockVariantDBAdaptor().getStudyConfigurationManager(), sessionId);
Assert.assertEquals(Collections.singletonMap(studyFqn, Collections.emptyList()), longListMap);
}
代码示例来源:origin: opencb/opencga
public File getFile(long id) throws CatalogException {
return catalogManager.getFileManager().get(String.valueOf(study.getFqn()), new Query(FileDBAdaptor.QueryParams.UID.key(), id)
.append(FileDBAdaptor.QueryParams.STATUS_NAME.key(), Status.DELETED + "," + File.FileStatus.TRASHED + "," + Status.READY)
, null, sessionIdUser)
.first();
}
代码示例来源: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 checkQueryGenotypes(VariantHadoopDBAdaptor dbAdaptor) {
StudyConfiguration sc = dbAdaptor.getStudyConfigurationManager().getStudyConfiguration(STUDY_ID, null).first();
List<Variant> allVariants = dbAdaptor.get(new Query(), new QueryOptions()).getResult();
for (String sample : StudyConfiguration.getIndexedSamples(sc).keySet()) {
VariantQueryResult<Variant> queryResult = dbAdaptor.get(new Query(VariantQueryParam.SAMPLE.key(), sample)
.append(VariantQueryParam.INCLUDE_SAMPLE.key(), VariantQueryUtils.ALL)
.append(VariantQueryParam.INCLUDE_FILE.key(), VariantQueryUtils.ALL), new QueryOptions("explain", true));
assertThat(queryResult, everyResult(allVariants,
withStudy(STUDY_NAME,
withSampleData(sample, "GT", containsString("1")))));
}
}
内容来源于网络,如有侵权,请联系作者删除!