Linear Code¶
A module for operating on GlycoMinds Linear Code
Assumes that the structure’s root is the right-most residue, as shown in A Novel Linear Code Nomenclature for Complex Carbohydrates, Banin et al..
Currently does not handle the sigils indicating deviation from the common forms.
-
glypy.io.linear_code.
dumps
(structure)¶ Common alias for
to_linear_code()
-
glypy.io.linear_code.
get_relevant_substituents
(residue)[source]¶ Retrieve the set of substituents not implicitly included in the base type’s symbol name.
-
glypy.io.linear_code.
glycan_to_linear_code
(structure=None, max_tolerance=3)[source]¶ Translate a
Glycan
structure into Linear Code. Called fromto_linear_code()
. Recursively operates on branches.Parameters: structure: Glycan or Monosaccharide
The glycan to be translated. Translation starts from
glycan.root
ifstructure
is aGlycan
.max_tolerance: int
The maximum amount of deviance to allow when translating
Monosaccharide
objects into nomenclature symbolsReturns: deque
-
glypy.io.linear_code.
loads
(text)¶ Common alias for
parse_linear_code()
-
glypy.io.linear_code.
monosaccharide_from_linear_code
(residue_str, parent=None)[source]¶ Helper function for
parse_linear_code()
. Given a residue string of the form “(base_type)(anomer)(outedge?)([substituents]?)”, construct aMonosaccharide
object. Ifparent
is notNone
, connect the resultingMonosaccharide
toparent
atoutedge
.
-
glypy.io.linear_code.
monosaccharide_to_linear_code
(monosaccharide, max_tolerance=3)[source]¶ Perform iteratively permissive attempts to translate
monosaccharide
into a nomenclature symbol.Note
Uses a multi-pass approach. Could alternatively do a single pass and keep the best match.
Parameters: monosaccharide: Monosaccharide
The residue to be translated
max_tolerance: int
The maximum error tolerance to allow while looking for a match
Returns: str
Raises: ValueError:
When no suitable translation can be found
KeyError:
When an unknown symbol is encountered
-
glypy.io.linear_code.
monosaccharides_from
= {'A': 'Gal', 'NJ': 'NeuGc', 'B': 'Rib', 'E': 'Fru', 'NN': 'NeuAc', 'G': 'Glc', 'F': 'Fuc', 'I': 'IdoA', 'H': 'Rha', 'K': 'KDN', 'M': 'Man', 'L': 'GalA', 'O': 'All', 'N': 'Neu', 'P': 'Api', 'R': 'Ara', 'U': 'GlcA', 'W': 'Kdo', 'GN': 'GlcNAc', 'X': 'Xyl', 'AN': 'GalNAc'}¶ A mapping from symbol to common monosaccharide name
-
glypy.io.linear_code.
monosaccharides_to
= OrderedDict([('Glc', 'G'), ('Gal', 'A'), ('GlcNAc', 'GN'), ('GalNAc', 'AN'), ('Man', 'M'), ('Neu', 'N'), ('NeuAc', 'NN'), ('NeuGc', 'NJ'), ('KDN', 'K'), ('Kdo', 'W'), ('GalA', 'L'), ('IdoA', 'I'), ('Rha', 'H'), ('Fuc', 'F'), ('Xyl', 'X'), ('Rib', 'B'), ('Ara', 'R'), ('GlcA', 'U'), ('All', 'O'), ('Api', 'P'), ('Fru', 'E')])¶ A mapping from common monosaccharide names to their symbol, ordered by priority
-
glypy.io.linear_code.
parse_linear_code
(text)[source]¶ Parse the character string
text
, extracting GlycoMinds Linear Code-format carbohydrate structures, converting them into aGlycan
object.Note
Assumes that the structure’s root is the right-most residue
Supports only concrete structures.
Parameters: text: str
The string to be parsed
Returns: Glycan
Raises: LinearCodeError:
When an error is encountered while parsing resulting from malformed syntax or structure
ValueError:
When a symbol is encountered for which no suitable translation could be found
KeyError:
When an unknown symbol is encountered
-
glypy.io.linear_code.
priority
(sym)[source]¶ Calculate the branching priority for a given symbol or
Monosaccharide
. Used when deciding when a residue is considered branch or backbone.Parameters: sym: str or Monosaccharide Returns: int
-
glypy.io.linear_code.
substituent_to_linear_code
(substituent, position=None)[source]¶ Translate a
Substituent
to Linear Code. Include’s the substituent’s position if it is known.Parameters: substituents: Substituent or str
The structure or the name to translate
position:
The position of the structure to try including
Returns: str
Raises: KeyError:
When an unknown symbol is encountered
-
glypy.io.linear_code.
substituents_from
= {'ME': 'methyl', 'P': 'phosphate', 'PYR': 'pyruvate', 'PE': 'ethanolominephosphate', 'N': 'n_acetyl', 'Q': 'amino', 'PC': 'phosphocholine', 'S': 'sulfate', 'SH': 'sulfide', 'T': 'o_acetyl', 'IN': 'inositol', 'EP': '2-aminoethylphosphonic acid'}¶ A mapping from symbol to common substituent names
-
glypy.io.linear_code.
substituents_to
= {'methyl': 'ME', 'pyruvate': 'PYR', 'n_acetyl': 'N', 'sulfide': 'SH', 'o_acetyl': 'T', 'inositol': 'IN', 'amino': 'Q', 'phosphocholine': 'PC', 'ethanolominephosphate': 'PE', 'sulfate': 'S', '2-aminoethylphosphonic acid': 'EP', 'phosphate': 'P'}¶ A mapping from common substituent names to symbol