Skip to content

Commit

Permalink
New project and package infra upgrades (#207)
Browse files Browse the repository at this point in the history
* Factor out functionality for reuse

* Implement new fileview building standards (#192)

* More default fileview updates

* Implement protocol binding

* Update Dockerfile

* Export, update pkg reference
  • Loading branch information
anngvu authored Jan 3, 2025
1 parent 1d403a1 commit 0fbb68b
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ RUN apt-get update && \
libxt6


RUN pip install synapseclient==3.0.0
RUN pip install synapseclient==4.3.1

COPY . /nfportalutils

# R components for installation or suggested usage
RUN R -e "install.packages(c('remotes', 'rmarkdown', 'DiagrammeR'), repos='http://cran.rstudio.com/')"
RUN R -e "remotes::install_local('nfportalutils', dependencies = c('Depends', 'Imports'))"
RUN R -e "remotes::install_version('reticulate', version = '1.28', repos ='http://cran.us.r-project.org')"
RUN R -e "remotes::install_version('reticulate', version = '1.39.0', repos ='http://cran.us.r-project.org')"

ENTRYPOINT [ "/bin/bash" ]

1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export(annotate_with_samtools_stats)
export(as_table_schema)
export(assign_study_data_types)
export(bad_url)
export(bind_schema)
export(bipartite_mmd_template)
export(byte_budget)
export(calculate_related_studies)
Expand Down
56 changes: 38 additions & 18 deletions R/new_project.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,7 @@ new_project <- function(name,

# 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))
bind_schema(id = data_folder_id, schema_id = "org.synapse.nf-superdataset", derived_annotations = TRUE)

# Create data-specific folders in "Raw Data"
if(length(datasets)) {
Expand All @@ -111,9 +105,15 @@ new_project <- function(name,

# Create homes for non-data resources alongside "Raw Data"
if(length(other_resources)) {
make_folder(parent = project, folders = other_resources)
other_resource_folders <- make_folder(parent = project, folders = other_resources)
if ("Protocols" %in% names(other_resource_folders)) {
bind_schema(id = other_resource_folders$Protocols$properties$id, schema_id = "org.synapse.nf-protocol", derived_annotations = FALSE)
}
}

# Aside from dataset schema, currently only have protocols schema


# Add Project Files and Metadata fileview, add NF schema; currently doesn't add facets
fv <- add_default_fileview(project)

Expand Down Expand Up @@ -156,29 +156,31 @@ add_default_fileview <- function(project) {
view <- synapseclient$EntityViewSchema(
name = "Project Files and Metadata",
columns=list(
synapseclient$Column(name="contentType", columnType="STRING", maximumSize="20"),
synapseclient$Column(name="resourceType", columnType="STRING", maximumSize="50"),
synapseclient$Column(name="assay", columnType="STRING", maximumSize="57"),
synapseclient$Column(name="assay", columnType="STRING", maximumSize="100"),
synapseclient$Column(name="dataType", columnType="STRING", maximumSize="30"),
synapseclient$Column(name="dataSubtype", columnType="STRING", maximumSize="13"),
synapseclient$Column(name="fileFormat", columnType="STRING", maximumSize="13"),
synapseclient$Column(name="diagnosis", columnType="STRING", maximumSize="39"),
synapseclient$Column(name="tumorType", columnType="STRING", maximumSize="90"),
synapseclient$Column(name="individualID", columnType="STRING", maximumSize="213"),
synapseclient$Column(name="specimenID", columnType="STRING", maximumSize="300"),
synapseclient$Column(name="individualID", columnType="STRING_LIST", maximumSize="50", maximumListLength = "50"),
synapseclient$Column(name="specimenID", columnType="STRING_LIST", maximumSize="50", maximumListLength = "50"),
synapseclient$Column(name="nf1Genotype", columnType="STRING", maximumSize="8"),
synapseclient$Column(name="nf2Genotype", columnType="STRING", maximumSize="7"),
synapseclient$Column(name="nf2Genotype", columnType="STRING", maximumSize="20"),
synapseclient$Column(name="species", columnType="STRING", maximumSize="100"),
synapseclient$Column(name="modelSystemName", columnType="STRING", maximumSize="42"),
synapseclient$Column(name="cellType", columnType="STRING", maximumSize="300"),
synapseclient$Column(name="sex", columnType="STRING", maximumSize="50"),
synapseclient$Column(name="modelSystemName", columnType="STRING", maximumSize="100"),
synapseclient$Column(name="cellType", columnType="STRING_LIST", maximumSize="50", maximumListLength = "50"),
synapseclient$Column(name="sex", columnType="STRING", maximumSize="30"),
synapseclient$Column(name="age", columnType="STRING", maximumSize="50"),
synapseclient$Column(name="experimentalCondition", columnType="STRING", maximumSize="58"),
synapseclient$Column(name="experimentalCondition", columnType="STRING", maximumSize="100"),
synapseclient$Column(name="progressReportNumber", columnType="INTEGER")
),
parent = project,
scopes = project,
includeEntityTypes = list(synapseclient$EntityViewType$FILE),
add_default_columns = TRUE)
includeEntityTypes = list(synapseclient$EntityViewType$FILE, synapseclient$EntityViewType$FOLDER),
add_default_columns = TRUE,
addAnnotationColumns = FALSE)
view <- .syn$store(view)
invisible(view)
}
Expand Down Expand Up @@ -296,3 +298,21 @@ is_valid_team <- function(id) {
if(length(status)) return(TRUE) else return(FALSE)
}

#' Wrapper for JSON schema binding
#'
#' See https://help.synapse.org/docs/JSON-Schemas.3107291536.html
#'
#' @param id Id of entity to which schema will be bound
#' @param schema_id Schema id as registered on Synapse.
#' @param derived_annotations Whether to enabled derived annotations.
#' Default `FALSE` as this is the API default.
#' @export
bind_schema <- function(id, schema_id, derived_annotations = FALSE) {

bind_schema_request <- jsonlite::toJSON(list(entityId = id,
`schema$id` = schema_id,
enableDerivedAnnotations = derived_annotations),
auto_unbox = TRUE)
binding_uri <- glue::glue("https://repo-prod.prod.sagebase.org/repo/v1/entity/{id}/schema/binding")
try(.syn$restPUT(binding_uri, bind_schema_request))
}
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ reference:
- table_query
- as_table_schema
- make_folder
- bind_schema
- add_to_scope
- new_view
- list_project_datasets
Expand Down
19 changes: 19 additions & 0 deletions man/bind_schema.Rd

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

0 comments on commit 0fbb68b

Please sign in to comment.