Search in sources :

Example 51 with Document

use of org.jdom.Document in project vcell by virtualcell.

the class PathwayReaderBiopax3 method main.

public static void main(String[] args) {
    try {
        // usual testing pathway
        Document document = XmlUtil.readXML(new File("C:\\dan\\reactome biopax\\Reactome3_189445.owl"));
        // infinite recursion between pathway steps
        // http://www.pathwaycommons.org/pc/webservice.do?cmd=get_record_by_cpath_id&version=2.0&q=826249&output=biopax
        // Document document = XmlUtil.readXML(new File("C:\\dan\\reactome biopax\\recursive.owl"));
        PathwayReaderBiopax3 pathwayReader = new PathwayReaderBiopax3(new RDFXMLContext());
        System.out.println("starting parsing");
        PathwayModel pathwayModel = pathwayReader.parse(document.getRootElement(), true);
        System.out.println("ending parsing");
        pathwayModel.reconcileReferences(null);
        System.out.println(pathwayModel.show(false));
    } catch (Exception e) {
        e.printStackTrace(System.out);
    }
}
Also used : Document(org.jdom.Document) PathwayModel(org.vcell.pathway.PathwayModel) File(java.io.File)

Example 52 with Document

use of org.jdom.Document in project vcell by virtualcell.

the class OptXmlReader method stringToXML.

public static Element stringToXML(String xmlString) {
    try {
        StringReader reader = new StringReader(xmlString);
        SAXBuilder builder = new SAXBuilder();
        Document sDoc = builder.build(reader);
        Element root = sDoc.getRootElement();
        return root;
    } catch (JDOMException e) {
        e.printStackTrace();
        throw new RuntimeException("source document is not well-formed\n" + e.getMessage());
    } catch (IOException e) {
        e.printStackTrace();
        throw new RuntimeException("Unable to read source document\n" + e.getMessage());
    }
}
Also used : SAXBuilder(org.jdom.input.SAXBuilder) Element(org.jdom.Element) StringReader(java.io.StringReader) IOException(java.io.IOException) Document(org.jdom.Document) JDOMException(org.jdom.JDOMException)

Example 53 with Document

use of org.jdom.Document in project vcell by virtualcell.

the class PathwayXMLHelper method getElementPathString.

private static String getElementPathString(Element childElement) {
    StringBuffer buffer = new StringBuffer();
    Element element = childElement;
    while (element != null) {
        if (buffer.length() == 0) {
            buffer.append(element.getName());
        } else {
            buffer.insert(0, element.getName() + "/");
        }
        Parent parent = element.getParent();
        if (parent instanceof Element) {
            element = (Element) parent;
        } else if (parent instanceof Document) {
            return buffer.toString();
        } else {
            return buffer.toString();
        }
    }
    return buffer.toString();
}
Also used : Parent(org.jdom.Parent) Element(org.jdom.Element) Document(org.jdom.Document)

Example 54 with Document

use of org.jdom.Document in project vcell by virtualcell.

the class PathwayEntryReader method main.

public static void main(String[] args) {
    try {
        Document document = XmlUtil.readXML(new File("C:\\dan\\reactome biopax\\PathwayCommons.xml"));
        PathwayEntryReader pathwayReader = new PathwayEntryReader();
        System.out.println("starting parsing");
        PathwayEntryModel pathwayModel = pathwayReader.parse(document.getRootElement());
        System.out.println("ending parsing");
        System.out.println(pathwayModel.show(true));
        System.out.println("Summary: ");
        System.out.println("   " + pathwayModel.getPathwayEntryObjects().size() + " elements.");
        System.out.println("   " + pathwayReader.numDuplicates + " duplicates.");
    } catch (Exception e) {
        e.printStackTrace(System.out);
    }
}
Also used : Document(org.jdom.Document) File(java.io.File)

Example 55 with Document

use of org.jdom.Document in project vcell by virtualcell.

the class PathwayBiopax3Test method main.

public static void main(String[] args) {
    try {
        // sbpax: http://www.signaling-gateway.org/molecule/query?afcsid=A000037&type=sbPAXExport
        // items within items
        // Document document = XmlUtil.readXML(new File("C:\\dan\\reactome biopax\\sbpax3fullexample.xml"));
        // biopax with URI-like IDs and resources
        // http://www.pathwaycommons.org/pc2/get?uri=HTTP:%2F%2FWWW.REACTOME.ORG%2FBIOPAX/48887%23PATHWAY1076_1_9606
        // sbpax3_uri_id.xml
        Document document = XmlUtil.readXML(new File("C:\\dan\\reactome biopax\\biopax3_no_id.xml"));
        // Document document = XmlUtil.readXML(new File("C:\\dan\\reactome biopax\\SBPax3.owl"));
        // Document document = XmlUtil.readXML(new File("C:\\dan\\reactome biopax\\Reactome3_189445.owl"));
        PathwayReaderBiopax3 pathwayReader = new PathwayReaderBiopax3(new RDFXMLContext());
        PathwayModel pathwayModel = pathwayReader.parse(document.getRootElement(), true);
        // System.out.print(pathwayModel.show(true));
        pathwayModel.reconcileReferences(null);
        bioModelToXML(pathwayModel);
    } catch (Exception e) {
        e.printStackTrace(System.out);
    }
}
Also used : Document(org.jdom.Document) PathwayModel(org.vcell.pathway.PathwayModel) File(java.io.File) XmlParseException(cbit.vcell.xml.XmlParseException)

Aggregations

Document (org.jdom.Document)144 Element (org.jdom.Element)102 SAXBuilder (org.jdom.input.SAXBuilder)51 IOException (java.io.IOException)49 JDOMException (org.jdom.JDOMException)29 File (java.io.File)27 ArrayList (java.util.ArrayList)22 XMLOutputter (org.jdom.output.XMLOutputter)22 List (java.util.List)16 StringReader (java.io.StringReader)15 Format (org.jdom.output.Format)12 VCDocument (org.vcell.util.document.VCDocument)11 XPath (org.jdom.xpath.XPath)10 StringWriter (java.io.StringWriter)9 InputStream (java.io.InputStream)8 URL (java.net.URL)8 NotNull (org.jetbrains.annotations.NotNull)7 Nullable (org.jetbrains.annotations.Nullable)7 FileNotFoundException (java.io.FileNotFoundException)5 Writer (java.io.Writer)5