Author: rodche
Date: 2012-06-13 16:57:47 -0700 (Wed, 13 Jun 2012)
New Revision: 29560

Removed:
   
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/StaxHack.java
Modified:
   core3/impl/trunk/biopax-impl/pom.xml
   
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/BioPaxMapper.java
   
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/BioPaxReaderTask.java
   
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/util/BioPaxUtil.java
   
core3/impl/trunk/cpath2-impl/src/main/java/org/cytoscape/cpath2/internal/util/BioPaxUtil.java
Log:
Fix (unencode html) for network/node/edge 'name' to show the actual latin 
symbol instead e.g. "β", etc. Some polishing.

Modified: core3/impl/trunk/biopax-impl/pom.xml
===================================================================
--- core3/impl/trunk/biopax-impl/pom.xml        2012-06-13 23:37:36 UTC (rev 
29559)
+++ core3/impl/trunk/biopax-impl/pom.xml        2012-06-13 23:57:47 UTC (rev 
29560)
@@ -9,7 +9,7 @@
        <properties>
                
<bundle.symbolicName>org.cytoscape.biopax-impl</bundle.symbolicName>
                <bundle.namespace>org.cytoscape.biopax</bundle.namespace>
-               <paxtools.version>4.1.1</paxtools.version>
+               <paxtools.version>4.1.5-SNAPSHOT</paxtools.version>
        </properties>
        
        <modelVersion>4.0.0</modelVersion>

Modified: 
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/BioPaxMapper.java
===================================================================
--- 
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/BioPaxMapper.java
  2012-06-13 23:37:36 UTC (rev 29559)
+++ 
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/BioPaxMapper.java
  2012-06-13 23:57:47 UTC (rev 29560)
@@ -19,6 +19,7 @@
 import org.biopax.paxtools.util.Filter;
 import org.cytoscape.biopax.internal.util.AttributeUtil;
 import org.cytoscape.biopax.internal.util.BioPaxUtil;
+import org.cytoscape.biopax.internal.util.BioPaxUtil.StaxHack;
 import org.cytoscape.biopax.internal.util.BioPaxVisualStyleUtil;
 import org.cytoscape.biopax.internal.util.ExternalLink;
 import org.cytoscape.biopax.internal.util.ExternalLinkUtil;
@@ -691,7 +692,7 @@
                // add a piece of the BioPAX (RDF/XML without parent|child 
elements)
                
                String owl = BioPaxUtil.toOwl(element); // (requires 
common-lang-2.4 bundle to be started)
-               AttributeUtil.set(network, node, 
CyNetwork.HIDDEN_ATTRS,BioPaxUtil.BIOPAX_DATA, owl, String.class);
+               AttributeUtil.set(network, node, CyNetwork.HIDDEN_ATTRS, 
BioPaxUtil.BIOPAX_DATA, owl, String.class);
                
                String name = 
BioPaxUtil.truncateLongStr(BioPaxUtil.getNodeName(element) + "");
                

Modified: 
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/BioPaxReaderTask.java
===================================================================
--- 
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/BioPaxReaderTask.java
      2012-06-13 23:37:36 UTC (rev 29559)
+++ 
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/BioPaxReaderTask.java
      2012-06-13 23:57:47 UTC (rev 29560)
@@ -2,6 +2,7 @@
 
 import java.io.InputStream;
 
+import org.apache.commons.lang.StringEscapeUtils;
 import org.biopax.paxtools.controller.ModelUtils;
 import org.biopax.paxtools.model.Model;
 import org.cytoscape.biopax.internal.util.BioPaxUtil;
@@ -89,10 +90,9 @@
                
                //normalize/infer properties: displayName, cellularLocation, 
organism, dartaSource
                BioPaxUtil.fixDisplayName(model);
-               ModelUtils mu = new ModelUtils(model);
-               mu.inferPropertyFromParent("dataSource");
-               mu.inferPropertyFromParent("organism");
-               mu.inferPropertyFromParent("cellularLocation");
+               ModelUtils.inferPropertyFromParent(model, "dataSource");
+               ModelUtils.inferPropertyFromParent(model, "organism");
+               ModelUtils.inferPropertyFromParent(model, "cellularLocation");
                
                // Map BioPAX Data to Cytoscape Nodes/Edges (run as task)
                BioPaxMapper mapper = new BioPaxMapper(model, networkFactory, 
taskMonitor);
@@ -121,7 +121,7 @@
                }
                
                // Take appropriate adjustments, if name already exists
-               name = naming.getSuggestedNetworkTitle(name);
+               name = 
naming.getSuggestedNetworkTitle(StringEscapeUtils.unescapeHtml(name));
                
                if(log.isDebugEnabled())
                        log.debug("New BioPAX network name is: " + name);

Deleted: 
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/StaxHack.java
===================================================================
--- 
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/StaxHack.java
      2012-06-13 23:37:36 UTC (rev 29559)
+++ 
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/StaxHack.java
      2012-06-13 23:57:47 UTC (rev 29560)
@@ -1,16 +0,0 @@
-package org.cytoscape.biopax.internal;
-
-import com.ctc.wstx.stax.WstxInputFactory;
-
-public class StaxHack {
-       public static final void runWithHack(Runnable runnable) {
-               Thread thread = Thread.currentThread();
-               ClassLoader loader = thread.getContextClassLoader();
-               try {
-                       
thread.setContextClassLoader(WstxInputFactory.class.getClassLoader());
-                       runnable.run();
-               } finally {
-                       thread.setContextClassLoader(loader);
-               }
-       }
-}

Modified: 
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/util/BioPaxUtil.java
===================================================================
--- 
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/util/BioPaxUtil.java
       2012-06-13 23:37:36 UTC (rev 29559)
+++ 
core3/impl/trunk/biopax-impl/src/main/java/org/cytoscape/biopax/internal/util/BioPaxUtil.java
       2012-06-13 23:57:47 UTC (rev 29560)
@@ -38,6 +38,7 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.commons.lang.StringEscapeUtils;
 import org.biopax.paxtools.controller.ModelUtils;
 import org.biopax.paxtools.controller.SimpleEditorMap;
 import org.biopax.paxtools.converter.OneTwoThree;
@@ -58,11 +59,12 @@
 import org.biopax.paxtools.model.level3.Xref;
 import org.biopax.paxtools.util.ClassFilterSet;
 import org.cytoscape.biopax.internal.BioPaxMapper;
-import org.cytoscape.biopax.internal.StaxHack;
 import org.cytoscape.model.CyNetwork;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.ctc.wstx.stax.WstxInputFactory;
+
 /**
  * BioPax Utility Class - is a BioPAX Model Adapter 
  * that also defines additional constants. 
@@ -86,6 +88,19 @@
         * BioPAX Class:  protein phosphorylated
         */
        public static final String PROTEIN_PHOSPHORYLATED = 
"Protein-phosphorylated";
+
+       public static class StaxHack {
+               public static final void runWithHack(Runnable runnable) {
+                       Thread thread = Thread.currentThread();
+                       ClassLoader loader = thread.getContextClassLoader();
+                       try {
+                               
thread.setContextClassLoader(WstxInputFactory.class.getClassLoader());
+                               runnable.run();
+                       } finally {
+                               thread.setContextClassLoader(loader);
+                       }
+               }
+       }
        
        // private Constructor
        private BioPaxUtil() {}
@@ -164,22 +179,17 @@
                }
                                
                String nodeName = getShortName(bpe);
-
-               if ((nodeName != null) && (nodeName.length() > 0)) {
-                       return nodeName;
+               if (nodeName == null || nodeName.length()== 0) {
+                       nodeName = getStandardName(bpe);
+                       if (nodeName == null || nodeName.length() == 0) {
+                               Collection<String> names = getSynonymList(bpe);
+                               if (!names.isEmpty())
+                                       nodeName = getTheShortestString(names);
+                       }
                }
 
-               nodeName = getStandardName(bpe);
-               if ((nodeName != null) && (nodeName.length() > 0)) {
-                       return nodeName;
-               }
-
-               Collection<String> names = getSynonymList(bpe);
-               if (names != null && !names.isEmpty()) {
-                       return getTheShortestString(names);
-               }
-
-               return bpe.getRDFId();
+               return (nodeName == null || nodeName.length() == 0)
+                               ? bpe.getRDFId() : 
StringEscapeUtils.unescapeHtml(nodeName);
        }
        
        
@@ -445,15 +455,13 @@
        public static String getName(Model model) {             
                StringBuffer modelName = new StringBuffer();
                
-               ModelUtils mu = new ModelUtils(model);
-               
-               Collection<Pathway> pws = mu.getRootElements(Pathway.class);
+               Collection<Pathway> pws = ModelUtils.getRootElements(model, 
Pathway.class);
                for(Pathway pw: pws) {
                                modelName.append(" ").append(getNodeName(pw)); 
                }
                
                if(modelName.length()==0) {
-                       Collection<Interaction> itrs = 
mu.getRootElements(Interaction.class);
+                       Collection<Interaction> itrs = 
ModelUtils.getRootElements(model, Interaction.class);
                        for(Interaction it: itrs) {
                                modelName.append(" ").append(getNodeName(it));
                        }       

Modified: 
core3/impl/trunk/cpath2-impl/src/main/java/org/cytoscape/cpath2/internal/util/BioPaxUtil.java
===================================================================
--- 
core3/impl/trunk/cpath2-impl/src/main/java/org/cytoscape/cpath2/internal/util/BioPaxUtil.java
       2012-06-13 23:37:36 UTC (rev 29559)
+++ 
core3/impl/trunk/cpath2-impl/src/main/java/org/cytoscape/cpath2/internal/util/BioPaxUtil.java
       2012-06-13 23:57:47 UTC (rev 29560)
@@ -39,9 +39,9 @@
 import java.util.Set;
 import java.util.Stack;
 
+import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.commons.lang.StringUtils;
 import org.biopax.paxtools.controller.AbstractTraverser;
-import org.biopax.paxtools.controller.ModelUtils;
 import org.biopax.paxtools.controller.ObjectPropertyEditor;
 import org.biopax.paxtools.controller.PropertyEditor;
 import org.biopax.paxtools.controller.SimpleEditorMap;
@@ -57,7 +57,6 @@
 import org.biopax.paxtools.model.level3.Interaction;
 import org.biopax.paxtools.model.level3.Level3Element;
 import org.biopax.paxtools.model.level3.Named;
-import org.biopax.paxtools.model.level3.Pathway;
 import org.biopax.paxtools.model.level3.PhysicalEntity;
 import org.biopax.paxtools.model.level3.Provenance;
 import org.biopax.paxtools.model.level3.PublicationXref;
@@ -177,22 +176,17 @@
                }
                                
                String nodeName = getShortName(bpe);
-
-               if ((nodeName != null) && (nodeName.length() > 0)) {
-                       return nodeName;
+               if (nodeName == null || nodeName.length()== 0) {
+                       nodeName = getStandardName(bpe);
+                       if (nodeName == null || nodeName.length() == 0) {
+                               Collection<String> names = getSynonymList(bpe);
+                               if (!names.isEmpty())
+                                       nodeName = getTheShortestString(names);
+                       }
                }
 
-               nodeName = getStandardName(bpe);
-               if ((nodeName != null) && (nodeName.length() > 0)) {
-                       return nodeName;
-               }
-
-               Collection<String> names = getSynonymList(bpe);
-               if (names != null && !names.isEmpty()) {
-                       return getTheShortestString(names);
-               }
-
-               return bpe.getRDFId();
+               return (nodeName == null || nodeName.length() == 0)
+                               ? bpe.getRDFId() : 
StringEscapeUtils.unescapeHtml(nodeName);
        }
        
        
@@ -446,41 +440,6 @@
                
                return subclasses;
        }
-
-
-       /**
-        * Creates a name for to the BioPAX model
-        * using its top-level process name(s). 
-        * 
-        * @param model
-        * @return
-        */
-       public static String getName(Model model) {             
-               StringBuffer modelName = new StringBuffer();
-               
-               ModelUtils mu = new ModelUtils(model);
-               
-               Collection<Pathway> pws = mu.getRootElements(Pathway.class);
-               for(Pathway pw: pws) {
-                               modelName.append(" ").append(getNodeName(pw)); 
-               }
-               
-               if(modelName.length()==0) {
-                       Collection<Interaction> itrs = 
mu.getRootElements(Interaction.class);
-                       for(Interaction it: itrs) {
-                               modelName.append(" ").append(getNodeName(it));
-                       }       
-               }
-               
-               if(modelName.length()==0) {
-                       modelName.append(model.getXmlBase());
-               }
-               
-               String name = modelName.toString().trim();
-
-               return name;
-       }
-
        
        /**
         * Gets all the objects of provided BioPAX types.

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