R/glycan_structure.R
build_glycan_igraph.RdConvert a parsed glycan tree into a directed `igraph` object with parent–child relationships and residue-level metadata suitable for structural motif detection.
build_glycan_igraph(tree)A parsed glycan tree from pGlyco3_to_tree or wurcs_to_tree.
A directed `igraph` object representing the glycan structure.
The resulting graph contains the following vertex attributes:
name — synthetic node label (`"a"`, `"b"`, ...)
residue — residue type (H, N, A, F, G)
type — identical to residue (for convenience)
color — color encoding of residue type
is_root — TRUE if the vertex is the structural root
# Example: parse a pGlyco3 monosaccharide expression into a glycan tree
pGlyco_expr <- "(N(N(H(H(H))(H(H)(H)(H(H))))))"
# Convert expression into a parsed tree structure
tree <- pGlyco3_to_tree(pGlyco_expr)
g <- build_glycan_igraph(tree)
g
#> IGRAPH 07ea582 DN-B 10 9 --
#> + attr: name (v/c), residue (v/c), is_root (v/l), type (v/c), color
#> | (v/c)
#> + edges from 07ea582 (vertex names):
#> [1] a->b b->c c->d d->e c->f f->g f->h f->i i->j