bomeara / sleq

A sleek package to deal with sequences in R. Joint O'Meara lab project.
GNU General Public License v2.0
3 stars 1 forks source link

Split DNA at defined places #3

Open kmassana opened 9 years ago

kmassana commented 9 years ago

i.e.,

SplitAlignmentOnce <- function(boundaries, sequences) {
    start <- boundaries[1]
    stop <- boundaries[2]
    if(stop<start) {
        stop("stop is less than start")
    }
    sub.sequences <- sequences[, start:stop]
    return(sub.sequences)
}

SplitAlignment <- function(start, stop, sequences) {
    all.boundaries <- cbind(start, stop)
    return(apply(all.boundaries, 1, SplitAlignmentOnce, sequences=sequences))
}

where start and stop are vectors of start and stop points