Author: pwang
Date: 2009-12-17 16:32:30 -0800 (Thu, 17 Dec 2009)
New Revision: 18786

Modified:
   cytoscape/trunk/src/cytoscape/data/readers/AbstractGraphReader.java
   cytoscape/trunk/tests/cytoscape/data/readers/FileImporterTest.java
Log:
Fixed bug 0002114: File extension should not be part of the network name after 
importation 

Modified: cytoscape/trunk/src/cytoscape/data/readers/AbstractGraphReader.java
===================================================================
--- cytoscape/trunk/src/cytoscape/data/readers/AbstractGraphReader.java 
2009-12-17 20:19:45 UTC (rev 18785)
+++ cytoscape/trunk/src/cytoscape/data/readers/AbstractGraphReader.java 
2009-12-18 00:32:30 UTC (rev 18786)
@@ -40,6 +40,7 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.util.regex.Pattern;
 
 import cytoscape.CyNetwork;
 import cytoscape.layout.CyLayoutAlgorithm;
@@ -100,6 +101,13 @@
                if (fileName != null) {
                        File tempFile = new File(fileName);
                        t = tempFile.getName();
+
+                       // Remove the file extension '.sif' or '.gml' as 
network title
+                       if (Pattern.matches(".+\\.SIF$", t.toUpperCase()) ||
+                                       Pattern.matches(".+\\.GML$", 
t.toUpperCase()))
+                       {
+                               t = t.substring(0, t.length()-4);
+                       }                       
                }
 
                return CyNetworkNaming.getSuggestedNetworkTitle(t);

Modified: cytoscape/trunk/tests/cytoscape/data/readers/FileImporterTest.java
===================================================================
--- cytoscape/trunk/tests/cytoscape/data/readers/FileImporterTest.java  
2009-12-17 20:19:45 UTC (rev 18785)
+++ cytoscape/trunk/tests/cytoscape/data/readers/FileImporterTest.java  
2009-12-18 00:32:30 UTC (rev 18786)
@@ -91,7 +91,7 @@
                network = Cytoscape.createNetworkFromFile(location);
 
                title = network.getTitle();
-               assertEquals("gal.gml", title);
+               assertEquals("gal", title);
 
                nodeCount = network.getNodeCount();
                assertEquals("number of nodes", 11, nodeCount);
@@ -129,7 +129,7 @@
                network = Cytoscape.createNetworkFromFile(location, false);
 
                title = network.getTitle();
-               assertEquals("galFiltered.sif", title);
+               assertEquals("galFiltered", title);
 
                nodeCount = network.getNodeCount();
                assertEquals("num nodes", 331, nodeCount);

--

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