Пример #1
0
 @Override
 public Collection<CyNode> getNeighbours(CyNode node) {
   Collection<CyNode> neighbours = new HashSet<CyNode>();
   CyNetwork network = getProxied();
   int nodeIndex = node.getRootGraphIndex();
   for (int index : network.getAdjacentEdgeIndicesArray(nodeIndex, true, true, true)) {
     CyEdge edge = (CyEdge) network.getEdge(index);
     CyNode other = (CyNode) edge.getSource();
     if (other.getRootGraphIndex() == nodeIndex) {
       other = (CyNode) edge.getTarget();
       if (other.getRootGraphIndex() == nodeIndex) {
         continue;
       }
     }
     neighbours.add((CyNode) other);
   }
   return neighbours;
 }
    public gpClique[] creategpClique() {
      gpClique[] gps = new gpClique[2];
      gps[0] = new gpClique();
      gps[1] = new gpClique();

      Iterator<Edge> edgeIt = nw.edgesIterator();
      CyAttributes edgeAtt = Cytoscape.getEdgeAttributes();

      ArrayList largeALNodes = new ArrayList();
      ArrayList targetALNodes = new ArrayList();
      ArrayList matchALNodes = new ArrayList();
      while (edgeIt.hasNext()) {

        Edge edge = edgeIt.next();
        if (edgeAtt.getStringAttribute(edge.getIdentifier(), "interaction").equals("p2")) {
          largeALNodes.add(new Integer(nw.getEdgeSourceIndex(edge.getRootGraphIndex())));
          largeALNodes.add(new Integer(nw.getEdgeTargetIndex(edge.getRootGraphIndex())));
          continue; // go directly next step
        }
        if (edgeAtt.getStringAttribute(edge.getIdentifier(), "interaction").equals("p1")) {
          targetALNodes.add(new Integer(nw.getEdgeSourceIndex(edge.getRootGraphIndex())));
          targetALNodes.add(new Integer(nw.getEdgeTargetIndex(edge.getRootGraphIndex())));
          continue;
        }
        if (edgeAtt.getStringAttribute(edge.getIdentifier(), "interaction").equals("pd")) {
          matchALNodes.add(
              new Integer(
                  nw.getEdgeSourceIndex(
                      edge
                          .getRootGraphIndex()))); // the matched node(containing "-") of target
                                                   // network
          matchALNodes.add(
              new Integer(
                  nw.getEdgeTargetIndex(
                      edge
                          .getRootGraphIndex()))); // the matched node(containing "-") of large
                                                   // network
          continue;
        }
        JOptionPane.showMessageDialog(Cytoscape.getDesktop(), "File Format error!");
        return null;
      }

      Iterator matchALNIt = matchALNodes.iterator();
      CyNode node;
      Integer it;
      while (matchALNIt.hasNext()) {
        it = (Integer) matchALNIt.next();
        node =
            Cytoscape.getCyNode(
                nw.getNode(it.intValue()).getIdentifier().substring(1),
                true); // get node according to its identifier
        matchNodes.add(node);
        if (!targetALNodes.contains(
            node.getRootGraphIndex())) // matched node,but not a node of network
        {
          nw.addNode(node);
          targetALNodes.add(node.getRootGraphIndex()); // add to network
        }

        it = (Integer) matchALNIt.next();
        node =
            Cytoscape.getCyNode(
                nw.getNode(it.intValue()).getIdentifier().substring(1),
                true); // get node according to its identifier
        matchNodes.add(node);
        if (!largeALNodes.contains(node.getRootGraphIndex())) {
          nw.addNode(node);
          largeALNodes.add(node.getRootGraphIndex());
        }
      }

      gps[0].setgpNodes(largeALNodes);
      gps[1].setgpNodes(targetALNodes);
      return gps;
    }