Example usage for com.mongodb BasicDBObject BasicDBObject

List of usage examples for com.mongodb BasicDBObject BasicDBObject

Introduction

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

Prototype

public BasicDBObject(final String key, final Object value) 

Source Link

Document

Creates an object with the given key/value

Usage

From source file:act.server.MongoDB.java

License:Open Source License

private void createCofactorsIndex(String field, boolean hashedIndex) {
    if (hashedIndex) {
        this.dbCofactors.createIndex(new BasicDBObject(field, "hashed"));
    } else {//from   w w  w. j a  v a2 s.  c o  m
        this.dbCofactors.createIndex(new BasicDBObject(field, 1));
    }
}

From source file:act.server.MongoDB.java

License:Open Source License

private void createChemicalsIndex(String field, boolean hashedIndex) {
    if (hashedIndex) {
        this.dbChemicals.createIndex(new BasicDBObject(field, "hashed"));
    } else {//  www.jav  a2 s.c om
        this.dbChemicals.createIndex(new BasicDBObject(field, 1));
    }
}

From source file:act.server.MongoDB.java

License:Open Source License

private void createSeqIndex(String field, boolean hashedIndex) {
    if (hashedIndex) {
        this.dbSeq.createIndex(new BasicDBObject(field, "hashed"));
    } else {//from  w w w.  ja  va 2 s  .c  om
        this.dbSeq.createIndex(new BasicDBObject(field, 1));
    }
}

From source file:act.server.MongoDB.java

License:Open Source License

private void createOrganismNamesIndex(String field) {
    this.dbOrganismNames.createIndex(new BasicDBObject(field, 1));
}

From source file:act.server.MongoDB.java

License:Open Source License

public void updateChemicalWithBingSearchResults(String inchi, String bestName, BasicDBObject metadata) {
    Chemical c = this.getChemicalFromInChI(inchi);
    if (c != null) {
        long id = c.getUuid();
        BasicDBObject set = new BasicDBObject("xref.BING.metadata", metadata);
        set.put("xref.BING.dbid", bestName);
        BasicDBObject query = new BasicDBObject("_id", id);
        BasicDBObject update = new BasicDBObject("$set", set);
        this.dbChemicals.update(query, update);
    }//  w w w .j av  a  2s  . co  m
}

From source file:act.server.MongoDB.java

License:Open Source License

public DBCursor fetchNamesAndUsageForInchis(Set<String> inchis) {
    BasicDBList inchiList = new BasicDBList();
    inchiList.addAll(inchis);// w w w  .j  a v  a2  s.co  m
    BasicDBObject inClause = new BasicDBObject("$in", inchiList);
    BasicDBObject whereQuery = new BasicDBObject("InChI", inClause);
    whereQuery.put("xref.BING", new BasicDBObject("$exists", true));
    BasicDBObject fields = new BasicDBObject();
    fields.put("InChI", true);
    fields.put("names.brenda", true);
    fields.put("xref", true);
    DBCursor cursor = dbChemicals.find(whereQuery, fields);
    return cursor;
}

From source file:act.server.MongoDB.java

License:Open Source License

public NamesOfMolecule fetchNamesFromInchi(String inchi) {
    BasicDBObject whereQuery = new BasicDBObject("InChI", inchi);
    BasicDBObject fields = new BasicDBObject();
    fields.put("InChI", true);
    fields.put("names.brenda", true);
    fields.put("xref.CHEBI.metadata.Synonym", true);
    fields.put("xref.DRUGBANK.metadata", true);
    fields.put("xref.METACYC.meta", true);
    fields.put("xref.WIKIPEDIA.metadata.article", true);

    BasicDBObject c = (BasicDBObject) dbChemicals.findOne(whereQuery, fields);
    if (c == null) {
        return null;
    }/*ww  w . j  a va 2s.  c o m*/
    NamesOfMolecule moleculeNames = getNamesFromBasicDBObject(c);
    return moleculeNames;
}

From source file:act.server.MongoDB.java

License:Open Source License

public boolean hasBingSearchResultsFromInchi(String inchi) {
    BasicDBObject whereQuery = new BasicDBObject("InChI", inchi);
    BasicDBObject existsQuery = new BasicDBObject("$exists", true);
    whereQuery.put("xref.BING", existsQuery);
    BasicDBObject fields = new BasicDBObject();
    BasicDBObject c = (BasicDBObject) dbChemicals.findOne(whereQuery, fields);
    return (c != null);
}

From source file:act.server.MongoDB.java

License:Open Source License

/**
 * This function retrieves the ChEBI ID corresponding to an InChI. In the (frequent) case where no ChEBI xref is
 * present, null is returned./*w w  w  .j ava2 s  .  c o m*/
 * @param inchi input InChI representation of the chemical
 * @return String: the ChEBI ID corresponding to the InChI representation provided
 */
public String getChebiIDFromInchi(String inchi) {
    BasicDBObject whereQuery = new BasicDBObject("InChI", inchi);
    BasicDBObject existsQuery = new BasicDBObject("$exists", true);
    whereQuery.put("xref.CHEBI", existsQuery);
    BasicDBObject c = (BasicDBObject) dbChemicals.findOne(whereQuery, new BasicDBObject());
    if (c == null) {
        return null;
    } else {
        BasicDBObject xref = (BasicDBObject) c.get("xref");
        BasicDBObject chebi = (BasicDBObject) xref.get("CHEBI");
        return (String) chebi.get("dbid");
    }
}

From source file:act.server.MongoDB.java

License:Open Source License

/**
 * This function retrieves the chemical corresponding to a ChEBI ID and update its metadata with the ChEBI
 * applications provided//  ww w  . j  a v a2  s  .  c om
 * @param chebiId ChEBI ID for the chemical to update
 * @param applicationSet Set of main and direct ChEBI applications, represented in a ChebiApplicationSet
 */
public void updateChemicalWithChebiApplications(String chebiId,
        BrendaChebiOntology.ChebiApplicationSet applicationSet) {
    Chemical c = this.getChemicalFromChebiId(chebiId);
    if (c != null && applicationSet != null) {
        long id = c.getUuid();
        BasicDBObject query = new BasicDBObject("_id", id);
        BasicDBObject update = new BasicDBObject("$set",
                new BasicDBObject("xref.CHEBI.metadata.applications", applicationSet.toBasicDBObject()));
        this.dbChemicals.update(query, update);
    }
}