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
|
### =========================================================================
### ExpandedVCF class methods
### =========================================================================
### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Constructor
###
### See VCF(..., collapsed=FALSE) in methods-VCF-class.R
### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Getters and Setters
###
### alt() setter
setReplaceMethod("alt", c("ExpandedVCF", "DNAStringSet"),
function(x, value)
{
if (length(value) != length(rowData(x)))
stop("length(value) must equal length(rowData(x))")
slot(x, "fixed")$ALT <- value
x
})
### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Utilities
###
VRangesForMatching <- function(x) {
with(rowData(x), VRanges(seqnames, IRanges(start, end), ref=REF, alt=ALT))
}
setMethod("match", c("ExpandedVCF", "ExpandedVCF"),
function(x, table, nomatch = NA_integer_, incomparables = NULL,
method = c("auto", "quick", "hash"))
{
x <- VRangesForMatching(x)
table <- VRangesForMatching(table)
callGeneric()
})
setMethod("match", c("ExpandedVCF", "VRanges"),
function(x, table, nomatch = NA_integer_, incomparables = NULL,
method = c("auto", "quick", "hash"))
{
x <- VRangesForMatching(x)
callGeneric()
})
setMethod("match", c("VRanges", "ExpandedVCF"),
function(x, table, nomatch = NA_integer_, incomparables = NULL,
method = c("auto", "quick", "hash"))
{
table <- VRangesForMatching(table)
callGeneric()
})
### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### isSNV family
###
.dispatchSNV_ExpandedVCF <- function(FUN, x)
{
if (is(alt <- alt(x), "character"))
stop("'alt' must be non-structural nucleotide values")
FUN(ref(x), alt)
}
setMethod("isSNV", "ExpandedVCF",
function(x, ...)
.dispatchSNV_ExpandedVCF(.isSNV, x)
)
setMethod("isInsertion", "ExpandedVCF",
function(x, ...)
.dispatchSNV_ExpandedVCF(.isInsertion, x)
)
setMethod("isDeletion", "ExpandedVCF",
function(x, ...)
.dispatchSNV_ExpandedVCF(.isDeletion, x)
)
setMethod("isIndel", "ExpandedVCF",
function(x, ...)
.dispatchSNV_ExpandedVCF(.isIndel, x)
)
setMethod("isTransition", "ExpandedVCF",
function(x, ...)
.dispatchSNV_ExpandedVCF(.isTransition, x)
)
setMethod("isSubstitution", "ExpandedVCF",
function(x, ...)
.dispatchSNV_ExpandedVCF(.isSubstitution, x)
)
### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### show
###
setMethod(show, "ExpandedVCF",
function(object)
{
.showVCFSubclass(object)
})
|