Skip to content

Instantly share code, notes, and snippets.

@katwre
Last active August 29, 2015 14:28
Show Gist options
  • Save katwre/897bae0c44e67baeda43 to your computer and use it in GitHub Desktop.
Save katwre/897bae0c44e67baeda43 to your computer and use it in GitHub Desktop.
destdir = "~/" #directory where fastq files will be stored
nmbr_of_cores = 20
SRAdb_path = '~/SRAmetadb.sqlite'
exp_ids=c("ERX620541")
require(SRAdb)
sqlfile <- SRAdb_path
if(!file.exists(SRAdb_path)) sqlfile <- getSRAdbFile()
sra_con <- dbConnect(SQLite(),sqlfile) #conection to SRA database
download = function(i, exp_ids=exp_ids, sra_con=sra_con, destdir=destdir){
sra = getSRA(exp_ids[i], out_types=c('sra','study','experiment','sample','run'), sra_con, acc_only=FALSE)
fas = getFASTQinfo( sra$run, sra_con, srcType = "ftp" )
filename <- basename(fas$ftp)
download.file(fas$ftp, paste(destdir, filename, sep=""))
}
require(parallel)
mclapply(1:length(exp_ids),
download,
exp_ids=exp_ids,
sra_con=sra_con,
destdir=destdir,
mc.cores=nmbr_of_cores)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment