-
Notifications
You must be signed in to change notification settings - Fork 3
/
metadata_find&fetch.R
26 lines (18 loc) · 1001 Bytes
/
metadata_find&fetch.R
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
library(ORFik)
library(data.table)
library(dplyr)
bioprojects <- ORFik::get_bioproject_candidates("(Ribosomal footprinting) OR (Ribosome footprinting) OR (Ribosome profiling) OR ribo-seq",add_study_title = TRUE)
processed_records <- system("ls SraRunInfo/", intern = TRUE) %>% sub("SraRunInfo_","",.) %>% sub(".csv","",.)
unprocessed <- bioprojects$id[!(bioprojects$id %in% processed_records)]
bioprojects$abstract <- ""
writeSRA <- function(candidate) {
print(candidate)
sra <- try(download.SRA.metadata(candidate, outdir = "SraRunInfo", rich.format = TRUE))
return(candidate)
}
rna_seq_meta <- lapply(unprocessed, function(x) writeSRA(x))
abstracts <- system("ls SraRunInfo/abstract_*", intern = TRUE)
abstracts <- sapply(abstracts, function(x) gsub("\"","",readLines(x)[[2]]), USE.NAMES = TRUE)
names(abstracts) <- names(abstracts) %>% sub(".*abstract_","",.) %>% sub(".csv","",.)
bioprojects[match(names(abstracts),id), abstract := abstracts]
fwrite(bioprojects, "bioprojects.csv")