def build_dihedral_hash(self,
                            dihedral_proxies=None,
                            sites_cart=None,
                            pdb_hierarchy=None,
                            include_hydrogens=False,
                            include_main_chain=True,
                            include_side_chain=True):
        if not include_hydrogens:
            i_seq_element_hash = \
              utils.build_element_hash(pdb_hierarchy=pdb_hierarchy)
        i_seq_name_hash = \
          utils.build_name_hash(pdb_hierarchy=pdb_hierarchy)
        dihedral_hash = dict()

        for dp in dihedral_proxies:
            try:
                #check for H atoms if required
                if not include_hydrogens:
                    for i_seq in dp.i_seqs:
                        if i_seq_element_hash[i_seq] == " H":
                            raise StopIteration()
                #ignore backbone dihedrals
                if not include_main_chain:
                    sc_atoms = False
                    for i_seq in dp.i_seqs:
                        if i_seq_name_hash[i_seq][0:4] not in [
                                ' CA ', ' N  ', ' C  ', ' O  '
                        ]:
                            sc_atoms = True
                            break
                    if not sc_atoms:
                        raise StopIteration()
                if not include_side_chain:
                    sc_atoms = False
                    for i_seq in dp.i_seqs:
                        if i_seq_name_hash[i_seq][0:4] \
                          not in [' CA ', ' N  ', ' C  ', ' O  ']:
                            sc_atoms = True
                            break
                    if sc_atoms:
                        raise StopIteration()
                key = ""
                for i_seq in dp.i_seqs:
                    key = key + i_seq_name_hash[i_seq]
                di = \
                  cctbx.geometry_restraints.dihedral(
                    sites_cart=sites_cart,
                    proxy=dp)
                dihedral_hash[key] = di.angle_model
            except StopIteration:
                pass
        return dihedral_hash
  def build_dihedral_hash(self,
                          dihedral_proxies=None,
                          sites_cart=None,
                          pdb_hierarchy=None,
                          include_hydrogens=False,
                          include_main_chain=True,
                          include_side_chain=True):
    if not include_hydrogens:
      i_seq_element_hash = \
        utils.build_element_hash(pdb_hierarchy=pdb_hierarchy)
    i_seq_name_hash = \
      utils.build_name_hash(pdb_hierarchy=pdb_hierarchy)
    dihedral_hash = dict()

    for dp in dihedral_proxies:
      try:
        #check for H atoms if required
        if not include_hydrogens:
          for i_seq in dp.i_seqs:
            if i_seq_element_hash[i_seq] == " H":
              raise StopIteration()
        #ignore backbone dihedrals
        if not include_main_chain:
          sc_atoms = False
          for i_seq in dp.i_seqs:
            if i_seq_name_hash[i_seq][0:4] not in [' CA ',' N  ',' C  ',' O  ']:
              sc_atoms = True
              break
          if not sc_atoms:
            raise StopIteration()
        if not include_side_chain:
          sc_atoms = False
          for i_seq in dp.i_seqs:
            if i_seq_name_hash[i_seq][0:4] \
              not in [' CA ', ' N  ', ' C  ', ' O  ']:
              sc_atoms = True
              break
          if sc_atoms:
            raise StopIteration()
        key = ""
        for i_seq in dp.i_seqs:
          key = key+i_seq_name_hash[i_seq]
        di = \
          cctbx.geometry_restraints.dihedral(
            sites_cart=sites_cart,
            proxy=dp)
        dihedral_hash[key] = di.angle_model
      except StopIteration:
        pass
    return dihedral_hash