R/split_alignment_by_lines.R

Defines functions split_by_width

split_by_width <- function(alignment, line_width = 30) {

m <- remove_align_mat_class(alignment)
m2 <- m

i <- rep(seq_len(ncol(m2)), each = line_width, length.out = ncol(m2))
j <- length(unique(i))
jj <- cumsum(rep(j, nrow(m2))) - j

f <- i + rep(jj, each = ncol(m2))

lines <- split(t(m2), f)
lines_collapsed <- lapply(lines, paste0, collapse = '')
m3 <- matrix(lines_collapsed, ncol = j, byrow = TRUE)

return(m3)

}

Try the agvgd package in your browser

Any scripts or data that you put into this service are public.

agvgd documentation built on Sept. 11, 2022, 1:07 a.m.