Author: mes
Date: 2012-05-01 11:58:55 -0700 (Tue, 01 May 2012)
New Revision: 29059

Modified:
   
csplugins/trunk/ucsd/mes/genomespace/genomespace-plugin/src/main/java/cytoscape/genomespace/GSUtils.java
   
csplugins/trunk/ucsd/mes/genomespace/genomespace-plugin/src/main/java/cytoscape/genomespace/NetworkTypeSelectionDialog.java
   
csplugins/trunk/ucsd/mes/genomespace/genomespace-plugin/src/main/java/cytoscape/genomespace/SaveNetworkToGenomeSpace.java
   
csplugins/trunk/ucsd/mes/genomespace/genomespace-plugin/src/main/java/cytoscape/genomespace/SaveSessionToGenomeSpace.java
   csplugins/trunk/ucsd/mes/genomespace/genomespace-webstart/README.txt
Log:
updates to export networks to genomespace

Modified: 
csplugins/trunk/ucsd/mes/genomespace/genomespace-plugin/src/main/java/cytoscape/genomespace/GSUtils.java
===================================================================
--- 
csplugins/trunk/ucsd/mes/genomespace/genomespace-plugin/src/main/java/cytoscape/genomespace/GSUtils.java
    2012-05-01 18:52:17 UTC (rev 29058)
+++ 
csplugins/trunk/ucsd/mes/genomespace/genomespace-plugin/src/main/java/cytoscape/genomespace/GSUtils.java
    2012-05-01 18:58:55 UTC (rev 29059)
@@ -163,5 +163,19 @@
                final int lastDotPos = fileName.lastIndexOf('.');
                return lastDotPos == -1 ? fileName : fileName.substring(0, 
lastDotPos);
        }
+
+    // Returns the directory component of "path"
+    public static String dirName(final String path) {
+        final int lastSlashPos = path.lastIndexOf('/');
+        return path.substring(0, lastSlashPos + 1);
+    }
+
+
+    // Returns the basename component of "path"
+    public static String baseName(final String path) {
+        final int lastSlashPos = path.lastIndexOf('/');
+        return lastSlashPos == -1 ? path : path.substring(lastSlashPos + 1);
+    }
+
 }
 

Modified: 
csplugins/trunk/ucsd/mes/genomespace/genomespace-plugin/src/main/java/cytoscape/genomespace/NetworkTypeSelectionDialog.java
===================================================================
--- 
csplugins/trunk/ucsd/mes/genomespace/genomespace-plugin/src/main/java/cytoscape/genomespace/NetworkTypeSelectionDialog.java
 2012-05-01 18:52:17 UTC (rev 29058)
+++ 
csplugins/trunk/ucsd/mes/genomespace/genomespace-plugin/src/main/java/cytoscape/genomespace/NetworkTypeSelectionDialog.java
 2012-05-01 18:58:55 UTC (rev 29059)
@@ -18,7 +18,7 @@
 final class NetworkTypeSelectionDialog extends JDialog {
        private String networkType;
        private final JRadioButton sifRadioButton;
-       private final JRadioButton nnfRadioButton;
+//     private final JRadioButton nnfRadioButton;
        private final JRadioButton xgmmlRadioButton;
        private final JRadioButton gmlRadioButton;
        private final JButton okButton;
@@ -39,9 +39,9 @@
                sifRadioButton = new JRadioButton("SIF", true);
                group.add(sifRadioButton);
                radioButtonPane.add(sifRadioButton);
-               nnfRadioButton = new JRadioButton("NNF");
-               group.add(nnfRadioButton);
-               radioButtonPane.add(nnfRadioButton);
+//             nnfRadioButton = new JRadioButton("NNF");
+//             group.add(nnfRadioButton);
+//             radioButtonPane.add(nnfRadioButton);
                xgmmlRadioButton = new JRadioButton("XGMML");
                group.add(xgmmlRadioButton);
                radioButtonPane.add(xgmmlRadioButton);
@@ -58,8 +58,8 @@
                                public void actionPerformed(ActionEvent 
actionEvent) {
                                        if 
(NetworkTypeSelectionDialog.this.sifRadioButton.isSelected())
                                                
NetworkTypeSelectionDialog.this.networkType = "SIF";
-                                       else if 
(NetworkTypeSelectionDialog.this.nnfRadioButton.isSelected())
-                                               
NetworkTypeSelectionDialog.this.networkType = "NNF";
+//                                     else if 
(NetworkTypeSelectionDialog.this.nnfRadioButton.isSelected())
+//                                             
NetworkTypeSelectionDialog.this.networkType = "NNF";
                                        else if 
(NetworkTypeSelectionDialog.this.xgmmlRadioButton.isSelected())
                                                
NetworkTypeSelectionDialog.this.networkType = "XGMML";
                                        else if 
(NetworkTypeSelectionDialog.this.gmlRadioButton.isSelected())

Modified: 
csplugins/trunk/ucsd/mes/genomespace/genomespace-plugin/src/main/java/cytoscape/genomespace/SaveNetworkToGenomeSpace.java
===================================================================
--- 
csplugins/trunk/ucsd/mes/genomespace/genomespace-plugin/src/main/java/cytoscape/genomespace/SaveNetworkToGenomeSpace.java
   2012-05-01 18:52:17 UTC (rev 29058)
+++ 
csplugins/trunk/ucsd/mes/genomespace/genomespace-plugin/src/main/java/cytoscape/genomespace/SaveNetworkToGenomeSpace.java
   2012-05-01 18:58:55 UTC (rev 29059)
@@ -1,8 +1,9 @@
 package cytoscape.genomespace;
 
 
+import cytoscape.CyNetwork;
+import cytoscape.view.CyNetworkView;
 import cytoscape.Cytoscape;
-import cytoscape.data.writers.CytoscapeSessionWriter;
 import cytoscape.logger.CyLogger;
 import cytoscape.task.Task;
 import cytoscape.task.TaskMonitor;
@@ -11,14 +12,25 @@
 import cytoscape.util.CytoscapeAction;
 import cytoscape.util.FileUtil;
 
+import cytoscape.data.readers.GMLParser;
+import cytoscape.data.readers.GMLWriter;
+import cytoscape.data.writers.InteractionWriter;
+import cytoscape.data.writers.XGMMLWriter;
+
 import java.awt.FileDialog;
 import java.awt.event.ActionEvent;
 import java.io.File;
+import java.io.FileWriter;
+import java.io.OutputStreamWriter;
+import java.io.FileOutputStream;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Vector;
 import javax.swing.ImageIcon;
 import javax.swing.JOptionPane;
+import java.net.URISyntaxException;
 
 import org.genomespace.datamanager.core.GSFileMetadata;
 import org.genomespace.client.DataManagerClient;
@@ -70,24 +82,14 @@
                        // Make sure the file name ends with the network type 
extension:
                        if (!saveFileName.toLowerCase().endsWith("." + 
networkType))
                                saveFileName += "." + networkType;
-/*
-                       // Create Task
-                       final File tempFile = File.createTempFile("temp", 
"cysession");
-                       final Task task = new 
SaveSessionTask(tempFile.getPath(), saveFileName,
-                                                             
dataManagerClient);
 
-                       // Configure JTask Dialog Pop-Up Box
-                       JTaskConfig jTaskConfig = new JTaskConfig();
+                       final File localNetworkFile = saveNetworkLocally( 
networkType ); 
 
-                       jTaskConfig.displayCancelButton(false);
-                       jTaskConfig.setOwner(Cytoscape.getDesktop());
-                       jTaskConfig.displayCloseButton(true);
-                       jTaskConfig.displayStatus(true);
-                       jTaskConfig.setAutoDispose(true);
+            GSFileMetadata uploadedFileMetadata = 
dataManagerClient.uploadFile(localNetworkFile, 
+                                                                           
GSUtils.dirName(saveFileName),
+                                                                           
GSUtils.baseName(saveFileName));
+            localNetworkFile.delete();
 
-                       // Execute Task in New Thread; pop open JTask Dialog 
Box.
-                       TaskManager.executeTask(task, jTaskConfig);
-*/
                } catch (final Exception ex) {
                        logger.error("GenomeSpace failed", ex);
                        JOptionPane.showMessageDialog(Cytoscape.getDesktop(),
@@ -95,4 +97,33 @@
                                                      
JOptionPane.ERROR_MESSAGE);
                }
        }
+
+       private File saveNetworkLocally(String type) throws IOException, 
URISyntaxException {
+               final File tempFile = File.createTempFile("tempNetwork", type);
+               CyNetwork network = Cytoscape.getCurrentNetwork();
+               CyNetworkView view = Cytoscape.getCurrentNetworkView();
+
+               OutputStreamWriter fileWriter = null;
+               if ( type.equalsIgnoreCase("xgmml") ) {
+                       fileWriter = new OutputStreamWriter(new 
FileOutputStream(tempFile), "UTF-8");
+                       final XGMMLWriter writer = new XGMMLWriter(network, 
view);
+                       writer.write(fileWriter);
+               } else if ( type.equalsIgnoreCase("sif") ) {
+                       fileWriter = new FileWriter(tempFile);
+                       InteractionWriter.writeInteractions(network, 
fileWriter, null);
+               } else if ( type.equalsIgnoreCase("gml") ) {
+                       List list = new Vector();
+                       fileWriter = new FileWriter(tempFile);
+                       GMLWriter gmlWriter = new GMLWriter();
+                       gmlWriter.writeGML(network, view, list);
+                       GMLParser.printList(list, fileWriter);
+               } else {
+                       throw new UnsupportedOperationException("Can't write " 
+ type + " format files to GenomeSpace.");
+               }
+
+               if ( fileWriter != null )
+                       fileWriter.close();
+
+               return tempFile;
+       }
 }

Modified: 
csplugins/trunk/ucsd/mes/genomespace/genomespace-plugin/src/main/java/cytoscape/genomespace/SaveSessionToGenomeSpace.java
===================================================================
--- 
csplugins/trunk/ucsd/mes/genomespace/genomespace-plugin/src/main/java/cytoscape/genomespace/SaveSessionToGenomeSpace.java
   2012-05-01 18:52:17 UTC (rev 29058)
+++ 
csplugins/trunk/ucsd/mes/genomespace/genomespace-plugin/src/main/java/cytoscape/genomespace/SaveSessionToGenomeSpace.java
   2012-05-01 18:58:55 UTC (rev 29059)
@@ -140,8 +140,7 @@
                        taskMonitor.setPercentCompleted(20);
                        final File localFile = new File(localFileName);
                        uploadedFileMetadata =
-                               dataManagerClient.uploadFile(localFile, 
dirName(uploadPath),
-                                                            
baseName(uploadPath));
+                               dataManagerClient.uploadFile(localFile, 
GSUtils.dirName(uploadPath), GSUtils.baseName(uploadPath));
                        localFile.delete();
                } catch (Exception e) {
                        taskMonitor.setException(e, "Could not write session to 
the file: "
@@ -184,17 +183,4 @@
        public String getTitle() {
                return "Saving Cytoscape Session";
        }
-
-       // Returns the directory component of "path"
-       private String dirName(final String path) {
-               final int lastSlashPos = path.lastIndexOf('/');
-               return path.substring(0, lastSlashPos + 1);
-       }
-
-
-       // Returns the basename component of "path"
-       private String baseName(final String path) {
-               final int lastSlashPos = path.lastIndexOf('/');
-               return lastSlashPos == -1 ? path : path.substring(lastSlashPos 
+ 1);
-       }
 }

Modified: csplugins/trunk/ucsd/mes/genomespace/genomespace-webstart/README.txt
===================================================================
--- csplugins/trunk/ucsd/mes/genomespace/genomespace-webstart/README.txt        
2012-05-01 18:52:17 UTC (rev 29058)
+++ csplugins/trunk/ucsd/mes/genomespace/genomespace-webstart/README.txt        
2012-05-01 18:58:55 UTC (rev 29059)
@@ -10,7 +10,7 @@
 The actual command: 
 
 
-       mvn webstart:jnlp-inline 
-Dwebstart.url=http://chianti.ucsd.edu/genomespace
+       mvn clean webstart:jnlp-inline 
-Dwebstart.url=http://chianti.ucsd.edu/genomespace
 
 
 

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