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:
objectRepresents the linkage between two molecules, described as an edge in a graph with optional directedness semantics.
Attributes
parent: MonosaccharideorSubstituentchild: MonosaccharideorSubstituentparent_position: int Position of link on parentchild_position: int position of link on childparent_loss: CompositionElemental composition lost from the parentwhen forming this bondchild_loss: CompositionElemental composition lost from the childwhen 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
parentandchildbetween the molecule positions specified. The bond may represent a partial loss of elemental composition from the parent and/or child molecules.Instantiating the
Linkobject 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 toNoneattach: bool
Whether to immediately attach the
Linkobject to theparentandchildmolecules on instantiation by usingLink.apply()
-
_glycoct_sigils(link)[source]¶ Helper method for determining which GlycoCT symbols and losses to present
-
apply()[source]¶ Actually alter
parentandchild‘s state. Deduct their respective losses from theircompositionand insert a reference toselfinto theirlinksorsubstituent_linksas appropriate.Sets
_attachedtoTrueSee also
-
break_link(refund=False)[source]¶ This function reverses
Link.apply(), removing the reference toselffrom bothparentandchild‘s store of links. IfrefundisTrue,Link.refund()will be called, restoring the lost elemental composition from this bond.Sets
_attachedtoFalseReturns: MonosaccharideorSubstituentparentMonosaccharideorSubstituentchild
-
clone(parent, child, prop_id=True, attach=True)[source]¶ Given two new objects
parentandchild, duplicate all other information inself, creating a newLinkobject betweenparentandchildwith the same properties asself.Returns: Link
-
is_attached(deep=False)[source]¶ Test to see if
selfis present inparentandchildlink structures. Presences indicates the link is attached.Returns: bool
-
is_substituent_link()[source]¶ If
childis aSubstituentandparentis aMonosaccharide, thenselfis a substituent_linkReturns: bool
-
reconnect(refund=False)[source]¶ The opposite of
Link.break_link(), addselfto the appropriate places onparentandchildParameters: refund: bool
Should
Link.refund()be called? Defaults toFalse
-
refund()[source]¶ Returns the lost elemental composition caused by
apply(). Adds backparent_lossandchild_lossto thecompositionofparentandchildrespectively
-
to(mol)[source]¶ Traverse the link from
molto its adjacent node. Ifmolis notself.parentorself.child, instead raises an error.__getitem__()is an alias oftoParameters: mol: :class:`Monosaccharide` or :class:`Substituent`
Returns: MonosaccharideorSubstituentRaises: KeyError:
If
molis not the parent or child of thisLink
-