R/downloadPubchem.R

downloadPubchem <- function(out_path,url = "ftp://ftp.ncbi.nlm.nih.gov/pubchem/Compound/CURRENT-Full/SDF/", start=1){
	filenames <- getURL(url,ftp.use.epsv = FALSE,dirlistonly = TRUE)
	filenames <- strsplit(filenames,"\n")[[1]]
	cat('\n',length(filenames),'files found\n')
	for (x in start:length(filenames)){
		cat("\n",x,'. ',filenames[x],'\n',sep = '')
		download.file(paste(url,filenames[x],sep="/"),paste(out_path,filenames[x],sep="/"))
		}
}
jasenfinch/pubchemPIP documentation built on May 18, 2019, 4:52 p.m.