R version 4.4.0 alpha (2024-04-07 r86351 ucrt) Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(WayFindR) > ## input directly from file > xmlfile <- system.file("pathways/WP3850.gpml", package = "WayFindR") > nodes <- collectNodes(xmlfile) > class(nodes) [1] "matrix" "array" > dim(nodes) [1] 52 3 > head(nodes) GraphId label Type a169c "a169c" "GSK3B" "GeneProduct" a2d31 "a2d31" "PI3K" "GeneProduct" a4cc9 "a4cc9" "SMAD3" "GeneProduct" a531f "a531f" "4EPB" "GeneProduct" a5550 "a5550" "EIF2B2" "GeneProduct" a8bb6 "a8bb6" "N-WASP" "GeneProduct" > tail(nodes) GraphId label Type b3910 "b3910" "Protein synthesis" "Pathway" c2a5c "c2a5c" "MTOR" "GeneProduct" f5051 "f5051" "MLST8" "GeneProduct" e1ccf "e1ccf" "MAPKAP1" "GeneProduct" c6e5f "c6e5f" "RICTOR" "GeneProduct" a3b41 "a3b41" "MTOR" "GeneProduct" > ## Alternative: input first, then look for nodes > doc <- XML::xmlParseDoc(xmlfile) > wnodes <- collectNodes(doc) > all( wnodes == nodes ) [1] TRUE > ## Obvious failure modes > try( collectNodes() ) Error in collectNodes() : argument "xmldoc" is missing, with no default > try( collectNodes("bogus") ) Error in collectNodes("bogus") : Cannot locate file 'bogus'! > badfile <- system.file("perl/nodeTypes.txt", package = "WayFindR") > try( collectNodes(badfile) ) D:/RCompile/CRANincoming/R-devel/lib/WayFindR/perl/nodeTypes.txt:1: parser error : Start tag expected, '<' not found CellularComponent 1 ^ Error in UseMethod("xmlNamespace") : no applicable method for 'xmlNamespace' applied to an object of class "NULL" In addition: Warning message: In xmlRoot.XMLInternalDocument(mydoc) : empty XML document > > proc.time() user system elapsed 0.39 0.14 0.48