Example usage for com.mongodb MongoClient close

List of usage examples for com.mongodb MongoClient close

Introduction

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

Prototype

public void close() 

Source Link

Document

Closes all resources associated with this instance, in particular any open network connections.

Usage

From source file:module.script.probcp.UpdateSamplesProbcp.java

License:Open Source License

public UpdateSamplesProbcp() {

    // ===== Connection =====

    MongoClient mongoClient = MongoUtil.buildMongoClient();
    MongoDatabase db = mongoClient.getDatabase("epimed_experiments");
    MongoCollection<Document> collectionSamples = db.getCollection("samples");

    // ===== Session PostgreSQL =====
    SessionFactory sessionFactory = HibernateUtil
            .buildSessionFactory("config/epimed_semantic.hibernate.cfg.xml");
    Session session = sessionFactory.openSession();

    String[] studies = { "tya16" };
    List<String> series = new ArrayList<String>();

    for (int l = 0; l < studies.length; l++) {

        String idStudy = studies[l];
        String studyName = idStudy.toUpperCase();

        series.clear();//from w w  w  .  j  a  v a  2s .  c  o  m
        series.add(studyName);
        series.add("PROBCP");

        String sql = "select * from st_bcp." + idStudy + "_sample order by id_sample";

        List<Object> listSamples = session.createSQLQuery(sql).list();

        for (int i = 0; i < listSamples.size(); i++) {

            Object[] lineSample = (Object[]) listSamples.get(i);

            String idSample = (String) lineSample[0];
            String clinicalClassification = (String) lineSample[1];
            String tnmStage = (String) lineSample[2];
            Integer grade = (Integer) lineSample[3];
            String type = (String) lineSample[4];

            System.out.println(Arrays.toString(lineSample));

            String id = studyName + "_" + idSample;

            Document docSample = collectionSamples.find(Filters.eq("_id", id)).first();
            Document expgroup = (Document) docSample.get("exp_group");
            expgroup.append("tnm_grade", grade);
            expgroup.append("tnm_stage", null);
            docSample.append("exp_group", expgroup);

            UpdateResult updateResult = collectionSamples.updateOne(Filters.eq("_id", id),
                    new Document("$set", docSample));

            System.out.println(docSample);

        }

    }

    if (session.isOpen()) {
        session.close();
    }
    sessionFactory.close();

    mongoClient.close();

}

From source file:module.script.QueryAvailableData.java

License:Open Source License

public QueryAvailableData() {

    // ===== Service =====
    FormatService formatService = new FormatService();

    // ===== Session Mongo =====

    MongoClient mongoClient = MongoUtil.buildMongoClient();
    MongoDatabase db = mongoClient.getDatabase("epimed_experiments");

    MongoCollection<Document> collectionSeries = db.getCollection("series");
    MongoCollection<Document> collectionSamples = db.getCollection("samples");

    // ===== Print block =====
    Block<Document> printBlock = new Block<Document>() {
        public void apply(final Document document) {
            System.out.println(document.toJson());
        }//w ww . j  a  v a2s .  com
    };

    // ===== Group by topology =====
    // db.getCollection('samples').aggregate({ $group: { "_id" : "$exp_group.topology", "total" : {$sum : 1} }}, {$sort : {total : -1}} )
    /*
    List<Document> listDocuments = collectionSamples.aggregate(
    Arrays.asList(
          Aggregates.group("$exp_group.topology", Accumulators.sum("total", 1)),
          Aggregates.sort(Sorts.orderBy(Sorts.descending("total")))
          ))
    .into(new ArrayList<Document>());
     */

    // ===== Group by sample =====
    /*
    List<Document> listSeries = collectionSeries
    .find()
    .projection(Projections.fields(Projections.include("title")))
    .sort(Sorts.ascending("_id"))
    .into(new ArrayList<Document>());
            
    for (Document doc : listSeries) {
            
       String idSeries = doc.getString("_id");
       Long nbSamples = collectionSamples.count((Filters.eq("series", idSeries)));
       doc.append("nbSamples", nbSamples);
    } 
    display(listSeries);
    */

    // === Export Geo for a list of idSeries ===

    // String[] listIdSeries = {"GSE11092","GSE13309", "GSE13159"};

    /*
    List<Document> docExpGroup = collectionSamples
    .find(Filters.in("series", listIdSeries))
    .projection(Projections.fields(Projections.include("exp_group"), Projections.excludeId()))
    .into(new ArrayList<Document>());
    // display(docExpGroup);
            
    List<String> header = formatService.extractHeader(docExpGroup, "exp_group");
    List<Object> data = formatService.extractData(docExpGroup, header, "exp_group");
    System.out.println(header);
    displayMatrix(data);
            
    */
    // List<Object> listObjects = formatService.convertHeterogeneousMongoDocuments(docExpGroup, "exp_group");
    // displayMatrix(listObjects);

    // List<Object> listObjects = formatService.convertHomogeneousMongoDocuments(listDocuments);

    // === Find series ===

    String[] listIdSamples = { "GSM80908", "GSM274639", "GSM274638", "GSM280213" };
    List<Document> listDocuments = collectionSamples
            .aggregate(Arrays.asList(Aggregates.match(Filters.in("_id", listIdSamples)),
                    Aggregates.group("$main_gse_number"),
                    Aggregates.sort(Sorts.orderBy(Sorts.ascending("main_gse_numbe")))))
            .into(new ArrayList<Document>());
    List<Object> listObjects = formatService.convertHomogeneousMongoDocuments(listDocuments);
    displayMatrix(listObjects);

    mongoClient.close();
}

From source file:module.script.TransferBrbAnnotations.java

License:Open Source License

@SuppressWarnings({ "unused", "unchecked" })
public TransferBrbAnnotations() {

    // ===== Session PostgreSQL =====
    SessionFactory sessionFactory = HibernateUtil
            .buildSessionFactory("config/epimed_semantic.hibernate.cfg.xml");
    Session session = sessionFactory.openSession();

    // ===== Session Mongo =====

    MongoClient mongoClient = MongoUtil.buildMongoClient();
    MongoDatabase db = mongoClient.getDatabase("epimed_experiments");

    MongoCollection<Document> collection = db.getCollection("samples");

    String sql = "select id_sample, main_gse_number, string_agg(id_substance, ', ') as list_substances from epimed_prod.om_sample "
            + "join epimed_prod.cl_biopatho using (id_biopatho) join epimed_prod.cl_patient using (id_patient) join epimed_prod.cl_exposure using (id_patient) "
            + "where exposed=true group by id_sample";

    List<Object> list = session.createSQLQuery(sql).setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP).list();

    for (Object item : list) {

        Map<String, Object> map = (HashMap<String, Object>) item;

        String gsmNumber = (String) map.get("id_sample");
        String gseNumber = (String) map.get("main_gse_number");

        System.out.println("-----------------------------");
        System.out.println(gseNumber + " " + gsmNumber);

        Document doc = collection.find(Filters.eq("_id", gsmNumber)).first();

        if (doc != null) {
            Document expGroup = (Document) doc.get("exp_group");
            expGroup.put("exposure", map.get("list_substances"));
            System.out.println(expGroup);

            // Update Mongo document
            doc.put("exp_group", expGroup);
            doc.put("analyzed", true);
            UpdateResult updateResult = collection.updateOne(Filters.eq("_id", gsmNumber),
                    new Document("$set", doc));
        }//from  w ww .ja  v a 2  s  .  co m

    }

    if (session.isOpen()) {
        session.close();
    }
    sessionFactory.close();

    mongoClient.close();
}

From source file:module.script.TransferBrbHistologyCodes.java

License:Open Source License

@SuppressWarnings({ "unused", "unchecked" })
public TransferBrbHistologyCodes() {

    // ===== Session PostgreSQL =====
    SessionFactory sessionFactory = HibernateUtil
            .buildSessionFactory("config/epimed_semantic.hibernate.cfg.xml");
    Session session = sessionFactory.openSession();

    // ===== Session Mongo =====

    MongoClient mongoClient = MongoUtil.buildMongoClient();
    MongoDatabase db = mongoClient.getDatabase("epimed_experiments");

    MongoCollection<Document> collection = db.getCollection("samples");

    String sql = "select id_sample, main_gse_number, index_histology_code, histology_code, ordered_histology_code from db_brb_lung.view_exp_group";

    List<Object> list = session.createSQLQuery(sql).setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP).list();

    for (Object item : list) {

        Map<String, Object> map = (HashMap<String, Object>) item;

        String gsmNumber = (String) map.get("id_sample");
        String gseNumber = (String) map.get("main_gse_number");

        System.out.println("-----------------------------");
        System.out.println(gseNumber + " " + gsmNumber);

        Document doc = collection.find(Filters.eq("_id", gsmNumber)).first();

        if (doc != null) {
            Document expGroup = (Document) doc.get("exp_group");
            expGroup.put("index_histology_code", map.get("index_histology_code"));
            expGroup.put("histology_code", map.get("histology_code"));
            expGroup.put("ordered_histology_code", map.get("ordered_histology_code"));
            System.out.println(expGroup);

            // Update Mongo document
            doc.put("exp_group", expGroup);
            doc.put("analyzed", true);
            UpdateResult updateResult = collection.updateOne(Filters.eq("_id", gsmNumber),
                    new Document("$set", doc));
        }//from w  w  w. j a v  a 2s .  co  m

    }

    if (session.isOpen()) {
        session.close();
    }
    sessionFactory.close();

    mongoClient.close();
}

From source file:module.script.TransferExposure.java

License:Open Source License

@SuppressWarnings({ "unused", "unchecked" })
public TransferExposure() {

    // ===== Session PostgreSQL =====
    SessionFactory sessionFactory = HibernateUtil
            .buildSessionFactory("config/epimed_semantic.hibernate.cfg.xml");
    Session session = sessionFactory.openSession();

    // ===== Session Mongo =====

    MongoClient mongoClient = MongoUtil.buildMongoClient();
    MongoDatabase db = mongoClient.getDatabase("epimed_experiments");

    MongoCollection<Document> collection = db.getCollection("samples");

    String sql = "select id_sample, main_gse_number, string_agg(id_substance, ', ') as list_substances from epimed_prod.om_sample "
            + "join epimed_prod.cl_biopatho using (id_biopatho) join epimed_prod.cl_patient using (id_patient) join epimed_prod.cl_exposure using (id_patient) "
            + "where exposed=true group by id_sample";

    List<Object> list = session.createSQLQuery(sql).setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP).list();

    for (Object item : list) {

        Map<String, Object> map = (HashMap<String, Object>) item;

        String gsmNumber = (String) map.get("id_sample");
        String gseNumber = (String) map.get("main_gse_number");

        System.out.println("-----------------------------");
        System.out.println(gseNumber + " " + gsmNumber);

        Document doc = collection.find(Filters.eq("_id", gsmNumber)).first();

        if (doc != null) {
            Document expGroup = (Document) doc.get("exp_group");
            expGroup.put("exposure", map.get("list_substances"));
            System.out.println(expGroup);

            // Update Mongo document
            doc.put("exp_group", expGroup);
            doc.put("analyzed", true);
            UpdateResult updateResult = collection.updateOne(Filters.eq("_id", gsmNumber),
                    new Document("$set", doc));
        }//w  w  w  .ja v  a 2  s .  c  om

    }

    if (session.isOpen()) {
        session.close();
    }
    sessionFactory.close();

    mongoClient.close();
}

From source file:module.script.TransferFromEpimedProd.java

License:Open Source License

@SuppressWarnings({ "unused", "unchecked" })
public TransferFromEpimedProd() {

    // ===== Session PostgreSQL =====
    SessionFactory sessionFactory = HibernateUtil
            .buildSessionFactory("config/epimed_semantic.hibernate.cfg.xml");
    Session session = sessionFactory.openSession();

    // ===== Session Mongo =====

    MongoClient mongoClient = MongoUtil.buildMongoClient();
    MongoDatabase db = mongoClient.getDatabase("epimed_experiments");

    MongoCollection<Document> collection = db.getCollection("samples");

    String sql = "select * from epimed_prod.view_exp_group order by main_gse_number, id_sample";
    List<Object> list = session.createSQLQuery(sql).setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP).list();

    String[] commonAttributes = { "pathology", "tnm_stage", "id_topology_group", "histology_subtype",
            "tissue_stage", "dead", "dfs_months", "age_max", "morphology", "id_tissue_stage", "topology", "sex",
            "age_min", "m", "topology_group", "n", "t", "collection_method", "id_morphology", "relapsed",
            "histology_type", "os_months", "id_topology" };

    List<ClPathology> listPathology = session.createCriteria(ClPathology.class).list();
    Map<String, ClPathology> mapPathology = new HashMap<String, ClPathology>();
    for (ClPathology p : listPathology) {
        mapPathology.put(p.getName(), p);
    }//from   w  w w.  j  a va  2 s . c  o  m

    List<ClTissueStatus> listTissueStatus = session.createCriteria(ClTissueStatus.class).list();
    Map<Integer, ClTissueStatus> mapTissueStatus = new HashMap<Integer, ClTissueStatus>();
    for (ClTissueStatus t : listTissueStatus) {
        mapTissueStatus.put(t.getIdTissueStatus(), t);
    }

    System.out.println(listTissueStatus);

    for (Object item : list) {

        Map<String, Object> map = (HashMap<String, Object>) item;

        String gsmNumber = (String) map.get("id_sample");
        String gseNumber = (String) map.get("main_gse_number");

        System.out.println("-----------------------------");
        System.out.println(gseNumber + " " + gsmNumber);

        Document doc = collection.find(Filters.eq("_id", gsmNumber)).first();

        if (doc != null) {
            Document expGroup = (Document) doc.get("exp_group");
            for (int j = 0; j < commonAttributes.length; j++) {
                String attr = commonAttributes[j];
                expGroup.put(attr, map.get(attr));
            }

            // Treatment
            expGroup.put("treatment", map.get("treatment_type"));

            // Pathology
            String pathoString = (String) map.get("pathology");
            ClPathology pathology = mapPathology.get(pathoString);
            if (pathology != null) {
                expGroup.put("id_pathology", pathology.getIdPathology());
                expGroup.put("pathology", pathology.getName());
            }

            // Tissue status
            Integer idTissueStatus = (Integer) map.get("id_tissue_status");
            if (idTissueStatus != null && idTissueStatus > 3) {
                idTissueStatus = 3;
            }
            ClTissueStatus tissueStatus = mapTissueStatus.get(idTissueStatus);
            if (tissueStatus != null) {
                expGroup.put("id_tissue_status", tissueStatus.getIdTissueStatus());
                expGroup.put("tissue_status", tissueStatus.getName());
            }

            System.out.println("idTissueStatus=" + tissueStatus + ", pathology=" + pathology);
            System.out.println(expGroup);

            // Update Mongo document
            doc.put("exp_group", expGroup);
            doc.put("analyzed", true);
            UpdateResult updateResult = collection.updateOne(Filters.eq("_id", gsmNumber),
                    new Document("$set", doc));
        }

    }

    if (session.isOpen()) {
        session.close();
    }
    sessionFactory.close();

    mongoClient.close();
}

From source file:module.test.CreateProbesets.java

License:Open Source License

public CreateProbesets() {

    // ===== Connection =====

    MongoClient mongoClient = MongoUtil.buildMongoClient();
    MongoDatabase db = mongoClient.getDatabase("epimed_experiments");
    MongoCollection<Document> collectionProbesets = db.getCollection("probesets");

    Document docProbeset = mongoService.createProbeset("GPL570", "1007_s_at");
    collectionProbesets.insertOne(docProbeset);
    mongoClient.close();

}

From source file:module.test.CustomExport.java

License:Open Source License

public CustomExport() {

    // ===== Connection =====

    MongoClient mongoClient = MongoUtil.buildMongoClient();
    MongoDatabase db = mongoClient.getDatabase("epimed_experiments");

    MongoCollection<Document> collection = db.getCollection("samples");

    // ===== Find exp_group in the database =====

    // === Query 1 ===
    /*/*from  www  . j  a va 2s  . c om*/
    String queryName = "breast_cancer_GPL570";
    List<Bson> filters = new ArrayList<Bson>();
    filters.add(Filters.eq("exp_group.id_platform", "GPL570"));
    filters.add(Filters.eq("exp_group.id_topology_group", "C50"));
    filters.add(Filters.eq("exp_group.id_tissue_status", 3)); // tumoral
     */

    // === Query 2 ===
    /*
    String queryName = "breast_normal_GPL570";
    List<Bson> filters = new ArrayList<Bson>();
    filters.add(Filters.eq("exp_group.id_platform", "GPL570"));
    filters.add(Filters.eq("exp_group.id_topology_group", "C50"));
    filters.add(Filters.eq("exp_group.id_tissue_status", 1)); // normal
    */

    // === Query 3 ===
    String queryName = "breast_cancer_with_survival_GPL570";
    List<Bson> filters = new ArrayList<Bson>();
    filters.add(Filters.eq("exp_group.id_platform", "GPL570"));
    filters.add(Filters.eq("exp_group.id_topology_group", "C50"));
    filters.add(Filters.eq("exp_group.id_tissue_status", 3)); // tumoral
    filters.add(Filters.or(Filters.ne("exp_group.os_months", null), Filters.ne("exp_group.dfss_months", null),
            Filters.ne("exp_group.relapsed", null), Filters.ne("exp_group.dead", null)));

    Bson filter = Filters.and(filters);
    Long nbSamples = collection.count(filter);
    List<String> listSeries = collection.distinct("exp_group.main_gse_number", filter, String.class)
            .into(new ArrayList<String>());
    queryName = queryName + "_" + nbSamples + "_samples_" + listSeries.size() + "_series";

    List<Document> docExpGroup = collection.find(filter)
            .projection(Projections.fields(Projections.include("exp_group"), Projections.excludeId()))
            .into(new ArrayList<Document>());

    List<Document> docParam = collection.find(filter)
            .projection(Projections.fields(Projections.include("parameters"), Projections.excludeId()))
            .into(new ArrayList<Document>());

    mongoClient.close();

    // ===== Load Exp Group into a matrix =====

    List<String> headerExpGroup = new ArrayList<String>();
    List<Object> dataExpGroup = new ArrayList<Object>();

    for (int i = 0; i < docExpGroup.size(); i++) {
        Map<String, String> expGroup = (Map<String, String>) docExpGroup.get(i).get("exp_group");
        if (i == 0) {
            headerExpGroup.addAll(expGroup.keySet());
        }

        Object[] dataLine = new Object[headerExpGroup.size()];
        for (int j = 0; j < headerExpGroup.size(); j++) {
            dataLine[j] = expGroup.get(headerExpGroup.get(j));
        }
        dataExpGroup.add(dataLine);
    }

    // ===== Load Params into a matrix =====

    Set<String> headerParamSet = new HashSet<String>();
    List<String> headerParam = new ArrayList<String>();
    List<Object> dataParam = new ArrayList<Object>();

    for (int i = 0; i < docParam.size(); i++) {
        Map<String, String> param = (Map<String, String>) docParam.get(i).get("parameters");
        headerParamSet.addAll(param.keySet());
    }
    headerParam.addAll(headerParamSet);
    Collections.sort(headerParam);

    for (int i = 0; i < docParam.size(); i++) {
        Map<String, String> param = (Map<String, String>) docParam.get(i).get("parameters");
        Object[] dataLine = new Object[headerParam.size()];
        for (int j = 0; j < headerParam.size(); j++) {
            dataLine[j] = param.get(headerParam.get(j));
        }
        // System.out.println(Arrays.toString(dataLine));
        dataParam.add(dataLine);

    }

    // === Output ===

    String fileName = this.getOutputDirectory() + this.getDirSeparator() + "EpiMed_database_" + queryName + "_"
            + dateFormat.format(new Date()) + ".xlsx";
    System.out.println(fileName);
    XSSFWorkbook workbook = fileService.createWorkbook();
    fileService.addSheet(workbook, "exp_group_" + dateFormat.format(new Date()), headerExpGroup, dataExpGroup);
    fileService.addSheet(workbook, "parameters_" + dateFormat.format(new Date()), headerParam, dataParam);
    fileService.writeWorkbook(workbook, fileName);

}

From source file:module.test.ImportProbesets.java

License:Open Source License

public ImportProbesets() {

    // === Display ===
    System.out.println("\n================ BEGIN Module " + this.getClass().getName() + "================");

    // ===== Connection =====

    MongoClient mongoClient = MongoUtil.buildMongoClient();
    MongoDatabase db = mongoClient.getDatabase("epimed_experiments");
    MongoCollection<Document> collectionProbesets = db.getCollection("probesets");

    // ===== Session PostgreSQL =====
    SessionFactory sessionFactory = HibernateUtil
            .buildSessionFactory("config/epimed_semantic.hibernate.cfg.xml");
    Session session = sessionFactory.openSession();

    String idPlatform = "GPL570";
    String gpl = idPlatform.toLowerCase();

    // ===== Load file =====

    String inputfile = this.getInputDirectory() + this.getDirSeparator() + "HG-U133_Plus_2.na36.annot.csv";

    System.out.println("ID Platform " + gpl);
    System.out.println("LOADING \t " + inputfile);
    System.out.println("Please wait... ");
    List<String> listRows = fileService.loadTextFile(inputfile);
    System.out.println("File sucessfully LOADED");

    // ===== Recognize header =====

    List<String> header = fileService.readHeader(listRows, "\",\"");
    System.out.println("Header " + header);
    List<List<String>> data = fileService.readData(listRows, "\",\"");
    System.out.println(//from w w  w.java2  s .c o  m
            "The data are sucessfully loaded: rows " + data.size() + ", columns " + data.get(0).size());

    Integer indProbeset = fileService.findIndex(header, "Probe Set ID");
    Integer indGenes = fileService.findIndex(header, "Entrez Gene");
    Integer indUnigenes = fileService.findIndex(header, "UniGene ID");
    Integer indTranscripts = fileService.findIndex(header, "RefSeq Transcript ID");
    Integer indGb = fileService.findIndex(header, "Representative Public ID");

    for (int i = 0; i < 5; i++) {
        List<String> dataline = data.get(i);

        String probeset = dataline.get(indProbeset);
        String genes = dataline.get(indGenes);
        String unigenes = dataline.get(indUnigenes);
        String transcripts = dataline.get(indTranscripts);
        String gb = dataline.get(indGb);

        System.out.println(probeset + "\t" + genes + "\t" + formatService.splitInArray(unigenes, "///") + "\t"
                + gb + "\t" + transcripts);

        Document docProbeset = mongoService.createProbeset(idPlatform, probeset);
        docProbeset.put("genes", formatService.splitInArray(genes, "///"));
        docProbeset.put("unigenes", formatService.splitInArray(unigenes, "///"));

        List<String> listTranscripts = formatService.splitInArray(transcripts, "///");
        listTranscripts.addAll(formatService.splitInArray(gb, "///"));

        docProbeset.put("transcripts", listTranscripts);

        collectionProbesets.insertOne(docProbeset);

        /*
        for (int j=0; j<dataline.size(); j++) {
           String key = header.get(j);
           String value = dataline.get(j);
           System.out.println(key + ": " + value);
        }
        */
    }

    /*
    String tableProbe = "hs.om_probe_" + gpl;
    String tableGP = "hs.om_gp_" + gpl;
    List<Object []> listProbesets = session.createNativeQuery("select * from " + tableProbe + " order by id_probe").getResultList();
    for (int i=0; i<10; i++) {
            
       Object[] line = listProbesets.get(i);
            
       System.out.println(Arrays.toString(line));
       // Document docProbeset = mongoService.createProbeset(idPlatform, "1007_s_at");
       // collectionProbesets.insertOne(docProbeset);
    }
     */

    // === Close connections ===

    if (session.isOpen()) {
        session.close();
    }
    sessionFactory.close();
    mongoClient.close();

    // === Display ===
    System.out.println("================ END Module " + this.getClass().getName() + "================");

}

From source file:module.test.SearchPlatforms.java

License:Open Source License

public SearchPlatforms() {

    // ===== Connection =====

    MongoClient mongoClient = MongoUtil.buildMongoClient();
    MongoDatabase db = mongoClient.getDatabase("epimed_experiments");
    MongoCollection<Document> collectionSamples = db.getCollection("sample");
    MongoCollection<Document> collectionPlatforms = db.getCollection("platform");

    List<Document> list = collectionSamples
            .aggregate(Arrays.asList(Aggregates.group("$exp_group.id_platform", Accumulators.sum("total", 1)),
                    Aggregates.sort(Sorts.orderBy(Sorts.descending("total")))))
            .into(new ArrayList<Document>());

    for (int i = 0; i < list.size(); i++) {
        System.out.println((i + 1) + " " + list.get(i));
    }/*from   w w  w.  ja  va2 s  .  co m*/

    // collectionPlatforms.find(Filters.regex("title", ".*ethyl.*")).forEach(printBlock);
    collectionPlatforms.find(Filters.eq("id_organism", "9606")).forEach(printBlock);

    mongoClient.close();

}