library(gplots)
# options( warn = 1 )


dataTableTryptone <- read.table(paste('experimentalData','ecoliGrowthData_20120229_Tryptone_40min.txt', sep= .Platform$file.sep), sep='\t', header = TRUE)

postscript(paste('figureOutput',"figure3A.eps", sep= .Platform$file.sep), width = 3.25, height = 3.25, horizontal = FALSE, onefile = FALSE, paper = "special", pointsize = 8)
par( mar= (c(4, 4, 0, 0)+0.1) )

plot( dataTableTryptone$timeHour*60, dataTableTryptone$OD1, type = 'p', col = 'coral', pch = 4,
axes = FALSE, ylim = c(0,0.7) ,xlim = c(-15,40), ylab = 'Host E. coli Population (OD600)', xlab = 'Time From Infection (min)', cex = 1.5)
aveUnInfTryp <- (dataTableTryptone$OD1 + dataTableTryptone$OD2)/2
axis(1, at = seq(from = 0, to = 40, by = 10))
axis(2, at = seq(from = 0, to = 0.7, by = 0.1))
points( dataTableTryptone$timeHour*60, dataTableTryptone$OD2, type = 'p', col = 'coral'  , pch = 4 , cex = 1.5)
aveInfTryp <- (dataTableTryptone$OD3inf + dataTableTryptone$OD4inf + dataTableTryptone$OD5inf)/3
points( dataTableTryptone$timeHour*60, dataTableTryptone$OD3inf, type = 'p', col = 'coral3'  , pch = 1, cex = 1.5)
points( dataTableTryptone$timeHour*60, dataTableTryptone$OD4inf, type = 'p', col = 'coral3'  , pch = 1, cex = 1.5)
points( dataTableTryptone$timeHour*60, dataTableTryptone$OD5inf, type = 'p', col = 'coral3'  , pch = 1, cex = 1.5)
points( dataTableTryptone$timeHour*60, aveUnInfTryp, type = 'l', col = 'coral' , lty = 2)
points( dataTableTryptone$timeHour*60, aveInfTryp, type = 'l', col = 'coral3' )
labelsLegend = c('Uninfected','T7 MOI ~1/10')
legend(x=-15, y=0.7, legend=labelsLegend,  pch = c(4,1), lty = c( 2,1), col=c( 'coral' ,'coral3'), bty="n", pt.cex = c(1.5,1.5) )


# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

tLimInHours <- 20/60

dataTableRI <- read.table(paste('simulationsText','tryptoneInfectedSimulation.txt', sep= .Platform$file.sep), sep='\t', header = TRUE)
dataTableRI <- subset(dataTableRI, t<tLimInHours)
hostTableRI <- subset(dataTableRI, hostFlag ==1)


dataTableRI$t <- dataTableRI$t*60


postscript(paste('figureOutput',"figure3C.eps", sep= .Platform$file.sep), width = 6.3, height = 1.0, horizontal = FALSE, onefile = FALSE, paper = "special", pointsize = 8)
# note that this will be a 7 in wide figure, but need to add ylabel
layout( matrix( (1:7), byrow = TRUE, ncol = 7) )

par( mar= c(2, 2, 1, 0.25), pointsize = 8, cex = 1, cex.axis=1,cex.main=1,xpd = NA )

colorUse <- 'firebrick'

# rich

plot(dataTableRI$t,dataTableRI$CONCvMRNA1Ref, col = 'grey70' , lty = '11', type = 'l', lwd = 2.5,  axes = FALSE, xlab='Time From Infection (min)')
lines(dataTableRI$t,dataTableRI$CONCvMRNA1, col = colorUse )
title(main="mRNA Gene 1", font.main = 1 )
axis(1, at = seq(from = 0, to = 20, by = 5), label = c('0', NA,'10',NA,'20'))
axis(2)

plot(dataTableRI$t,dataTableRI$CONCvGP1Ref, col = 'grey70' , lty = '11', type = 'l', lwd = 2.5, bty='n',axes = FALSE,ylab = '')
lines(dataTableRI$t,dataTableRI$CONCvGP1, col = colorUse,ylab = '')
title(main="Gene Product 1", font.main = 1 )
axis(1, at = seq(from = 0, to = 20, by = 5), label = c('0', NA,'10',NA,'20'),xlab = NULL)
axis(2,ylab = '')

plot(dataTableRI$t,dataTableRI$CONCvMRNA10ARef, col = 'grey70' ,   bty='n' , lty = '11', type = 'l', lwd = 2.5,,ylim = c(0,130),axes = FALSE,ylab = '')
lines(dataTableRI$t,dataTableRI$CONCvMRNA10A, col = colorUse,ylab = '')
title(main="mRNA Gene 10A", font.main = 1 )
axis(1, at = seq(from = 0, to = 20, by = 5), label = c('0', NA,'10',NA,'20'),axes = FALSE)
axis(2,ylab = '')

plot(dataTableRI$t,dataTableRI$CONCvGP10ARef, col = 'grey70' , lty = '11', type = 'l', lwd = 2.5,   bty='n' ,axes = FALSE,ylab = '')
lines(dataTableRI$t,dataTableRI$CONCvGP10A, col = colorUse ,ylab = '')
title(main="Gene Product 10A", font.main = 1 )
axis(1, at = seq(from = 0, to = 20, by = 5), label = c('0', NA,'10',NA,'20'),axes = FALSE)
axis(2,ylab = '')

plot(dataTableRI$t,dataTableRI$CONCvPROCAPSIDRef, col = 'grey70' , lty = '11', type = 'l', lwd = 2.5,   bty='n' ,axes = FALSE,ylab = '')
lines(dataTableRI$t,dataTableRI$CONCvPROCAPSID, col = colorUse ,ylab = '')
title(main="Procapsid", font.main = 1 )
axis(1, at = seq(from = 0, to = 20, by = 5), label = c('0', NA,'10',NA,'20'),axes = FALSE)
axis(2,ylab = '')

plot(dataTableRI$t,dataTableRI$CONCvGENOMERef,  bty='n' , col = 'grey70' , lty = '11', type = 'l', lwd = 2.5 ,ylim = c(0,200),axes = FALSE,ylab = '')
lines(dataTableRI$t,dataTableRI$CONCvGENOME,col = colorUse,ylab = '')
title(main="T7 Genome", font.main = 1 )
axis(1, at = seq(from = 0, to = 20, by = 5), label = c('0', NA,'10',NA,'20'),axes = FALSE)
axis(2,ylab = '')

plot(dataTableRI$t,dataTableRI$CONCvT7Ref, col = 'grey70', lty = '11', type = 'l', lwd = 2.5,  bty='n' ,axes = FALSE,ylab = '')
lines(dataTableRI$t,dataTableRI$CONCvT7, col = colorUse,ylab = '' )
title(main="T7 Phage", font.main = 1 )
axis(1, at = seq(from = 0, to = 20, by = 5), label = c('0', NA,'10',NA,'20'),axes = FALSE)
axis(2,ylab = '')

dev.off()



# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -