Browse code

Merge pull request #65 from Bioconductor/bfc-from-df

add makeBiocFileCacheFromDataFrame example

lshep authored on 16/07/2025 16:51:49 • GitHub committed on 16/07/2025 16:51:49
Showing 2 changed files

... ...
@@ -27,6 +27,30 @@
27 27
 #' @param ask logical(1) Confirm creation of BiocFileCache.
28 28
 #'
29 29
 #' @return A BiocFileCache object
30
+#'
31
+#' @examples
32
+#' ## Create a data.frame with the required columns
33
+#' tempf <- tempfile(fileext = ".txt")
34
+#' file.create(tempf)
35
+#' df <- data.frame(
36
+#' rtype = "local",
37
+#' fpath = tempf,
38
+#' rpath = tempf,
39
+#' rname = "Example File 1",
40
+#' etag = "etag1",
41
+#' last_modified_time = as.character(Sys.Date()),
42
+#' expires = as.character(Sys.Date() + 1),
43
+#' stringsAsFactors = FALSE
44
+#' )
45
+#' ## Create a BiocFileCache from the data.frame
46
+#' bfc <- makeBiocFileCacheFromDataFrame(
47
+#' df, cache = tempfile(), actionLocal = "move",
48
+#' metadataName = "resourceMetadata", ask = FALSE
49
+#' )
50
+#' bfc
51
+#' bfcinfo(bfc)
52
+#' removebfc(bfc, ask = FALSE)
53
+#'
30 54
 #' @export
31 55
 setGeneric("makeBiocFileCacheFromDataFrame",
32 56
 function(df, cache,
... ...
@@ -62,3 +62,27 @@ columns. Similarly, the optional columns 'rname', 'etag',
62 62
 not listed as required or optional will be kept as an additional
63 63
 metadata table in the BiocFileCache database.
64 64
 }
65
+\examples{
66
+## Create a data.frame with the required columns
67
+tempf <- tempfile(fileext = ".txt")
68
+file.create(tempf)
69
+df <- data.frame(
70
+ rtype = "local",
71
+ fpath = tempf,
72
+ rpath = tempf,
73
+ rname = "Example File 1",
74
+ etag = "etag1",
75
+ last_modified_time = as.character(Sys.Date()),
76
+ expires = as.character(Sys.Date() + 1),
77
+ stringsAsFactors = FALSE
78
+)
79
+## Create a BiocFileCache from the data.frame
80
+bfc <- makeBiocFileCacheFromDataFrame(
81
+ df, cache = tempfile(), actionLocal = "move",
82
+ metadataName = "resourceMetadata", ask = FALSE
83
+)
84
+bfc
85
+bfcinfo(bfc)
86
+removebfc(bfc, ask = FALSE)
87
+
88
+}