Skip to contents

This function converts monosaccharide types of monosaccharide characters, glycan compositions, or glycan structures. Supported types: "concrete" and "generic" (see details below). The conversion can only be done from "concrete" to "generic".

Usage

convert_mono_type(x, to)

# S3 method for class 'character'
convert_mono_type(x, to)

# S3 method for class 'glyrepr_structure'
convert_mono_type(x, to)

# S3 method for class 'glyrepr_composition'
convert_mono_type(x, to)

Arguments

x

Either of these objects:

  • A character of monosaccharide;

  • A glycan composition vector ("glyrepr_composition" object);

  • A glycan structure vector ("glyrepr_structure" object).

to

A character string specifying the target monosaccharide type.

Value

A new object of the same class as x with monosaccharides converted to the target type.

Two types of monosaccharides

There are two types of monosaccharides:

  • concrete: e.g. "Gal", "GlcNAc", "Glc", "Fuc", etc.

  • generic: e.g. "Hex", "HexNAc", "HexA", "HexN", etc.

For the full list of monosaccharides, use available_monosaccharides().

Examples

# Allowed
convert_mono_type(c("Gal", "GlcNAc"), to = "generic")  # concrete -> generic
#> [1] "Hex"    "HexNAc"

# Not allowed
if (FALSE) { # \dontrun{
convert_mono_type(c("Hex", "HexNAc"), to = "concrete")  # generic -> concrete
} # }

# Convert glycan compositions
comps <- glycan_composition(
  c(Hex = 5, HexNAc = 2),
  c(Hex = 5, HexNAc = 4, dHex = 1)
)
convert_mono_type(comps, to = "generic")
#> <glycan_composition[2]>
#> [1] Hex(5)HexNAc(2)
#> [2] Hex(5)HexNAc(4)dHex(1)

# Convert glycan structures
strucs <- glycan_structure(
  n_glycan_core(),
  o_glycan_core_1()
)
convert_mono_type(strucs, to = "generic")
#> <glycan_structure[2]>
#> [1] Hex(a1-3)[Hex(a1-6)]Hex(b1-4)HexNAc(b1-4)HexNAc(?1-
#> [2] Hex(b1-3)HexNAc(a1-
#> # Unique structures: 2