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(): ReturnsTRUEif at least one unique structure satisfies the predicatesevery(): ReturnsTRUEif all unique structures satisfy the predicatesnone(): ReturnsTRUEif 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
