Author: chinmoy
Date: 2009-08-06 23:21:26 -0700 (Thu, 06 Aug 2009)
New Revision: 17734

Modified:
   
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/PhylotreePlugin.java
   
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/actions/PhyloTreeImportAction.java
   
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/CircularCladogram.java
   
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/RadialCladogram.java
   
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/RectangularCladogram.java
   
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/SlantedCladogram.java
   
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/parser/PhylipTreeImpl.java
   
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/ui/PhyloFileDialog.java
   
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/visualstyle/DepthwiseSize.java
Log:
Added file validation for phylip files


Modified: 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/PhylotreePlugin.java
===================================================================
--- 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/PhylotreePlugin.java
      2009-08-07 06:18:07 UTC (rev 17733)
+++ 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/PhylotreePlugin.java
      2009-08-07 06:21:26 UTC (rev 17734)
@@ -43,22 +43,6 @@
                
                //(2) add another menu item: Layout->Phylotree layouts
                
-               
-//             RectangularCladogram a = new RectangularCladogram();
-//             CyLayouts.addLayout(a,"Phylotree Layouts");
-//             
-//             
Cytoscape.getDesktop().update(Cytoscape.getDesktop().getGraphics());
-//             
-//             JMenu j = Cytoscape.getDesktop().getCyMenus().getLayoutMenu();
-//             JMenuItem jt;
-//             
-//             for(int i = 0; i<j.getItemCount(); i++)
-//             {
-//                     jt= j.getItem(i);
-//                     if(jt!=null)
-//                     System.out.println("Name: "+i+" "+jt.getText());
-//             }
-               
                PhyloTreeLayoutAction layoutAction = new 
PhyloTreeLayoutAction(new RectangularCladogram());
                
Cytoscape.getDesktop().getCyMenus().addCytoscapeAction((CytoscapeAction) 
layoutAction);
                

Modified: 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/actions/PhyloTreeImportAction.java
===================================================================
--- 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/actions/PhyloTreeImportAction.java
        2009-08-07 06:18:07 UTC (rev 17733)
+++ 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/actions/PhyloTreeImportAction.java
        2009-08-07 06:21:26 UTC (rev 17734)
@@ -24,19 +24,23 @@
 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
 
 import org.cytoscape.phylotree.visualstyle.DepthwiseColor;
-import org.cytoscape.phylotree.visualstyle.PhyloVisualStyle;
+import org.cytoscape.phylotree.visualstyle.DepthwiseSize;
 import org.cytoscape.phylotree.visualstyle.PhyloVisualStyleManager;
 
+import java.io.BufferedReader;
 import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
 import java.io.IOException;
 import java.util.List;
 import java.util.Iterator;
 
 
+import cytoscape.layout.CyLayoutAlgorithm;
 import cytoscape.layout.CyLayouts;
 
 public class PhyloTreeImportAction extends CytoscapeAction{
-       
+
        public PhyloTreeImportAction(PhylotreePlugin p) {
                // Add the menu item under menu pulldown "File->Import"
                super("Phylogenetic tree...");
@@ -53,43 +57,46 @@
                        System.out.println("pFile = null");
                        return;
                }
-                               
+
                if (pFormat.equalsIgnoreCase("phylip")){
-                       loadnetwork_phylip(pFile);
+                       if(validatePhylipFile(pFile))
+                               loadnetwork_phylip(pFile);
                }
                else if (pFormat.equalsIgnoreCase("phyloxml")){
                        loadnetwork_phyloXML(pFile);
                }
-               
+
                // Add the phylogenetic tree specific visual styles
                PhyloVisualStyleManager phyloVSMan = new 
PhyloVisualStyleManager();
+               phyloVSMan.addVisualStyle(new DepthwiseSize());
                phyloVSMan.addVisualStyle(new DepthwiseColor());
-               
+
+
        }
-       
-       
+
+
        private void loadnetwork_phylip(File pFile) {
                // Use the parser to read the file
-               
+
                // Parse the file
                PhylipTreeImpl phylipParser = new PhylipTreeImpl(pFile);
-               
+
                CyNetwork cyNetwork = Cytoscape.createNetwork(pFile.getName(), 
true);
-               
+
                CyAttributes cyAttributes = Cytoscape.getEdgeAttributes();
-               
-               
+
+
                // Get all nodes in the PHYLIP tree
                List<PhylotreeNode> nodeList = phylipParser.getNodeList();
-               
+
                // For each node, get all edges
                for(Iterator<PhylotreeNode> nodeListIterator = 
nodeList.iterator(); nodeListIterator.hasNext();)
                {
                        PhylotreeNode pNode = nodeListIterator.next();
-                       
+
                        // Get edges
                        List<PhylotreeEdge> edgeList = 
phylipParser.getEdges(pNode);
-                       
+
                        // For each edge, create the two nodes connected if 
they do not exist
                        for(Iterator<PhylotreeEdge> edgeListIterator = 
edgeList.iterator(); edgeListIterator.hasNext();)
                        {
@@ -97,9 +104,9 @@
 
                                CyNode node1 = 
Cytoscape.getCyNode(pEdge.getSourceNode().getName(), true);
                                CyNode node2 = 
Cytoscape.getCyNode(pEdge.getTargetNode().getName(), true);
-                               
+
                                CyEdge cyEdge = Cytoscape.getCyEdge(node1, 
node2, Semantics.INTERACTION, "pp", true, true);
-                       
+
                                // Get edge attributes and set them
                                List<Object> edgeAttributes = 
phylipParser.getEdgeAttribute(pEdge);
                                
cyAttributes.setAttribute(cyEdge.getIdentifier(), "branchLength", 
(Double)edgeAttributes.get(0));
@@ -108,34 +115,38 @@
                                cyNetwork.addNode(node2);
                        }
                }
-               
+
                cyAttributes.setUserEditable("branchLength", false);
                cyAttributes.setUserVisible("branchLength", true);
 
                // Apply default layout
                CyLayouts.getLayout("slanted_cladogram").doLayout();
-               
+
+
                // Apply visual style
                Cytoscape.firePropertyChange(Cytoscape.VIZMAP_LOADED, null, 
"phyloVizMap.props");
 
        }
-       
+
        private void loadnetwork_phyloXML(File pFile) {
-//             PhyloXmlParser parser = new PhyloXmlParser();
+               
+               // PhyloXmlParser parser = new PhyloXmlParser();
                PhylogenyParser parser = new PhyloXmlParser();
 
-               //parser.setSource(pFile);
 
+
                PhylogenyFactory factory = 
ParserBasedPhylogenyFactory.getInstance();
                Phylogeny[] trees; 
                try {
                        trees = factory.create(pFile, parser);
-                       //trees = parser.parse();
                        
-       
+
+
                }
                catch (PhylogenyParserException ppe){
                        System.out.println("PhloXML Parser error occured.");
+                       System.out.println("Verify that file is a valid 
PhyloXML file.");
+                       
                        return;
                }
                catch(IOException ioe){
@@ -145,82 +156,127 @@
 
                for (int i=0; i< trees.length; i++){
                        PhylogenyNodeIterator it = 
trees[i].iteratorLevelOrder();
-                       
-       
-                       
+
+
+
                        // Create a network
                        CyNetwork cyNetwork = 
Cytoscape.createNetwork(trees[i].getName(), true);
-                       
-                       
-                       
+
+
+
                        // Add network attributes
                        addPhyloXMLNetworkAttributes(trees[i], 
cyNetwork.getIdentifier());
-                       
+
                        int unnamedNodeIndex = 0;
                        // process each node, get node, edge and attributes     
                
                        while (it.hasNext())
                        {
                                PhylogenyNode node = (PhylogenyNode) it.next();
                                PhylogenyNode parent = node.getParent(); // for 
edge
-                               
-                               
+
+
                                // Add the node to the network
                                if(node.getNodeName().equals(""))
-                                       {
+                               {
                                        node.setName("Node"+unnamedNodeIndex);
                                        unnamedNodeIndex++;
-                                       }
+                               }
                                CyNode cyNode = 
Cytoscape.getCyNode(node.getNodeName(), true);
                                // Add the node's attributes
-                               
+
                                cyNetwork.addNode(cyNode);
-                               
+
                                addPhyloXMLNodeAttributes(node, 
cyNode.getIdentifier());
-                               
+
                                // If parent exists, add it as well as all 
edges connecting the two
                                if(parent!=null)
                                {
                                        CyNode cyParent = 
Cytoscape.getCyNode(parent.getNodeName(), true);
-                                       
+
                                        
if(cyParent.getRootGraphIndex()!=cyNode.getRootGraphIndex())
                                        {
-                                       // Add the parent's attributes
-                                       CyEdge cyEdge = 
Cytoscape.getCyEdge(cyParent, cyNode, Semantics.INTERACTION, "pp", true, true);
-                                       // Add the edge's attributes
+                                               // Add the parent's attributes
+                                               CyEdge cyEdge = 
Cytoscape.getCyEdge(cyParent, cyNode, Semantics.INTERACTION, "pp", true, true);
+                                               // Add the edge's attributes
 
-                                       cyNetwork.addEdge(cyEdge);
-                                       addPhyloXMLEdgeAttributes(node, 
cyEdge.getIdentifier());
-                                       
+                                               cyNetwork.addEdge(cyEdge);
+                                               addPhyloXMLEdgeAttributes(node, 
cyEdge.getIdentifier());
+
                                        }
                                }
                        }
-                       
-                       
 
+
+
                        // Apply default layout
                        CyLayouts.getLayout("slanted_cladogram").doLayout();
-                       
+
                        // Apply visual style
                        Cytoscape.firePropertyChange(Cytoscape.VIZMAP_LOADED, 
null, "phyloVizMap.props");
                }
 
-               
+
        }
-       
+
+       private boolean validatePhylipFile(File file)
+       {
+               // Read the file to obtain the tree
+               if(file!=null)
+               {
+                       PhylipTreeImpl phylipParser = new PhylipTreeImpl(file);
+                       
+                       
+                       String fileStr = phylipParser.getTreeTextFromFile(file);
+                       
+                       
+                       // Check to make sure file is a complete tree
+                       int numOpenParens = 0;
+                       int numCloseParens = 0;
+
+                       for(int i = 0; i<fileStr.length(); i++)
+                       {
+                               if(fileStr.charAt(i)=='(')
+                                       numOpenParens++;
+                               else if(fileStr.charAt(i)==')')
+                                       numCloseParens++;
+                       }
+
+                       if(numOpenParens!=numCloseParens)
+                       {
+                               System.out.println("File is not a valid 
Phylip/Newick format file.");
+                               System.out.println("Number of '(' not equal to 
')'.");
+                               return false;
+                       }
+
+                       
+                       // Check to make sure file is not an empty tree
+                       if(numOpenParens==0)
+                       {
+                               System.out.println("File is not a valid 
Phylip/Newick format file.");
+                               System.out.println("Tree in the file does not 
consist of any nodes.");
+                               return false;
+                       }
+
+                       return true;
+               }
+               else
+                       return false;
+       }
+
        private void addPhyloXMLNetworkAttributes(Phylogeny phy, String 
networkID )
        {
                CyAttributes networkAttributes = 
Cytoscape.getNetworkAttributes();
-               
+
                // Check and assign network attributes
                if(!phy.getName().equals(""))
                        
networkAttributes.setAttribute(networkID,"Name",phy.getName());
-                               
+
                if(phy.getIdentifier()!=null)
                        networkAttributes.setAttribute(networkID, "ID", 
phy.getIdentifier().getValue());
 
                if(!phy.getDescription().equals(""))
                        
networkAttributes.setAttribute(networkID,"Description",phy.getDescription());
-                       
+
                if(phy.getConfidence()!=null)
                        
networkAttributes.setAttribute(networkID,"Confidence",phy.getConfidence().getValue());
                if(phy.isRooted())
@@ -231,26 +287,26 @@
                        networkAttributes.setAttribute(networkID, "Rerootable", 
true);
                else
                        networkAttributes.setAttribute(networkID, "Rerootable", 
false);
-               
+
                if(!phy.getType().equals(""))
                        
networkAttributes.setAttribute(networkID,"Type",phy.getType());
-                               
+
                if(!phy.getDistanceUnit().equals(""))
                        networkAttributes.setAttribute(networkID,"Distance 
Unit",phy.getDistanceUnit());
-               
+
                Cytoscape.firePropertyChange(Cytoscape.ATTRIBUTES_CHANGED, 
null, null);         
-               
+
        }
 
        private void addPhyloXMLNodeAttributes(PhylogenyNode node, String 
nodeID )
        {
                NodeData nodeData = node.getNodeData();
-       
+
                CyAttributes nodeAttributes = Cytoscape.getNodeAttributes();
-               
 
+
                // Check and assign node attributes
-               
+
                if(nodeData.isHasTaxonomy())
                {
                        if(!nodeData.getTaxonomy().getCommonName().equals(""))
@@ -275,14 +331,14 @@
                                        nodeAttributes.setAttribute(nodeID, 
"Taxonomy: URI Description", nodeData.getTaxonomy().getUri().getDescription());
                        }
                }
-               
+
                if(nodeData.isHasBinaryCharacters())
                {
-                               nodeAttributes.setAttribute(nodeID, "Binary 
Characters", nodeData.getBinaryCharacters().toString());
+                       nodeAttributes.setAttribute(nodeID, "Binary 
Characters", nodeData.getBinaryCharacters().toString());
                }
-               
-               
-               
+
+
+
                if(nodeData.isHasDate())
                {
                        if(nodeData.getDate().getRange()!=null)
@@ -293,10 +349,10 @@
                                nodeAttributes.setAttribute(nodeID, "Date: 
Description", nodeData.getDate().getDesc());
                        if(nodeData.getDate().getValue()!=null)
                                nodeAttributes.setAttribute(nodeID, "Date: 
Value", nodeData.getDate().getValue().toString());
-                                       
-                       
+
+
                }
-               
+
                if(nodeData.isHasDistribution())
                {
                        if(nodeData.getDistribution().getAltitude()!=null)
@@ -309,30 +365,30 @@
                                nodeAttributes.setAttribute(nodeID, 
"Distribution: Latitude", nodeData.getDistribution().getLatitude().toString());
                        if(nodeData.getDistribution().getLongitude()!=null)
                                nodeAttributes.setAttribute(nodeID, 
"Distribution: Longitude", 
nodeData.getDistribution().getLongitude().toString());
-                       
+
                }
-               
+
                if(nodeData.isHasEvent())
                {
                        if(nodeData.getEvent().getEventType()!=null)
                                nodeAttributes.setAttribute(nodeID, "Event: 
Type", nodeData.getEvent().getEventType().name());
                        if(nodeData.getEvent().getConfidence()!=null)
                                nodeAttributes.setAttribute(nodeID, "Event: 
Confidence", nodeData.getEvent().getConfidence().getType());
-                               
+
                        nodeAttributes.setAttribute(nodeID, "Event: # 
Duplications", nodeData.getEvent().getNumberOfDuplications());
                        nodeAttributes.setAttribute(nodeID, "Event: # Gene 
Losses", nodeData.getEvent().getNumberOfGeneLosses());
                        nodeAttributes.setAttribute(nodeID, "Event: # 
Speciations", nodeData.getEvent().getNumberOfSpeciations());
-                                               
+
                }
-               
+
                if(nodeData.isHasNodeIdentifier())
                {
-                       
+
                        if(!nodeData.getNodeIdentifier().getValue().equals(""))
                                
nodeAttributes.setAttribute(nodeID,"Identifier",nodeData.getNodeIdentifier().getValue());
-                       
+
                }
-               
+
                if(nodeData.isHasProperties())
                {
                        Property[] props = 
nodeData.getProperties().getPropertiesArray();
@@ -350,11 +406,11 @@
                                        
nodeAttributes.setAttribute(nodeID,"Property"+i+": Unit", props[i].getUnit());
                                if(!props[i].getValue().equals(""))
                                        
nodeAttributes.setAttribute(nodeID,"Property"+i+": Value", props[i].getValue());
-                               
+
                        }
-                       
+
                }
-               
+
                if(nodeData.isHasReference())
                {
                        if(!nodeData.getReference().getDoi().equals(""))
@@ -362,7 +418,7 @@
                        if(!nodeData.getReference().getValue().equals(""))
                                nodeAttributes.setAttribute(nodeID,"Reference: 
Value", nodeData.getReference().getValue());
                }
-               
+
                if(nodeData.isHasSequence())
                {
 
@@ -374,13 +430,13 @@
 
                        if(nodeData.getSequence().getName().equals(""))
                                nodeAttributes.setAttribute(nodeID, "Sequence: 
Name", nodeData.getSequence().getName());
-                       
+
                        if(nodeData.getSequence().getSymbol().equals(""))
                                nodeAttributes.setAttribute(nodeID, "Sequence: 
Symbol", nodeData.getSequence().getSymbol());
-                       
+
                        if(nodeData.getSequence().getType().equals(""))
                                nodeAttributes.setAttribute(nodeID, "Sequence: 
Type", nodeData.getSequence().getType());
-                       
+
                        if(nodeData.getSequence().getUri()!=null)
                        {
                                
if(!nodeData.getSequence().getUri().getValue().toString().equals(""))
@@ -390,16 +446,16 @@
                                
if(!nodeData.getSequence().getUri().getDescription().equals(""))
                                        nodeAttributes.setAttribute(nodeID, 
"Sequence: URI Description", nodeData.getSequence().getUri().getDescription());
                        }
-                       
+
                        if(nodeData.getSequence().getAccession()!=null)
                        {
                                
if(!nodeData.getSequence().getAccession().getSource().equals(""))
                                        nodeAttributes.setAttribute(nodeID, 
"Sequence: Accession Source", 
nodeData.getSequence().getAccession().getSource());
                                
if(!nodeData.getSequence().getAccession().getValue().equals(""))
                                        nodeAttributes.setAttribute(nodeID, 
"Sequence: Accession", nodeData.getSequence().getAccession().getValue());
-                               
+
                        }
-                       
+
                        if(nodeData.getSequence().getDomainArchitecture()!=null)
                        {
                                nodeAttributes.setAttribute(nodeID, "Sequence: 
Domain Total Length", 
nodeData.getSequence().getDomainArchitecture().getTotalLength());
@@ -407,22 +463,22 @@
                                {
                                        
if(!nodeData.getSequence().getDomainArchitecture().getDomain(i).getId().equals(""))
                                                
nodeAttributes.setAttribute(nodeID, "Sequence: Domain"+i+" ID", 
nodeData.getSequence().getDomainArchitecture().getDomain(i).getId());
-                                       
+
                                        
if(!nodeData.getSequence().getDomainArchitecture().getDomain(i).getName().equals(""))
                                                
nodeAttributes.setAttribute(nodeID, "Sequence: Domain"+i+" Name", 
nodeData.getSequence().getDomainArchitecture().getDomain(i).getName());
-                                       
-                                               
nodeAttributes.setAttribute(nodeID, "Sequence: Domain"+i+" Confidence", 
nodeData.getSequence().getDomainArchitecture().getDomain(i).getConfidence());
-                                               
nodeAttributes.setAttribute(nodeID, "Sequence: Domain"+i+" From", 
nodeData.getSequence().getDomainArchitecture().getDomain(i).getFrom());
-                                               
nodeAttributes.setAttribute(nodeID, "Sequence: Domain"+i+" To", 
nodeData.getSequence().getDomainArchitecture().getDomain(i).getTo());
-                                               
nodeAttributes.setAttribute(nodeID, "Sequence: Domain"+i+" Length", 
nodeData.getSequence().getDomainArchitecture().getDomain(i).getLength());
-                                               
+
+                                       nodeAttributes.setAttribute(nodeID, 
"Sequence: Domain"+i+" Confidence", 
nodeData.getSequence().getDomainArchitecture().getDomain(i).getConfidence());
+                                       nodeAttributes.setAttribute(nodeID, 
"Sequence: Domain"+i+" From", 
nodeData.getSequence().getDomainArchitecture().getDomain(i).getFrom());
+                                       nodeAttributes.setAttribute(nodeID, 
"Sequence: Domain"+i+" To", 
nodeData.getSequence().getDomainArchitecture().getDomain(i).getTo());
+                                       nodeAttributes.setAttribute(nodeID, 
"Sequence: Domain"+i+" Length", 
nodeData.getSequence().getDomainArchitecture().getDomain(i).getLength());
+
                                }
-                               
+
                        }
-                       
+
                        List<PhylogenyData> annotations = 
nodeData.getSequence().getAnnotations();
                        Iterator<PhylogenyData> iterator = 
annotations.iterator();
-                       
+
                        int index = 0;                  
                        while(iterator.hasNext())
                        {
@@ -431,16 +487,16 @@
                                        nodeAttributes.setAttribute(nodeID, 
"Sequence: Annotation"+index, data.toString());
                                index++;
                        }
-                                       
-                       
-                       
-                       
+
+
+
+
                }
-               
+
                Cytoscape.firePropertyChange(Cytoscape.ATTRIBUTES_CHANGED, 
null, null);         
        }       
-       
-       
+
+
        private void addPhyloXMLEdgeAttributes(PhylogenyNode node, String 
edgeID )
        {
                BranchData branchData = node.getBranchData();
@@ -453,7 +509,7 @@
 
                if(branchData.getBranchColor()!=null)
                        edgeAttributes.setAttribute(edgeID, "Color", 
branchData.getBranchColor().getValue().toString());
-               
+
                List<Confidence> confidences = branchData.getConfidences();
                Iterator<Confidence> iterator = confidences.iterator();
                int index = 0;
@@ -463,10 +519,10 @@
                        edgeAttributes.setAttribute(edgeID, "Confidence"+index, 
c.getValue());
                        edgeAttributes.setAttribute(edgeID, 
"Confidence"+index+" type", c.getType());
                        index++;
-                       
+
                }
-               
+
        }
-       
-       
+
+
 }

Modified: 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/CircularCladogram.java
===================================================================
--- 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/CircularCladogram.java
  2009-08-07 06:18:07 UTC (rev 17733)
+++ 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/CircularCladogram.java
  2009-08-07 06:21:26 UTC (rev 17734)
@@ -95,12 +95,17 @@
                return "Circular Cladogram Layout";
        }
 
-
+       public void construct(double radius)
+       {
+               BASE_RADIUS += radius;
+               construct();
+       }
+       
        public void construct() {
                taskMonitor.setStatus("Initializing");
                initialize(); 
+               
 
-
                // Find the root of the tree
                Node root = commonFunctions.getTreeRoot(network);
 

Modified: 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/RadialCladogram.java
===================================================================
--- 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/RadialCladogram.java
    2009-08-07 06:18:07 UTC (rev 17733)
+++ 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/RadialCladogram.java
    2009-08-07 06:21:26 UTC (rev 17734)
@@ -94,8 +94,13 @@
        public  String toString(){
                return "Radial Cladogram Layout";
        }
+       
+       public void construct(double radius)
+       {
+               BASE_RADIUS = radius;
+               construct();
+       }
 
-
        public void construct() {
                taskMonitor.setStatus("Initializing");
                initialize(); 

Modified: 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/RectangularCladogram.java
===================================================================
--- 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/RectangularCladogram.java
       2009-08-07 06:18:07 UTC (rev 17733)
+++ 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/RectangularCladogram.java
       2009-08-07 06:21:26 UTC (rev 17734)
@@ -94,7 +94,11 @@
        public  String toString(){
                return "Rectangular Cladogram Layout";
        }
-
+       public void construct(double distance)
+       {
+               INTERNODE_DISTANCE += distance;
+               construct();
+       }
        
        public void construct() {
                taskMonitor.setStatus("Initializing");

Modified: 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/SlantedCladogram.java
===================================================================
--- 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/SlantedCladogram.java
   2009-08-07 06:18:07 UTC (rev 17733)
+++ 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/SlantedCladogram.java
   2009-08-07 06:21:26 UTC (rev 17734)
@@ -95,8 +95,12 @@
        public  String toString(){
                return "Slanted Cladogram Layout";
        }
+       public void construct(double distance)
+       {
+               INTERNODE_DISTANCE += distance;
+               construct();
+       }
 
-
        public void construct() {
                taskMonitor.setStatus("Initializing");
                initialize(); 

Modified: 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/parser/PhylipTreeImpl.java
===================================================================
--- 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/parser/PhylipTreeImpl.java
        2009-08-07 06:18:07 UTC (rev 17733)
+++ 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/parser/PhylipTreeImpl.java
        2009-08-07 06:21:26 UTC (rev 17734)
@@ -43,7 +43,7 @@
  /* 
   * Reads a PHYLIP file and returns the tree in string format
   */
- private String getTreeTextFromFile(File pTreeFile){
+ public String getTreeTextFromFile(File pTreeFile){
   String retStr = null;
 
   try

Modified: 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/ui/PhyloFileDialog.java
===================================================================
--- 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/ui/PhyloFileDialog.java
   2009-08-07 06:18:07 UTC (rev 17733)
+++ 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/ui/PhyloFileDialog.java
   2009-08-07 06:21:26 UTC (rev 17734)
@@ -2,6 +2,8 @@
 
 import javax.swing.JDialog;
 import javax.swing.JFileChooser;
+import javax.swing.filechooser.FileFilter;
+
 import cytoscape.Cytoscape;
 import java.io.File;
 import org.cytoscape.phylotree.actions.PhyloTreeImportAction;
@@ -138,13 +140,16 @@
     private void btnFileActionPerformed(java.awt.event.ActionEvent evt) {      
                                  
        JFileChooser chooser = new JFileChooser(System.getProperty("user.dir"));
                chooser.setAcceptAllFileFilterUsed(false);
-               //chooser.addChoosableFileFilter(new TxtFileFilter());
+               
+               chooser.addChoosableFileFilter(new PhylipFileFilter());
+               chooser.addChoosableFileFilter(new PhyloXMLFileFilter());
            int returnVal = chooser.showOpenDialog(this);
            if(returnVal == JFileChooser.APPROVE_OPTION) {
                selectedFile = chooser.getSelectedFile();
+               tfFileName.setText(selectedFile.getName());     
            }
         
-           tfFileName.setText(selectedFile.getName());     
+               
     }                                       
 
     private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {    
                                      
@@ -178,4 +183,76 @@
     private javax.swing.JTextField tfFileName;
     // End of variables declaration                   
     
+    
+    // Inner classes - file filters for Phylip and phyloxml format
+    class PhylipFileFilter extends FileFilter{
+        //Accept all directories and all gif, jpg, tiff, or png files.
+        public boolean accept(File f) {
+            if (f.isDirectory()) {
+                return true;
+            }
+
+            String extension = getExtension(f);
+            if (extension != null) {
+                if (extension.equals("nh") || extension.equals("newick") || 
extension.equals("phy"))
+                {
+                        return true;
+                } 
+                else
+                {
+                    return false;
+                }
+            }
+
+            return false;
+        }
+
+        //The description of this filter
+        public String getDescription() {
+            return "Newick and Phylip format files";
+        }
+       
+    }
+    
+    class PhyloXMLFileFilter extends FileFilter{
+          public boolean accept(File f) {
+           if (f.isDirectory()) {
+               return true;
+           }
+
+           String extension = getExtension(f);
+           if (extension != null) {
+               if (extension.equals("phyloxml") || extension.equals("xml"))
+               {
+                       return true;
+               } 
+               else
+               {
+                   return false;
+               }
+           }
+
+           return false;
+       }
+
+       //The description of this filter
+       public String getDescription() {
+           return "PhyloXML format files";
+       }
+       
+   }
+    
+    /*
+     * Get the extension of a file.
+     */
+    public String getExtension(File f) {
+        String ext = null;
+        String s = f.getName();
+        int i = s.lastIndexOf('.');
+
+        if (i > 0 &&  i < s.length() - 1) {
+            ext = s.substring(i+1).toLowerCase();
+        }
+        return ext;
+    }
 }

Modified: 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/visualstyle/DepthwiseSize.java
===================================================================
--- 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/visualstyle/DepthwiseSize.java
    2009-08-07 06:18:07 UTC (rev 17733)
+++ 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/visualstyle/DepthwiseSize.java
    2009-08-07 06:21:26 UTC (rev 17734)
@@ -5,8 +5,6 @@
 
 import cytoscape.CyNetwork;
 import cytoscape.Cytoscape;
-import cytoscape.visual.Appearance;
-import cytoscape.visual.ArrowShape;
 import cytoscape.visual.EdgeAppearance;
 import cytoscape.visual.EdgeAppearanceCalculator;
 import cytoscape.visual.GlobalAppearanceCalculator;
@@ -19,7 +17,6 @@
 import cytoscape.visual.calculators.Calculator;
 import cytoscape.visual.mappings.BoundaryRangeValues;
 import cytoscape.visual.mappings.ContinuousMapping;
-import cytoscape.visual.mappings.DiscreteMapping;
 import cytoscape.visual.mappings.Interpolator;
 import cytoscape.visual.mappings.LinearNumberToColorInterpolator;
 import cytoscape.visual.mappings.ObjectMapping;
@@ -35,6 +32,8 @@
 
 
 public class DepthwiseSize implements PhyloVisualStyle {
+
+       static double MAX_SIZE = 135.0;
        
        public String getName()
        {
@@ -68,21 +67,19 @@
                nodeApp.set(VisualPropertyType.NODE_LABEL_POSITION, new 
LabelPosition(5,3,2,0,0));
                nodeApp.set(VisualPropertyType.NODE_FONT_SIZE,20);
                
-               
                nodeAppCalc.setDefaultAppearance(nodeApp);
                
                // Add edge appearance specific settings
                EdgeAppearance edgeApp = new EdgeAppearance();
                edgeApp.set(VisualPropertyType.EDGE_LABEL_COLOR, Color.WHITE);
                edgeApp.set(VisualPropertyType.EDGE_FONT_SIZE,20);
-               edgeApp.set(VisualPropertyType.EDGE_LINE_WIDTH,10);
+               edgeApp.set(VisualPropertyType.EDGE_LINE_WIDTH,5);
                edgeAppCalc.setDefaultAppearance(edgeApp);
                
-               
                nodeAppCalc.setCalculator(createNodeColorCalculator(network));
                nodeAppCalc.setCalculator(createNodeSizeCalculator(network));
                edgeAppCalc.setCalculator(createEdgeColorCalculator(network));
-
+               
                // Create the visual style 
                VisualStyle visualStyle = new VisualStyle("DepthwiseSize", 
nodeAppCalc, edgeAppCalc, globalAppCalc);
 
@@ -300,7 +297,7 @@
                // Set controlling Attribute
                cm.setControllingAttributeName("Depth", 
Cytoscape.getCurrentNetwork(), false);
                
-               Double underSize = 135.0;
+               Double underSize = MAX_SIZE;
                Double minSize = 110.0;
                Double midSize = 85.0;
                Double maxSize = 60.0;


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