Skip to content
Snippets Groups Projects
Commit 7d3beb97 authored by Claus Jonathan Fritzemeier's avatar Claus Jonathan Fritzemeier
Browse files

findExchangeReact can now deal with bigger matrices

parent a76360cb
No related branches found
No related tags found
No related merge requests found
...@@ -45,11 +45,23 @@ findExchReact <- function(model) { ...@@ -45,11 +45,23 @@ findExchReact <- function(model) {
} }
# columns with only one entry # columns with only one entry
if(is(St, "Matrix")){
oneEntry <- colSums(St != 0)==1
}
else{
oneEntry <- apply(St, 2, function(x) sum(x != 0) == 1) oneEntry <- apply(St, 2, function(x) sum(x != 0) == 1)
}
if (sum(oneEntry) > 0) { if (sum(oneEntry) > 0) {
# exchange reactions -- with a -1 or 1 # exchange reactions -- with a -1 or 1
if(is(St, "Matrix")){
exchangeReact <- (colSums(St[ , oneEntry, drop = FALSE] == 1) == 1 | colSums(St[ , oneEntry, drop = FALSE]== -1) == 1)
}
else{
exchangeReact <- apply(St[ , oneEntry, drop = FALSE], 2, function(x) (sum(x == 1) == 1) | (sum(x == -1) == 1)) exchangeReact <- apply(St[ , oneEntry, drop = FALSE], 2, function(x) (sum(x == 1) == 1) | (sum(x == -1) == 1))
}
# vector with the reaction id's of the exchange reactions # vector with the reaction id's of the exchange reactions
ex <- c(1 : dim(St)[2])[oneEntry[exchangeReact]] ex <- c(1 : dim(St)[2])[oneEntry[exchangeReact]]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment