Returns all atoms in AMPAL object within `cut-off` distance from the `point`.
13963
def is_within(self, cutoff_dist, point, ligands=True):
        """"""
        return find_atoms_within_distance(self.get_atoms(ligands=ligands), cutoff_dist, point)
75088
public List<AtomContact> getContactsWithinDistance(double distance) {

		if (distance>=cutoff)
			throw new IllegalArgumentException("Given distance "+
					String.format("%.2f", distance)+" is larger than contacts' distance cutoff "+
					String.format("%.2f", cutoff));

		List<AtomContact> list = new ArrayList<AtomContact>();
		for (AtomContact contact:this.contacts.values()) {
			if (contact.getDistance()<distance) {
				list.add(contact);
			}
		}
		return list;
	}
638042
def central_vertices(self):
        """"""
        max_distances = self.distances.max(0)
        max_distances_min = max_distances[max_distances > 0].min()
        return (max_distances == max_distances_min).nonzero()[0]
816307
def _get_facet_chempots(self, facet):
        
        complist = [self.qhull_entries[i].composition for i in facet]
        energylist = [self.qhull_entries[i].energy_per_atom for i in facet]
        m = [[c.get_atomic_fraction(e) for e in self.elements] for c in
             complist]
        chempots = np.linalg.solve(m, energylist)
        return dict(zip(self.elements, chempots))
1072045
def points(self, size=1.0, highlight=None, colorlist=None, opacity=1.0):
        
        if colorlist is None:
            colorlist = [get_atom_color(t) for t in self.topology['atom_types']]
        if highlight is not None:
            if isinstance(highlight, int):
                colorlist[highlight] = 0xff0000
            if isinstance(highlight, (list, np.ndarray)):
                for i in highlight:
                    colorlist[i] = 0xff0000

        sizes = [size] * len(self.topology['atom_types'])

        points = self.add_representation('points', {'coordinates': self.coordinates.astype('float32'),
                                                    'colors': colorlist,
                                                    'sizes': sizes,
                                                    'opacity': opacity})
        # Update closure
        def update(self=self, points=points):
            self.update_representation(points, {'coordinates': self.coordinates.astype('float32')})

        self.update_callbacks.append(update)
        self.autozoom(self.coordinates)
432318
private static final double getEnd2EndDistance(Atom[] ca1, Atom[] ca2, int p1b, int p1e, int p2b, int p2e)
	{

		double min = 99;
			double dist1 = Calc.getDistance(ca1[p1b], ca1[p1e]);
			double dist2 = Calc.getDistance(ca2[p2b], ca2[p2e]);
			min = dist1 - dist2;

		return Math.abs(min);
	}
308190
def find_the_closest_atoms(self,topology):
        

        # The measurements are made to ligand molecule without hydrogen atoms (ligand_noH) because the
        # hydrogen atoms are not plotted in the final graph
        self.universe.load_new(topology)
        self.universe.ligand_noH = self.universe.ligand.select_atoms("not name H*")
        ligand_positions = self.universe.ligand_noH.positions

        for residue in self.dict_of_plotted_res.keys():
            residue_selection = self.universe.select_atoms("resname "+residue[0]+" and resid "+residue[1]+" and segid "+ residue[2])
            residue_positions = residue_selection.positions
            dist_array = MDAnalysis.analysis.distances.distance_array(ligand_positions,residue_positions)
            min_values_per_atom={}
            i=0
            for atom in self.universe.ligand_noH:
                min_values_per_atom[atom.name]=dist_array[i].min()
                i+=1
            sorted_min_values = sorted(min_values_per_atom.items(), key=operator.itemgetter(1))
            self.closest_atoms[residue]=[(sorted_min_values[0][0],sorted_min_values[0][1])]
574604
def get_distance_to(self, origin=None, other_atoms=None, sort=False):
        
        if origin is None:
            origin = np.zeros(3)
        elif pd.api.types.is_list_like(origin):
            origin = np.array(origin, dtype='f8')
        else:
            origin = self.loc[origin, ['x', 'y', 'z']]

        if other_atoms is None:
            other_atoms = self.index

        new = self.loc[other_atoms, :].copy()
        norm = np.linalg.norm
        try:
            new['distance'] = norm((new - origin).loc[:, ['x', 'y', 'z']],
                                   axis=1)
        except AttributeError:
            # Happens if molecule consists of only one atom
            new['distance'] = norm((new - origin).loc[:, ['x', 'y', 'z']])
        if sort:
            new.sort_values(by='distance', inplace=True)
        return new
1110894
def get_atoms(self, inc_alt_states=False):
        
        if inc_alt_states:
            return itertools.chain(*[x[1].values() for x in sorted(list(self.states.items()))])
        return self.atoms.values()
78708
def distance_to(atom)
		Math.sqrt((self.x - atom.x)**2 + (self.y - atom.y)**2 + (self.z - atom.z)**2)
	end
694626
def within(self, x, ctrs, kdtree=None):
        """"""

        if kdtree is None:
            # If no KDTree is provided, execute a brute-force search
            # over all cubes.
            idxs = np.where(np.max(np.abs(ctrs - x), axis=1) <= self.hside)[0]
        else:
            # If a KDTree is provided, find all points within r (`hside`).
            idxs = kdtree.query_ball_point(x, self.hside, p=np.inf, eps=0)

        return idxs
525667
def select_atoms(indices):
    '''

    '''
    rep = current_representation()
    rep.select({'atoms': Selection(indices, current_system().n_atoms)})
    return rep.selection_state
819792
def centers_list(self):
        
        center = set()
        adj = defaultdict(set)
        for n, atom in self.atoms():
            if atom._reactant != atom._product:
                center.add(n)

        for n, m, bond in self.bonds():
            if bond._reactant != bond._product:
                adj[n].add(m)
                adj[m].add(n)
                center.add(n)
                center.add(m)

        out = []
        while center:
            n = center.pop()
            if n in adj:
                c = set(self.__plain_bfs(adj, n))
                out.append(list(c))
                center.difference_update(c)
            else:
                out.append([n])

        return out
934394
def atoms_order(self):
        
        if not len(self):  # for empty containers
            return {}
        elif len(self) == 1:  # optimize single atom containers
            return dict.fromkeys(self, 2)

        params = {n: (int(node), tuple(sorted(int(edge) for edge in self._adj[n].values())))
                  for n, node in self.atoms()}
        newlevels = {}
        countprime = iter(primes)
        weights = {x: newlevels.get(y) or newlevels.setdefault(y, next(countprime))
                   for x, y in sorted(params.items(), key=itemgetter(1))}

        tries = len(self) * 4

        numb = len(set(weights.values()))
        stab = 0

        while tries:
            oldnumb = numb
            neweights = {}
            countprime = iter(primes)

            # weights[n] ** 2 NEED for differentiation of molecules like A-B or any other complete graphs.
            tmp = {n: reduce(mul, (weights[x] for x in m), weights[n] ** 2) for n, m in self._adj.items()}

            weights = {x: (neweights.get(y) or neweights.setdefault(y, next(countprime)))
                       for x, y in sorted(tmp.items(), key=itemgetter(1))}

            numb = len(set(weights.values()))
            if numb == len(self):  # each atom now unique
                break
            elif numb == oldnumb:
                x = Counter(weights.values())
                if x[min(x)] > 1:
                    if stab == 3:
                        break
                elif stab >= 2:
                    break

                stab += 1
            elif stab:
                stab = 0

            tries -= 1
            if not tries and numb < oldnumb:
                warning('morgan. number of attempts exceeded. uniqueness has decreased. next attempt will be made')
                tries = 1
        else:
            warning('morgan. number of attempts exceeded')

        return weights
355607
def bounds(self, vertices):
        
        if util.is_shape(vertices, (-1, 2)) and self.closed:
            # if we have a closed arc (a circle), we can return the actual bounds
            # this only works in two dimensions, otherwise this would return the
            # AABB of an sphere
            info = self.center(vertices)
            bounds = np.array([info['center'] - info['radius'],
                               info['center'] + info['radius']],
                              dtype=np.float64)
        else:
            # since the AABB of a partial arc is hard, approximate
            # the bounds by just looking at the discrete values
            discrete = self.discrete(vertices)
            bounds = np.array([discrete.min(axis=0),
                               discrete.max(axis=0)],
                              dtype=np.float64)
        return bounds
1089058
def example():
    ''''''

    # 1a8d is an example from the loops benchmark
    # 1lfa contains hydrogens
    b = Bonsai.retrieve('1lfa', cache_dir='/tmp')
    search_radius = 10.0

    atom_of_interest = b.get_atom(1095)
    nearby_atoms = b.find_atoms_near_atom(atom_of_interest, search_radius)
    for na in nearby_atoms:
        assert(na - atom_of_interest <= search_radius)
    for fa in b.get_atom_set_complement(nearby_atoms):
        assert(fa - atom_of_interest > search_radius)

    # Get all heavy atoms within the radius (including HETATM)
    nearby_heavy_atoms = b.find_heavy_atoms_near_atom(atom_of_interest, search_radius)

    # Get all C-alpha atoms within the radius
    nearby_ca_atoms = b.find_atoms_near_atom(atom_of_interest, search_radius, atom_names_to_include = ['CA'])

    # Get all carbon atoms within the radius
    nearby_c_atoms = b.find_atoms_near_atom(atom_of_interest, search_radius, atom_names_to_include = b.get_atom_names_by_group(['C']))
796143
public IAtom getFarthestAtom(Point3d refAtomPoint, IAtomContainer ac) {
        double distance = 0;
        IAtom atom = null;
        for (int i = 0; i < ac.getAtomCount(); i++) {
            if (ac.getAtom(i).getPoint3d() != null) {
                if (Math.abs(refAtomPoint.distance(ac.getAtom(i).getPoint3d())) > distance) {
                    atom = ac.getAtom(i);
                    distance = Math.abs(refAtomPoint.distance(ac.getAtom(i).getPoint3d()));
                }
            }
        }
        return atom;
    }