`CVParam` objects instantiate controlled vocabulary entries.

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

# S4 method for class 'CVParam'
show(object)

# S4 method for class 'CVParam'
rep(x, times)

Arguments

label

`character(1)` with the ontology label. If missing, a user-defined parameter is created.

name

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

accession

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

value

`character(1)` with the value of the `CVParam` o be constructed. This argument is optional.

exact

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

object

`CVParam` object.

x

`CVParam` to be repeated.

times

`numeric(1)` defining the number of repetitions.

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 (prefix), `"ACCESSION"` is the term accession number, `"NAME"` is the term's name and `"VALUE"` is the value. Note that only the syntax validity is verified, not the semantics. See example below.

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

- `coerce(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.

Author

Laurent Gatto

Examples


## User param
CVParam(name = "A user param", value = "the value")
#> [, , A user param, the value] 
## CVParam ESI from PSI's Mass Spectrometry ontology
olsTerm("GO", "GO:0035145")
#> A olsTerm from the GO ontology: GO:0035145 
#>  Label: exon-exon junction complex
#>   A multi-subunit complex deposited by the spliceosome upstream of
#>   messenger RNA exon-exon junctions. The exon-exon junction complex
#>   provides a binding platform for factors involved in mRNA export and
#>   nonsense-mediated mRNA decay.
(eej <- CVParam(label = "GO", accession = "GO:0035145"))
#> [GO, GO:0035145, exon-exon junction complex, ] 
class(eej)
#> [1] "CVParam"
#> attr(,"package")
#> [1] "rols"

## From a CVParam object to a character
cv <- as(eej, "character")
cv ## note the quotes
#> [1] "[GO, GO:0035145, exon-exon junction complex, ]"

## From a character object to a CVParam
as(cv, "CVParam")
#> [GO, GO:0035145, exon-exon junction complex, ] 
as("[GO, GO:0035145, , ]", "CVParam") ## no name
#> [GO, GO:0035145, exon-exon junction complex, ] 
as("[GO, GO:0035145, exon-exon junction complex, ]", "CVParam")
#> [GO, GO:0035145, exon-exon junction complex, ] 
as(c(cv, cv), "CVParam") ## more than 1 character
#> [[1]]
#> [GO, GO:0035145, exon-exon junction complex, ] 
#> 
#> [[2]]
#> [GO, GO:0035145, exon-exon junction complex, ] 
#> 

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
#> [1] "[MS, MS:123 , , ]"      "[, , foo, bar]"         "[MS, MS:123, foo, bar]"
#> [4] "[MS, MS:123, , foo]"    "[MS, MS:123, foo, ]"   
rols:::notvalidCVchars
#>  [1] "[ , , , ]"         "[, , , ]"          "[ , , ,]"         
#>  [4] "[,,,]"             "[AB, MS:123 , , ]" "[, MS:123 , , ]"  
#>  [7] "[MS, AB:123, , ]"  "[, , foo, ]"       "[, , , bar]"      
#> [10] "[foo, , , ]"       "[, bar, , ]"       "[, foo, bar, ]"   
#> [13] "[MS, , , bar]"     "[MS, , foo, ]"