
Test Predicates on Glycan Structure Vectors
smap_predicates.Rd
These functions test predicates on unique structures in a glycan structure vector, taking advantage of hash-based deduplication to avoid redundant computation. Similar to purrr predicate functions, but optimized for glycan structure vectors.
Details
These functions only evaluate .p
once for each unique structure, making them
much more efficient than applying .p
to each element individually when there
are duplicate structures.
Return Values:
ssome()
: ReturnsTRUE
if at least one unique structure satisfies the predicatesevery()
: ReturnsTRUE
if all unique structures satisfy the predicatesnone()
: ReturnsTRUE
if no unique structures satisfy the predicate
Examples
# Create a structure vector with duplicates
core1 <- o_glycan_core_1()
core2 <- n_glycan_core()
structures <- glycan_structure(core1, core2, core1) # core1 appears twice
# Test if some structures have more than 5 vertices
ssome(structures, function(g) igraph::vcount(g) > 5)
#> [1] FALSE
# Test if all structures have at least 3 vertices
severy(structures, function(g) igraph::vcount(g) >= 3)
#> [1] FALSE
# Test if no structures have more than 20 vertices
snone(structures, function(g) igraph::vcount(g) > 20)
#> [1] TRUE
# Use purrr-style lambda functions
ssome(structures, ~ igraph::vcount(.x) > 5)
#> [1] FALSE
severy(structures, ~ igraph::vcount(.x) >= 3)
#> [1] FALSE
snone(structures, ~ igraph::vcount(.x) > 20)
#> [1] TRUE