-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
I was just messing around with a set of motifs and I wanted to selectively RC one while using a universalmotif_df.
df <- to_df(c(create_motif, create_motif(name = "motif2")))
df %>%
mutate(motif = ifelse(name == "motif2", motif_rc(motif), motif))
Of course, this doesn't work because of the AsIs class.
So this got me thinking if there could be a way for folks to deprotect the motif for cases like this. Users doing this would know the operation is unsafe. Here's the silly implementation I came up with:
edit_motif <- function(m){
class(m) <- NULL
m
}
So the above becomes:
df <- to_df(c(create_motif, create_motif(name = "motif2")))
df %>%
mutate(motif = ifelse(name == "motif2", motif_rc(edit_motif(motif)), edit_motif(motif)))
Not sure if this is the perfect solution. For instance, this won't keep the AsIs attribute after the mutate, so maybe a macro for wrapping the whole ifelse operation to deprotect could work? I'll do some more thinking on this, but figured I'd post it now.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels