Skip to content

Commit

Permalink
Refactor code to only use grep
Browse files Browse the repository at this point in the history
  • Loading branch information
HDash committed Oct 22, 2024
1 parent c99577c commit c224027
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions R/filter_repeats.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,7 @@ filter_repeats <- function(motifs, filter_n = 6) {
}

repeat_pattern <- paste0("([A-Z])\\1{", filter_n - 1, ",}")
good_motif_indices <- vapply(seq_along(motifs$consensus), function(i) {
if (!grepl(repeat_pattern, motifs$consensus[i])) {
return(i)
} else {
return(-1)
}
}, numeric(1))
good_motif_indices <- good_motif_indices[good_motif_indices != -1]
good_motif_indices <- grep(repeat_pattern, motifs$consensus, invert = TRUE)
filtered_motifs <- motifs[good_motif_indices,]
return(filtered_motifs)
}

0 comments on commit c224027

Please sign in to comment.