Glycan Composition¶
GlycanComposition
, MonosaccharideResidue
, and SubstituentResidue
are
useful for working with bag-of-residues where topology and connections are not relevant, but
the aggregate composition is known. These types work with a subset of the IUPAC three letter code
for specifying compositions.
A Monosaccharide
is meant to be able to precisely describe where all of the bonds from
the carbon backbone are. A MonosaccharideResidue
abstracts away the notion of
position, and automatically deduct a water molecule from their composition
to
account for a single incoming and a single outgoing glycosidic bond. Because they do not try to
completely describe the physical configuration of the molecule, MonosaccharideResidue
removes information about ring type, anomericty, configuration, and optionally stem type. The level
of detail discarded is customizable in the MonosaccharideResidue.from_monosaccahride()
class method.
A GlycanComposition
is just a bag of MonosaccharideResidue
and SubstituentResidue
, similar to Composition
.
Its keys may be either MonosaccharideResidue
instances, SubstituentResidue
instances or strings which can be parsed by
from_iupac_lite()
, and its values are integers. They may also be written to and from a string using
GlycanComposition.serialize()
and GlycanComposition.parse()
.
>>> g = GlycanComposition(Hex=3, HexNAc=2)
>>> g["Hex"]
3
>>> r = MonosaccharideResidue.from_iupac_lite("Hex")
>>> r
MonosaccharideResidue(Hex)
>>> g[r]
3
>>> import glypy
>>> abs(g.mass() - glypy.motifs["N-Glycan core basic 1"].mass()) < 1e-5
True
>>> g2 = GlycanComposition(Hex=5)
>>> g["@n-acetyl"] = -2 # Remove two n-acetyl groups from the composition
>>> abs(g.mass() - g2.mass()) < 1e-5
True
-
class
glypy.composition.glycan_composition.
GlycanComposition
(*args, **kwargs)[source]¶ Bases:
dict
,glypy.structure.base.SaccharideCollection
Describe a glycan as a collection of
MonosaccharideResidue
counts without explicit linkage information relating how each monosaccharide is connected to its neighbors.This class subclasses
dict
, and assumes that keys will either beMonosaccharideResidue
instances,SubstituentResidue
instances, or strings iniupac_lite
format which will be parsed into one of these types. While other types may be used, this is not recommended. All standarddict
methods are supported.|GlycanComposition| objects may be derivatized just as
Glycan
objects are, withglypy.composition.composition_transform.derivatize()
andglypy.composition.composition_transform.strip_derivatization()
.GlycanComposition objects also support composition arithmetic, and can be added or subtracted from each other or multiplied by an integer.
As GlycanComposition is not a complete structure, they cannot be translated into text formats as full
Glycan
objects are. They may instead be converted to and from a short-form text notation usingGlycanComposition.serialize()
and reconstructed from this format usingGlycanComposition.parse()
.Attributes
reducing_end (|ReducingEnd|) Describe the reducing end of the aggregate without binding it to a specific monosaccharide. This will contribute to composition and mass calculations. _composition_offset: Composition
Account for the one water molecule’s worth of composition left over from applying the “residue” transformation to each monosaccharide in the aggregate. -
__getitem__
(key)[source]¶ Get the quantity of
key
If
key
is a string, it will be passed throughfrom_iupac_lite()
If
key
has a reducing end value, that reducing end will be set onself
Parameters: key : str, MonosaccharideResidue, SubstituentResidue, or MolecularComposition
The entity to store
Returns: int
-
__setitem__
(key, value)[source]¶ Set the quantity of
key
tovalue
If
key
is a string, it will be passed throughfrom_iupac_lite()
If
key
has a reducing end value, that reducing end will be set onself
Parameters: key : str, MonosaccharideResidue, SubstituentResidue, or MolecularComposition
The entity to store
value : int
The value to store
-
collapse
()[source]¶ Merge redundant keys.
After performing a structure-detail removing operation like
drop_positions()
,drop_configurations()
, ordrop_stems()
, monosaccharide keys may be redundant.collapse
will merge keys which refer to the same type of molecule.
-
classmethod
from_glycan
(glycan)[source]¶ Convert a
Glycan
into a |GlycanComposition|.Parameters: glycan : Glycan
The instance to be converted
Returns: GlycanComposition
-
-
class
glypy.composition.glycan_composition.
MonosaccharideResidue
(*args, **kwargs)[source]¶ Bases:
glypy.structure.monosaccharide.Monosaccharide
-
__eq__
(other)[source]¶ Test for equality between
MonosaccharideResidue
instances by comparing the result ofMonosaccharideResidue.name()
calls betweenself
andother
.MonosaccharideResidue.name()
is an alias ofto_iupac_lite()
called onself
-
__hash__
()[source]¶ Obtain a hash value from
self
based onMonosaccharideResidue.name()
.Returns: int
-
classmethod
from_monosaccharide
(monosaccharide, configuration=False, stem=True, ring=False)[source]¶ Construct an instance of
MonosaccharideResidue
from an instance ofMonosaccharide
. This function attempts to preserve derivatization if possible.This function will create a deep copy of
monosaccharide
.Parameters: monosaccharide : Monosaccharide
The monosaccharide to be converted
configuration : bool, optional
Whether or not to preserve
Configuration
. Defaults toFalse
stem : bool, optional
Whether or not to preserve
Stem
. Defaults toTrue
ring : bool, optional
Whether or not to preserve |RingType|. Defaults to
False
Returns: MonosaccharideResidue
-
-
class
glypy.composition.glycan_composition.
SubstituentResidue
(name, composition=None, id=None, links=None, can_nh_derivatize=None, is_nh_derivatizable=None, derivatize=False, attachment_composition=None)[source]¶ Bases:
glypy.structure.substituent.Substituent
Represent substituent molecules unassociated with a specific monosaccharide residue.
Note
SubstituentResidue
‘s composition value includes the losses for forming a bond between a monosaccharide residue and the substituent.Attributes
name: str As in Substituent
, but withSubstituentResidue.sigil
prepended.composition: Composition
links: OrderedMultiMap
_order: int
-
sigil
= '@'¶ All substituent string identifiers are prefixed with this character for the
from_iupac_lite()
parser
-
-
glypy.composition.glycan_composition.
to_iupac_lite
()¶
-
glypy.composition.glycan_composition.
from_iupac_lite
()¶
-
glypy.composition.glycan_composition.
from_glycan
(cls, glycan)¶ Convert a
Glycan
into a |GlycanComposition|.Parameters: glycan : Glycan
The instance to be converted
Returns: GlycanComposition
-
glypy.composition.glycan_composition.
parse
(cls, string)¶