File: ReshapedHDF5ArraySeed-class.R

package info (click to toggle)
r-bioc-hdf5array 1.34.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,736 kB
  • sloc: ansic: 5,815; makefile: 4
file content (75 lines) | stat: -rw-r--r-- 2,205 bytes parent folder | download
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
### =========================================================================
### ReshapedHDF5ArraySeed objects
### -------------------------------------------------------------------------


setClass("ReshapedHDF5ArraySeed",
    contains="HDF5ArraySeed",
    representation(
        reshaped_dim="integer",
        reshaped_chunkdim="integer_OR_NULL"
    )
)


### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Validity
###

### TODO


### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### dim() getter
###

### Does NOT access the file.
setMethod("dim", "ReshapedHDF5ArraySeed", function(x) x@reshaped_dim)


### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### extract_array()
###

.extract_array_from_ReshapedHDF5ArraySeed <- function(x, index)
{
    ans_dim <- S4Arrays:::get_Nindex_lengths(index, dim(x))
    h5mread_from_reshaped(path(x), x@name, x@reshaped_dim, starts=index)
}

setMethod("extract_array", "ReshapedHDF5ArraySeed",
    .extract_array_from_ReshapedHDF5ArraySeed
)


### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### chunkdim() getter
###

### Does NOT access the file.
setMethod("chunkdim", "ReshapedHDF5ArraySeed", function(x) x@reshaped_chunkdim)


### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Constructor
###

### Return a ReshapedHDF5ArraySeed object with NO dimnames!
### See HDF5ArraySeed() constructor in the HDF5ArraySeed-class.R file for more
### information about the dimnames issue.
ReshapedHDF5ArraySeed <- function(filepath, name, dim, type=NA)
{
    seed <- HDF5ArraySeed(filepath, name, type=type)
    reshaped_dim <- S4Arrays:::normarg_dim(dim)
    collapse_along <- find_dims_to_collapse(reshaped_dim, seed@dim)
    if (is.null(seed@chunkdim)) {
        reshaped_chunkdim <- NULL
    } else {
        reshaped_chunkdim <- collapse_dims(seed@chunkdim, collapse_along)
        reshaped_chunkdim <- as.integer(reshaped_chunkdim)
    }
    new2("ReshapedHDF5ArraySeed", seed,
                                  reshaped_dim=reshaped_dim,
                                  reshaped_chunkdim=reshaped_chunkdim)
}