# Automatically generated by openapi-generator (https://openapi-generator.tech)
# Please update as you see appropriate
context("Test Software")
model.instance <- Software$new()
ref.json <- "[{\"id\":1,\"parameter\":{\"cv_label\":\"MS\",\"cv_accession\":\"MS:1000532\",\"name\":\"Xcalibur\",\"value\":\"2.8-280502/2.8.1.2806\"},\"setting\":[\"ScheduledSRMWindow: 2 min\",\"CycleTime: 2 s\"]},{\"id\":2,\"parameter\":{\"cv_label\":\"MS\",\"cv_accession\":\"MS:1000922\",\"name\":\"Skyline\",\"value\":\"3.5.0.9319\"},\"setting\":[\"MSMSmassrange: (50.0, 1800.0)\"]}]"
test_that("software_deserialization_works", {
software <- jsonlite::fromJSON(ref.json)
softwareObjects <- ApiClient$new()$deserializeObj(software, "array[Software]", loadNamespace("rmzTabM"))
#software <- model.instance$fromJSONString(ref)
expect_false(is.null(software))
expect_false(is.null(softwareObjects))
expect_equal(length(softwareObjects), 2)
expect_equal(softwareObjects[[1]]$id, 1)
expect_equal(length(softwareObjects[[1]]$setting), 1)
expect_equal(softwareObjects[[1]]$toJSONString(), "{\"id\":\n 1\n ,\"parameter\":\n {\"cv_label\":\"MS\",\"cv_accession\":\"MS:1000532\",\"name\":\"Xcalibur\",\"value\":\"2.8-280502/2.8.1.2806\"}\n ,\"setting\":\n [\"ScheduledSRMWindow: 2 min\",\"CycleTime: 2 s\"]\n }")
})
test_that("software$toDataFrame works", {
software <- jsonlite::fromJSON(ref.json)
softwareObjects <- ApiClient$new()$deserializeObj(software, "array[Software]", loadNamespace("rmzTabM"))
sdf1 <- softwareObjects[[1]]$toDataFrame()
expect_equal(sdf1[1, "PREFIX"], "MTD")
expect_equal(sdf1[1, "KEY"], "software[1]")
expect_equal(sdf1[1, "VALUE"], "[MS, MS:1000532, Xcalibur, 2.8-280502/2.8.1.2806]")
expect_equal(sdf1[2, "KEY"], "software[1]-setting[1]")
expect_equal(sdf1[2, "VALUE"], "ScheduledSRMWindow: 2 min")
expect_equal(sdf1[3, "KEY"], "software[1]-setting[2]")
expect_equal(sdf1[3, "VALUE"], "CycleTime: 2 s")
sdf2 <- softwareObjects[[2]]$toDataFrame()
expect_equal(sdf2[1, "PREFIX"], "MTD")
expect_equal(sdf2[1, "KEY"], "software[2]")
expect_equal(sdf2[1, "VALUE"], "[MS, MS:1000922, Skyline, 3.5.0.9319]")
})
test_that("software$fromDataFrame works", {
softwareMtd <-
'
MTD\tsoftware[1]\t[MS, MS:1000551, Analyst, 1.6.2]
MTD\tsoftware[1]-setting[1]\tScheduledSRMWindow: 2 min
MTD\tsoftware[1]-setting[2]\tCycleTime: 2 s
MTD\tsoftware[2]\t[MS, MS:1000922, Skyline, 3.5.0.9319]
MTD\tsoftware[2]-setting[1]\tMSMSmassrange: (50.0, 1800.0)
'
mzTabTable <- readMzTabString(softwareMtd)
metadataTable <- extractMetadata(mzTabTable)
idElements <- extractIdElements(metadataTable, "software", "parameter")
model.instance <- Software$new()
model.instance$fromDataFrame(idElements[[1]])
expect_equal(model.instance$`id`, 1)
#parameter
expect_equal(model.instance$`parameter`$cv_label, "MS")
expect_equal(model.instance$`parameter`$cv_accession, "MS:1000551")
expect_equal(model.instance$`parameter`$name, "Analyst")
expect_equal(model.instance$`parameter`$value, "1.6.2")
#setting list
expect_equal(length(model.instance$`setting`), 2)
expect_equal(model.instance$`setting`[[1]], "ScheduledSRMWindow: 2 min")
expect_equal(model.instance$`setting`[[2]], "CycleTime: 2 s")
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.