CVParam-class: Class '"CVParam"'

CVParam-classR Documentation

Class "CVParam"

Description

CVParam objects instantiate controlled vocabulary entries.

Usage

CVParam(label, name, accession, value, exact = TRUE)

Arguments

label

A character with the ontology label. If missing, a user-defined parameter is created.

name

A character with the name of the CVParam to be constructed. This argument can be omitted if accession is used and label is not missing.

accession

A character with the accession of the CVParam to be constructed. This argument can be omitted if name is used. Ignored for user-defined instances.

value

A character with the value of the CVParam to be constructed. This argument is optional.

exact

A logical defining whether the query to retrieve the accession (when name is used) should be an exact match.

Objects from the Class

Objects can be created with the CVParam constructor.

Slots

label:

Object of class "character" that defines the label of the instance, i.e the ontology abbreviation/prefix. See Ontologies to generate a list of available ontologies and olsPrefix for existing labels.

accession:

Object of class "character" with the parameter's valid label ontology accession number. See below for validity constrains.

name:

Object of class "character" with the instance's valid name, i.e matching with the accession. name and accession must follow term(accession, label) == name for the instance to be valid.

value:

Object of class "character" with the CVParams value, if applicable, of empty string ("") otherwise.

user:

Object of class "logical" defining if the instance is a user-defined parameter (also called User params).

.__classVersion__:

Object of class "Versions" describing the instance's class definition version. For development use.

Extends

Class "Versioned", directly.

Methods

charIsCVParam(x)

Checks if x, a character of the form "[ONTO, ACCESSION, NAME, VALUE]", is a valid (possibly user-defined) CVParam. "ONTO" is the ontology label (prefi), "ACCESSION" is the term accession number, "NAME" is the term's name and "VALUE" is the value. Note that only syntax validity is verified, not semantics. See example below.

Methods

coerce

signature(from = "CVParam", to = "character"): Coerces CVParam from to a character of the following form: [label, accession, name, value]. as.character is also defined.

coerce

signature(from = "character", to = "CVParam"): Coerces character from to a CVParam. as.CVParam is also defined. If a label is absent, the character is converted to a User param, else, the label and accession are used to query the Ontology Lookup Service (see OlsSearch)). If a name is provided and does not match the retrieved name, a warning is thrown.

This function is vectorised; if the from character is of length greater than 1, then a list of CVParam is returned. The queries to the OLS are processed one-by-one, though.

show

signature(object = "CVParam"): Prints the CVParam instance as text.

rep

signature(x = "CVParam", times = "numeric"): Replicates the CVParam x times times.

Author(s)

Laurent Gatto <lg390@cam.ac.uk>

Examples

## a user param
CVParam(name = "A user param", value = "the value")
## a CVParam from PSI's Mass Spectrometry ontology
term("MS", "MS:1000073")
CVParam(label = "MS", accession = "MS:1000073")

## From a CVParam object to a character
cv <- as(CVParam(label = "MS", accession = "MS:1000073"), "character")
cv

## From a character object to a CVParam
as(cv, "CVParam")
as("[MS, MS:1000073, , ]", "CVParam") ## no name
as("[MS, MS:1000073, ESI, ]", "CVParam") ## name does not match
as(c(cv, cv), "CVParam") ## more than 1 character

x <- c("[MS, MS:1000073, , ]", ## valid CV param
       "[, , Hello, world]",   ## valid User param
       "[this, one is, not, valid]", ## not valid
       "[ , , , ]") ## not valid

stopifnot(charIsCVParam(x) == c(TRUE, TRUE, FALSE, FALSE))

## A list of expected valid and non-valid entries
rols:::validCVchars
rols:::notvalidCVchars

lgatto/rols documentation built on Aug. 17, 2022, 5:35 a.m.