Gets all placed neighbouring atoms of a atom.

@param  atom  central atom (Atom)
@param  ac    the molecule
@return       all connected and placed atoms to the central atom
((AtomContainer)
344614
public IAtomContainer getPlacedAtomsInAtomContainer(IAtom atom, IAtomContainer ac) {

        List bonds = ac.getConnectedBondsList(atom);
        IAtomContainer connectedAtoms = atom.getBuilder().newInstance(IAtomContainer.class);
        IAtom connectedAtom = null;
        for (int i = 0; i < bonds.size(); i++) {
            connectedAtom = ((IBond) bonds.get(i)).getOther(atom);
            if (connectedAtom.getFlag(CDKConstants.ISPLACED)) {
                connectedAtoms.addAtom(connectedAtom);
            }
        }
        return connectedAtoms;
    }
1250641
public static List<QueryConnectedComponent> getConnectedComponents(ClassifiedTBox reasoner, CQIE cqie,
																	   AtomFactory atomFactory,
																	   ImmutabilityTools immutabilityTools) {

		Set<Term> headTerms = new HashSet<>(cqie.getHead().getTerms());

		// collect all edges and loops 
		//      an edge is a binary predicate P(t, t') with t \ne t'
		// 		a loop is either a unary predicate A(t) or a binary predicate P(t,t)
		//      a nonDL atom is an atom with a non-data predicate 
		Map<TermPair, Edge> pairs = new HashMap<>();
		Map<Term, Loop> allLoops = new HashMap<>();
		List<Function> nonDLAtoms = new LinkedList<>();
		
		for (Function atom : cqie.getBody()) {
			Predicate p = atom.getFunctionSymbol();
			// TODO: support quads
			if (atom.isDataFunction() && (p instanceof TriplePredicate)) { // if DL predicates
				Function a = getCanonicalForm(reasoner, atom, atomFactory, immutabilityTools);
				Term t0 = a.getTerm(0);

				ImmutableList<ImmutableTerm> arguments = a.getTerms().stream()
						.map(immutabilityTools::convertIntoImmutableTerm)
						.collect(ImmutableCollectors.toList());
				boolean isClass = ((TriplePredicate) p).getClassIRI(arguments).isPresent();

				if ((!isClass) && !t0.equals(a.getTerm(2))) {
					// proper DL edge between two distinct terms
					Term t1 = a.getTerm(2);
					TermPair pair = new TermPair(t0, t1);
					Edge edge =  pairs.get(pair); 
					if (edge == null) {
						Loop l0 = getLoop(t0, allLoops, headTerms);
						Loop l1 = getLoop(t1, allLoops, headTerms);
						edge = new Edge(l0, l1);
						pairs.put(pair, edge);
					}
					edge.bAtoms.add(a);			
				}
				else {
					Loop l0 = getLoop(t0, allLoops, headTerms);
					l0.atoms.add(a);
				}
			}
			else { // non-DL precicate
				//log.debug("NON-DL ATOM {}",  a);
				nonDLAtoms.add(atom);
			}
		}	

		
		List<QueryConnectedComponent> ccs = new LinkedList<>();
		
		// form the list of connected components from the list of edges
		while (!pairs.isEmpty()) {
			Edge edge = pairs.entrySet().iterator().next().getValue();			
			ccs.add(getConnectedComponent(pairs, allLoops, nonDLAtoms, edge.getTerm0()));			
		}
		
		while (!nonDLAtoms.isEmpty()) {
			//log.debug("NON-DL ATOMS ARE NOT EMPTY: {}", nonDLAtoms);
			Function f = nonDLAtoms.iterator().next(); 
			Set<Variable> vars = new HashSet<>();
			TermUtils.addReferencedVariablesTo(vars, f);
			Variable v = vars.iterator().next();
			ccs.add(getConnectedComponent(pairs, allLoops, nonDLAtoms, v));			
		}

		// create degenerate connected components for all remaining loops (which are disconnected from anything else)
		//for (Entry<term, Loop> loop : allLoops.entrySet()) {
		while (!allLoops.isEmpty()) {
			Term seed = allLoops.keySet().iterator().next();
			ccs.add(getConnectedComponent(pairs, allLoops, nonDLAtoms, seed));			
			//ccs.add(new QueryConnectedComponent(Collections.EMPTY_LIST, loop.getValue(), Collections.EMPTY_LIST, Collections.singletonList(loop.getValue())));
		}
				
		return ccs;
	}
318945
public IAtom getUnplacedRingHeavyAtom(IAtomContainer molecule, IAtom atom) {
        List<IBond> bonds = molecule.getConnectedBondsList(atom);
        IAtom connectedAtom = null;
        for (IBond bond : bonds) {
            connectedAtom = bond.getOther(atom);
            if (isUnplacedHeavyAtom(connectedAtom) && connectedAtom.getFlag(CDKConstants.ISINRING)) {
                return connectedAtom;
            }
        }
        return connectedAtom;
    }
1191855
private int getDoubleBondedOxygenCount(IAtomContainer ac, IAtom atom) {
        List<IAtom> neighbours = ac.getConnectedAtomsList(atom);
        IBond bond;
        int odbcounter = 0;
        boolean chargeFlag = false;
        if (atom.getFormalCharge() >= 1) {
            chargeFlag = true;
        }
        for (IAtom neighbour : neighbours) {
            if (neighbour.getSymbol().equals("O")) {
                bond = ac.getBond(neighbour, atom);
                if (chargeFlag && neighbour.getFormalCharge() == -1 && bond.getOrder() == IBond.Order.SINGLE) {
                    odbcounter += 1;
                }
                if (!neighbour.getFlag(CDKConstants.ISAROMATIC)) {
                    if (bond.getOrder() == IBond.Order.DOUBLE) {
                        odbcounter += 1;
                    }
                }
            }
        }
        return odbcounter;
    }
1354257
private int getAromaticCarbonsCount(IAtomContainer ac, IAtom atom) {
        List<IAtom> neighbours = ac.getConnectedAtomsList(atom);
        int carocounter = 0;
        for (IAtom neighbour : neighbours) {
            if (neighbour.getSymbol().equals("C") && neighbour.getFlag(CDKConstants.ISAROMATIC)) {
                carocounter += 1;
            }
        }
        return carocounter;
    }
721173
public boolean contains(IAtom atom) {
        for (int i = 0; i < atomCount; i++) {
            if (atoms[i].equals(atom)) {
                return true;
            }
        }
        return false;
    }
1105993
public static final Atom[] getAllNonHAtomArray(Structure s, boolean hetAtoms) {
		AtomIterator iter = new AtomIterator(s);
		return getAllNonHAtomArray(s, hetAtoms, iter);
	}
800816
@Override
    public boolean isConnectedTo(IBond bond) {
        for (IAtom atom : atoms) {
            if (bond.contains(atom)) return true;
        }
        return false;
    }
1159475
public static Rectangle2D calculateBounds(IAtomContainer atomContainer) {
        // this is essential, otherwise a rectangle
        // of (+INF, -INF, +INF, -INF) is returned!
        if (atomContainer.getAtomCount() == 0) {
            return new Rectangle2D.Double();
        } else if (atomContainer.getAtomCount() == 1) {
            Point2d point = atomContainer.getAtom(0).getPoint2d();
            if (point == null) {
                throw new IllegalArgumentException("Cannot calculate bounds when 2D coordinates are missing.");
            }
            return new Rectangle2D.Double(point.x, point.y, 0, 0);
        }

        double xmin = Double.POSITIVE_INFINITY;
        double xmax = Double.NEGATIVE_INFINITY;
        double ymin = Double.POSITIVE_INFINITY;
        double ymax = Double.NEGATIVE_INFINITY;

        for (IAtom atom : atomContainer.atoms()) {
            Point2d point = atom.getPoint2d();
            if (point == null) {
                throw new IllegalArgumentException("Cannot calculate bounds when 2D coordinates are missing.");
            }
            xmin = Math.min(xmin, point.x);
            xmax = Math.max(xmax, point.x);
            ymin = Math.min(ymin, point.y);
            ymax = Math.max(ymax, point.y);
        }
        double width = xmax - xmin;
        double height = ymax - ymin;
        return new Rectangle2D.Double(xmin, ymin, width, height);
    }
624907
public AtomContact getContact(Atom atom1, Atom atom2) {
		return contacts.get(new Pair<AtomIdentifier>(
				new AtomIdentifier(atom1.getPDBserial(),atom1.getGroup().getChainId()),
				new AtomIdentifier(atom2.getPDBserial(),atom2.getGroup().getChainId()) ));
	}
228239
def neighbor_atoms(self, atom_symbol=None):
        
        if not atom_symbol:
            return self.neighbors
        else:
            return [atom for atom in self.neighbors if atom['atom_symbol'] == atom_symbol]
579678
public static final Atom[] getAllNonHAtomArray(Chain c, boolean hetAtoms) {
		List<Atom> atoms = new ArrayList<Atom>();

		for (Group g : c.getAtomGroups()) {
			if (g.isWater())
				continue;
			for (Atom a : g.getAtoms()) {

				if (a.getElement() == Element.H)
					continue;

				if (!hetAtoms && g.getType().equals(GroupType.HETATM))
					continue;

				atoms.add(a);
			}
		}
		return atoms.toArray(new Atom[atoms.size()]);
	}
37133
private int getAtomTypeXCount(IAtomContainer ac, IAtom atom) {
        List<IAtom> neighbours = ac.getConnectedAtomsList(atom);
        int nocounter = 0;
        IBond bond;
        for (IAtom neighbour : neighbours) {
            if ((neighbour.getSymbol().equals("N") || neighbour.getSymbol().equals("O"))
                    && !(Boolean) neighbour.getProperty("IS_IN_AROMATIC_RING")) {
                //if (ac.getMaximumBondOrder(neighbours[i]) == 1.0) {
                bond = ac.getBond(neighbour, atom);
                if (bond.getOrder() != IBond.Order.DOUBLE) {
                    nocounter += 1;
                }
            }
        }
        return nocounter;
    }
740035
private int getConnectivity(IAtom atom, IAtomContainer container) {
        int connectivity = 0;
        for (IBond bond : container.bonds()) {
            if (bond.contains(atom)) {
                switch (bond.getOrder()) {
                    case SINGLE:
                        connectivity++;
                        break;
                    case DOUBLE:
                        connectivity += 2;
                        break;
                    case TRIPLE:
                        connectivity += 3;
                        break;
                    case QUADRUPLE:
                        connectivity += 4;
                        break;
                    default:
                        connectivity += 10;
                }
            }
        }
        return connectivity;
    }
108687
public static IAtom getAtomById(IAtomContainer ac, String id) throws CDKException {
        for (int i = 0; i < ac.getAtomCount(); i++) {
            if (ac.getAtom(i).getID() != null && ac.getAtom(i).getID().equals(id)) return ac.getAtom(i);
        }
        throw new CDKException("no suc atom");
    }
465595
@Override
    public boolean contains(IAtom atom) {
        if (atoms == null) return false;
        for (IAtom localAtom : atoms) {
            if (localAtom.equals(atom)) return true;
        }
        return false;
    }
1120796
protected static IAtomContainer makeAtomContainer(IAtom atom, List<IBond> parts, IAtom excludedAtom) {
        IAtomContainer partContainer = atom.getBuilder().newInstance(IAtomContainer.class);
        partContainer.addAtom(atom);
        for (IBond aBond : parts) {
            for (IAtom bondedAtom : aBond.atoms()) {
                if (!bondedAtom.equals(excludedAtom) && !partContainer.contains(bondedAtom))
                    partContainer.addAtom(bondedAtom);
            }
            if (!aBond.contains(excludedAtom)) partContainer.addBond(aBond);
        }
        return partContainer;
    }