# mzTab-M reference implementation and validation API.
#
# This is the mzTab-M reference implementation and validation API service.
#
# The version of the OpenAPI document: 2.0.0
# Contact: nils.hoffmann@cebitec.uni-bielefeld.de
# Generated by: https://openapi-generator.tech
#' @docType class
#' @title SpectraRef
#' @description SpectraRef Class
#' @format An \code{R6Class} generator object
#' @field ms_run \link{MsRun}
#'
#' @field reference character
#'
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
SpectraRef <- R6::R6Class(
'SpectraRef',
public = list(
`ms_run` = NULL,
`reference` = NULL,
#' @description Create a SpectraRef
#' @param ms_run The ms run \link{MsRun} .
#' @param reference The reference to a particular spectrum using the id_format defined in \link{MsRun}.
#' @param ... local optional variable arguments
#'
initialize = function(`ms_run`, `reference`, ...){
local.optional.var <- list(...)
if (!missing(`ms_run`)) {
stopifnot(is.numeric(`ms_run`), length(`ms_run`) == 1)
self$`ms_run` <- `ms_run`
}
if (!missing(`reference`)) {
stopifnot(is.character(`reference`), length(`reference`) == 1)
self$`reference` <- `reference`
}
},
#' @description Serialize to list object suitable for jsonlite
toJSON = function() {
SpectraRefObject <- list()
if (!is.null(self$`ms_run`)) {
SpectraRefObject[['ms_run']] <-
rmzTabM::safe_unbox(self$`ms_run`)
}
if (!is.null(self$`reference`)) {
SpectraRefObject[['reference']] <-
rmzTabM::safe_unbox(self$`reference`)
}
SpectraRefObject
},
#' @description Deserialize from jsonlite list object
#' @param SpectraRefJson list object.
fromJSON = function(SpectraRefJson) {
SpectraRefObject <- jsonlite::fromJSON(SpectraRefJson)
if (!is.null(SpectraRefObject$`ms_run`)) {
self$`ms_run` <- SpectraRefObject$`ms_run`
}
if (!is.null(SpectraRefObject$`reference`)) {
self$`reference` <- SpectraRefObject$`reference`
}
},
#' @description Serialize to JSON string.
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`ms_run`)) {
sprintf(
'"ms_run":
%d
',
rmzTabM::safe_unbox(self$`ms_run`)
)},
if (!is.null(self$`reference`)) {
sprintf(
'"reference":
"%s"
',
rmzTabM::safe_unbox(self$`reference`)
)}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
paste('{', jsoncontent, '}', sep = "")
},
#' @description Deserialize from JSON string
#' @param SpectraRefJson JSON string
fromJSONString = function(SpectraRefJson) {
SpectraRefObject <- jsonlite::fromJSON(SpectraRefJson)
self$`ms_run` <- MsRun$new()$fromJSONString(jsonlite::toJSON(SpectraRefObject$ms_run, auto_unbox = TRUE, null = "null", na = "null", digits = NA))
self$`reference` <- SpectraRefObject$`reference`
self
},
#' @description Serialize to string
toString = function() {
spectraRefStr <- ""
if (!is.null(self$`ms_run`) && !is.null(self$`reference`)) {
if (typeof(self$`ms_run`)=="double" || typeof(self$`ms_run`)=="integer") {
spectraRefStr <- paste0("ms_run[", self$`ms_run`, "]:", self$`reference`)
} else {
spectraRefStr <- paste0("ms_run[", self$`ms_run`$`id`, "]:", self$`reference`)
}
}
spectraRefStr
},
#' @description Deerialize from string
#' @param SpectraRefString The SpectraRef string representation.
fromString = function(SpectraRefString) {
split <- strsplit(SpectraRefString, ":", fixed=TRUE)
self$`ms_run` <- extractId(split[[1]][[1]], regexp = idElementRegexp)
self$`reference` <- split[[1]][[2]]
self
}
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.