Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pullProject() and saveProject() #48

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
10 changes: 6 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: pepr
Type: Package
Title: Reading Portable Encapsulated Projects
Version: 0.5.0
Date: 2023-11-16
Version: 0.6.0
Date: 2024-08-10
Authors@R: c(person("Nathan", "Sheffield", email = "nathan@code.databio.org",
role = c("aut", "cph","cre")),person("Michal","Stolarczyk",email="michal@virginia.edu",role=c("aut")))
Maintainer: Nathan Sheffield <nathan@code.databio.org>
Expand All @@ -18,7 +18,9 @@ Imports:
pryr,
data.table,
methods,
RCurl
RCurl,
tidyr,
httr
Suggests:
knitr,
testthat,
Expand All @@ -27,5 +29,5 @@ Suggests:
VignetteBuilder: knitr
License: BSD_2_clause + file LICENSE
BugReports: https://github.com/pepkit/pepr
RoxygenNote: 7.2.3
RoxygenNote: 7.3.2
Encoding: UTF-8
5 changes: 5 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,21 @@ export(getSample)
export(getSubsample)
export(listAmendments)
export(makeSectionsAbsolute)
export(pullProject)
export(sampleTable)
export(saveJWT)
export(saveProject)
exportClasses(Config)
exportClasses(Project)
exportMethods("$")
exportMethods("[")
exportMethods("[[")
import(RCurl)
import(httr)
import(pryr)
import(stringr)
import(yaml)
importFrom(methods,as)
importFrom(methods,callNextMethod)
importFrom(methods,is)
importFrom(tidyr,unnest)
11 changes: 8 additions & 3 deletions R/config.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ setMethod("initialize", "Config", function(.Object, data) {
#' @export
#' @rdname Config-class
Config = function(file, amendments = NULL) {
### if the config from the Project constructor is a list and not a filepath, it is from a PEP fetched from PEPhub
if (typeof(file) == 'list') {
config = methods::new("Config", data = file)
return(config)
}
message("Loading config file: ", file)
cfg_data = .loadConfig(filename = file, amendments = amendments)
config = methods::new("Config", data = cfg_data)
Expand Down Expand Up @@ -58,7 +63,7 @@ setMethod(
#' .expandList(x)
#' @export
#' @keywords internal
.expandList <- function(x) {
.expandList = function(x) {
if (is.list(x))
return(lapply(x, .expandList))
if (length(x) > 1)
Expand All @@ -81,7 +86,7 @@ setMethod(
#' .getSubscript(l, 1) == .getSubscript(l, "a")
#' @export
#' @keywords internal
.getSubscript <- function(lst, i) {
.getSubscript = function(lst, i) {
if (is.character(i))
return(grep(paste0("^", i, "$"), names(lst)))
return(i)
Expand Down Expand Up @@ -135,7 +140,7 @@ setMethod("[[", "Config", function(x, i) {
})


.DollarNames.Config <- function(x, pattern = "")
.DollarNames.Config = function(x, pattern = "")
grep(paste0("^", pattern), grep(names(x), value = TRUE))

#' @rdname select-config
Expand Down
3 changes: 2 additions & 1 deletion R/constants.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ CFG_DUPLICATE_KEY = "duplicate"
CFG_REMOVE_KEY = "remove"
CFG_LOOPER_KEY = "looper"
SAMPLE_NAME_ATTR = "sample_name"
SUBSAMPLE_NAME_ATTR = "subsample_name"
SUBSAMPLE_NAME_ATTR = "subsample_name"
BASE_URL = "https://pephub-api.databio.org/api/v1/"
2 changes: 2 additions & 0 deletions R/pepr.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#' @import yaml
#' @import stringr
#' @import pryr
#' @import httr
#' @importFrom tidyr unnest
#'
#' @references
#' GitHub: \url{https://github.com/pepkit/pepr}, Documentation: \url{https://code.databio.org/pepr/}
Expand Down
Loading
Loading