Author: pwang
Date: 2008-09-11 12:08:23 -0700 (Thu, 11 Sep 2008)
New Revision: 14886

Modified:
   
csplugins/trunk/ucsd/pwang/SessionForWebPlugin/src/SessionForWebPlugin/HTMLSessionExporter.java
Log:
Correct sub-directory for CellCircuit web site

Modified: 
csplugins/trunk/ucsd/pwang/SessionForWebPlugin/src/SessionForWebPlugin/HTMLSessionExporter.java
===================================================================
--- 
csplugins/trunk/ucsd/pwang/SessionForWebPlugin/src/SessionForWebPlugin/HTMLSessionExporter.java
     2008-09-11 19:06:47 UTC (rev 14885)
+++ 
csplugins/trunk/ucsd/pwang/SessionForWebPlugin/src/SessionForWebPlugin/HTMLSessionExporter.java
     2008-09-11 19:08:23 UTC (rev 14886)
@@ -4,7 +4,6 @@
 import java.util.List;
 import java.util.Map;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Set;
 import java.util.TreeSet;
 import java.io.File;
@@ -14,7 +13,6 @@
 import java.awt.image.BufferedImage;
 import javax.swing.tree.TreeModel;
 import javax.imageio.ImageIO;
-
 import cytoscape.Cytoscape;
 import cytoscape.CyNetwork;
 import cytoscape.view.CyNetworkView;
@@ -24,6 +22,7 @@
 import cytoscape.task.Task;
 import cytoscape.task.TaskMonitor;
 import cytoscape.task.util.TaskManager;
+import cytoscape.data.CyAttributes;
 import cytoscape.data.writers.InteractionWriter;
 import cytoscape.data.writers.CytoscapeSessionWriter;
 
@@ -69,7 +68,7 @@
                                {
                                        List<String> networkIDs = networkIDs();
                                        //crap(networkIDs);
-                                       if (settings.destination == 
settings.DESTINATION_ZIP_ARCHIVE_4CELLCIRCUITS) {
+                                       if (settings.destination == 
SessionExporterSettings.DESTINATION_ZIP_ARCHIVE_4CELLCIRCUITS) {
                                                
generateNetworkFiles(networkIDs);                                               
                                        }
                                        else {
@@ -305,6 +304,26 @@
                                tempStream.close();
                        } // end writeSession()
 
+                       private String getSpeciesSubDirectory(String 
speciesStr){
+                               // Turn the string "Saccharomyces 
cerevisia,Homo sapiens" into "Saccharomyces_cerevisia_Homo_sapiens"
+                               if (speciesStr == null || 
speciesStr.trim().equals("")) {
+                                       return "unknown_species";
+                               }
+                               String retValue = "";
+                               String[] items = speciesStr.split(",");
+                               for (int i=0; i< items.length; i++){
+                                       String oneSpecies = items[i];
+                                       String[] components = 
oneSpecies.split(" ");
+                                       for (int j=0; j<components.length; j++ 
) {
+                                               if (!retValue.equals("")) {
+                                                       retValue += "_";
+                                               }
+                                               retValue += components[j];
+                                       }
+                               }
+                               return retValue;
+                       }
+                       
                        private void generateNetworkFiles(List<String> 
networkIDs) throws Exception
                        {
                                Map viewMap = Cytoscape.getNetworkViewMap();
@@ -321,9 +340,15 @@
                                        // export the sif file
                                        setStatus("Exporting SIF for: " + 
networkTitle);
                                        setPercentCompleted(10 + 80 * 
currentNetwork / networkCount);
-                                       if (settings.destination == 
settings.DESTINATION_ZIP_ARCHIVE_4CELLCIRCUITS) {
+                                       if (settings.destination == 
SessionExporterSettings.DESTINATION_ZIP_ARCHIVE_4CELLCIRCUITS) {
                                                ZipBundle2 zipBundle2 = 
(ZipBundle2) bundle;
-                                               zipBundle2.openEntry("sif", 
Bundle.sifFile(networkTitle));
+                                               
+                                               CyAttributes cyAttrs = 
Cytoscape.getNetworkAttributes();                                               
 
+                                               String species = 
cyAttrs.getStringAttribute(networkID, "species");
+                                               String speciesSubDir = 
getSpeciesSubDirectory(species);
+                                               
+                                               
zipBundle2.openEntry("sif/"+speciesSubDir, Bundle.sifFile(networkTitle));
+                                               
                                                CyNetwork network = 
Cytoscape.getNetwork(networkID);
                                                
InteractionWriter.writeInteractions(network, zipBundle2.entryWriter(), null);   
                                        
                                        }
@@ -344,7 +369,7 @@
                                        BufferedImage image = 
GraphViewToImage.convert(view, settings);
                                        if (image != null)
                                        {
-                                               if (settings.destination == 
settings.DESTINATION_ZIP_ARCHIVE_4CELLCIRCUITS) {
+                                               if (settings.destination == 
SessionExporterSettings.DESTINATION_ZIP_ARCHIVE_4CELLCIRCUITS) {
                                                        ZipBundle2 zipBundle2 = 
(ZipBundle2) bundle;
                                                        
zipBundle2.openEntry("img", Bundle.imageFile(networkTitle, 
settings.imageFormat));
                                                        ImageIO.write(image, 
settings.imageFormat, bundle.entryOutputStream());
@@ -362,7 +387,7 @@
                                        // generate thumbnail
                                        setStatus("Generating thumbnail for: " 
+ networkTitle);
                                        setPercentCompleted(10 + 80 * 
currentNetwork / networkCount + 40 / networkCount);
-                                       if (settings.destination == 
settings.DESTINATION_ZIP_ARCHIVE_4CELLCIRCUITS) {
+                                       if (settings.destination == 
SessionExporterSettings.DESTINATION_ZIP_ARCHIVE_4CELLCIRCUITS) {
                                                ZipBundle2 zipBundle2 = 
(ZipBundle2) bundle;
                                                zipBundle2.openEntry("thm_img", 
ZipBundle2.thumbnailFile(networkTitle, settings.imageFormat));
                                                BufferedImage thumbnail = 
Thumbnails.createThumbnail(image, settings);
@@ -378,7 +403,7 @@
                                        if (needToHalt)
                                                return;
 
-                                       if (settings.destination == 
settings.DESTINATION_ZIP_ARCHIVE_4CELLCIRCUITS) {
+                                       if (settings.destination == 
SessionExporterSettings.DESTINATION_ZIP_ARCHIVE_4CELLCIRCUITS) {
                                                continue;
                                        }
                                        


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