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

Patch/study registration #79

Merged
merged 2 commits into from
Dec 5, 2023
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
4 changes: 2 additions & 2 deletions new_project/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM ghcr.io/nf-osi/nfportalutils:develop@sha256:103c21eea8c9a2c0e438880f28b03827e4285bc4e71f3141f5fdcf28a6b813ce
FROM ghcr.io/nf-osi/nfportalutils:develop@sha256:32e4820eb9e5a7aecc51413a796c7d470c215182ffc3f20f3d2148c55de49077

ARG USERNAME=nfosi
ARG USER_UID=1001
ARG USER_GID=1000

RUN apt-get update -qq && \
RUN apt-get update && \
apt-get install -y jq

# Create the user
Expand Down
7 changes: 3 additions & 4 deletions new_project/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
## New Project

Create new project(s) given study JSON data following the [NF schema]().
Create new project(s) based on study data following the [NF study schema](https://github.com/nf-osi/dcc-site/blob/main/lib/study-schema.json).

### Examples

See files under tests for examples of what these study data look like.
For testing, add `-e PROFILE=TEST` when running (see below). This will create the project but register it with the [test fixture Studies table](https://www.synapse.org/#!Synapse:syn27353709/tables/) instead of the production Studies table.

#### Test

Single study:
`docker run -v "$(pwd)":/app -e SYNAPSE_AUTH_TOKEN=$SYNAPSE_AUTH_TOKEN -e PROFILE=TEST ghcr.io/nf-osi/jobs-new-project tests/study_basic.json`
`docker run -v "$(pwd)":/app -e SYNAPSE_AUTH_TOKEN=$SYNAPSE_AUTH_TOKEN ghcr.io/nf-osi/jobs-new-project tests/study_basic.json`

Multiple studies:
`docker run -v "$(pwd)":/app -e SYNAPSE_AUTH_TOKEN=$SYNAPSE_AUTH_TOKEN -e PROFILE=TEST ghcr.io/nf-osi/jobs-new-project tests/study_two_datasets.json tests/study_same_data_labels.json`
`docker run -v "$(pwd)":/app -e SYNAPSE_AUTH_TOKEN=$SYNAPSE_AUTH_TOKEN ghcr.io/nf-osi/jobs-new-project tests/study_two_datasets.json tests/study_same_data_labels.json`

37 changes: 18 additions & 19 deletions new_project/new_project_from_json.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ setup_from_config <- function(config_file) {
DATASETS <- make.unique(DATASETS, sep = " ")
DATASETS <- as.list(DATASETS)
for(i in seq_along(DATA_DEPOSIT)) {
# Set attributes -- note that properties not present resolve to NULL, which is OK
# Set selected attributes -- note that properties not present resolve to NULL, which is OK
attr(DATASETS[[i]], "assay") <- DATA_DEPOSIT[[i]]$dataAssay
attr(DATASETS[[i]], "dataType") <- DATA_DEPOSIT[[i]]$dataType
attr(DATASETS[[i]], "description") <- DATA_DEPOSIT[[i]]$dataDescription
attr(DATASETS[[i]], "progressReportNumber") <- DATA_DEPOSIT[[i]]$dataProgressReportNumber
attr(DATASETS[[i]], "contentType") <- "dataset"
Expand All @@ -67,28 +68,26 @@ setup_from_config <- function(config_file) {
PROJECT_ID <- created_project$properties$id
FILEVIEW_ID <- attr(created_project, "fileview")

# Register
STUDY_TABLE_ID <- if(Sys.getenv("PROFILE") == "TEST") "syn27353709" else "syn16787123"
nfportalutils::register_study(name = NAME,
project_id = PROJECT_ID,
abstract = SUMMARY,
lead = LEAD_CSV,
institution = INSTITUTION,
focus = FOCUS,
manifestation = MANIFESTATIONS,
fileview_id = FILEVIEW_ID,
funder = FUNDER,
initiative = INITIATIVE,
grant_doi = GRANT_DOI,
study_table_id = STUDY_TABLE_ID)

# Add to scope of master portal fileview
nfportalutils::register_study_files(PROJECT_ID)

# Write new syn id to config
cat("Writing", PROJECT_ID, "to", config_file, "\n")
command <- paste0('jq \'. += { "studyId" : "', PROJECT_ID, '" }\' ', config_file, ' > tmp.json && mv tmp.json ' , config_file)
system(command)

# Register with some translations
config$studyLeads <- config$PI
config$studyFileviewId <- FILEVIEW_ID
config$studyName <- config$name
config$institutions <- config$institution
config$manifestation <- config$diseaseManifestation
nfportalutils::register_study(id = PROJECT_ID,
study_meta = config,
summary = SUMMARY,
study_summary_table = "syn16787123",
portal_project_view = "syn52677631")

# Add to scope of master portal fileview
nfportalutils::register_study_files(PROJECT_ID)

}

for(config in configs) {
Expand Down
Loading