예제 #1
0
    def _apply_KDTree(self, group):
        """Selection using KDTree but periodic = True not supported.
        (KDTree routine is ca 15% slower than the distance matrix one)
        """
        sys_indices = numpy.array([a.number for a in self._group_atoms_list])
        sys_coor = Selection.coord[sys_indices]
        if self.periodic:
            pass  # or warn? -- no periodic functionality with KDTree search
        from MDAnalysis.KDTree.NeighborSearch import CoordinateNeighborSearch

        CNS = CoordinateNeighborSearch(sys_coor)  # cache the KDTree for this selection/frame?
        found_indices = CNS.search(self.ref, self.cutoff)
        res_atoms = [self._group_atoms_list[i] for i in found_indices]  # make list numpy array and use fancy indexing?
        return set(res_atoms)
예제 #2
0
 def _apply_KDTree(self, group):
     """KDTree based selection is about 7x faster than distmat for typical problems.
     Limitations: always ignores periodicity
     """
     sel_atoms = self.sel._apply(group)  # group is wrong, should be universe (?!)
     sys_atoms_list = [a for a in (self._group_atoms - sel_atoms)]  # list needed for back-indexing
     sel_indices = numpy.array([a.number for a in sel_atoms], dtype=int)
     sys_indices = numpy.array([a.number for a in sys_atoms_list], dtype=int)
     sel_coor = Selection.coord[sel_indices]
     sys_coor = Selection.coord[sys_indices]
     from MDAnalysis.KDTree.NeighborSearch import CoordinateNeighborSearch
     # Can we optimize search by using the larger set for the tree?
     CNS = CoordinateNeighborSearch(sys_coor)  # cache the KDTree for this selection/frame?
     found_indices = CNS.search_list(sel_coor, self.cutoff)
     res_atoms = [sys_atoms_list[i] for i in found_indices]  # make list numpy array and use fancy indexing?
     return set(res_atoms)
예제 #3
0
    def _apply_KDTree(self, group):
        """Selection using KDTree but periodic = True not supported.
        (KDTree routine is ca 15% slower than the distance matrix one)
        """
        sys_indices = numpy.array([a.number for a in self._group_atoms_list])
        sys_coor = Selection.coord[sys_indices]
        if self.periodic:
            pass  # or warn? -- no periodic functionality with KDTree search
        from MDAnalysis.KDTree.NeighborSearch import CoordinateNeighborSearch

        CNS = CoordinateNeighborSearch(
            sys_coor)  # cache the KDTree for this selection/frame?
        found_indices = CNS.search(self.ref, self.cutoff)
        res_atoms = [self._group_atoms_list[i] for i in found_indices
                     ]  # make list numpy array and use fancy indexing?
        return set(res_atoms)
예제 #4
0
    def _apply_KDTree(self, group):
        """Selection using KDTree but periodic = True not supported.
        (KDTree routine is ca 15% slower than the distance matrix one)
        """
        sys_indices = numpy.array([a.number for a in self._group_atoms_list])
        sys_coor = Selection.coord[sys_indices]
        sel_atoms = self.sel._apply(group)  # group is wrong, should be universe (?!)
        sel_CoG = AtomGroup(sel_atoms).centerOfGeometry()
        self.ref = numpy.array((sel_CoG[0], sel_CoG[1], sel_CoG[2]))
        if self.periodic:
            pass  # or warn? -- no periodic functionality with KDTree search
        from MDAnalysis.KDTree.NeighborSearch import CoordinateNeighborSearch

        CNS = CoordinateNeighborSearch(sys_coor)  # cache the KDTree for this selection/frame?
        found_ExtIndices = CNS.search(self.ref, self.exRadius)
        found_IntIndices = CNS.search(self.ref, self.inRadius)
        found_indices = list(set(found_ExtIndices) - set(found_IntIndices))
        res_atoms = [self._group_atoms_list[i] for i in found_indices]
        return set(res_atoms)
예제 #5
0
    def _apply_KDTree(self, group):
        """Selection using KDTree but periodic = True not supported.
        (KDTree routine is ca 15% slower than the distance matrix one)
        """
        sys_indices = numpy.array([a.number for a in self._group_atoms_list])
        sys_coor = Selection.coord[sys_indices]
        sel_atoms = self.sel._apply(
            group)  # group is wrong, should be universe (?!)
        sel_CoG = AtomGroup(sel_atoms).centerOfGeometry()
        self.ref = numpy.array((sel_CoG[0], sel_CoG[1], sel_CoG[2]))
        if self.periodic:
            pass  # or warn? -- no periodic functionality with KDTree search
        from MDAnalysis.KDTree.NeighborSearch import CoordinateNeighborSearch

        CNS = CoordinateNeighborSearch(
            sys_coor)  # cache the KDTree for this selection/frame?
        found_ExtIndices = CNS.search(self.ref, self.exRadius)
        found_IntIndices = CNS.search(self.ref, self.inRadius)
        found_indices = list(set(found_ExtIndices) - set(found_IntIndices))
        res_atoms = [self._group_atoms_list[i] for i in found_indices]
        return set(res_atoms)
예제 #6
0
 def _apply_KDTree(self, group):
     """KDTree based selection is about 7x faster than distmat for typical problems.
     Limitations: always ignores periodicity
     """
     sel_atoms = self.sel._apply(
         group)  # group is wrong, should be universe (?!)
     sys_atoms_list = [a for a in (self._group_atoms - sel_atoms)
                       ]  # list needed for back-indexing
     sel_indices = numpy.array([a.number for a in sel_atoms], dtype=int)
     sys_indices = numpy.array([a.number for a in sys_atoms_list],
                               dtype=int)
     sel_coor = Selection.coord[sel_indices]
     sys_coor = Selection.coord[sys_indices]
     from MDAnalysis.KDTree.NeighborSearch import CoordinateNeighborSearch
     # Can we optimize search by using the larger set for the tree?
     CNS = CoordinateNeighborSearch(
         sys_coor)  # cache the KDTree for this selection/frame?
     found_indices = CNS.search_list(sel_coor, self.cutoff)
     res_atoms = [sys_atoms_list[i] for i in found_indices
                  ]  # make list numpy array and use fancy indexing?
     return set(res_atoms)