Entering edit mode
I would like to save a BSgenome object into a gzipped file in the fasta format. However, the following attempts didn't work.
Pass a connection opened by gzfile:
> export(object=BSgenome..., con=gzfile("~/test.fa.gz", "w"), format="fasta") Error in .local(object, ...) : Connection resource requested as a path
Pass nothing to the con
argument to retrieve a character vector that will then be written using gzfile
:
> test = export(object=BSgenome.Vvinifera.URGI.IGGP12Xv2, format="fasta") Error in .local(object, ...) : Connection resource requested as a path
Of course, I could first do export(BSgenome.Vvinifera.URGI.IGGP12Xv2, "test.fasta")
and then use gzip
on the cmd-line. But I'd prefer to do it all inside R.