Skip to content

Commit

Permalink
Merge branch 'develop' into patch/nf-anno-utils
Browse files Browse the repository at this point in the history
  • Loading branch information
anngvu authored Nov 14, 2024
2 parents 667608d + 82157b5 commit 6134491
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 9 deletions.
3 changes: 1 addition & 2 deletions R/basic_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ dt_read <- function(file) {
bare_syn_id <- function(uri) {
not_na <- which(!is.na(uri))
x <- uri[not_na]
syn <- regmatches(x, regexpr("syn[0-9]{8,12}", x))
syn <- regmatches(x, regexpr("syn[0-9]{7,12}", x))
uri[not_na] <- syn
return(uri)
}
Expand All @@ -65,7 +65,6 @@ bare_syn_id <- function(uri) {
#' @keywords internal
is_valid_syn_id <- function(id) {
result <- grepl("^syn[0-9]{4,}$", id)
result
}

#' Walk through a directory
Expand Down
38 changes: 35 additions & 3 deletions R/new_project.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
#' @param institution Affiliated institution(s), **semicolon-sep if multiple**, e.g. "Stanford University; University of California, San Francisco".
#' @param funder The funding agency. The relevant funder team will be made admin.
#' @param initiative Title of funding initiative, e.g. "Young Investigator Award".
#' @param datasets (Optional) Datasets for which folders will be created under main data folder ("Raw Data").
#' @param datasets (Optional) List of datasets for which folders will be created under main data folder ("Raw Data").
#' Attributes set on the list items become annotations on the dataset folders.
#' @param other_resources (Optional) List of non-data resource types for which folders will be created.
#' Attributes set on the list items become annotations on these folders.
#' @param publicview Whether to put this project in the public view instead of staying private (registered or non-registered users can see project).
#' @param webview Whether to open web browser to view newly created project. Defaults to FALSE.
#' @param ... Additional arguments. Not used.
Expand All @@ -33,6 +36,7 @@ new_project <- function(name,
funder,
initiative,
datasets = NULL,
other_resources = NULL,
publicview = FALSE,
webview = FALSE,
...) {
Expand Down Expand Up @@ -73,13 +77,41 @@ new_project <- function(name,
}

# ASSETS ---------------------------------------------------------------------#

# Folder structure looks something like this,
# where * elements are conditionally present on data given:
#├── Analysis
#├── Milestone Reports
#├── Protocols*
#├── Raw Data
#│ ├── IHC dataset*
#│ └── RNA-seq dataset*
#└── Scripts*

# Note that all protocol files, etc. is expected to live in a single protocol folder and not further nested.

# Create default upper-level folders
folders <- add_default_folders(project)
data_folder <- folders[["Raw Data"]]
data_folder_id <- folders[["Raw Data"]]$properties$id

# Bind JSON schema so children folders have NF's dataset schemas, see
# https://repo-prod.prod.sagebase.org/repo/v1/schema/type/registered/org.synapse.nf-superdataset
# and https://help.synapse.org/docs/JSON-Schemas.3107291536.html
bind_schema_request <- jsonlite::toJSON(list(entityId = data_folder_id,
`schema$id` = "org.synapse.nf-superdataset",
enableDerivedAnnotations = TRUE),
auto_unbox = TRUE)
binding_uri <- glue::glue("https://repo-prod.prod.sagebase.org/repo/v1/entity/{data_folder_id}/schema/binding")
try(.syn$restPUT(binding_uri, bind_schema_request))

# Create data-specific folders in "Raw Data"
if(length(datasets)) {
make_folder(parent = data_folder$properties$id, folders = datasets)
make_folder(parent = data_folder_id, folders = datasets)
}

# Create homes for non-data resources alongside "Raw Data"
if(length(other_resources)) {
make_folder(parent = project, folders = other_resources)
}

# Add Project Files and Metadata fileview, add NF schema; currently doesn't add facets
Expand Down
7 changes: 5 additions & 2 deletions R/register_study.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ add_new_study_meta <- function(id, study_meta) {
"dataStatus",
"grantDOI",
"relatedStudies",
"studyFileviewId")]
"studyFileviewId",
"grantStartDate",
"grantEndDate",
"embargoEndDate")]

if(is.null(study_meta$studyStatus) || is.na(study_meta$studyStatus)) study_meta$studyStatus <- "Active"
if(is.null(study_meta$dataStatus) || is.na(study_meta$dataStatus)) study_meta$dataStatus <- "Data Pending"
Expand Down Expand Up @@ -95,7 +98,7 @@ add_study_summary <- function(study_id, summary, table_id = "syn16787123") {
BASE_URL <- "https://repo-prod.prod.sagebase.org/repo/v1"
url <- glue::glue("{BASE_URL}/entity/{table_id}/table/transaction/async/start")

studyId_col_model <- "82658"
studyId_col_model <- "82686"
summary_col_model <- "82091"

new_row <- list(etag = NULL,
Expand Down
2 changes: 1 addition & 1 deletion R/wiki_mod.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ data_curator_app_subpage <- function(project_id, dry_run = TRUE) {
subpage <- "NF Data Curator App"
# Default buttons and links
app_label <- "App"
app_url <- "https://shiny.synapse.org/users/rallaway/NF_data_curator"
app_url <- "https://dca.app.sagebionetworks.org/"
app_btn <- button_widget(label = app_label, url = app_url)

doc_label <- "Docs"
Expand Down
7 changes: 6 additions & 1 deletion man/new_project.Rd

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

0 comments on commit 6134491

Please sign in to comment.