Thanks, Herve!

To answer Tim's question (though it has become irrelevant after Herve's solution): because I'd rather not add VariantAnnotation to my dependency tree for only a couple of lines of code. It also seemed like the sort of thing that should be possible with a DNAStringSetList constructor, so I'm glad it will be starting tomorrow.

Stephanie

On 4/19/13 12:35 PM, Hervé Pagès wrote:
Hi Stephanie,

On 04/19/2013 11:55 AM, Stephanie M. Gogarten wrote:
Hi all,

There is a non-exported function in VariantAnnotation called
.toDNAStringSetList that converts a vector of comma-separated character
strings to a DNAStringSetList.  I'd like to use this code in a package
I'm working on.  Would it make sense to export this from Biostrings?  If
not, what is the proper way to attribute code if I borrow a few lines
from .toDNAStringSetList?

This should be a 1-liner but the 1-liner fails at the moment because the
DNAStringSetList() constructor doesn't work on a list:

   > comma_sep_strings <- c("AA,TT", "ACGT", "", "TT,A,,TAG")
   > DNAStringSetList(strsplit(comma_sep_strings, ",", fixed=TRUE))
   Error in strsplit(comma_sep_strings, ",") : non-character argument

Of course this should work (and it will work tomorrow after you run
biocLite()). In the mean time the workaround is to use do.call():

   > do.call(DNAStringSetList, strsplit(comma_sep_strings, ",",
fixed=TRUE))
   DNAStringSetList of length 4
   [[1]] AA TT
   [[2]] ACGT
   [[3]]   A DNAStringSet instance of length 0
   [[4]] TT A  TAG

Cheers,
H.

PS: Calling strsplit() with 'fixed=TRUE' makes it about 4x faster :-)


thanks,
Stephanie

_______________________________________________
Bioc-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/bioc-devel


_______________________________________________
Bioc-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/bioc-devel

Reply via email to