Changeset 3131

Show
Ignore:
Timestamp:
03/02/10 11:24:34 (5 months ago)
Author:
martijn
Message:

Convert embedded biopax from level 2 to level 3. Fixes #1129

Location:
trunk/src/core/org/pathvisio/model
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/core/org/pathvisio/model/GpmlFormat.java

    r3103 r3131  
    4848        public static final Namespace RDF = Namespace.getNamespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"); 
    4949        public static final Namespace RDFS = Namespace.getNamespace("rdfs", "http://www.w3.org/2000/01/rdf-schema#"); 
    50         public static final Namespace BIOPAX = Namespace.getNamespace("bp", "http://www.biopax.org/release/biopax-level2.owl#"); 
     50        public static final Namespace BIOPAX = Namespace.getNamespace("bp", "http://www.biopax.org/release/biopax-level3.owl#"); 
    5151        public static final Namespace OWL = Namespace.getNamespace("owl", "http://www.w3.org/2002/07/owl#"); 
    5252 
  • trunk/src/core/org/pathvisio/model/GpmlFormat200X.java

    r3130 r3131  
    2323 
    2424import org.bridgedb.DataSource; 
     25import org.jdom.Attribute; 
     26import org.jdom.Document; 
    2527import org.jdom.Element; 
    2628import org.jdom.Namespace; 
     
    479481        } 
    480482 
     483        protected void mapBiopax(PathwayElement o, Element e) throws ConverterException 
     484        { 
     485                //this method clones all content, 
     486                //getContent will leave them attached to the parent, which we don't want 
     487                //We can safely remove them, since the JDOM element isn't used anymore after this method 
     488                Element root = new Element("RDF", GpmlFormat.RDF); 
     489                root.addNamespaceDeclaration(GpmlFormat.RDFS); 
     490                root.addNamespaceDeclaration(GpmlFormat.RDF); 
     491                root.addNamespaceDeclaration(GpmlFormat.OWL); 
     492                root.addNamespaceDeclaration(GpmlFormat.BIOPAX); 
     493                root.setAttribute(new Attribute("base", getGpmlNamespace().getURI() + "#", Namespace.XML_NAMESPACE)); 
     494                //Element owl = new Element("Ontology", OWL); 
     495                //owl.setAttribute(new Attribute("about", "", RDF)); 
     496                //Element imp = new Element("imports", OWL); 
     497                //imp.setAttribute(new Attribute("resource", BIOPAX.getURI(), RDF)); 
     498                //owl.addContent(imp); 
     499                //root.addContent(owl); 
     500 
     501                root.addContent(e.cloneContent()); 
     502                Document bp = new Document(root); 
     503 
     504                updateBiopaxNamespace(root); 
     505                o.setBiopax(bp); 
     506        } 
     507 
     508        private static final Namespace BP_LEV2 = Namespace.getNamespace("bp", "http://www.biopax.org/release/biopax-level2.owl#"); 
     509         
     510        /** 
     511         * Convert the namespace of biopax element from old level2 to new level3. 
     512         * Starting from GpmlFormat2010a, we only support level 3. 
     513         * <p> 
     514         * We ignore all other differences between level 2 and level 3 here. For 
     515         * PublicationXref, it doesn't matter. 
     516         */ 
     517        private void updateBiopaxNamespace(Element e) 
     518        { 
     519                if (e.getNamespace().equals(BP_LEV2)) 
     520                { 
     521                        e.setNamespace(GpmlFormat.BIOPAX); 
     522                } 
     523                for (Object f : e.getChildren()) 
     524                { 
     525                        updateBiopaxNamespace((Element)f); 
     526                } 
     527        } 
     528         
    481529} 
  • trunk/src/core/org/pathvisio/model/GpmlFormat2010a.java

    r3130 r3131  
    2828 
    2929import org.bridgedb.DataSource; 
     30import org.jdom.Attribute; 
    3031import org.jdom.Document; 
    3132import org.jdom.Element; 
     
    788789        } 
    789790 
     791        protected void mapBiopax(PathwayElement o, Element e) throws ConverterException 
     792        { 
     793                //this method clones all content, 
     794                //getContent will leave them attached to the parent, which we don't want 
     795                //We can safely remove them, since the JDOM element isn't used anymore after this method 
     796                Element root = new Element("RDF", GpmlFormat.RDF); 
     797                root.addNamespaceDeclaration(GpmlFormat.RDFS); 
     798                root.addNamespaceDeclaration(GpmlFormat.RDF); 
     799                root.addNamespaceDeclaration(GpmlFormat.OWL); 
     800                root.addNamespaceDeclaration(GpmlFormat.BIOPAX); 
     801                root.setAttribute(new Attribute("base", getGpmlNamespace().getURI() + "#", Namespace.XML_NAMESPACE)); 
     802                //Element owl = new Element("Ontology", OWL); 
     803                //owl.setAttribute(new Attribute("about", "", RDF)); 
     804                //Element imp = new Element("imports", OWL); 
     805                //imp.setAttribute(new Attribute("resource", BIOPAX.getURI(), RDF)); 
     806                //owl.addContent(imp); 
     807                //root.addContent(owl); 
     808 
     809                root.addContent(e.cloneContent()); 
     810                Document bp = new Document(root); 
     811 
     812                o.setBiopax(bp); 
     813        } 
     814 
    790815} 
  • trunk/src/core/org/pathvisio/model/GpmlFormatAbstract.java

    r3126 r3131  
    447447                mapMappInfoDataVariable(o, e); 
    448448        } 
    449  
    450         protected void mapBiopax(PathwayElement o, Element e) throws ConverterException 
    451         { 
    452                 //this method clones all content, 
    453                 //getContent will leave them attached to the parent, which we don't want 
    454                 //We can safely remove them, since the JDOM element isn't used anymore after this method 
    455                 Element root = new Element("RDF", GpmlFormat.RDF); 
    456                 root.addNamespaceDeclaration(GpmlFormat.RDFS); 
    457                 root.addNamespaceDeclaration(GpmlFormat.RDF); 
    458                 root.addNamespaceDeclaration(GpmlFormat.OWL); 
    459                 root.addNamespaceDeclaration(GpmlFormat.BIOPAX); 
    460                 root.setAttribute(new Attribute("base", nsGPML.getURI() + "#", Namespace.XML_NAMESPACE)); 
    461                 //Element owl = new Element("Ontology", OWL); 
    462                 //owl.setAttribute(new Attribute("about", "", RDF)); 
    463                 //Element imp = new Element("imports", OWL); 
    464                 //imp.setAttribute(new Attribute("resource", BIOPAX.getURI(), RDF)); 
    465                 //owl.addContent(imp); 
    466                 //root.addContent(owl); 
    467  
    468                 root.addContent(e.cloneContent()); 
    469                 Document bp = new Document(root); 
    470  
    471                 o.setBiopax(bp); 
    472         } 
    473  
     449         
    474450        protected void updateBiopax(PathwayElement o, Element e) throws ConverterException 
    475451        {