Package nMOLDYN :: Package Core :: Module Chemistry |
[hide private]
[frames] | no frames]

# Source Code for Module nMOLDYN.Core.Chemistry

     1  """This modules implements the functions and procedures that are related to chemistry.
     2
     3  Functions:
     4      * belongToAnAmine  : this function determine whether or not |atom| is part of an amine group.
     5      * belongToAHydroxy : this function determine whether or not |atom| is part of a hydroxy group.
     6      * belongToAMethyl  : this function determine whether or not |atom| is part of a mathyl group.
     7      * belongToAThiol   : this function determine whether or not |atom| is part of a thiol group.
     8  """
     9
    10 -def belongToAMethyl(atom):
    11      """This function determine whether or not |atom| is part of a methyl group.
    12      """
    13
    14      belong = None
    15
    16      if atom.type.name.strip().lower() == 'carbon':
    17          neighbours = atom.bondedTo()
    18          hydrogens = [neigh for neigh in neighbours if neigh.type.name.strip().lower() == 'hydrogen']
    19          if len(hydrogens) >= 3:
    20              return atom
    21
    22      elif atom.type.name.strip().lower() == 'hydrogen':
    23          c = atom.bondedTo()[0]
    24          if c != atom:
    25              belong = belongToAMethyl(c)
    26
    27      return belong
    28
    29 -def belongToAnAmine(atom):
    30      """This function determine whether or not |atom| is part of an amine group.
    31      """
    32
    33      belong = None
    34
    35      if atom.type.name.strip().lower() == 'nitrogen':
    36          neighbours = atom.bondedTo()
    37          hydrogens = [neigh for neigh in neighbours if neigh.type.name.strip().lower() == 'hydrogen']
    38          if len(hydrogens) >= 2:
    39              return atom
    40
    41      elif atom.type.name.strip().lower() == 'hydrogen':
    42          n = atom.bondedTo()[0]
    43          if n != atom:
    44              belong = belongToAMethyl(n)
    45
    46      return belong
    47
    48 -def belongToAThiol(atom):
    49      """This function determine whether or not |atom| is part of a thiol group.
    50      """
    51
    52      belong = None
    53
    54      if atom.type.name.strip().lower() in ['sulphur', 'sulfur']:
    55          neighbours = atom.bondedTo()
    56          hydrogens = [neigh for neigh in neighbours if neigh.type.name.strip().lower() == 'hydrogen']
    57          if len(hydrogens) >= 1:
    58              return atom
    59
    60      elif atom.type.name.strip().lower() == 'hydrogen':
    61          s = atom.bondedTo()[0]
    62          if s != atom:
    63              belong = belongToAMethyl(s)
    64
    65      return belong
    66
    67 -def belongToAHydroxy(atom):
    68      """This function determine whether or not |atom| is part of a hydroxy group.
    69      """
    70      belong = None
    71
    72      if atom.type.name.strip().lower() == 'oxygen':
    73          neighbours = atom.bondedTo()
    74          hydrogens = [neigh for neigh in neighbours if neigh.type.name.strip().lower() == 'hydrogen']
    75          if len(hydrogens) >= 1:
    76              return atom
    77
    78      elif atom.type.name.strip().lower() == 'hydrogen':
    79          o = atom.bondedTo()[0]
    80          if o != atom:
    81              belong = belongToAMethyl(o)
    82
    83      return belong
    84