-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpmetrics.rscript
executable file
·100 lines (86 loc) · 2.88 KB
/
pmetrics.rscript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env Rscript
#sabryr 2020-02-14
# This script is not supposed to be used directly,
# and should be invoked from pmetrics.sh
args <- commandArgs(trailingOnly = TRUE)
r <- getOption("repos")
r["CRAN"] <- "http://cran.r-project.org"
options(repos=r)
Sys.setenv(R_INSTALL_STAGED = FALSE)
valmap <- list()
valmap$auto <- TRUE
valmap$include <- FALSE
valmap$exclude <- FALSE
valmap$indpts <- FALSE
valmap$salt <- FALSE
valmap$intern <- FALSE
valmap$silent <- FALSE
valmap$overwrite <- FALSE
valmap$nocheck <- FALSE
valmap$alq <- FALSE
valmap$remote <- FALSE
valmap$run <- FALSE
valmap$aucint <- FALSE
valmap$prior <- FALSE
valmap$cycles <- 100
valmap$ode <- -4
valmap$tol <- 0.01
valmap$idelta <- 12
valmap$parallel <- NA
valmap$model <- "model.txt"
valmap$data <- "data.csv"
valmap$icen <- "median"
valmap$server_address <- NULL
if (length(args)>=8) {
loc = args[1]
dataset_file = args[2]
model_file = args[3]
mycycles = args[4]
myindpts = args[5]
parallel = args[6]
data_file_new_name = args[7]#"data.csv"
model_file_new_name = args[8] #"model.txt"
if (length(args)>=10) {
valmap$ode <- args[9]
valmap$tol <- args[10]
}
if (!suppressWarnings(require("Pmetrics"))){
devtools::install_github("Sabryr/Pmetrics", ref = "debug", upgrade = FALSE)
library(Pmetrics)
PMbuild()
}
print("Paths")
print(.libPaths())
library(Pmetrics)
fortranloc <- paste(trimws(Sys.getenv("HOME")),".config/Pmetrics/compiledFortran", sep = "/")
#print(fortranloc)
#if(!file.exists(fortranloc)){
# PMbuild()
#}
setwd(loc)
print(paste("Current working directory", getwd(), sep = " : "))
#file.copy(from=c(model_file, dataset_file), to=getwd(), overwrite=T)
file.copy(from=model_file, to=getwd(), overwrite=T)
file.copy(from=dataset_file, to=getwd(), overwrite=T)
print(paste("model_file was ", model_file, " now "))
print(list.files(pattern="*txt"))
print(paste("dataset_file ",dataset_file, " now "))
print(list.files(pattern="*csv"))
#if(!file.exists(model_file_new_name)){
# print("Safe, No model.txt found , renaming ")
file.rename(basename(model_file), model_file_new_name)
print(paste(basename(model_file), " renamed to ", model_file_new_name))
#}
#if(!file.exists(data_file_new_name)){
#print("No model.txt")
file.rename(basename(dataset_file), data_file_new_name )
print(paste(basename(dataset_file), " renamed to ", data_file_new_name))
#}
#print(paste(" model_file_new_name ", model_file_new_name, sep = " : "))
#print(paste(" data_file_new_name ", data_file_new_name, sep = " : "))
#print(paste("Files in ", getwd(), list.files(), sep = " : "))
print(paste("ode =", valmap$ode, " tol = ",valmap$tol))
NPrun(model = model_file_new_name, data = data_file_new_name, cycles = mycycles, indpts = myindpts , overwrite = T, parallel = TRUE , ode = valmap$ode, tol = valmap$tol )
}else{
stop("Needs 8 arguments", call.=FALSE)
}