[R] how to download pdb structure files?

Duncan Temple Lang duncan at wald.ucdavis.edu
Sun Oct 28 23:42:32 CET 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Just for the record ...

Using external tools like wget, curl, etc.  is very
useful.  If one needs an approach that relies on
R or working with a subset of the files without transferring
them all, or simply not dealing with the file system (for security,
efficiency, etc.), then you can use the following
via the RCurl package

library(RCurl)
url = "ftp://ftp.wwpdb.org/pub/pdb/data/structures/all/pdb/"
fileNames = getURL(url, .opts = list(customrequest = "NLST *.gz") )
fileNames = strsplit(fileNames, "\\\r\\\n")[[1]]


And then you have the 46,818 file names that are in that
directory. (They meant it when they named the directory "all/"!)
This is an example where we really don't want to go to the
trouble of using wget -r and then pick out a few files.

But of course, if the original post was about how to download
a single file with a known name, then as Gabor said, reading
the documentation for download.file would be much more efficient,
as would specifying the operating system being used.

 D.

Ben Bolker wrote:
> 
> 
> Baoqiang Cao-2 wrote:
>> Dear All,
>>
>> I'd like to know if there is anyway to download a certain structure file
>> from http://www.pdb.org/. I tried the following but failed:
>>
>> tmp <-
>> download.file(url="ftp://ftp.wwpdb.org/pub/pdb/data/structures/all/pdb",
>> destfile="pdb100d.ent.gz")
>>
>> trying URL 'ftp://ftp.wwpdb.org/pub/pdb/data/structures/all/pdb'
>> Error in download.file(url =
>> "ftp://ftp.wwpdb.org/pub/pdb/data/structures/all/pdb",  : 
>>         cannot open URL
>> 'ftp://ftp.wwpdb.org/pub/pdb/data/structures/all/pdb'
>>
>> Any tips to fix it please? Thanks in advance.
>>
>> Best,
>> Baoqiang
>>
> 
>   I don't know that this is possible within R.  I would try obtaining wget
> and using
> wget -r to fetch the files ...
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHJRBY9p/Jzwa2QP4RAmOwAJ9Nw9ESkFjMTG34HNxOcWOKR647qwCeLK3t
WPsE371ipo0sXceqN+UH5Q8=
=gG2x
-----END PGP SIGNATURE-----



More information about the R-help mailing list