diff --git a/R/addReact.R b/R/addReact.R index c99b64caf4e061719f39edeb9dc112d0bd896fda..31a8c66d93b1e230ff5cfad7f88b0e497da948a5 100644 --- a/R/addReact.R +++ b/R/addReact.R @@ -54,9 +54,7 @@ addReact <- function(model, stop("needs an object of class modelorg!") } - if(!.hasSlot(model, "version")){ - validObject(model) - } + stopifnot(checkVersion(model)) if (length(met) != length(Scoef)) { stop("arguments 'met' and 'Scoef' must have the same length") diff --git a/R/geneDel.R b/R/geneDel.R index 874bb63b25c45afdb81f3a2b7c7864c53c733967..87811bb55e0474f12665dc6065d0a39c11a10845 100644 --- a/R/geneDel.R +++ b/R/geneDel.R @@ -41,9 +41,7 @@ geneDel <- function(model, genes, checkId = FALSE) { stop("needs an object of class modelorg!") } - if(!.hasSlot(model, "version")){ - validObject(model) - } + stopifnot(checkVersion(model)) if (isTRUE(checkId)) { if (is(genes, "character")) { @@ -99,9 +97,10 @@ geneDel <- function(model, genes, checkId = FALSE) { #print(reactInd) #x <- logical(length(allGenes(model))) - x <- rep(TRUE, length(allGenes(model))) + xAll <- rep(TRUE, length(allGenes(model))) #print(x) - x[geneInd] <- FALSE + xAll[geneInd] <- FALSE + names(xAll) <- allGenes(model) constReact <- logical(length(reactInd)) #print(constReact) @@ -112,10 +111,15 @@ geneDel <- function(model, genes, checkId = FALSE) { # If that's the case, the reaction needs gene bla. ru <- gprRules(model)[reactInd] + ge <- genes(model)[reactInd] for(i in 1:length(reactInd)) { #print(reactInd[i]) #print(ru[i]) #ev <- eval(parse(text = ru[i])) + + #define x for eval: + x <- xAll[ge[[i]]] + ev <- tryCatch(eval(parse(text = ru[i])), error = function(e) e) if (is(ev, "simpleError")) { stop("wrong gene association:", diff --git a/R/modelorgClass.R b/R/modelorgClass.R index 8f8343ad72c5e8e56772e43151c96e8615d0ba8a..d44d5489a14303b13bd60cbc264f5a08b1beec59 100644 --- a/R/modelorgClass.R +++ b/R/modelorgClass.R @@ -604,6 +604,7 @@ setMethod("optimizeProb", signature(object = "modelorg"), prCmd = NA, poCmd = NA, prCil = NA, poCil = NA, ...) { + stopifnot(checkVersion(object)) if (!is.null(gene)) { if (!is.null(react)) { @@ -1097,13 +1098,13 @@ setMethod("singletonMetabolites", signature(object = "modelorg"), setMethod("checkVersion", signature(object = "modelorg"), function(object) { if(!.hasSlot(object, "version")){ - stop("No version slot found. Please use upgradeModelorg on object") + return("No version slot found. Please use upgradeModelorg with object") } if(compareVersion(version(object), SYBIL_SETTINGS("MODELORG_VERSION")) == 0){ return(TRUE) } - stop(paste0("modelorg has version ", object(version), ", but you need at least version ", version)) + return(paste0("modelorg has version ", version(object), ", but you need at least version ", version)) } ) diff --git a/R/rmReact.R b/R/rmReact.R index 6e13204f342e6e07a36bf88107a8fdab6daeb5b7..45ab6ed9e8df8089510449bcf0ebc8d047b8c576 100644 --- a/R/rmReact.R +++ b/R/rmReact.R @@ -42,10 +42,8 @@ rmReact <- function(model, react, rm_met = TRUE) { stop("needs an object of class modelorg!") } - if(!.hasSlot(model, "version")){ - validObject(model) - } - + stopifnot(checkVersion(model)) + # check this, propably working wrong if (is.na(match(is(react)[1], c("reactId", "numeric", "integer", "character")))) { stop("argument react must be numeric, character, or of class reactId. Use checkReactId!") diff --git a/R/validmodelorg.R b/R/validmodelorg.R index 0be179668724efeca658e9e3f2856d708594229e..2aaee840fa48f230f3f41a35f9c2a14be6a076d3 100644 --- a/R/validmodelorg.R +++ b/R/validmodelorg.R @@ -38,13 +38,10 @@ return("needs an object of class modelorg!") } - if(compareVersion(version(object), SYBIL_SETTINGS("MODELORG_VERSION")) != 0){ - if(compareVersion(version(object), SYBIL_SETTINGS("MODELORG_VERSION")) == -1){ - return("You are using an old version of the modelorg-Class. Use upgradeModelorg to get a compatible object!") - } - if(compareVersion(version(object), SYBIL_SETTINGS("MODELORG_VERSION")) == 1){ - return("You are using a new version of the modelorg-Class. Plase upgrade your sybil package!") - } + versionCheck <- checkVersion(object) + + if(!isTRUE(versionCheck)){ + return(versionCheck) } if ((length(mod_id(object)) != 1) || (length(mod_name(object)) != 1)) { diff --git a/data/Ec_core.RData b/data/Ec_core.RData index 4030d203e277531c772fa49364dc271910625cde..ebf33613cc778356128bc432ac0ee3f02d95b12f 100644 Binary files a/data/Ec_core.RData and b/data/Ec_core.RData differ