# Automatically generated by openapi-generator (https://openapi-generator.tech)
# Please update as you see appropriate
context("Test MsRun")
model.instance <- MsRun$new()
ref.json <- '{
"id" : 1,
"instrument_ref" : 1,
"location" : "file:///path/to/my/file.mzML",
"format" : {
"cv_label" : "MS",
"cv_accession" : "MS:1",
"name" : "made up, also for testing",
"value" : null
},
"id_format" : {
"cv_label" : "MS",
"cv_accession" : "MS:2",
"name" : "made up for testing",
"value" : "some, weird, value"
},
"fragmentation_method": [{
"cv_label" : "MS",
"cv_accession" : "MS:3",
"name" : "made up for testing",
"value" : null
}, {
"cv_label" : "MS",
"cv_accession" : "MS:3a",
"name" : "made up for testing",
"value" : null
}],
"scan_polarity" : [{
"cv_label" : "MS",
"cv_accession" : "MS:4",
"name" : "made up, for testing",
"value" : "some value"
}],
"hash" : "hlkasdhlkh2139810asjdklh",
"hash_method" : {
"cv_label" : "MS",
"cv_accession" : "MS:5",
"name" : "made up, for testing",
"value" : "some value"
}
}'
test_that("msRun", {
model.instance <- model.instance$fromJSONString(ref.json)
expect_equal(model.instance$`id`, 1)
expect_equal(model.instance$`instrument_ref`, 1)
expect_equal(model.instance$`location`, "file:///path/to/my/file.mzML")
expect_equal(
model.instance$`format`,
Parameter$new(
cv_label = "MS",
cv_accession = "MS:1",
name = "made up, also for testing"
)
)
expect_equal(
model.instance$`id_format`,
Parameter$new(
cv_label = "MS",
cv_accession = "MS:2",
name = "made up for testing",
value = "some, weird, value"
)
)
expect_equal(
model.instance$`fragmentation_method`[[1]],
Parameter$new(
cv_label = "MS",
cv_accession = "MS:3",
name = "made up for testing"
)
)
expect_equal(
model.instance$`fragmentation_method`[[2]],
Parameter$new(
cv_label = "MS",
cv_accession = "MS:3a",
name = "made up for testing"
)
)
expect_equal(
model.instance$`scan_polarity`[[1]],
Parameter$new(
cv_label = "MS",
cv_accession = "MS:4",
name = "made up, for testing",
value = "some value"
)
)
expect_equal(model.instance$`hash`, "hlkasdhlkh2139810asjdklh")
expect_equal(
model.instance$`hash_method`,
Parameter$new(
cv_label = "MS",
cv_accession = "MS:5",
name = "made up, for testing",
value = "some value"
)
)
model.instance$toJSONString()
})
test_that("MsRun$toDataFrame() works", {
msRun <- MsRun$new()
msRun$`id` <- 1
# msRun$`name` <- "Just a name for the run"
msRun$`instrument_ref` <- 1
msRun$`location` <- "file:///path/to/my/file.mzML"
msRun$`format` <- Parameter$new(cv_label = "MS", cv_accession = "MS:1", name = "made up, also for testing")
msRun$`id_format` <- Parameter$new(cv_label = "MS", cv_accession = "MS:2", name = "made up for testing", value = "some, weird, value")
msRun$`fragmentation_method` <- list(
Parameter$new(cv_label = "MS", cv_accession = "MS:3", name = "made up for testing"),
Parameter$new(cv_label = "MS", cv_accession = "MS:3a", name = "made up for testing")
)
msRun$`scan_polarity` <- list(
Parameter$new(cv_label = "MS", cv_accession = "MS:4", name = "made up, for testing", value = "some value")
)
msRun$`hash` <- "hlkasdhlkh2139810asjdklh"
msRun$`hash_method` <- Parameter$new(cv_label = "MS", cv_accession = "MS:5", name = "made up for testing")
df <- msRun$toDataFrame()
expect_equal(nrow(df), 9)
expect_equal(df[1, "PREFIX"], "MTD")
# expect_equal(df[1, "KEY"], "ms_run[1]-name")
# expect_equal(df[1, "VALUE"], "Just a name for the run")
expect_equal(df[1, "KEY"], "ms_run[1]-location")
expect_equal(df[1, "VALUE"], "file:///path/to/my/file.mzML")
expect_equal(df[2, "KEY"], "ms_run[1]-instrument_ref")
expect_equal(df[2, "VALUE"], "instrument[1]")
expect_equal(df[3, "KEY"], "ms_run[1]-format")
expect_equal(df[3, "VALUE"], "[MS, MS:1, \"made up, also for testing\", ]")
expect_equal(df[4, "KEY"], "ms_run[1]-id_format")
expect_equal(df[4, "VALUE"], "[MS, MS:2, made up for testing, \"some, weird, value\"]")
expect_equal(df[5, "KEY"], "ms_run[1]-fragmentation_method[1]")
expect_equal(df[5, "VALUE"], "[MS, MS:3, made up for testing, ]")
expect_equal(df[6, "KEY"], "ms_run[1]-fragmentation_method[2]")
expect_equal(df[6, "VALUE"], "[MS, MS:3a, made up for testing, ]")
expect_equal(df[7, "KEY"], "ms_run[1]-scan_polarity[1]")
expect_equal(df[7, "VALUE"], "[MS, MS:4, \"made up, for testing\", some value]")
expect_equal(df[8, "KEY"], "ms_run[1]-hash")
expect_equal(df[8, "VALUE"], "hlkasdhlkh2139810asjdklh")
expect_equal(df[9, "KEY"], "ms_run[1]-hash_method")
expect_equal(df[9, "VALUE"], "[MS, MS:5, made up for testing, ]")
})
test_that("msRun$fromDataFrame() works", {
model.instance <- model.instance$fromJSONString(ref.json)
expect_equal(model.instance$`id`, 1)
expect_equal(model.instance$`instrument_ref`, 1)
expect_equal(model.instance$`location`, "file:///path/to/my/file.mzML")
expect_equal(
model.instance$`format`,
Parameter$new(
cv_label = "MS",
cv_accession = "MS:1",
name = "made up, also for testing"
)
)
expect_equal(
model.instance$`id_format`,
Parameter$new(
cv_label = "MS",
cv_accession = "MS:2",
name = "made up for testing",
value = "some, weird, value"
)
)
expect_equal(
model.instance$`fragmentation_method`[[1]],
Parameter$new(
cv_label = "MS",
cv_accession = "MS:3",
name = "made up for testing"
)
)
expect_equal(
model.instance$`fragmentation_method`[[2]],
Parameter$new(
cv_label = "MS",
cv_accession = "MS:3a",
name = "made up for testing"
)
)
expect_equal(
model.instance$`scan_polarity`[[1]],
Parameter$new(
cv_label = "MS",
cv_accession = "MS:4",
name = "made up, for testing",
value = "some value"
)
)
expect_equal(model.instance$`hash`, "hlkasdhlkh2139810asjdklh")
expect_equal(
model.instance$`hash_method`,
Parameter$new(
cv_label = "MS",
cv_accession = "MS:5",
name = "made up, for testing",
value = "some value"
)
)
model.instance$toJSONString()
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.