R/small_molecule_feature.R

# 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 SmallMoleculeFeature
#' @description SmallMoleculeFeature Class
#' @format An \code{R6Class} generator object
#' @field prefix  character [optional]
#'
#' @field header_prefix  character [optional]
#'
#' @field smf_id  integer 
#'
#' @field sme_id_refs  list( integer ) [optional]
#'
#' @field sme_id_ref_ambiguity_code  integer [optional]
#'
#' @field adduct_ion  character [optional]
#'
#' @field isotopomer  \link{Parameter} [optional]
#'
#' @field exp_mass_to_charge  numeric 
#'
#' @field charge  integer 
#'
#' @field retention_time_in_seconds  numeric [optional]
#'
#' @field retention_time_in_seconds_start  numeric [optional]
#'
#' @field retention_time_in_seconds_end  numeric [optional]
#'
#' @field abundance_assay  list( numeric ) [optional]
#'
#' @field opt  list( \link{OptColumnMapping} ) [optional]
#'
#' @field comment  list( \link{Comment} ) [optional]
#'
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
SmallMoleculeFeature <- R6::R6Class(
  'SmallMoleculeFeature',
  public = list(
    `prefix` = NULL,
    `header_prefix` = NULL,
    `smf_id` = NULL,
    `sme_id_refs` = NULL,
    `sme_id_ref_ambiguity_code` = NULL,
    `adduct_ion` = NULL,
    `isotopomer` = NULL,
    `exp_mass_to_charge` = NULL,
    `charge` = NULL,
    `retention_time_in_seconds` = NULL,
    `retention_time_in_seconds_start` = NULL,
    `retention_time_in_seconds_end` = NULL,
    `abundance_assay` = NULL,
    `opt` = NULL,
    `comment` = NULL,
    #' @description Create a new SmallMoleculeFeature.
    #' @param smf_id The small molecule feature id.
    #' @param exp_mass_to_charge The experimental mass to charge of the feature.
    #' @param charge The charge of the feature.
    #' @param prefix 'SMF'.
    #' @param header_prefix 'SFH'.
    #' @param sme_id_refs References by id to \link{SmallMoleculeEvidence}s.
    #' @param sme_id_ref_ambiguity_code Ambiguity code for SME id refs.
    #' @param adduct_ion The adduct ion.
    #' @param isotopomer The isotopomer.
    #' @param retention_time_in_seconds The feature's retention time in seconds.
    #' @param retention_time_in_seconds_start The feature's retention time start in seconds.
    #' @param retention_time_in_seconds_end The feature's retention time end in seconds.
    #' @param abundance_assay The abundances over all assays.
    #' @param opt Optional columns and values.
    #' @param comment Comments.
    #' @param ... local optional variable arguments.
    initialize = function(`smf_id`, `exp_mass_to_charge`, `charge`, `prefix`='SMF', `header_prefix`='SFH', `sme_id_refs`=NULL, `sme_id_ref_ambiguity_code`=NULL, `adduct_ion`=NULL, `isotopomer`=NULL, `retention_time_in_seconds`=NULL, `retention_time_in_seconds_start`=NULL, `retention_time_in_seconds_end`=NULL, `abundance_assay`=NULL, `opt`=NULL, `comment`=NULL, ...){
      local.optional.var <- list(...)
      if (!missing(`smf_id`)) {
        stopifnot(is.numeric(`smf_id`), length(`smf_id`) == 1)
        self$`smf_id` <- `smf_id`
      }
      if (!missing(`exp_mass_to_charge`)) {
        stopifnot(is.numeric(`exp_mass_to_charge`), length(`exp_mass_to_charge`) == 1)
        self$`exp_mass_to_charge` <- `exp_mass_to_charge`
      }
      if (!missing(`charge`)) {
        stopifnot(is.numeric(`charge`), length(`charge`) == 1)
        self$`charge` <- `charge`
      }
      if (!is.null(`prefix`)) {
        stopifnot(is.character(`prefix`), length(`prefix`) == 1)
        self$`prefix` <- `prefix`
      }
      if (!is.null(`header_prefix`)) {
        stopifnot(is.character(`header_prefix`), length(`header_prefix`) == 1)
        self$`header_prefix` <- `header_prefix`
      }
      if (!is.null(`sme_id_refs`)) {
        stopifnot(is.vector(`sme_id_refs`), length(`sme_id_refs`) != 0)
        sapply(`sme_id_refs`, function(x) stopifnot(is.numeric(x)))
        self$`sme_id_refs` <- `sme_id_refs`
      }
      if (!is.null(`sme_id_ref_ambiguity_code`)) {
        stopifnot(is.numeric(`sme_id_ref_ambiguity_code`), length(`sme_id_ref_ambiguity_code`) == 1)
        self$`sme_id_ref_ambiguity_code` <- `sme_id_ref_ambiguity_code`
      }
      if (!is.null(`adduct_ion`)) {
        stopifnot(is.character(`adduct_ion`), length(`adduct_ion`) == 1)
        self$`adduct_ion` <- `adduct_ion`
      }
      if (!is.null(`isotopomer`)) {
        stopifnot(R6::is.R6(`isotopomer`))
        self$`isotopomer` <- `isotopomer`
      }
      if (!is.null(`retention_time_in_seconds`)) {
        stopifnot(is.numeric(`retention_time_in_seconds`), length(`retention_time_in_seconds`) == 1)
        self$`retention_time_in_seconds` <- `retention_time_in_seconds`
      }
      if (!is.null(`retention_time_in_seconds_start`)) {
        stopifnot(is.numeric(`retention_time_in_seconds_start`), length(`retention_time_in_seconds_start`) == 1)
        self$`retention_time_in_seconds_start` <- `retention_time_in_seconds_start`
      }
      if (!is.null(`retention_time_in_seconds_end`)) {
        stopifnot(is.numeric(`retention_time_in_seconds_end`), length(`retention_time_in_seconds_end`) == 1)
        self$`retention_time_in_seconds_end` <- `retention_time_in_seconds_end`
      }
      if (!is.null(`abundance_assay`)) {
        stopifnot(is.vector(`abundance_assay`), length(`abundance_assay`) != 0)
        sapply(`abundance_assay`, function(x) stopifnot(is.character(x)))
        self$`abundance_assay` <- `abundance_assay`
      }
      if (!is.null(`opt`)) {
        stopifnot(is.vector(`opt`), length(`opt`) != 0)
        sapply(`opt`, function(x) stopifnot(R6::is.R6(x)))
        self$`opt` <- `opt`
      }
      if (!is.null(`comment`)) {
        stopifnot(is.vector(`comment`), length(`comment`) != 0)
        sapply(`comment`, function(x) stopifnot(R6::is.R6(x)))
        self$`comment` <- `comment`
      }
    },
    #' @description Serialize to list object suitable for jsonlite    
    toJSON = function() {
      SmallMoleculeFeatureObject <- list()
      if (!is.null(self$`prefix`)) {
        SmallMoleculeFeatureObject[['prefix']] <-
          rmzTabM::safe_unbox(self$`prefix`)
      }
      if (!is.null(self$`header_prefix`)) {
        SmallMoleculeFeatureObject[['header_prefix']] <-
          rmzTabM::safe_unbox(self$`header_prefix`)
      }
      if (!is.null(self$`smf_id`)) {
        SmallMoleculeFeatureObject[['smf_id']] <-
          rmzTabM::safe_unbox(self$`smf_id`)
      }
      if (!is.null(self$`sme_id_refs`)) {
        SmallMoleculeFeatureObject[['sme_id_refs']] <-
          unlist(self$`sme_id_refs`)
      }
      if (!is.null(self$`sme_id_ref_ambiguity_code`)) {
        SmallMoleculeFeatureObject[['sme_id_ref_ambiguity_code']] <-
          rmzTabM::safe_unbox(self$`sme_id_ref_ambiguity_code`)
      }
      if (!is.null(self$`adduct_ion`)) {
        SmallMoleculeFeatureObject[['adduct_ion']] <-
          rmzTabM::safe_unbox(self$`adduct_ion`)
      }
      if (!is.null(self$`isotopomer`)) {
        SmallMoleculeFeatureObject[['isotopomer']] <-
          rmzTabM::safe_unbox(self$`isotopomer`$toJSON())
      }
      if (!is.null(self$`exp_mass_to_charge`)) {
        SmallMoleculeFeatureObject[['exp_mass_to_charge']] <-
          rmzTabM::safe_unbox(self$`exp_mass_to_charge`)
      }
      if (!is.null(self$`charge`)) {
        SmallMoleculeFeatureObject[['charge']] <-
          rmzTabM::safe_unbox(self$`charge`)
      }
      if (!is.null(self$`retention_time_in_seconds`)) {
        SmallMoleculeFeatureObject[['retention_time_in_seconds']] <-
          rmzTabM::safe_unbox(self$`retention_time_in_seconds`)
      }
      if (!is.null(self$`retention_time_in_seconds_start`)) {
        SmallMoleculeFeatureObject[['retention_time_in_seconds_start']] <-
          rmzTabM::safe_unbox(self$`retention_time_in_seconds_start`)
      }
      if (!is.null(self$`retention_time_in_seconds_end`)) {
        SmallMoleculeFeatureObject[['retention_time_in_seconds_end']] <-
          rmzTabM::safe_unbox(self$`retention_time_in_seconds_end`)
      }
      if (!is.null(self$`abundance_assay`)) {
        SmallMoleculeFeatureObject[['abundance_assay']] <-
          rmzTabM::safe_unbox(self$`abundance_assay`)
      }
      if (!is.null(self$`opt`)) {
        SmallMoleculeFeatureObject[['opt']] <-
          lapply(self$`opt`, function(x) x$toJSON())
      }
      if (!is.null(self$`comment`)) {
        SmallMoleculeFeatureObject[['comment']] <-
          lapply(self$`comment`, function(x) x$toJSON())
      }

      SmallMoleculeFeatureObject
    },
    #' @description Deserialize from jsonlite list object
    #' @param SmallMoleculeFeatureJson list object.
    fromJSON = function(SmallMoleculeFeatureJson) {
      SmallMoleculeFeatureObject <- jsonlite::fromJSON(SmallMoleculeFeatureJson)
      if (!is.null(SmallMoleculeFeatureObject$`prefix`)) {
        self$`prefix` <- SmallMoleculeFeatureObject$`prefix`
      }
      if (!is.null(SmallMoleculeFeatureObject$`header_prefix`)) {
        self$`header_prefix` <- SmallMoleculeFeatureObject$`header_prefix`
      }
      if (!is.null(SmallMoleculeFeatureObject$`smf_id`)) {
        self$`smf_id` <- SmallMoleculeFeatureObject$`smf_id`
      }
      if (!is.null(SmallMoleculeFeatureObject$`sme_id_refs`)) {
        self$`sme_id_refs` <- ApiClient$new()$deserializeObj(SmallMoleculeFeatureObject$`sme_id_refs`, "array[integer]", loadNamespace("rmzTabM"))
      }
      if (!is.null(SmallMoleculeFeatureObject$`sme_id_ref_ambiguity_code`)) {
        self$`sme_id_ref_ambiguity_code` <- SmallMoleculeFeatureObject$`sme_id_ref_ambiguity_code`
      }
      if (!is.null(SmallMoleculeFeatureObject$`adduct_ion`)) {
        self$`adduct_ion` <- SmallMoleculeFeatureObject$`adduct_ion`
      }
      if (!is.null(SmallMoleculeFeatureObject$`isotopomer`)) {
        isotopomerObject <- Parameter$new()
        isotopomerObject$fromJSON(jsonlite::toJSON(SmallMoleculeFeatureObject$isotopomer, auto_unbox = TRUE, null = "null", na = "null", digits = NA))
        self$`isotopomer` <- isotopomerObject
      }
      if (!is.null(SmallMoleculeFeatureObject$`exp_mass_to_charge`)) {
        self$`exp_mass_to_charge` <- SmallMoleculeFeatureObject$`exp_mass_to_charge`
      }
      if (!is.null(SmallMoleculeFeatureObject$`charge`)) {
        self$`charge` <- SmallMoleculeFeatureObject$`charge`
      }
      if (!is.null(SmallMoleculeFeatureObject$`retention_time_in_seconds`)) {
        self$`retention_time_in_seconds` <- SmallMoleculeFeatureObject$`retention_time_in_seconds`
      }
      if (!is.null(SmallMoleculeFeatureObject$`retention_time_in_seconds_start`)) {
        self$`retention_time_in_seconds_start` <- SmallMoleculeFeatureObject$`retention_time_in_seconds_start`
      }
      if (!is.null(SmallMoleculeFeatureObject$`retention_time_in_seconds_end`)) {
        self$`retention_time_in_seconds_end` <- SmallMoleculeFeatureObject$`retention_time_in_seconds_end`
      }
      if (!is.null(SmallMoleculeFeatureObject$`abundance_assay`)) {
        self$`abundance_assay` <- ApiClient$new()$deserializeObj(SmallMoleculeFeatureObject$`abundance_assay`, "array[numeric]", loadNamespace("rmzTabM"))
      }
      if (!is.null(SmallMoleculeFeatureObject$`opt`)) {
        self$`opt` <- ApiClient$new()$deserializeObj(SmallMoleculeFeatureObject$`opt`, "array[OptColumnMapping]", loadNamespace("rmzTabM"))
      }
      if (!is.null(SmallMoleculeFeatureObject$`comment`)) {
        self$`comment` <- ApiClient$new()$deserializeObj(SmallMoleculeFeatureObject$`comment`, "array[Comment]", loadNamespace("rmzTabM"))
      }
    },
    #' @description Serialize to JSON string.
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`prefix`)) {
        sprintf(
        '"prefix":
          "%s"
                ',
        rmzTabM::safe_unbox(self$`prefix`)
        )},
        if (!is.null(self$`header_prefix`)) {
        sprintf(
        '"header_prefix":
          "%s"
                ',
        rmzTabM::safe_unbox(self$`header_prefix`)
        )},
        if (!is.null(self$`smf_id`)) {
        sprintf(
        '"smf_id":
          %d
                ',
        rmzTabM::safe_unbox(self$`smf_id`)
        )},
        if (!is.null(self$`sme_id_refs`)) {
        sprintf(
        '"sme_id_refs":
           %s
        ',
        paste(unlist(lapply(self$`sme_id_refs`, function(x) paste0(x))), collapse=",")
        )},
        if (!is.null(self$`sme_id_ref_ambiguity_code`)) {
        sprintf(
        '"sme_id_ref_ambiguity_code":
          %d
                ',
        rmzTabM::safe_unbox(self$`sme_id_ref_ambiguity_code`)
        )},
        if (!is.null(self$`adduct_ion`)) {
        sprintf(
        '"adduct_ion":
          "%s"
                ',
        rmzTabM::safe_unbox(self$`adduct_ion`)
        )},
        if (!is.null(self$`isotopomer`)) {
        sprintf(
        '"isotopomer":
        %s
        ',
        jsonlite::toJSON(self$`isotopomer`$toJSON(), auto_unbox=FALSE, null = "null", na = "null", digits = NA)
        )},
        if (!is.null(self$`exp_mass_to_charge`)) {
        sprintf(
        '"exp_mass_to_charge":
          %f
                ',
        rmzTabM::safe_unbox(self$`exp_mass_to_charge`)
        )},
        if (!is.null(self$`charge`)) {
        sprintf(
        '"charge":
          %d
                ',
        rmzTabM::safe_unbox(self$`charge`)
        )},
        if (!is.null(self$`retention_time_in_seconds`)) {
        sprintf(
        '"retention_time_in_seconds":
          %f
                ',
        rmzTabM::safe_unbox(self$`retention_time_in_seconds`)
        )},
        if (!is.null(self$`retention_time_in_seconds_start`)) {
        sprintf(
        '"retention_time_in_seconds_start":
          %f
                ',
        rmzTabM::safe_unbox(self$`retention_time_in_seconds_start`)
        )},
        if (!is.null(self$`retention_time_in_seconds_end`)) {
        sprintf(
        '"retention_time_in_seconds_end":
          %f
                ',
        rmzTabM::safe_unbox(self$`retention_time_in_seconds_end`)
        )},
        if (!is.null(self$`abundance_assay`)) {
        sprintf(
        '"abundance_assay":
           [%s]
        ',
        paste(unlist(lapply(self$`abundance_assay`, function(x) paste0('"', x, '"'))), collapse=",")
        )},
        if (!is.null(self$`opt`)) {
        sprintf(
        '"opt":
        [%s]
',
        paste(sapply(self$`opt`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=FALSE, null = "null", na = "null", digits = NA)), collapse=",")
        )},
        if (!is.null(self$`comment`)) {
        sprintf(
        '"comment":
        [%s]
',
        paste(sapply(self$`comment`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=FALSE, null = "null", na = "null", digits = NA)), collapse=",")
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    #' @description Deserialize from JSON string
    #' @param SmallMoleculeFeatureJson SmallMoleculeFeatureJson string
    fromJSONString = function(SmallMoleculeFeatureJson) {
      SmallMoleculeFeatureObject <- jsonlite::fromJSON(SmallMoleculeFeatureJson)
      self$`prefix` <- SmallMoleculeFeatureObject$`prefix`
      self$`header_prefix` <- SmallMoleculeFeatureObject$`header_prefix`
      self$`smf_id` <- SmallMoleculeFeatureObject$`smf_id`
      self$`sme_id_refs` <- ApiClient$new()$deserializeObj(SmallMoleculeFeatureObject$`sme_id_refs`, "array[integer]", loadNamespace("rmzTabM"))
      self$`sme_id_ref_ambiguity_code` <- SmallMoleculeFeatureObject$`sme_id_ref_ambiguity_code`
      self$`adduct_ion` <- SmallMoleculeFeatureObject$`adduct_ion`
      self$`isotopomer` <- Parameter$new()$fromJSONString(jsonlite::toJSON(SmallMoleculeFeatureObject$isotopomer, auto_unbox = TRUE, null = "null", na = "null", digits = NA))
      self$`exp_mass_to_charge` <- SmallMoleculeFeatureObject$`exp_mass_to_charge`
      self$`charge` <- SmallMoleculeFeatureObject$`charge`
      self$`retention_time_in_seconds` <- SmallMoleculeFeatureObject$`retention_time_in_seconds`
      self$`retention_time_in_seconds_start` <- SmallMoleculeFeatureObject$`retention_time_in_seconds_start`
      self$`retention_time_in_seconds_end` <- SmallMoleculeFeatureObject$`retention_time_in_seconds_end`
      self$`abundance_assay` <- ApiClient$new()$deserializeObj(SmallMoleculeFeatureObject$`abundance_assay`, "array[numeric]", loadNamespace("rmzTabM"))
      self$`opt` <- ApiClient$new()$deserializeObj(SmallMoleculeFeatureObject$`opt`, "array[OptColumnMapping]", loadNamespace("rmzTabM"))
      self$`comment` <- ApiClient$new()$deserializeObj(SmallMoleculeFeatureObject$`comment`, "array[Comment]", loadNamespace("rmzTabM"))
      self
    },
    #' @description Serialize to data frame
    toDataFrame = function() {
      fixed_header_values <- c(
        "SFH"=self$`prefix`,
        "SMF_ID"=self$`smf_id`,	
        "SME_ID_REFS"=valueOrDefault(unlist(self$`sme_id_refs`), FUN=paste, collapse="|"),
        "SME_ID_REF_ambiguity_code"=valueOrDefault(self$`sme_id_ref_ambiguity_code`),
        "adduct_ion"=valueOrDefault(self$`adduct_ion`),
        "isotopomer"=valueOrDefault(self$`isotopomer`, FUN=function(x){x$toString()}),
        "exp_mass_to_charge"=valueOrDefault(self$`exp_mass_to_charge`),
        "charge"=valueOrDefault(self$`charge`),
        "retention_time_in_seconds"=valueOrDefault(self$`retention_time_in_seconds`),
        "retention_time_in_seconds_start"=valueOrDefault(self$`retention_time_in_seconds_start`),
        "retention_time_in_seconds_end"=valueOrDefault(self$`retention_time_in_seconds_end`)
      )
      abundance_assay <-
        unlist(lapply(seq_along(self$`abundance_assay`), function(idx, x) {
          paste0("abundance_assay[", idx, "]")
        }, x = self$`abundance_assay`))
      abundance_assay_values <-
        unlist(lapply(seq_along(self$`abundance_assay`), function(idx, x) {
          valueOrDefault(x)
        }, x = self$`abundance_assay`))
      names(abundance_assay_values) <- abundance_assay
      
      opt <-
        unlist(lapply(self$`opt`, function(x) {
          x$toString()
        }))
      opt_values <- 
        unlist(lapply(self$`opt`, function(x) {
          valueOrDefault(x$`value`)
        }))
      names(opt_values) <- opt
      entries <-
        as.data.frame(
          t(
            c(
              fixed_header_values,
              abundance_assay_values,
              opt_values
            )
          )
        )
      entries
    },
    #' @description Deserialize from feature data frame
    #' @param FeatureDataFrame Feature data frame
    fromDataFrame = function(FeatureDataFrame) {
      stopifnot(nrow(FeatureDataFrame)==1)
      columnNames <- colnames(FeatureDataFrame)
      self$`prefix` <- "SMF"
      self$`header_prefix` <- "SFH"
      if (rlang::has_name(FeatureDataFrame, "smf_id")) {
        self$`smf_id` <- as.numeric(FeatureDataFrame$`smf_id`)
      }
      if (rlang::has_name(FeatureDataFrame, "SMF_ID")) {
        self$`smf_id` <- as.numeric(FeatureDataFrame$`SMF_ID`)
      }
      if (rlang::has_name(FeatureDataFrame, "sme_id_refs")) {
        refList <- splitList(FeatureDataFrame$`sme_id_refs`)
        self$`sme_id_refs` <- lapply(refList, function(x) {
          extractId(x)  
        })
      }
      if (rlang::has_name(FeatureDataFrame, "SME_ID_REFS")) {
        refList <- splitList(FeatureDataFrame$`SME_ID_REFS`)
        self$`sme_id_refs` <- lapply(refList, function(x) {
          extractId(x)  
        })
      }
      if (rlang::has_name(FeatureDataFrame, "sme_id_ref_ambiguity_code")) {
        self$`sme_id_ref_ambiguity_code` <- FeatureDataFrame$`sme_id_ref_ambiguity_code`
      }
      if (rlang::has_name(FeatureDataFrame, "SME_ID_REF_ambiguity_code")) {
        self$`sme_id_ref_ambiguity_code` <- FeatureDataFrame$`SME_ID_REF_ambiguity_code`
      }
      if (rlang::has_name(FeatureDataFrame, "adduct_ion")) {
        self$`adduct_ion` <- FeatureDataFrame$`adduct_ion`
      }
      if (rlang::has_name(FeatureDataFrame, "isotopomer")) {
        param <- Parameter$new()
        self$`isotopomer` <- param$fromString(NULL, FeatureDataFrame$`isotopomer`)
      }
      if (rlang::has_name(FeatureDataFrame, "exp_mass_to_charge")) {
        self$`exp_mass_to_charge` <- as.numeric(FeatureDataFrame$`exp_mass_to_charge`)
      }
      if (rlang::has_name(FeatureDataFrame, "charge")) {
        self$`charge` <- as.numeric(FeatureDataFrame$`charge`)
      }
      if (rlang::has_name(FeatureDataFrame, "retention_time_in_seconds")) {
        self$`retention_time_in_seconds` <- FeatureDataFrame$`retention_time_in_seconds`
      }
      if (rlang::has_name(FeatureDataFrame, "retention_time_in_seconds_start")) {
        self$`retention_time_in_seconds_start` <- FeatureDataFrame$`retention_time_in_seconds_start`
      }
      if (rlang::has_name(FeatureDataFrame, "retention_time_in_seconds_end")) {
        self$`retention_time_in_seconds_end` <- FeatureDataFrame$`retention_time_in_seconds_end`
      }
      abundance_assay_df <- FeatureDataFrame %>% dplyr::select(dplyr::starts_with("abundance_assay"))
      if (!is.null(dim(abundance_assay_df)) && dim(abundance_assay_df)[1] > 0) {
        self$`abundance_assay` <- lapply(abundance_assay_df, function(x) {
          as.numeric(x)
        })
      }
      # TODO opt handling
      # self$`opt` <- ApiClient$new()$deserializeObj(SmallMoleculeFeatureObject$`opt`, "array[OptColumnMapping]", loadNamespace("rmzTabM"))
      
      opt_cols <- FeatureDataFrame %>% dplyr::select(dplyr::starts_with("opt_"))
      if (!is.null(dim(opt_cols)) && dim(opt_cols)[1] > 0) {
        warning("Handling of Optional columns not yet implemented")
      }
      
      if (rlang::has_name(FeatureDataFrame, "comment")) {
        comment <- Comment$new()
        browser()
        self$`comment` <- comment$fromDataFrame(FeatureDataFrame$`comment`)
      }
      self
    }
  )
)
lifs-tools/rmzTab-m documentation built on Jan. 26, 2023, 4:45 p.m.