Bioconductor/Biostrings

adding single element to existing DNAStringSetList

jayoung opened this issue · 3 comments

Hi there,

DNAStringSetList seems to have trouble with one intuitive (to me!) way to add a single element using [[ notation. I think the code below should show you what I mean.

thanks!

Janet

library(Biostrings)

dna1 <- c("AAA", "AC", "", "T", "GGATA")
dna2 <- c("G", "TT", "C")

x <- DNAStringSetList(dna1, dna2)
names(x) <- c("a", "b")

## an ordinary list for comparison
y <- list(a=DNAStringSet(dna1), b=DNAStringSet(dna2))

## this works
x[ c("c","d") ] <- DNAStringSetList(dna1,dna2)
x

class(x[["a"]])
# [1] "DNAStringSet"
# attr(,"package")
# [1] "Biostrings"

## this doesn't work, seems like it should (by analogy with ordinary lists)
x[["e"]] <- DNAStringSet(dna1)
    # Error in .wrap_in_length_one_list_like_object(value, name, x) : 
    #   failed to coerce 'list(value)' to a DNAStringSetList object of length 1
# works for an ordinary list
y[["c"]] <- DNAStringSet(dna1)

## this also doesn't work, but it makes sense to me that it shouldn't work
x[["e"]] <- DNAStringSetList(dna1)
    # Error in .wrap_in_length_one_list_like_object(value, name, x) : 
    #   failed to coerce 'list(value)' to a DNAStringSetList object of length 1

## single [ notation does work though
x["e"] <- DNAStringSetList(dna1)


sessionInfo()

R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.6

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats4    parallel  stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] Biostrings_2.56.0   XVector_0.28.0      IRanges_2.22.2      S4Vectors_0.26.1    BiocGenerics_0.34.0

loaded via a namespace (and not attached):
[1] zlibbioc_1.34.0 compiler_4.0.2  tools_4.0.2     crayon_1.3.4   

Looks like this is actually a duplicate of issue #75, which has been fixed.

you're right - same issue! glad it's fixed now. I had no memory of this when I filed the later one. Half the time I google for how to solve a bioconductor question, I find a post from myself asking the same question years ago. You'd think I would learn....

🤣