2
2
# ' @export
3
3
# ' @include annotation_database_class.R BiocFileCache_database_helpers.R
4
4
# ' @family database
5
- BiocFileCache_database <- function (
6
- source ,
7
- bfc_path = NULL ,
8
- resource_name ,
9
- bfc_fun = .cache_as_is ,
10
- import_fun = read.csv ,
11
- offline = FALSE ,
12
- ... ) {
5
+ BiocFileCache_database <- function (source ,
6
+ bfc_path = NULL ,
7
+ resource_name ,
8
+ bfc_fun = .cache_as_is ,
9
+ import_fun = read.csv ,
10
+ offline = FALSE ,
11
+ ... ) {
13
12
# new object
14
13
out <- struct :: new_struct(
15
14
" BiocFileCache_database" ,
@@ -119,13 +118,13 @@ setMethod(
119
118
if (is.null(obj $ bfc_path )) {
120
119
obj $ bfc_path <- BiocFileCache :: getBFCOption(" CACHE" )
121
120
}
122
-
121
+
123
122
# get path
124
123
path <- .get_cached_path(obj )
125
-
124
+
126
125
# read
127
126
df <- obj $ import_fun(path )
128
-
127
+
129
128
# return
130
129
return (df )
131
130
}
@@ -144,7 +143,7 @@ setMethod(
144
143
query = obj $ source ,
145
144
field = " fpath" , exact = TRUE
146
145
)$ rid
147
-
146
+
148
147
# if not present, then add it
149
148
if (! length(rid )) {
150
149
rid <- names(
@@ -156,11 +155,12 @@ setMethod(
156
155
)
157
156
)
158
157
}
159
-
158
+
160
159
if (rid %in% BiocFileCache :: bfcquery(
161
160
bfc ,
162
- field = " rtype" ,
163
- query = " web" )$ rid ) {
161
+ field = " rtype" ,
162
+ query = " web"
163
+ )$ rid ) {
164
164
# TRUE if newly added or stale
165
165
update <- BiocFileCache :: bfcneedsupdate(bfc , rid )
166
166
if (is.na(update )) { # FALSE if NA
@@ -169,8 +169,8 @@ setMethod(
169
169
} else {
170
170
update <- FALSE # cant update if not web resource
171
171
}
172
-
173
-
172
+
173
+
174
174
# download & unzip
175
175
if (update & ! obj $ offline ) {
176
176
BiocFileCache :: bfcdownload(
@@ -181,9 +181,9 @@ setMethod(
181
181
verbose = FALSE
182
182
)
183
183
}
184
-
184
+
185
185
# get path
186
186
path <- BiocFileCache :: bfcrpath(bfc , rids = rid )
187
-
187
+
188
188
return (path )
189
189
}
0 commit comments