[Rcolony-commits] r10 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Apr 20 18:30:48 CEST 2009


Author: jonesor
Date: 2009-04-20 18:30:47 +0200 (Mon, 20 Apr 2009)
New Revision: 10

Added:
   pkg/R/get.interm.data.R
Modified:
   pkg/R/run.colony.R
Log:
Added get.interm.data.R function.

Added: pkg/R/get.interm.data.R
===================================================================
--- pkg/R/get.interm.data.R	                        (rev 0)
+++ pkg/R/get.interm.data.R	2009-04-20 16:30:47 UTC (rev 10)
@@ -0,0 +1,26 @@
+get.interm.data<-function(v1="CrLogL",datadir){
+
+getval<-function(v1,xx){
+
+ind<-grep(paste(v1,"=",sep=""),xx)
+s1<-"[A-Za-z =0-9,]*"
+s2<-"[ ]*([-.+E0-9]+),[A-Z#a-z =0-9,]*"
+s3<-paste(s1,paste(v1,"=",sep=""),s2,sep="")
+x.out<-NULL
+
+for (i in 1:length(ind)){
+	x.out[i]<-as.numeric(sub(s3,"\\1",xx[ind][i]))
+	}
+
+return(x.out)}
+
+outfile<-readLines(paste(datadir,"temp.txt",sep=""))
+
+Itr<-getval("Itr",outfile)
+CrLogL<-getval(v1,outfile)
+chk<-c(length(Itr),length(CrLogL))
+
+df1<-data.frame(Itr=Itr[1:min(chk)],CrLogL=CrLogL[1:min(chk)])
+return(df1)
+}
+

Modified: pkg/R/run.colony.R
===================================================================
--- pkg/R/run.colony.R	2009-04-20 12:34:50 UTC (rev 9)
+++ pkg/R/run.colony.R	2009-04-20 16:30:47 UTC (rev 10)
@@ -1,14 +1,11 @@
 `run.colony` <-
-function(colonyexec="Colony2.exe",colonypath="/Users/ZSL/Documents/IoZ/Colony/",datadir="/Users/ZSL/Desktop/Test/",filename="Test1.DAT",wait=TRUE){
+function(colonyexec="Colony2.exe",colonypath="/Users/ZSL/Documents/IoZ/Colony/",datadir="/Users/ZSL/Desktop/Test/",filename="Test1.DAT",wait=TRUE,monitor=TRUE){
 	 #don't forget the trailing slash!
 	 
-	 cat("Be aware: this may take several minutes, hours, or even weeks to run, depending on the settings.")
+	 cat("Be aware: this may take several minutes, hours, or even weeks to run, depending on the settings.\n")
 	 
-	 
 	 current.wd<-getwd()
 	 
-	 #change this so that it copies the colony program to the directory, not the other way round.
-	 
 	 #Extract the output file name defined in the colony file.
 	 readLines(paste(datadir,filename,sep=""),n=2)->x
 	 outputfilename<-substring (x[2], 1, 20)
@@ -26,14 +23,14 @@
 	system(paste("cp",paste(colonypath,colonyexec,sep=""),datadir,sep=" "))
 	system(paste("mv",paste(datadir,filename,sep=""),paste(datadir,"Colony2.DAT",sep=""),sep=" "))
 
-system("./Colony2.exe 2>&1 | tee temp.txt",wait=wait)
+if(monitor==TRUE){system("./Colony2.exe 2>&1 | tee temp.txt",wait=wait)}else{system("./Colony2.exe",wait=wait)}
 
 	system(paste("mv",paste(datadir,"Colony2.DAT",sep=""),paste(datadir,filename,sep=""),sep=" "))
 	system("rm Colony2.exe")
 
-
-
-	 }else{if(platform$OS.type=="windows"){
+#Check whether Colony has finished, if it has delete this "temp.txt" file.
+#system("rm temp.txt",ignore.stderr=TRUE)
+}else{if(platform$OS.type=="windows"){
 	#Windows commands
 	shell(paste("copy",paste(colonypath,colonyexec,sep=""),datadir,sep=" "))#Copy the colony exe file to the project directory	
 	shell(paste("rename",paste(datadir,filename,sep=""),paste(datadir,"Colony2.DAT",sep=""),sep=" "))#Rename the colony dat file as Colony2.DAT	 



More information about the Rcolony-commits mailing list