This function injects motifs to a sequence

add_motifs(motifs, sequence)

Arguments

motifs

list of motifs to be injected

sequence

vector of alphabet elements

Value

list(sequence, motifs, masks)

Examples

# simple injection
add_motifs(list(c(1, "_", 1), c(1, 1)), c(2, 2, 3, 4))
#> [1] "1" "2" "1" "1"
#> attr(,"motifs")
#> attr(,"motifs")[[1]]
#> [1] "1" "_" "1"
#> 
#> attr(,"motifs")[[2]]
#> [1] 1 1
#> 
#> attr(,"masks")
#> attr(,"masks")[[1]]
#> [1]  TRUE FALSE  TRUE FALSE
#> 
#> attr(,"masks")[[2]]
#> [1] FALSE FALSE  TRUE  TRUE
#> 
# little bit more interesting
alph <- as.character(1L:4)
motifs <- generate_motifs(alph, 2, 2, n = 4, d = 6)
example_sequence <- sample(alph, size = 10, replace = TRUE)
add_motifs(motifs, example_sequence)
#>  [1] "3" "1" "3" "1" "1" "4" "1" "2" "3" "2"
#> attr(,"motifs")
#> attr(,"motifs")[[1]]
#>  [1] "3" "_" "3" "_" "_" "4" "_" "_" "_" "2"
#> 
#> attr(,"motifs")[[2]]
#> [1] "1" "_" "_" "_" "_" "_" "_" "3"
#> 
#> attr(,"masks")
#> attr(,"masks")[[1]]
#>  [1]  TRUE FALSE  TRUE FALSE FALSE  TRUE FALSE FALSE FALSE  TRUE
#> 
#> attr(,"masks")[[2]]
#>  [1] FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE
#>