@Override protected ONDEXConcept reallyGetEntity(int i) { return aog.getConcept(i); } };
@Override public void start() throws Exception { Set<ONDEXConcept> conceptsWithNT = graph.getConceptsOfAttributeName(graph.getMetaData().getAttributeName("NA")); Set<ONDEXConcept> conceptsWithProteins = graph.getConceptsOfAttributeName(graph.getMetaData().getAttributeName("AA")); DecypherAlignment dcAlign = new DecypherAlignment( net.sourceforge.ondex.config.Config.ondexDir, getArguments().getUniqueValue(PROGRAM_DIR_ARG).toString(), 0, //cutff 0f, //% 0001f, //evalue 0, //bitscore Integer.MAX_VALUE, //max alignments false); Collection<Match> hits = dcAlign.query(graph, conceptsWithNT, conceptsWithProteins, BLASTAlignmentProgram.ALGO_BLASTX); RelationType h_s_s = graph.getMetaData().getRelationType("h_s_s"); EvidenceType ev = graph.getMetaData().createEvidenceType("BLASTx", "BLASTx", "BLASTx"); Set<EvidenceType> evs = new HashSet<EvidenceType>(); for (Match hit : hits) { //you might prefer to build an index query-->Hit if you want to take the best n ONDEXConcept query = graph.getConcept(hit.getQueryId()); ONDEXConcept hitTarget = graph.getConcept(hit.getTargetId()); ONDEXRelation relation = graph.createRelation(query, hitTarget, h_s_s, evs); //add some properties to the relations...etc } }
public static void colourByContexts(OVTK2PropertiesAggregator viewer) { ONDEXGraph graph = viewer.getONDEXJUNGGraph(); Color color = JColorChooser.showDialog(OVTK2Desktop.getInstance().getMainFrame(), "Choose Background Color", Color.blue); if (color == null) return; System.err.println(color); PickedState<ONDEXConcept> state = viewer.getVisualizationViewer().getPickedVertexState(); Set<ONDEXConcept> set = state.getPicked(); for (ONDEXConcept n : set) { ONDEXConcept context = graph.getConcept(n.getId()); Annotation.setColor(viewer, context, color); for (ONDEXConcept c : graph.getConceptsOfTag(context)) { Annotation.setColor(viewer, c, color); } } }
/** * @param id * @return * @see net.sourceforge.ondex.core.ONDEXGraph#getConcept(int) */ public ONDEXConcept getConcept(int id) { return og.getConcept(id); }
@Override protected ONDEXConcept reallyGetEntity(int i) { return aog.getConcept(i); } };
/** * Converts a collection of ids to a set of respective concepts * * @param graph * @param ids * @return */ public static Set<ONDEXConcept> toConcepts(ONDEXGraph graph, Collection<Integer> ids) { Set<ONDEXConcept> cs = new HashSet<ONDEXConcept>(); for (Integer id : ids) { cs.add(graph.getConcept(id)); } return cs; }
/** * Returns a bitset of neighbouring concepts at position 0 and all relations * at position 1 * * @param conceptID * @param graph * @return */ public static BitSet[] getNeighbours(int conceptID, ONDEXGraph graph) { return getNeighbours(graph.getConcept(conceptID), graph); }
@Override protected ONDEXConcept retrieveConcept(int id) { ONDEXConcept c = parent.getConcept(id); if (c != null) { return new LuceneConcept(sid, c); } else { return null; } }
private void rebuild() throws Exception { for (Integer id : temp_set.idToData.keySet()) { processConcept(graph.getConcept(id)); } }
public static BitSet[] getNeighbours(int conceptID, ONDEXGraph graph, Set<ONDEXRelation> validRelations) { return getNeighbours(graph.getConcept(conceptID), graph, validRelations); }
private void processedAddiotons(List<Integer> additions, int currentlevel) throws Exception { if (currentlevel > maxLevel) return; ids.addAll(additions); List<Integer> newAdditions = new LinkedList<Integer>(); for (Integer addition : additions) { newAdditions.addAll(processSeed(graph.getConcept(addition))); } if (newAdditions.size() > 0) processedAddiotons(newAdditions, ++currentlevel); }
public Collection<ONDEXConcept> getConceptSet() { Vector<ONDEXConcept> cs = new Vector<ONDEXConcept>(); HashMap<String, Integer> ccMap = new HashMap<String, Integer>(); for (int c : cons) { ONDEXConcept concept = aog.getConcept(c); cs.add(concept); String cc = concept.getOfType().getId(); Integer count = ccMap.get(cc); if (count == null) { ccMap.put(cc, 1); } else { ccMap.put(cc, count + 1); } } if (DEBUG) System.out.println(">>>>> found " + cs.size() + " concepts"); printMap(ccMap); return cs; }
/** * Clones a concept from the original graph to the new graph * * @param cid * the id of the concept in the original graph * @return the new Concept in the new graph */ public ONDEXConcept cloneConcept(int cid) { ONDEXConcept concept = origGraph.getConcept(cid); if (concept == null) { throw new NullPointerException(cid + " is not found in orginal Graph " + origGraph.getSID()); } return cloneConcept(concept); }
private Path(List<Integer> ids) throws MalformedPathException { path = new ONDEXEntity[ids.size()]; for (int i = 0; i < path.length; i++) { if (i % 2 == 0) { path[i] = og.getConcept(ids.get(i)); if (path[i] == null) { throw new MalformedPathException("No concept for id "+ids.get(i)); } } else { path[i] = og.getRelation(ids.get(i)); if (path[i] == null) { throw new MalformedPathException("No relation for id"+ids.get(i)); } } } } public ONDEXConcept head() {
private void mergeConcepts(final Set<Integer> cluster) { Iterator<Integer> it = cluster.iterator(); ONDEXConcept toKeep = graph.getConcept(it.next()); while (it.hasNext()) { ONDEXConcept toMerge = graph.getConcept(it.next()); for (ONDEXRelation r : graph.getRelationsOfConcept(toMerge)) { boolean retainId = false; if (this.relations.contains(r)) { relations.remove(r); retainId = true; } if (retainId) { relations.add(GraphElementManipulation.changeRelationVertex(graph, toMerge, toKeep, r)); } else { GraphElementManipulation.changeRelationVertex(graph, toMerge, toKeep, r); } } GraphElementManipulation.copyConceptAttributes(toMerge, toKeep); int cId = toMerge.getId(); concepts.add(toMerge); if (graph.getConcept(cId) != null) graph.deleteConcept(cId); } }
@Override public Font transform(ONDEXConcept n) { ONDEXConcept c = graph.getConcept(n.getId()); Attribute attribute = c.getAttribute(an); if (attribute != null) { Float size = (float) (((Double) attribute.getValue() / (Double) gdsMax) * (maxSize - minSize) + minSize); return newFont.deriveFont(size); } return newFont; } });
/** * Semantic Motif Search for list of genes * * @param accessions * @param regex * trait-related * @return OndexGraph containing the gene network */ public ONDEXGraph getGenes(Integer[] ids, String regex) { System.out.println("get genes function "+ids.length); AttributeName attTAXID = graph.getMetaData().getAttributeName("TAXID"); Set<ONDEXConcept> seed = new HashSet<ONDEXConcept>(); for (int id : ids) { ONDEXConcept c = graph.getConcept(id); if (c.getAttribute(attTAXID) != null && c.getAttribute(attTAXID).getValue().toString() .equals(taxID)) { seed.add(c); } } System.out.println("Now we will call findSemanticMotifs!"); ONDEXGraph subGraph = findSemanticMotifs(seed, regex); return subGraph; }
/** * Will add a specified tag concept to all members of this subgraph * * @param tag - a tag concept */ public void addTag(ONDEXConcept tag) { int conceptCounter = 0; for(ONDEXConcept c : concepts) { if (graph.getConcept(c.getId()) != null) { graph.getConcept(c.getId()).addTag(tag); conceptCounter++; } } int relationCounter = 0; for(ONDEXRelation r : relations) { if (graph.getRelation(r.getId()) != null) { graph.getRelation(r.getId()).addTag(tag); relationCounter++; } } System.err.println("Assigned tag to " + conceptCounter + " concepts and " + relationCounter + " relations."); }
/** * recursively builds the output graph based on the * consensus tree. * * @param n input cluster (call this method with the root cluster) */ private ONDEXConcept buildOutput(Cluster n) { ONDEXConcept c = graph.getFactory().createConcept("hierarchy_node:" + n.toString(), dataSource_unknown, cc_hierarchy, ev); BitSet kidleaves = new BitSet(usedConcepts.size()); if (n.getChildren() != null) { for (Cluster kid : n.getChildren()) { ONDEXConcept c_kid = buildOutput(kid); kidleaves.or((BitSet) kid.getKey()); graph.getFactory().createRelation(c_kid, c, rts_isp, ev); } } BitSet leaves = (BitSet) n.getKey().clone(); leaves.andNot((BitSet) kidleaves); for (int i = leaves.nextSetBit(0); i > -1; i = leaves.nextSetBit(i + 1)) { ONDEXConcept cl = graph.getConcept(iid2cid.get(i)); graph.getFactory().createRelation(cl, c, rts_isp, ev); } return c; }
/** * recursively builds an output graph based on a * single binary tree. * * @param n input node. (call this method with the root node) */ private ONDEXConcept buildOutput(Node n) { ONDEXConcept c; if (n.isLeaf()) { c = graph.getConcept(iid2cid.get(n.getId())); } else { c = graph.getFactory().createConcept("hierarchy_node:" + n.getId(), dataSource_unknown, cc_hierarchy, ev); c.createAttribute(an_theta, new Double(n.theta), false); c.createAttribute(an_logl, new Double(n.logF), false); ONDEXConcept cl = buildOutput(n.getChild(Node.LEFT)); ONDEXConcept cr = buildOutput(n.getChild(Node.RIGHT)); graph.getFactory().createRelation(cl, c, rts_isp, ev); graph.getFactory().createRelation(cr, c, rts_isp, ev); } return c; }