Skip to content
This repository has been archived by the owner on Sep 24, 2019. It is now read-only.

Commit

Permalink
fix associate to kam with invalid BEL CyNodes
Browse files Browse the repository at this point in the history
closes #18
  • Loading branch information
Anthony Bargnesi committed Jun 27, 2013
1 parent 1af7799 commit abd5b83
Showing 1 changed file with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public void run() {
int nodeCount = network.getNodeCount();
int[] nodes = network.getNodeIndicesArray();
List<Node> wsNodes = new ArrayList<Node>(nodeCount);
List<CyNode> cyNodes = new ArrayList<>(nodes.length);
for (int idx : nodes) {
CyNode node = (CyNode) network.getNode(idx);
String nodeId = node.getIdentifier();
Expand All @@ -119,6 +120,10 @@ public void run() {
continue;
}

// track queryable cytoscape node
cyNodes.add(node);

// build up WebAPI Node objects for query
Node wsNode = new Node();
wsNode.setFunction(fx);
wsNode.setLabel(nodeId);
Expand All @@ -133,22 +138,25 @@ public void run() {

m.setPercentCompleted(60);

// hard assertion; resolveNodes web operation should be congruent
if (cyNodes.size() != resolvedNodes.size())
throw new AssertionError("len(cyNodes) != len(resolvedNodes)");

// update non-null nodes; index to ease resolve edges
int nc = resolvedNodes.size();
Map<String, Node> cyNodeResolveMap = new HashMap<String, Node>(nc);
Iterator<KamNode> nit = resolvedNodes.iterator();
for (int idx : nodes) {
CyNode node = (CyNode) network.getNode(idx);
for (int i = 0; i < nc; i++) {
CyNode node = cyNodes.get(i);
if (node == null) continue;

if (nit.hasNext()) {
KamNode resolved = nit.next();
if (resolved != null) {
updateNode(node, kamId, resolved);
cyNodeResolveMap.put(node.getIdentifier(), resolved);
} else {
disassociate(node);
}
KamNode resolved = resolvedNodes.get(i);
if (resolved == null) {
disassociate(node);
continue;
}

updateNode(node, kamId, resolved);
cyNodeResolveMap.put(node.getIdentifier(), resolved);
}

// resolve edges
Expand Down

0 comments on commit abd5b83

Please sign in to comment.