Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions R/2025-10-27_JF_R_Galaxy_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -953,52 +953,59 @@ galaxy_history_size <- function(history_id,
#' \dontrun{
#' galaxy_set_credentials(
#' api_key = "your-secret-key",
#' galaxy_url = "https://usegalaxy.eu",
#' username = "your-username",
#' password = "your-password"
#' password = "your-password",
#' galaxy_url = "https://usegalaxy.eu"
#' )
#' }
#'
#' @export
galaxy_set_credentials <- function(api_key = NULL,
galaxy_url = NULL,
username = NULL,
password = NULL,
overwrite = TRUE) {
username = NULL,
password = NULL,
galaxy_url = "https://usegalaxy.eu",
overwrite = TRUE) {

# rename inputs
values <- list(
GALAXY_API_KEY = api_key,
GALAXY_URL = galaxy_url,
GALAXY_USERNAME = username,
GALAXY_PASSWORD = password
)

if(galaxy_has_key() & overwrite) {
# replace previous key
if (galaxy_has_key() & overwrite) {
warning("There was already an API key set which will be overwritten")
}

# loop over inputs
set_values <- list()

for (name in names(values)) {
value <- values[[name]]

# skip empty values
if (is.null(value)) {
next
}

# stop at empty strings
if (!nzchar(value)) {
stop(name, " must be a non-empty string.")
}

# check whether environmental variable is set already
existing <- Sys.getenv(name, unset = NA_character_)
if (!isTRUE(overwrite) && !is.na(existing) && nzchar(existing)) {
stop(name, " already set; use overwrite = TRUE to replace.")
}

Sys.setenv(structure(value, names = name))
# sets variable
do.call(Sys.setenv, as.list(structure(value, names = name)))
set_values[[name]] <- value
}

# returns list of set variables
invisible(set_values)
}

Expand Down
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# GalaxyRTools
# GalaxyR

**GalaxyRTools** is an R package for programmatic interaction with the **Galaxy API** (tested primarily against [Galaxy Europe](https://usegalaxy.eu)).
**GalaxyR** is an R package for programmatic interaction with the **Galaxy API** (tested primarily against [Galaxy Europe](https://usegalaxy.eu)).
It allows you to manage histories, upload data, run tools and workflows, wait for jobs to complete, and download results — all directly from R.

This package is designed for **automation, reproducibility, and scripting**, not UI replacement.
Expand Down Expand Up @@ -42,12 +42,13 @@ You can either:

### Option 1: Set it once per session
```r
galaxy_set_api_key("YOUR_GALAXY_API_KEY")
galaxy_set_credentials("your-secret-key")
```

### Option 2: Add it to `~/.Renviron` (recommended)
```
GALAXY_API_KEY=your-secret-key
#usethis::edit_r_environ()
GALAXY_API_KEY = your-secret-key
```

Restart R after editing `.Renviron`.
Expand Down Expand Up @@ -102,7 +103,7 @@ job_id <- galaxy_run_tool(
text_input = "added text",
infile = list(
src = "hda",
id = file_id$id
id = file_id
),
options = "header" # add text at the top of the file
)
Expand Down Expand Up @@ -178,8 +179,8 @@ Terminal states:

---

Author:
Julian Frey
Chair of Forest Growth and Dendroecology
Author:<br>
Julian Frey<br>
Chair of Forest Growth and Dendroecology<br>
University of Freiburg

10 changes: 10 additions & 0 deletions inst/CITATION
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
citHeader("To cite GalaxyR in publications use:")

citEntry(
entry = "misc",
title = "GalaxyR",
author = "Julian Frey",
year = "2026",
url = "https://github.com/JulFrey/GalaxyR",
textVersion = "Frey, J. (2026) GalaxyR. https://github.com/JulFrey/GalaxyR"
)
12 changes: 6 additions & 6 deletions man/galaxy_set_credentials.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.