List of usage examples for com.mongodb BasicDBObject BasicDBObject
public BasicDBObject()
From source file:act.server.MongoDB.java
License:Open Source License
public List<Seq> getSeqWithRxnRef(Long rxnId) { List<Seq> seqs = new ArrayList<>(); BasicDBObject query = new BasicDBObject(); query.put("rxn_refs", rxnId); DBCursor cur = this.dbSeq.find(query, new BasicDBObject()); try {//from w w w . ja v a 2 s .c om while (cur.hasNext()) { DBObject o = cur.next(); seqs.add(convertDBObjectToSeq(o)); } } finally { if (cur != null) { cur.close(); } } return seqs; }
From source file:act.server.MongoDB.java
License:Open Source License
public DBIterator getDbIteratorOverOrgs(BasicDBObject matchCriterion, BasicDBObject keys) { if (keys == null) { keys = new BasicDBObject(); }//from w w w .j a v a2 s . c o m DBCursor cursor = this.dbOrganismNames.find(matchCriterion, keys); cursor = cursor.addOption(Bytes.QUERYOPTION_NOTIMEOUT); return new DBIterator(cursor); }
From source file:act.server.MongoDB.java
License:Open Source License
public String getOrganismNameFromId(Long id) { BasicDBObject query = new BasicDBObject(); query.put("org_id", id); BasicDBObject keys = new BasicDBObject(); keys.put("name", 1); if (this.dbOrganismNames != null) { DBObject cur = this.dbOrganismNames.findOne(query, keys); if (cur == null) { //System.out.println("Did not find in organismnames: " + name); return null; }/*from ww w .j av a 2 s . co m*/ return (String) cur.get("name"); } else { //System.out.println("no organism names collection"); } return null; }
From source file:act.server.MongoDB.java
License:Open Source License
public long getOrganismId(String name) { BasicDBObject query = new BasicDBObject(); query.put("name", name); BasicDBObject keys = new BasicDBObject(); keys.put("org_id", 1); if (this.dbOrganismNames != null) { DBObject cur = this.dbOrganismNames.findOne(query, keys); if (cur == null) { //System.out.println("Did not find in organismnames: " + name); return -1; }// w w w .jav a 2 s . c o m return (Long) cur.get("org_id"); // checked: db type IS long } else { //System.out.println("no organism names collection"); } return -1; }
From source file:act.server.MongoDB.java
License:Open Source License
public Set<Long> getOrganismIDs() { DBIterator iterator = getIteratorOverReactions(new BasicDBObject(), null); Set<Long> ids = new HashSet<Long>(); while (iterator.hasNext()) { DBObject r = iterator.next();//from w ww. java 2 s. com BasicDBList orgs = (BasicDBList) r.get("organisms"); for (Object o : orgs) { ids.add((Long) ((DBObject) o).get("id")); // checked: db type IS Long } } return ids; }
From source file:act.server.MongoDB.java
License:Open Source License
public Set<Long> getOrganismIDs(Long reactionID) { if (reactionID < 0) { reactionID = Reaction.reverseID(reactionID); }/* w ww. ja va 2 s . c o m*/ DBObject query = new BasicDBObject(); query.put("_id", reactionID); Set<Long> ids = new HashSet<Long>(); DBObject reaction = this.dbReactions.findOne(query); if (reaction != null) { BasicDBList orgs = (BasicDBList) reaction.get("organisms"); for (Object o : orgs) { ids.add((Long) ((DBObject) o).get("id")); // checked: db type IS long } } return ids; }
From source file:act.server.MongoDB.java
License:Open Source License
public List<P<Reaction.RefDataSource, String>> getReferences(Long reactionID) { if (reactionID < 0) { reactionID = Reaction.reverseID(reactionID); }//from ww w . j a v a 2 s. c om DBObject query = new BasicDBObject(); query.put("_id", reactionID); List<P<Reaction.RefDataSource, String>> refs = new ArrayList<>(); DBObject reaction = this.dbReactions.findOne(query); if (reaction != null) { BasicDBList dbrefs = (BasicDBList) reaction.get("references"); if (dbrefs != null) for (Object oo : dbrefs) { DBObject ref = (DBObject) oo; Reaction.RefDataSource src = Reaction.RefDataSource.valueOf((String) ref.get("src")); String val = (String) ref.get("val"); refs.add(new P<Reaction.RefDataSource, String>(src, val)); } } return refs; }
From source file:act.server.MongoDB.java
License:Open Source License
public Set<String> getKMValues(Long reactionID) { DBObject query = new BasicDBObject(); query.put("_id", reactionID); Set<String> kmSet = new HashSet<String>(); DBObject reaction = this.dbReactions.findOne(query); if (reaction != null) { BasicDBList kms = (BasicDBList) reaction.get("km_values"); if (kms != null) { for (Object km : kms) { kmSet.add((String) km); }/*from w w w. java 2s . c o m*/ } } return kmSet; }
From source file:act.server.MongoDB.java
License:Open Source License
public Set<String> getTurnoverNumbers(Long reactionID) { DBObject query = new BasicDBObject(); query.put("_id", reactionID); Set<String> turnoverSet = new HashSet<String>(); DBObject reaction = this.dbReactions.findOne(query); if (reaction != null) { BasicDBList turnovers = (BasicDBList) reaction.get("turnover_numbers"); if (turnovers != null) { for (Object turnover : turnovers) { turnoverSet.add((String) turnover); }/* ww w. j a v a 2 s . co m*/ } } return turnoverSet; }
From source file:act.server.MongoDB.java
License:Open Source License
public int submitToActSeqDB(Seq.AccDB src, String ec, String org, Long org_id, String seq, List<JSONObject> references, Set<Long> rxns, DBObject meta) { BasicDBObject doc = new BasicDBObject(); int id = new Long(this.dbSeq.count()).intValue(); doc.put("_id", id); doc.put("src", src.name()); // genbank, uniprot, swissprot, trembl, embl doc.put("ecnum", ec); doc.put("org", org); doc.put("org_id", org_id); // this is the NCBI Taxonomy id, should correlate with db.organismnames{org_id} and db.organisms.{id} doc.put("seq", seq); BasicDBList refs = new BasicDBList(); for (JSONObject ref : references) { refs.add(MongoDBToJSON.conv(ref)); }// w w w .j ava 2 s . com doc.put("references", refs); doc.put("metadata", meta); // the metadata contains the uniprot acc#, name, uniprot catalytic activity, Object accession = meta.get("accession"); doc.put("rxn_refs", to_dblist(rxns)); this.dbSeq.insert(doc); if (org != null && seq != null) System.out.format("Inserted %s = [%s, %s] = %s %s\n", accession, ec, org.substring(0, Math.min(10, org.length())), seq.substring(0, Math.min(20, seq.length())), refs); return id; }