List of usage examples for com.mongodb QueryBuilder get
public DBObject get()
From source file:org.opencb.cellbase.mongodb.db.variation.VariationMongoDBAdaptor.java
License:Apache License
@Override public List<QueryResult> getAllByRegionList(List<Region> regions, QueryOptions options) { List<DBObject> queries = new ArrayList<>(); List<String> ids = new ArrayList<>(regions.size()); String phenotype = options.getString("phenotype"); if (phenotype != null && !phenotype.equals("")) { for (Region region : regions) { QueryBuilder builder = QueryBuilder.start("chromosome").is(region.getChromosome()).and("start") .greaterThanEquals(region.getStart()).lessThanEquals(region.getEnd()); builder = builder.and("phenotype").is(phenotype); queries.add(builder.get()); ids.add(region.toString());/*from ww w . java 2 s . c om*/ } return executeQueryList2(ids, queries, options, mongoVariationPhenotypeDBCollection2); } else { String consequenceTypes = options.getString("consequence_type", null); BasicDBList consequenceTypeDBList = new BasicDBList(); if (consequenceTypes != null && !consequenceTypes.equals("")) { for (String ct : consequenceTypes.split(",")) { consequenceTypeDBList.add(ct); } } for (Region region : regions) { // QueryBuilder builder = QueryBuilder.start("chromosome").is(region.getSequenceName()).and("end").greaterThan(region.getStart()).and("start").lessThan(region.getEnd()); QueryBuilder builder = QueryBuilder.start("chromosome").is(region.getChromosome()).and("start") .greaterThanEquals(region.getStart()).lessThanEquals(region.getEnd()); if (consequenceTypeDBList.size() > 0) { builder = builder.and("transcriptVariations.consequenceTypes").in(consequenceTypeDBList); } queries.add(builder.get()); ids.add(region.toString()); } return executeQueryList2(ids, queries, options); } }
From source file:org.opencb.cellbase.mongodb.db.variation.VariationMongoDBAdaptor.java
License:Apache License
@Override public List<QueryResult> getIdByVariantList(List<GenomicVariant> variations, QueryOptions options) { List<DBObject> queries = new ArrayList<>(variations.size()); List<QueryResult> results; for (GenomicVariant variation : variations) { String chunkId = getChunkIdPrefix(variation.getChromosome(), variation.getPosition(), variationChunkSize);/*w w w . j ava 2s .co m*/ QueryBuilder builder = QueryBuilder.start("_chunkIds").is(chunkId).and("chromosome") .is(variation.getChromosome()).and("start").is(variation.getPosition()).and("alternate") .is(variation.getAlternative()); if (variation.getReference() != null) { builder = builder.and("reference").is(variation.getReference()); } queries.add(builder.get()); } results = executeQueryList2(variations, queries, options, mongoDBCollection); for (QueryResult result : results) { List<String> idList = new LinkedList(); BasicDBList idListObject = (BasicDBList) result.getResult(); for (Object idObject : idListObject) { DBObject variantObject = (DBObject) idObject; idList.add(variantObject.get("id").toString()); } // result.setResult(Joiner.on(",").skipNulls().join(idList)); result.setResult(idList); } return results; }
From source file:org.opencb.cellbase.mongodb.db.variation.VariationMongoDBAdaptor.java
License:Apache License
@Override public List<QueryResult> getAllByVariantList(List<GenomicVariant> variations, QueryOptions options) { List<DBObject> queries = new ArrayList<>(variations.size()); List<QueryResult> results; for (GenomicVariant variation : variations) { String chunkId = getChunkIdPrefix(variation.getChromosome(), variation.getPosition(), variationChunkSize);// w w w .j a v a 2 s . c o m QueryBuilder builder = QueryBuilder.start("_chunkIds").is(chunkId).and("chromosome") .is(variation.getChromosome()).and("start").is(variation.getPosition()).and("alternate") .is(variation.getAlternative()); if (variation.getReference() != null) { builder = builder.and("reference").is(variation.getReference()); } queries.add(builder.get()); } results = executeQueryList2(variations, queries, options, mongoDBCollection); // results = executeQueryList(variations, queries, options, mongoDBCollection); return results; }
From source file:org.opencb.cellbase.mongodb.db.variation.VariationPhenotypeAnnotationMongoDBAdaptor.java
License:Apache License
@Override public List<QueryResult> getAllByIdList(List<String> idList, QueryOptions options) { List<DBObject> queries = new ArrayList<>(); for (String id : idList) { QueryBuilder builder = QueryBuilder.start("id").is(id); queries.add(builder.get()); }//from w w w.j a v a 2s. c o m return executeQueryList2(idList, queries, options); }
From source file:org.opencb.cellbase.mongodb.db.variation.VariationPhenotypeAnnotationMongoDBAdaptor.java
License:Apache License
@Override public QueryResult getAllByPhenotype(String phenotype, QueryOptions options) { QueryBuilder builder = QueryBuilder.start("phenotype").is(phenotype); return executeQuery(phenotype, builder.get(), options); }
From source file:org.opencb.cellbase.mongodb.db.variation.VariationPhenotypeAnnotationMongoDBAdaptor.java
License:Apache License
@Override public QueryResult getAllByGene(String gene, QueryOptions options) { QueryBuilder builder = QueryBuilder.start("associatedGenes").is(gene); return executeQuery(gene, builder.get(), options); }
From source file:org.opencb.cellbase.mongodb.db.variation.VariationPhenotypeAnnotationMongoDBAdaptor.java
License:Apache License
@Override public List<QueryResult> getAllByGeneList(List<String> geneList, QueryOptions options) { List<DBObject> queries = new ArrayList<>(geneList.size()); for (String id : geneList) { QueryBuilder builder = QueryBuilder.start("associatedGenes").is(id); queries.add(builder.get()); }/*from w w w .j a va2 s . co m*/ return executeQueryList2(geneList, queries, options); }
From source file:org.opencb.cellbase.mongodb.db.variation.VariationPhenotypeAnnotationMongoDBAdaptor.java
License:Apache License
@Override public QueryResult getAllGenesByPhenotype(String phenotype, QueryOptions options) { QueryBuilder builder = QueryBuilder.start("phenotype").is(phenotype); return executeQuery(phenotype, builder.get(), options); }
From source file:org.opencb.cellbase.mongodb.db.variation.VariationPhenotypeAnnotationMongoDBAdaptor.java
License:Apache License
@Override public List<QueryResult> getAllGenesByPhenotypeList(List<String> phenotypeList, QueryOptions options) { List<DBObject> queries = new ArrayList<>(phenotypeList.size()); for (String id : phenotypeList) { QueryBuilder builder = QueryBuilder.start("phenotype").is(id); queries.add(builder.get()); }/*from w w w. j a va2s.c o m*/ return executeQueryList2(phenotypeList, queries, options); }
From source file:org.opencb.cellbase.mongodb.db.VariationMongoDBAdaptor.java
License:Apache License
@Override public List<QueryResult> getAllByIdList(List<String> idList, QueryOptions options) { List<DBObject> queries = new ArrayList<>(); for (String id : idList) { QueryBuilder builder = QueryBuilder.start("id").is(id); queries.add(builder.get()); }/* w w w . ja v a2s. c o m*/ return executeQueryList(idList, queries, options); }