# Automatically generated by openapi-generator (https://openapi-generator.tech)
# Please update as you see appropriate
context("Test Assay")
model.instance <- Assay$new()
ref.json <- '{
"id" : 1,
"name" : "Description of assay 1",
"custom" : [
{"id": 1, "cv_label": "MSIO", "cv_accession": "MSIO:0000148", "name":"high performance liquid chromatography", "value":null},
{"id": 2, "cv_label": null, "cv_accession": null, "name": "custom user param", "value":null}
],
"external_uri" : null,
"sample_ref" : 1,
"ms_run_ref" : [ 1 ]
}'
test_that("Assay$fromJSONString() works", {
model.instance <- model.instance$fromJSONString(ref.json)
expect_equal(model.instance$`id`, 1)
expect_equal(model.instance$`name`, "Description of assay 1")
expect_equal(length(model.instance$`custom`), 2)
expect_null(model.instance$`external_uri`)
expect_equal(model.instance$`sample_ref`, 1)
expect_equal(length(model.instance$`ms_run_ref`), 1)
expect_equal(model.instance$`ms_run_ref`[[1]], 1)
model.instance$toJSONString()
})
test_that("Assay$toDataFrame() works", {
assay <-
Assay$new(
id = 1,
name = "Just a name for the assay",
custom = list(
Parameter$new(
cv_label = "MS",
cv_accession = "MS:1",
name = "made up, also for testing"
)
),
external_uri = "file:///path/to/my/file.mzML",
sample_ref = 2,
ms_run_ref = list("1", "2", "3")
)
df <- assay$toDataFrame()
expect_equal(nrow(df), 7)
expect_equal(df[1, "PREFIX"], "MTD")
expect_equal(df[1, "KEY"], "assay[1]")
expect_equal(df[1, "VALUE"], "Just a name for the assay")
expect_equal(df[2, "KEY"], "assay[1]-custom[1]")
expect_equal(df[2, "VALUE"], "[MS, MS:1, \"made up, also for testing\", ]")
expect_equal(df[3, "KEY"], "assay[1]-external_uri")
expect_equal(df[3, "VALUE"], "file:///path/to/my/file.mzML")
expect_equal(df[4, "KEY"], "assay[1]-sample_ref")
expect_equal(df[4, "VALUE"], "sample[2]")
expect_equal(df[5, "KEY"], "assay[1]-ms_run_ref")
expect_equal(df[5, "VALUE"], "ms_run[1]")
expect_equal(df[6, "KEY"], "assay[1]-ms_run_ref")
expect_equal(df[6, "VALUE"], "ms_run[2]")
expect_equal(df[7, "KEY"], "assay[1]-ms_run_ref")
expect_equal(df[7, "VALUE"], "ms_run[3]")
})
test_that("Assay$fromDataFrame() works", {
assayMtd <-
'
MTD assay[1] Description of assay 1
MTD assay[1]-sample_ref sample[1]
MTD assay[1]-ms_run_ref ms_run[1]
MTD assay[1]-custom[1] [MS, MS:1, "made up, also for testing", ]
'
mzTabTable <- readMzTabString(assayMtd)
metadataTable <- extractMetadata(mzTabTable)
idElements <- extractIdElements(metadataTable, "assay", "name")
model.instance <- Assay$new()
model.instance$fromDataFrame(idElements[[1]])
expect_equal(model.instance$`id`, 1)
expect_equal(model.instance$`name`, 'Description of assay 1')
expect_equal(length(model.instance$`custom`), 1)
expect_equal(model.instance$`custom`[[1]]$cv_accession, "MS:1")
expect_null(model.instance$`external_uri`)
expect_equal(model.instance$`sample_ref`, 1)
expect_equal(length(model.instance$`ms_run_ref`), 1)
expect_equal(model.instance$`ms_run_ref`[[1]], 1)
}
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.