| MetadataActionTranslate | R Documentation |
Metadata action: translate
Metadata action: translate
Performs a dictionary-style translation action for an entry.
In the reading direction, multiple entries may be mapped to one output value;
in the writing direction, a single value needs to be specified.
If coalesce is set, untranslated values will be copied verbatim.
SpectraMapping::MetadataActionBase -> MetadataActionTranslate
process_read()read implementation
MetadataActionTranslate$process_read(data, params)
dataMsBackendMapping to execute the metadata mapping step on
paramsList of parameters for a single action (one params entry fully merged.)
process_write()write implementation
MetadataActionTranslate$process_write(data, params)
dataMsBackendMapping to execute the metadata mapping step on
paramsList of parameters for a single action (one params entry fully merged.)
clone()The objects of this class are cloneable with this method.
MetadataActionTranslate$clone(deep = FALSE)
deepWhether to make a deep clone.
backend <- get_proto_backend(MS_TYPE = c("POSITIVE", "P", "n", "gugus", NA))
action <- get_proto_action(
"translate",
source = "MS_TYPE",
target = "*msLevel",
dictionary = list(
list(value = 1, read = c("POSITIVE", "P", "p", "pos"), write = "POSITIVE"),
list(value = 0, read = c("NEGATIVE", "N", "n", "neg"), write = "NEGATIVE")
)
)
fw <- action$execute_read(backend)
fw@variables <- fw@variables %>% select(-MS_TYPE)
# Example with `coalesce`:
# Note that `coalesce` only works when source and destination type are equal.
backend <- get_proto_backend(MS_TYPE = c("POSITIVE", "P", "n", "gugus", NA))
action <- get_proto_action(
"translate",
source = "MS_TYPE",
target = "*msLevel",
coalesce = TRUE,
dictionary = list(
list(value = "1", read = c("POSITIVE", "P", "p", "pos"), write = "POSITIVE"),
list(value = "0", read = c("NEGATIVE", "N", "n", "neg"), write = "NEGATIVE")
)
)
fw <- action$execute_read(backend)
fw@variables <- fw@variables %>% select(-MS_TYPE)
bw <- action$execute_write(fw)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.