private boolean isDiseaseObject(Renderable r, Set<Long> diseaseIds) { if (r instanceof FlowLine) { FlowLine fl = (FlowLine) r; return isFlowLineRelatedToSet(fl, diseaseIds); } // Assume normal objects only: this is a very strong assumption if (r.getReactomeId() == null) return false; // A PE may be represented multiple times in a pathway diagram. Some of them // are linked to normal reactions, and some linked to disease reactions. // Have to check these cases. if (r instanceof HyperEdge) return diseaseIds.contains(r.getReactomeId()); if (r instanceof Node) { Node node = (Node) r; List<HyperEdge> edges = node.getConnectedReactions(); boolean isDisease = false; for (HyperEdge edge : edges) { if (edge instanceof FlowLine) { isDisease = isFlowLineRelatedToSet((FlowLine) edge, diseaseIds); } else if (edge.getReactomeId() != null && diseaseIds.contains(edge.getReactomeId())) { isDisease = true; } if (isDisease) return true; } } return false; }
private boolean isNormalObject(Renderable r, Set<Long> normalIds) { if (r instanceof HyperEdge) { if (r instanceof FlowLine) return isFlowLineRelatedToSet((FlowLine) r, normalIds); // Most likely the following statements should not be reached. But place // here just in case. if (r.getReactomeId() == null) return true; if (normalIds.contains(r.getReactomeId())) return true; } else if (r instanceof Node) { if (r instanceof ProcessNode) return true; // Should be used only for normal pathway. if (r.getReactomeId() == null) return true; // Check if it is linked to another disease entities Node node = (Node) r; List<HyperEdge> edges = node.getConnectedReactions(); boolean isNormal = false; for (HyperEdge edge : edges) { if (edge instanceof FlowLine) isNormal = isFlowLineRelatedToSet((FlowLine) edge, normalIds); if (isNormal) return true; if (edge.getReactomeId() != null && normalIds.contains(edge.getReactomeId())) return true; // Some special cases that use links if (!(edge instanceof EntitySetAndEntitySetLink) && !(edge instanceof EntitySetAndMemberLink) && edge.getReactomeId() == null) return true; } } return false; }