Recycling a DNAStringSet over an IRangesList in extractAt()
1
0
Entering edit mode
@Nicholas-24385
Last seen 3 months ago
United States

I've gotten myself into a situation where I'd like to use extractAt to pull multiple IRangesList positions from a DNAStringSet. A very simple version of what I'm trying to do would start with:

seqs <- DNAStringSet("ATCGTA")
v01 <- IRangesList(IRanges(start = c(1, 4),
end = c(3, 6)),
IRanges(start = c(1, 3, 5),
end = c(2, 4, 6)))


However this will error out complaining that the lengths are not matched.

v02 <- extractAt(x = seqs, at = v01)


Is there a simple way to perform this kind of operation, returning a DNAStringSetList is likely the goal in the short term.

Biostrings IRanges • 421 views
0
Entering edit mode

You could use either of these two options:

#/ either:
v02 <- extractAt(x = seqs, at = do.call(c, v01))

#/ or:
v02 <- lapply(v01, function(z) extractAt(x = seqs, at = z))

2
Entering edit mode
@michael-lawrence-3846
Last seen 8 months ago
United States

extractAt() could gain support for recycling x. In the mean time, you can just do:

extractAt(rep(seqs, length=length(v01)), v01)

0
Entering edit mode

This will work great in the short term! Recycling would I think be preferable, especially in cases where seqs is very large. Thanks!