Utilities and commonly reused generics

glypy reuses several common structures and functions throughout the library. Some of these features are intended to be internal only. Those that affect the object interfaces that users see are described here.

User-Facing Utilities

glypy.utils.base.root(structure)[source]

A generic method for obtaining the root of a structure representing or containing a glycan graph with a single distinct root.

Implementing objects should provide a __root__ method that returns a Monosaccharide object.

Parameters

structure (any) – An object that implements the root protocol, containing a tree structure somewhere inside it.

Returns

Monosaccharide

Return type

The root of the Glycan tree

Raises

RootProtocolNotSupportedError

glypy.utils.base.tree(structure)[source]

A generic method for obtaining the Glycan of a structure representing or containing a glycan graph.

Implementing objects should provide a __tree__ method that returns a Glycan object.

Parameters

structure (any) – An object that implements the tree protocol, containing a tree structure somewhere inside it.

Return type

Glycan

Raises

TreeProtocolNotSupportedError

Error Types

exception glypy.utils.base.RootProtocolNotSupportedError[source]

A subclass of TypeError that signals that the provided type does not support the __root__ protocol.

exception glypy.utils.base.TreeProtocolNotSupportedError[source]

A subclass of TypeError that signals that the provided type does not support the __tree__ protocol.

Enum Type Implementation

class glypy.utils.enum.EnumMeta
class glypy.utils.enum.EnumValue

Represents a wrapper around an value with a name to identify it and more rich comparison logic. A value of an enumerated type

Multimap Implementation

Monosaccharide and Substituent objects’ store position-specific infomration about links and modifiers using a Mapping-like object that allows a key to be used to designate multiple values. These are usually OrderedMultiMap objects, which remember the order in which keys were added to them. These types are implemented in the glypy.utils.multimap module.

class glypy.utils.multimap.MultiMap(**kwargs)[source]
class glypy.utils.multimap.OrderedMultiMap(**kwargs)[source]

Implements a simple MultiMap data structure on top of a dictionary of lists that remembers the order keys were first inserted in.