-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathread-tbl-classes.R
156 lines (127 loc) · 3.34 KB
/
read-tbl-classes.R
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# Reference table --------------------------------------------------------------
new_ref_tbl <- function(x) {
tibble::new_tibble(x, class = "ref_tbl")
}
#' @export
`[.ref_tbl` <- function(x, i, j, drop = FALSE) {
ref_tbl_reconstruct(NextMethod())
}
#' @export
`names<-.ref_tbl` <- function(x, value) {
ref_tbl_reconstruct(NextMethod())
}
#' @export
`$<-.ref_tbl` <- function(x, name, value) {
ref_tbl_reconstruct(NextMethod())
}
#' @importFrom tibble tbl_sum
#' @export
tbl_sum.ref_tbl <- function(x) {
orig <- NextMethod()
c("A reference table" = unname(orig))
}
# Alternate table --------------------------------------------------------------
new_alt_tbl <- function(x) {
tibble::new_tibble(x, class = "alt_tbl")
}
#' @export
`[.alt_tbl` <- function(x, i, j, drop = FALSE) {
alt_tbl_reconstruct(NextMethod())
}
#' @export
`names<-.alt_tbl` <- function(x, value) {
alt_tbl_reconstruct(NextMethod())
}
#' @export
`$<-.alt_tbl` <- function(x, name, value) {
alt_tbl_reconstruct(NextMethod())
}
#' @export
tbl_sum.alt_tbl <- function(x) {
orig <- NextMethod()
c("An alternate table" = unname(orig))
}
# Coverage table ---------------------------------------------------------------
new_cov_tbl <- function(x) {
tibble::new_tibble(x, class = "cov_tbl")
}
#' @export
`[.cov_tbl` <- function(x, i, j, drop = FALSE) {
cov_tbl_reconstruct(NextMethod())
}
#' @export
`names<-.cov_tbl` <- function(x, value) {
cov_tbl_reconstruct(NextMethod())
}
#' @export
`$<-.cov_tbl` <- function(x, name, value) {
cov_tbl_reconstruct(NextMethod())
}
#' @export
tbl_sum.cov_tbl <- function(x) {
orig <- NextMethod()
c("A coverage table" = unname(orig))
}
# Genotype table ---------------------------------------------------------------
new_geno_tbl <- function(x) {
tibble::new_tibble(x, class = "geno_tbl")
}
#' @export
`[.geno_tbl` <- function(x, i, j, drop = FALSE) {
geno_tbl_reconstruct(NextMethod())
}
#' @export
`names<-.geno_tbl` <- function(x, value) {
geno_tbl_reconstruct(NextMethod())
}
#' @export
`$<-.geno_tbl` <- function(x, name, value) {
geno_tbl_reconstruct(NextMethod())
}
#' @export
tbl_sum.geno_tbl <- function(x) {
orig <- NextMethod()
c("A genotype table" = unname(orig))
}
# Haplotype table --------------------------------------------------------------
new_hap_tbl <- function(x) {
tibble::new_tibble(x, class = "hap_tbl")
}
#' @export
`[.hap_tbl` <- function(x, i, j, drop = FALSE) {
hap_tbl_reconstruct(NextMethod())
}
#' @export
`names<-.hap_tbl` <- function(x, value) {
hap_tbl_reconstruct(NextMethod())
}
#' @export
`$<-.hap_tbl` <- function(x, name, value) {
hap_tbl_reconstruct(NextMethod())
}
#' @export
tbl_sum.hap_tbl <- function(x) {
orig <- NextMethod()
c("A haplotype table" = unname(orig))
}
# Reference, alternate, coverage table -----------------------------------------
new_ref_alt_cov_tbl <- function(x) {
tibble::new_tibble(x, class = "ref_alt_cov_tbl")
}
#' @export
`[.ref_alt_cov_tbl` <- function(x, i, j, drop = FALSE) {
ref_alt_cov_tbl_reconstruct(NextMethod())
}
#' @export
`names<-.ref_alt_cov_tbl` <- function(x, value) {
ref_alt_cov_tbl_reconstruct(NextMethod())
}
#' @export
`$<-.ref_alt_cov_tbl` <- function(x, name, value) {
ref_alt_cov_tbl_reconstruct(NextMethod())
}
#' @export
tbl_sum.ref_alt_cov_tbl <- function(x) {
orig <- NextMethod()
c("A ref alt cov table" = unname(orig))
}