Linkage and Bonds¶
Represents the connections between residues, such as the bond between Substituent
and Monosaccharide
or the glycocidic bond between two Monosaccharide
residues.
-
class
glypy.structure.link.
Link
(parent, child, parent_position=-1, child_position=-1, parent_loss=None, child_loss=None, id=None, attach=True)[source]¶ Bases:
object
Represents the linkage between two molecules, described as an edge in a graph with optional directedness semantics.
Attributes
parent: Monosaccharide
orSubstituent
child: Monosaccharide
orSubstituent
parent_position: int Position of link on parent
child_position: int position of link on child
parent_loss: Composition
Elemental composition lost from the parent
when forming this bondchild_loss: Composition
Elemental composition lost from the child
when forming this bond-
__init__
(parent, child, parent_position=-1, child_position=-1, parent_loss=None, child_loss=None, id=None, attach=True)[source]¶ Defines a bond between
parent
andchild
between the molecule positions specified. The bond may represent a partial loss of elemental composition from the parent and/or child molecules.Instantiating the
Link
object will automatically attach it to its endpoints, mutating them unlessattach=False
. If not attached on instantiation, the bond can be realized by callingLink.apply()
at a later time.Parameters: parent: :class:`Monosaccharide` or :class:`Substituent`
child: :class:`Monosaccharide` or :class:`Substituent`
parent_position: int
The position on the parent to attach to Defaults to -1
child_position: int
The position on the child to attach to. Defaults to -1
parent_loss: :class:`Composition` or str
The elemental composition deducted from the parent when the bond is applied
child_loss: :class:`Composition` or str
The elemental composition deducted from the child when the bond is applied
id: int
A locally unique identifier within a graph. If
None
, uuid4 is used to generate one. Defaults toNone
attach: bool
Whether to immediately attach the
Link
object to theparent
andchild
molecules on instantiation by usingLink.apply()
-
_glycoct_sigils
(link)[source]¶ Helper method for determining which GlycoCT symbols and losses to present
-
apply
()[source]¶ Actually alter
parent
andchild
‘s state. Deduct their respective losses from theircomposition
and insert a reference toself
into theirlinks
orsubstituent_links
as appropriate.Sets
_attached
toTrue
See also
-
break_link
(refund=False)[source]¶ This function reverses
Link.apply()
, removing the reference toself
from bothparent
andchild
‘s store of links. Ifrefund
isTrue
,Link.refund()
will be called, restoring the lost elemental composition from this bond.Sets
_attached
toFalse
Returns: Monosaccharide
orSubstituent
parentMonosaccharide
orSubstituent
child
-
clone
(parent, child, prop_id=True, attach=True)[source]¶ Given two new objects
parent
andchild
, duplicate all other information inself
, creating a newLink
object betweenparent
andchild
with the same properties asself
.Returns: Link
-
is_attached
(deep=False)[source]¶ Test to see if
self
is present inparent
andchild
link structures. Presences indicates the link is attached.Returns: bool
-
is_substituent_link
()[source]¶ If
child
is aSubstituent
andparent
is aMonosaccharide
, thenself
is a substituent_linkReturns: bool
-
reconnect
(refund=False)[source]¶ The opposite of
Link.break_link()
, addself
to the appropriate places onparent
andchild
Parameters: refund: bool
Should
Link.refund()
be called? Defaults toFalse
-
refund
()[source]¶ Returns the lost elemental composition caused by
apply()
. Adds backparent_loss
andchild_loss
to thecomposition
ofparent
andchild
respectively
-
to
(mol)[source]¶ Traverse the link from
mol
to its adjacent node. Ifmol
is notself.parent
orself.child
, instead raises an error.__getitem__()
is an alias ofto
Parameters: mol: :class:`Monosaccharide` or :class:`Substituent`
Returns: Monosaccharide
orSubstituent
Raises: KeyError:
If
mol
is not the parent or child of thisLink
-