-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_rhs.r
36 lines (31 loc) · 1.02 KB
/
check_rhs.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
##jmd
##6.14.2011
##check_rhs.r
library('Matrix')
library('Rcplex')
options(stringsAsFactors=FALSE)
setwd('/msc/neurospora/FBA/farm_data')
source('../farm/fba.r')
##made sparse format biomass_s.txt using make_biomass.r
##created sparse format transport rxns (import Vogel's media) in excel
##read
print("Checking growth on Vogels with Sv>=0")
bm <- read.delim('biomass_s.txt')
vogel <- read.delim('vogel_trans_s.txt')
s0 <- read.delim('s15.txt', as.is=FALSE, na='NIL')
s.sp <- sparseMatrix(i=as.numeric(s0$compound), j=as.numeric(s0$rxn), x=as.real(s0$coeff))
dimnames(s.sp) <- list(levels(s0$compound), levels(s0$rxn))
nmets <- nrow(s.sp); nrxns <- ncol(s.sp)
#code uses s as s.sp
s <- s.sp
##fba
fba.ub <- rep(10^3, nrxns); names(fba.ub) <- colnames(s.sp)
c.rxns <- c('SUCROSE-TRANS-RXN-L2R','CIT-TRANS-RXN-L2R', 'PROTON-TRANS-RXN-L2R')
fba.ub[vogel$rxn] <- 0
#fba.ub[c.rxns] <- 1000
fba.lp <- FBA(a=s.sp)
v <- fba.lp$xopt; names(v) <- names(fba.ub)
##get rhs
rhs <- (s.sp %*% v)[,1]
names(rhs) <- rownames(s.sp)
rhs.pos <- rhs[rhs>0]