/
loadNcbiTax.R
29 lines (28 loc) · 922 Bytes
/
loadNcbiTax.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
27
28
29
#' Feeding BED: Load taxonomic information from NCBI
#'
#' Not exported to avoid unintended modifications of the DB.
#'
#' @param reDumpThr time difference threshold between 2 downloads
#' @param ddir path to the directory where the data should be saved
#' @param orgOfInt organisms of interest: a character vector
#' @param curDate current date as given by [Sys.Date]
#'
loadNcbiTax <- function(
reDumpThr,
ddir,
orgOfInt=c("human", "rat", "mouse"),
curDate
){
names.dmp <- NULL
dumpNcbiTax(
reDumpThr=reDumpThr, ddir=ddir, toDump="names.dmp", curDate=curDate
)
taxNames <- names.dmp[,-seq(2, 8, by=2)]
colnames(taxNames) <- c(
"tax_id", "name_txt", "unique_name", "name_class"
)
###############################
toLoad <- unique(taxNames$tax_id[which(taxNames$name_txt %in% orgOfInt)])
toLoad <- taxNames[which(taxNames$tax_id %in% toLoad),]
loadOrganisms(toLoad)
}