original_docstring: Create bonds based on the atom and residue names for all standard residue types.
  
          Definitions for standard amino acids and nucleotides are built in.  You can call loadBondDefinitions() to load
          additional definitions for other residue types.
          
docstring: Create bonds based on the atom and residue names for all standard residue types.
  Definitions for standard amino acids and nucleotides are built in.  You can call loadBondDefinitions() to load
  additional definitions for other residue types.
docstring_tokens: Create bonds based on the atom and residue names for all standard residue types . Definitions for standard amino acids and nucleotides are built in . You can call loadBondDefinitions () to load additional definitions for other residue types .
code: def createStandardBonds(self, positions, ff_fileNames):
          """Create bonds based on the atom and residue names for all standard residue types.
  
          Definitions for standard amino acids and nucleotides are built in.  You can call loadBondDefinitions() to load
          additional definitions for other residue types.
          """
          if not MyTopology._hasLoadedStandardBonds:
              # Load the standard bond definitions.
  
              for ff_fname in ff_fileNames:
                  MyTopology.loadBondDefinitions(ff_fname)
              MyTopology._hasLoadedStandardBonds = True
  
          for chain in self._chains:
              # First build a map of atom names to atoms.
              nres = chain._residues[0]
              cres = chain._residues[-1]
  
              atomMaps = []
  
              for residue in chain._residues:
                  atomMap = {}
                  atomMaps.append(atomMap)
  
                  for atom in residue._atoms:
                      # if atom.name in _atomNameReplacements:
                      #    atom.name = _atomNameReplacements[atom.name]
                      atomMap[atom.name] = atom
  
              # Loop over residues and construct bonds.
  
              for i in range(len(chain._residues)):
                  res = chain._residues[i]
                  name = res.name
                  if name in _standardResidues:
                      if res == nres:
                          name = "N" + res.name
                      elif res == cres:
                          name = "C" + res.name
  
                      if name in ['HIE', 'HIS']:
                          """
                          HIE: no HD1, yes HE2
                          HID: yes HD1, no HE2
                          HIP: yes HD1, yes HE2
                          """
                          atomNames = []
                          name = 'HIE'
                          for atom in res._atoms:
                              atomNames.append(atom.name)
  
                          if 'HD1' in atomNames:
                              if 'HE2' in atomNames:
                                  name = 'HIP'
                              else:
                                  name = 'HID'
                          res.name = name
  
                  if name in MyTopology._standardBonds:
                      for bond in MyTopology._standardBonds[name]:
  
                          if bond[0].startswith('-') and i > 0:
                              fromResidue = i-1
                              fromAtom = bond[0][1:]
                          elif bond[0].startswith('+') and i < len(chain._residues)-1:
                              fromResidue = i+1
                              fromAtom = bond[0][1:]
                          else:
                              fromResidue = i
                              fromAtom = bond[0]
                          if bond[1].startswith('-') and i > 0:
                              toResidue = i-1
                              toAtom = bond[1][1:]
                          elif bond[1].startswith('+') and i < len(chain._residues)-1:
                              toResidue = i+1
                              toAtom = bond[1][1:]
                          else:
                              toResidue = i
                              toAtom = bond[1]
  
                          l_add_Bond = False
                          if fromAtom in atomMaps[fromResidue] and toAtom in atomMaps[toResidue]:
                              l_add_Bond = True
  
                          if fromResidue != toResidue and l_add_Bond:
                              atom1 = atomMaps[fromResidue][fromAtom]
                              atom2 = atomMaps[toResidue][toAtom]
                              pos1 = positions[atom1.index]
                              pos2 = positions[atom2.index]
                              delta = [x - y for (x, y) in zip(pos1, pos2)]
                              distance = sqrt(
                                  delta[0]*delta[0] + delta[1]*delta[1] + delta[2]*delta[2])
                              if distance > 0.20*nanometers:
                                  l_add_Bond = False
  
                          if l_add_Bond:
                              self.addBond(
                                  atomMaps[fromResidue][fromAtom], atomMaps[toResidue][toAtom])
  
          # sys.exit()
code_tokens: def createStandardBonds ( self , positions , ff_fileNames ) : if not MyTopology . _hasLoadedStandardBonds : for ff_fname in ff_fileNames : MyTopology . loadBondDefinitions ( ff_fname ) MyTopology . _hasLoadedStandardBonds = True for chain in self . _chains : nres = chain . _residues [ 0 ] cres = chain . _residues [ - 1 ] atomMaps = [ ] for residue in chain . _residues : atomMap = { } atomMaps . append ( atomMap ) for atom in residue . _atoms : atomMap [ atom . name ] = atom for i in range ( len ( chain . _residues ) ) : res = chain . _residues [ i ] name = res . name if name in _standardResidues : if res == nres : name = "N" + res . name elif res == cres : name = "C" + res . name if name in [ 'HIE' , 'HIS' ] : """
                          HIE: no HD1, yes HE2
                          HID: yes HD1, no HE2
                          HIP: yes HD1, yes HE2
                          """ atomNames = [ ] name = 'HIE' for atom in res . _atoms : atomNames . append ( atom . name ) if 'HD1' in atomNames : if 'HE2' in atomNames : name = 'HIP' else : name = 'HID' res . name = name if name in MyTopology . _standardBonds : for bond in MyTopology . _standardBonds [ name ] : if bond [ 0 ] . startswith ( '-' ) and i > 0 : fromResidue = i - 1 fromAtom = bond [ 0 ] [ 1 : ] elif bond [ 0 ] . startswith ( '+' ) and i < len ( chain . _residues ) - 1 : fromResidue = i + 1 fromAtom = bond [ 0 ] [ 1 : ] else : fromResidue = i fromAtom = bond [ 0 ] if bond [ 1 ] . startswith ( '-' ) and i > 0 : toResidue = i - 1 toAtom = bond [ 1 ] [ 1 : ] elif bond [ 1 ] . startswith ( '+' ) and i < len ( chain . _residues ) - 1 : toResidue = i + 1 toAtom = bond [ 1 ] [ 1 : ] else : toResidue = i toAtom = bond [ 1 ] l_add_Bond = False if fromAtom in atomMaps [ fromResidue ] and toAtom in atomMaps [ toResidue ] : l_add_Bond = True if fromResidue != toResidue and l_add_Bond : atom1 = atomMaps [ fromResidue ] [ fromAtom ] atom2 = atomMaps [ toResidue ] [ toAtom ] pos1 = positions [ atom1 . index ] pos2 = positions [ atom2 . index ] delta = [ x - y for ( x , y ) in zip ( pos1 , pos2 ) ] distance = sqrt ( delta [ 0 ] * delta [ 0 ] + delta [ 1 ] * delta [ 1 ] + delta [ 2 ] * delta [ 2 ] ) if distance > 0.20 * nanometers : l_add_Bond = False if l_add_Bond : self . addBond ( atomMaps [ fromResidue ] [ fromAtom ] , atomMaps [ toResidue ] [ toAtom ] )
short_docstring: Create bonds based on the atom and residue names for all standard residue types.
short_docstring_tokens: Create bonds based on the atom and residue names for all standard residue types .
comment: """Create bonds based on the atom and residue names for all standard residue types.
  
          Definitions for standard amino acids and nucleotides are built in.  You can call loadBondDefinitions() to load
          additional definitions for other residue types.
          """$SEP$# Load the standard bond definitions.$SEP$# First build a map of atom names to atoms.$SEP$# if atom.name in _atomNameReplacements:$SEP$#    atom.name = _atomNameReplacements[atom.name]$SEP$# Loop over residues and construct bonds.$SEP$"""
                          HIE: no HD1, yes HE2
                          HID: yes HD1, no HE2
                          HIP: yes HD1, yes HE2
                          """$SEP$# sys.exit()