diff --git a/DESCRIPTION b/DESCRIPTION index 5f867f03..c6a1bea2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -6,7 +6,7 @@ Authors: Rongrong Chai, Xengie Doan, Milen Nikolov, Sujay Patil, Robert Allaway, License: file LICENSE Encoding: UTF-8 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 Imports: httr, dplyr, jsonlite, shinyjs, yaml, promises, readr Suggests: covr diff --git a/R/schematic_rest_api.R b/R/schematic_rest_api.R index 1e1546c2..caf8c051 100644 --- a/R/schematic_rest_api.R +++ b/R/schematic_rest_api.R @@ -221,8 +221,18 @@ manifest_validate <- function(url="http://localhost:3001/v1/model/validate", #' @param schema_url URL to a schema jsonld #' @param data_type Type of dataset #' @param dataset_id Synapse ID of existing manifest -#' @param access_token Synapse login cookie, PAT, or API key. -#' @param csv_file Filepath of csv to validate +#' @param restrict_rules Default = FALSE +#' @param access_token Synapse login cookie, PAT, or API key +#' @param json_str Json string to submit +#' @param asset_view Synapse fileview +#' @param manifest_record_type Default = "table_and_file" +#' @param file_name Name of file +#' @param table_manipulation Default = "replace" +#' @param hide_blanks Default = FALSE +#' @param table_column_names Default = "class_and_label" +#' @param annotation_keys Default = "class_and_label" +#' @param data_model_labels Default = "class_and_label" +#' @param upload_file_annotations Default = TRUE #' #' @returns TRUE if successful upload or validate errors if not. #' @export @@ -240,7 +250,8 @@ model_submit <- function(url="http://localhost:3001/v1/model/submit", hide_blanks=FALSE, table_column_names="class_label", annotation_keys="class_label", - data_model_labels="class_label") { + data_model_labels="class_label", + file_annotations_upload=TRUE) { req <- httr::POST(url, httr::add_headers(Authorization = sprintf("Bearer %s", access_token)), query=list( @@ -255,7 +266,8 @@ model_submit <- function(url="http://localhost:3001/v1/model/submit", table_column_names=table_column_names, annotation_keys=annotation_keys, data_model_labels=data_model_labels, - hide_blanks=hide_blanks), + hide_blanks=hide_blanks, + file_annotations_upload=file_annotations_upload), body=list(file_name=httr::upload_file(file_name)) #body=list(file_name=file_name) ) diff --git a/man/get_asset_view_table.Rd b/man/get_asset_view_table.Rd index 2abe1d0f..a2bf1037 100644 --- a/man/get_asset_view_table.Rd +++ b/man/get_asset_view_table.Rd @@ -6,7 +6,7 @@ \usage{ get_asset_view_table( url = "http://localhost:3001/v1/storage/assets/tables", - input_token, + access_token, asset_view, return_type = "json" ) @@ -14,7 +14,7 @@ get_asset_view_table( \arguments{ \item{url}{URL to schematic API endpoint} -\item{input_token}{synapse PAT} +\item{access_token}{synapse PAT} \item{asset_view}{Synapse ID of asset view} } diff --git a/man/get_synapse_table_names.Rd b/man/get_synapse_table_names.Rd new file mode 100644 index 00000000..5f3770d9 --- /dev/null +++ b/man/get_synapse_table_names.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/synapse_rest_api.R +\name{get_synapse_table_names} +\alias{get_synapse_table_names} +\title{Get column names from a Synapse table +https://rest-docs.synapse.org/rest/GET/entity/id/table/query/async/get/asyncToken.html +Uses a table query to get the column names from a Synapse table} +\usage{ +get_synapse_table_names(id, auth) +} +\arguments{ +\item{id}{Synapse ID of table} + +\item{auth}{Synapse token} +} +\description{ +Get column names from a Synapse table +https://rest-docs.synapse.org/rest/GET/entity/id/table/query/async/get/asyncToken.html +Uses a table query to get the column names from a Synapse table +} diff --git a/man/manifest_generate.Rd b/man/manifest_generate.Rd index 4af1fc37..ba9d0099 100644 --- a/man/manifest_generate.Rd +++ b/man/manifest_generate.Rd @@ -6,15 +6,16 @@ \usage{ manifest_generate( url = "http://localhost:3001/v1/manifest/generate", - schema_url = - "https://raw.githubusercontent.com/ncihtan/data-models/main/HTAN.model.jsonld", + schema_url, title, data_type, - oauth = "true", use_annotations = "false", dataset_id = NULL, asset_view, - output_format + output_format, + access_token = NULL, + strict_validation = FALSE, + data_model_labels = "class_label" ) } \arguments{ @@ -22,11 +23,11 @@ manifest_generate( \item{data_type}{Type of dataset} -\item{oauth}{true or false STRING passed to python} - \item{use_annotations}{true or false STRING passed to python} \item{dataset_id}{Synapse ID of existing manifest} + +\item{oauth}{true or false STRING passed to python} } \value{ a URL to a google sheet diff --git a/man/manifest_populate.Rd b/man/manifest_populate.Rd index 59bfe157..2259feb1 100644 --- a/man/manifest_populate.Rd +++ b/man/manifest_populate.Rd @@ -6,10 +6,11 @@ \usage{ manifest_populate( url = "http://localhost:3001/v1/manifest/populate", - schema_url = - "https://raw.githubusercontent.com/ncihtan/data-models/main/HTAN.model.jsonld", + schema_url, data_type, title, + return_excel = FALSE, + data_model_labels = "class_label", csv_file ) } diff --git a/man/manifest_validate.Rd b/man/manifest_validate.Rd index 482b6e7d..bef15d38 100644 --- a/man/manifest_validate.Rd +++ b/man/manifest_validate.Rd @@ -6,10 +6,14 @@ \usage{ manifest_validate( url = "http://localhost:3001/v1/model/validate", - schema_url = - "https://raw.githubusercontent.com/ncihtan/data-models/main/HTAN.model.jsonld", + schema_url, data_type, - json_str + file_name, + restrict_rules = FALSE, + project_scope = NULL, + access_token, + asset_view = NULL, + data_model_labels = "class_label" ) } \arguments{ @@ -19,7 +23,7 @@ manifest_validate( \item{data_type}{Type of dataset} -\item{csv_file}{Filepath of csv to validate} +\item{file_name}{Filepath of csv to validate} } \value{ An empty list() if sucessfully validated. Or a list of errors. diff --git a/man/model_component_requirements.Rd b/man/model_component_requirements.Rd index 6d66d91b..7b80b159 100644 --- a/man/model_component_requirements.Rd +++ b/man/model_component_requirements.Rd @@ -8,7 +8,8 @@ model_component_requirements( url = "http://localhost:3001/v1/model/component-requirements", schema_url, source_component, - as_graph = FALSE + as_graph = FALSE, + data_model_labels = "class_label" ) } \arguments{ diff --git a/man/model_submit.Rd b/man/model_submit.Rd index b049e6cf..572e7475 100644 --- a/man/model_submit.Rd +++ b/man/model_submit.Rd @@ -6,14 +6,21 @@ \usage{ model_submit( url = "http://localhost:3001/v1/model/submit", - schema_url = - "https://raw.githubusercontent.com/ncihtan/data-models/main/HTAN.model.jsonld", + schema_url, data_type, dataset_id, restrict_rules = FALSE, - input_token, - json_str, - asset_view + access_token, + json_str = NULL, + asset_view, + manifest_record_type = "table_and_file", + file_name, + table_manipulation = "replace", + hide_blanks = FALSE, + table_column_names = "class_label", + annotation_keys = "class_label", + data_model_labels = "class_label", + file_annotations_upload = TRUE ) } \arguments{ @@ -25,9 +32,29 @@ model_submit( \item{dataset_id}{Synapse ID of existing manifest} -\item{input_token}{Synapse login cookie, PAT, or API key.} +\item{restrict_rules}{Default = FALSE} -\item{csv_file}{Filepath of csv to validate} +\item{access_token}{Synapse login cookie, PAT, or API key} + +\item{json_str}{Json string to submit} + +\item{asset_view}{Synapse fileview} + +\item{manifest_record_type}{Default = "table_and_file"} + +\item{file_name}{Name of file} + +\item{table_manipulation}{Default = "replace"} + +\item{hide_blanks}{Default = FALSE} + +\item{table_column_names}{Default = "class_and_label"} + +\item{annotation_keys}{Default = "class_and_label"} + +\item{data_model_labels}{Default = "class_and_label"} + +\item{upload_file_annotations}{Default = TRUE} } \value{ TRUE if successful upload or validate errors if not. diff --git a/man/storage_dataset_files.Rd b/man/storage_dataset_files.Rd index c09e5d46..6037a77d 100644 --- a/man/storage_dataset_files.Rd +++ b/man/storage_dataset_files.Rd @@ -10,7 +10,7 @@ storage_dataset_files( dataset_id, file_names = list(), full_path = FALSE, - input_token + access_token ) } \arguments{ @@ -22,7 +22,7 @@ storage_dataset_files( \item{full_path}{Boolean. If True return the full path as part of this filename; otherwise return just base filename} -\item{input_token}{synapse PAT} +\item{access_token}{synapse PAT} \item{syn_master_file_view}{synapse ID of master file view.} diff --git a/man/storage_project_datasets.Rd b/man/storage_project_datasets.Rd index 1093cbc9..efc7427a 100644 --- a/man/storage_project_datasets.Rd +++ b/man/storage_project_datasets.Rd @@ -8,7 +8,7 @@ storage_project_datasets( url = "http://localhost:3001/v1/storage/project/datasets", asset_view, project_id, - input_token + access_token ) } \arguments{ @@ -16,7 +16,7 @@ storage_project_datasets( \item{project_id}{synapse ID of a storage project.} -\item{input_token}{synapse PAT} +\item{access_token}{synapse PAT} \item{syn_master_file_view}{synapse ID of master file view.} diff --git a/man/storage_projects.Rd b/man/storage_projects.Rd index f10d1f8f..c52dc300 100644 --- a/man/storage_projects.Rd +++ b/man/storage_projects.Rd @@ -7,13 +7,13 @@ storage_projects( url = "http://localhost:3001/v1/storage/projects", asset_view, - input_token + access_token ) } \arguments{ \item{url}{URL to schematic API endpoint} -\item{input_token}{synapse PAT} +\item{access_token}{synapse PAT} \item{syn_master_file_view}{synapse ID of master file view.} diff --git a/man/synapse_download_file_handle.Rd b/man/synapse_download_file_handle.Rd new file mode 100644 index 00000000..4d9e8db5 --- /dev/null +++ b/man/synapse_download_file_handle.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/synapse_rest_api.R +\name{synapse_download_file_handle} +\alias{synapse_download_file_handle} +\title{Download a synapse file from its URL +https://rest-docs.synapse.org/rest/GET/file/id.html} +\usage{ +synapse_download_file_handle(dataFileHandleId, id, auth, filepath = NULL) +} +\arguments{ +\item{dataFileHandleId}{The dataFileHandleId from an entity} + +\item{id}{The synapse ID of the file to download} + +\item{auth}{Synapse token} + +\item{filepath}{Optional path to download data. If NULL, return a data frame.} +} +\description{ +Download a synapse file from its URL +https://rest-docs.synapse.org/rest/GET/file/id.html +} diff --git a/man/synapse_entity_children.Rd b/man/synapse_entity_children.Rd new file mode 100644 index 00000000..ac343f6c --- /dev/null +++ b/man/synapse_entity_children.Rd @@ -0,0 +1,42 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/synapse_rest_api.R +\name{synapse_entity_children} +\alias{synapse_entity_children} +\title{Get children of a synapse entity +https://rest-docs.synapse.org/rest/POST/entity/children.html} +\usage{ +synapse_entity_children( + url = "https://repo-prod.prod.sagebase.org/repo/v1/entity/children", + auth, + parentId = NULL, + nextPageToken = NULL, + includeTypes = "project", + sortBy = "NAME", + sortDirection = "ASC", + includeTotalChildCount = FALSE, + includeSumFileSizes = FALSE +) +} +\arguments{ +\item{url}{Synapse api endpoint} + +\item{auth}{Synapse token} + +\item{parentId}{Synapse ID of parent folder} + +\item{nextPageToken}{Synapse next page token} + +\item{includeTypes}{Types to return} + +\item{sortBy}{Variable to sort by} + +\item{sortDirection}{sort direction} + +\item{includeTotalChildCount}{boolean include count of children} + +\item{includeSumFileSizes}{boolean include sum of file sizes} +} +\description{ +Get children of a synapse entity +https://rest-docs.synapse.org/rest/POST/entity/children.html +} diff --git a/man/synapse_get_project_scope.Rd b/man/synapse_get_project_scope.Rd new file mode 100644 index 00000000..30ac52e3 --- /dev/null +++ b/man/synapse_get_project_scope.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/synapse_rest_api.R +\name{synapse_get_project_scope} +\alias{synapse_get_project_scope} +\title{Get projects within scope of Synapse project} +\usage{ +synapse_get_project_scope( + url = "https://repo-prod.prod.sagebase.org/repo/v1/entity/", + id, + auth +) +} +\arguments{ +\item{url}{Synapse api endpoint} + +\item{id}{Synapse ID} + +\item{auth}{Synapse token} +} +\description{ +Get projects within scope of Synapse project +} diff --git a/man/synapse_projects_user.Rd b/man/synapse_projects_user.Rd new file mode 100644 index 00000000..2ef7347a --- /dev/null +++ b/man/synapse_projects_user.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/synapse_rest_api.R +\name{synapse_projects_user} +\alias{synapse_projects_user} +\title{Get projects a user has access to} +\usage{ +synapse_projects_user( + url = "https://repo-prod.prod.sagebase.org/repo/v1/projects/user", + auth, + nextPageToken = NULL +) +} +\arguments{ +\item{url}{Synapse api endpoint} + +\item{auth}{Synapse token} + +\item{nextPageToken}{Synapse next page token} +} +\description{ +Get projects a user has access to +} diff --git a/man/synapse_storage_projects.Rd b/man/synapse_storage_projects.Rd new file mode 100644 index 00000000..f3d99ab9 --- /dev/null +++ b/man/synapse_storage_projects.Rd @@ -0,0 +1,24 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/synapse_rest_api.R +\name{synapse_storage_projects} +\alias{synapse_storage_projects} +\title{Get storage projects within a Synapse table +https://rest-docs.synapse.org/rest/GET/entity/id/table/query/async/get/asyncToken.html} +\usage{ +synapse_storage_projects( + id, + auth, + select_cols = c("id", "name", "parentId", "projectId", "type", "columnType") +) +} +\arguments{ +\item{id}{Synapse ID of table} + +\item{auth}{Synapse token} + +\item{select_cols}{Columns to get from table} +} +\description{ +Get storage projects within a Synapse table +https://rest-docs.synapse.org/rest/GET/entity/id/table/query/async/get/asyncToken.html +} diff --git a/server.R b/server.R index c6702476..d28a88f3 100644 --- a/server.R +++ b/server.R @@ -1001,6 +1001,7 @@ shinyServer(function(input, output, session) { .submit_manifest_record_type <- dcc_config_react()$schematic$model_submit$manifest_record_type .restrict_rules <- dcc_config_react()$schematic$model_validate$restrict_rules .hide_blanks <- dcc_config_react()$schematic$model_submit$hide_blanks + .file_annotations_upload <- dcc_config_react()$schematic$model_submit$file_annotations_upload # associates metadata with data and returns manifest id promises::future_promise({ @@ -1028,7 +1029,8 @@ shinyServer(function(input, output, session) { manifest_record_type = .submit_manifest_record_type, table_manipulation = .table_manipulation, data_model_labels = .data_model_labels, - hide_blanks = .hide_blanks + hide_blanks = .hide_blanks, + file_annotations_upload = .file_annotations_upload ), "synXXXX - No data uploaded" ) @@ -1056,6 +1058,8 @@ shinyServer(function(input, output, session) { .submit_manifest_record_type <- dcc_config_react()$schematic$model_submit$manifest_record_type .restrict_rules <- dcc_config_react()$schematic$model_validate$restrict_rules .hide_blanks <- dcc_config_react()$schematic$model_submit$hide_blanks + .file_annotations_upload <- dcc_config_react()$schematic$model_submit$file_annotations_upload + # associates metadata with data and returns manifest id promises::future_promise({ try( @@ -1082,7 +1086,8 @@ shinyServer(function(input, output, session) { manifest_record_type = .submit_manifest_record_type, table_manipulation = .table_manipulation, data_model_labels = .data_model_labels, - hide_blanks = .hide_blanks + hide_blanks = .hide_blanks, + file_annotations_upload = .file_annotations_upload ), "synXXXX - No data uploaded" )