Glycan¶
Represent polysaccharide molecules and their associated functions
Represent a sugar graph with pseudo-directed edges.
-
glypy.structure.glycan.
fragment_to_substructure
(fragment, tree)[source]¶ Extract the substructure of
tree
which is contained infragment
>>> from glypy import glycans as glycan_factory >>> from glypy.structure import glycan >>> n_linked_core = glycan_factory["N-Linked Core"] >>> frag = n_linked_core.fragments().next() >>> frag <Fragment mass=221.089937203 kind=Y included_nodes=set([1]) link_ids={1: ('', 'Y')} name=Y1 crossring_cleavages={} score=0.0 composition=Composition({'H': 15, 'C': 8, 'O': 6, 'N': 1})> >>> glycan.fragment_to_substructure(frag, n_linked_core) RES 1b:b-dglc-HEX-1:5 2s:n-acetyl LIN 1:1d(2+1)2n >>>
Parameters: fragment: Fragment
The
Fragment
to extract substructure for.tree: Glycan
The
Glycan
to extract substructure from.Returns: Glycan:
The
Glycan
substructure defined by the nodes contained infragment
as found intree
-
class
glypy.structure.glycan.
Glycan
(root=None, index_method='dfs')[source]¶ Bases:
glypy.structure.base.SaccharideCollection
Represents a full graph of connected
Monosaccharide
objects and their connecting bonds.Attributes
root: Monosaccharide
The first monosaccharide unit of the glycan, and the reducing end if present. index: list
A list of the Monosaccharide
instances inself
in the order they are encountered by traversal bytraversal_methods[index_method]
link_index: list
A list of the Link
connecting theMonosaccharide
instances inself
in the order they are encountered by traversal bytraversal_methods[index_method]
reducing_end: ReducedEnd
orNone
The reducing end on root
.branch_lengths: dict
A dictionary mapping branch symbols to their lengths -
__eq__
(other)[source]¶ Two glycans are considered equal if they are identically ordered nodes.
Parameters: self, other: :class:`~glypy.structure.glycan.Glycan` Returns: bool See also
glypy.structure.Monosaccharide.exact_ordering_equality()
-
__init__
(root=None, index_method='dfs')[source]¶ Constructs a new Glycan from the collection of connected
Monosaccharide
objects rooted atroot
.If index_method is not
None
, the graph is indexed by the default search method given bytraversal_methods[index_method]
-
breadth_first_traversal
(from_node=None, apply_fn=<function identity at 0x00000000081CCE48>, visited=None)[source]¶ Make a breadth-first traversal of the glycan graph. Children are explored in descending bond-order.
bfs()
is an alias of this method. Both names can be used to specify this strategy to_get_traversal_method()
.Parameters: from_node: None or Monosaccharide
If
from_node
isNone
, then traversal starts from the root node. Otherwise it begins from the given node.apply_fn: function
A function applied to each node on arrival. If this function returns a non-None value, the result is yielded from the generator, otherwise it is ignored. Defaults to
identity()
visited: set or None
Yields: Return Value of
apply_fn
, by defaultMonosaccharide
See also
-
break_links_subtrees
(n_links)[source]¶ Iteratively generate all subtrees from glycosidic bond cleavages, creating all 2{L \choose n} subtrees.
Parameters: n_links : int
Number of links to break simultaneously
Yields: Subtree
-
clone
(index_method='dfs', visited=None, cls=None)[source]¶ Create a copy of
self
, indexed usingindex_method
, a traversal method orNone
.Returns: Glycan
-
crossring_subtrees
(n_links)[source]¶ Generate all combinations of cross ring fragments and glycosidic cleavages, cleaving between 1 and
n_links
monosaccharides paired withn_links
- 1 to 0 glycosidic cleavages.Parameters: n_links : int
Total number of breaks to create, between cross ring cleavages and complemenatary glycosidic cleavages.
Yields: Subtree
-
deindex
()[source]¶ When combining two Glycan structures, very often their component ids will overlap, making it impossible to differentiate between a cycle and the new graph. This function mangles all of the node and link ids so that they are distinct from the pre-existing nodes.
-
depth_first_traversal
(from_node=None, apply_fn=<function identity at 0x00000000081CCE48>, visited=None)[source]¶ Make a depth-first traversal of the glycan graph. Children are explored in descending bond-order.
This is the default traversal method for all
Glycan
objects.dfs()
is an alias of this method. Both names can be used to specify this strategy to_get_traversal_method()
.Parameters: from_node: None or Monosaccharide
If
from_node
isNone
, then traversal starts from the root node. Otherwise it begins from the given node.apply_fn: function
A function applied to each node on arrival. If this function returns a non-None value, the result is yielded from the generator, otherwise it is ignored. Defaults to
identity()
visited: set or None
Yields: Return Value of
apply_fn
, by defaultMonosaccharide
See also
-
exact_ordering_equality
(other)¶ Two glycans are considered equal if they are identically ordered nodes.
Parameters: self, other: :class:`~glypy.structure.glycan.Glycan` Returns: bool See also
glypy.structure.Monosaccharide.exact_ordering_equality()
-
fragments
(kind='BY', max_cleavages=1, average=False, charge=0, mass_data=None, traversal_method='dfs')[source]¶ Generate carbohydrate backbone fragments from this glycan by examining the disjoint subtrees created by removing one or more monosaccharide-monosaccharide bond.
Parameters: kind: `sequence`
Any
iterable
orsequence
of characters corresponding to A/B/C/X/Y/Z as published by Domon and Costellomax_cleavages: |int|
The maximum number of bonds to break per fragment
average: bool, optional, defaults to `False`
Whether or not to use the average isotopic composition when calculating masses. When
average == False
, masses are calculated using monoisotopic mass.charge: int, optional, defaults to 0
If charge is non-zero, m/z is calculated, where m is the theoretical mass, and z is
charge
mass_data: dict, optional, defaults to `None`
If mass_data is
None
, standard NIST mass and isotopic abundance data are used. Otherwise the contents ofmass_data
are assumed to contain elemental mass and isotopic abundance information.Yields: Fragment
See also
glypy.composition.composition.calculate_mass()
,subtrees()
,crossring_subtrees()
,Subtree.to_fragments()
-
iterlinks
(apply_fn=<function identity at 0x00000000081CCE48>, substituents=False, method='dfs', visited=None)[source]¶ Iterates over all
Link
objects inGlycan
.Parameters: substituents: bool
If
substituents
isTrue
, then include theLink
objects insubstituent_links
on eachMonosaccharide
method: str or function
The traversal method controlling the order of the nodes visited
visited: None or set
The collection of id values to ignore when traversing
Yields: Link
-
iternodes
(from_node=None, apply_fn=<function identity at 0x00000000081CCE48>, method='dfs', visited=None)[source]¶ Generic iterator over nodes.
Glycan.__iter__()
is an alias of this methodParameters: from_node: None or Monosaccharide
If
from_node
isNone
, then traversal starts from the root node. Otherwise it begins from the given node.apply_fn: function
A function applied to each node on arrival. If this function returns a non-None value, the result is yielded from the generator, otherwise it is ignored. Defaults to
identity()
method: str or `function`
Traversal method to use. See
_get_traversal_method()
visited: set or None
Yields: Return Value of
apply_fn
, by default MonosaccharideSee also
depth_first_traversal
,breadth_first_traversal
,_get_traversal_method
-
label_branches
()[source]¶ Labels each branch point with an alphabetical symbol. Also computes and stores each branch’s length and stores it in
branch_lengths
. Setsbranch_lengths
ofself
andLink.label
for each link attached toself
.
-
leaves
(bidirectional=False, method='dfs', visited=None)[source]¶ Iterates over all
Monosaccharide
objects inGlycan
, yielding only those that have no child nodes.Parameters: bidirectional: bool
If
bidirectional
isTrue
, then onlyMonosaccharide
objects with only one entry inlinks
.method: str or function
The traversal method controlling the order of the nodes visited
visited: None or set
The collection of id values to ignore when traversing
Yields:
-
mass
(average=False, charge=0, mass_data=None, method='dfs')[source]¶ Calculates the total mass of the intact graph by querying each node for its mass.
Parameters: average: bool
Whether or not to use the average isotopic composition when calculating masses. When
average == False
, masses are calculated using monoisotopic mass.charge: int
If charge is non-zero, m/z is calculated, where m is the theoretical mass, and z is
charge
mass_data: dict
If mass_data is None, standard NIST mass and isotopic abundance data are used. Otherwise the contents of mass_data are assumed to contain elemental mass and isotopic abundance information.
Returns: float
-
name_fragment
(fragment)[source]¶ Attempt to assign a full name to a fragment based on the branch and position relative to the reducing end along side A/B/C/X/Y/Z, according to Domon and Costello
-
reducing_end
¶ An alias for
Monosaccharide.reducing_end
forroot
-
reindex
(method='dfs')[source]¶ Traverse the graph using the function specified by
method
. The order of traversal defines the newid
value for eachMonosaccharide
andLink
.The order of traversal also defines the ordering of the
Monosaccharide
inindex
andLink
inlink_index
.
-
set_reducing_end
(value)[source]¶ Sets the reducing end type, and configures the root residue appropriately.
If the reducing_end is not
None
, then the following state changes are made to the root:self.root.ring_start = 0 self.root.ring_end = 0 self.root.anomer = "uncyclized"
Else, the correct state is unknown:
self.root.ring_start = None self.root.ring_end = None self.root.anomer = None
-
substructures
(max_cleavages=1, min_cleavages=1, inplace=False)[source]¶ Generate disjoint subtrees from this glycan by examining by removing one or more monosaccharide-monosaccharide bond.
Parameters: max_cleavages: |int|
The maximum number of bonds to break per substructure
min_cleavages: |int|
The minimum number of bonds to break per substructure
min_size: |int|
The minimum number of monosaccharides per substructure
-
subtrees
(max_cleavages=1, include_crossring=False)[source]¶ Generate subtrees from this tree by breaking
max_cleavages
bonds or rings.Parameters: max_cleavages: int
The maximum number of bonds to break per fragment
include_crossring: bool
Whether to include cross ring cleavages
Yields: Subtree
-
topological_equality
(other)[source]¶ Two glycans are considered equal if they are topologically equal.
Parameters: self: :class:`Glycan`
other: :class:`Glycan`
Returns: bool
See also
glypy.structure.Monosaccharide.topological_equality()
-
total_composition
(method='dfs')[source]¶ Computes the sum of the composition of all
Monosaccharide
objects inself
Returns: Composition
-