private Collection getNeighbors(CyNode node) { Set result = new HashSet(); Collection edges = network.getAdjacentEdgeList(node, org.cytoscape.model.CyEdge.Type.ANY); if (edges == null || edges.size() == 0) return result; Long targetID = node.getSUID(); for (Iterator iterator = edges.iterator(); iterator.hasNext(); ) { CyEdge curEdge = (CyEdge) iterator.next(); if (curEdge.getSource().getSUID() != targetID) result.add(curEdge.getSource()); else if (curEdge.getTarget().getSUID() != targetID) result.add(curEdge.getTarget()); } return result; }
/** {@inheritDoc} */ @Override public void mapToTable(Graph graph, Edge edge, Evidence evidence, CyTable table) { if (graph == null) throw new NullPointerException("graph cannot be null"); if (edge == null) throw new NullPointerException("edge cannot be null"); if (evidence == null) throw new NullPointerException("evidence cannot be null"); if (table == null) throw new NullPointerException("table cannot be null"); if (graph.cyNetwork == null) throw new IllegalArgumentException("graph's cyNetwork cannot be null"); if (edge.cyEdge == null) throw new IllegalArgumentException("edge's cyEdge cannot be null"); CyNetwork cyN = graph.cyNetwork; CyEdge cyE = edge.cyEdge; CyRow networkRow = cyN.getRow(cyN); String networkName = networkRow.get(CyNetwork.NAME, String.class); CyRow row = table.getRow(SUIDFactory.getNextSUID()); row.set(NETWORK_SUID, cyN.getSUID()); row.set(NETWORK_NAME, networkName); row.set(EDGE_SUID, cyE.getSUID()); row.set(BEL_STATEMENT, evidence.belStatement); row.set(SUMMARY_TEXT, evidence.summaryText); if (evidence.citation != null) { row.set(CITATION_TYPE, evidence.citation.type); row.set(CITATION_ID, evidence.citation.id); row.set(CITATION_NAME, evidence.citation.name); } if (evidence.biologicalContext != null) { // create any annotation columns that do not already exist BiologicalContext bc = evidence.biologicalContext; for (String varyingKey : bc.variedAnnotations.keySet()) { getOrCreateColumn(varyingKey, String.class, false, table); } // set annotation values row.set(SPECIES, bc.speciesCommonName); Map<String, Object> varying = bc.variedAnnotations; for (Entry<String, Object> entry : varying.entrySet()) { row.set(entry.getKey(), getOrEmptyString(entry.getKey(), varying)); } } }