... | ... |
@@ -4,8 +4,12 @@ |
4 | 4 |
# |
5 | 5 |
|
6 | 6 |
.getSeedClasses <- function(seed) { |
7 |
- if (is(seed, "SeedBinder") || is(seed, "ConformableSeedCombiner")) { |
|
8 |
- seeds <- seed@seeds |
|
7 |
+ if (is(seed, "DelayedOp")) { |
|
8 |
+ seeds <- try(seed@seeds, silent = TRUE) |
|
9 |
+ if (is(seeds, "try-error")) { |
|
10 |
+ seed <- seed@seed |
|
11 |
+ return(.getSeedClasses(seed)) |
|
12 |
+ } |
|
9 | 13 |
return(lapply(seeds, .getSeedClasses)) |
10 | 14 |
} else if (is(seed, "DelayedArray")) { |
11 | 15 |
# A DelayedArray can have another DelayedArray as a seed |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,42 @@ |
1 |
+#------------------------------------------------------------------------------- |
|
2 |
+# Is a DelayedMatrix object (or the assays of a SummarizedExperiment object) |
|
3 |
+# backed by a HDF5 file? |
|
4 |
+# |
|
5 |
+ |
|
6 |
+.getSeedClasses <- function(seed) { |
|
7 |
+ if (is(seed, "SeedBinder") || is(seed, "ConformableSeedCombiner")) { |
|
8 |
+ seeds <- seed@seeds |
|
9 |
+ return(lapply(seeds, .getSeedClasses)) |
|
10 |
+ } else if (is(seed, "DelayedArray")) { |
|
11 |
+ # A DelayedArray can have another DelayedArray as a seed |
|
12 |
+ seed <- seed@seed |
|
13 |
+ return(.getSeedClasses(seed)) |
|
14 |
+ } |
|
15 |
+ else { |
|
16 |
+ class(seed) |
|
17 |
+ } |
|
18 |
+} |
|
19 |
+ |
|
20 |
+# NOTE: Returns TRUE if *any* assay is HDF5Array-backed and FALSE if *all* |
|
21 |
+# assays are not HDF5Array-backed |
|
22 |
+.isHDF5ArrayBacked <- function(object) { |
|
23 |
+ if (is(object, "SummarizedExperiment")) { |
|
24 |
+ return(all(vapply(X = assays(object, withDimnames = FALSE), |
|
25 |
+ FUN = .isHDF5ArrayBacked, |
|
26 |
+ FUN.VALUE = logical(1L)))) |
|
27 |
+ } |
|
28 |
+ if (is(object, "DelayedArray")) { |
|
29 |
+ seed <- object@seed |
|
30 |
+ seed_classes <- .getSeedClasses(seed) |
|
31 |
+ is_hdf5_backed <- vapply(unlist(seed_classes, use.names = FALSE), |
|
32 |
+ extends, class2 = "HDF5ArraySeed", |
|
33 |
+ logical(1L)) |
|
34 |
+ return(any(is_hdf5_backed)) |
|
35 |
+ } else if (is.matrix(object)) { |
|
36 |
+ FALSE |
|
37 |
+ } else if (is.null(object)) { |
|
38 |
+ FALSE |
|
39 |
+ } else { |
|
40 |
+ stop("Don't know how to handle object of class ", class(object)) |
|
41 |
+ } |
|
42 |
+} |