Substituents

Represents non-saccharide units that are found attached to saccharide residues. They also posses graph node-like properties.

class glypy.structure.substituent.Substituent(name, links=None, composition=None, id=None, can_nh_derivatize=None, is_nh_derivatizable=None, derivatize=False, attachment_composition=None)[source]

Represents a non-saccharide molecule commonly found bound to saccharide units.

Variables
  • name (str) – The name of the substituent, used to uniquely identify it.

  • links (OrderedMultiMap) – All links to all molecules connected to this one.

  • composition (Composition) – The chemical makeup of this molecule.

  • attachment_composition (Composition) – The default cost of attaching this substituent to a Monosaccharide

  • id (int) – A unique identifier number for this molecule.

  • can_nh_derivatize (bool) – Whether this substituent will derivatize at an amine group.

  • is_nh_derivatizable (bool) – Whether this substituent contains a derivatizable amine group.

  • _derivatize (bool) – Whether this substituent was added by a derivatization process.

  • _degree (int) – The number of connections to this molecule. Mutated internally by Link objects, not for external use. See order().

add_substituent(substitent, position=2, max_occupancy=1, child_position=1, parent_loss=None, child_loss=None)[source]

Adds a Substituent and associated Link to links at the site given by position. This new substituent is included when calculating mass with substituents included

Parameters
  • substituent (str or Substituent) – The substituent to add. If passed a str, it will be translated into an instance of Substituent

  • position (int or 'x') – The location to add the Substituent link to links. Defaults to 2

  • child_position (int) – The location to add the link to in substituent’s links. Defaults to 1. Substituent indices are currently not checked.

  • max_occupancy (int, optional) – The maximum number of items acceptable at position. Defaults to 1

  • parent_loss (Composition or str) – The elemental composition removed from self. Defaults to H1.

  • child_loss (Composition or str) – The elemental composition removed from substituent. Defaults to H1.

Raises

ValueError:position is occupied by more than max_occupancy elements

children(links=False, bridging=False)[source]

Returns an iterator over the Monosaccharide`s which are considered the descendants of ``self`.

clone(prop_id=True)[source]

Duplicates this Substituent object, recursively copying all children as well.

Parameters

prop_id (bool) – Whether or not to propagate id to the clone.

Return type

Substituent

See also

structure.Monosaccharide.clone()

is_occupied(position)[source]

Check to see if position is occupied. Unlike Monosaccharide, Substituent objects can only have two attachment sites at this time.

Parameters

position (int) –

Returns

Number of links at position

Return type

int

Raises

IndexError: – If position > 2 or < 1

mass(average=False, charge=0, mass_data=None)[source]

Calculates the total mass of self and all nodes returned by children().

Parameters
  • 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 of mass_data are assumed to contain elemental mass and isotopic abundance information.

Return type

float

parents(links=False)[source]

Returns an iterator over the objects which are considered the ancestors of self.

static register(name, composition, can_nh_derivatize=None, is_nh_derivatizable=None, attachment_composition=None)

Register common information about a Substituent group to be used during initialization of instances of Substituent which share that name.

Parameters
  • name (str) – The name to be registered

  • composition (Composition) – The shared base composition that will be initialized for each instance

  • can_nh_derivatize (None, optional) – Passed to DerivatizePathway.register

  • is_nh_derivatizable (None, optional) – Passed to DerivatizePathway.register

  • attachment_composition (None, optional) – The shared composition that will be lost from the parent molecule when forming a bond with substituents of this type.

total_composition()[source]

Computes the sum of the composition of self and each of its linked :class:`~.substituent.Substituent`s

Return type

Composition

static unregister(name)

Removes all information about the Substituent group denoted by name from the shared indices.

Parameters

name (str) – The name to un-register

glypy.structure.substituent.register(name, composition, can_nh_derivatize=None, is_nh_derivatizable=None, attachment_composition=None)[source]

Register common information about a Substituent group to be used during initialization of instances of Substituent which share that name.

Parameters
  • name (str) – The name to be registered

  • composition (Composition) – The shared base composition that will be initialized for each instance

  • can_nh_derivatize (None, optional) – Passed to DerivatizePathway.register

  • is_nh_derivatizable (None, optional) – Passed to DerivatizePathway.register

  • attachment_composition (None, optional) – The shared composition that will be lost from the parent molecule when forming a bond with substituents of this type.

glypy.structure.substituent.unregister(name)[source]

Removes all information about the Substituent group denoted by name from the shared indices.

Parameters

name (str) – The name to un-register