Browse code

Tighten up .isHDF5BackendBSseqUpdatable()

Peter Hickey authored on 14/10/2018 22:45:48
Showing4 changed files

... ...
@@ -1,5 +1,5 @@
1 1
 Package: bsseq
2
-Version: 1.17.4
2
+Version: 1.17.5
3 3
 Encoding: UTF-8
4 4
 Title: Analyze, manage and store bisulfite sequencing data
5 5
 Description: A collection of tools for analyzing and visualizing bisulfite
... ...
@@ -55,7 +55,8 @@ makeClusters <- function(hasGRanges, maxGap = 10^8) {
55 55
         M = unname(read_block(M, grid[[b]])),
56 56
         Cov = unname(read_block(Cov, grid[[b]])))
57 57
     # Ensure 0 < M < Cov to avoid boundary issues (only relevant at loci with
58
-    # non-zero coverage, so doesn't matter what M is for these loci).
58
+    # non-zero coverage, so doesn't matter what M is for loci with zero
59
+    # coverage).
59 60
     sdata[["M"]] <- pmin(pmax(sdata[["M"]], 0.01), pmax(sdata[["Cov"]] - 0.01))
60 61
     n_loci <- nrow(sdata)
61 62
     n_loci_with_non_zero_coverage <- sum(sdata[["Cov"]] > 0)
... ...
@@ -135,12 +135,13 @@ blockApplyWithRealization <- function(x, FUN, ..., sink = NULL, x_grid = NULL,
135 135
 #       can contain other files besides these; check.
136 136
 .isHDF5BackedBSseqUpdatable <- function(x) {
137 137
     stopifnot(is(x, "BSseq"))
138
-    if (!identical(.getBSseqBackends(x), "HDF5Array")) {
138
+    assay_class <- vapply(assays(x, withDimnames = FALSE), class, character(1L))
139
+    if (!all(assay_class == "HDF5Matrix")) {
139 140
         return(FALSE)
140 141
     }
141 142
     paths <- vapply(assays(x, withDimnames = FALSE), path, character(1L))
142
-    if (all(paths == paths[[1L]]) && all(basename(paths) == "assays.h5")) {
143
-        return(TRUE)
143
+    if (!all(paths == paths[[1L]]) || !all(basename(paths) == "assays.h5")) {
144
+        return(FALSE)
144 145
     }
145
-    FALSE
146
+    TRUE
146 147
 }
... ...
@@ -71,3 +71,4 @@ findLoci <- function(pattern, subject, include = seqlevels(subject),
71 71
 # TODO: Default value of seqlevels may not be working.
72 72
 # TODO: What happens if subject is a non-filepath character (e.g., "CATGCG") or
73 73
 #       a DNAString?
74
+# TODO: Allow passing of seqinfo and/or autogenerate?