def _indexGenerator(self):

        frame = self.dsim.getFrame(0)
        # atom and global indices of all atoms in the system
        self.all_atom_ids = np.arange(len(self.dsim.cst.atom)) + 1
        self.all_atom_gids = np.arange(
            len(self.dsim.cst.atom) + self.dsim.cst._pseudo_total)
        # obtain oxygen atom and global indices for all water molecules
        oxygen_sel = FAS('atom.ele O')
        all_oxygen_atoms = oxygen_sel.getAtomIndices(frame)
        water_sel = select_component(self.dsim.cst, ['solvent'])
        solvent_atoms = water_sel.getAtomIndices(frame)
        solvent_oxygen_atoms = list(
            set(solvent_atoms).intersection(set(all_oxygen_atoms)))
        solvent_oxygen_atoms.sort()
        self.wat_oxygen_atom_ids = np.array(solvent_oxygen_atoms, dtype=np.int)
        self.wat_oxygen_atom_gids = self.wat_oxygen_atom_ids - 1
        # obtain atom indices for all water atoms
        self.wat_atom_ids = self.getWaterIndices(self.wat_oxygen_atom_ids)
        # obtain atom and global indices for all water atoms
        #wat_id_list = self.getWaterIndices(self.wat_oxygen_atom_ids)
        #self.wat_atom_ids = wat_id_list[0]
        #self.wat_atom_gids = wat_id_list[1]
        # obtain all non-water atom and global indices
        self.non_water_atom_ids = np.setxor1d(self.all_atom_ids,
                                              self.wat_atom_ids).astype(int)
 def _indexGenerator(self, ligand_file):
     frame = self.dsim.getFrame(0)
     # atom and global indices of all atoms in the system
     self.all_atom_ids = np.arange(len(self.dsim.cst.atom))+1
     self.all_atom_gids = np.arange(len(self.dsim.cst.atom)+self.dsim.cst._pseudo_total)
     # obtain oxygen atom and global indices for all water molecules
     oxygen_sel = FAS('atom.ele O')
     all_oxygen_atoms = oxygen_sel.getAtomIndices(frame)
     water_sel = select_component(self.dsim.cst, ['solvent'])
     solvent_atoms = water_sel.getAtomIndices(frame)
     solvent_oxygen_atoms = list(set(solvent_atoms).intersection(set(all_oxygen_atoms)))
     solvent_oxygen_atoms.sort()
     self.wat_oxygen_atom_ids = np.array(solvent_oxygen_atoms, dtype=np.int)
     self.wat_oxygen_atom_gids = self.wat_oxygen_atom_ids - 1
     # obtain atom indices for all water atoms
     self.wat_atom_ids = self.getWaterIndices(self.wat_oxygen_atom_ids)
     # obtain atom and global indices for all water atoms
     #wat_id_list = self.getWaterIndices(self.wat_oxygen_atom_ids)
     #self.wat_atom_ids = wat_id_list[0]
     #self.wat_atom_gids = wat_id_list[1]        
     # obtain all non-water atom and global indices
     self.non_water_atom_ids = np.setxor1d(self.all_atom_ids, self.wat_atom_ids).astype(int)
     # here add commands to restrict non-water atom ids to within 5.0A of ligand
     #***************************************************************
     # Tag protein atoms that are near ligand
     solute_indices_near_lig = []
     ligand = structure.StructureReader(ligand_file).next()
     self.ligand = ligand
     lig_atom_coords = ligand.getXYZ()
     solute_pos = frame.position[self.non_water_atom_ids-1]
     d_solute_nbrs = _DistanceCell(solute_pos, 5)
     for coord in lig_atom_coords:
         solute_nbr_indices = d_solute_nbrs.query_nbrs(coord)
         for solute_nbr_index in solute_nbr_indices:
             if solute_nbr_index not in solute_indices_near_lig:
                 solute_indices_near_lig.append(solute_nbr_index)
     #print self.non_water_atom_ids
     self.non_water_atom_ids_near_lig = [self.non_water_atom_ids[nbr_index] for nbr_index in solute_indices_near_lig]
     #self.non_water_atom_ids_near_lig = self.non_water_atom_ids
     #***************************************************************
     # Type protein atoms
     acc_list = []
     don_list = []
     acc_don_list = []
     # To speed up calculations, we will pre-create donor atom, hydrogen pairs
     self.don_H_pair_dict = {}
     if self.non_water_atom_ids.size != 0:
         frame_st = self.dsim.getFrameStructure(0)
         for solute_at_id in self.non_water_atom_ids:
             solute_atom = frame_st.atom[solute_at_id]
             solute_atom_type = solute_atom.pdbres.strip(" ") + " " + solute_atom.pdbname.strip(" ")
             if solute_atom.element in ["O", "S"]:
                 # if O/S atom is bonded to an H, type it as donor and an acceptor
                 if "H" in [bonded_atom.element for bonded_atom in solute_atom.bonded_atoms]:
                     #print "Found donor-acceptor atom type: %i %s" % (solute_at_id, solute_atom_type)
                     acc_don_list.append(solute_at_id)
                     # create a dictionary entry for this atom, that will hold all atom, H id pairs 
                     self.don_H_pair_dict[solute_at_id] = []
                     for bonded_atom in solute_atom.bonded_atoms:
                         if bonded_atom.element == "H":
                             self.don_H_pair_dict[solute_at_id].append([solute_at_id, bonded_atom.index])
                 # if O/S atom is not bonded to an H, type it as an acceptor
                 else:
                     #print "Found acceptor atom type: %i %s" % (solute_at_id, solute_atom_type)
                     acc_list.append(solute_at_id)
             if solute_atom.element in ["N"]:
                 # if N atom is bonded to an H, type it as a donor
                 if "H" in [bonded_atom.element for bonded_atom in solute_atom.bonded_atoms]:
                     #print "Found donor atom type: %i %s" % (solute_at_id, solute_atom_type)
                     don_list.append(solute_at_id)
                     # create a dictionary entry for this atom, that will hold all atom, H id pairs 
                     self.don_H_pair_dict[solute_at_id] = []
                     for bonded_atom in solute_atom.bonded_atoms:
                         if bonded_atom.element == "H":
                             self.don_H_pair_dict[solute_at_id].append([solute_at_id, bonded_atom.index])
                 else:
                     #print "Found acceptor atom type: %i %s" % (solute_at_id, solute_atom_type)
                     acc_list.append(solute_at_id)
     #print don_list
     #print acc_list
     #print acc_don_list
     self.solute_acc_ids = np.array(acc_list, dtype=np.int)
     self.solute_acc_don_ids = np.array(acc_don_list, dtype=np.int)
     self.solute_don_ids = np.array(don_list, dtype=np.int)
     self.prot_hbond_data = {}
     for hb_group in np.concatenate((self.solute_acc_ids, self.solute_acc_don_ids, self.solute_don_ids)):
         hb_group_name = self.dsim.cst.atom[hb_group].getResidue().pdbres.strip() + str(self.dsim.cst.atom[hb_group].getResidue().resnum) + " " + self.dsim.cst.atom[hb_group].pdbname.strip()
         self.prot_hbond_data[hb_group] = [hb_group_name, np.zeros(10, dtype="float64")]
         #print self.prot_hbond_data[hb_group]
     #***************************************************************
     # Type ligand atoms
     lig_acc_list = []
     lig_don_list = []
     lig_acc_don_list = []
     self.lig_don_H_pair_dict = {}
     if len(ligand.atom) != 0:
         for lig_at in ligand.atom:
             lig_atom_type = lig_at.pdbres.strip(" ") + " " + lig_at.pdbname.strip(" ")
             if lig_at.element in ["O", "S"]:
                 # if O/S atom is bonded to an H, type it as donor and an acceptor
                 if "H" in [bonded_atom.element for bonded_atom in lig_at.bonded_atoms]:
                     #print "Found donor-acceptor atom type: %i %s" % (lig_at.index, lig_atom_type)
                     lig_acc_don_list.append(lig_at.index)
                     # create a dictionary entry for this atom, that will hold all atom, H id pairs 
                     self.lig_don_H_pair_dict[lig_at.index] = []
                     for bonded_atom in lig_at.bonded_atoms:
                         if bonded_atom.element == "H":
                             self.lig_don_H_pair_dict[lig_at.index].append([lig_at.index, bonded_atom.index])
                 # if O/S atom is not bonded to an H, type it as an acceptor
                 else:
                     #print "Found acceptor atom type: %i %s" % (lig_at.index, lig_atom_type)
                     lig_acc_list.append(lig_at.index)
             if lig_at.element in ["N"]:
                 # if N atom is bonded to an H, type it as a donor
                 if "H" in [bonded_atom.element for bonded_atom in lig_at.bonded_atoms]:
                     #print "Found donor atom type: %i %s" % (lig_at.index, lig_atom_type)
                     lig_don_list.append(lig_at.index)
                     # create a dictionary entry for this atom, that will hold all atom, H id pairs 
                     self.lig_don_H_pair_dict[lig_at.index] = []
                     for bonded_atom in lig_at.bonded_atoms:
                         if bonded_atom.element == "H":
                             self.lig_don_H_pair_dict[lig_at.index].append([lig_at.index, bonded_atom.index])
                 else:
                     #print "Found acceptor atom type: %i %s" % (lig_at.index, lig_atom_type)
                     lig_acc_list.append(lig_at.index)
     self.ligand_acc_ids = np.array(lig_acc_list, dtype=np.int)
     self.ligand_acc_don_ids = np.array(lig_acc_don_list, dtype=np.int)
     self.ligand_don_ids = np.array(lig_don_list, dtype=np.int)
    def _indexGenerator(self):

        frame = self.dsim.getFrame(0)
        # atom and global indices of all atoms in the system
        self.all_atom_ids = np.arange(len(self.dsim.cst.atom)) + 1
        self.all_atom_gids = np.arange(
            len(self.dsim.cst.atom) + self.dsim.cst._pseudo_total)
        # obtain oxygen atom and global indices for all water molecules
        oxygen_sel = FAS('atom.ele O')
        all_oxygen_atoms = oxygen_sel.getAtomIndices(frame)
        water_sel = select_component(self.dsim.cst, ['solvent'])
        solvent_atoms = water_sel.getAtomIndices(frame)
        solvent_oxygen_atoms = list(
            set(solvent_atoms).intersection(set(all_oxygen_atoms)))
        solvent_oxygen_atoms.sort()
        self.wat_oxygen_atom_ids = np.array(solvent_oxygen_atoms, dtype=np.int)
        self.wat_oxygen_atom_gids = self.wat_oxygen_atom_ids - 1
        # obtain atom indices for all water atoms
        self.wat_atom_ids = self.getWaterIndices(self.wat_oxygen_atom_ids)
        # obtain atom and global indices for all water atoms
        #wat_id_list = self.getWaterIndices(self.wat_oxygen_atom_ids)
        #self.wat_atom_ids = wat_id_list[0]
        #self.wat_atom_gids = wat_id_list[1]
        # obtain all non-water atom and global indices
        self.non_water_atom_ids = np.setxor1d(self.all_atom_ids,
                                              self.wat_atom_ids).astype(int)
        #self.non_water_gids = np.setxor1d(self.all_atom_gids,self.wat_atom_gids)
        # These lists define the search space for solute water Hbond calculation
        acc_list = []
        don_list = []
        acc_don_list = []
        # To speed up calculations, we will pre-create donor atom, hydrogen pairs
        self.don_H_pair_dict = {}
        if self.non_water_atom_ids.size != 0:
            frame_st = self.dsim.getFrameStructure(0)
            for solute_at_id in self.non_water_atom_ids:
                solute_atom = frame_st.atom[solute_at_id]
                solute_atom_type = solute_atom.pdbres.strip(
                    " ") + " " + solute_atom.pdbname.strip(" ")
                if solute_atom.element in ["O", "S"]:
                    # if O/S atom is bonded to an H, type it as donor and an acceptor
                    if "H" in [
                            bonded_atom.element
                            for bonded_atom in solute_atom.bonded_atoms
                    ]:
                        #print "Found donor-acceptor atom type: %i %s" % (solute_at_id, solute_atom_type)
                        acc_don_list.append(solute_at_id)
                        # create a dictionary entry for this atom, that will hold all atom, H id pairs
                        self.don_H_pair_dict[solute_at_id] = []
                        for bonded_atom in solute_atom.bonded_atoms:
                            if bonded_atom.element == "H":
                                self.don_H_pair_dict[solute_at_id].append(
                                    [solute_at_id, bonded_atom.index])

                    # if O/S atom is not bonded to an H, type it as an acceptor
                    else:
                        #print "Found acceptor atom type: %i %s" % (solute_at_id, solute_atom_type)
                        acc_list.append(solute_at_id)
                if solute_atom.element in ["N"]:
                    # if N atom is bonded to an H, type it as a donor
                    if "H" in [
                            bonded_atom.element
                            for bonded_atom in solute_atom.bonded_atoms
                    ]:
                        #print "Found donor atom type: %i %s" % (solute_at_id, solute_atom_type)
                        don_list.append(solute_at_id)
                        # create a dictionary entry for this atom, that will hold all atom, H id pairs
                        self.don_H_pair_dict[solute_at_id] = []
                        for bonded_atom in solute_atom.bonded_atoms:
                            if bonded_atom.element == "H":
                                self.don_H_pair_dict[solute_at_id].append(
                                    [solute_at_id, bonded_atom.index])

                    # if N atom is not bonded to an H, type it as an acceptor
                    else:
                        #print "Found acceptor atom type: %i %s" % (solute_at_id, solute_atom_type)
                        acc_list.append(solute_at_id)
        #print don_list
        #print acc_list
        #print acc_don_list
        self.solute_acc_ids = np.array(acc_list, dtype=np.int)
        self.solute_acc_don_ids = np.array(acc_don_list, dtype=np.int)
        self.solute_don_ids = np.array(don_list, dtype=np.int)