throw away old code, prepare tests
[epclust.git] / old_C_code / wrapper.R
diff --git a/old_C_code/wrapper.R b/old_C_code/wrapper.R
deleted file mode 100644 (file)
index d6d05e1..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-#Exemple :
-#
-#dans old_C_code/build :
-#cmake ../stage1/src
-#make
-#
-#dans data/, lancer R puis :
-#source("../old_C_code/wrapper.R")
-#serialize("../old_C_code/build", "2009.csv","2009.bin",1)
-#library(parallel)
-#np = detectCores()
-#nbSeriesPerChunk = 3000
-#nbClusters = 20
-#ppam_exe("../old_C_code/build",np,"2009.bin",nbSeriesPerChunk,nbClusters)
-#C = getMedoids("../old_C_code/build", "ppamResult.xml", "ppamFinalSeries.bin")
-#first100series = deserialize("../old_C_code/build", "2009.bin", "2009.csv.part", "1-100")
-#distor = getDistor("../old_C_code/build", "ppamResult.xml", "2009.bin")
-
-ppam_exe = function(path=".", np=parallel::detectCores(), data=NULL,
-       nbSeriesPerChunk, nbClusters, randomize=1, p_dissims=2)
-{
-       args = paste(nbSeriesPerChunk," ",nbClusters," ",randomize," ",p_dissims,sep="")
-
-       command_line = paste("mpirun -np ",np," ",path,"/ppam.exe cluster",sep="")
-
-       #if data provided (as data.frame or matrix...): binarize it, and add it as first argument
-       if (!is.null(data))
-       {
-               if (!is.character(data))
-               {
-                       #assuming matrix or data.frame, WITH row names
-                       #( identifiers; could be line number... e.g. data <- cbind(1:nrow(data),data) )
-                       write.table(data, "/tmp/data_csv", sep=",", row.names=FALSE, col.names=FALSE)
-                       system(paste(path,"/ppam.exe serialize /tmp/data_csv /tmp/data_bin 0 0",sep=""))
-               } else
-               {
-                       system(paste(path,"/ppam.exe serialize ",data," /tmp/data_bin 0 0",sep=""))
-               }
-               command_line = paste(command_line," /tmp/data_bin",sep="")
-       }
-
-       command_line = paste(command_line," ",args,sep="")
-       system(command_line)
-}
-
-#NOTE: identifiers in first column
-getMedoids = function(path=".", xmlResult = "ppamResult.xml",
-       finalSeries = "ppamFinalSeries.bin")
-{
-       system(paste(path,"/ppam.exe deserialize ",finalSeries," ppamFinalSeries.csv -1",sep=""))
-       curves = read.table("ppamFinalSeries.csv", sep=",")
-       library(XML)
-       ranks = as.integer( xmlToList( xmlParse(xmlResult) )$ranks )
-       return ( curves[ranks,] ) # == medoids
-}
-
-getDistor = function(path=".", xmlResult = "ppamResult.xml",
-       finalSeries = "ppamFinalSeries.bin")
-{
-       system(paste(path,"/ppam.exe classif ",finalSeries," ",xmlResult,sep=""))
-}
-
-serialize = function(path=".", csvSeries, binSeries, byCols=0, nbSeries=0)
-{
-       system(paste(path,"/ppam.exe serialize ",csvSeries," ",binSeries," ",byCols," ",nbSeries,
-               sep=""))
-}
-
-deserialize = function(path=".", binSeries, csvSeries, ranks="-1", return=TRUE)
-{
-       system(paste(path,"/ppam.exe deserialize ",binSeries," ",csvSeries," ",ranks,sep=""))
-       if (return)
-               return ( read.table(csvSeries, sep=",") )
-}