Friday, March 6, 2015

Download from BaseSpace using R

#under shell
sudo apt-get update
sudo apt-get install libcurl4-gnutls-dev
sudo R

#under R
source('http://bioconductor.org/biocLite.R')
biocLite('RCurl')
biocLite('BaseSpaceR')
quit()


#Start R again
library(BaseSpaceR)
ACCESS_TOKEN<- ''
PROJECT_ID<- '3289289'
aAuth<- AppAuth(access_token = ACCESS_TOKEN)
selProj <- Projects(aAuth, id = PROJECT_ID, simplify = TRUE) 
sampl <- listSamples(selProj, limit= 1000)
inSample <- Samples(aAuth, id = Id(sampl), simplify = TRUE)
for(s in inSample)
{
    f <- listFiles(s, Extensions = ".gz")
    print(Name(f))
    getFiles(aAuth, id= Id(f), destDir = 'fastq/', verbose = TRUE)
}
Reference: http://seqanswers.com/forums/showthread.php?t=47633