crawlSynapseEntity: recursively query the file hiearachy of a given synapse...

Usage Arguments Examples

Usage

1

Arguments

synId
G

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (synId, G = NULL)
{
    result <- adjacentEdges(synId)
    while (!is.null(result)) {
        if (is.null(G)) {
            G <- list()
            id1 <- c(synId, result$entity.id)
            name1 <- c("head", result$entity.name)
            type1 <- c("head", result$entity.concreteType)
            G$id <- id1
            G$name <- name1
            G$type <- type1
            G$adjList <- vector("list", length(G$id))
            names(G$adjList) <- G$id
        }
        else {
            a <- which(!result$entity.id %in% G$id)
            id1 <- result$entity.id[a]
            name1 <- result$entity.name[a]
            type1 <- result$entity.concreteType[a]
            if (length(a) > 0) {
                G$adjList <- c(G$adjList, vector("list", length(id1)))
                G$id <- c(G$id, id1)
                G$name <- c(G$name, name1)
                G$type <- c(G$type, type1)
                names(G$adjList) <- G$id
            }
        }
        for (i in 1:length(result$entity.id)) {
            if (!as.character(result$entity.id[i]) %in% G$adjList[[as.character(synId)]]) {
                G$adjList[[as.character(synId)]] <- c(G$adjList[[as.character(synId)]],
                  as.character(result$entity.id[i]))
                cat("Crawling", result$entity.id[i], "\n")
                cat("Number of branches:", length(c(unlist(G$adjList))),
                  "\n")
                cat("Number of nodes:", length(G$adjList), "\n")
                G <- crawlSynapseEntity(result$entity.id[i],
                  G)
            }
            else {
                return(G)
            }
        }
    }
    return(G)
  }

Sage-Bionetworks/rSynapseUtilities documentation built on May 9, 2019, 12:13 p.m.