[Rcolony-commits] r11 - pkg/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Apr 20 18:33:44 CEST 2009
Author: jonesor
Date: 2009-04-20 18:33:44 +0200 (Mon, 20 Apr 2009)
New Revision: 11
Modified:
pkg/R/monitor.colony.R
Log:
Totally rewrote the monitor.colony.R function so that it grabs the stdout files. Works for Unix/OS X ONLY at the moment.
Modified: pkg/R/monitor.colony.R
===================================================================
--- pkg/R/monitor.colony.R 2009-04-20 16:30:47 UTC (rev 10)
+++ pkg/R/monitor.colony.R 2009-04-20 16:33:44 UTC (rev 11)
@@ -1,44 +1,59 @@
-#Dynamic plotting experiments
+
monitor.colony<-function(datadir,interv.t=3,last.few=10){
- if(length(list.files(datadir,pattern=".Ne"))>0){stop("There are already files present in output directory. Remove them and start again.")}
+
+ # if(length(list.files(datadir,pattern=".Ne"))>0){stop("There are already files present in output directory. Remove them and start again.")}
+
+
+MidResult<-NULL
+
#Get start time
t1<-Sys.time()
elapsed.t<-0
- while(length(list.files(datadir,pattern=".Ne"))<1){#run forever
+
+ #while(length(list.files(datadir,pattern=".Ne"))<1){#run forever
+ while(TRUE){#run forever
+
t2<-Sys.time()
elapsed.t<-as.numeric(t2-t1)
if(elapsed.t>interv.t){
- fileok<-length(list.files(datadir,pattern=".MidResult"))>0
- col.names<-c("Date","Time","Run","Tmr","NumIterate","CrLogL","F1","F2","F3","FS","HSPair","FSPair","AssgnC1","AssgnC2","AssgnP1","AssgnP2")
+ fileok<-file.exists("temp.txt")
+if(fileok==TRUE&!is.na(get.interm.data(datadir=datadir)[1,1])){
+ MidResult2<-get.interm.data(datadir=datadir)
+ MidResult<-rbind(MidResult,MidResult2)
+ MidResult<-unique(MidResult)
+
+x<-MidResult[,1]
+y<-MidResult[,2]
- if(fileok==TRUE){
+plot(x,y,type="b",xlab="",ylab="")
+title(xlab="NumIterate",ylab="CrLogL")
+
+#add routine to delete contents if file is too big.
+#50lines?
+
+tmp<-readLines(paste(datadir,"temp.txt",sep=""))
+n<-50
+from<-if(length(tmp)-n>0){length(tmp)-n>0}else{1}
+to<-length(tmp)
+
+write.table(tmp[from:to],file="temp.txt",row.names=FALSE,col.names=FALSE,quote=FALSE)
+print(MidResult)
+cat("\n")
+
+ }else{cat("Waiting...\n")}
- paste(datadir,list.files(pattern=".MidResult")[1],sep="")
- MidResult<-read.table(paste(datadir,list.files(datadir,pattern=".MidResult")[1],sep=""),header=FALSE,col.names=col.names,skip=1)
- if(length(MidResult$NumIterate)<1){MidResult<-as.data.frame(matrix(rep(0,length(col.names)),ncol=length(col.names)))}
-
-
- }else{
-
- MidResult<-as.data.frame(matrix(rep(0,length(col.names)),ncol=length(col.names)))}
-
- names(MidResult)<-col.names
- x<-MidResult$NumIterate
- y<-MidResult$CrLogL
-
- plot(x,y,type="b",xlab="",ylab="")
- title(xlab="NumIterate",ylab="CrLogL")
- #legend("bottomright","Still Running...",text.col="red")
-
+
t1<-Sys.time()
- }
}
- }
\ No newline at end of file
+ }}
+
+
+
More information about the Rcolony-commits
mailing list