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") > edges <- collectEdges(xmlfile) > class(edges) [1] "matrix" "array" > dim(edges) [1] 46 3 > head(edges) Source Target MIM id2257fd8 "c0520" "b2305" "mim-inhibition" id25882942 "a531f" "b3910" "Arrow" id25c739ca "f5259" "ceb96" "Arrow" id2848101a "cc7e6" "fea9d" "Arrow" id295ae5fe "a8bb6" "b687e" "Arrow" id2e105012 "fea9d" "cd260" "Arrow" > tail(edges) Source Target MIM idf7bb43f7 "f2f0d" "a2d31" "mim-inhibition" idfc5a5200 "f58ce" "d3cde" "Arrow" idfea9f3db "ceb96" "a2d31" "Arrow" idfed646d2 "ba0fb" "fca28" "Arrow" id2d5bc3d8 "b0088" "b2d78" "mim-inhibition" id70c7e487 "b62b2" "b3356" "mim-inhibition" > ## Alternative: input first, then look for edges > doc <- XML::xmlParseDoc(xmlfile) > wedges <- collectEdges(doc) > all( wedges == edges) [1] TRUE > ## Obvious failure modes > try( collectEdges() ) Error in collectEdges() : argument "xmldoc" is missing, with no default > try( collectEdges("bogus") ) Error in collectEdges("bogus") : Cannot locate file 'bogus'! > badfile <- system.file("perl/nodeTypes.txt", package = "WayFindR") > try( collectEdges(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.50 0.04 0.51