improve wrapper.R to handle files too
[epclust.git] / code / stage1 / wrapper.R
1 ppam_exe = function(path=".", np=parallel::detectCores(), data=NULL, args="DontLetMeEmpty")
2 {
3 command_line = paste("mpirun -np ",np," ",path,"/ppam.exe cluster",sep="")
4
5 #if data provided (as data.frame or matrix...): binarize it, and add it as first argument
6 if (!is.null(data))
7 {
8 if (!is.character(data))
9 {
10 #assuming matrix or data.frame, WITH row names (identifiers; could be line number...)
11 write.csv(data, "/tmp/data_csv", row.names=TRUE, col.names=FALSE)
12 system(paste(path,"/ppam.exe serialize /tmp/data_csv /tmp/data_bin 0 0",sep=""))
13 } else
14 {
15 system(paste(path,"/ppam.exe serialize ",data," /tmp/data_bin 0 0",sep=""))
16 }
17 command_line = paste(command_line," /tmp/data_bin",sep="")
18 }
19
20 command_line = paste(command_line," ",args,sep="")
21 system(command_line)
22 }