glyrex searches glycan structures using a glycowork-style regular
expression language and a stringr-style R API. It provides a more
flexible and expressive way for glycan substructure analysis than
glymotif.
# install.packages("pak")
# pak::pkg_install("glycoverse/glyrex")
install.packages("glyrex", repos = c('https://glycoverse.r-universe.dev', 'https://cloud.r-project.org'))
This is an experimental development package. It depends on glyrepr for glycan representations.
glymotif provides a concise syntax for matching glycan motifs.
However, exact motif matching may not be sufficient to express more
complex structural constraints. For example, a sialyl-LacNAc motif
without fucosylation cannot be specified using a bare IUPAC-condensed
sequence. To address this limitation, glyrex introduces a dedicated
glyco-regex syntax that enables more flexible and expressive pattern
matching.
library(glyrex)
x <- c(
"Gal(b1-4)[Fuc(a1-3)]GlcNAc(a1-",
"Gal(b1-4)GlcNAc(b1-",
NA_character_
)
p <- rex_compile("Galb4-(Fuca3-)GlcNAc")
rex_detect(x, p)
#> [1] TRUE FALSE NA
rex_extract(x, p)
#> [1] "Fuc(a1-3)[Gal(b1-4)]GlcNAc(a1-" NA
#> [3] NA
rex_match(x, "(?<antenna>Galb4)-GlcNAc")
#> match antenna
#> [1,] "Gal(b1-4)GlcNAc(a1-" "Gal(b1-"
#> [2,] "Gal(b1-4)GlcNAc(b1-" "Gal(b1-"
#> [3,] NA NA
rex_locate_all(x, p)
#> [[1]]
#> nodes edges
#> 1 1, 2, 3 1, 2
#>
#> [[2]]
#> [1] nodes edges
#> <0 rows> (or 0-length row.names)
#>
#> [[3]]
#> nodes edges
#> 1 NA NA
The glyco-regex syntax is adapted from glycowork, while the API design is inspired by stringr.