Example usage for com.mongodb BasicDBList BasicDBList

List of usage examples for com.mongodb BasicDBList BasicDBList

Introduction

In this page you can find the example usage for com.mongodb BasicDBList BasicDBList.

Prototype

BasicDBList

Source Link

Usage

From source file:org.opencb.cellbase.lib.impl.ProteinMongoDBAdaptor.java

License:Apache License

@Override
public QueryResult<ProteinVariantAnnotation> getVariantAnnotation(String ensemblTranscriptId, int position,
        String aaReference, String aaAlternate, QueryOptions options) {
    QueryResult<ProteinVariantAnnotation> queryResult = new QueryResult<>();
    queryResult.setId(ensemblTranscriptId + "/" + position + "/" + aaAlternate);
    long dbTimeStart = System.currentTimeMillis();

    ProteinVariantAnnotation proteinVariantAnnotation = new ProteinVariantAnnotation();
    proteinVariantAnnotation.setPosition(position);
    proteinVariantAnnotation.setReference(aaReference);
    proteinVariantAnnotation.setAlternate(aaAlternate);
    //        proteinVariantAnnotation.setSubstitutionScores(getProteinSubstitutionScores(ensemblTranscriptId, position, aaAlternate));
    Query query = new Query("transcript", ensemblTranscriptId).append("position", position).append("aa",
            aaAlternate);/*from   w w w.  j  a  va2 s.  c  o  m*/
    //        try {
    //            if (ensemblTranscriptId.equals("ENST00000383037") || ensemblTranscriptId.equals("ENST00000428666")) {
    //                int a = 1;
    //            }
    // Stop_gain/lost variants do not have SIFT/POLYPHEN scores
    if (!aaAlternate.equals("STOP") && !aaReference.equals("STOP")) {
        proteinVariantAnnotation.setSubstitutionScores(getSubstitutionScores(query, null).getResult());
    }
    //        } catch (Exception e) {
    //            int a = 1;
    //        }

    QueryResult proteinVariantData = null;
    String shortAlternativeAa = aaShortNameMap.get(aaAlternate);
    if (shortAlternativeAa != null) {
        List<Bson> pipeline = new ArrayList<>();

        //            BasicDBList andDBList1 = new BasicDBList();
        //            andDBList1.add(new Document("dbReference.id", ensemblTranscriptId));
        //            andDBList1.add(new Document("feature.location.position.position", position));
        //            andDBList1.add(new Document("feature.variation", shortAlternativeAa));
        //            pipeline.add(new Document("$match", new Document("$and", andDBList1)));

        pipeline.add(new Document("$match", new Document("dbReference.id", ensemblTranscriptId)));

        Document projection = new Document();
        projection.put("accession", 1);
        projection.put("keyword", 1);
        projection.put("feature", 1);
        pipeline.add(new Document("$project", projection));

        pipeline.add(new Document("$unwind", "$feature"));

        BasicDBList andDBList2 = new BasicDBList();
        andDBList2.add(new Document("feature.location.position.position", position));
        andDBList2.add(new Document("feature.variation", shortAlternativeAa));
        Document firstOr = new Document("$and", andDBList2);
        BasicDBList andDBList3 = new BasicDBList();
        andDBList3.add(new Document("feature.location.end.position", new Document("$gte", position)));
        andDBList3.add(new Document("feature.location.begin.position", new Document("$lte", position)));
        Document secondOr = new Document();
        secondOr.put("$and", andDBList3);
        BasicDBList orList = new BasicDBList();
        orList.add(firstOr);
        orList.add(secondOr);
        pipeline.add(new Document("$match", new Document("$or", orList)));
        //            pipeline.add(new Document("$match", firstOr));
        //
        Document groupFields = new Document();
        groupFields.put("_id", "$accession");
        groupFields.put("keyword", new Document("$addToSet", "$keyword"));
        groupFields.put("feature", new Document("$addToSet", "$feature"));
        pipeline.add(new Document("$group", groupFields));

        //TODO:terminar el pipeline de agregacion
        //            QueryBuilder builder = QueryBuilder.start("dbReference.id").is(ensemblTranscriptId)
        //                    .and("feature.location.position.position").is(position)
        //                    .and("feature.variation").is(shortAlternativeAa);
        //
        //            Document firstOr = new Document();
        //            firstOr.put("location.position.position", position);
        //            firstOr.put("variation", shortAlternativeAa);
        //
        //            BasicDBList andList = new BasicDBList();
        //            andList.add(new Document("location.end.position", new Document("$gte", position)));
        //            andList.add(new Document("location.begin.position", new Document("$lte", position)));
        //            Document secondOr = new Document();
        //            secondOr.put("$and", andList);
        //
        //            BasicDBList orList = new BasicDBList();
        //            orList.add(firstOr);
        //            orList.add(secondOr);
        //
        //            Document elemMatch = new Document();
        //            elemMatch.put("$elemMatch", new Document("$or", orList));
        //
        //            Document projection = new Document();
        //            projection.put("feature", elemMatch);
        //
        //            QueryOptions localQueryOptions = new QueryOptions();
        //            localQueryOptions.put("elemMatch",projection);
        //            localQueryOptions.put("include","accession,keyword,feature");
        //            proteinVariantData = executeQuery(ensemblTranscriptId + "_" + String.valueOf(position) + "_"
        //                            + aaAlternate, new Document(builder.get().toMap()), localQueryOptions);
        proteinVariantData = executeAggregation2(
                ensemblTranscriptId + "_" + String.valueOf(position) + "_" + aaAlternate, pipeline,
                new QueryOptions());
        if (proteinVariantData.getNumResults() > 0) {
            proteinVariantAnnotation = processProteinVariantData(proteinVariantAnnotation, shortAlternativeAa,
                    (Document) proteinVariantData.getResult().get(0));
        }
    }

    long dbTimeEnd = System.currentTimeMillis();
    queryResult.setDbTime(Long.valueOf(dbTimeEnd - dbTimeStart).intValue());

    //        if (proteinVariantAnnotation.getSubstitutionScores() != null || proteinVariantAnnotation.getUniprotAccession() != null) {
    queryResult.setNumResults(1);
    queryResult.setResult(Collections.singletonList(proteinVariantAnnotation));
    //        }
    return queryResult;
}

From source file:org.opencb.cellbase.mongodb.db.ClinicalMongoDBAdaptor.java

License:Apache License

private DBObject getClinvarRegionFilterDBObject(List<Region> regionList) {
    BasicDBList orDBList = new BasicDBList();
    for (Region region : regionList) {
        BasicDBList andDBList = new BasicDBList();
        andDBList.add(new BasicDBObject("chromosome", region.getChromosome()));
        andDBList.add(new BasicDBObject("end", new BasicDBObject("$gte", region.getStart())));
        andDBList.add(new BasicDBObject("start", new BasicDBObject("$lte", region.getEnd())));
        orDBList.add(new BasicDBObject("$and", andDBList));
    }/*from  w  w  w .jav  a 2s.c o m*/

    return new BasicDBObject("$match", new BasicDBObject("$or", orDBList));
}

From source file:org.opencb.cellbase.mongodb.db.ClinicalMongoDBAdaptor.java

License:Apache License

private QueryBuilder addClinvarRegionFilter(QueryBuilder builder, QueryOptions options) {
    List<Object> regions = options.getList("region", null);
    BasicDBList regionList = new BasicDBList();
    if (regions != null) {
        Region region = (Region) regions.get(0);
        QueryBuilder regionQueryBuilder = QueryBuilder.start("chromosome").is(region.getChromosome()).and("end")
                .greaterThanEquals(region.getStart()).and("start").lessThanEquals(region.getEnd());
        for (int i = 1; i < regions.size(); i++) {
            region = (Region) regions.get(i);
            regionQueryBuilder = regionQueryBuilder.or(QueryBuilder.start("chromosome")
                    .is(region.getChromosome()).and("end").greaterThanEquals(region.getStart()).and("start")
                    .lessThanEquals(region.getEnd()).get());
        }//from   ww  w  .ja  v  a  2s. c  om
        builder = builder.and(regionQueryBuilder.get());
    }
    return builder;
}

From source file:org.opencb.cellbase.mongodb.db.ClinicalMongoDBAdaptor.java

License:Apache License

private QueryBuilder addClinvarGeneFilter(QueryBuilder builder, QueryOptions options) {
    List<Object> genes = options.getList("gene", null);
    BasicDBList geneSymbols = new BasicDBList();
    if (genes != null && genes.size() > 0) {
        geneSymbols.addAll(genes);//from   w ww  .j av  a2s.  c o m
        builder = builder.and(
                "clinvarList.clinvarSet.referenceClinVarAssertion.measureSet.measure.measureRelationship.symbol.elementValue.value")
                .in(geneSymbols);
    }
    return builder;
}

From source file:org.opencb.cellbase.mongodb.db.ClinicalMongoDBAdaptor.java

License:Apache License

private List<QueryResult> prepareClinvarQueryResultList(List<QueryResult> clinicalQueryResultList) {
    List<QueryResult> queryResultList = new ArrayList<>();
    for (QueryResult clinicalQueryResult : clinicalQueryResultList) {
        QueryResult queryResult = new QueryResult();
        queryResult.setId(clinicalQueryResult.getId());
        queryResult.setDbTime(clinicalQueryResult.getDbTime());
        BasicDBList basicDBList = new BasicDBList();
        int numResults = 0;
        for (BasicDBObject clinicalRecord : (List<BasicDBObject>) clinicalQueryResult.getResult()) {
            if (clinicalRecord.containsKey("clinvarList")) {
                basicDBList.add(clinicalRecord);
                numResults += 1;//w w w .  j a v  a2s  .  c  om
            }
        }
        queryResult.setResult(basicDBList);
        queryResult.setNumResults(numResults);
        queryResultList.add(queryResult);
    }
    return queryResultList;
}

From source file:org.opencb.cellbase.mongodb.db.ConservationMongoDBAdaptor.java

License:Apache License

@Deprecated
@Override//ww w. j a v  a2 s  .  c o m
public List<QueryResult> getAllByRegionList(List<Region> regions, QueryOptions options) {
    //TODO not finished yet
    List<DBObject> queries = new ArrayList<>();
    List<String> ids = new ArrayList<>(regions.size());
    List<String> integerChunkIds;
    for (Region region : regions) {
        integerChunkIds = new ArrayList<>();
        // positions below 1 are not allowed
        if (region.getStart() < 1) {
            region.setStart(1);
        }
        if (region.getEnd() < 1) {
            region.setEnd(1);
        }

        /****/
        QueryBuilder builder;
        int regionChunkStart = getChunkId(region.getStart(), this.chunkSize);
        int regionChunkEnd = getChunkId(region.getEnd(), this.chunkSize);
        if (regionChunkStart == regionChunkEnd) {
            builder = QueryBuilder.start("_chunkIds")
                    .is(getChunkIdPrefix(region.getChromosome(), region.getStart(), this.chunkSize));
        } else {
            //                for (int chunkId = regionChunkStart; chunkId <= regionChunkEnd; chunkId++) {
            ////                    integerChunkIds.add(chunkId);
            //                    integerChunkIds.add(region.getChromosome() + "_" + chunkId + "_" + this.chunkSize/1000 + "k");
            //                }
            //                builder = QueryBuilder.start("chromosome").is(region.getChromosome()).and("chunkId").in(integerChunkIds);
            builder = QueryBuilder.start("chromosome").is(region.getChromosome()).and("end")
                    .greaterThanEquals(region.getStart()).and("start").lessThanEquals(region.getEnd());
        }
        //            QueryBuilder builder = QueryBuilder.start("chromosome").is(region.getChromosome()).and("chunkId").in(hunkIds);
        /****/

        queries.add(builder.get());
        ids.add(region.toString());

        logger.info(builder.get().toString());
    }

    List<QueryResult> queryResults = executeQueryList(ids, queries, options);

    for (int i = 0; i < regions.size(); i++) {
        Region region = regions.get(i);
        QueryResult queryResult = queryResults.get(i);
        BasicDBList list = (BasicDBList) queryResult.getResult();

        Map<String, List<Float>> typeMap = new HashMap();

        //            int start = region.getStart();

        for (int j = 0; j < list.size(); j++) {
            BasicDBObject chunk = (BasicDBObject) list.get(j);
            String type = chunk.getString("type");
            List<Float> valuesList;
            if (!typeMap.containsKey(type)) {
                valuesList = new ArrayList<>(region.getEnd() - region.getStart() + 1);
                for (int val = 0; val < region.getEnd() - region.getStart() + 1; val++) {
                    valuesList.add(null);
                }
                typeMap.put(type, valuesList);
            } else {
                valuesList = typeMap.get(type);
            }

            BasicDBList valuesChunk = (BasicDBList) chunk.get("values");

            int pos = 0;
            if (region.getStart() > chunk.getInt("start")) {
                pos = region.getStart() - chunk.getInt("start");
            }

            for (; pos < valuesChunk.size() && (pos + chunk.getInt("start") <= region.getEnd()); pos++) {
                //                    System.out.println("valuesList SIZE = " + valuesList.size());
                //                    System.out.println("pos = " + pos);
                //                    System.out.println("DIV " + (chunk.getInt("start") - region.getStart()));
                //                    System.out.println("valuesChunk = " + valuesChunk.get(pos));
                //                    System.out.println("indexFinal = " + (pos + chunk.getInt("start") - region.getStart()));
                valuesList.set(pos + chunk.getInt("start") - region.getStart(),
                        new Float((Double) valuesChunk.get(pos)));
            }
        }
        //
        BasicDBList resultList = new BasicDBList();
        ConservedRegionFeature conservedRegionChunk;
        for (Map.Entry<String, List<Float>> elem : typeMap.entrySet()) {
            conservedRegionChunk = new ConservedRegionFeature(region.getChromosome(), region.getStart(),
                    region.getEnd(), elem.getKey(), elem.getValue());
            resultList.add(conservedRegionChunk);
        }
        queryResult.setResult(resultList);
    }

    return queryResults;
}

From source file:org.opencb.cellbase.mongodb.db.ConservationMongoDBAdaptor.java

License:Apache License

@Override
public List<QueryResult> getAllScoresByRegionList(List<Region> regions, QueryOptions options) {
    //TODO not finished yet
    List<DBObject> queries = new ArrayList<>();
    List<String> ids = new ArrayList<>(regions.size());
    List<Integer> integerChunkIds;
    for (Region region : regions) {
        integerChunkIds = new ArrayList<>();
        // positions below 1 are not allowed
        if (region.getStart() < 1) {
            region.setStart(1);/*w w  w  .  j a  v a  2 s  .  c o m*/
        }
        if (region.getEnd() < 1) {
            region.setEnd(1);
        }

        /****/
        QueryBuilder builder;
        int regionChunkStart = getChunkId(region.getStart(), this.chunkSize);
        int regionChunkEnd = getChunkId(region.getEnd(), this.chunkSize);
        if (regionChunkStart == regionChunkEnd) {
            builder = QueryBuilder.start("_chunkIds")
                    .is(getChunkIdPrefix(region.getChromosome(), region.getStart(), chunkSize));
        } else {
            //                for (int chunkId = regionChunkStart; chunkId <= regionChunkEnd; chunkId++) {
            //                    integerChunkIds.add(chunkId);
            //                }
            //    //            QueryBuilder builder = QueryBuilder.start("chromosome").is(region.getChromosome()).and("chunkId").in(hunkIds);
            //                builder = QueryBuilder.start("chromosome").is(region.getChromosome()).and("chunkId").in(integerChunkIds);
            builder = QueryBuilder.start("chromosome").is(region.getChromosome()).and("end")
                    .greaterThanEquals(region.getStart()).and("start").lessThanEquals(region.getEnd());
        }
        /****/

        queries.add(builder.get());
        ids.add(region.toString());

        logger.info(builder.get().toString());

    }
    List<QueryResult> queryResults = executeQueryList2(ids, queries, options);
    //        List<QueryResult> queryResults = executeQueryList(ids, queries, options);

    for (int i = 0; i < regions.size(); i++) {
        Region region = regions.get(i);
        QueryResult queryResult = queryResults.get(i);
        List<BasicDBObject> list = (List<BasicDBObject>) queryResult.getResult();

        Map<String, List<Float>> typeMap = new HashMap();

        //            int start = region.getStart();

        for (int j = 0; j < list.size(); j++) {
            BasicDBObject chunk = (BasicDBObject) list.get(j);
            String type = chunk.getString("type");
            List<Float> valuesList;
            if (!typeMap.containsKey(type)) {
                valuesList = new ArrayList<>(region.getEnd() - region.getStart() + 1);
                for (int val = 0; val < region.getEnd() - region.getStart() + 1; val++) {
                    valuesList.add(null);
                }
                typeMap.put(type, valuesList);
            } else {
                valuesList = typeMap.get(type);
            }

            BasicDBList valuesChunk = (BasicDBList) chunk.get("values");

            int pos = 0;
            if (region.getStart() > chunk.getInt("start")) {
                pos = region.getStart() - chunk.getInt("start");
            }

            for (; pos < valuesChunk.size() && (pos + chunk.getInt("start") <= region.getEnd()); pos++) {
                valuesList.set(pos + chunk.getInt("start") - region.getStart(),
                        new Float((Double) valuesChunk.get(pos)));
            }
        }

        BasicDBList resultList = new BasicDBList();
        for (Map.Entry<String, List<Float>> elem : typeMap.entrySet()) {
            for (Float value : elem.getValue()) {
                resultList.add(value != null ? (new Score(new Double(value), elem.getKey())) : null);
            }
        }
        queryResult.setResult(resultList);
    }

    return queryResults;
}

From source file:org.opencb.cellbase.mongodb.db.core.ConservationMongoDBAdaptor.java

License:Apache License

@Deprecated
@Override/*from   w  w  w  .j  a v  a 2  s .  c o  m*/
public List<QueryResult> getAllByRegionList(List<Region> regions, QueryOptions options) {
    //TODO not finished yet
    List<DBObject> queries = new ArrayList<>();
    List<String> ids = new ArrayList<>(regions.size());
    List<String> integerChunkIds;
    for (Region region : regions) {
        integerChunkIds = new ArrayList<>();
        // positions below 1 are not allowed
        if (region.getStart() < 1) {
            region.setStart(1);
        }
        if (region.getEnd() < 1) {
            region.setEnd(1);
        }

        // Max region size is 10000bp
        if (region.getEnd() - region.getStart() > 10000) {
            region.setEnd(region.getStart() + 10000);
        }

        QueryBuilder builder;
        int regionChunkStart = getChunkId(region.getStart(), this.chunkSize);
        int regionChunkEnd = getChunkId(region.getEnd(), this.chunkSize);
        if (regionChunkStart == regionChunkEnd) {
            builder = QueryBuilder.start("_chunkIds")
                    .is(getChunkIdPrefix(region.getChromosome(), region.getStart(), this.chunkSize));
        } else {
            //                for (int chunkId = regionChunkStart; chunkId <= regionChunkEnd; chunkId++) {
            ////                    integerChunkIds.add(chunkId);
            //                    integerChunkIds.add(region.getChromosome() + "_" + chunkId + "_" + this.chunkSize/1000 + "k");
            //                }
            //                builder = QueryBuilder.start("chromosome").is(region.getChromosome()).and("chunkId").in(integerChunkIds);
            builder = QueryBuilder.start("chromosome").is(region.getChromosome()).and("end")
                    .greaterThanEquals(region.getStart()).and("start").lessThanEquals(region.getEnd());
        }
        //            QueryBuilder builder = QueryBuilder.start("chromosome").is(region.getChromosome()).and("chunkId").in(hunkIds);
        /****/

        queries.add(builder.get());
        ids.add(region.toString());

        logger.debug(builder.get().toString());
    }

    List<QueryResult> queryResults = executeQueryList2(ids, queries, options);
    for (int i = 0; i < regions.size(); i++) {
        Region region = regions.get(i);
        QueryResult queryResult = queryResults.get(i);
        //            BasicDBList list = (BasicDBList) queryResult.getResult();
        List list = queryResult.getResult();

        Map<String, List<Float>> typeMap = new HashMap();

        //            int start = region.getStart();

        for (int j = 0; j < list.size(); j++) {
            BasicDBObject chunk = (BasicDBObject) list.get(j);
            String type = chunk.getString("type");
            List<Float> valuesList;
            if (!typeMap.containsKey(type)) {
                valuesList = new ArrayList<>(region.getEnd() - region.getStart() + 1);
                for (int val = 0; val < region.getEnd() - region.getStart() + 1; val++) {
                    valuesList.add(null);
                }
                typeMap.put(type, valuesList);
            } else {
                valuesList = typeMap.get(type);
            }

            BasicDBList valuesChunk = (BasicDBList) chunk.get("values");

            int pos = 0;
            if (region.getStart() > chunk.getInt("start")) {
                pos = region.getStart() - chunk.getInt("start");
            }

            for (; pos < valuesChunk.size() && (pos + chunk.getInt("start") <= region.getEnd()); pos++) {
                //                    System.out.println("valuesList SIZE = " + valuesList.size());
                //                    System.out.println("pos = " + pos);
                //                    System.out.println("DIV " + (chunk.getInt("start") - region.getStart()));
                //                    System.out.println("valuesChunk = " + valuesChunk.get(pos));
                //                    System.out.println("indexFinal = " + (pos + chunk.getInt("start") - region.getStart()));
                valuesList.set(pos + chunk.getInt("start") - region.getStart(),
                        new Float((Double) valuesChunk.get(pos)));
            }
        }
        //
        BasicDBList resultList = new BasicDBList();
        ConservedRegionFeature conservedRegionChunk;
        for (Map.Entry<String, List<Float>> elem : typeMap.entrySet()) {
            conservedRegionChunk = new ConservedRegionFeature(region.getChromosome(), region.getStart(),
                    region.getEnd(), elem.getKey(), elem.getValue());
            resultList.add(conservedRegionChunk);
        }
        queryResult.setResult(resultList);
    }

    return queryResults;
}

From source file:org.opencb.cellbase.mongodb.db.core.ConservationMongoDBAdaptor.java

License:Apache License

@Override
public List<QueryResult> getAllScoresByRegionList(List<Region> regions, QueryOptions options) {
    //TODO not finished yet
    List<DBObject> queries = new ArrayList<>();
    List<String> ids = new ArrayList<>(regions.size());
    List<Integer> integerChunkIds;
    for (Region region : regions) {
        integerChunkIds = new ArrayList<>();
        // positions below 1 are not allowed
        if (region.getStart() < 1) {
            region.setStart(1);/*from  ww  w  .  j a  v  a  2s .  co m*/
        }
        if (region.getEnd() < 1) {
            region.setEnd(1);
        }

        /****/
        QueryBuilder builder;
        int regionChunkStart = getChunkId(region.getStart(), this.chunkSize);
        int regionChunkEnd = getChunkId(region.getEnd(), this.chunkSize);
        if (regionChunkStart == regionChunkEnd) {
            builder = QueryBuilder.start("_chunkIds")
                    .is(getChunkIdPrefix(region.getChromosome(), region.getStart(), chunkSize));
        } else {
            //                for (int chunkId = regionChunkStart; chunkId <= regionChunkEnd; chunkId++) {
            //                    integerChunkIds.add(chunkId);
            //                }
            //    //            QueryBuilder builder = QueryBuilder.start("chromosome").is(region.getChromosome()).and("chunkId").in(hunkIds);
            //                builder = QueryBuilder.start("chromosome").is(region.getChromosome()).and("chunkId").in(integerChunkIds);
            builder = QueryBuilder.start("chromosome").is(region.getChromosome()).and("end")
                    .greaterThanEquals(region.getStart()).and("start").lessThanEquals(region.getEnd());
        }
        /****/

        queries.add(builder.get());
        ids.add(region.toString());

        logger.debug(builder.get().toString());

    }
    List<QueryResult> queryResults = executeQueryList2(ids, queries, options);
    //        List<QueryResult> queryResults = executeQueryList(ids, queries, options);

    for (int i = 0; i < regions.size(); i++) {
        Region region = regions.get(i);
        QueryResult queryResult = queryResults.get(i);
        List<BasicDBObject> list = (List<BasicDBObject>) queryResult.getResult();

        Map<String, List<Float>> typeMap = new HashMap();

        //            int start = region.getStart();

        for (int j = 0; j < list.size(); j++) {
            BasicDBObject chunk = (BasicDBObject) list.get(j);
            String type = chunk.getString("type");
            List<Float> valuesList;
            if (!typeMap.containsKey(type)) {
                valuesList = new ArrayList<>(region.getEnd() - region.getStart() + 1);
                for (int val = 0; val < region.getEnd() - region.getStart() + 1; val++) {
                    valuesList.add(null);
                }
                typeMap.put(type, valuesList);
            } else {
                valuesList = typeMap.get(type);
            }

            BasicDBList valuesChunk = (BasicDBList) chunk.get("values");

            int pos = 0;
            if (region.getStart() > chunk.getInt("start")) {
                pos = region.getStart() - chunk.getInt("start");
            }

            for (; pos < valuesChunk.size() && (pos + chunk.getInt("start") <= region.getEnd()); pos++) {
                valuesList.set(pos + chunk.getInt("start") - region.getStart(),
                        new Float((Double) valuesChunk.get(pos)));
            }
        }

        BasicDBList resultList = new BasicDBList();
        for (Map.Entry<String, List<Float>> elem : typeMap.entrySet()) {
            for (Float value : elem.getValue()) {
                if (value != null) {
                    resultList.add(new Score(new Double(value), elem.getKey()));
                }
            }
        }
        if (!resultList.isEmpty()) {
            queryResult.setResult(resultList);
        } else {
            queryResult.setResult(null);
        }
    }

    return queryResults;
}

From source file:org.opencb.cellbase.mongodb.db.core.GeneMongoDBAdaptor.java

License:Apache License

@Override
public QueryResult getAll(QueryOptions options) {
    QueryBuilder builder = new QueryBuilder();

    List<String> biotypes = options.getAsStringList("biotype");
    if (biotypes != null && biotypes.size() > 0) {
        BasicDBList biotypeIds = new BasicDBList();
        biotypeIds.addAll(biotypes);/*  w w  w. j av a  2s.c om*/
        builder = builder.and("biotype").in(biotypeIds);
    }

    return executeQuery("result", builder.get(), options);
}