structure_to_iupac: Convert Glycan Structure to IUPAC-like Sequence

View source: R/structure-to-iupac.R

structure_to_iupacR Documentation

Convert Glycan Structure to IUPAC-like Sequence

Description

Convert a glycan structure vector or one glycan igraph to a sequence representation in the form of mono(linkage)mono, with branches represented by square brackets []. The backbone is chosen as the longest path, and for branches, linkages are ordered lexicographically with smaller linkages on the backbone.

Usage

structure_to_iupac(glycan)

Arguments

glycan

A glyrepr_structure vector or one glycan igraph.

Value

A character vector for structure-vector input, or one unnamed character scalar for graph input.

Sequence Format

The sequence follows the format mono(linkage)mono, where:

  • mono: monosaccharide name with optional substituents (e.g., Glc, GlcNAc, Glc3Me)

  • linkage: glycosidic linkage (e.g., b1-4, a1-3)

  • Branches are enclosed in square brackets []

  • Substituents are appended directly to monosaccharide names (e.g., Glc3Me for Glc with 3Me substituent)

  • An alditol reducing end has an -ol suffix before its reducing-end annotation (e.g., ⁠GlcNAc-ol(a1-⁠)

Backbone Selection

The backbone is selected as the longest path in the tree. For branches, the same rule applies recursively.

Linkage Comparison

Linkages are compared lexicographically:

  1. First by anomeric configuration: ? > b > a

  2. Then by first position: ? > numbers (numerically)

  3. Finally by second position: ? > numbers (numerically)

Smaller linkages are placed on the backbone, larger ones in branches.

For graph input, structure_to_iupac() validates and canonicalizes a copy of the graph before generating the sequence. Use graph_to_iupac() when the graph is already valid and canonical and the lower-level trusted-input path is desired.

Examples

# Simple linear structure
structure_to_iupac(o_glycan_core_1())

# Branched structure
structure_to_iupac(n_glycan_core())

# Structure with substituents
graph <- igraph::make_graph(~ 1-+2)
igraph::V(graph)$mono <- c("Glc", "GlcNAc")
igraph::V(graph)$sub <- c("3Me", "6Ac")
igraph::E(graph)$linkage <- "b1-4"
graph$anomer <- "a1"
glycan <- glycan_structure(graph)
structure_to_iupac(glycan)  # Returns "GlcNAc6Ac(b1-4)Glc3Me(a1-"
structure_to_iupac(graph)
structure_to_iupac(as_glycan_structure("GlcNAc-ol(a1-"))

# Vectorized structures
structs <- c(o_glycan_core_1(), n_glycan_core())
structure_to_iupac(structs)


glyrepr documentation built on Sept. 22, 2026, 5:09 p.m.