Skip to content

Commit

Permalink
Update get-template to handle filepaths or URLs in config.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
afwillia committed Mar 7, 2022
1 parent 7c87f97 commit c7991d1
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 10 deletions.
7 changes: 6 additions & 1 deletion R/get-template.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#' @param synID Synapse ID of an excel or csv file containing a metadata
#' template
#' @param id The id of JSON metadata schema registered in Synapse or Synapse ID
#' of an excel or csv file containing a metadata template
#' of an excel or csv file containing a metadata template. Or a filepath or URL
#' to a json schema.
#' @inheritParams get_synapse_annotations
#' @param ... Additional arguments passed to syn$get()
#' @return Character vector of template column names
Expand All @@ -28,6 +29,10 @@ get_template <- function(id = NA, syn, synID = NA, ...) {
if (grepl("^syn", id)) {
return(get_template_keys_synID(syn = syn, synID = id, ...))
}
## Check if a schema file or URL was passed
if (identical(tolower(tools::file_ext(id)), "json") | grepl("/", id)) {
return(get_template_keys_schema(syn = syn, file = id))
}
## If not a synID, assume a schema id
return(get_template_keys_schema(syn = syn, id = id))
}
Expand Down
84 changes: 78 additions & 6 deletions inst/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
default:
production: TRUE
app_url: "https://shinypro.synapse.org/users/nkauer/dccvalidator-test/"
app_url: "https://shinypro.synapse.org/users/awilliams/dccvalidator/"
parent: "syn20400157"
path_to_markdown: "inst/using-the-dccvalidator-app-amp-ad.Rmd"
study_table: "syn11363298"
Expand All @@ -19,14 +19,15 @@ default:
templates:
manifest_template: "syn20820080"
individual_templates:
human: "syn12973254"
human: "awilliams.test-IndividualHumanMetadataTemplate"
mouse or other animal model: "syn12973253"
biospecimen_templates:
mouse or other animal model: "syn12973252"
human: "syn12973252"
drosophila: "syn20673251"
assay_templates:
rnaSeq: "sysbio.metadataTemplates-assay.rnaSeq"
rnaSeq: "awilliams.test-AssayRnaSeqMetadataTemplate"
16SrRNAseq: "awilliams.test-Assay16SrRNAseqMetadataTemplate"
species_list:
- "mouse or other animal model"
- "human"
Expand Down Expand Up @@ -77,8 +78,9 @@ testing:


amp-ad:
app_url: "https://shinypro.synapse.org/users/nkauer/dccvalidator-ad/"
app_url: "https://shinypro.synapse.org/users/awilliams/dccvalidator/"
parent: "syn21643404"
samples_table: "syn21578908"
annotations_table: "syn21459391"
annotations_link: "https://shinypro.synapse.org/users/kwoo/amp-ad-metadata-dictionary/"
teams:
Expand Down Expand Up @@ -116,6 +118,7 @@ amp-ad:
ATACseq: "syn22024364"
autorad: "syn22087295"
immunoassay: "syn22117582"
rnaSeq: "sysbio.metadataTemplates-assay.rnaSeq"
proteomics: "syn12973255"
single cell RNAseq: "syn21018360"
wholeGenomeSeq: "syn21018358"
Expand Down Expand Up @@ -150,7 +153,7 @@ amp-ad:
contact_email: "[email protected]"

pec:
app_url: "https://shinypro.synapse.org/users/kmontgomery/apps_w_oauth/dccvalidator/"
app_url: "https://shinypro.synapse.org/users/awilliams/dccvalidator/"
parent: "syn21763123"
path_to_markdown: "inst/using-the-dccvalidator-pec.Rmd"
study_table: "syn20968992"
Expand Down Expand Up @@ -219,7 +222,7 @@ pec:
contact_email: "[email protected]"

veoibd:
app_url: "https://shinypro.synapse.org/users/nkauer/dccvalidator-veoibd/"
app_url: "https://shinypro.synapse.org/users/awilliams/dccvalidator/"
parent: "syn25556537"
path_to_markdown: "inst/using-the-dccvalidator-veoibd.Rmd"
study_table: "syn25557724"
Expand Down Expand Up @@ -279,3 +282,72 @@ veoibd:
assay:
- "specimenID"
contact_email: "[email protected]"

amp-ad-test:
app_url: "https://shinypro.synapse.org/users/awilliams/dccmonitor"
annotations_link: "https://shinypro.synapse.org/users/kwoo/amp-ad-metadata-dictionary/"
consortium_fileview: "syn21448475"
samples_table: "syn21578908"
annotations_storage: "syn21698384"
annotations_table: "syn21459391"
annotation_keys:
- "age"
- "primaryDiagnosis"
teams:
- "3346847"
species_list:
- "human"
- "drosophila"
- "MODEL-AD mouse model"
- "other mouse or animal model"
templates:
individual_templates:
human: "https://raw.githubusercontent.com/afwillia/sysbioDCCjsonschemas/schematic_workflow/schematic_schemas/json/amp.ad.data.IndividualHumanMetadataTemplate.schema.json"
other mouse or animal model: "syn27000468"
MODEL-AD mouse model: "syn21084071"
biospecimen_templates:
human:
in vivo, postmortem, other: "awilliams.test-BiospecimenMetadataTemplate"
in vitro: "awilliams.test-BiospecimenInvitroMetadataTemplate"
other mouse or animal model:
in vivo, postmortem, other: "syn12973252"
in vitro: "syn25955510"
MODEL-AD mouse model:
in vivo, postmortem, other: "syn12973252"
in vitro: "syn25955510"
drosophila: "syn20673251"
assay_templates:
ATACseq: "awilliams.test-AssayATACSeqMetadataTemplate"
autorad: "syn22087295"
rnaSeq: "awilliams.test-AssayRnaSeqMetadataTemplate"
immunoassay: "syn22117582"
proteomics: "syn12973255"
single cell RNAseq: "awilliams.test-AssayScrnaSeqMetadataTemplate"
wholeGenomeSeq: "awilliams.test-AssayWholeGenomeSeqMetadataTemplate"
wholeExomeSeq: "awilliams.test-AssayWholeExomeSeqMetadataTemplate"
NanoString: "awilliams.test-AssayNanostringMetadataTemplate"
snpArray: "awilliams.test-AssaySnpArrayMetadataTemplate"
STARRSeq: "awilliams.test-AssaySTARRSeqMetadataTemplate"
TMT quantitation: "awilliams.test-AssayTMTquantitationMetadataTemplate"
methylationArray: "awilliams.test-AssayMethylationArrayMetadataTemplate"
MRI: "awilliams.test-AssayMRIMetadataTemplate"
PET: "awilliams.test-AssayPETMetadataTemplate"
16SrRNAseq: "awilliams.test-Assay16SrRNAseqMetadataTemplate"
metabolomics: "awilliams.test-AssayMetabolomicsMetadataTemplate"
HI-C: "syn27000426"
ChIPSeq: "awilliams.test-AssayChIPSeqMetadataTemplate"
bisulfiteSeq: "awilliams.test-AssayBisulfiteSeqMetadataTemplate"
complete_columns:
manifest:
- "consortium"
- "study"
- "grant"
- "fileFormat"
- "parent"
individual:
- "individualID"
biospecimen:
- "individualID"
- "specimenID"
assay:
- "specimenID"
3 changes: 2 additions & 1 deletion man/get_synapse_schema.Rd

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

3 changes: 2 additions & 1 deletion man/get_template.Rd

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

14 changes: 13 additions & 1 deletion tests/testthat/test-get-template.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,18 @@ test_that("get_template accepts synID with id param", {
expect_equal(xlsx2, c("a", "b", "c", "d"))
})

test_that("get_template can correctly handles URLs and filepaths", {
gt <- get_template(id = "https://raw.githubusercontent.com/afwillia/sysbioDCCjsonschemas/schematic_workflow/schematic_schemas/json/amp.ad.data.Assay16SrRNAseqMetadataTemplate.schema.json",
syn = syn)
gu <- get_file_schema(file="https://raw.githubusercontent.com/afwillia/sysbioDCCjsonschemas/schematic_workflow/schematic_schemas/json/amp.ad.data.Assay16SrRNAseqMetadataTemplate.schema.json")
expect_identical(gt, names(gu$properties))

gt <- get_template(id = system.file("testdata",
"amp.ad.data.Assay16SrRNAseqMetadataTemplate.schema.json",
package="dccvalidator"))
expect_identical(gt, names(gu$properties))
})

# test_that("get_template can get keys from a (simple) registered schema", {
# skip_if_not(logged_in(syn = syn))
#
Expand Down Expand Up @@ -103,7 +115,7 @@ test_that("get_template can get a schema file", {
"specimenID", "platform", "assay", "readLength", "dnaBatch", "Component",
"assayTarget", "libraryBatch"))

schema_url <- get_file_schema(file="https://raw.githubusercontent.com/afwillia/sysbioDCCjsonschemas/schematic_workflow/schema_metadata_templates/schematic_test/json/amp.ad.data.Assay16SrRNAseqMetadataTemplate.schema.json")
schema_url <- get_file_schema(file="https://raw.githubusercontent.com/afwillia/sysbioDCCjsonschemas/schematic_workflow/schematic_schemas/json/amp.ad.data.Assay16SrRNAseqMetadataTemplate.schema.json")
expect_equal(names(schema_url$properties),
c("dnaExtractionMethod", "runType", "libraryPrep", "sequencingBatch",
"specimenID", "platform", "assay", "readLength", "dnaBatch", "Component",
Expand Down

0 comments on commit c7991d1

Please sign in to comment.