Skip to content

Commit

Permalink
Merge pull request #15 from CNAG-Biomedical-Informatics/fix_rank_base…
Browse files Browse the repository at this point in the history
…d_on_converted_data

Fix rank based on converted data
  • Loading branch information
IvoLeist authored Feb 21, 2024
2 parents 94e3402 + 6ae39bd commit d9aa035
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 7 deletions.
2 changes: 2 additions & 0 deletions data/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
uploads/rankInput/*.json
uploads/ontologies/*.yaml
uploads/weights/*.yaml
uploads/config/*.yaml

output/simulatedData/*.json
output/tmp/*.json
Expand All @@ -15,3 +16,4 @@ output/rankedCohortMatrixes/*
output/convertedData/*
!output/convertedData/README.md


12 changes: 12 additions & 0 deletions data/temp/conversionConfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
allowed_terms:
- Bar
- Baz
- Foo
- id
array_terms: Bar
format: CSV
id_correspondence:
CSV:
- Bar: Bar
primary_key: id

1 change: 1 addition & 0 deletions data/temp/conversionOutput.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"Bar":[["bar1a"],["bar1b"]],"Baz":["baz1"],"Foo":["foo1"],"id":["PR_00000001"]},{"Bar":[["bar2a"],["bar2b"]],"Baz":["baz2"],"Foo":["foo2"],"id":["PR_00000002"]}]
1 change: 1 addition & 0 deletions data/temp/phenoRankerSim.bff.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions data/temp/phenoRankerSim.pxf.json

Large diffs are not rendered by default.

Empty file added data/uploads/config/README.md
Empty file.
51 changes: 46 additions & 5 deletions phenoRankeR/R/fct_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,15 @@ validateYAML <- function(yaml_input) {
outputDownloadHandler <- function(data_sources, file_names, zip_download = FALSE) {
downloadHandler(
filename = function() {
ext <- ".json"
if (length(file_names) == 1 && grepl("conversionConfig", file_names)) {
ext <- ".yaml"
}

if (zip_download) {
"phenoRankerSim.zip"
} else {
paste0(file_names, ".json")
paste0(file_names, ext)
}
},
content = function(file) {
Expand All @@ -135,17 +140,53 @@ outputDownloadHandler <- function(data_sources, file_names, zip_download = FALSE
# Need to set wd otherwise the files will be inside nested folders
setwd(temp_dir)

# Initialize a vector to hold the full filenames with extensions
full_file_names <- c()

for (i in seq_along(data_sources)) {
content_file <- file.path(paste0(file_names[i], ".json"))
writeLines(as.character(toJSON(data_sources[[i]])), content_file)

# check if the file is a yaml file
fn <- file_names[[i]]
print("fn")
print(fn)
if (fn == "conversionConfig") {
print("inside conversionConfig")
content_file <- file.path(paste0(fn, ".yaml"))
print("content_file")
print(content_file)
writeLines(data_sources[[i]], content_file)

# Add the yaml file to the vector
full_file_names <- c(full_file_names, paste0(fn, ".yaml"))

} else {
content_file <- file.path(paste0(file_names[i], ".json"))
writeLines(as.character(toJSON(data_sources[[i]])), content_file)

# Add the json file to the vector
full_file_names <- c(full_file_names, paste0(file_names[i], ".json"))
}
# content_file <- file.path(paste0(file_names[i], ".json"))
# writeLines(as.character(toJSON(data_sources[[i]])), content_file)
}
zip(
file,
files = paste0(file_names, ".json")
# files = paste0(file_names, ".json")
files = full_file_names
)
unlink(temp_dir, recursive = TRUE)
} else {
writeLines(as.character(toJSON(data_sources)), file)
if (grepl("conversionConfig", file_names)) {
print("data_sources")
print(data_sources)

print("file")
print(file)

writeLines(data_sources, file)
} else {
writeLines(as.character(toJSON(data_sources)), file)
}
}
}
)
Expand Down
2 changes: 0 additions & 2 deletions phenoRankeR/R/mod_conv_mode.R
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ mod_conv_output_viewer_server <- function(id, conv_out, cfg_out) {
print("cfg_out")
print(cfg_out)

# data arives here but there is nothing rendered

output$conv_output_viewer <- renderUI({
fluidRow(
generateJsonView(conv_out, "JSON output", 6),
Expand Down
3 changes: 3 additions & 0 deletions phenoRankeR/R/mod_patient_mode.R
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,9 @@ mod_patient_mode_server <- function(
paste0(timestamp,"_config.yaml")
)

print("input$yamlEditor_config")
print(input$yamlEditor_config)

writeLines(
input$yamlEditor_config,
extra_config_file_path
Expand Down

0 comments on commit d9aa035

Please sign in to comment.