|
1 | | -guess.core.query <- function() |
2 | | -{ |
3 | | - guess.query.func(oligo:::getFidMetaProbesetCore) |
4 | | -} |
| 1 | +#guess.core.query <- function() |
| 2 | +#{ |
| 3 | +# guess.query.func(oligo:::getFidMetaProbesetCore) |
| 4 | +#} |
| 5 | +# |
| 6 | +#guess.probeset.query <- function() |
| 7 | +#{ |
| 8 | +# guess.query.func(oligo:::getFidProbeset) |
| 9 | +#} |
5 | 10 |
|
6 | | -guess.probeset.query <- function() |
| 11 | +guess.query.func <- function(object, target) |
7 | 12 | { |
8 | | - guess.query.func(oligo:::getFidProbeset) |
9 | | -} |
10 | | - |
11 | | -guess.query.func <- function(defined.function) |
12 | | -{ |
13 | | - core.func <- deparse(defined.function) |
14 | | - core.query <- core.func[grep("SELECT", core.func)] |
15 | | - if (length(core.query) != 1) |
| 13 | + if (target == "core") |
| 14 | + { |
| 15 | + use.func <- oligo:::getFidMetaProbesetCore |
| 16 | + }else |
| 17 | + { |
| 18 | + use.func <- oligo:::getFidProbeset |
| 19 | + } |
| 20 | + |
| 21 | + func.list <- as.list(body(use.func)) |
| 22 | + |
| 23 | + which.sql <- sapply(func.list, function(x) any(grep("SELECT", x))) |
| 24 | + |
| 25 | + if (sum(which.sql) != 1) |
16 | 26 | { |
17 | | - stop("ERROR: Guess at query failed, please supply valid SQL queries to the VariantMaskParams object") |
| 27 | + stop("ERROR: Guess at query failed--multiple possible queries found") |
18 | 28 | } |
19 | 29 |
|
20 | | - temp <- eval(parse(text=core.query)) |
| 30 | + sql.val <- eval(func.list[which.sql][[1]]) |
| 31 | + |
| 32 | + if (is.character(sql.val) == F || length(sql.val) != 1) |
| 33 | + { |
| 34 | + stop("ERROR: Guess at query failed--only one SQL query expected") |
| 35 | + } |
21 | 36 |
|
22 | | - return(temp) |
| 37 | + return(sql.val) |
23 | 38 | } |
24 | 39 |
|
25 | 40 | valid.VariantMaskParams <- function(object) |
@@ -53,9 +68,9 @@ valid.VariantMaskParams <- function(object) |
53 | 68 | return(TRUE) |
54 | 69 | } |
55 | 70 |
|
56 | | -setClass(Class="VariantMaskParams", representation=list(mask.type="character", geno.filter="logical", rm.unmap="logical", rm.mult="logical", core.query="character", |
57 | | - probeset.query="character", oligo.probe.id="character", var.db="VcfDB"), |
58 | | - prototype=prototype(mask.type="static", geno.filter=FALSE, rm.unmap=TRUE, rm.mult=TRUE, core.query=guess.core.query(), probeset.query=guess.probeset.query(), oligo.probe.id ="fid", var.db=new("VcfDB")), |
| 71 | +setClass(Class="VariantMaskParams", representation=list(mask.type="character", geno.filter="logical", rm.unmap="logical", rm.mult="logical", |
| 72 | + oligo.probe.id="character", var.db="VcfDB"), |
| 73 | + prototype=prototype(mask.type="static", geno.filter=FALSE, rm.unmap=TRUE, rm.mult=TRUE, oligo.probe.id ="fid", var.db=new("VcfDB")), |
59 | 74 | validity=valid.VariantMaskParams) |
60 | 75 |
|
61 | 76 | setMethod("show", signature("VariantMaskParams"), function(object) |
@@ -122,7 +137,7 @@ get.shortest.query.path <- function(var.mask.par, start=NULL, finish=NULL, rever |
122 | 137 | setGeneric("validProbeQuery", def=function(object,...) standardGeneric("validProbeQuery")) |
123 | 138 | setMethod("validProbeQuery", signature("VariantMaskParams"), function(object, target, should.add=TRUE, should.count=FALSE) |
124 | 139 | { |
125 | | - oligo.query <- switch(target, core=object@core.query, probeset=object@probeset.query) |
| 140 | + oligo.query <- guess.query.func(object, target) |
126 | 141 |
|
127 | 142 | var.presence <- "contains_var" |
128 | 143 | filter.presence <- "passes_filter" |
|
0 commit comments