Author: chinmoy
Date: 2009-06-08 19:55:33 -0700 (Mon, 08 Jun 2009)
New Revision: 16874

Added:
   csplugins/trunk/soc/chinmoy/phylotree/.classpath
   csplugins/trunk/soc/chinmoy/phylotree/.project
   csplugins/trunk/soc/chinmoy/phylotree/parser/
   
csplugins/trunk/soc/chinmoy/phylotree/parser/ParserPlugin$MyPluginAction.class
   csplugins/trunk/soc/chinmoy/phylotree/parser/ParserPlugin.class
   csplugins/trunk/soc/chinmoy/phylotree/parser/ParserPlugin.java
Log:


Added: csplugins/trunk/soc/chinmoy/phylotree/.classpath
===================================================================
--- csplugins/trunk/soc/chinmoy/phylotree/.classpath                            
(rev 0)
+++ csplugins/trunk/soc/chinmoy/phylotree/.classpath    2009-06-09 02:55:33 UTC 
(rev 16874)
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" path=""/>
+       <classpathentry kind="con" 
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/cytoscape.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/activation.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/biojava-1.4.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/colt.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/coltginy.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/commons-cli-1.x-cytoscape-custom.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/com-nerius-math-xform.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/concurrent.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/cytoscape-cruft-obo.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/cytoscape-geom-rtree.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/cytoscape-geom-spacial.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/cytoscape-graph-dynamic.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/cytoscape-graph-fixed.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/cytoscape-render-export.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/cytoscape-render-immed.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/cytoscape-render-stateful.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/cytoscape-task.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/cytoscape-util-intr.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/ding.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/FastInfoset.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/fing.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/freehep-export-2.1.1.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/freehep-graphics2d-2.1.1.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/freehep-graphicsio-2.1.1.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/freehep-graphicsio-java-2.1.1.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/freehep-graphicsio-ps-2.1.1.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/freehep-graphicsio-svg-2.1.1.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/freehep-io-2.0.2.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/freehep-jas-plotter-2.2.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/freehep-swing-2.0.3.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/freehep-util-2.0.2.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/freehep-xml-2.1.1.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/giny.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/glf.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/http.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/i4jruntime.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/itext-2.0.4.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/jaxb-api.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/jaxb-impl.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/jaxws-api.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/jaxws-rt.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/jaxws-tools.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/jdom-1.0.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/jhall.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/jnlp.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/jsr173_1.0_api.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/jsr181-api.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/jsr250-api.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/junit.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/l2fprod-common-all.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/looks-2.1.4.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/phoebe.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/piccolo.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/resolver.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/saaj-api.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/saaj-impl.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/sjsxp.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/stax-ex.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/streambuffer.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/swing-layout-1.0.1.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/swingx-2006_10_27.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/tclib.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/undo.support.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/violinstrings-1.0.2.jar"/>
+       <classpathentry kind="lib" path="C:/Program 
Files/Cytoscape_v2.6.2/lib/wizard.jar"/>
+       <classpathentry kind="output" path=""/>
+</classpath>

Added: csplugins/trunk/soc/chinmoy/phylotree/.project
===================================================================
--- csplugins/trunk/soc/chinmoy/phylotree/.project                              
(rev 0)
+++ csplugins/trunk/soc/chinmoy/phylotree/.project      2009-06-09 02:55:33 UTC 
(rev 16874)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>ParserPlugin</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>

Added: 
csplugins/trunk/soc/chinmoy/phylotree/parser/ParserPlugin$MyPluginAction.class
===================================================================
(Binary files differ)


Property changes on: 
csplugins/trunk/soc/chinmoy/phylotree/parser/ParserPlugin$MyPluginAction.class
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: csplugins/trunk/soc/chinmoy/phylotree/parser/ParserPlugin.class
===================================================================
(Binary files differ)


Property changes on: 
csplugins/trunk/soc/chinmoy/phylotree/parser/ParserPlugin.class
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: csplugins/trunk/soc/chinmoy/phylotree/parser/ParserPlugin.java
===================================================================
--- csplugins/trunk/soc/chinmoy/phylotree/parser/ParserPlugin.java              
                (rev 0)
+++ csplugins/trunk/soc/chinmoy/phylotree/parser/ParserPlugin.java      
2009-06-09 02:55:33 UTC (rev 16874)
@@ -0,0 +1,178 @@
+package parser;
+
+
+import java.awt.event.ActionEvent;
+import java.util.*;
+import cytoscape.CyEdge;
+import cytoscape.CyNetwork;
+import cytoscape.CyNode;
+import cytoscape.Cytoscape;
+import cytoscape.plugin.CytoscapePlugin;
+import cytoscape.util.CytoscapeAction;
+/**
+ * Plugin to parse a phylogenetic tree into a network
+ * 
+ */
+
+public class ParserPlugin extends CytoscapePlugin {
+
+       /**
+        * Parser a string representation of a PHYLIP phylogenetic tree
+        * into a Cytoscape network.
+        * Edit the String treeString to try different phylogenetic trees
+        * 
+        */
+       public ParserPlugin() {
+               // Create an Action, add the action to Cytoscape menu
+               MyPluginAction action = new MyPluginAction(this);
+               
Cytoscape.getDesktop().getCyMenus().addCytoscapeAction((CytoscapeAction) 
action);
+       }
+       
+       public class MyPluginAction extends CytoscapeAction {
+
+               public MyPluginAction(ParserPlugin myPlugin) {
+                       // Add the menu item under menu pulldown "Plugins"
+                       super("ParserPlugin");
+                       setPreferredMenu("Plugins");
+               }
+
+               public void actionPerformed(ActionEvent e) {
+                       
+                       // Pick a string represenation of a phylogenetic tree
+                       // These have all been obtained from the PHYLIP site
+                       
+                       // String treeString= "";
+                       
+                        String treeString =  
"(Bovine:0.69395,(Gibbon:0.36079,(Orang:0.33636,(Gorilla:0.17147,(Chimp:0.19268,
 Human:0.11927):0.08386):0.06124):0.15057):0.54939,Mouse:1.21460)";
+                       
+                       // String treeString = 
"(Bovine:0.69395,(Hylobates:0.36079,(Pongo:0.33636,(G._Gorilla:0.17147, 
(P._paniscus:0.19268,H._sapiens:0.11927):0.08386):0.06124):0.15057):0.54939, 
Rodent:1.21460)";
+                       // String treeString = 
"((raccoon:19.19959,bear:6.80041):0.84600,((sea_lion:11.99700,seal:12.00300):7.52973,((monkey:100.85930,cat:47.14069):20.59201,weasel:18.87953):2.09460):3.87382,dog:25.46154)";
+                       
+                       
+                       //String treeString = "(B,(A,C,E),D)";
+                       
+                               Stack <String> stack = new Stack<String>();     
+                           LinkedList<String> list = new LinkedList<String>();
+                           LinkedList<String> edgeList = new 
LinkedList<String>();
+                           
+                           Iterator<String> iterator;
+                           Iterator<String> edgeListIterator;
+                       
+                           CyNetwork cyNetwork = 
Cytoscape.createNetwork("network", false);
+                       
+                               
+                           // Split the input string into a list
+                           String [] substrings = treeString.split(":|,");
+                           for(int i =0; i<substrings.length;i++)
+                           {
+                             substrings[i] = substrings[i].trim();
+                           }
+                           
+                           // Parse the input into a list
+                           for(int i = 0; i<substrings.length; i++)
+                           {
+                             substrings[i].trim();
+                             if (substrings[i].charAt(0) == '(')
+                             {
+                               list.add("(");
+                               String[] tempSub = substrings[i].split("\\(");
+                               list.add(tempSub[1]);
+                             }
+                             else if(substrings[i].charAt(0) != '(' && 
substrings[i].charAt(0) != ')')
+                             {
+                               String[] tempSub2 = substrings[i].split("\\)");
+                               list.add(tempSub2[0]);
+                             }
+                             
if(substrings[i].charAt(substrings[i].length()-1)== ')')
+                             {
+                               list.add(")");
+                             }
+                             
+                           }
+                           
+                           
+                           // Parse the list into a CyNetwork using a stack
+                           
+                           iterator = list.iterator();
+                           int tempNodeIndex = 0;
+                           while(iterator.hasNext())
+                           {
+                             Object tempObj = iterator.next();
+                             String tempStr = (String) tempObj;
+                             
+                             if(!tempStr.equals(")"))
+                             {
+                               stack.push(tempStr);
+                               // Ignore (
+                             }
+                             if(tempStr.equals(")"))
+                             {
+                               String stackTop = stack.pop();
+                               while(!stackTop.equals("("))
+                               {
+
+                                   try
+                                   {
+                                     Double branchLength = 
Double.parseDouble(stackTop);
+                                     // @DEVELOP_ME
+                                     // Find a way to store the branch length 
with the node
+                                     // so that the layout is actually 
representative of the 
+                                     // edge distances
+                                   }
+                                   catch(NumberFormatException f)
+                                   {
+                                     // Add a node
+       
+                                       CyNode nodeA = 
Cytoscape.getCyNode(stackTop, true);
+                                               cyNetwork.addNode(nodeA);
+                                               
+                                               
+                                       // Store each node label into a list
+                                               
+                                                       edgeList.add(stackTop);
+                                   }
+                                           
+                                 stackTop = stack.pop();
+                               }
+                                if(stackTop.equals("("))
+                                 {
+                                   // Add a temporary parent node
+                                        String tempNodeLabel = 
"tempNode"+tempNodeIndex;
+                                        CyNode tempNode = 
Cytoscape.getCyNode(tempNodeLabel, true);
+                                        cyNetwork.addNode(tempNode);
+                                        tempNodeIndex++;
+                               
+                                        // Add edges between the temporary 
parent and the children
+                                        edgeListIterator = edgeList.iterator();
+                                        int tempEdgeIndex = 0;
+                                               
while(edgeListIterator.hasNext())
+                                               {
+                                                       Object tempEdgeListObj 
= edgeListIterator.next();
+                                                       String tempEdgeListStr 
= (String) tempEdgeListObj;
+                                                       String tempEdgeLabel = 
"edge"+tempEdgeIndex;
+                                                       CyEdge edgeA = 
Cytoscape.getCyEdge(tempNodeLabel, tempEdgeLabel, tempEdgeListStr, "pp");
+                                                       tempEdgeIndex++;
+                                                       
cyNetwork.addEdge(edgeA);
+                                               
+                                               
+                                               }
+                                        edgeList.clear();
+                                        
+                                        // Add only the tempNode back to the 
edgeList so that its parent can make an edge to it.
+                                        edgeList.add(tempNodeLabel);
+                                }
+                             }
+                            
+                           }
+                        
+                 
+                       // remove a node
+                       //cyNetwork.removeNode(node1.getRootGraphIndex(), true);
+                       
//Cytoscape.firePropertyChange(Cytoscape.NETWORK_MODIFIED, null, cyNetwork);
+                       
+                       // destroy the network
+                       //Cytoscape.destroyNetwork(cyNetwork);
+                       
//Cytoscape.firePropertyChange(Cytoscape.NETWORK_DESTROYED, cyNetwork, null);
+               }
+       }
+}


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