Author: scooter
Date: 2011-06-24 23:09:03 -0700 (Fri, 24 Jun 2011)
New Revision: 25941

Modified:
   
cytoscape/trunk/application/src/main/java/cytoscape/data/readers/XGMMLParser.java
   
cytoscape/trunk/application/src/main/java/cytoscape/data/readers/XGMMLReader.java
   
cytoscape/trunk/application/src/main/java/cytoscape/data/writers/XGMMLWriter.java
Log:
Some fixes to handle complex group cases.


Modified: 
cytoscape/trunk/application/src/main/java/cytoscape/data/readers/XGMMLParser.java
===================================================================
--- 
cytoscape/trunk/application/src/main/java/cytoscape/data/readers/XGMMLParser.java
   2011-06-25 04:38:44 UTC (rev 25940)
+++ 
cytoscape/trunk/application/src/main/java/cytoscape/data/readers/XGMMLParser.java
   2011-06-25 06:09:03 UTC (rev 25941)
@@ -153,6 +153,7 @@
        private HashMap<String,CyNode> idMap = null;
        /* Map of group nodes to children */
        private HashMap<CyNode,List<CyNode>> groupMap = null;
+       private HashMap<CyNode,List<CyEdge>> groupEdgeMap = null;
        /* List of nodes we weren't able to resolve */
        private HashMap<CyNode, CyEdge> unresolvedNodeMap = null;
        /* List of edges we weren't able to resolve */
@@ -623,7 +624,11 @@
                return groupMap;
        }
 
+       HashMap<CyNode, List<CyEdge>> getGroupEdgeMap() {
+               return groupEdgeMap;
+       }
 
+
        void setMetaData(CyNetwork network) {
                MetadataParser mdp = new MetadataParser(network);
                if (RDFType != null)
@@ -972,6 +977,13 @@
                        } else if (sourceAlias != null && targetAlias != null) {
                                currentEdge = createEdge(sourceAlias, 
targetAlias, interaction, label);
                        }
+
+                       // If we're part of a group, this edge needs to be 
remembered as (possibly) an
+                       // inner or outer edge
+                       if (currentGroupNode != null) {
+                               List<CyEdge> groupEdges = 
groupEdgeMap.get(currentGroupNode);
+                               groupEdges.add(currentEdge);
+                       }
                        
                        return current;
                }
@@ -1024,9 +1036,11 @@
        class handleGroup implements Handler {
                public ParseState handle(String tag, Attributes atts, 
ParseState current) throws SAXException {
                        if (groupMap == null) groupMap = new HashMap<CyNode, 
List<CyNode>>();
+                       if (groupEdgeMap == null) groupEdgeMap = new 
HashMap<CyNode, List<CyEdge>>();
                        if (currentGroupNode != null) 
groupStack.push(currentGroupNode);
                        currentGroupNode = currentNode;
                        groupMap.put(currentGroupNode, new ArrayList<CyNode>());
+                       groupEdgeMap.put(currentGroupNode, new 
ArrayList<CyEdge>());
                        // logger.debug("Found group: "+currentNode);
                        return current;
                }

Modified: 
cytoscape/trunk/application/src/main/java/cytoscape/data/readers/XGMMLReader.java
===================================================================
--- 
cytoscape/trunk/application/src/main/java/cytoscape/data/readers/XGMMLReader.java
   2011-06-25 04:38:44 UTC (rev 25940)
+++ 
cytoscape/trunk/application/src/main/java/cytoscape/data/readers/XGMMLReader.java
   2011-06-25 06:09:03 UTC (rev 25941)
@@ -714,6 +714,7 @@
                // we don't create views by default, but groups should still
                // exist even when we don't create the view
                Map<CyNode,List<CyNode>>groupMap = parser.getGroupMap();
+               Map<CyNode,List<CyEdge>>groupEdgeMap = parser.getGroupEdgeMap();
                if (groupMap != null) {
                        CyAttributes nodeAttributes = 
Cytoscape.getNodeAttributes();
 
@@ -722,6 +723,8 @@
 
                        for (CyNode groupNode : groupMap.keySet()) {
                                List<CyNode> childList = 
groupMap.get(groupNode);
+                               List<CyEdge> edgeList = 
groupEdgeMap.get(groupNode);
+
                                viewer = 
nodeAttributes.getStringAttribute(groupNode.getIdentifier(), 
CyGroup.GROUP_VIEWER_ATTR);
                                CyGroupViewer groupViewer = 
CyGroupManager.getGroupViewer(viewer);
                                boolean isLocal = false;
@@ -758,6 +761,14 @@
                                        if (groupViewer == null)
                                                network.hideNode(groupNode);
                                }
+
+                               // OK, make sure we have all of our inner and 
outer edges added
+                               for (CyEdge edge: edgeList) {
+                                       if 
(childList.contains(edge.getSource()) && childList.contains(edge.getTarget()))
+                                               newGroup.addInnerEdge(edge);
+                                       else
+                                               newGroup.addOuterEdge(edge);
+                               }
                        }
 
                        // If we have a view, notify the group viewer

Modified: 
cytoscape/trunk/application/src/main/java/cytoscape/data/writers/XGMMLWriter.java
===================================================================
--- 
cytoscape/trunk/application/src/main/java/cytoscape/data/writers/XGMMLWriter.java
   2011-06-25 04:38:44 UTC (rev 25940)
+++ 
cytoscape/trunk/application/src/main/java/cytoscape/data/writers/XGMMLWriter.java
   2011-06-25 06:09:03 UTC (rev 25941)
@@ -665,10 +665,10 @@
                        }
                        for (CyEdge edge: group.getOuterEdges()) {
                                logger.debug("Writing outer edge 
"+edge.getIdentifier()+" for group "+group);
-                               if (!edgeMap.containsKey(edge)) {
+                               // if (!edgeMap.containsKey(edge)) {
                                        edgeMap.put(edge,edge);
                                        writeEdge(edge, false);
-                               }
+                               // }
                        }
 
                        depth--; writeElement("</graph>\n");

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to