-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgmql_init.R
executable file
·125 lines (119 loc) · 3.5 KB
/
gmql_init.R
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#' Init GMQL server
#'
#' It initializes and runs GMQL server for executing GMQL query.
#' It also performs a login to GMQL REST services suite, if needed
#'
#' @importFrom rJava J
#'
#' @param output_format string that identifies the output format of all sample
#' files. It can be TAB, GTF or COLLECT:
#' \itemize{
#' \item{TAB: tab-delimited file format}
#' \item{GTF: tab-delimited text standard format based on the General
#' Feature Format}
#' \item{COLLECT: used for storing output in memory (only in the case of local
#' processing, i.e., remote_processing = FALSE)}
#' }
#' @param remote_processing logical value specifying the processing mode.
#' True for processing on cluster (remote), false for local processing.
#'
#' @param url string url of server: It must contain the server address
#' and base url; service name is added automatically.
#' If NULL, no login is performed.
#' You can always perform it by calling the function \code{\link{login_gmql}}
#' explicitly
#'
#' @param username string name used during remote server signup
#' @param password string password used during remote server signup
#'
#' @return None
#'
#' @examples
#'
#' ## This statement initializes GMQL with local processing with sample files
#' ## output format as tab-delimited
#'
#' init_gmql("tab", FALSE)
#'
#' ## This statement initializes GMQL with remote processing
#'
#' remote_url = "http://www.gmql.eu/gmql-rest/"
#' init_gmql(remote_processing = TRUE, url = remote_url)
#'
#' @export
#'
init_gmql <- function(
output_format = "GTF",
remote_processing = FALSE,
url = NULL,
username = NULL,
password = NULL
) {
out_format <- toupper(output_format)
if(!out_format %in% c("TAB", "GTF", "COLLECT"))
stop("output_format: must be TAB, GTF or COLLECT")
.check_logical(remote_processing)
# mettere attesa da input keyboard, controllare se token già esiste
# da sessione precedente
if(!is.null(url) && !exists("GMQL_credentials", envir = .GlobalEnv))
login_gmql(url, username, password)
WrappeR <- J("it/polimi/genomics/r/Wrapper")
WrappeR$initGMQL(out_format,remote_processing)
}
#' Stop GMQL server
#'
#' It stops GMQL server processing
#'
#' @importFrom rJava J
#'
#' @return None
#'
#' @examples
#'
#' ## This statement first initializes GMQL with local processing and with
#' ## sample file output format as tab-delimited, and then stops it
#'
#' init_gmql("tab", FALSE)
#'
#' stop_gmql()
#'
#' @export
#'
stop_gmql <- function() {
WrappeR <- J("it/polimi/genomics/r/Wrapper")
WrappeR$stopGMQL()
}
#' Disable or Enable remote processing
#'
#' It allows to enable or disable remote processing
#'
#' @details
#' The invocation of this function allows to change mode of processing.
#' After invoking collect() function, it is not possbile to switch the
#' processing mode.
#'
#' @importFrom rJava J
#'
#' @param is_remote logical value used in order to set the processing mode.
#' TRUE: you set a remote query processing mode, otherwise it will be local
#'
#' @return None
#'
#' @examples
#'
#' ## This statement initializes GMQL with local processing with sample
#' ## files output format as tab-delimited, and then it changes processing
#' ## mode to remote
#'
#' init_gmql("tab", remote_processing = FALSE)
#'
#' remote_processing(TRUE)
#'
#' @export
#'
remote_processing <- function(is_remote) {
WrappeR <- J("it/polimi/genomics/r/Wrapper")
.check_logical(is_remote)
response <- WrappeR$remote_processing(is_remote)
print(response)
}