-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfactorbookEncodeScrape.r
More file actions
27 lines (20 loc) · 986 Bytes
/
factorbookEncodeScrape.r
File metadata and controls
27 lines (20 loc) · 986 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
library(XML)
library(RCurl)
library(parallel)
dir.create("FactorBookMotifs")
fbFwdURL<-"http://compbio.mit.edu/encode-motifs/logos/table/logos/mat/fwd/"
fbRevURL<-"http://compbio.mit.edu/encode-motifs/logos/table/logos/mat/rev/"
fbFwd<-getURL("http://compbio.mit.edu/encode-motifs/logos/table/logos/mat/fwd/")
fbRev<-getURL("http://compbio.mit.edu/encode-motifs/logos/table/logos/mat/rev/")
fbFwd<-htmlParse(fbFwd)
fbRev<-htmlParse(fbRev)
matsFwd<-xpathSApply(fbFwd ,"//a/@href")
matsRev<-xpathSApply(fbFwd ,"//a/@href")
matsRev<-grep(".txt",matsRev,value=T)
matsFwd<-grep(".txt",matsFwd,value=T)
mclapply(matsFwd, mc.cores = 4,
function(x) download.file(paste0(fbFwdURL,x),quiet = T,
destfile =paste0("FactorBookMotifs/fwd_",x)))
mclapply(matsFwd, mc.cores = 4,
function(x) download.file(paste0(fbRevURL,x),quiet = T,
destfile =paste0("FactorBookMotifs/rev_",x)))