/** * @param concept * @return * @see net.sourceforge.ondex.core.ONDEXGraph#getRelationsOfConcept(net.sourceforge.ondex.core.ONDEXConcept) */ public Set<ONDEXRelation> getRelationsOfConcept(ONDEXConcept concept) { return og.getRelationsOfConcept(concept); }
@Override protected Set<ONDEXRelation> retrieveRelationAllConcept(ONDEXConcept concept) { return parent.getRelationsOfConcept(concept); }
@Override public boolean accepts() { ONDEXGraph graph = viewer.getONDEXJUNGGraph(); for (ONDEXConcept n : entities) { if (!graph.getRelationsOfConcept(n).isEmpty()) return true; } return false; }
@Override public boolean accepts() { ONDEXGraph graph = viewer.getONDEXJUNGGraph(); for (ONDEXConcept c : entities) { if (!graph.getRelationsOfConcept(c).isEmpty()) return true; } return false; }
public static Set<ONDEXRelation> getAllConnectingEdges(ONDEXGraph graph, ONDEXConcept a, ONDEXConcept b) { Set<ONDEXRelation> rs = new HashSet<ONDEXRelation>(); for (ONDEXRelation z : graph.getRelationsOfConcept(a)) { if (b.equals(getOtherNode(a, z))) { rs.add(z); } } return rs; }
private static Set<ONDEXRelation> withinGroupRelations(ONDEXGraph graph, Collection<ONDEXConcept> cs) { Set<ONDEXRelation> rs = new HashSet<ONDEXRelation>(); for (ONDEXConcept c : cs) { Collection<ONDEXRelation> rsOfc = graph.getRelationsOfConcept(c); for (ONDEXRelation rOfc : rsOfc) { if (cs.contains(getOtherNode(c, rOfc))) { rs.add(rOfc); } } } return rs; }
/** * Calculates degree centrality on the ONDEX graph. Result returned as a map * of concept to its degree centrality value. * * @return Object2DoubleOpenHashMap<ONDEXConcept> * @throws AccessDeniedException * @throws NullValueException */ public static final Map<ONDEXConcept, Double> getDegreeCentrality(Set<ONDEXConcept> itc, Set<ONDEXRelation> itr, ONDEXGraph aog) throws NullValueException, AccessDeniedException { Map<ONDEXConcept, Double> conceptToDegree = new HashMap<ONDEXConcept, Double>(); double normalisationFactor = itc.size() - 1; for (ONDEXConcept c : itc) { if (itr.size() == aog.getRelations().size()) conceptToDegree.put(c, aog.getRelationsOfConcept(c).size() / normalisationFactor); else conceptToDegree.put(c, BitSetFunctions.and(aog.getRelationsOfConcept(c), itr).size() / normalisationFactor); } return conceptToDegree; }
public static Set<ONDEXConcept> filteroutUnconnected(ONDEXGraph graph, Set<ONDEXConcept> setOfConcepts, Set<ONDEXRelation> validRelations) { BitSet resultSet = new BitSet(); for (ONDEXConcept c : setOfConcepts) { if (BitSetFunctions.and(graph.getRelationsOfConcept(c), validRelations).size() > 0) resultSet.set(c.getId()); } Set<ONDEXConcept> result = BitSetFunctions.create(graph, ONDEXConcept.class, resultSet); return result; }
/** * Returns all outgoing relations of concept * * @param graph * - graph * @param c * - concept * @param exclude * - ignore retalions of these types * @return - set of relations */ public static final Set<ONDEXRelation> getOutgoingRelations(ONDEXGraph graph, ONDEXConcept c, RelationType... exclude) { Set<RelationType> toExclude = new HashSet<RelationType>(Arrays.asList(exclude)); Set<ONDEXRelation> result = new HashSet<ONDEXRelation>(); for (ONDEXRelation r : graph.getRelationsOfConcept(c)) { if (r.getFromConcept().equals(c) && !toExclude.contains(r.getOfType())) result.add(r); } return result; }
/** * Returns all outgoing relations of concept c that connect it to one of the * concepts of selected concept class(es) * * @param graph * - graph * @param c * - concept * @return - set of relations */ public static final Set<ONDEXRelation> getOutgoingRelationsToConceptClass(ONDEXGraph graph, ONDEXConcept c, ConceptClass... ccs) { Set<ONDEXRelation> result = new HashSet<ONDEXRelation>(); Set<ConceptClass> test = new HashSet<ConceptClass>(Arrays.asList(ccs)); for (ONDEXRelation r : graph.getRelationsOfConcept(c)) { if (r.getFromConcept().equals(c) && (test.size() == 0 || test.contains(r.getToConcept().getOfType()))) result.add(r); } return result; }
/** * Returns all incoming relations of conceptc that connect it to one of the * concepts of selected concept class(es) * * @param graph * - graph * @param c * - concept * @return - set of relations */ public static final Set<ONDEXRelation> getIncomingRelationsToConceptClass(ONDEXGraph graph, ONDEXConcept c, ConceptClass... ccs) { Set<ONDEXRelation> it = graph.getRelationsOfConcept(c); Set<ONDEXRelation> result = new HashSet<ONDEXRelation>(); Set<ConceptClass> test = new HashSet<ConceptClass>(Arrays.asList(ccs)); for (ONDEXRelation r : it) { if (r.getToConcept().equals(c) && (test.size() == 0 || test.contains(r.getToConcept().getOfType()))) result.add(r); } return result; }
public static Set<ONDEXConcept> getOtherNodesIncoming(ONDEXGraph graph, ONDEXConcept c, RelationType... types) { Set<RelationType> restriction = new HashSet<RelationType>(); boolean performCheck = false; if (types != null && types.length > 0) { performCheck = true; restriction.addAll(Arrays.asList(types)); } Set<ONDEXConcept> result = new HashSet<ONDEXConcept>(); for (ONDEXRelation r : graph.getRelationsOfConcept(c)) { if (!r.getToConcept().equals(c)) { continue; } if (!performCheck || restriction.contains(r.getOfType())) { result.add(getOtherNode(c, r)); } } return result; }
/** * Returns an array of two bitset of neighbouring concepts at array position * 0 and all relations at array position 1 * * @param seed * @param graph * @return */ public static BitSet[] getNeighbours(ONDEXConcept seed, ONDEXGraph graph) { BitSet[] result = new BitSet[2]; result[0] = new BitSet(); // concepts result[1] = new BitSet(); // relations for (ONDEXRelation r : graph.getRelationsOfConcept(seed)) { result[0].set(StandardFunctions.getOtherNode(seed, r).getId()); result[1].set(r.getId()); } return result; }
private static Set<ONDEXRelation> getRelationsWithAttribute(ONDEXGraph graph, ONDEXConcept c, AttributeName an) { BitSet set = new BitSet(); for (ONDEXRelation r : graph.getRelationsOfConcept(c)) { if (r.getFromConcept().equals(r.getToConcept())) continue; if (r.getAttribute(an) != null) set.set(r.getId()); } Set<ONDEXRelation> result = BitSetFunctions.create(graph, ONDEXRelation.class, set); return result; }
public static void copyRelations(ONDEXGraph graph, ONDEXConcept copySource, ONDEXConcept copyTarget) { for (ONDEXRelation r : graph.getRelationsOfConcept(copySource)) { ONDEXConcept from = r.getFromConcept(); ONDEXConcept to = r.getToConcept(); if (from.equals(copySource)) { from = copyTarget; } else { to = copyTarget; } copyRelation(graph, from, to, r); } } }
private void recurseState(State s) throws InterruptedException { int nextDepth = s.depth + 1; for (ONDEXRelation r : og.getRelationsOfConcept(s.concept)) { if ((foundRelations.get(r) == null || nextDepth < foundRelations .get(r)) && validateRelationAtDepth(r, nextDepth, s.concept)) { foundRelations.put(r, nextDepth); addAndRecurseConcept(r.getFromConcept(), nextDepth); addAndRecurseConcept(r.getToConcept(), nextDepth); } } }
/** * returns a hashset with the protein families that are connected with the * given concept. * * @param c the concept * @return a hashset of pfams that are connected */ private HashSet<ONDEXConcept> getConnectedPfams(ONDEXConcept c) { HashSet<ONDEXConcept> set = new HashSet<ONDEXConcept>(); for (ONDEXRelation inOrOutRelation : graph.getRelationsOfConcept(c)) { if (inOrOutRelation.getOfType().equals(rts_seq2pfam)) { ONDEXConcept otherEnd = (inOrOutRelation.getFromConcept().equals(c)) ? inOrOutRelation.getToConcept() : inOrOutRelation.getFromConcept(); if (otherEnd.getOfType().equals(cc_protFam)) { set.add(otherEnd); } } } return set; }
/** * Which concepts are taking part in modifier relations for a given concept. * * @param c * ONDEXConcept with relations * @return modifier concepts */ private Set<ONDEXConcept> getModifiers(ONDEXConcept c) { Set<ONDEXConcept> output = new HashSet<ONDEXConcept>(); for (ONDEXRelation r : graph.getRelationsOfConcept(c)) { if (!proc_subset || sourceRelations.contains(r)) { String relationType = r.getOfType().getFullname(); if (relationType == null) relationType = r.getOfType().getId(); if (relationTypeToRegArc.contains(relationType) && !getSource(r).equals(c)) { output.add(getSource(r)); } } } return output; }
private void propagate(BitSet toKeep, ONDEXConcept c, int l) throws NullValueException, AccessDeniedException { if (l > depth) return; if (toKeep.get(c.getId())) return; toKeep.set(c.getId()); for (ONDEXRelation r : graph.getRelationsOfConcept(c)) { if (!r.getToConcept().equals(c)) { propagate(toKeep, r.getToConcept(), l + 1); } else { propagate(toKeep, r.getFromConcept(), l + 1); } } }
public static void filterByClassHasRt(OVTK2PropertiesAggregator viewer, String cls, String rt) { ONDEXGraph graph = viewer.getONDEXJUNGGraph(); ONDEXJUNGGraph jung = viewer.getONDEXJUNGGraph(); Set<ONDEXConcept> del = new HashSet<ONDEXConcept>(); for (ONDEXConcept c : graph.getConceptsOfConceptClass(createCC(graph, cls))) { boolean keep = false; for (ONDEXRelation r : graph.getRelationsOfConcept(c)) { if (r.getOfType().getId().equals(rt)) { keep = true; break; } } if (!keep) { del.add(c); } } for (ONDEXConcept c : del) { // graph.deleteConcept(c.getId()); jung.setVisibility(c, false); } }