[R] get compressed data via a socket connection

Simon Penel penel at biomserv.univ-lyon1.fr
Wed Nov 8 11:14:08 CET 2006


Dear R developers

I am currently working on the seqinR package.  The seqinR package 
allows  a  remote access to  biological databases via a socket connection.
We are using the  functions  socketConnection, writeLines and  readLines 
to open the socket, send request to the server  and receive response 
from the
server respectively.
Recently, a new function implemented in the socket server allows the 
server to send zlib-compressed data and we would like to use this 
function in R ( seqinR).
Thus I have 2 questions about this.
I did not found any R function dedicated to  handle compressed data from 
a socket connection.  My first question is :  Is it possible that this 
function actually exist or
that it will exist in the future ?

Here there is an example of the R fonction we use, the first time with 
no compression, the second one with compression.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

 > library(seqinr)  # loading seqinr
 > choosebank("hoverprot") # choose the database ( this operation will 
open the socketanknameSocket$socket )
 > query("toto","k=btg@")  # do a query ( it means : give me the 
sequences associated to the keywords begining with btg, save the list in 
toto)
 > socket <- banknameSocket$socket  # here I save the socket in "socket"
 > 
request="extractseqs&lrank=2&format=\"fasta\"&operation=\"simple\"&zlib=F" 
# writing a request
 > #( it means : give me the sequence information of the list of rank 2 
( toto) in fasta format, no compressed
 > writeLines(request, socket, sep = "\n")  # put the request into the 
socket
 > seq <- readLines(socket , n = -1) # read the answer of the socket 
server: it works, seq object contains the socket answer with sequence data

 > 
request="extractseqs&lrank=2&format=\"fasta\"&operation=\"simple\"&zlib=T" 
 # now I try with zlib compression on
 > writeLines(request, socket, sep = "\n") #
 > seq <- readLines(socket , n = -1) #  it doesno work
Warning message:
incomplete final line found by readLines on '->pbil.univ-lyon1.fr:5558'
 >


Finaly  I  begin to create a C interface to get the compressed data from 
the server.  However I am wondering how I can pass a opened socket as 
argument
to the C interface, especially which R type defined in C  I should  use 
to handle this.  Should I  use the structure Rconn defined in 
Rconnection.h ? It seems to me that I may finally have to write a 
modified version of the C function readLines, but I think this not the 
best solution. This my second question....


I hope this mail is not irrelevant,  thanks for any help about these 
questions
All the best,

Simon



-- 
Simon Penel
Laboratoire de Biometrie et Biologie Evolutive           
Bat 711  -   CNRS UMR 5558  -    Universite Lyon 1              
43 bd du 11 novembre 1918 69622 Villeurbanne Cedex       
Tel:   04 72 43 29 04      Fax:  04 72 43 13 88
http://pbil.univ-lyon1.fr/members/penel



More information about the R-help mailing list