Author: kono
Date: 2010-02-11 02:45:18 -0800 (Thu, 11 Feb 2010)
New Revision: 19292

Added:
   
csplugins/trunk/ucsd/kono/KGMLReader/src/org/cytoscape/data/reader/kgml/KEGGShape.java
Modified:
   
csplugins/trunk/ucsd/kono/KGMLReader/src/org/cytoscape/data/reader/kgml/KGMLReader.java
   
csplugins/trunk/ucsd/kono/KGMLReader/src/org/cytoscape/data/reader/kgml/PathwayMapper.java
Log:
Edge generator added.  Relations only.

Added: 
csplugins/trunk/ucsd/kono/KGMLReader/src/org/cytoscape/data/reader/kgml/KEGGShape.java
===================================================================
--- 
csplugins/trunk/ucsd/kono/KGMLReader/src/org/cytoscape/data/reader/kgml/KEGGShape.java
                              (rev 0)
+++ 
csplugins/trunk/ucsd/kono/KGMLReader/src/org/cytoscape/data/reader/kgml/KEGGShape.java
      2010-02-11 10:45:18 UTC (rev 19292)
@@ -0,0 +1,34 @@
+package org.cytoscape.data.reader.kgml;
+
+import cytoscape.visual.NodeShape;
+
+public enum KEGGShape {
+       CIRCLE("circle", NodeShape.ELLIPSE), RECTANGLE("rectangle",
+                       NodeShape.RECT), ROUND_RECTANGLE("roundrectangle",
+                       NodeShape.ROUND_RECT), LINE("line", null);
+
+       private String tag;
+       private NodeShape shape;
+
+       private KEGGShape(final String tag, final NodeShape shape) {
+               this.shape = shape;
+               this.tag = tag;
+       }
+
+       public static int getShape(final String shape) {
+               for (KEGGShape keggShape : KEGGShape.values()) {
+                       if (keggShape.tag.equals(shape)) {
+                               if (keggShape.shape == null)
+                                       return -1;
+                               else
+                                       return keggShape.shape.getGinyShape();
+                       }
+               }
+
+               return NodeShape.RECT.getGinyShape();
+       }
+       
+       public String getTag() {
+               return this.tag;
+       }
+}
\ No newline at end of file

Modified: 
csplugins/trunk/ucsd/kono/KGMLReader/src/org/cytoscape/data/reader/kgml/KGMLReader.java
===================================================================
--- 
csplugins/trunk/ucsd/kono/KGMLReader/src/org/cytoscape/data/reader/kgml/KGMLReader.java
     2010-02-11 09:28:41 UTC (rev 19291)
+++ 
csplugins/trunk/ucsd/kono/KGMLReader/src/org/cytoscape/data/reader/kgml/KGMLReader.java
     2010-02-11 10:45:18 UTC (rev 19292)
@@ -89,6 +89,7 @@
                mapper = new PathwayMapper(pathway);
                mapper.doMapping();
                nodeIdx = mapper.getNodeIdx();
+               edgeIdx = mapper.getEdgeIdx();
 
        }
 

Modified: 
csplugins/trunk/ucsd/kono/KGMLReader/src/org/cytoscape/data/reader/kgml/PathwayMapper.java
===================================================================
--- 
csplugins/trunk/ucsd/kono/KGMLReader/src/org/cytoscape/data/reader/kgml/PathwayMapper.java
  2010-02-11 09:28:41 UTC (rev 19291)
+++ 
csplugins/trunk/ucsd/kono/KGMLReader/src/org/cytoscape/data/reader/kgml/PathwayMapper.java
  2010-02-11 10:45:18 UTC (rev 19292)
@@ -12,6 +12,8 @@
 import org.cytoscape.data.reader.kgml.generated.Entry;
 import org.cytoscape.data.reader.kgml.generated.Graphics;
 import org.cytoscape.data.reader.kgml.generated.Pathway;
+import org.cytoscape.data.reader.kgml.generated.Relation;
+import org.cytoscape.data.reader.kgml.generated.Subtype;
 
 import cytoscape.CyEdge;
 import cytoscape.CyNetwork;
@@ -32,34 +34,7 @@
 import cytoscape.visual.mappings.PassThroughMapping;
 
 public class PathwayMapper {
-
-       private enum KEGGShape {
-               CIRCLE("circle", NodeShape.ELLIPSE), RECTANGLE("rectangle",
-                               NodeShape.RECT), 
ROUND_RECTANGLE("roundrectangle",
-                               NodeShape.ROUND_RECT), LINE("line", null);
-
-               private String tag;
-               private NodeShape shape;
-
-               private KEGGShape(final String tag, final NodeShape shape) {
-                       this.shape = shape;
-                       this.tag = tag;
-               }
-
-               public static int getShape(final String shape) {
-                       for (KEGGShape keggShape : KEGGShape.values()) {
-                               if (keggShape.tag.equals(shape)) {
-                                       if (keggShape.shape == null)
-                                               return -1;
-                                       else
-                                               return 
keggShape.shape.getGinyShape();
-                               }
-                       }
-
-                       return NodeShape.RECT.getGinyShape();
-               }
-       }
-
+       
        private final Pathway pathway;
        private final String pathwayName;
 
@@ -73,6 +48,7 @@
 
        public void doMapping() {
                mapNode();
+               mapEdge();
        }
 
        private final Map<String, Entry> entryMap = new HashMap<String, 
Entry>();
@@ -87,7 +63,7 @@
                final CyAttributes nodeAttr = Cytoscape.getNodeAttributes();
 
                for (final Entry comp : components) {
-                       if 
(!comp.getGraphics().getType().equals(KEGGShape.LINE.tag)) {
+                       if 
(!comp.getGraphics().getType().equals(KEGGShape.LINE.getTag())) {
                                CyNode node = Cytoscape.getCyNode(pathwayID + 
"-"
                                                + comp.getId(), true);
                                nodeAttr.setAttribute(node.getIdentifier(), 
"KEGG.name", comp
@@ -104,6 +80,37 @@
                        idx++;
                }
        }
+       
+       private void mapEdge() {
+               final List<Relation> relations = pathway.getRelation();
+               final List<CyEdge> edges = new ArrayList<CyEdge>();
+               
+               for(Relation rel: relations) {
+                       final String ent1 = rel.getEntry1();
+                       final String ent2 = rel.getEntry2();
+                       
+                       final List<Subtype> subs = rel.getSubtype();
+                       final String type = rel.getType();
+                       CyNode source = nodeMap.get(ent1);
+                       CyNode target = nodeMap.get(ent2);
+                       CyNode compound = nodeMap.get(subs.get(0).getValue());
+                       System.out.println(source.getIdentifier());
+                       System.out.println(target.getIdentifier());
+                       System.out.println(compound.getIdentifier() + "\n\n");
+                       CyEdge edge1 = Cytoscape.getCyEdge(source, compound, 
"interaction", type, true);
+                       CyEdge edge2 = Cytoscape.getCyEdge(compound, target, 
"interaction", type, true);
+                       edges.add(edge1);
+                       edges.add(edge2);
+               }
+               
+               edgeIdx = new int[edges.size()];
+               int idx = 0;
+               for (CyEdge edge : edges) {
+                       edgeIdx[idx] = edge.getRootGraphIndex();
+                       idx++;
+               }
+               
+       }
 
        protected void updateView(final CyNetwork network) {
 
@@ -204,4 +211,8 @@
                return nodeIdx;
        }
 
+       public int[] getEdgeIdx() {
+               return edgeIdx;
+       }
+
 }

-- 
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