Author: rodche
Date: 2012-10-16 11:14:05 -0700 (Tue, 16 Oct 2012)
New Revision: 30676

Modified:
   cytoscape/trunk/coreplugins/BioPAX/pom.xml
   
cytoscape/trunk/coreplugins/BioPAX/src/main/java/cytoscape/coreplugins/biopax/util/BioPaxUtil.java
   
cytoscape/trunk/coreplugins/BioPAX/src/test/java/cytoscape/coreplugins/biopax/mapper/TestBioPaxToCytoscapeMapper.java
Log:
bug fixed, related to getLocalRdfId method (also - renamed, made private); this 
was also related to proper using of BioPAX model's xml:base (URI prefix)... 

Modified: cytoscape/trunk/coreplugins/BioPAX/pom.xml
===================================================================
--- cytoscape/trunk/coreplugins/BioPAX/pom.xml  2012-10-16 09:55:03 UTC (rev 
30675)
+++ cytoscape/trunk/coreplugins/BioPAX/pom.xml  2012-10-16 18:14:05 UTC (rev 
30676)
@@ -67,7 +67,7 @@
                <dependency>
                        <groupId>org.biopax.paxtools</groupId>
                        <artifactId>paxtools-core</artifactId>
-                       <version>4.1.1</version>
+                       <version>4.1.5b</version>
                </dependency>
                <dependency>
                        <groupId>commons-logging</groupId>

Modified: 
cytoscape/trunk/coreplugins/BioPAX/src/main/java/cytoscape/coreplugins/biopax/util/BioPaxUtil.java
===================================================================
--- 
cytoscape/trunk/coreplugins/BioPAX/src/main/java/cytoscape/coreplugins/biopax/util/BioPaxUtil.java
  2012-10-16 09:55:03 UTC (rev 30675)
+++ 
cytoscape/trunk/coreplugins/BioPAX/src/main/java/cytoscape/coreplugins/biopax/util/BioPaxUtil.java
  2012-10-16 18:14:05 UTC (rev 30676)
@@ -33,6 +33,7 @@
 import cytoscape.logger.CyLogger;
 
 import org.biopax.paxtools.controller.EditorMap;
+import org.biopax.paxtools.controller.ModelUtils;
 import org.biopax.paxtools.controller.SimpleEditorMap;
 import org.biopax.paxtools.io.SimpleIOHandler;
 import org.biopax.paxtools.model.BioPAXElement;
@@ -245,21 +246,20 @@
                        return getTheShortestString(names);
                }
 
-               return getLocalPartRdfId(bpe);
+               return fixPepRdfId(bpe);
        }
        
        
+       /**
+        * Generates a unique CyNode identifier
+        */
        public static String generateId(BioPAXElement bpe) {
-               String id = (bpe instanceof physicalEntityParticipant 
-                               && 
((physicalEntityParticipant)bpe).getPHYSICAL_ENTITY()!=null)
-                                       ? 
((physicalEntityParticipant)bpe).getPHYSICAL_ENTITY().getRDFId() 
-                                       : bpe.getRDFId();
-               return Cytoscape.getCurrentNetwork().getIdentifier().hashCode() 
+ 
-                               "" + id.hashCode() + "-" + 
getLocalPartRdfId(bpe);
+               String id = fixPepRdfId(bpe);
+               return 
ModelUtils.md5hex(Cytoscape.getCurrentNetwork().getIdentifier() + id);
        }
 
        
-       public static String getLocalPartRdfId(BioPAXElement bpe) {
+       private static String fixPepRdfId(BioPAXElement bpe) {
                if(bpe == null) return "";
                
                // also fix pEPs
@@ -268,7 +268,7 @@
                                        ? 
((physicalEntityParticipant)bpe).getPHYSICAL_ENTITY().getRDFId() 
                                        : bpe.getRDFId();
                                        
-               return id.replaceFirst("^.+#", "");
+               return id;
        }
        
        // get the shortest string

Modified: 
cytoscape/trunk/coreplugins/BioPAX/src/test/java/cytoscape/coreplugins/biopax/mapper/TestBioPaxToCytoscapeMapper.java
===================================================================
--- 
cytoscape/trunk/coreplugins/BioPAX/src/test/java/cytoscape/coreplugins/biopax/mapper/TestBioPaxToCytoscapeMapper.java
       2012-10-16 09:55:03 UTC (rev 30675)
+++ 
cytoscape/trunk/coreplugins/BioPAX/src/test/java/cytoscape/coreplugins/biopax/mapper/TestBioPaxToCytoscapeMapper.java
       2012-10-16 18:14:05 UTC (rev 30676)
@@ -117,8 +117,9 @@
 
                while (nodeIterator.hasNext()) {
                        CyNode node = (CyNode) nodeIterator.next();
-
-                       if (node.getIdentifier().endsWith("CPATH-126")) {
+                       String uri = Cytoscape.getNodeAttributes()
+                         .getStringAttribute(node.getIdentifier(), 
MapBioPaxToCytoscape.BIOPAX_RDF_ID);
+                       if (uri.endsWith("CPATH-126")) {
                                targetNodeIndex = node.getRootGraphIndex();
                        }
                }
@@ -181,8 +182,9 @@
 
                while (nodeIterator.hasNext()) {
                        CyNode node = (CyNode) nodeIterator.next();
-
-                       if 
(node.getIdentifier().endsWith("physicalInteraction1")) {
+                       String uri = Cytoscape.getNodeAttributes()
+                         .getStringAttribute(node.getIdentifier(), 
MapBioPaxToCytoscape.BIOPAX_RDF_ID);
+                       if (uri.endsWith("physicalInteraction1")) {
                                targetNodeIndex = node.getRootGraphIndex();
                        }
                }
@@ -215,8 +217,9 @@
                int nodeCount = cyNetwork.getNodeCount();
                assertEquals(12, nodeCount);
 
-               //  This HashMap contains a list of expected node identifiers.
-               // correction: these are identifier's part (real id now begins 
with hash code)
+               //  This HashMap contains all expected nodes.
+               //  But node identifier is now a auto-generated md5hex digest; 
+               //  so it's easier to test here by using biopax.rdfid values 
instead)
                Map<String, Integer> nodeMap = new HashMap<String, Integer>();
                nodeMap.put("protein45", new Integer(0));
                nodeMap.put("protein32", new Integer(0));
@@ -226,7 +229,6 @@
                nodeMap.put("smallMolecule27", new Integer(0));
                nodeMap.put("smallMolecule39", new Integer(0));
                nodeMap.put("smallMolecule99", new Integer(0));
-
                //  These represent interaction nodes
                nodeMap.put("catalysis43", new Integer(0));
                nodeMap.put("biochemicalReaction6", new Integer(0));
@@ -239,9 +241,10 @@
                while (nodeIterator.hasNext()) {
                        CyNode node = (CyNode) nodeIterator.next();
                        String id = node.getIdentifier();
-
+                       String uri = Cytoscape.getNodeAttributes()
+                         .getStringAttribute(id, 
MapBioPaxToCytoscape.BIOPAX_RDF_ID);
                        //  Test a specific node label
-                       if (id.endsWith("smallMolecule99")) {
+                       if (uri.endsWith("smallMolecule99")) {
                                String label = Cytoscape.getNodeAttributes()
                                                  .getStringAttribute(id, 
BioPaxVisualStyleUtil.BIOPAX_NODE_LABEL);
                                assertEquals("Mg2+", label);
@@ -249,7 +252,9 @@
 
                        String found = null;
                        for(String key : nodeMap.keySet()) {
-                               if(id.endsWith(key)) {
+                               uri = Cytoscape.getNodeAttributes()
+                                               .getStringAttribute(id, 
MapBioPaxToCytoscape.BIOPAX_RDF_ID);
+                               if(uri.endsWith(key)) {
                                        found = key;
                                        break;
                                }
@@ -287,8 +292,9 @@
 
                while (nodeIterator.hasNext()) {
                        CyNode node = (CyNode) nodeIterator.next();
-
-                       if 
(node.getIdentifier().endsWith("biochemicalReaction37")) {
+                       String uri = Cytoscape.getNodeAttributes()
+                         .getStringAttribute(node.getIdentifier(), 
MapBioPaxToCytoscape.BIOPAX_RDF_ID);
+                       if (uri.endsWith("biochemicalReaction37")) {
                                targetNodeIndex = node.getRootGraphIndex();
                        }
                }

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